forked from react/react-native-devtools-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmobile_throttling-meta.ts
More file actions
142 lines (131 loc) · 5.01 KB
/
Copy pathmobile_throttling-meta.ts
File metadata and controls
142 lines (131 loc) · 5.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import * as Common from '../../core/common/common.js';
import * as i18n from '../../core/i18n/i18n.js';
import * as Root from '../../core/root/root.js';
import * as UI from '../../ui/legacy/legacy.js';
import type * as MobileThrottling from './mobile_throttling.js';
const UIStrings = {
/**
*@description Text for throttling the network
*/
throttling: 'Throttling',
/**
*@description Command for showing the Mobile Throttling tool.
*/
showThrottling: 'Show Throttling',
/**
*@description Title of an action in the network conditions tool to network offline
*/
goOffline: 'Go offline',
/**
*@description A tag of Mobile related settings that can be searched in the command menu
*/
device: 'device',
/**
*@description A tag of Network related actions that can be searched in the command menu
*/
throttlingTag: 'throttling',
/**
* @description Title of an action in the network conditions tool to simulate an environment with a
* slow 3G connection, i.e. for a low end mobile device.
*/
enableSlowGThrottling: 'Enable slow `3G` throttling',
/**
* @description Title of an action in the network conditions tool to simulate an environment with a
* medium-speed 3G connection, i.e. for a mid-tier mobile device.
*/
enableFastGThrottling: 'Enable fast `3G` throttling',
/**
*@description Title of an action in the network conditions tool to network online
*/
goOnline: 'Go online',
} as const;
const str_ = i18n.i18n.registerUIStrings('panels/mobile_throttling/mobile_throttling-meta.ts', UIStrings);
const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_);
let loadedMobileThrottlingModule: (typeof MobileThrottling|undefined);
async function loadMobileThrottlingModule(): Promise<typeof MobileThrottling> {
if (!loadedMobileThrottlingModule) {
loadedMobileThrottlingModule = await import('./mobile_throttling.js');
}
return loadedMobileThrottlingModule;
}
UI.ViewManager.registerViewExtension({
location: UI.ViewManager.ViewLocationValues.SETTINGS_VIEW,
id: 'throttling-conditions',
title: i18nLazyString(UIStrings.throttling),
commandPrompt: i18nLazyString(UIStrings.showThrottling),
order: 35,
async loadView() {
const MobileThrottling = await loadMobileThrottlingModule();
return new MobileThrottling.ThrottlingSettingsTab.ThrottlingSettingsTab();
},
settings: [
'custom-network-conditions',
'calibrated-cpu-throttling',
],
iconName: 'performance',
});
UI.ActionRegistration.registerActionExtension({
actionId: 'network-conditions.network-offline',
category: UI.ActionRegistration.ActionCategory.NETWORK,
experiment: Root.Runtime.ExperimentName.NOT_REACT_NATIVE_SPECIFIC_UI,
title: i18nLazyString(UIStrings.goOffline),
async loadActionDelegate() {
const MobileThrottling = await loadMobileThrottlingModule();
return new MobileThrottling.ThrottlingManager.ActionDelegate();
},
tags: [
i18nLazyString(UIStrings.device),
i18nLazyString(UIStrings.throttlingTag),
],
});
UI.ActionRegistration.registerActionExtension({
actionId: 'network-conditions.network-low-end-mobile',
category: UI.ActionRegistration.ActionCategory.NETWORK,
experiment: Root.Runtime.ExperimentName.NOT_REACT_NATIVE_SPECIFIC_UI,
title: i18nLazyString(UIStrings.enableSlowGThrottling),
async loadActionDelegate() {
const MobileThrottling = await loadMobileThrottlingModule();
return new MobileThrottling.ThrottlingManager.ActionDelegate();
},
tags: [
i18nLazyString(UIStrings.device),
i18nLazyString(UIStrings.throttlingTag),
],
});
UI.ActionRegistration.registerActionExtension({
actionId: 'network-conditions.network-mid-tier-mobile',
category: UI.ActionRegistration.ActionCategory.NETWORK,
experiment: Root.Runtime.ExperimentName.NOT_REACT_NATIVE_SPECIFIC_UI,
title: i18nLazyString(UIStrings.enableFastGThrottling),
async loadActionDelegate() {
const MobileThrottling = await loadMobileThrottlingModule();
return new MobileThrottling.ThrottlingManager.ActionDelegate();
},
tags: [
i18nLazyString(UIStrings.device),
i18nLazyString(UIStrings.throttlingTag),
],
});
UI.ActionRegistration.registerActionExtension({
actionId: 'network-conditions.network-online',
category: UI.ActionRegistration.ActionCategory.NETWORK,
experiment: Root.Runtime.ExperimentName.NOT_REACT_NATIVE_SPECIFIC_UI,
title: i18nLazyString(UIStrings.goOnline),
async loadActionDelegate() {
const MobileThrottling = await loadMobileThrottlingModule();
return new MobileThrottling.ThrottlingManager.ActionDelegate();
},
tags: [
i18nLazyString(UIStrings.device),
i18nLazyString(UIStrings.throttlingTag),
],
});
Common.Settings.registerSettingExtension({
storageType: Common.Settings.SettingStorageType.SYNCED,
settingName: 'custom-network-conditions',
settingType: Common.Settings.SettingType.ARRAY,
defaultValue: [],
});