Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
jlipps committed Aug 28, 2023
1 parent 326b3e9 commit 923e1b3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 18 deletions.
15 changes: 6 additions & 9 deletions lib/mixins/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async function connect (timeout = APP_CONNECT_TIMEOUT_MS) {
try {
await waitForCondition(() => !_.isEmpty(this.appDict), {
waitMs: timeout,
interval: APP_CONNECT_INTERVAL_MS,
intervalMs: APP_CONNECT_INTERVAL_MS,
});
} catch (err) {
log.debug(`Timed out waiting for applications to be reported`);
Expand Down Expand Up @@ -181,15 +181,15 @@ async function selectApp (currentUrl = null, maxTries = SELECT_APP_RETRIES, igno
* @returns {Promise<AppPages?>}
*/
async function searchForApp (currentUrl, maxTries, ignoreAboutBlankUrl) {
if (!this.rpcClient) {
throw new Error('rpcClient is undefined. Is the debugger connected?');
}

const bundleIds = this.includeSafari && !this.isSafari
? [this.bundleId, ...this.additionalBundleIds, SAFARI_BUNDLE_ID]
: [this.bundleId, ...this.additionalBundleIds];
try {
return await retryInterval(maxTries, SELECT_APP_RETRY_SLEEP_MS, async (retryCount) => {
if (!this.rpcClient) {
throw new Error('rpcClient is undefined. Is the debugger connected?');
}

logApplicationDictionary(this.appDict);
const possibleAppIds = getPossibleDebuggerAppKeys(bundleIds, this.appDict);
log.debug(`Trying out the possible app ids: ${possibleAppIds.join(', ')} (try #${retryCount + 1} of ${maxTries})`);
Expand All @@ -200,10 +200,7 @@ async function searchForApp (currentUrl, maxTries, ignoreAboutBlankUrl) {
continue;
}
log.debug(`Attempting app '${attemptedAppIdKey}'`);
// @ts-ignore rpcClient must be defined
const [appIdKey, pageDict] = await this.rpcClient.selectApp(
attemptedAppIdKey, this.onAppConnect.bind(this)
);
const [appIdKey, pageDict] = await this.rpcClient.selectApp(attemptedAppIdKey);
// in iOS 8.2 the connect logic happens, but with an empty dictionary
// which leads to the remote debugger getting disconnected, and into a loop
if (_.isEmpty(pageDict)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/message-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function onPageChange (err, appIdKey, pageDict) {
async function onAppConnect (err, dict) {
const appIdKey = dict.WIRApplicationIdentifierKey;
log.debug(`Notified that new application '${appIdKey}' has connected`);
await this.useAppDictLock((done) => {
await this.useAppDictLock((/** @type {() => Void} */done) => {
try {
this.updateAppsWithDict(dict);
} finally {
Expand Down
2 changes: 1 addition & 1 deletion lib/remote-debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class RemoteDebugger extends EventEmitter {
static EVENT_DISCONNECT;

// methods
/** @type {(connId: string) => Record<string, any>} */
/** @type {() => Promise<void>} */
setConnectionKey;
/** @type {() => Promise<void>} */
disconnect;
Expand Down
6 changes: 0 additions & 6 deletions lib/rpc/rpc-client-real-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ export default class RpcClientRealDevice extends RpcClient {
super(Object.assign({
shouldCheckForTarget: false,
}, opts));

const {
udid,
} = opts;

this.udid = udid;
}

async connect () {
Expand Down
3 changes: 3 additions & 0 deletions lib/rpc/rpc-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default class RpcClient {
webInspectorMaxFrameLength,
socketChunkSize,
fullPageInitialization = false,
udid,
} = opts;

this.isSafari = isSafari;
Expand All @@ -59,6 +60,8 @@ export default class RpcClient {
this.senderId = util.uuidV4();
this.msgId = 0;

this.udid = udid;

this.logAllCommunication = logAllCommunication;
this.logAllCommunicationHexDump = logAllCommunicationHexDump;
this.socketChunkSize = socketChunkSize;
Expand Down
3 changes: 2 additions & 1 deletion test/unit/mixins/execute-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ describe('execute', function () {
rpcClient: {
send () {
return {result: {objectId: 'fake-object-id'}};
}
},
isConnected: true,
},
waitForDom () { },
pageLoading: true,
Expand Down

0 comments on commit 923e1b3

Please sign in to comment.