chrome-devtools-frontend 1.0.1672557 → 1.0.1675430

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/.agents/skills/devtools-ux-writing-refactor/SKILL.md +26 -9
  2. package/front_end/core/common/ParsedURL.ts +5 -1
  3. package/front_end/core/common/SettingRegistration.ts +30 -34
  4. package/front_end/core/common/Settings.ts +4 -64
  5. package/front_end/core/host/UserMetrics.ts +127 -117
  6. package/front_end/core/protocol_client/PuppeteerDevToolsConnection.ts +42 -9
  7. package/front_end/core/root/Runtime.ts +14 -0
  8. package/front_end/core/sdk/NetworkManager.ts +0 -35
  9. package/front_end/core/sdk/SourceMap.ts +1 -19
  10. package/front_end/core/sdk/SourceMapManager.ts +75 -48
  11. package/front_end/core/sdk/SourceMapScopesInfo.ts +0 -62
  12. package/front_end/core/sdk/TargetManager.ts +18 -0
  13. package/front_end/devtools_compatibility.js +1 -1
  14. package/front_end/entrypoints/main/MainImpl.ts +1 -0
  15. package/front_end/foundation/Universe.ts +44 -29
  16. package/front_end/generated/InspectorBackendCommands.ts +4 -3
  17. package/front_end/generated/SupportedCSSProperties.ts +16 -1
  18. package/front_end/generated/protocol-mapping.d.ts +8 -0
  19. package/front_end/generated/protocol-proxy-api.d.ts +6 -0
  20. package/front_end/generated/protocol.ts +16 -2
  21. package/front_end/models/ai_assistance/AiSetting.ts +66 -3
  22. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +15 -5
  23. package/front_end/models/bindings/CompilerScriptMapping.ts +1 -1
  24. package/front_end/models/emulation/DeviceModeModel.ts +82 -102
  25. package/front_end/models/emulation/EmulatedDevices.ts +18 -66
  26. package/front_end/models/javascript_metadata/NativeFunctions.js +4 -4
  27. package/front_end/models/persistence/AutomaticFileSystemManager.ts +2 -2
  28. package/front_end/models/persistence/IsolatedFileSystemManager.ts +20 -29
  29. package/front_end/models/trace/ModelImpl.ts +5 -0
  30. package/front_end/models/trace/Processor.ts +5 -0
  31. package/front_end/models/trace/handlers/LayoutShiftsHandler.ts +7 -1
  32. package/front_end/models/trace/handlers/MetaHandler.ts +8 -4
  33. package/front_end/models/trace/handlers/PageLoadMetricsHandler.ts +11 -0
  34. package/front_end/models/workspace/FileManager.ts +13 -6
  35. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +11 -10
  36. package/front_end/panels/ai_assistance/ai_assistance-meta.ts +3 -45
  37. package/front_end/panels/application/BackgroundServiceView.ts +42 -40
  38. package/front_end/panels/application/KeyValueStorageItemsView.ts +1 -0
  39. package/front_end/panels/application/WebMCPView.ts +13 -5
  40. package/front_end/panels/application/components/AdsView.ts +24 -1
  41. package/front_end/panels/application/components/adsView.css +27 -21
  42. package/front_end/panels/autofill/AutofillView.ts +12 -12
  43. package/front_end/panels/autofill/autofill-meta.ts +2 -2
  44. package/front_end/panels/common/ExtensionServer.ts +7 -1
  45. package/front_end/panels/common/common.ts +0 -1
  46. package/front_end/panels/console/ConsoleInsightTeaser.ts +7 -6
  47. package/front_end/panels/console/ConsoleViewMessage.ts +1 -1
  48. package/front_end/panels/elements/ClassesPaneWidget.ts +2 -2
  49. package/front_end/panels/elements/ElementsTreeElement.ts +602 -327
  50. package/front_end/panels/elements/ElementsTreeOutline.ts +1 -1
  51. package/front_end/panels/elements/StylesSidebarPane.ts +1 -1
  52. package/front_end/panels/elements/components/AdornerManager.ts +1 -0
  53. package/front_end/panels/emulation/AdvancedApp.ts +3 -3
  54. package/front_end/panels/emulation/DeviceModeToolbar.ts +2 -11
  55. package/front_end/panels/emulation/DeviceModeView.ts +234 -75
  56. package/front_end/panels/emulation/InspectedPagePlaceholder.ts +1 -1
  57. package/front_end/panels/emulation/deviceModeView.css +4 -21
  58. package/front_end/panels/emulation/emulation-meta.ts +4 -30
  59. package/front_end/panels/emulation/emulation.ts +0 -3
  60. package/front_end/panels/explain/components/ConsoleInsight.ts +11 -7
  61. package/front_end/panels/js_timeline/js_timeline-meta.ts +8 -8
  62. package/front_end/panels/layer_viewer/LayerDetailsView.ts +30 -30
  63. package/front_end/panels/layer_viewer/LayerTreeOutline.ts +6 -6
  64. package/front_end/panels/layer_viewer/LayerViewHost.ts +1 -1
  65. package/front_end/panels/layer_viewer/Layers3DView.ts +11 -11
  66. package/front_end/panels/layer_viewer/PaintProfilerView.ts +8 -8
  67. package/front_end/panels/layer_viewer/TransformController.ts +3 -3
  68. package/front_end/panels/layer_viewer/layer_viewer-meta.ts +11 -11
  69. package/front_end/panels/layers/LayersPanel.ts +2 -2
  70. package/front_end/panels/layers/layers-meta.ts +2 -2
  71. package/front_end/panels/lighthouse/LighthouseController.ts +3 -7
  72. package/front_end/panels/mobile_throttling/CPUThrottlingSelector.ts +313 -0
  73. package/front_end/panels/mobile_throttling/NetworkPanelIndicator.ts +0 -10
  74. package/front_end/panels/mobile_throttling/NetworkThrottlingSelector.ts +21 -10
  75. package/front_end/panels/mobile_throttling/ThrottlingManager.ts +1 -58
  76. package/front_end/panels/mobile_throttling/mobile_throttling.ts +2 -9
  77. package/front_end/panels/network/NetworkConfigView.ts +1 -71
  78. package/front_end/panels/network/networkConfigView.css +1 -2
  79. package/front_end/panels/profiler/HeapDetachedElementsDataGrid.ts +3 -3
  80. package/front_end/panels/profiler/HeapDetachedElementsView.ts +5 -5
  81. package/front_end/panels/profiler/HeapProfileView.ts +32 -32
  82. package/front_end/panels/profiler/HeapProfilerPanel.ts +2 -2
  83. package/front_end/panels/profiler/HeapSnapshotDataGrids.ts +33 -37
  84. package/front_end/panels/profiler/HeapSnapshotGridNodes.ts +26 -27
  85. package/front_end/panels/profiler/HeapSnapshotView.ts +48 -48
  86. package/front_end/panels/profiler/IsolateSelector.ts +10 -10
  87. package/front_end/panels/profiler/ModuleUIStrings.ts +25 -25
  88. package/front_end/panels/profiler/ProfileLauncherView.ts +6 -6
  89. package/front_end/panels/profiler/ProfilesPanel.ts +6 -6
  90. package/front_end/panels/profiler/WritableProfileHeader.ts +6 -6
  91. package/front_end/panels/profiler/profiler-meta.ts +7 -7
  92. package/front_end/panels/protocol_monitor/ProtocolMonitor.ts +7 -0
  93. package/front_end/panels/recorder/RecorderPanel.ts +1 -1
  94. package/front_end/panels/settings/AISettingsTab.ts +27 -23
  95. package/front_end/panels/settings/emulation/DevicesSettingsTab.ts +1 -2
  96. package/front_end/panels/timeline/TimelineFlameChartNetworkDataProvider.ts +12 -17
  97. package/front_end/panels/timeline/TimelinePanel.ts +20 -35
  98. package/front_end/panels/timeline/components/LiveMetricsView.ts +27 -6
  99. package/front_end/panels/timeline/components/NetworkTrackWidget.ts +1 -1
  100. package/front_end/panels/timeline/components/components.ts +0 -4
  101. package/front_end/panels/timeline/components/liveMetricsView.css +7 -0
  102. package/front_end/third_party/chromium/README.chromium +1 -1
  103. package/front_end/third_party/source-map-scopes-codec/package/CONTRIBUTING.md +0 -0
  104. package/front_end/third_party/source-map-scopes-codec/package/LICENSE +0 -0
  105. package/front_end/third_party/source-map-scopes-codec/package/README.md +0 -0
  106. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts +0 -0
  107. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts.map +1 -1
  108. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts +0 -0
  109. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts.map +0 -0
  110. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts +0 -0
  111. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts.map +0 -0
  112. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts +0 -0
  113. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts.map +0 -0
  114. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts +0 -0
  115. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts.map +0 -0
  116. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/scopes.d.ts +0 -0
  117. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/scopes.d.ts.map +0 -0
  118. package/front_end/third_party/source-map-scopes-codec/package/deno.json +1 -1
  119. package/front_end/third_party/source-map-scopes-codec/package/package.json +1 -1
  120. package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js +2 -0
  121. package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js.map +1 -1
  122. package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.ts +2 -0
  123. package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js +0 -0
  124. package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js.map +0 -0
  125. package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.ts +0 -0
  126. package/front_end/third_party/source-map-scopes-codec/package/src/codec.js +0 -0
  127. package/front_end/third_party/source-map-scopes-codec/package/src/codec.js.map +0 -0
  128. package/front_end/third_party/source-map-scopes-codec/package/src/codec.ts +0 -0
  129. package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js +0 -0
  130. package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js.map +0 -0
  131. package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.ts +0 -0
  132. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js +0 -0
  133. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js.map +0 -0
  134. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.ts +0 -0
  135. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js +0 -0
  136. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js.map +0 -0
  137. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.ts +0 -0
  138. package/front_end/third_party/source-map-scopes-codec/package/src/mod.js +0 -0
  139. package/front_end/third_party/source-map-scopes-codec/package/src/mod.js.map +0 -0
  140. package/front_end/third_party/source-map-scopes-codec/package/src/mod.ts +0 -0
  141. package/front_end/third_party/source-map-scopes-codec/package/src/scopes.js +0 -0
  142. package/front_end/third_party/source-map-scopes-codec/package/src/scopes.js.map +0 -0
  143. package/front_end/third_party/source-map-scopes-codec/package/src/scopes.ts +0 -0
  144. package/front_end/third_party/source-map-scopes-codec/package/src/util.js +0 -0
  145. package/front_end/third_party/source-map-scopes-codec/package/src/util.js.map +0 -0
  146. package/front_end/third_party/source-map-scopes-codec/package/src/util.ts +0 -0
  147. package/front_end/third_party/source-map-scopes-codec/package/src/vlq.js +0 -0
  148. package/front_end/third_party/source-map-scopes-codec/package/src/vlq.js.map +0 -0
  149. package/front_end/third_party/source-map-scopes-codec/package/src/vlq.ts +0 -0
  150. package/front_end/ui/comments/CommentAnchorResolver.ts +132 -0
  151. package/front_end/ui/comments/comments.ts +9 -0
  152. package/front_end/ui/components/dialogs/ShortcutDialog.ts +2 -0
  153. package/front_end/ui/components/settings/SettingCheckbox.ts +4 -12
  154. package/front_end/ui/components/settings/settingCheckbox.css +0 -7
  155. package/front_end/ui/legacy/Treeoutline.ts +14 -14
  156. package/front_end/ui/legacy/UIUtils.ts +2 -47
  157. package/front_end/ui/legacy/Widget.ts +10 -2
  158. package/front_end/ui/legacy/components/data_grid/DataGridElement.ts +40 -0
  159. package/front_end/ui/legacy/components/settings_ui/SettingsUI.ts +1 -1
  160. package/front_end/ui/legacy/components/utils/Linkifier.ts +1 -0
  161. package/front_end/ui/lit/Directives.ts +80 -0
  162. package/front_end/ui/lit/lit.ts +1 -0
  163. package/front_end/ui/lit/render.ts +8 -0
  164. package/front_end/ui/settings/SettingUIRegistration.ts +4 -0
  165. package/front_end/ui/visual_logging/Debugging.ts +1 -5
  166. package/front_end/ui/visual_logging/KnownContextValues.ts +3 -0
  167. package/front_end/ui/visual_logging/LoggingConfig.ts +21 -0
  168. package/front_end/ui/visual_logging/visual_logging.ts +9 -0
  169. package/mcp/mcp.ts +1 -0
  170. package/package.json +1 -1
  171. package/front_end/panels/common/ThrottlingUtils.ts +0 -51
  172. package/front_end/panels/emulation/DeviceModeWrapper.ts +0 -248
  173. package/front_end/panels/mobile_throttling/MobileThrottlingSelector.ts +0 -92
  174. package/front_end/panels/timeline/components/CPUThrottlingSelector.ts +0 -235
  175. package/front_end/panels/timeline/components/NetworkThrottlingSelector.ts +0 -245
  176. package/front_end/panels/timeline/components/cpuThrottlingSelector.css +0 -30
  177. package/front_end/panels/timeline/components/networkThrottlingSelector.css +0 -24
