appium-remote-debugger 15.2.14 → 15.3.0
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 +6 -0
- 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 +39 -36
- 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/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} +54 -57
- package/lib/rpc/{rpc-client.js → rpc-client.ts} +368 -284
- package/lib/types.ts +27 -0
- package/package.json +1 -1
- package/lib/rpc/rpc-client-real-device.js +0 -64
|
@@ -1,268 +1,357 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { RemoteMessages } from './remote-messages';
|
|
2
|
+
import RpcMessageHandler from './rpc-message-handler';
|
|
3
|
+
import { EventEmitter } from 'node:events';
|
|
4
|
+
import AsyncLock from 'async-lock';
|
|
5
|
+
import type { StringRecord } from '@appium/types';
|
|
6
|
+
import type { AppIdKey, PageIdKey, TargetId, TargetInfo, ProvisionalTargetInfo, RemoteCommandOpts, RemoteCommand, RpcClientOptions } from '../types';
|
|
7
|
+
export declare const NEW_APP_CONNECTED_ERROR = "New application has connected";
|
|
8
|
+
export declare const EMPTY_PAGE_DICTIONARY_ERROR = "Empty page dictionary received";
|
|
9
|
+
/**
|
|
10
|
+
* Details about a pending page target notification.
|
|
11
|
+
*/
|
|
12
|
+
interface PendingPageTargetDetails {
|
|
13
|
+
appIdKey: AppIdKey;
|
|
14
|
+
pageIdKey: PageIdKey;
|
|
15
|
+
pageReadinessDetector?: PageReadinessDetector;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Pages to targets mapping with optional provisional target info and lock.
|
|
19
|
+
*/
|
|
20
|
+
interface PagesToTargets {
|
|
21
|
+
[key: string]: TargetId | ProvisionalTargetInfo | AsyncLock | undefined;
|
|
22
|
+
provisional?: ProvisionalTargetInfo;
|
|
23
|
+
lock: AsyncLock;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Mapping of application IDs to their pages and targets.
|
|
27
|
+
*/
|
|
28
|
+
type AppToTargetsMap = Record<AppIdKey, PagesToTargets>;
|
|
29
|
+
/**
|
|
30
|
+
* Detector for determining when a page is ready.
|
|
31
|
+
*/
|
|
32
|
+
interface PageReadinessDetector {
|
|
33
|
+
timeoutMs: number;
|
|
34
|
+
readinessDetector: (readyState: string) => boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Base class for RPC clients that communicate with the Web Inspector.
|
|
38
|
+
* Provides functionality for managing targets, sending commands, and handling
|
|
39
|
+
* page initialization. Subclasses must implement device-specific connection logic.
|
|
40
|
+
*/
|
|
41
|
+
export declare class RpcClient {
|
|
42
|
+
protected readonly messageHandler: RpcMessageHandler;
|
|
43
|
+
protected readonly remoteMessages: RemoteMessages;
|
|
44
|
+
protected connected: boolean;
|
|
45
|
+
protected readonly isSafari: boolean;
|
|
46
|
+
protected readonly connId: string;
|
|
47
|
+
protected readonly senderId: string;
|
|
48
|
+
protected msgId: number;
|
|
49
|
+
protected readonly udid?: string;
|
|
50
|
+
protected readonly logAllCommunication?: boolean;
|
|
51
|
+
protected readonly logAllCommunicationHexDump?: boolean;
|
|
52
|
+
protected readonly socketChunkSize?: number;
|
|
53
|
+
protected readonly webInspectorMaxFrameLength?: number;
|
|
54
|
+
protected readonly fullPageInitialization?: boolean;
|
|
55
|
+
protected readonly bundleId?: string;
|
|
56
|
+
protected readonly pageLoadTimeoutMs?: number;
|
|
57
|
+
protected readonly platformVersion: string;
|
|
58
|
+
protected readonly _contexts: number[];
|
|
59
|
+
protected readonly _targets: AppToTargetsMap;
|
|
60
|
+
protected readonly _targetSubscriptions: EventEmitter;
|
|
61
|
+
protected _pendingTargetNotification?: PendingPageTargetDetails;
|
|
62
|
+
protected readonly _targetCreationTimeoutMs: number;
|
|
63
|
+
protected readonly _provisionedPages: Set<PageIdKey>;
|
|
64
|
+
protected readonly _pageSelectionLock: AsyncLock;
|
|
65
|
+
protected readonly _pageSelectionMonitor: EventEmitter;
|
|
4
66
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {RpcClientOptions} [opts={}]
|
|
67
|
+
* @param opts - Options for configuring the RPC client.
|
|
7
68
|
*/
|
|
8
69
|
constructor(opts?: RpcClientOptions);
|
|
9
|
-
/** @type {RpcMessageHandler|undefined} */
|
|
10
|
-
messageHandler: RpcMessageHandler | undefined;
|
|
11
|
-
/** @type {RemoteMessages|undefined} */
|
|
12
|
-
remoteMessages: RemoteMessages | undefined;
|
|
13
|
-
/** @type {boolean} */
|
|
14
|
-
connected: boolean;
|
|
15
|
-
/** @type {boolean} */
|
|
16
|
-
isSafari: boolean;
|
|
17
|
-
/** @type {string} */
|
|
18
|
-
connId: string;
|
|
19
|
-
/** @type {string} */
|
|
20
|
-
senderId: string;
|
|
21
|
-
/** @type {number} */
|
|
22
|
-
msgId: number;
|
|
23
|
-
/** @type {string|undefined} */
|
|
24
|
-
udid: string | undefined;
|
|
25
|
-
/** @type {boolean|undefined} */
|
|
26
|
-
logAllCommunication: boolean | undefined;
|
|
27
|
-
/** @type {boolean|undefined} */
|
|
28
|
-
logAllCommunicationHexDump: boolean | undefined;
|
|
29
|
-
/** @type {number|undefined} */
|
|
30
|
-
socketChunkSize: number | undefined;
|
|
31
|
-
/** @type {number|undefined} */
|
|
32
|
-
webInspectorMaxFrameLength: number | undefined;
|
|
33
|
-
/** @type {boolean|undefined} */
|
|
34
|
-
fullPageInitialization: boolean | undefined;
|
|
35
|
-
/** @type {string|undefined} */
|
|
36
|
-
bundleId: string | undefined;
|
|
37
|
-
/** @type {number | undefined} */
|
|
38
|
-
pageLoadTimeoutMs: number | undefined;
|
|
39
|
-
/** @type {string} */
|
|
40
|
-
platformVersion: string;
|
|
41
|
-
/** @type {string[]} */
|
|
42
|
-
_contexts: string[];
|
|
43
|
-
/** @type {AppToTargetsMap} */
|
|
44
|
-
_targets: AppToTargetsMap;
|
|
45
|
-
/** @type {EventEmitter} */
|
|
46
|
-
_targetSubscriptions: EventEmitter;
|
|
47
|
-
/** @type {PendingPageTargetDetails | undefined} */
|
|
48
|
-
_pendingTargetNotification: PendingPageTargetDetails | undefined;
|
|
49
|
-
/** @type {number} */
|
|
50
|
-
_targetCreationTimeoutMs: number;
|
|
51
70
|
/**
|
|
52
|
-
*
|
|
71
|
+
* Gets the list of execution context IDs.
|
|
72
|
+
*
|
|
73
|
+
* @returns Array of execution context IDs.
|
|
53
74
|
*/
|
|
54
|
-
|
|
75
|
+
get contexts(): number[];
|
|
55
76
|
/**
|
|
56
|
-
*
|
|
77
|
+
* Gets the mapping of applications to their pages and targets.
|
|
78
|
+
*
|
|
79
|
+
* @returns The targets mapping structure.
|
|
57
80
|
*/
|
|
58
|
-
get
|
|
59
|
-
_provisionedPages: Set<any>;
|
|
60
|
-
_pageSelectionLock: any;
|
|
61
|
-
_pageSelectionMonitor: EventEmitter<any>;
|
|
81
|
+
get targets(): AppToTargetsMap;
|
|
62
82
|
/**
|
|
63
|
-
*
|
|
83
|
+
* Gets whether the client is currently connected.
|
|
84
|
+
*
|
|
85
|
+
* @returns True if connected, false otherwise.
|
|
64
86
|
*/
|
|
65
|
-
get
|
|
87
|
+
get isConnected(): boolean;
|
|
66
88
|
/**
|
|
67
|
-
*
|
|
89
|
+
* Sets the connection status.
|
|
90
|
+
*
|
|
91
|
+
* @param connected - The connection status to set.
|
|
68
92
|
*/
|
|
69
|
-
|
|
93
|
+
set isConnected(connected: boolean);
|
|
70
94
|
/**
|
|
71
|
-
*
|
|
95
|
+
* Gets the event emitter for target subscriptions.
|
|
96
|
+
*
|
|
97
|
+
* @returns The target subscriptions event emitter.
|
|
72
98
|
*/
|
|
73
99
|
get targetSubscriptions(): EventEmitter;
|
|
74
100
|
/**
|
|
101
|
+
* Registers an event listener on the message handler.
|
|
102
|
+
*
|
|
103
|
+
* Supported events include:
|
|
104
|
+
*
|
|
105
|
+
* **RPC-level events:**
|
|
106
|
+
* - `_rpc_reportSetup:` - Emitted when the debugger setup is reported
|
|
107
|
+
* - `_rpc_reportConnectedApplicationList:` - Emitted when the list of connected applications is reported
|
|
108
|
+
* - `_rpc_forwardGetListing:` - Emitted when an application sends a page listing
|
|
109
|
+
* - `_rpc_applicationConnected:` - Emitted when a new application connects
|
|
110
|
+
* - `_rpc_applicationDisconnected:` - Emitted when an application disconnects
|
|
111
|
+
* - `_rpc_applicationUpdated:` - Emitted when an application is updated
|
|
112
|
+
* - `_rpc_reportConnectedDriverList:` - Emitted when the list of connected drivers is reported
|
|
113
|
+
* - `_rpc_reportCurrentState:` - Emitted when the current state is reported
|
|
114
|
+
*
|
|
115
|
+
* **Target events:**
|
|
116
|
+
* - `Target.targetCreated` - Emitted when a new target is created (args: error, appIdKey, targetInfo)
|
|
117
|
+
* - `Target.targetDestroyed` - Emitted when a target is destroyed (args: error, appIdKey, targetInfo)
|
|
118
|
+
* - `Target.didCommitProvisionalTarget` - Emitted when a provisional target commits (args: error, appIdKey, provisionalTargetInfo)
|
|
119
|
+
*
|
|
120
|
+
* **Page events:**
|
|
121
|
+
* - `Page.frameStoppedLoading` - Emitted when a frame stops loading
|
|
122
|
+
* - `Page.frameNavigated` - Emitted when a frame navigates
|
|
123
|
+
* - `Page.frameDetached` - Emitted when a frame is detached
|
|
124
|
+
* - `Page.loadEventFired` - Emitted when the page load event fires
|
|
75
125
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
126
|
+
* **Runtime events:**
|
|
127
|
+
* - `Runtime.executionContextCreated` - Emitted when an execution context is created (args: error, context)
|
|
128
|
+
*
|
|
129
|
+
* **Console events:**
|
|
130
|
+
* - `Console.messageAdded` - Emitted when a console message is added (args: error, message)
|
|
131
|
+
* - `Console.messageRepeatCountUpdated` - Emitted when a console message repeat count is updated
|
|
132
|
+
* - `ConsoleEvent` - Aggregate event for all Console.* events (args: error, params, methodName)
|
|
133
|
+
*
|
|
134
|
+
* **Network events:**
|
|
135
|
+
* - `NetworkEvent` - Aggregate event for all Network.* events (args: error, params, methodName)
|
|
136
|
+
*
|
|
137
|
+
* **Timeline events:**
|
|
138
|
+
* - `Timeline.eventRecorded` - Emitted when a timeline event is recorded (args: error, record)
|
|
139
|
+
*
|
|
140
|
+
* **Heap events:**
|
|
141
|
+
* - `Heap.garbageCollected` - Emitted when garbage collection occurs
|
|
142
|
+
*
|
|
143
|
+
* **Message ID events:**
|
|
144
|
+
* - Any numeric string (message ID) - Emitted for command responses (args: error, result)
|
|
145
|
+
*
|
|
146
|
+
* @param event - The event name to listen for.
|
|
147
|
+
* @param listener - The listener function to call when the event is emitted.
|
|
148
|
+
* The listener receives (error, ...args) where error may be null/undefined.
|
|
149
|
+
* @returns This instance for method chaining.
|
|
79
150
|
*/
|
|
80
|
-
on(event: string, listener:
|
|
151
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
|
81
152
|
/**
|
|
153
|
+
* Registers a one-time event listener on the message handler.
|
|
154
|
+
* The listener will be automatically removed after being called once.
|
|
82
155
|
*
|
|
83
|
-
* @
|
|
84
|
-
*
|
|
85
|
-
* @
|
|
156
|
+
* See {@link RpcClient.on} for a list of supported events.
|
|
157
|
+
*
|
|
158
|
+
* @param event - The event name to listen for.
|
|
159
|
+
* @param listener - The listener function to call when the event is emitted.
|
|
160
|
+
* The listener receives (error, ...args) where error may be null/undefined.
|
|
161
|
+
* @returns This instance for method chaining.
|
|
162
|
+
*/
|
|
163
|
+
once(event: string, listener: (...args: any[]) => void): this;
|
|
164
|
+
/**
|
|
165
|
+
* Removes an event listener from the message handler.
|
|
166
|
+
*
|
|
167
|
+
* See {@link RpcClient.on} for a list of supported events.
|
|
168
|
+
*
|
|
169
|
+
* @param event - The event name to stop listening for.
|
|
170
|
+
* @param listener - The listener function to remove.
|
|
171
|
+
* @returns This instance for method chaining.
|
|
86
172
|
*/
|
|
87
|
-
|
|
173
|
+
off(event: string, listener: (...args: any[]) => void): this;
|
|
88
174
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
175
|
+
* Waits for a target to be created for the specified app and page.
|
|
176
|
+
* If the target already exists, returns it immediately. Otherwise,
|
|
177
|
+
* waits up to the configured timeout for the target to be created.
|
|
178
|
+
*
|
|
179
|
+
* @param appIdKey - The application identifier key.
|
|
180
|
+
* @param pageIdKey - The page identifier key.
|
|
181
|
+
* @returns A promise that resolves to the target ID if found, undefined otherwise.
|
|
182
|
+
* @throws Error if no target is found after the timeout.
|
|
92
183
|
*/
|
|
93
|
-
|
|
184
|
+
waitForTarget(appIdKey: AppIdKey, pageIdKey: PageIdKey): Promise<TargetId | undefined>;
|
|
94
185
|
/**
|
|
186
|
+
* Sends a command to the remote debugger with automatic retry logic
|
|
187
|
+
* for target-related errors. Handles cases where targets are not yet
|
|
188
|
+
* available or not supported.
|
|
95
189
|
*
|
|
96
|
-
* @param
|
|
97
|
-
* @param
|
|
98
|
-
* @
|
|
190
|
+
* @param command - The command name to send.
|
|
191
|
+
* @param opts - Options for the command.
|
|
192
|
+
* @param waitForResponse - Whether to wait for a response. Defaults to true.
|
|
193
|
+
* @returns A promise that resolves to the command result or options.
|
|
99
194
|
*/
|
|
100
|
-
|
|
195
|
+
send(command: string, opts: RemoteCommandOpts, waitForResponse?: boolean): Promise<any>;
|
|
101
196
|
/**
|
|
197
|
+
* Sends a command directly to the device, handling message routing,
|
|
198
|
+
* response waiting, and error handling.
|
|
102
199
|
*
|
|
103
|
-
* @
|
|
104
|
-
* @param
|
|
105
|
-
* @param
|
|
106
|
-
* @
|
|
200
|
+
* @template TWaitForResponse - Whether to wait for a response.
|
|
201
|
+
* @param command - The command name to send.
|
|
202
|
+
* @param opts - Options for the command.
|
|
203
|
+
* @param waitForResponse - Whether to wait for a response. Defaults to true.
|
|
204
|
+
* @returns A promise that resolves based on waitForResponse:
|
|
205
|
+
* - If true: resolves to the response value
|
|
206
|
+
* - If false: resolves to the full options object
|
|
107
207
|
*/
|
|
108
|
-
|
|
208
|
+
sendToDevice<TWaitForResponse extends boolean = true>(command: string, opts: RemoteCommandOpts, waitForResponse?: TWaitForResponse): Promise<TWaitForResponse extends true ? any : RemoteCommandOpts>;
|
|
109
209
|
/**
|
|
210
|
+
* Connects to the remote debugger. Must be implemented by subclasses.
|
|
110
211
|
*
|
|
111
|
-
* @
|
|
112
|
-
* @param {string} command
|
|
113
|
-
* @param {import('../types').RemoteCommandOpts} opts
|
|
114
|
-
* @param {TWaitForResponse} [waitForResponse=true]
|
|
115
|
-
* @returns {Promise<TWaitForResponse extends true ? import('../types').RemoteCommandOpts : any>}
|
|
212
|
+
* @throws Error indicating that subclasses must implement this method.
|
|
116
213
|
*/
|
|
117
|
-
sendToDevice<TWaitForResponse extends boolean>(command: string, opts: import("../types").RemoteCommandOpts, waitForResponse?: TWaitForResponse): Promise<TWaitForResponse extends true ? import("../types").RemoteCommandOpts : any>;
|
|
118
214
|
connect(): Promise<void>;
|
|
215
|
+
/**
|
|
216
|
+
* Disconnects from the remote debugger and cleans up event listeners.
|
|
217
|
+
*/
|
|
119
218
|
disconnect(): Promise<void>;
|
|
120
219
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
220
|
+
* Sends a message to the device. Must be implemented by subclasses.
|
|
221
|
+
*
|
|
222
|
+
* @param _command - The command to send.
|
|
223
|
+
* @throws Error indicating that subclasses must implement this method.
|
|
123
224
|
*/
|
|
124
|
-
sendMessage(
|
|
225
|
+
sendMessage(_command: RemoteCommand): Promise<void>;
|
|
125
226
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
227
|
+
* Receives data from the device. Must be implemented by subclasses.
|
|
228
|
+
*
|
|
229
|
+
* @param _data - The data received from the device.
|
|
230
|
+
* @throws Error indicating that subclasses must implement this method.
|
|
128
231
|
*/
|
|
129
|
-
receive(
|
|
232
|
+
receive(_data: any): Promise<void>;
|
|
130
233
|
/**
|
|
234
|
+
* Handles the creation of a new target for an application and page.
|
|
235
|
+
* Initializes the page and waits for readiness if configured.
|
|
131
236
|
*
|
|
132
|
-
* @param
|
|
133
|
-
* @param
|
|
134
|
-
* @param
|
|
135
|
-
* @returns {Promise<void>}
|
|
237
|
+
* @param err - Error if one occurred, undefined otherwise.
|
|
238
|
+
* @param app - The application identifier key.
|
|
239
|
+
* @param targetInfo - Information about the created target.
|
|
136
240
|
*/
|
|
137
|
-
addTarget(err: Error | undefined, app:
|
|
241
|
+
addTarget(err: Error | undefined, app: AppIdKey, targetInfo: TargetInfo): Promise<void>;
|
|
138
242
|
/**
|
|
243
|
+
* Handles updates to provisional targets when they commit.
|
|
139
244
|
*
|
|
140
|
-
* @param
|
|
141
|
-
* @param
|
|
142
|
-
* @param
|
|
143
|
-
* @returns {Promise<void>}
|
|
245
|
+
* @param err - Error if one occurred, undefined otherwise.
|
|
246
|
+
* @param app - The application identifier key.
|
|
247
|
+
* @param targetInfo - Information about the provisional target update.
|
|
144
248
|
*/
|
|
145
|
-
updateTarget(err: Error | undefined, app:
|
|
249
|
+
updateTarget(err: Error | undefined, app: AppIdKey, targetInfo: ProvisionalTargetInfo): Promise<void>;
|
|
146
250
|
/**
|
|
251
|
+
* Handles the destruction of a target, including cleanup of provisional targets.
|
|
147
252
|
*
|
|
148
|
-
* @param
|
|
149
|
-
* @param
|
|
150
|
-
* @param
|
|
151
|
-
* @returns {Promise<void>}
|
|
253
|
+
* @param err - Error if one occurred, undefined otherwise.
|
|
254
|
+
* @param app - The application identifier key.
|
|
255
|
+
* @param targetInfo - Information about the destroyed target.
|
|
152
256
|
*/
|
|
153
|
-
removeTarget(err: Error | undefined, app:
|
|
257
|
+
removeTarget(err: Error | undefined, app: AppIdKey, targetInfo: TargetInfo): Promise<void>;
|
|
154
258
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
* @
|
|
259
|
+
* Gets the target ID for a specific app and page combination.
|
|
260
|
+
*
|
|
261
|
+
* @param appIdKey - The application identifier key.
|
|
262
|
+
* @param pageIdKey - The page identifier key.
|
|
263
|
+
* @returns The target ID if found, undefined otherwise.
|
|
158
264
|
*/
|
|
159
|
-
getTarget(appIdKey?:
|
|
265
|
+
getTarget(appIdKey?: AppIdKey, pageIdKey?: PageIdKey): TargetId | undefined;
|
|
160
266
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
267
|
+
* Selects a page within an application, setting up the Web Inspector session
|
|
268
|
+
* and waiting for the page to be initialized. Mimics the steps that Desktop
|
|
269
|
+
* Safari uses to initialize a Web Inspector session.
|
|
270
|
+
*
|
|
271
|
+
* @param appIdKey - The application identifier key.
|
|
272
|
+
* @param pageIdKey - The page identifier key.
|
|
273
|
+
* @param pageReadinessDetector - Optional detector for determining when the page is ready.
|
|
165
274
|
*/
|
|
166
|
-
selectPage(appIdKey:
|
|
275
|
+
selectPage(appIdKey: AppIdKey, pageIdKey: PageIdKey, pageReadinessDetector?: PageReadinessDetector): Promise<void>;
|
|
167
276
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
277
|
+
* Initializes a page by enabling various Web Inspector domains.
|
|
278
|
+
* Can perform either simple or full initialization based on configuration.
|
|
279
|
+
* Mimics the steps that Desktop Safari Develop tools uses to initialize
|
|
280
|
+
* a Web Inspector session.
|
|
170
281
|
*
|
|
171
|
-
* @param
|
|
172
|
-
* @param
|
|
173
|
-
* @param
|
|
174
|
-
* @returns
|
|
282
|
+
* @param appIdKey - The application identifier key.
|
|
283
|
+
* @param pageIdKey - The page identifier key.
|
|
284
|
+
* @param targetId - Optional target ID. If not provided, will be retrieved from the targets map.
|
|
285
|
+
* @returns A promise that resolves to true if initialization succeeded, false otherwise.
|
|
175
286
|
*/
|
|
176
|
-
_initializePage
|
|
287
|
+
private _initializePage;
|
|
177
288
|
/**
|
|
289
|
+
* Connects to a specific application and returns its page dictionary.
|
|
178
290
|
*
|
|
179
|
-
* @param
|
|
180
|
-
* @returns
|
|
291
|
+
* @param appIdKey - The application identifier key to connect to.
|
|
292
|
+
* @returns A promise that resolves to a tuple containing the connected app ID key
|
|
293
|
+
* and the page dictionary.
|
|
294
|
+
* @throws Error if a new application connects during the process or if the page
|
|
295
|
+
* dictionary is empty.
|
|
181
296
|
*/
|
|
182
|
-
selectApp(appIdKey:
|
|
297
|
+
selectApp(appIdKey: AppIdKey): Promise<[string, StringRecord]>;
|
|
183
298
|
/**
|
|
299
|
+
* Handles execution context creation events by storing the context ID.
|
|
184
300
|
*
|
|
185
|
-
* @param
|
|
186
|
-
* @param
|
|
301
|
+
* @param err - Error if one occurred, undefined otherwise.
|
|
302
|
+
* @param context - The execution context information.
|
|
187
303
|
*/
|
|
188
|
-
onExecutionContextCreated(err: Error |
|
|
304
|
+
onExecutionContextCreated(err: Error | undefined, context: {
|
|
305
|
+
id: number;
|
|
306
|
+
}): void;
|
|
189
307
|
/**
|
|
190
|
-
*
|
|
308
|
+
* Handles garbage collection events by logging them.
|
|
309
|
+
* Garbage collection can affect operation timing.
|
|
191
310
|
*/
|
|
192
311
|
onGarbageCollected(): void;
|
|
193
312
|
/**
|
|
313
|
+
* Handles script parsing events by logging script information.
|
|
194
314
|
*
|
|
195
|
-
* @param
|
|
196
|
-
* @param
|
|
315
|
+
* @param err - Error if one occurred, undefined otherwise.
|
|
316
|
+
* @param scriptInfo - Information about the parsed script.
|
|
197
317
|
*/
|
|
198
|
-
onScriptParsed(err: Error |
|
|
318
|
+
onScriptParsed(err: Error | undefined, scriptInfo: StringRecord): void;
|
|
199
319
|
/**
|
|
320
|
+
* Resumes a paused target.
|
|
200
321
|
*
|
|
201
|
-
* @param
|
|
202
|
-
* @param
|
|
203
|
-
* @param
|
|
204
|
-
* @returns {Promise<void>}
|
|
322
|
+
* @param appIdKey - The application identifier key.
|
|
323
|
+
* @param pageIdKey - The page identifier key.
|
|
324
|
+
* @param targetId - The target ID to resume.
|
|
205
325
|
*/
|
|
206
|
-
_resumeTarget
|
|
326
|
+
private _resumeTarget;
|
|
207
327
|
/**
|
|
328
|
+
* Waits for a page to be ready by periodically checking the document readyState.
|
|
329
|
+
* Uses the provided readiness detector to determine when the page is ready.
|
|
208
330
|
*
|
|
209
|
-
* @param
|
|
210
|
-
* @param
|
|
211
|
-
* @param
|
|
212
|
-
* @param
|
|
213
|
-
* @returns {Promise<void>}
|
|
331
|
+
* @param appIdKey - The application identifier key.
|
|
332
|
+
* @param pageIdKey - The page identifier key.
|
|
333
|
+
* @param targetId - The target ID.
|
|
334
|
+
* @param pageReadinessDetector - The detector for determining page readiness.
|
|
214
335
|
*/
|
|
215
|
-
_waitForPageReadiness
|
|
336
|
+
private _waitForPageReadiness;
|
|
216
337
|
/**
|
|
338
|
+
* Waits for a page to be initialized by acquiring locks on both the page
|
|
339
|
+
* target lock and the page selection lock.
|
|
217
340
|
*
|
|
218
|
-
* @param
|
|
219
|
-
* @param
|
|
220
|
-
* @
|
|
341
|
+
* @param appIdKey - The application identifier key.
|
|
342
|
+
* @param pageIdKey - The page identifier key.
|
|
343
|
+
* @throws Error if no targets are found for the application.
|
|
221
344
|
*/
|
|
222
|
-
waitForPage(appIdKey:
|
|
345
|
+
waitForPage(appIdKey: AppIdKey, pageIdKey: PageIdKey): Promise<void>;
|
|
223
346
|
/**
|
|
224
|
-
*
|
|
347
|
+
* Gets the pending target details if there is a pending request for the given app.
|
|
348
|
+
* Filters out non-page target types (e.g., 'frame').
|
|
225
349
|
*
|
|
226
|
-
* @param
|
|
227
|
-
* @param
|
|
228
|
-
* @returns
|
|
350
|
+
* @param appId - The application identifier key.
|
|
351
|
+
* @param targetInfo - Information about the target.
|
|
352
|
+
* @returns The pending page target details if there's a match, undefined otherwise.
|
|
229
353
|
*/
|
|
230
|
-
_getPendingPageTargetDetails
|
|
354
|
+
private _getPendingPageTargetDetails;
|
|
231
355
|
}
|
|
232
|
-
export
|
|
233
|
-
export type RpcClientOptions = {
|
|
234
|
-
bundleId?: string | undefined;
|
|
235
|
-
platformVersion?: string | undefined;
|
|
236
|
-
isSafari?: boolean | undefined;
|
|
237
|
-
logAllCommunication?: boolean | undefined;
|
|
238
|
-
logAllCommunicationHexDump?: boolean | undefined;
|
|
239
|
-
webInspectorMaxFrameLength?: number | undefined;
|
|
240
|
-
socketChunkSize?: number | undefined;
|
|
241
|
-
fullPageInitialization?: boolean | undefined;
|
|
242
|
-
pageLoadTimeoutMs?: number | undefined;
|
|
243
|
-
udid?: string | undefined;
|
|
244
|
-
targetCreationTimeoutMs?: number | undefined;
|
|
245
|
-
};
|
|
246
|
-
export type PendingPageTargetDetails = {
|
|
247
|
-
appIdKey: import("../types").AppIdKey;
|
|
248
|
-
pageIdKey: import("../types").PageIdKey;
|
|
249
|
-
pageReadinessDetector: PageReadinessDetector | undefined;
|
|
250
|
-
};
|
|
251
|
-
export type PageDict = {
|
|
252
|
-
[key: import("../types").PageIdKey]: import("../types").TargetId;
|
|
253
|
-
};
|
|
254
|
-
export type PagesToTargets = PageDict & {
|
|
255
|
-
provisional?: import("../types").ProvisionalTargetInfo;
|
|
256
|
-
lock: AsyncLock;
|
|
257
|
-
};
|
|
258
|
-
export type AppToTargetsMap = {
|
|
259
|
-
[key: import("../types").AppIdKey]: PagesToTargets;
|
|
260
|
-
};
|
|
261
|
-
export type PageReadinessDetector = {
|
|
262
|
-
timeoutMs: number;
|
|
263
|
-
readinessDetector: (readyState: string) => boolean;
|
|
264
|
-
};
|
|
265
|
-
import RpcMessageHandler from './rpc-message-handler';
|
|
266
|
-
import { RemoteMessages } from './remote-messages';
|
|
267
|
-
import { EventEmitter } from 'node:events';
|
|
356
|
+
export {};
|
|
268
357
|
//# sourceMappingURL=rpc-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-client.d.ts","sourceRoot":"","sources":["../../../lib/rpc/rpc-client.
|
|
1
|
+
{"version":3,"file":"rpc-client.d.ts","sourceRoot":"","sources":["../../../lib/rpc/rpc-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKnD,OAAO,iBAAiB,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,UAAU,EACV,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EAEb,gBAAgB,EAEjB,MAAM,UAAU,CAAC;AAalB,eAAO,MAAM,uBAAuB,kCAAkC,CAAC;AACvE,eAAO,MAAM,2BAA2B,mCAAmC,CAAC;AAG5E;;GAEG;AACH,UAAU,wBAAwB;IAChC,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C;AAED;;GAEG;AACH,UAAU,cAAc;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,qBAAqB,GAAG,SAAS,GAAG,SAAS,CAAC;IACxE,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,IA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