appium-remote-debugger 15.2.14 → 15.3.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.js +2 -2
- package/build/lib/atoms.js.map +1 -1
- package/build/lib/remote-debugger.d.ts +1 -1
- package/build/lib/remote-debugger.d.ts.map +1 -1
- package/build/lib/remote-debugger.js +2 -2
- package/build/lib/remote-debugger.js.map +1 -1
- package/build/lib/rpc/remote-messages.js +3 -3
- package/build/lib/rpc/remote-messages.js.map +1 -1
- package/build/lib/rpc/rpc-client-real-device.d.ts +26 -8
- package/build/lib/rpc/rpc-client-real-device.d.ts.map +1 -1
- package/build/lib/rpc/rpc-client-real-device.js +21 -16
- package/build/lib/rpc/rpc-client-real-device.js.map +1 -1
- package/build/lib/rpc/rpc-client-simulator.d.ts +36 -28
- package/build/lib/rpc/rpc-client-simulator.d.ts.map +1 -1
- package/build/lib/rpc/rpc-client-simulator.js +43 -40
- package/build/lib/rpc/rpc-client-simulator.js.map +1 -1
- package/build/lib/rpc/rpc-client.d.ts +278 -189
- package/build/lib/rpc/rpc-client.d.ts.map +1 -1
- package/build/lib/rpc/rpc-client.js +222 -178
- package/build/lib/rpc/rpc-client.js.map +1 -1
- package/build/lib/types.d.ts +25 -0
- package/build/lib/types.d.ts.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/atoms.ts +1 -1
- package/lib/remote-debugger.ts +1 -1
- package/lib/rpc/remote-messages.ts +3 -3
- package/lib/rpc/rpc-client-real-device.ts +68 -0
- package/lib/rpc/{rpc-client-simulator.js → rpc-client-simulator.ts} +55 -58
- package/lib/rpc/{rpc-client.js → rpc-client.ts} +368 -284
- package/lib/types.ts +27 -0
- package/package.json +2 -2
- package/lib/rpc/rpc-client-real-device.js +0 -64
package/lib/atoms.ts
CHANGED
package/lib/remote-debugger.ts
CHANGED
|
@@ -155,7 +155,7 @@ export class RemoteMessages {
|
|
|
155
155
|
const realParams = {
|
|
156
156
|
targetId,
|
|
157
157
|
message: JSON.stringify({
|
|
158
|
-
id,
|
|
158
|
+
id: parseInt(id, 10),
|
|
159
159
|
method,
|
|
160
160
|
params: Object.assign({
|
|
161
161
|
objectGroup: OBJECT_GROUP,
|
|
@@ -198,7 +198,7 @@ export class RemoteMessages {
|
|
|
198
198
|
const realParams = {
|
|
199
199
|
targetId,
|
|
200
200
|
message: JSON.stringify({
|
|
201
|
-
id,
|
|
201
|
+
id: parseInt(id, 10),
|
|
202
202
|
method,
|
|
203
203
|
params,
|
|
204
204
|
}),
|
|
@@ -233,7 +233,7 @@ export class RemoteMessages {
|
|
|
233
233
|
const plist = {
|
|
234
234
|
__argument: {
|
|
235
235
|
WIRSocketDataKey: {
|
|
236
|
-
id,
|
|
236
|
+
id: parseInt(id, 10),
|
|
237
237
|
method,
|
|
238
238
|
params,
|
|
239
239
|
},
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
|
|
6
|
+
/**
|
|
7
|
+
* RPC client implementation for real iOS devices.
|
|
8
|
+
* Extends RpcClient to provide device-specific connection handling.
|
|
9
|
+
*/
|
|
10
|
+
export class RpcClientRealDevice extends RpcClient {
|
|
11
|
+
protected service?: any;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Connects to the Web Inspector service on a real iOS device.
|
|
15
|
+
* Starts the Web Inspector service and sets up message listening.
|
|
16
|
+
*/
|
|
17
|
+
override async connect(): Promise<void> {
|
|
18
|
+
this.service = await services.startWebInspectorService(this.udid, {
|
|
19
|
+
osVersion: this.platformVersion,
|
|
20
|
+
isSimulator: false,
|
|
21
|
+
verbose: this.logAllCommunication,
|
|
22
|
+
verboseHexDump: this.logAllCommunicationHexDump,
|
|
23
|
+
socketChunkSize: this.socketChunkSize,
|
|
24
|
+
maxFrameLength: this.webInspectorMaxFrameLength,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
this.service.listenMessage(this.receive.bind(this));
|
|
28
|
+
this.isConnected = true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Disconnects from the Web Inspector service on the real device.
|
|
33
|
+
* Closes the service connection and cleans up resources.
|
|
34
|
+
*/
|
|
35
|
+
override async disconnect(): Promise<void> {
|
|
36
|
+
if (!this.isConnected) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
log.debug('Disconnecting from remote debugger');
|
|
41
|
+
await super.disconnect();
|
|
42
|
+
this.service?.close();
|
|
43
|
+
this.isConnected = false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Sends a command message to the Web Inspector service.
|
|
48
|
+
*
|
|
49
|
+
* @param cmd - The command to send to the device.
|
|
50
|
+
*/
|
|
51
|
+
override async sendMessage(cmd: RemoteCommand): Promise<void> {
|
|
52
|
+
if (!this.service) {
|
|
53
|
+
throw new Error('RPC service is not initialized. Is the client connected?');
|
|
54
|
+
}
|
|
55
|
+
this.service.sendMessage(cmd);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Receives data from the Web Inspector service and handles it.
|
|
60
|
+
*
|
|
61
|
+
* @param data - The data received from the service.
|
|
62
|
+
*/
|
|
63
|
+
override async receive(data: any): Promise<void> {
|
|
64
|
+
if (this.isConnected) {
|
|
65
|
+
await this.messageHandler.handleMessage(data);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import { log } from '../logger';
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
import B from 'bluebird';
|
|
4
|
-
import net from 'net';
|
|
4
|
+
import net from 'node:net';
|
|
5
5
|
import { RpcClient } from './rpc-client';
|
|
6
6
|
import { services } from 'appium-ios-device';
|
|
7
|
+
import type { RpcClientOptions, RpcClientSimulatorOptions, RemoteCommand } from '../types';
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* RPC client implementation for iOS simulators.
|
|
11
|
+
* Extends RpcClient to provide simulator-specific connection handling
|
|
12
|
+
* via TCP sockets or Unix domain sockets.
|
|
13
|
+
*/
|
|
8
14
|
export class RpcClientSimulator extends RpcClient {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/** @type {any} */
|
|
16
|
-
messageProxy;
|
|
17
|
-
|
|
18
|
-
/** @type {import('node:net').Socket|null} */
|
|
19
|
-
socket;
|
|
20
|
-
|
|
21
|
-
/** @type {string|undefined} */
|
|
22
|
-
socketPath;
|
|
15
|
+
protected readonly host?: string;
|
|
16
|
+
protected port?: number;
|
|
17
|
+
protected readonly messageProxy?: any;
|
|
18
|
+
protected socket: net.Socket | null;
|
|
19
|
+
protected readonly socketPath?: string;
|
|
20
|
+
protected service?: any;
|
|
23
21
|
|
|
24
22
|
/**
|
|
25
|
-
* @param
|
|
23
|
+
* @param opts - Options for configuring the RPC client, including
|
|
24
|
+
* simulator-specific options like socketPath, host, and port.
|
|
26
25
|
*/
|
|
27
|
-
constructor
|
|
26
|
+
constructor(opts: RpcClientOptions & RpcClientSimulatorOptions = {}) {
|
|
28
27
|
super(opts);
|
|
29
28
|
|
|
30
29
|
const {
|
|
@@ -44,9 +43,10 @@ export class RpcClientSimulator extends RpcClient {
|
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
/**
|
|
47
|
-
*
|
|
46
|
+
* Connects to the Web Inspector service on an iOS simulator.
|
|
47
|
+
* Supports both Unix domain sockets and TCP connections, with optional proxy support.
|
|
48
48
|
*/
|
|
49
|
-
async connect
|
|
49
|
+
override async connect(): Promise<void> {
|
|
50
50
|
// create socket and handle its messages
|
|
51
51
|
if (this.socketPath) {
|
|
52
52
|
if (this.messageProxy) {
|
|
@@ -57,10 +57,11 @@ export class RpcClientSimulator extends RpcClient {
|
|
|
57
57
|
// Forward the actual socketPath to the proxy
|
|
58
58
|
this.socket.once('connect', () => {
|
|
59
59
|
log.debug(`Forwarding the actual web inspector socket to the proxy: '${this.socketPath}'`);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
if (this.socket) {
|
|
61
|
+
this.socket.write(JSON.stringify({
|
|
62
|
+
socketPath: this.socketPath
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
} else {
|
|
@@ -77,7 +78,11 @@ export class RpcClientSimulator extends RpcClient {
|
|
|
77
78
|
// tcp socket
|
|
78
79
|
log.debug(`Connecting to remote debugger ${this.messageProxy ? 'via proxy ' : ''}through TCP: ${this.host}:${this.port}`);
|
|
79
80
|
this.socket = new net.Socket();
|
|
80
|
-
|
|
81
|
+
if (this.port && this.host) {
|
|
82
|
+
this.socket.connect(this.port, this.host);
|
|
83
|
+
} else {
|
|
84
|
+
throw new Error('Both port and host must be defined for TCP connection');
|
|
85
|
+
}
|
|
81
86
|
}
|
|
82
87
|
|
|
83
88
|
this.socket.setNoDelay(true);
|
|
@@ -103,16 +108,17 @@ export class RpcClientSimulator extends RpcClient {
|
|
|
103
108
|
this.service.listenMessage(this.receive.bind(this));
|
|
104
109
|
|
|
105
110
|
// connect the socket
|
|
106
|
-
return await new B((resolve, reject) => {
|
|
111
|
+
return await new B<void>((resolve, reject) => {
|
|
107
112
|
// only resolve this function when we are actually connected
|
|
108
|
-
|
|
113
|
+
if (!this.socket) {
|
|
114
|
+
return reject(new Error('RPC socket is not connected. Please contact developers'));
|
|
115
|
+
}
|
|
109
116
|
this.socket.on('connect', () => {
|
|
110
117
|
log.debug(`Debugger socket connected`);
|
|
111
118
|
this.isConnected = true;
|
|
112
119
|
|
|
113
120
|
resolve();
|
|
114
121
|
});
|
|
115
|
-
// @ts-ignore socket must be defined here
|
|
116
122
|
this.socket.on('error', (err) => {
|
|
117
123
|
if (this.isConnected) {
|
|
118
124
|
log.error(`Socket error: ${err.message}`);
|
|
@@ -126,37 +132,41 @@ export class RpcClientSimulator extends RpcClient {
|
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
/**
|
|
129
|
-
*
|
|
135
|
+
* Disconnects from the Web Inspector service on the simulator.
|
|
136
|
+
* Closes the socket and service connection, and cleans up resources.
|
|
130
137
|
*/
|
|
131
|
-
async disconnect
|
|
138
|
+
override async disconnect(): Promise<void> {
|
|
132
139
|
if (!this.isConnected) {
|
|
133
140
|
return;
|
|
134
141
|
}
|
|
135
142
|
|
|
136
143
|
log.debug('Disconnecting from remote debugger');
|
|
137
144
|
await super.disconnect();
|
|
138
|
-
this.service
|
|
145
|
+
this.service?.close();
|
|
139
146
|
this.isConnected = false;
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
/**
|
|
143
|
-
*
|
|
150
|
+
* Sends a command message to the Web Inspector service via the socket.
|
|
151
|
+
* Handles socket errors and ensures the socket is available before sending.
|
|
152
|
+
*
|
|
153
|
+
* @param cmd - The command to send to the simulator.
|
|
144
154
|
*/
|
|
145
|
-
async sendMessage
|
|
146
|
-
let onSocketError;
|
|
155
|
+
override async sendMessage(cmd: RemoteCommand): Promise<void> {
|
|
156
|
+
let onSocketError: ((err: Error) => void) | undefined;
|
|
147
157
|
|
|
148
|
-
return await new B((resolve, reject) => {
|
|
158
|
+
return await new B<void>((resolve, reject) => {
|
|
149
159
|
// handle socket problems
|
|
150
|
-
onSocketError = (err) => {
|
|
160
|
+
onSocketError = (err: Error) => {
|
|
151
161
|
log.error(`Socket error: ${err.message}`);
|
|
152
162
|
|
|
153
163
|
// the connection was refused, so reject the connect promise
|
|
154
164
|
reject(err);
|
|
155
165
|
};
|
|
156
166
|
|
|
157
|
-
if (!this.socket) {
|
|
167
|
+
if (!this.socket || !this.service) {
|
|
158
168
|
return reject(
|
|
159
|
-
new Error('The RPC
|
|
169
|
+
new Error('The RPC client is not connected. Have you called `connect()` before sending a message?')
|
|
160
170
|
);
|
|
161
171
|
}
|
|
162
172
|
this.socket.on('error', onSocketError);
|
|
@@ -165,22 +175,20 @@ export class RpcClientSimulator extends RpcClient {
|
|
|
165
175
|
})
|
|
166
176
|
.finally(() => {
|
|
167
177
|
// remove this listener, so we don't exhaust the system
|
|
168
|
-
|
|
169
|
-
// @ts-ignore socket must be defined
|
|
178
|
+
if (this.socket && onSocketError) {
|
|
170
179
|
this.socket.removeListener('error', onSocketError);
|
|
171
|
-
}
|
|
180
|
+
}
|
|
172
181
|
});
|
|
173
182
|
}
|
|
174
183
|
|
|
175
184
|
/**
|
|
176
|
-
*
|
|
185
|
+
* Receives data from the Web Inspector service and handles it.
|
|
186
|
+
* Converts Buffer data to strings for certain message keys.
|
|
187
|
+
*
|
|
188
|
+
* @param data - The data received from the service.
|
|
177
189
|
*/
|
|
178
|
-
async receive
|
|
179
|
-
if (!this.isConnected) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (!data) {
|
|
190
|
+
override async receive(data: any): Promise<void> {
|
|
191
|
+
if (!this.isConnected || !data) {
|
|
184
192
|
return;
|
|
185
193
|
}
|
|
186
194
|
|
|
@@ -189,17 +197,6 @@ export class RpcClientSimulator extends RpcClient {
|
|
|
189
197
|
data[key] = data[key].toString('utf8');
|
|
190
198
|
}
|
|
191
199
|
}
|
|
192
|
-
// @ts-ignore messageHandler must be defined
|
|
193
200
|
await this.messageHandler.handleMessage(data);
|
|
194
201
|
}
|
|
195
202
|
}
|
|
196
|
-
|
|
197
|
-
export default RpcClientSimulator;
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* @typedef {Object} RpcClientSimulatorOptions
|
|
201
|
-
* @property {string} [socketPath]
|
|
202
|
-
* @property {string} [host='::1']
|
|
203
|
-
* @property {number} [port]
|
|
204
|
-
* @property {any} [messageProxy]
|
|
205
|
-
*/
|