microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
e4ac653e109fbed056449d4ec6ef8b37b6dce8c0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/common/extensionMessaging.ts

42lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import {HostPlatform} from "./hostPlatform";
5import {Crypto} from "./node/crypto";
6
7/**
8 * Defines the messages sent to the extension.
9 * Add new messages to this enum.
10 */
11export enum ExtensionMessage {
12 START_PACKAGER,
13 STOP_PACKAGER,
14 PREWARM_BUNDLE_CACHE,
15 START_MONITORING_LOGCAT,
16 STOP_MONITORING_LOGCAT,
17 GET_PACKAGER_PORT,
18 SEND_TELEMETRY,
19}
20
21export interface MessageWithArguments {
22 message: ExtensionMessage;
23 args?: any[];
24}
25
26export let ErrorMarker = "vscodereactnative-error-marker";
27
28export class MessagingChannel {
29 constructor(private projectRootPath: string) {
30 // Nothing needed here
31 }
32
33 public getPath(): string {
34 /* We need to use a different value for each VS Code window so the pipe names won't clash.
35 We create the pipe path hashing the user id + project root path so both client and server
36 will generate the same path, yet it's unique for each vs code instance */
37 const userID = HostPlatform.getUserID();
38 const uniqueSeed = `${userID}:${this.projectRootPath}`;
39 const hash = new Crypto().hash(uniqueSeed);
40 return HostPlatform.getPipePath(`vscode-reactnative-${hash}`);
41 }
42}
43