@@ -1,235 +0,0 @@
1
- // Copyright 2024 The Chromium Authors
2
- // Use of this source code is governed by a BSD-style license that can be
3
- // found in the LICENSE file.
4
-
5
- import '../../../ui/kit/kit.js';
6
- import '../../../ui/components/menus/menus.js';
7
-
8
- import * as Common from '../../../core/common/common.js';
9
- import * as i18n from '../../../core/i18n/i18n.js';
10
- import * as SDK from '../../../core/sdk/sdk.js';
11
- import type * as Menus from '../../../ui/components/menus/menus.js';
12
- import * as UI from '../../../ui/legacy/legacy.js';
13
- import * as Lit from '../../../ui/lit/lit.js';
14
- import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
15
- import * as PanelsCommon from '../../common/common.js';
16
- import * as MobileThrottling from '../../mobile_throttling/mobile_throttling.js';
17
-
18
- import cpuThrottlingSelectorStyles from './cpuThrottlingSelector.css.js';
19
-
20
- const {render, html} = Lit;
21
-
22
- const UIStrings = {
23
- /**
24
- * @description Text label for a selection box showing which CPU throttling option is applied.
25
- * @example {No throttling} PH1
26
- */
27
- cpu: 'CPU: {PH1}',
28
- /**
29
- * @description Text label for a selection box showing which CPU throttling option is applied.
30
- * @example {No throttling} PH1
31
- */
32
- cpuThrottling: 'CPU throttling: {PH1}',
33
- /**
34
- * @description Text label for a selection box showing that a specific option is recommended.
35
- * @example {4x slowdown} PH1
36
- */
37
- recommendedThrottling: '{PH1} – recommended',
38
- /**
39
- * @description Text for why user should change a throttling setting.
40
- */
41
- recommendedThrottlingReason: 'Consider changing setting to simulate real user environments',
42
- /**
43
- * @description Text to prompt the user to run the CPU calibration process.
44
- */
45
- calibrate: 'Calibrate…',
46
- /**
47
- * @description Text to prompt the user to re-run the CPU calibration process.
48
- */
49
- recalibrate: 'Recalibrate…',
50
- /**
51
- * @description Label shown above a list of CPU calibration preset options.
52
- */
53
- labelCalibratedPresets: 'Calibrated presets',
54
- } as const;
55
-
56
- const str_ = i18n.i18n.registerUIStrings('panels/timeline/components/CPUThrottlingSelector.ts', UIStrings);
57
- const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
58
-
59
- interface CPUThrottlingGroup {
60
- name: string;
61
- items: PanelsCommon.CPUThrottlingOption.CPUThrottlingOption[];
62
- showCustomAddOption?: boolean;
63
- }
64
-
65
- interface ViewInput {
66
- recommendedOption: PanelsCommon.CPUThrottlingOption.CPUThrottlingOption|null;
67
- currentOption: PanelsCommon.CPUThrottlingOption.CPUThrottlingOption;
68
- groups: CPUThrottlingGroup[];
69
- throttling: PanelsCommon.CPUThrottlingOption.CalibratedCPUThrottling;
70
- onMenuItemSelected: (event: Menus.SelectMenu.SelectMenuItemSelectedEvent) => void;
71
- onCalibrateClick: () => void;
72
- }
73
-
74
- export const DEFAULT_VIEW = (input: ViewInput, _output: undefined, target: HTMLElement): void => {
75
- let recommendedInfoEl;
76
- if (input.recommendedOption && input.currentOption === PanelsCommon.CPUThrottlingOption.NoThrottlingOption) {
77
- recommendedInfoEl = html`<devtools-icon
78
- title=${i18nString(UIStrings.recommendedThrottlingReason)}
79
- name=info></devtools-icon>`;
80
- }
81
-
82
- const selectionTitle = input.currentOption.title();
83
- const hasCalibratedOnce = input.throttling.low || input.throttling.mid;
84
- const calibrationLabel = hasCalibratedOnce ? i18nString(UIStrings.recalibrate) : i18nString(UIStrings.calibrate);
85
-
86
- // clang-format off
87
- /* eslint-disable @devtools/no-deprecated-component-usages */
88
- const template = html`
89
- <style>${cpuThrottlingSelectorStyles}</style>
90
- <devtools-select-menu
91
- @selectmenuselected=${input.onMenuItemSelected}
92
- .showDivider=${true}
93
- .showArrow=${true}
94
- .sideButton=${false}
95
- .showSelectedItem=${true}
96
- .jslogContext=${'cpu-throttling'}
97
- .buttonTitle=${i18nString(UIStrings.cpu, {PH1: selectionTitle})}
98
- .title=${i18nString(UIStrings.cpuThrottling, {PH1: selectionTitle})}
99
- >
100
- ${input.groups.map(group => {
101
- return html`
102
- <devtools-menu-group .name=${group.name} .title=${group.name}>
103
- ${group.items.map(option => {
104
- const title = option === input.recommendedOption ? i18nString(UIStrings.recommendedThrottling, {PH1: option.title()}) : option.title();
105
- const rate = option.rate();
106
- return html`
107
- <devtools-menu-item
108
- .value=${option.calibratedDeviceType ?? rate}
109
- .selected=${input.currentOption === option}
110
- .disabled=${rate === 0}
111
- .title=${title}
112
- jslog=${VisualLogging.item(option.jslogContext).track({click: true})}
113
- >
114
- ${title}
115
- </devtools-menu-item>
116
- `;
117
- })}
118
- ${group.name === 'Calibrated presets' ? html`<devtools-menu-item
119
- .value=${-1 /* This won't be displayed unless it has some value. */}
120
- .title=${calibrationLabel}
121
- jslog=${VisualLogging.action('cpu-throttling-selector-calibrate').track({click: true})}
122
- @click=${input.onCalibrateClick}
123
- >
124
- ${calibrationLabel}
125
- </devtools-menu-item>` : Lit.nothing}
126
- </devtools-menu-group>`;
127
- })}
128
- </devtools-select-menu>
129
- ${recommendedInfoEl}
130
- `;
131
- // clang-format on
132
- render(template, target);
133
- };
134
-
135
- type View = typeof DEFAULT_VIEW;
136
-
137
- export class CPUThrottlingSelector extends UI.Widget.Widget {
138
- #currentOption: PanelsCommon.CPUThrottlingOption.CPUThrottlingOption;
139
- #recommendedOption: PanelsCommon.CPUThrottlingOption.CPUThrottlingOption|null = null;
140
- #groups: CPUThrottlingGroup[] = [];
141
- #calibratedThrottlingSetting: Common.Settings.Setting<PanelsCommon.CPUThrottlingOption.CalibratedCPUThrottling>;
142
- readonly #view: View;
143
- readonly #cpuThrottlingManager = SDK.CPUThrottlingManager.CPUThrottlingManager.instance();
144
-
145
- constructor(element?: HTMLElement, view: View = DEFAULT_VIEW) {
146
- super(element);
147
- this.#currentOption = MobileThrottling.ThrottlingManager.throttlingManager().cpuThrottlingOption();
148
- this.#calibratedThrottlingSetting =
149
- Common.Settings.Settings.instance().createSetting<PanelsCommon.CPUThrottlingOption.CalibratedCPUThrottling>(
150
- 'calibrated-cpu-throttling', {}, Common.Settings.SettingStorageType.GLOBAL);
151
- this.#resetGroups();
152
- this.#view = view;
153
- }
154
-
155
- set recommendedOption(recommendedOption: PanelsCommon.CPUThrottlingOption.CPUThrottlingOption|null) {
156
- this.#recommendedOption = recommendedOption;
157
- this.requestUpdate();
158
- }
159
-
160
- override wasShown(): void {
161
- super.wasShown();
162
- this.#cpuThrottlingManager.addEventListener(SDK.CPUThrottlingManager.Events.RATE_CHANGED, this.#onOptionChange,
163
- this);
164
- this.#calibratedThrottlingSetting.addChangeListener(this.#onCalibratedSettingChanged, this);
165
- this.#onOptionChange();
166
- }
167
-
168
- override willHide(): void {
169
- super.willHide();
170
- this.#calibratedThrottlingSetting.removeChangeListener(this.#onCalibratedSettingChanged, this);
171
- this.#cpuThrottlingManager.removeEventListener(SDK.CPUThrottlingManager.Events.RATE_CHANGED, this.#onOptionChange,
172
- this);
173
- }
174
-
175
- #onOptionChange(): void {
176
- this.#currentOption = MobileThrottling.ThrottlingManager.throttlingManager().cpuThrottlingOption();
177
-
178
- this.requestUpdate();
179
- }
180
-
181
- #onCalibratedSettingChanged(): void {
182
- this.#resetGroups();
183
- this.requestUpdate();
184
- }
185
-
186
- #onMenuItemSelected(event: Menus.SelectMenu.SelectMenuItemSelectedEvent): void {
187
- let option;
188
- if (typeof event.itemValue === 'string') {
189
- if (event.itemValue === 'low-tier-mobile') {
190
- option = PanelsCommon.CPUThrottlingOption.CalibratedLowTierMobileThrottlingOption;
191
- } else if (event.itemValue === 'mid-tier-mobile') {
192
- option = PanelsCommon.CPUThrottlingOption.CalibratedMidTierMobileThrottlingOption;
193
- }
194
- } else {
195
- const rate = Number(event.itemValue);
196
- option = MobileThrottling.ThrottlingPresets.ThrottlingPresets.cpuThrottlingPresets.find(
197
- option => !option.calibratedDeviceType && option.rate() === rate);
198
- }
199
-
200
- if (option) {
201
- MobileThrottling.ThrottlingManager.throttlingManager().setCPUThrottlingOption(option);
202
- }
203
- }
204
-
205
- #onCalibrateClick(): void {
206
- void Common.Revealer.reveal(this.#calibratedThrottlingSetting);
207
- }
208
-
209
- #resetGroups(): void {
210
- this.#groups = [
211
- {
212
- name: '',
213
- items: MobileThrottling.ThrottlingPresets.ThrottlingPresets.cpuThrottlingPresets.filter(
214
- option => !option.calibratedDeviceType),
215
- },
216
- {
217
- name: i18nString(UIStrings.labelCalibratedPresets),
218
- items: MobileThrottling.ThrottlingPresets.ThrottlingPresets.cpuThrottlingPresets.filter(
219
- option => option.calibratedDeviceType),
220
- },
221
- ];
222
- }
223
-
224
- override async performUpdate(): Promise<void> {
225
- const input: ViewInput = {
226
- recommendedOption: this.#recommendedOption,
227
- currentOption: this.#currentOption,
228
- groups: this.#groups,
229
- throttling: this.#calibratedThrottlingSetting.get(),
230
- onMenuItemSelected: this.#onMenuItemSelected.bind(this),
231
- onCalibrateClick: this.#onCalibrateClick.bind(this),
232
- };
233
- this.#view(input, undefined, this.contentElement);
234
- }
235
- }
@@ -1,245 +0,0 @@
1
- // Copyright 2024 The Chromium Authors
2
- // Use of this source code is governed by a BSD-style license that can be
3
- // found in the LICENSE file.
4
- /* eslint-disable @devtools/no-lit-render-outside-of-view */
5
-
6
- import '../../../ui/kit/kit.js';
7
- import '../../../ui/components/menus/menus.js';
8
-
9
- import * as Common from '../../../core/common/common.js';
10
- import * as i18n from '../../../core/i18n/i18n.js';
11
- import * as Platform from '../../../core/platform/platform.js';
12
- import * as SDK from '../../../core/sdk/sdk.js';
13
- import * as ComponentHelpers from '../../../ui/components/helpers/helpers.js';
14
- import type * as Menus from '../../../ui/components/menus/menus.js';
15
- import * as Lit from '../../../ui/lit/lit.js';
16
- import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
17
- import * as MobileThrottling from '../../mobile_throttling/mobile_throttling.js';
18
-
19
- import networkThrottlingSelectorStyles from './networkThrottlingSelector.css.js';
20
-
21
- const {html, nothing} = Lit;
22
-
23
- const UIStrings = {
24
- /**
25
- * @description Text label for a selection box showing which network throttling option is applied.
26
- * @example {No throttling} PH1
27
- */
28
- network: 'Network: {PH1}',
29
- /**
30
- * @description Text label for a selection box showing which network throttling option is applied.
31
- * @example {No throttling} PH1
32
- */
33
- networkThrottling: 'Network throttling: {PH1}',
34
- /**
35
- * @description Text label for a selection box showing that a specific option is recommended for network throttling.
36
- * @example {Fast 4G} PH1
37
- */
38
- recommendedThrottling: '{PH1} – recommended',
39
- /**
40
- * @description Text for why user should change a throttling setting.
41
- */
42
- recommendedThrottlingReason: 'Consider changing setting to simulate real user environments',
43
- /**
44
- * @description Text label for a menu group that disables network throttling.
45
- */
46
- disabled: 'Disabled',
47
- /**
48
- * @description Text label for a menu group that contains default presets for network throttling.
49
- */
50
- presets: 'Presets',
51
- /**
52
- * @description Text label for a menu group that contains custom presets for network throttling.
53
- */
54
- custom: 'Custom',
55
- /**
56
- * @description Text label for a menu option to add a new custom throttling preset.
57
- */
58
- add: 'Add…',
59
- } as const;
60
-
61
- const str_ = i18n.i18n.registerUIStrings('panels/timeline/components/NetworkThrottlingSelector.ts', UIStrings);
62
- const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
63
-
64
- interface ConditionsGroup {
65
- name: string;
66
- items: SDK.NetworkManager.Conditions[];
67
- showCustomAddOption?: boolean;
68
- jslogContext?: string;
69
- }
70
-
71
- export class NetworkThrottlingSelector extends HTMLElement {
72
- readonly #shadow = this.attachShadow({mode: 'open'});
73
-
74
- #customNetworkConditionsSetting: Common.Settings.Setting<SDK.NetworkManager.Conditions[]>;
75
- #groups: ConditionsGroup[] = [];
76
- #currentConditions: SDK.NetworkManager.Conditions;
77
- #recommendedConditions: SDK.NetworkManager.Conditions|null = null;
78
-
79
- constructor() {
80
- super();
81
- this.#customNetworkConditionsSetting =
82
- Common.Settings.Settings.instance().moduleSetting('custom-network-conditions');
83
- this.#resetPresets();
84
- this.#currentConditions = SDK.NetworkManager.MultitargetNetworkManager.instance().networkConditions();
85
- this.#render();
86
- }
87
-
88
- set recommendedConditions(recommendedConditions: SDK.NetworkManager.Conditions|null) {
89
- this.#recommendedConditions = recommendedConditions;
90
- void ComponentHelpers.ScheduledRender.scheduleRender(this, this.#render);
91
- }
92
-
93
- connectedCallback(): void {
94
- SDK.NetworkManager.MultitargetNetworkManager.instance().addEventListener(
95
- SDK.NetworkManager.MultitargetNetworkManager.Events.CONDITIONS_CHANGED, this.#onConditionsChanged, this);
96
-
97
- // Also call onConditionsChanged immediately to make sure we get the
98
- // latest snapshot. Otherwise if another panel updated this value and this
99
- // component wasn't in the DOM, this component will not update itself
100
- // when it is put into the page
101
- this.#onConditionsChanged();
102
- this.#customNetworkConditionsSetting.addChangeListener(this.#onSettingChanged, this);
103
- }
104
-
105
- disconnectedCallback(): void {
106
- SDK.NetworkManager.MultitargetNetworkManager.instance().removeEventListener(
107
- SDK.NetworkManager.MultitargetNetworkManager.Events.CONDITIONS_CHANGED, this.#onConditionsChanged, this);
108
- this.#customNetworkConditionsSetting.removeChangeListener(this.#onSettingChanged, this);
109
- }
110
-
111
- #resetPresets(): void {
112
- this.#groups = [
113
- {
114
- name: i18nString(UIStrings.disabled),
115
- items: [
116
- SDK.NetworkManager.NoThrottlingConditions,
117
- ],
118
- },
119
- {
120
- name: i18nString(UIStrings.presets),
121
- items: MobileThrottling.ThrottlingPresets.ThrottlingPresets.networkPresets,
122
- },
123
- {
124
- name: i18nString(UIStrings.custom),
125
- items: this.#customNetworkConditionsSetting.get(),
126
- showCustomAddOption: true,
127
- jslogContext: 'custom-network-throttling-item',
128
- },
129
- ];
130
- }
131
-
132
- #onConditionsChanged(): void {
133
- this.#currentConditions = SDK.NetworkManager.MultitargetNetworkManager.instance().networkConditions();
134
- void ComponentHelpers.ScheduledRender.scheduleRender(this, this.#render);
135
- }
136
-
137
- #onMenuItemSelected(event: Menus.SelectMenu.SelectMenuItemSelectedEvent): void {
138
- const newConditions = this.#groups.flatMap(g => g.items).find(item => {
139
- const keyForItem = this.#keyForNetworkConditions(item);
140
- return keyForItem === event.itemValue;
141
- });
142
- if (newConditions) {
143
- SDK.NetworkManager.MultitargetNetworkManager.instance().setNetworkConditions(newConditions);
144
- }
145
- }
146
-
147
- #onSettingChanged(): void {
148
- this.#resetPresets();
149
- void ComponentHelpers.ScheduledRender.scheduleRender(this, this.#render);
150
- }
151
-
152
- #getConditionsTitle(conditions: SDK.NetworkManager.Conditions): string {
153
- return conditions.title instanceof Function ? conditions.title() : conditions.title;
154
- }
155
-
156
- #onAddClick(): void {
157
- void Common.Revealer.reveal(this.#customNetworkConditionsSetting);
158
- }
159
-
160
- /**
161
- * The key that uniquely identifies the condition setting. All the DevTools
162
- * presets have the i18nKey, so we rely on that, but for custom user added
163
- * ones we fallback to using the title (it wouldn't make sense for a user to
164
- * add presets with the same title)
165
- */
166
- #keyForNetworkConditions(conditions: SDK.NetworkManager.Conditions): string {
167
- return conditions.i18nTitleKey || this.#getConditionsTitle(conditions);
168
- }
169
-
170
- #render = (): void => {
171
- const selectionTitle = this.#getConditionsTitle(this.#currentConditions);
172
- const selectedConditionsKey = this.#keyForNetworkConditions(this.#currentConditions);
173
-
174
- let recommendedInfoEl;
175
- if (this.#recommendedConditions && this.#currentConditions === SDK.NetworkManager.NoThrottlingConditions) {
176
- recommendedInfoEl = html`<devtools-icon
177
- title=${i18nString(UIStrings.recommendedThrottlingReason)}
178
- name=info></devtools-icon>`;
179
- }
180
-
181
- // clang-format off
182
- /* eslint-disable @devtools/no-deprecated-component-usages */
183
- const output = html`
184
- <style>${networkThrottlingSelectorStyles}</style>
185
- <devtools-select-menu
186
- @selectmenuselected=${this.#onMenuItemSelected}
187
- .showDivider=${true}
188
- .showArrow=${true}
189
- .sideButton=${false}
190
- .showSelectedItem=${true}
191
- .jslogContext=${'network-conditions'}
192
- .buttonTitle=${i18nString(UIStrings.network, {PH1: selectionTitle})}
193
- .title=${i18nString(UIStrings.networkThrottling, {PH1: selectionTitle})}
194
- >
195
- ${this.#groups.map(group => {
196
- return html`
197
- <devtools-menu-group .name=${group.name} .title=${group.name}>
198
- ${group.items.map(conditions => {
199
- let title = this.#getConditionsTitle(conditions);
200
- if (conditions === this.#recommendedConditions) {
201
- title = i18nString(UIStrings.recommendedThrottling, {PH1: title});
202
- }
203
-
204
- const key = this.#keyForNetworkConditions(conditions);
205
- const jslogContext = group.jslogContext || Platform.StringUtilities.toKebabCase(conditions.i18nTitleKey || title);
206
- return html`
207
- <devtools-menu-item
208
- .value=${key}
209
- .selected=${selectedConditionsKey === key}
210
- .title=${title}
211
- jslog=${VisualLogging.item(jslogContext).track({click: true})}
212
- >
213
- ${title}
214
- </devtools-menu-item>
215
- `;
216
- })}
217
- ${group.showCustomAddOption ? html`
218
- <devtools-menu-item
219
- .value=${1 /* This won't be displayed unless it has some value. */}
220
- .title=${i18nString(UIStrings.add)}
221
- jslog=${VisualLogging.action('add').track({click: true})}
222
- @click=${this.#onAddClick}
223
- >
224
- ${i18nString(UIStrings.add)}
225
- </devtools-menu-item>
226
- ` : nothing}
227
- </devtools-menu-group>
228
- `;
229
- })}
230
- </devtools-select-menu>
231
- ${recommendedInfoEl}
232
- `;
233
- /* eslint-enable @devtools/no-deprecated-component-usages */
234
- // clang-format on
235
- Lit.render(output, this.#shadow, {host: this});
236
- };
237
- }
238
-
239
- customElements.define('devtools-network-throttling-selector', NetworkThrottlingSelector);
240
-
241
- declare global {
242
- interface HTMLElementTagNameMap {
243
- 'devtools-network-throttling-selector': NetworkThrottlingSelector;
244
- }
245
- }
@@ -1,30 +0,0 @@
1
- /*
2
- * Copyright 2024 The Chromium Authors
3
- * Use of this source code is governed by a BSD-style license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- @scope to (devtools-widget > *) {
8
- :scope {
9
- display: flex;
10
- align-items: center;
11
- max-width: 100%;
12
- height: 20px;
13
- }
14
-
15
- * {
16
- font-family: var(--default-font-family);
17
- }
18
-
19
- devtools-icon[name="info"] {
20
- margin-left: var(--sys-size-3);
21
- width: var(--sys-size-8);
22
- height: var(--sys-size-8);
23
- }
24
-
25
- devtools-select-menu {
26
- min-width: 160px;
27
- max-width: 100%;
28
- height: 20px;
29
- }
30
- }
@@ -1,24 +0,0 @@
1
- /*
2
- * Copyright 2024 The Chromium Authors
3
- * Use of this source code is governed by a BSD-style license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- :host {
8
- display: flex;
9
- align-items: center;
10
- max-width: 100%;
11
- height: 20px;
12
- }
13
-
14
- devtools-icon[name="info"] {
15
- margin-left: var(--sys-size-3);
16
- width: var(--sys-size-8);
17
- height: var(--sys-size-8);
18
- }
19
-
20
- devtools-select-menu {
21
- min-width: 160px;
22
- max-width: 100%;
23
- height: 20px;
24
- }