forked from NativeScript/nativescript-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug-service-base.ts
80 lines (69 loc) · 2.34 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { EventEmitter } from "events";
import {
IDebugData,
IDebugOptions,
IDeviceDebugService,
IDebugResultInfo,
} from "../definitions/debug";
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 debug(
debugData: IDebugData,
debugOptions: IDebugOptions
): Promise<IDebugResultInfo>;
public abstract 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
// 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 = `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}`;
return chromeUrl;
}
}