appium-remote-debugger 15.7.3 → 15.8.1
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 +27 -28
- package/build/lib/atoms.js.map +1 -1
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/index.js +7 -0
- package/build/lib/index.js.map +1 -1
- package/build/lib/mixins/connect.d.ts.map +1 -1
- package/build/lib/mixins/connect.js +21 -25
- package/build/lib/mixins/connect.js.map +1 -1
- package/build/lib/mixins/execute.d.ts.map +1 -1
- package/build/lib/mixins/execute.js +2 -8
- 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 +8 -12
- 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 +5 -39
- 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 +20 -55
- package/build/lib/mixins/navigate.js.map +1 -1
- package/build/lib/mixins/property-accessors.d.ts +24 -0
- package/build/lib/mixins/property-accessors.d.ts.map +1 -1
- package/build/lib/mixins/property-accessors.js +24 -0
- package/build/lib/mixins/property-accessors.js.map +1 -1
- package/build/lib/remote-debugger.d.ts +38 -38
- package/build/lib/remote-debugger.d.ts.map +1 -1
- package/build/lib/remote-debugger.js +64 -69
- package/build/lib/remote-debugger.js.map +1 -1
- package/build/lib/rpc/remote-messages.d.ts.map +1 -1
- package/build/lib/rpc/remote-messages.js +7 -8
- package/build/lib/rpc/remote-messages.js.map +1 -1
- package/build/lib/rpc/rpc-client-real-device-shim.d.ts.map +1 -1
- package/build/lib/rpc/rpc-client-real-device-shim.js +3 -6
- package/build/lib/rpc/rpc-client-real-device-shim.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 -5
- package/build/lib/rpc/rpc-client-simulator.js.map +1 -1
- package/build/lib/rpc/rpc-client.d.ts +27 -27
- package/build/lib/rpc/rpc-client.d.ts.map +1 -1
- package/build/lib/rpc/rpc-client.js +226 -224
- package/build/lib/rpc/rpc-client.js.map +1 -1
- package/build/lib/rpc/rpc-message-handler.js +7 -10
- package/build/lib/rpc/rpc-message-handler.js.map +1 -1
- package/build/lib/types.d.ts +19 -19
- package/build/lib/types.d.ts.map +1 -1
- package/build/lib/utils.d.ts +77 -8
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +197 -29
- package/build/lib/utils.js.map +1 -1
- package/lib/atoms.ts +31 -32
- package/lib/index.ts +7 -0
- package/lib/mixins/connect.ts +22 -23
- package/lib/mixins/execute.ts +3 -5
- package/lib/mixins/message-handlers.ts +9 -10
- package/lib/mixins/misc.ts +8 -7
- package/lib/mixins/navigate.ts +58 -63
- package/lib/mixins/property-accessors.ts +24 -0
- package/lib/remote-debugger.ts +74 -76
- package/lib/rpc/remote-messages.ts +10 -5
- package/lib/rpc/rpc-client-real-device-shim.ts +3 -3
- package/lib/rpc/rpc-client-simulator.ts +3 -5
- package/lib/rpc/rpc-client.ts +259 -247
- package/lib/rpc/rpc-message-handler.ts +7 -7
- package/lib/types.ts +24 -24
- package/lib/utils.ts +205 -29
- package/package.json +3 -7
- package/scripts/common.mjs +42 -37
- package/scripts/web_inspector_proxy.mjs +3 -5
package/lib/remote-debugger.ts
CHANGED
|
@@ -10,50 +10,16 @@ import * as cookieMixins from './mixins/cookies';
|
|
|
10
10
|
import * as screenshotMixins from './mixins/screenshot';
|
|
11
11
|
import * as eventMixins from './mixins/events';
|
|
12
12
|
import * as miscellaneousMixins from './mixins/misc';
|
|
13
|
-
import
|
|
13
|
+
import {util} from '@appium/support';
|
|
14
14
|
import type {RemoteDebuggerOptions, AppDict, EventListener, PageIdKey, AppIdKey} from './types';
|
|
15
15
|
import type {AppiumLogger, StringRecord} from '@appium/types';
|
|
16
16
|
import type {RpcClient} from './rpc/rpc-client';
|
|
17
|
-
import type B from 'bluebird';
|
|
18
17
|
|
|
19
18
|
export const REMOTE_DEBUGGER_PORT = 27753;
|
|
20
19
|
const PAGE_READY_TIMEOUT_MS = 5000;
|
|
21
20
|
const {version: MODULE_VERSION} = getModuleProperties();
|
|
22
21
|
|
|
23
22
|
export class RemoteDebugger extends EventEmitter {
|
|
24
|
-
protected _skippedApps: string[];
|
|
25
|
-
protected _clientEventListeners: StringRecord<EventListener[]>;
|
|
26
|
-
protected _appDict: AppDict;
|
|
27
|
-
protected _appIdKey?: AppIdKey;
|
|
28
|
-
protected _pageIdKey?: PageIdKey;
|
|
29
|
-
protected _connectedDrivers?: StringRecord[];
|
|
30
|
-
protected _currentState?: string;
|
|
31
|
-
protected _pageLoadDelay?: B<void>;
|
|
32
|
-
protected _rpcClient: RpcClient | null;
|
|
33
|
-
protected _pageLoading: boolean;
|
|
34
|
-
protected _navigatingToPage: boolean;
|
|
35
|
-
protected _allowNavigationWithoutReload: boolean;
|
|
36
|
-
protected _pageLoadMs?: number;
|
|
37
|
-
protected readonly _pageLoadStrategy?: string;
|
|
38
|
-
protected readonly _log: AppiumLogger;
|
|
39
|
-
protected readonly _bundleId?: string;
|
|
40
|
-
protected readonly _additionalBundleIds?: string[];
|
|
41
|
-
protected readonly _ignoredBundleIds?: string[];
|
|
42
|
-
protected readonly _platformVersion?: string;
|
|
43
|
-
protected readonly _isSafari: boolean;
|
|
44
|
-
protected readonly _includeSafari: boolean;
|
|
45
|
-
protected readonly _garbageCollectOnExecute: boolean;
|
|
46
|
-
protected readonly _host?: string;
|
|
47
|
-
protected readonly _port?: number;
|
|
48
|
-
protected readonly _socketPath?: string;
|
|
49
|
-
protected readonly _remoteDebugProxy?: any;
|
|
50
|
-
protected readonly _pageReadyTimeout: number;
|
|
51
|
-
protected readonly _logAllCommunication: boolean;
|
|
52
|
-
protected readonly _logAllCommunicationHexDump: boolean;
|
|
53
|
-
protected readonly _socketChunkSize?: number;
|
|
54
|
-
protected readonly _webInspectorMaxFrameLength?: number;
|
|
55
|
-
protected readonly _fullPageInitialization?: boolean;
|
|
56
|
-
|
|
57
23
|
// events
|
|
58
24
|
static readonly EVENT_PAGE_CHANGE: string;
|
|
59
25
|
static readonly EVENT_DISCONNECT: string;
|
|
@@ -90,7 +56,7 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
90
56
|
garbageCollect = miscellaneousMixins.garbageCollect;
|
|
91
57
|
isJavascriptExecutionBlocked = miscellaneousMixins.isJavascriptExecutionBlocked;
|
|
92
58
|
|
|
93
|
-
//
|
|
59
|
+
// callbacks
|
|
94
60
|
onPageChange = messageHandlerMixins.onPageChange;
|
|
95
61
|
onConnectedApplicationList = messageHandlerMixins.onConnectedApplicationList;
|
|
96
62
|
onAppConnect = messageHandlerMixins.onAppConnect;
|
|
@@ -100,6 +66,39 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
100
66
|
onCurrentState = messageHandlerMixins.onCurrentState;
|
|
101
67
|
frameDetached = navigationMixins.frameDetached;
|
|
102
68
|
|
|
69
|
+
protected _skippedApps: string[];
|
|
70
|
+
protected _clientEventListeners: StringRecord<EventListener[]>;
|
|
71
|
+
protected _appDict: AppDict;
|
|
72
|
+
protected _appIdKey?: AppIdKey;
|
|
73
|
+
protected _pageIdKey?: PageIdKey;
|
|
74
|
+
protected _connectedDrivers?: StringRecord[];
|
|
75
|
+
protected _currentState?: string;
|
|
76
|
+
protected _pageLoadDelay?: ReturnType<typeof util.cancellableDelay>;
|
|
77
|
+
protected _rpcClient: RpcClient | null;
|
|
78
|
+
protected _pageLoading: boolean;
|
|
79
|
+
protected _navigatingToPage: boolean;
|
|
80
|
+
protected _allowNavigationWithoutReload: boolean;
|
|
81
|
+
protected _pageLoadMs?: number;
|
|
82
|
+
protected readonly _pageLoadStrategy?: string;
|
|
83
|
+
protected readonly _log: AppiumLogger;
|
|
84
|
+
protected readonly _bundleId?: string;
|
|
85
|
+
protected readonly _additionalBundleIds?: string[];
|
|
86
|
+
protected readonly _ignoredBundleIds?: string[];
|
|
87
|
+
protected readonly _platformVersion?: string;
|
|
88
|
+
protected readonly _isSafari: boolean;
|
|
89
|
+
protected readonly _includeSafari: boolean;
|
|
90
|
+
protected readonly _garbageCollectOnExecute: boolean;
|
|
91
|
+
protected readonly _host?: string;
|
|
92
|
+
protected readonly _port?: number;
|
|
93
|
+
protected readonly _socketPath?: string;
|
|
94
|
+
protected readonly _remoteDebugProxy?: any;
|
|
95
|
+
protected readonly _pageReadyTimeout: number;
|
|
96
|
+
protected readonly _logAllCommunication: boolean;
|
|
97
|
+
protected readonly _logAllCommunicationHexDump: boolean;
|
|
98
|
+
protected readonly _socketChunkSize?: number;
|
|
99
|
+
protected readonly _webInspectorMaxFrameLength?: number;
|
|
100
|
+
protected readonly _fullPageInitialization?: boolean;
|
|
101
|
+
|
|
103
102
|
constructor(opts: RemoteDebuggerOptions = {}) {
|
|
104
103
|
super();
|
|
105
104
|
|
|
@@ -146,13 +145,12 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
146
145
|
this._remoteDebugProxy = remoteDebugProxy;
|
|
147
146
|
this._pageReadyTimeout = pageReadyTimeout;
|
|
148
147
|
|
|
149
|
-
this._logAllCommunication =
|
|
150
|
-
? !!logFullResponse
|
|
151
|
-
: !!logAllCommunication;
|
|
148
|
+
this._logAllCommunication =
|
|
149
|
+
logAllCommunication == null ? !!logFullResponse : !!logAllCommunication;
|
|
152
150
|
this._logAllCommunicationHexDump = logAllCommunicationHexDump;
|
|
153
151
|
this._socketChunkSize = socketChunkSize;
|
|
154
152
|
|
|
155
|
-
if (
|
|
153
|
+
if (Number.isInteger(webInspectorMaxFrameLength)) {
|
|
156
154
|
this._webInspectorMaxFrameLength = webInspectorMaxFrameLength;
|
|
157
155
|
}
|
|
158
156
|
|
|
@@ -168,6 +166,41 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
168
166
|
return this._log;
|
|
169
167
|
}
|
|
170
168
|
|
|
169
|
+
get isConnected(): boolean {
|
|
170
|
+
return !!this._rpcClient?.isConnected;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Only use this getter to read the appDict value.
|
|
174
|
+
// Any changes to it don't mutate the original property
|
|
175
|
+
// because the getter always returns the copy of it
|
|
176
|
+
get appDict(): AppDict {
|
|
177
|
+
return structuredClone(this._appDict);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
get allowNavigationWithoutReload(): boolean {
|
|
181
|
+
return !!this._allowNavigationWithoutReload;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
get currentState(): string | undefined {
|
|
185
|
+
return this._currentState;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
get connectedDrivers(): StringRecord[] | undefined {
|
|
189
|
+
return this._connectedDrivers;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
get pageLoadMs(): number {
|
|
193
|
+
return this._pageLoadMs ?? navigationMixins.DEFAULT_PAGE_READINESS_TIMEOUT_MS;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
set allowNavigationWithoutReload(allow: boolean) {
|
|
197
|
+
this._allowNavigationWithoutReload = allow;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
set pageLoadMs(value: number) {
|
|
201
|
+
this._pageLoadMs = value;
|
|
202
|
+
}
|
|
203
|
+
|
|
171
204
|
requireRpcClient(checkConnected: boolean = false): RpcClient {
|
|
172
205
|
if (!this._rpcClient) {
|
|
173
206
|
throw new Error(`rpcClient is undefined. Has 'initRpcClient' been called before?`);
|
|
@@ -228,44 +261,9 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
228
261
|
pageLoadTimeoutMs: this._pageLoadMs,
|
|
229
262
|
});
|
|
230
263
|
}
|
|
231
|
-
|
|
232
|
-
get isConnected(): boolean {
|
|
233
|
-
return !!this._rpcClient?.isConnected;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// Only use this getter to read the appDict value.
|
|
237
|
-
// Any changes to it don't mutate the original property
|
|
238
|
-
// because the getter always returns the copy of it
|
|
239
|
-
get appDict(): AppDict {
|
|
240
|
-
return _.cloneDeep(this._appDict);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
set allowNavigationWithoutReload(allow: boolean) {
|
|
244
|
-
this._allowNavigationWithoutReload = allow;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
get allowNavigationWithoutReload(): boolean {
|
|
248
|
-
return !!this._allowNavigationWithoutReload;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
get currentState(): string | undefined {
|
|
252
|
-
return this._currentState;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
get connectedDrivers(): StringRecord[] | undefined {
|
|
256
|
-
return this._connectedDrivers;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
get pageLoadMs(): number {
|
|
260
|
-
return this._pageLoadMs ?? navigationMixins.DEFAULT_PAGE_READINESS_TIMEOUT_MS;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
set pageLoadMs(value: number) {
|
|
264
|
-
this._pageLoadMs = value;
|
|
265
|
-
}
|
|
266
264
|
}
|
|
267
265
|
|
|
268
|
-
for (const [name, event] of
|
|
266
|
+
for (const [name, event] of Object.entries(eventMixins.events)) {
|
|
269
267
|
RemoteDebugger[name] = event;
|
|
270
268
|
}
|
|
271
269
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
1
|
import {getProtocolCommand} from '../protocol';
|
|
3
2
|
import type {
|
|
4
3
|
RawRemoteCommand,
|
|
@@ -15,6 +14,12 @@ const MINIMAL_COMMAND = 'getMinimalCommand';
|
|
|
15
14
|
const FULL_COMMAND = 'getFullCommand';
|
|
16
15
|
const DIRECT_COMMAND = 'getDirectCommand';
|
|
17
16
|
|
|
17
|
+
function omitNilValues<T extends Record<string, any>>(obj: T): Partial<T> {
|
|
18
|
+
return Object.fromEntries(
|
|
19
|
+
Object.entries(obj).filter(([, value]) => value !== null && value !== undefined),
|
|
20
|
+
) as Partial<T>;
|
|
21
|
+
}
|
|
22
|
+
|
|
18
23
|
// mapping of commands to the function for getting the command
|
|
19
24
|
// defaults to `getMinimalCommand`, so no need to have those listed here
|
|
20
25
|
const COMMANDS = {
|
|
@@ -117,7 +122,7 @@ export class RemoteMessages {
|
|
|
117
122
|
return {
|
|
118
123
|
__argument: {
|
|
119
124
|
WIRApplicationIdentifierKey: appIdKey,
|
|
120
|
-
WIRIndicateEnabledKey:
|
|
125
|
+
WIRIndicateEnabledKey: enabled == null ? true : enabled,
|
|
121
126
|
WIRConnectionIdentifierKey: connId,
|
|
122
127
|
WIRPageIdentifierKey: pageIdKey,
|
|
123
128
|
},
|
|
@@ -191,7 +196,7 @@ export class RemoteMessages {
|
|
|
191
196
|
},
|
|
192
197
|
__selector: '_rpc_forwardSocketData:',
|
|
193
198
|
};
|
|
194
|
-
return
|
|
199
|
+
return omitNilValues(plist) as RawRemoteCommand;
|
|
195
200
|
}
|
|
196
201
|
|
|
197
202
|
/**
|
|
@@ -227,7 +232,7 @@ export class RemoteMessages {
|
|
|
227
232
|
},
|
|
228
233
|
__selector: '_rpc_forwardSocketData:',
|
|
229
234
|
};
|
|
230
|
-
return
|
|
235
|
+
return omitNilValues(plist) as RawRemoteCommand;
|
|
231
236
|
}
|
|
232
237
|
|
|
233
238
|
/**
|
|
@@ -254,7 +259,7 @@ export class RemoteMessages {
|
|
|
254
259
|
},
|
|
255
260
|
__selector: '_rpc_forwardSocketData:',
|
|
256
261
|
};
|
|
257
|
-
return
|
|
262
|
+
return omitNilValues(plist) as RawRemoteCommand;
|
|
258
263
|
}
|
|
259
264
|
|
|
260
265
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {log} from '../logger';
|
|
2
|
+
import {isPlainObject} from '../utils';
|
|
2
3
|
import {RpcClient} from './rpc-client';
|
|
3
4
|
import type {RemoteCommand, RpcClientOptions} from '../types';
|
|
4
5
|
import type {StringRecord} from '@appium/types';
|
|
5
6
|
import type {WebInspectorService, RemoteXpcConnection} from 'appium-ios-remotexpc';
|
|
6
|
-
import _ from 'lodash';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Options specific to RpcClientRealDeviceShim.
|
|
@@ -190,7 +190,7 @@ export class RpcClientRealDeviceShim extends RpcClient {
|
|
|
190
190
|
};
|
|
191
191
|
|
|
192
192
|
// Convert buffer data to strings where necessary
|
|
193
|
-
if (
|
|
193
|
+
if (isPlainObject(message.__argument)) {
|
|
194
194
|
const args = {...message.__argument};
|
|
195
195
|
|
|
196
196
|
// Handle WIRMessageDataKey and WIRSocketDataKey which may be buffers
|
|
@@ -213,7 +213,7 @@ export class RpcClientRealDeviceShim extends RpcClient {
|
|
|
213
213
|
* @returns The translated arguments for the shim service.
|
|
214
214
|
*/
|
|
215
215
|
private translateArguments(args: any): StringRecord {
|
|
216
|
-
if (!
|
|
216
|
+
if (!isPlainObject(args)) {
|
|
217
217
|
return {};
|
|
218
218
|
}
|
|
219
219
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import {log} from '../logger';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
import B from 'bluebird';
|
|
4
2
|
import net from 'node:net';
|
|
5
3
|
import {RpcClient} from './rpc-client';
|
|
6
4
|
import {services} from 'appium-ios-device';
|
|
@@ -110,7 +108,7 @@ export class RpcClientSimulator extends RpcClient {
|
|
|
110
108
|
this.service.listenMessage(this.receive.bind(this));
|
|
111
109
|
|
|
112
110
|
// connect the socket
|
|
113
|
-
return await new
|
|
111
|
+
return await new Promise<void>((resolve, reject) => {
|
|
114
112
|
// only resolve this function when we are actually connected
|
|
115
113
|
if (!this.socket) {
|
|
116
114
|
return reject(new Error('RPC socket is not connected. Please contact developers'));
|
|
@@ -157,7 +155,7 @@ export class RpcClientSimulator extends RpcClient {
|
|
|
157
155
|
override async sendMessage(cmd: RemoteCommand): Promise<void> {
|
|
158
156
|
let onSocketError: ((err: Error) => void) | undefined;
|
|
159
157
|
|
|
160
|
-
return await new
|
|
158
|
+
return await new Promise<void>((resolve, reject) => {
|
|
161
159
|
// handle socket problems
|
|
162
160
|
onSocketError = (err: Error) => {
|
|
163
161
|
log.error(`Socket error: ${err.message}`);
|
|
@@ -196,7 +194,7 @@ export class RpcClientSimulator extends RpcClient {
|
|
|
196
194
|
}
|
|
197
195
|
|
|
198
196
|
for (const key of ['WIRMessageDataKey', 'WIRDestinationKey', 'WIRSocketDataKey']) {
|
|
199
|
-
if (
|
|
197
|
+
if (data[key] !== undefined) {
|
|
200
198
|
data[key] = data[key].toString('utf8');
|
|
201
199
|
}
|
|
202
200
|
}
|