microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
test-microbuild1

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/networkInspector/clientUtils.ts

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