-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathdebug-service-base.ts
48 lines (36 loc) · 1.82 KB
/
debug-service-base.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { EventEmitter } from "events";
export abstract class DebugServiceBase extends EventEmitter implements IPlatformDebugService {
constructor(protected $devicesService: Mobile.IDevicesService) { super(); }
public abstract get platform(): string;
public abstract async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string>;
public abstract async debugStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<void>;
public abstract async debugStop(): Promise<void>;
protected getCanExecuteAction(deviceIdentifier: string): (device: Mobile.IDevice) => boolean {
return (device: Mobile.IDevice): boolean => {
if (deviceIdentifier) {
let isSearchedDevice = device.deviceInfo.identifier === deviceIdentifier;
if (!isSearchedDevice) {
const deviceByDeviceOption = this.$devicesService.getDeviceByDeviceOption();
isSearchedDevice = deviceByDeviceOption && device.deviceInfo.identifier === deviceByDeviceOption.deviceInfo.identifier;
}
return isSearchedDevice;
} else {
return true;
}
};
}
protected getChromeDebugUrl(debugOptions: IDebugOptions, port: number): string {
// corresponds to 55.0.2883 Chrome version
const commitSHA = debugOptions.devToolsCommit || "02e6bde1bbe34e43b309d4ef774b1168d25fd024";
debugOptions.useHttpUrl = debugOptions.useHttpUrl === undefined ? false : debugOptions.useHttpUrl;
let chromeDevToolsPrefix = `chrome-devtools://devtools/remote/serve_file/@${commitSHA}`;
if (debugOptions.useBundledDevTools) {
chromeDevToolsPrefix = "chrome-devtools://devtools/bundled";
}
if (debugOptions.useHttpUrl) {
chromeDevToolsPrefix = `https://chrome-devtools-frontend.appspot.com/serve_file/@${commitSHA}`;
}
const chromeUrl = `${chromeDevToolsPrefix}/inspector.html?experiments=true&ws=localhost:${port}`;
return chromeUrl;
}
}