microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.3.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/cdp-proxy/CDPMessageHandlers/iOSDirectCDPMessageHandler.ts

66lines · modeblame

259c018fYuri Skorokhodov5 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import { BaseCDPMessageHandler } from "./baseCDPMessageHandler";
5import { ProcessedCDPMessage } from "./ICDPMessageHandler";
6import { CDP_API_NAMES } from "./CDPAPINames";
7
8export class IOSDirectCDPMessageHandler extends BaseCDPMessageHandler {
9private isBackcompatConfigured: boolean;
10
11constructor() {
12super();
13this.isBackcompatConfigured = false;
14}
15
16public processDebuggerCDPMessage(event: any): ProcessedCDPMessage {
17let sendBack = false;
18if (!this.isBackcompatConfigured && event.method === CDP_API_NAMES.RUNTIME_ENABLE) {
19this.configureTargetForIWDPCommunication();
20}
21return {
22event,
23sendBack,
24};
25}
26
27public processApplicationCDPMessage(event: any): ProcessedCDPMessage {
28if (event.method === CDP_API_NAMES.CONSOLE_MESSAGE_ADDED) {
29event = this.processDeprecatedConsoleMessage(event);
30}
31if (event.result && event.result.properties) {
32event.result = { result: event.result.properties };
33}
34return {
35event,
36sendBack: false,
37};
38}
39
40private processDeprecatedConsoleMessage(event: any) {
41return {
42method: CDP_API_NAMES.RUNTIME_CONSOLE_API_CALLED,
43params: {
44type: event.params.message.type,
45timestamp: event.params.message.timestamp,
34472878RedMickey5 years ago46args: event.params.message.parameters || [
47{ type: "string", value: event.params.message.text },
48],
49stackTrace: {
50callFrames: event.params.message.stack || event.params.message.stackTrace,
51},
259c018fYuri Skorokhodov5 years ago52executionContextId: 1,
53},
54};
55}
56
57private configureTargetForIWDPCommunication(): void {
58this.isBackcompatConfigured = true;
59try {
60this.applicationTarget?.api.Console.enable({});
61this.applicationTarget?.api.Debugger.setBreakpointsActive({ active: true });
62} catch (err) {
63// Specifically ignore a fail here since it's only for backcompat
64}
65}
34472878RedMickey5 years ago66}