-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathdebug-service-base.ts
57 lines (45 loc) · 2.26 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
49
50
51
52
53
54
55
56
57
import { EventEmitter } from "events";
export abstract class DebugServiceBase extends EventEmitter implements IDeviceDebugService {
constructor(
protected device: Mobile.IDevice,
protected $devicesService: Mobile.IDevicesService
) {
super();
}
public abstract get platform(): string;
public abstract async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<IDebugResultInfo>;
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, legacy?: boolean): string {
// corresponds to 55.0.2883 Chrome version
// SHA is taken from https://chromium.googlesource.com/chromium/src/+/55.0.2883.100
// This SHA is old and does not support debugging with HMR.
// In case we want to stick with concrete SHA, get it from one of the tags https://chromium.googlesource.com/chromium/src/
// IMPORTANT: When you get the SHA, ensure you are using the `parent` commit, not the actual one.
// Using the actual commit will result in 404 error in the remote serve.
const commitSHA = debugOptions.devToolsCommit || "02e6bde1bbe34e43b309d4ef774b1168d25fd024";
const devToolsProtocol = `${legacy ? 'chrome-' : ''}devtools`;
let chromeDevToolsPrefix = `${devToolsProtocol}://devtools/remote/serve_file/@${commitSHA}`;
if (debugOptions.useBundledDevTools === undefined || debugOptions.useBundledDevTools) {
chromeDevToolsPrefix = `${devToolsProtocol}://devtools/bundled`;
}
if (debugOptions.useHttpUrl) {
chromeDevToolsPrefix = `https://chrome-devtools-frontend.appspot.com/serve_file/@${commitSHA}`;
}
const chromeUrl = `${chromeDevToolsPrefix}/inspector.html?ws=localhost:${port}${legacy ? '&experiments=true' : ''}`;
return chromeUrl;
}
}