in src/cdpTargetsProvider.ts [31:85]
async getChildren(element?: CDPTarget): Promise<CDPTarget[]> {
let targets: CDPTarget[] = [];
const willShowWorkers = vscode.workspace.getConfiguration(SETTINGS_STORE_NAME).get('showWorkers');
if (!element) {
// Get a list of the targets available
const { hostname, port, useHttps } = getRemoteEndpointSettings();
const responseArray = await getListOfTargets(hostname, port, useHttps);
if (Array.isArray(responseArray)) {
await this.clearFaviconResourceDirectory();
if (responseArray.length > 0) {
const responseIconPromiseArray: Array<Promise<IRemoteTargetJson>> = [];
responseArray.forEach((target: IRemoteTargetJson) => {
const actualTarget = fixRemoteWebSocket(hostname, port, target);
if (actualTarget.type === 'page' || actualTarget.type === 'iframe') {
responseIconPromiseArray.push(this.downloadFaviconFromSitePromise(actualTarget));
} else if ((actualTarget.type !== 'service_worker' && actualTarget.type !== 'shared_worker') || willShowWorkers) {
targets.push(new CDPTarget(actualTarget, '', this.extensionPath));
}
});
const iconResultsArray = await Promise.all(responseIconPromiseArray);
for (const actualTarget of iconResultsArray) {
if (isLocalResource(actualTarget.faviconUrl)) {
targets.push(new CDPTarget(actualTarget, '', this.extensionPath, actualTarget.faviconUrl));
} else {
targets.push(new CDPTarget(actualTarget, '', this.extensionPath));
}
}
}
} else {
this.telemetryReporter.sendTelemetryEvent('view/error/no_json_array');
}
// Sort the targets by type and then title, but keep 'page' types at the top
// since those are the ones most likely to be the ones the user wants.
targets.sort((a: CDPTarget, b: CDPTarget) => {
if (a.targetJson.type === b.targetJson.type) {
return a.targetJson.title < b.targetJson.title ? -1 : 1;
} if (a.targetJson.type === 'page') {
return -1;
} if (b.targetJson.type === 'page') {
return 1;
}
return a.targetJson.type < b.targetJson.type ? -1 : 1;
});
} else {
// Just expand the element to show its properties
targets = element.getChildren();
}
return targets;
}