appium-remote-debugger 12.2.6 → 12.2.7
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/remote-debugger.d.ts +17 -17
- package/build/lib/remote-debugger.d.ts.map +1 -1
- package/build/lib/remote-debugger.js +4 -4
- package/build/lib/remote-debugger.js.map +1 -1
- package/build/lib/rpc/remote-messages.d.ts +5 -5
- package/build/lib/rpc/remote-messages.d.ts.map +1 -1
- package/build/lib/rpc/remote-messages.js +10 -10
- package/build/lib/rpc/remote-messages.js.map +1 -1
- package/build/lib/rpc/rpc-client.d.ts +8 -8
- package/build/lib/rpc/rpc-client.d.ts.map +1 -1
- package/build/lib/rpc/rpc-client.js +110 -74
- package/build/lib/rpc/rpc-client.js.map +1 -1
- package/build/lib/types.d.ts +4 -3
- package/build/lib/types.d.ts.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/remote-debugger.ts +21 -21
- package/lib/rpc/remote-messages.js +10 -10
- package/lib/rpc/rpc-client.js +110 -77
- package/lib/types.ts +4 -3
- package/package.json +1 -1
package/lib/remote-debugger.ts
CHANGED
|
@@ -32,35 +32,35 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
32
32
|
protected _skippedApps: string[];
|
|
33
33
|
protected _clientEventListeners: StringRecord<EventListener[]>;
|
|
34
34
|
protected _appDict: AppDict;
|
|
35
|
-
protected _appIdKey
|
|
36
|
-
protected _pageIdKey
|
|
37
|
-
protected _connectedDrivers
|
|
38
|
-
protected _currentState
|
|
39
|
-
protected _pageLoadDelay
|
|
35
|
+
protected _appIdKey?: AppIdKey;
|
|
36
|
+
protected _pageIdKey?: PageIdKey;
|
|
37
|
+
protected _connectedDrivers?: StringRecord[];
|
|
38
|
+
protected _currentState?: string;
|
|
39
|
+
protected _pageLoadDelay?: B<void>;
|
|
40
40
|
protected _rpcClient: RpcClient | null;
|
|
41
41
|
protected _pageLoading: boolean;
|
|
42
42
|
protected _navigatingToPage: boolean;
|
|
43
43
|
protected _allowNavigationWithoutReload: boolean;
|
|
44
|
-
protected _pageLoadMs
|
|
45
|
-
protected readonly _pageLoadStrategy
|
|
44
|
+
protected _pageLoadMs?: number;
|
|
45
|
+
protected readonly _pageLoadStrategy?: string;
|
|
46
46
|
protected readonly _log: AppiumLogger;
|
|
47
|
-
protected readonly _bundleId
|
|
48
|
-
protected readonly _additionalBundleIds
|
|
49
|
-
protected readonly _platformVersion
|
|
47
|
+
protected readonly _bundleId?: string;
|
|
48
|
+
protected readonly _additionalBundleIds?: string[];
|
|
49
|
+
protected readonly _platformVersion?: string;
|
|
50
50
|
protected readonly _isSafari: boolean;
|
|
51
51
|
protected readonly _includeSafari: boolean;
|
|
52
52
|
protected readonly _useNewSafari: boolean;
|
|
53
53
|
protected readonly _garbageCollectOnExecute: boolean;
|
|
54
|
-
protected readonly _host
|
|
55
|
-
protected readonly _port
|
|
56
|
-
protected readonly _socketPath
|
|
57
|
-
protected readonly _remoteDebugProxy
|
|
54
|
+
protected readonly _host?: string;
|
|
55
|
+
protected readonly _port?: number;
|
|
56
|
+
protected readonly _socketPath?: string;
|
|
57
|
+
protected readonly _remoteDebugProxy?: any;
|
|
58
58
|
protected readonly _pageReadyTimeout: number;
|
|
59
59
|
protected readonly _logAllCommunication: boolean;
|
|
60
60
|
protected readonly _logAllCommunicationHexDump: boolean;
|
|
61
|
-
protected readonly _socketChunkSize
|
|
62
|
-
protected readonly _webInspectorMaxFrameLength
|
|
63
|
-
protected readonly _fullPageInitialization
|
|
61
|
+
protected readonly _socketChunkSize?: number;
|
|
62
|
+
protected readonly _webInspectorMaxFrameLength?: number;
|
|
63
|
+
protected readonly _fullPageInitialization?: boolean;
|
|
64
64
|
|
|
65
65
|
// events
|
|
66
66
|
static readonly EVENT_PAGE_CHANGE: string;
|
|
@@ -187,8 +187,8 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
187
187
|
setup (): void {
|
|
188
188
|
// app handling configuration
|
|
189
189
|
this._appDict = {};
|
|
190
|
-
this._appIdKey =
|
|
191
|
-
this._pageIdKey =
|
|
190
|
+
this._appIdKey = undefined;
|
|
191
|
+
this._pageIdKey = undefined;
|
|
192
192
|
this._pageLoading = false;
|
|
193
193
|
this._navigatingToPage = false;
|
|
194
194
|
this._currentState = undefined;
|
|
@@ -203,8 +203,8 @@ export class RemoteDebugger extends EventEmitter {
|
|
|
203
203
|
this.log.debug('Cleaning up listeners');
|
|
204
204
|
|
|
205
205
|
this._appDict = {};
|
|
206
|
-
this._appIdKey =
|
|
207
|
-
this._pageIdKey =
|
|
206
|
+
this._appIdKey = undefined;
|
|
207
|
+
this._pageIdKey = undefined;
|
|
208
208
|
this._pageLoading = false;
|
|
209
209
|
|
|
210
210
|
this._rpcClient = null;
|
|
@@ -81,7 +81,7 @@ export class RemoteMessages {
|
|
|
81
81
|
* @param {string} connId
|
|
82
82
|
* @param {string} senderId
|
|
83
83
|
* @param {import('../types').AppIdKey} appIdKey
|
|
84
|
-
* @param {import('../types').PageIdKey} pageIdKey
|
|
84
|
+
* @param {import('../types').PageIdKey} [pageIdKey]
|
|
85
85
|
* @returns {import('../types').RemoteCommand}
|
|
86
86
|
*/
|
|
87
87
|
setSenderKey (connId, senderId, appIdKey, pageIdKey) {
|
|
@@ -101,8 +101,8 @@ export class RemoteMessages {
|
|
|
101
101
|
*
|
|
102
102
|
* @param {string} connId
|
|
103
103
|
* @param {import('../types').AppIdKey} appIdKey
|
|
104
|
-
* @param {import('../types').PageIdKey} pageIdKey
|
|
105
|
-
* @param {boolean} enabled
|
|
104
|
+
* @param {import('../types').PageIdKey} [pageIdKey]
|
|
105
|
+
* @param {boolean} [enabled]
|
|
106
106
|
* @returns {import('../types').RemoteCommand}
|
|
107
107
|
*/
|
|
108
108
|
indicateWebView (connId, appIdKey, pageIdKey, enabled) {
|
|
@@ -291,18 +291,18 @@ export class RemoteMessages {
|
|
|
291
291
|
}
|
|
292
292
|
return this.setConnectionKey(connId);
|
|
293
293
|
case 'indicateWebView':
|
|
294
|
-
if (!connId) {
|
|
295
|
-
throw new Error('Cannot indicate web view without a connection ID');
|
|
294
|
+
if (!connId || !appIdKey) {
|
|
295
|
+
throw new Error('Cannot indicate web view without a connection ID and app ID');
|
|
296
296
|
}
|
|
297
297
|
return this.indicateWebView(connId, appIdKey, pageIdKey, !!opts.enabled);
|
|
298
298
|
case 'connectToApp':
|
|
299
|
-
if (!connId) {
|
|
300
|
-
throw new Error('Cannot connect to app without a connection ID');
|
|
299
|
+
if (!connId || !appIdKey) {
|
|
300
|
+
throw new Error('Cannot connect to app without a connection ID and app ID');
|
|
301
301
|
}
|
|
302
302
|
return this.connectToApp(connId, appIdKey);
|
|
303
303
|
case 'setSenderKey':
|
|
304
|
-
if (!connId || !senderId) {
|
|
305
|
-
throw new Error('Cannot set sender key without a connection ID and
|
|
304
|
+
if (!connId || !senderId || !appIdKey) {
|
|
305
|
+
throw new Error('Cannot set sender key without a connection ID, sender ID, and app ID');
|
|
306
306
|
}
|
|
307
307
|
return this.setSenderKey(connId, senderId, appIdKey, pageIdKey);
|
|
308
308
|
case 'launchApplication':
|
|
@@ -315,7 +315,7 @@ export class RemoteMessages {
|
|
|
315
315
|
// deal with WebKit commands
|
|
316
316
|
const builderFunction = COMMANDS[command] || MINIMAL_COMMAND;
|
|
317
317
|
return this[builderFunction]({
|
|
318
|
-
...getProtocolCommand(id, command, opts),
|
|
318
|
+
...getProtocolCommand(/** @type {string} */ (id), command, opts),
|
|
319
319
|
connId,
|
|
320
320
|
appIdKey,
|
|
321
321
|
senderId,
|
package/lib/rpc/rpc-client.js
CHANGED
|
@@ -298,11 +298,11 @@ export class RpcClient {
|
|
|
298
298
|
/**
|
|
299
299
|
*
|
|
300
300
|
* @param {string} command
|
|
301
|
-
* @param {
|
|
301
|
+
* @param {import('../types').RemoteCommandOpts} opts
|
|
302
302
|
* @param {boolean} [waitForResponse]
|
|
303
303
|
* @returns {Promise<any>}
|
|
304
304
|
*/
|
|
305
|
-
async send (command, opts
|
|
305
|
+
async send (command, opts, waitForResponse = true) {
|
|
306
306
|
const timer = new timing.Timer().start();
|
|
307
307
|
const {
|
|
308
308
|
appIdKey,
|
|
@@ -319,9 +319,9 @@ export class RpcClient {
|
|
|
319
319
|
);
|
|
320
320
|
this.isTargetBased = false;
|
|
321
321
|
return await this.sendToDevice(command, opts, waitForResponse);
|
|
322
|
-
} else if (NO_TARGET_PRESENT_YET_ERRORS.some((error) => messageLc.includes(error))) {
|
|
322
|
+
} else if (appIdKey && NO_TARGET_PRESENT_YET_ERRORS.some((error) => messageLc.includes(error))) {
|
|
323
323
|
this.isTargetBased = true;
|
|
324
|
-
await this.waitForTarget(appIdKey, pageIdKey);
|
|
324
|
+
await this.waitForTarget(appIdKey, /** @type {import('../types').PageIdKey} */ (pageIdKey));
|
|
325
325
|
return await this.sendToDevice(command, opts, waitForResponse);
|
|
326
326
|
}
|
|
327
327
|
throw err;
|
|
@@ -333,11 +333,11 @@ export class RpcClient {
|
|
|
333
333
|
/**
|
|
334
334
|
*
|
|
335
335
|
* @param {string} command
|
|
336
|
-
* @param {
|
|
336
|
+
* @param {import('../types').RemoteCommandOpts} opts
|
|
337
337
|
* @param {boolean} [waitForResponse]
|
|
338
338
|
* @returns {Promise<any>}
|
|
339
339
|
*/
|
|
340
|
-
async sendToDevice (command, opts
|
|
340
|
+
async sendToDevice (command, opts, waitForResponse = true) {
|
|
341
341
|
return await new B(async (resolve, reject) => {
|
|
342
342
|
// promise to be resolved whenever remote debugger
|
|
343
343
|
// replies to our request
|
|
@@ -548,11 +548,10 @@ export class RpcClient {
|
|
|
548
548
|
targets[page] = newTargetId;
|
|
549
549
|
const opts = {appIdKey: app, pageIdKey: parseInt(page, 10)};
|
|
550
550
|
(async () => {
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
log.warn(err.message);
|
|
551
|
+
if (this.fullPageInitialization) {
|
|
552
|
+
await this.initializePageFull(opts.appIdKey, opts.pageIdKey);
|
|
553
|
+
} else {
|
|
554
|
+
await this.initializePage(opts.appIdKey, opts.pageIdKey);
|
|
556
555
|
}
|
|
557
556
|
this._targetSubscriptions.emit(ON_TARGET_PROVISIONED_EVENT, {
|
|
558
557
|
...opts,
|
|
@@ -579,11 +578,14 @@ export class RpcClient {
|
|
|
579
578
|
}
|
|
580
579
|
|
|
581
580
|
/**
|
|
582
|
-
* @param {import('../types').AppIdKey} appIdKey
|
|
583
|
-
* @param {import('../types').PageIdKey} pageIdKey
|
|
584
|
-
* @returns {
|
|
581
|
+
* @param {import('../types').AppIdKey} [appIdKey]
|
|
582
|
+
* @param {import('../types').PageIdKey} [pageIdKey]
|
|
583
|
+
* @returns {string | undefined}
|
|
585
584
|
*/
|
|
586
585
|
getTarget (appIdKey, pageIdKey) {
|
|
586
|
+
if (!appIdKey || !pageIdKey) {
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
587
589
|
return (this.targets[appIdKey] || {})[pageIdKey];
|
|
588
590
|
}
|
|
589
591
|
|
|
@@ -641,17 +643,25 @@ export class RpcClient {
|
|
|
641
643
|
pageIdKey,
|
|
642
644
|
};
|
|
643
645
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
+
// The sequence of domains is important
|
|
647
|
+
for (const domain of [
|
|
648
|
+
'Inspector.enable',
|
|
649
|
+
'Page.enable',
|
|
650
|
+
'Runtime.enable',
|
|
646
651
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
await this.send('Debugger.enable', sendOpts, false);
|
|
652
|
-
await this.send('Console.enable', sendOpts, false);
|
|
652
|
+
'Network.enable',
|
|
653
|
+
'Heap.enable',
|
|
654
|
+
'Debugger.enable',
|
|
655
|
+
'Console.enable',
|
|
653
656
|
|
|
654
|
-
|
|
657
|
+
'Inspector.initialized',
|
|
658
|
+
]) {
|
|
659
|
+
try {
|
|
660
|
+
await this.send(domain, sendOpts);
|
|
661
|
+
} catch (err) {
|
|
662
|
+
log.info(`Cannot enable domain '${domain}' during initialization: ${err.message}`);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
655
665
|
}
|
|
656
666
|
|
|
657
667
|
/**
|
|
@@ -668,61 +678,84 @@ export class RpcClient {
|
|
|
668
678
|
pageIdKey,
|
|
669
679
|
};
|
|
670
680
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
681
|
+
// The sequence of commands here is important
|
|
682
|
+
const domainsToOptsMap = {
|
|
683
|
+
'Inspector.enable': sendOpts,
|
|
684
|
+
'Page.enable': sendOpts,
|
|
685
|
+
'Runtime.enable': sendOpts,
|
|
686
|
+
|
|
687
|
+
'Page.getResourceTree': sendOpts,
|
|
688
|
+
'Network.enable': sendOpts,
|
|
689
|
+
'Network.setResourceCachingDisabled': {
|
|
690
|
+
disabled: false,
|
|
691
|
+
...sendOpts,
|
|
692
|
+
},
|
|
693
|
+
'DOMStorage.enable': sendOpts,
|
|
694
|
+
'Database.enable': sendOpts,
|
|
695
|
+
'IndexedDB.enable': sendOpts,
|
|
696
|
+
'CSS.enable': sendOpts,
|
|
697
|
+
'Heap.enable': sendOpts,
|
|
698
|
+
'Memory.enable': sendOpts,
|
|
699
|
+
'ApplicationCache.enable': sendOpts,
|
|
700
|
+
'ApplicationCache.getFramesWithManifests': sendOpts,
|
|
701
|
+
'Timeline.setInstruments': {
|
|
702
|
+
instruments: ['Timeline', 'ScriptProfiler', 'CPU'],
|
|
703
|
+
...sendOpts,
|
|
704
|
+
},
|
|
705
|
+
'Timeline.setAutoCaptureEnabled': {
|
|
706
|
+
enabled: false,
|
|
707
|
+
...sendOpts,
|
|
708
|
+
},
|
|
709
|
+
'Debugger.enable': sendOpts,
|
|
710
|
+
'Debugger.setBreakpointsActive': {
|
|
711
|
+
active: true,
|
|
712
|
+
...sendOpts,
|
|
713
|
+
},
|
|
714
|
+
'Debugger.setPauseOnExceptions': {
|
|
715
|
+
state: 'none',
|
|
716
|
+
...sendOpts,
|
|
717
|
+
},
|
|
718
|
+
'Debugger.setPauseOnAssertions': {
|
|
719
|
+
enabled: false,
|
|
720
|
+
...sendOpts,
|
|
721
|
+
},
|
|
722
|
+
'Debugger.setAsyncStackTraceDepth': {
|
|
723
|
+
depth: 200,
|
|
724
|
+
...sendOpts,
|
|
725
|
+
},
|
|
726
|
+
'Debugger.setPauseForInternalScripts': {
|
|
727
|
+
shouldPause: false,
|
|
728
|
+
...sendOpts,
|
|
729
|
+
},
|
|
730
|
+
'LayerTree.enable': sendOpts,
|
|
731
|
+
'Worker.enable': sendOpts,
|
|
732
|
+
'Canvas.enable': sendOpts,
|
|
733
|
+
'Console.enable': sendOpts,
|
|
734
|
+
'DOM.getDocument': sendOpts,
|
|
735
|
+
'Console.getLoggingChannels': sendOpts,
|
|
736
|
+
|
|
737
|
+
'Inspector.initialized': sendOpts,
|
|
738
|
+
};
|
|
724
739
|
|
|
725
|
-
|
|
740
|
+
for (const [domain, opts] of Object.entries(domainsToOptsMap)) {
|
|
741
|
+
try {
|
|
742
|
+
const res = await this.send(domain, opts);
|
|
743
|
+
if (domain === 'Console.getLoggingChannels') {
|
|
744
|
+
for (const source of (res?.channels || []).map((/** @type {{ source: any; }} */ entry) => entry.source)) {
|
|
745
|
+
try {
|
|
746
|
+
await this.send('Console.setLoggingChannelLevel', Object.assign({
|
|
747
|
+
source,
|
|
748
|
+
level: 'verbose',
|
|
749
|
+
}, sendOpts));
|
|
750
|
+
} catch (err) {
|
|
751
|
+
log.info(`Cannot set logging channel level for '${source}': ${err.message}`);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
} catch (err) {
|
|
756
|
+
log.info(`Cannot enable domain '${domain}' during full initialization: ${err.message}`);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
726
759
|
}
|
|
727
760
|
|
|
728
761
|
/**
|
package/lib/types.ts
CHANGED
|
@@ -85,14 +85,15 @@ export type AppIdKey = string | number;
|
|
|
85
85
|
export type PageIdKey = string | number;
|
|
86
86
|
|
|
87
87
|
export interface RemoteCommandOpts {
|
|
88
|
-
appIdKey
|
|
89
|
-
pageIdKey
|
|
90
|
-
id
|
|
88
|
+
appIdKey?: AppIdKey;
|
|
89
|
+
pageIdKey?: PageIdKey;
|
|
90
|
+
id?: string;
|
|
91
91
|
connId?: string;
|
|
92
92
|
senderId?: string;
|
|
93
93
|
targetId?: string;
|
|
94
94
|
bundleId?: string;
|
|
95
95
|
enabled?: boolean;
|
|
96
|
+
[key: string]: any;
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
export interface ProtocolCommandOpts {
|