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,49 +1,54 @@
|
|
|
1
1
|
/* eslint-disable dot-notation */
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
2
|
+
import type {StringRecord} from '@appium/types';
|
|
3
|
+
import type {RemoteDebugger} from '../remote-debugger';
|
|
4
|
+
import type {EventListener} from '../types';
|
|
5
5
|
|
|
6
|
-
export function getAppDict(instance: RemoteDebugger): typeof instance['_appDict'] {
|
|
6
|
+
export function getAppDict(instance: RemoteDebugger): (typeof instance)['_appDict'] {
|
|
7
7
|
return instance['_appDict'];
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export function getAppIdKey(instance: RemoteDebugger): typeof instance['_appIdKey'] {
|
|
10
|
+
export function getAppIdKey(instance: RemoteDebugger): (typeof instance)['_appIdKey'] {
|
|
11
11
|
return instance['_appIdKey'];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export function setAppIdKey(instance: RemoteDebugger, value: typeof instance['_appIdKey']): void {
|
|
14
|
+
export function setAppIdKey(instance: RemoteDebugger, value: (typeof instance)['_appIdKey']): void {
|
|
15
15
|
instance['_appIdKey'] = value;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export function getRcpClient(instance: RemoteDebugger): typeof instance['_rpcClient'] {
|
|
18
|
+
export function getRcpClient(instance: RemoteDebugger): (typeof instance)['_rpcClient'] {
|
|
19
19
|
return instance['_rpcClient'];
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export function getPageIdKey(instance: RemoteDebugger): typeof instance['_pageIdKey'] {
|
|
22
|
+
export function getPageIdKey(instance: RemoteDebugger): (typeof instance)['_pageIdKey'] {
|
|
23
23
|
return instance['_pageIdKey'];
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export function setPageIdKey(
|
|
26
|
+
export function setPageIdKey(
|
|
27
|
+
instance: RemoteDebugger,
|
|
28
|
+
value: (typeof instance)['_pageIdKey'],
|
|
29
|
+
): void {
|
|
27
30
|
instance['_pageIdKey'] = value;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
export function getIsSafari(instance: RemoteDebugger): typeof instance['_isSafari'] {
|
|
33
|
+
export function getIsSafari(instance: RemoteDebugger): (typeof instance)['_isSafari'] {
|
|
31
34
|
return instance['_isSafari'];
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
export function getIncludeSafari(instance: RemoteDebugger): typeof instance['_includeSafari'] {
|
|
37
|
+
export function getIncludeSafari(instance: RemoteDebugger): (typeof instance)['_includeSafari'] {
|
|
35
38
|
return instance['_includeSafari'];
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
export function getBundleId(instance: RemoteDebugger): typeof instance['_bundleId'] {
|
|
41
|
+
export function getBundleId(instance: RemoteDebugger): (typeof instance)['_bundleId'] {
|
|
39
42
|
return instance['_bundleId'];
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
export function getAdditionalBundleIds(
|
|
45
|
+
export function getAdditionalBundleIds(
|
|
46
|
+
instance: RemoteDebugger,
|
|
47
|
+
): (typeof instance)['_additionalBundleIds'] {
|
|
43
48
|
return instance['_additionalBundleIds'];
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
export function getSkippedApps(instance: RemoteDebugger): typeof instance['_skippedApps'] {
|
|
51
|
+
export function getSkippedApps(instance: RemoteDebugger): (typeof instance)['_skippedApps'] {
|
|
47
52
|
return instance['_skippedApps'];
|
|
48
53
|
}
|
|
49
54
|
|
|
@@ -59,38 +64,58 @@ export function setPageLoading(instance: RemoteDebugger, value: boolean): void {
|
|
|
59
64
|
instance['_pageLoading'] = value;
|
|
60
65
|
}
|
|
61
66
|
|
|
62
|
-
export function getGarbageCollectOnExecute(
|
|
67
|
+
export function getGarbageCollectOnExecute(
|
|
68
|
+
instance: RemoteDebugger,
|
|
69
|
+
): (typeof instance)['_garbageCollectOnExecute'] {
|
|
63
70
|
return instance['_garbageCollectOnExecute'];
|
|
64
71
|
}
|
|
65
72
|
|
|
66
|
-
export function getNavigatingToPage(
|
|
73
|
+
export function getNavigatingToPage(
|
|
74
|
+
instance: RemoteDebugger,
|
|
75
|
+
): (typeof instance)['_navigatingToPage'] {
|
|
67
76
|
return instance['_navigatingToPage'];
|
|
68
77
|
}
|
|
69
78
|
|
|
70
|
-
export function setNavigatingToPage(
|
|
79
|
+
export function setNavigatingToPage(
|
|
80
|
+
instance: RemoteDebugger,
|
|
81
|
+
value: (typeof instance)['_navigatingToPage'],
|
|
82
|
+
): void {
|
|
71
83
|
instance['_navigatingToPage'] = value;
|
|
72
84
|
}
|
|
73
85
|
|
|
74
|
-
export function setCurrentState(
|
|
86
|
+
export function setCurrentState(
|
|
87
|
+
instance: RemoteDebugger,
|
|
88
|
+
value: (typeof instance)['_currentState'],
|
|
89
|
+
): void {
|
|
75
90
|
instance['_currentState'] = value;
|
|
76
91
|
}
|
|
77
92
|
|
|
78
|
-
export function setConnectedDrivers(
|
|
93
|
+
export function setConnectedDrivers(
|
|
94
|
+
instance: RemoteDebugger,
|
|
95
|
+
value: (typeof instance)['_connectedDrivers'],
|
|
96
|
+
): void {
|
|
79
97
|
instance['_connectedDrivers'] = value;
|
|
80
98
|
}
|
|
81
99
|
|
|
82
|
-
export function getPageLoadDelay(instance: RemoteDebugger): typeof instance['_pageLoadDelay'] {
|
|
100
|
+
export function getPageLoadDelay(instance: RemoteDebugger): (typeof instance)['_pageLoadDelay'] {
|
|
83
101
|
return instance['_pageLoadDelay'];
|
|
84
102
|
}
|
|
85
103
|
|
|
86
|
-
export function setPageLoadDelay(
|
|
104
|
+
export function setPageLoadDelay(
|
|
105
|
+
instance: RemoteDebugger,
|
|
106
|
+
value: (typeof instance)['_pageLoadDelay'],
|
|
107
|
+
): void {
|
|
87
108
|
instance['_pageLoadDelay'] = value;
|
|
88
109
|
}
|
|
89
110
|
|
|
90
|
-
export function getPageLoadStartegy(
|
|
111
|
+
export function getPageLoadStartegy(
|
|
112
|
+
instance: RemoteDebugger,
|
|
113
|
+
): (typeof instance)['_pageLoadStrategy'] {
|
|
91
114
|
return instance['_pageLoadStrategy'];
|
|
92
115
|
}
|
|
93
116
|
|
|
94
|
-
export function getPageReadyTimeout(
|
|
117
|
+
export function getPageReadyTimeout(
|
|
118
|
+
instance: RemoteDebugger,
|
|
119
|
+
): (typeof instance)['_pageReadyTimeout'] {
|
|
95
120
|
return instance['_pageReadyTimeout'];
|
|
96
121
|
}
|
package/lib/mixins/screenshot.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from './property-accessors';
|
|
5
|
-
import type { RemoteDebugger } from '../remote-debugger';
|
|
6
|
-
import type { Rect } from '@appium/types';
|
|
1
|
+
import {getAppIdKey, getPageIdKey} from './property-accessors';
|
|
2
|
+
import type {RemoteDebugger} from '../remote-debugger';
|
|
3
|
+
import type {Rect} from '@appium/types';
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* Options for capturing a screenshot.
|
|
@@ -28,15 +25,17 @@ export interface ScreenshotCaptureOptions {
|
|
|
28
25
|
*/
|
|
29
26
|
export async function captureScreenshot(
|
|
30
27
|
this: RemoteDebugger,
|
|
31
|
-
opts: ScreenshotCaptureOptions = {}
|
|
28
|
+
opts: ScreenshotCaptureOptions = {},
|
|
32
29
|
): Promise<string> {
|
|
33
30
|
const {rect = null, coordinateSystem = 'Viewport'} = opts;
|
|
34
31
|
this.log.debug('Capturing screenshot');
|
|
35
32
|
|
|
36
|
-
const arect =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
const arect =
|
|
34
|
+
rect ??
|
|
35
|
+
((await this.executeAtom('execute_script', [
|
|
36
|
+
'return {x: 0, y: 0, width: window.innerWidth, height: window.innerHeight}',
|
|
37
|
+
[],
|
|
38
|
+
])) as Rect);
|
|
40
39
|
const response = await this.requireRpcClient().send('Page.snapshotRect', {
|
|
41
40
|
...arect,
|
|
42
41
|
appIdKey: getAppIdKey(this),
|
package/lib/protocol/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type {StringRecord} from '@appium/types';
|
|
2
|
+
import type {RemoteCommandOpts, ProtocolCommandOpts} from '../types';
|
|
3
3
|
|
|
4
4
|
const OBJECT_GROUP = 'console';
|
|
5
5
|
|
|
@@ -197,7 +197,7 @@ const COMMANDS = {
|
|
|
197
197
|
'Worker.enable': [],
|
|
198
198
|
'Worker.disable': [],
|
|
199
199
|
'Worker.initialized': ['workerId'],
|
|
200
|
-
'Worker.sendMessageToWorker': ['workerId', 'message']
|
|
200
|
+
'Worker.sendMessageToWorker': ['workerId', 'message'],
|
|
201
201
|
//#endregion
|
|
202
202
|
} as const;
|
|
203
203
|
|
|
@@ -219,18 +219,20 @@ export function getProtocolCommand(
|
|
|
219
219
|
id: string,
|
|
220
220
|
method: string,
|
|
221
221
|
opts: RemoteCommandOpts,
|
|
222
|
-
direct: boolean = false
|
|
222
|
+
direct: boolean = false,
|
|
223
223
|
): ProtocolCommandOpts {
|
|
224
224
|
const paramNames = COMMANDS[method as keyof typeof COMMANDS];
|
|
225
225
|
if (!paramNames) {
|
|
226
226
|
throw new Error(`Unknown command: '${method}'`);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
const params: StringRecord = (paramNames as readonly string[])
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
229
|
+
const params: StringRecord = (paramNames as readonly string[]).reduce(function (
|
|
230
|
+
acc: StringRecord,
|
|
231
|
+
name: string,
|
|
232
|
+
) {
|
|
233
|
+
acc[name] = opts[name];
|
|
234
|
+
return acc;
|
|
235
|
+
}, {} as StringRecord);
|
|
234
236
|
const result: ProtocolCommandOpts = {
|
|
235
237
|
id,
|
|
236
238
|
method,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
1
|
+
import {RemoteDebugger} from './remote-debugger';
|
|
2
|
+
import {RpcClientRealDevice} from './rpc';
|
|
3
|
+
import type {RemoteDebuggerRealDeviceOptions} from './types';
|
|
4
4
|
|
|
5
5
|
export class RemoteDebuggerRealDevice extends RemoteDebugger {
|
|
6
6
|
private readonly _udid: string;
|
|
7
7
|
|
|
8
|
-
constructor
|
|
8
|
+
constructor(opts: RemoteDebuggerRealDeviceOptions) {
|
|
9
9
|
super(opts);
|
|
10
10
|
this._udid = opts.udid;
|
|
11
11
|
this._skippedApps = ['lockdownd'];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
override initRpcClient
|
|
14
|
+
override initRpcClient(): void {
|
|
15
15
|
this._rpcClient = new RpcClientRealDevice({
|
|
16
16
|
bundleId: this._bundleId,
|
|
17
17
|
platformVersion: this._platformVersion,
|
package/lib/remote-debugger.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import {EventEmitter} from 'node:events';
|
|
2
|
+
import {log as defaultLog} from './logger';
|
|
3
|
+
import {RpcClientSimulator} from './rpc';
|
|
4
|
+
import {getModuleProperties} from './utils';
|
|
5
5
|
import * as connectMixins from './mixins/connect';
|
|
6
6
|
import * as executeMixins from './mixins/execute';
|
|
7
7
|
import * as messageHandlerMixins from './mixins/message-handlers';
|
|
@@ -11,22 +11,14 @@ import * as screenshotMixins from './mixins/screenshot';
|
|
|
11
11
|
import * as eventMixins from './mixins/events';
|
|
12
12
|
import * as miscellaneousMixins from './mixins/misc';
|
|
13
13
|
import _ from 'lodash';
|
|
14
|
-
import type {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
EventListener,
|
|
18
|
-
PageIdKey,
|
|
19
|
-
AppIdKey,
|
|
20
|
-
} from './types';
|
|
21
|
-
import type { AppiumLogger, StringRecord } from '@appium/types';
|
|
22
|
-
import type { RpcClient } from './rpc/rpc-client';
|
|
14
|
+
import type {RemoteDebuggerOptions, AppDict, EventListener, PageIdKey, AppIdKey} from './types';
|
|
15
|
+
import type {AppiumLogger, StringRecord} from '@appium/types';
|
|
16
|
+
import type {RpcClient} from './rpc/rpc-client';
|
|
23
17
|
import type B from 'bluebird';
|
|
24
18
|
|
|
25
|
-
|
|
26
19
|
export const REMOTE_DEBUGGER_PORT = 27753;
|
|
27
20
|
const PAGE_READY_TIMEOUT_MS = 5000;
|
|
28
|
-
const {
|
|
29
|
-
|
|
21
|
+
const {version: MODULE_VERSION} = getModuleProperties();
|
|
30
22
|
|
|
31
23
|
export class RemoteDebugger extends EventEmitter {
|
|
32
24
|
protected _skippedApps: string[];
|
|
@@ -107,7 +99,7 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
107
99
|
onCurrentState = messageHandlerMixins.onCurrentState;
|
|
108
100
|
frameDetached = navigationMixins.frameDetached;
|
|
109
101
|
|
|
110
|
-
constructor
|
|
102
|
+
constructor(opts: RemoteDebuggerOptions = {}) {
|
|
111
103
|
super();
|
|
112
104
|
|
|
113
105
|
this._log = opts.log ?? defaultLog;
|
|
@@ -151,7 +143,9 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
151
143
|
this._remoteDebugProxy = remoteDebugProxy;
|
|
152
144
|
this._pageReadyTimeout = pageReadyTimeout;
|
|
153
145
|
|
|
154
|
-
this._logAllCommunication = _.isNil(logAllCommunication)
|
|
146
|
+
this._logAllCommunication = _.isNil(logAllCommunication)
|
|
147
|
+
? !!logFullResponse
|
|
148
|
+
: !!logAllCommunication;
|
|
155
149
|
this._logAllCommunicationHexDump = logAllCommunicationHexDump;
|
|
156
150
|
this._socketChunkSize = socketChunkSize;
|
|
157
151
|
|
|
@@ -181,7 +175,7 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
181
175
|
return this._rpcClient;
|
|
182
176
|
}
|
|
183
177
|
|
|
184
|
-
setup
|
|
178
|
+
setup(): void {
|
|
185
179
|
// app handling configuration
|
|
186
180
|
this._appDict = {};
|
|
187
181
|
this._appIdKey = undefined;
|
|
@@ -196,7 +190,7 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
196
190
|
this._clientEventListeners = {};
|
|
197
191
|
}
|
|
198
192
|
|
|
199
|
-
teardown
|
|
193
|
+
teardown(): void {
|
|
200
194
|
this.log.debug('Cleaning up listeners');
|
|
201
195
|
|
|
202
196
|
this._appDict = {};
|
|
@@ -215,7 +209,7 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
215
209
|
}
|
|
216
210
|
}
|
|
217
211
|
|
|
218
|
-
initRpcClient
|
|
212
|
+
initRpcClient(): void {
|
|
219
213
|
this._rpcClient = new RpcClientSimulator({
|
|
220
214
|
bundleId: this._bundleId,
|
|
221
215
|
platformVersion: this._platformVersion,
|
|
@@ -232,7 +226,7 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
232
226
|
});
|
|
233
227
|
}
|
|
234
228
|
|
|
235
|
-
get isConnected
|
|
229
|
+
get isConnected(): boolean {
|
|
236
230
|
return !!this._rpcClient?.isConnected;
|
|
237
231
|
}
|
|
238
232
|
|
|
@@ -243,27 +237,27 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
243
237
|
return _.cloneDeep(this._appDict);
|
|
244
238
|
}
|
|
245
239
|
|
|
246
|
-
set allowNavigationWithoutReload
|
|
240
|
+
set allowNavigationWithoutReload(allow: boolean) {
|
|
247
241
|
this._allowNavigationWithoutReload = allow;
|
|
248
242
|
}
|
|
249
243
|
|
|
250
|
-
get allowNavigationWithoutReload
|
|
244
|
+
get allowNavigationWithoutReload(): boolean {
|
|
251
245
|
return !!this._allowNavigationWithoutReload;
|
|
252
246
|
}
|
|
253
247
|
|
|
254
|
-
get currentState
|
|
248
|
+
get currentState(): string | undefined {
|
|
255
249
|
return this._currentState;
|
|
256
250
|
}
|
|
257
251
|
|
|
258
|
-
get connectedDrivers
|
|
252
|
+
get connectedDrivers(): StringRecord[] | undefined {
|
|
259
253
|
return this._connectedDrivers;
|
|
260
254
|
}
|
|
261
255
|
|
|
262
|
-
get pageLoadMs
|
|
256
|
+
get pageLoadMs(): number {
|
|
263
257
|
return this._pageLoadMs ?? navigationMixins.DEFAULT_PAGE_READINESS_TIMEOUT_MS;
|
|
264
258
|
}
|
|
265
259
|
|
|
266
|
-
set pageLoadMs
|
|
260
|
+
set pageLoadMs(value: number) {
|
|
267
261
|
this._pageLoadMs = value;
|
|
268
262
|
}
|
|
269
263
|
}
|
package/lib/rpc/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export {RpcClientSimulator} from './rpc-client-simulator';
|
|
2
|
+
export {RpcClientRealDevice} from './rpc-client-real-device';
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
2
|
+
import {getProtocolCommand} from '../protocol';
|
|
3
|
+
import type {
|
|
4
|
+
RawRemoteCommand,
|
|
5
|
+
RemoteCommandOpts,
|
|
6
|
+
ProtocolCommandOpts,
|
|
7
|
+
AppIdKey,
|
|
8
|
+
PageIdKey,
|
|
9
|
+
RemoteCommandId,
|
|
10
|
+
} from '../types';
|
|
4
11
|
|
|
5
12
|
const OBJECT_GROUP = 'console';
|
|
6
13
|
|
|
@@ -43,9 +50,9 @@ export class RemoteMessages {
|
|
|
43
50
|
setConnectionKey(connId: string): RawRemoteCommand {
|
|
44
51
|
return {
|
|
45
52
|
__argument: {
|
|
46
|
-
WIRConnectionIdentifierKey: connId
|
|
53
|
+
WIRConnectionIdentifierKey: connId,
|
|
47
54
|
},
|
|
48
|
-
__selector: '_rpc_reportIdentifier:'
|
|
55
|
+
__selector: '_rpc_reportIdentifier:',
|
|
49
56
|
};
|
|
50
57
|
}
|
|
51
58
|
|
|
@@ -60,9 +67,9 @@ export class RemoteMessages {
|
|
|
60
67
|
return {
|
|
61
68
|
__argument: {
|
|
62
69
|
WIRConnectionIdentifierKey: connId,
|
|
63
|
-
WIRApplicationIdentifierKey: appIdKey
|
|
70
|
+
WIRApplicationIdentifierKey: appIdKey,
|
|
64
71
|
},
|
|
65
|
-
__selector: '_rpc_forwardGetListing:'
|
|
72
|
+
__selector: '_rpc_forwardGetListing:',
|
|
66
73
|
};
|
|
67
74
|
}
|
|
68
75
|
|
|
@@ -75,7 +82,12 @@ export class RemoteMessages {
|
|
|
75
82
|
* @param pageIdKey - Optional page identifier key.
|
|
76
83
|
* @returns A RawRemoteCommand for setting the sender key.
|
|
77
84
|
*/
|
|
78
|
-
setSenderKey(
|
|
85
|
+
setSenderKey(
|
|
86
|
+
connId: string,
|
|
87
|
+
senderId: string,
|
|
88
|
+
appIdKey: AppIdKey,
|
|
89
|
+
pageIdKey?: PageIdKey,
|
|
90
|
+
): RawRemoteCommand {
|
|
79
91
|
return {
|
|
80
92
|
__argument: {
|
|
81
93
|
WIRApplicationIdentifierKey: appIdKey,
|
|
@@ -84,7 +96,7 @@ export class RemoteMessages {
|
|
|
84
96
|
WIRPageIdentifierKey: pageIdKey,
|
|
85
97
|
WIRAutomaticallyPause: false,
|
|
86
98
|
},
|
|
87
|
-
__selector: '_rpc_forwardSocketSetup:'
|
|
99
|
+
__selector: '_rpc_forwardSocketSetup:',
|
|
88
100
|
};
|
|
89
101
|
}
|
|
90
102
|
|
|
@@ -97,15 +109,20 @@ export class RemoteMessages {
|
|
|
97
109
|
* @param enabled - Whether the web view indication is enabled. Defaults to true if not provided.
|
|
98
110
|
* @returns A RawRemoteCommand for indicating web view status.
|
|
99
111
|
*/
|
|
100
|
-
indicateWebView(
|
|
112
|
+
indicateWebView(
|
|
113
|
+
connId: string,
|
|
114
|
+
appIdKey: AppIdKey,
|
|
115
|
+
pageIdKey?: PageIdKey,
|
|
116
|
+
enabled?: boolean,
|
|
117
|
+
): RawRemoteCommand {
|
|
101
118
|
return {
|
|
102
119
|
__argument: {
|
|
103
120
|
WIRApplicationIdentifierKey: appIdKey,
|
|
104
121
|
WIRIndicateEnabledKey: _.isNil(enabled) ? true : enabled,
|
|
105
122
|
WIRConnectionIdentifierKey: connId,
|
|
106
|
-
WIRPageIdentifierKey: pageIdKey
|
|
123
|
+
WIRPageIdentifierKey: pageIdKey,
|
|
107
124
|
},
|
|
108
|
-
__selector: '_rpc_forwardIndicateWebView:'
|
|
125
|
+
__selector: '_rpc_forwardIndicateWebView:',
|
|
109
126
|
};
|
|
110
127
|
}
|
|
111
128
|
|
|
@@ -118,9 +135,9 @@ export class RemoteMessages {
|
|
|
118
135
|
launchApplication(bundleId: string): RawRemoteCommand {
|
|
119
136
|
return {
|
|
120
137
|
__argument: {
|
|
121
|
-
WIRApplicationBundleIdentifierKey: bundleId
|
|
138
|
+
WIRApplicationBundleIdentifierKey: bundleId,
|
|
122
139
|
},
|
|
123
|
-
__selector: '_rpc_requestApplicationLaunch:'
|
|
140
|
+
__selector: '_rpc_requestApplicationLaunch:',
|
|
124
141
|
};
|
|
125
142
|
}
|
|
126
143
|
|
|
@@ -132,16 +149,7 @@ export class RemoteMessages {
|
|
|
132
149
|
* @returns A RawRemoteCommand with full parameter set.
|
|
133
150
|
*/
|
|
134
151
|
getFullCommand(opts: RemoteCommandOpts & ProtocolCommandOpts): RawRemoteCommand {
|
|
135
|
-
const {
|
|
136
|
-
method,
|
|
137
|
-
params,
|
|
138
|
-
connId,
|
|
139
|
-
senderId,
|
|
140
|
-
appIdKey,
|
|
141
|
-
pageIdKey,
|
|
142
|
-
targetId,
|
|
143
|
-
id,
|
|
144
|
-
} = opts;
|
|
152
|
+
const {method, params, connId, senderId, appIdKey, pageIdKey, targetId, id} = opts;
|
|
145
153
|
|
|
146
154
|
/* The Web Inspector has a number of parameters that can be passed in, as
|
|
147
155
|
* seen when dumping what Safari is doing when communicating with it. Most
|
|
@@ -157,14 +165,17 @@ export class RemoteMessages {
|
|
|
157
165
|
message: JSON.stringify({
|
|
158
166
|
id: parseInt(id, 10),
|
|
159
167
|
method,
|
|
160
|
-
params: Object.assign(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
params: Object.assign(
|
|
169
|
+
{
|
|
170
|
+
objectGroup: OBJECT_GROUP,
|
|
171
|
+
includeCommandLineAPI: true,
|
|
172
|
+
doNotPauseOnExceptionsAndMuteConsole: false,
|
|
173
|
+
emulateUserGesture: false,
|
|
174
|
+
generatePreview: false,
|
|
175
|
+
saveResult: false,
|
|
176
|
+
},
|
|
177
|
+
params,
|
|
178
|
+
),
|
|
168
179
|
}),
|
|
169
180
|
};
|
|
170
181
|
|
|
@@ -215,7 +226,7 @@ export class RemoteMessages {
|
|
|
215
226
|
WIRApplicationIdentifierKey: appIdKey,
|
|
216
227
|
WIRPageIdentifierKey: pageIdKey,
|
|
217
228
|
},
|
|
218
|
-
__selector: '_rpc_forwardSocketData:'
|
|
229
|
+
__selector: '_rpc_forwardSocketData:',
|
|
219
230
|
};
|
|
220
231
|
return _.omitBy(plist, _.isNil) as RawRemoteCommand;
|
|
221
232
|
}
|
|
@@ -242,7 +253,7 @@ export class RemoteMessages {
|
|
|
242
253
|
WIRApplicationIdentifierKey: appIdKey,
|
|
243
254
|
WIRPageIdentifierKey: pageIdKey,
|
|
244
255
|
},
|
|
245
|
-
__selector: '_rpc_forwardSocketData:'
|
|
256
|
+
__selector: '_rpc_forwardSocketData:',
|
|
246
257
|
};
|
|
247
258
|
return _.omitBy(plist, _.isNil) as RawRemoteCommand;
|
|
248
259
|
}
|
|
@@ -257,14 +268,7 @@ export class RemoteMessages {
|
|
|
257
268
|
* @throws Error if required parameters are missing for specific commands.
|
|
258
269
|
*/
|
|
259
270
|
getRemoteCommand(command: string, opts: RemoteCommandOpts & RemoteCommandId): RawRemoteCommand {
|
|
260
|
-
const {
|
|
261
|
-
id,
|
|
262
|
-
connId,
|
|
263
|
-
appIdKey,
|
|
264
|
-
senderId,
|
|
265
|
-
pageIdKey,
|
|
266
|
-
targetId,
|
|
267
|
-
} = opts;
|
|
271
|
+
const {id, connId, appIdKey, senderId, pageIdKey, targetId} = opts;
|
|
268
272
|
|
|
269
273
|
// deal with Safari Web Inspector commands
|
|
270
274
|
switch (command) {
|
|
@@ -296,13 +300,9 @@ export class RemoteMessages {
|
|
|
296
300
|
}
|
|
297
301
|
|
|
298
302
|
// deal with WebKit commands
|
|
299
|
-
const builderFunction = (COMMANDS[command as keyof typeof COMMANDS] ||
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
command,
|
|
303
|
-
opts,
|
|
304
|
-
isDirectCommand(command),
|
|
305
|
-
);
|
|
303
|
+
const builderFunction = (COMMANDS[command as keyof typeof COMMANDS] ||
|
|
304
|
+
MINIMAL_COMMAND) as CommandBuilderFunction;
|
|
305
|
+
const commonOpts = getProtocolCommand(id, command, opts, isDirectCommand(command));
|
|
306
306
|
return this[builderFunction]({
|
|
307
307
|
...commonOpts,
|
|
308
308
|
connId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
1
|
+
import {log} from '../logger';
|
|
2
|
+
import {RpcClient} from './rpc-client';
|
|
3
|
+
import {services} from 'appium-ios-device';
|
|
4
|
+
import type {RemoteCommand} from '../types';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* RPC client implementation for real iOS devices.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {log} from '../logger';
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
import B from 'bluebird';
|
|
4
4
|
import net from 'node:net';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import type {
|
|
5
|
+
import {RpcClient} from './rpc-client';
|
|
6
|
+
import {services} from 'appium-ios-device';
|
|
7
|
+
import type {RpcClientOptions, RpcClientSimulatorOptions, RemoteCommand} from '../types';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* RPC client implementation for iOS simulators.
|
|
@@ -26,12 +26,7 @@ export class RpcClientSimulator extends RpcClient {
|
|
|
26
26
|
constructor(opts: RpcClientOptions & RpcClientSimulatorOptions = {}) {
|
|
27
27
|
super(opts);
|
|
28
28
|
|
|
29
|
-
const {
|
|
30
|
-
socketPath,
|
|
31
|
-
host = '::1',
|
|
32
|
-
port,
|
|
33
|
-
messageProxy,
|
|
34
|
-
} = opts;
|
|
29
|
+
const {socketPath, host = '::1', port, messageProxy} = opts;
|
|
35
30
|
|
|
36
31
|
// host/port config for TCP communication, socketPath for unix domain sockets
|
|
37
32
|
this.host = host;
|
|
@@ -51,19 +46,24 @@ export class RpcClientSimulator extends RpcClient {
|
|
|
51
46
|
if (this.socketPath) {
|
|
52
47
|
if (this.messageProxy) {
|
|
53
48
|
// unix domain socket via proxy
|
|
54
|
-
log.debug(
|
|
49
|
+
log.debug(
|
|
50
|
+
`Connecting to remote debugger via proxy through unix domain socket: '${this.messageProxy}'`,
|
|
51
|
+
);
|
|
55
52
|
this.socket = net.connect(this.messageProxy);
|
|
56
53
|
|
|
57
54
|
// Forward the actual socketPath to the proxy
|
|
58
55
|
this.socket.once('connect', () => {
|
|
59
|
-
log.debug(
|
|
56
|
+
log.debug(
|
|
57
|
+
`Forwarding the actual web inspector socket to the proxy: '${this.socketPath}'`,
|
|
58
|
+
);
|
|
60
59
|
if (this.socket) {
|
|
61
|
-
this.socket.write(
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
this.socket.write(
|
|
61
|
+
JSON.stringify({
|
|
62
|
+
socketPath: this.socketPath,
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
64
65
|
}
|
|
65
66
|
});
|
|
66
|
-
|
|
67
67
|
} else {
|
|
68
68
|
// unix domain socket
|
|
69
69
|
log.debug(`Connecting to remote debugger through unix domain socket: '${this.socketPath}'`);
|
|
@@ -76,7 +76,9 @@ export class RpcClientSimulator extends RpcClient {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
// tcp socket
|
|
79
|
-
log.debug(
|
|
79
|
+
log.debug(
|
|
80
|
+
`Connecting to remote debugger ${this.messageProxy ? 'via proxy ' : ''}through TCP: ${this.host}:${this.port}`,
|
|
81
|
+
);
|
|
80
82
|
this.socket = new net.Socket();
|
|
81
83
|
if (this.port && this.host) {
|
|
82
84
|
this.socket.connect(this.port, this.host);
|
|
@@ -166,14 +168,15 @@ export class RpcClientSimulator extends RpcClient {
|
|
|
166
168
|
|
|
167
169
|
if (!this.socket || !this.service) {
|
|
168
170
|
return reject(
|
|
169
|
-
new Error(
|
|
171
|
+
new Error(
|
|
172
|
+
'The RPC client is not connected. Have you called `connect()` before sending a message?',
|
|
173
|
+
),
|
|
170
174
|
);
|
|
171
175
|
}
|
|
172
176
|
this.socket.on('error', onSocketError);
|
|
173
177
|
this.service.sendMessage(cmd);
|
|
174
178
|
resolve();
|
|
175
|
-
})
|
|
176
|
-
.finally(() => {
|
|
179
|
+
}).finally(() => {
|
|
177
180
|
// remove this listener, so we don't exhaust the system
|
|
178
181
|
if (this.socket && onSocketError) {
|
|
179
182
|
this.socket.removeListener('error', onSocketError);
|