microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.7.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/networkInspector/clientUtils.ts

73lines · modeblame

4bb0956eRedMickey5 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 { ClientIdConstituents, ClientQuery } from "./clientDevice";
5import { OutputChannelLogger } from "../log/OutputChannelLogger";
6
7export enum ClientOS {
8iOS = "iOS",
9Android = "Android",
10Windows = "Windows",
11MacOS = "MacOS",
12}
13
14/**
15* @preserve
16* Start region: the code is borrowed from https://github.com/facebook/flipper/blob/v0.79.1/desktop/app/src/utils/clientUtils.tsx#L60-L78
17*
18* Copyright (c) Facebook, Inc. and its affiliates.
19*
20* This source code is licensed under the MIT license found in the
21* LICENSE file in the root directory of this source tree.
22*
23* @format
24*/
25export function buildClientId(
26clientInfo: {
27app: string;
28os: ClientOS;
29device: string;
30device_id: string;
31},
32logger: OutputChannelLogger,
33): string {
34for (const key of ["app", "os", "device", "device_id"] as Array<keyof ClientIdConstituents>) {
35if (!clientInfo[key]) {
36logger.error(`Attempted to build clientId with invalid ${key}: "${clientInfo[key]}`);
37}
38}
39const escapedName = escape(clientInfo.app);
40return `${escapedName}#${clientInfo.os}#${clientInfo.device}#${clientInfo.device_id}`;
41}
42
43/**
44* @preserve
45* End region: https://github.com/facebook/flipper/blob/v0.79.1/desktop/app/src/utils/clientUtils.tsx#L60-L78
46*/
47
48/**
49* @preserve
50* Start region: the code is borrowed from https://github.com/facebook/flipper/blob/v0.79.1/desktop/app/src/server.tsx#L74-L83
51*
52* Copyright (c) Facebook, Inc. and its affiliates.
53*
54* This source code is licensed under the MIT license found in the
55* LICENSE file in the root directory of this source tree.
56*
57* @format
58*/
59export function appNameWithUpdateHint(query: ClientQuery): string {
60// in previous version (before 3), app may not appear in correct device
61// section because it refers to the name given by client which is not fixed
62// for android emulators, so it is indicated as outdated so that developers
63// might want to update SDK to get rid of this connection swap problem
64if (query.os === ClientOS.Android && (!query.sdk_version || query.sdk_version < 3)) {
65return query.app + " (Outdated SDK)";
66}
67return query.app;
68}
69
70/**
71* @preserve
72* End region: https://github.com/facebook/flipper/blob/v0.79.1/desktop/app/src/server.tsx#L74-L83
73*/