microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0fc1f1ded677de3d424c138ff2b42948ec8d4f08

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/common/extensionMessaging.ts

44lines · 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 OPEN_FILE_AT_LOCATION,
20}
21
22export interface MessageWithArguments {
23 message: ExtensionMessage;
24 args?: any[];
25}
26
27export let ErrorMarker = "vscodereactnative-error-marker";
28
29export class MessagingChannel {
30 constructor(private projectRootPath: string) {
31 // Nothing needed here
32 }
33
34 public getPath(): string {
35 /* We need to use a different value for each VS Code window so the pipe names won't clash.
36 We create the pipe path hashing the user id + project root path so both client and server
37 will generate the same path, yet it's unique for each vs code instance */
38 const userID = HostPlatform.getUserID();
39 const normalizedRootPath = this.projectRootPath.toLowerCase();
40 const uniqueSeed = `${userID}:${normalizedRootPath}`;
41 const hash = new Crypto().hash(uniqueSeed);
42 return HostPlatform.getPipePath(`vscode-reactnative-${hash}`);
43 }
44}
45