chrome-devtools-frontend 1.0.1672388 → 1.0.1674545
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.
- package/eslint.config.mjs +3 -3
- package/front_end/core/common/SettingRegistration.ts +1 -26
- package/front_end/core/common/Settings.ts +4 -53
- package/front_end/core/host/UserMetrics.ts +127 -117
- package/front_end/core/protocol_client/PuppeteerDevToolsConnection.ts +42 -9
- package/front_end/core/root/Runtime.ts +7 -2
- package/front_end/core/sdk/NetworkManager.ts +0 -35
- package/front_end/core/sdk/SourceMap.ts +1 -19
- package/front_end/core/sdk/SourceMapManager.ts +75 -48
- package/front_end/core/sdk/SourceMapScopesInfo.ts +0 -62
- package/front_end/devtools_compatibility.js +1 -1
- package/front_end/generated/InspectorBackendCommands.ts +4 -3
- package/front_end/generated/{SupportedCSSProperties.js → SupportedCSSProperties.ts} +32 -1
- package/front_end/generated/protocol-mapping.d.ts +8 -0
- package/front_end/generated/protocol-proxy-api.d.ts +6 -0
- package/front_end/generated/protocol.ts +16 -2
- package/front_end/models/ai_assistance/AiSetting.ts +66 -3
- package/front_end/models/ai_assistance/agents/PerformanceAgent.snapshot.txt +1 -1
- package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.ts +4 -3
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +1 -1
- package/front_end/models/bindings/CompilerScriptMapping.ts +1 -1
- package/front_end/models/emulation/DeviceModeModel.ts +25 -34
- package/front_end/models/emulation/EmulatedDevices.ts +1 -1
- package/front_end/models/javascript_metadata/NativeFunctions.js +4 -4
- package/front_end/models/trace/ModelImpl.ts +5 -0
- package/front_end/models/trace/Processor.ts +47 -10
- package/front_end/models/trace/handlers/LayoutShiftsHandler.ts +18 -19
- package/front_end/models/trace/handlers/MetaHandler.ts +46 -9
- package/front_end/models/trace/handlers/PageLoadMetricsHandler.ts +11 -0
- package/front_end/models/trace/insights/CLSCulprits.ts +1 -2
- package/front_end/models/trace/insights/CharacterSet.ts +1 -1
- package/front_end/models/trace/insights/Common.ts +21 -2
- package/front_end/models/trace/insights/DocumentLatency.ts +1 -1
- package/front_end/models/trace/insights/LCPBreakdown.ts +7 -6
- package/front_end/models/trace/insights/LCPDiscovery.ts +1 -1
- package/front_end/models/trace/insights/ModernHTTP.ts +7 -3
- package/front_end/models/trace/insights/NetworkDependencyTree.ts +1 -1
- package/front_end/models/trace/insights/RenderBlocking.ts +1 -1
- package/front_end/models/trace/insights/ThirdParties.ts +5 -2
- package/front_end/models/trace/insights/types.ts +11 -6
- package/front_end/models/trace/types/Configuration.ts +5 -0
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +11 -10
- package/front_end/panels/ai_assistance/ai_assistance-meta.ts +3 -45
- package/front_end/panels/application/BackgroundServiceView.ts +42 -40
- package/front_end/panels/application/KeyValueStorageItemsView.ts +1 -0
- package/front_end/panels/common/ExtensionServer.ts +7 -1
- package/front_end/panels/common/common.ts +0 -1
- package/front_end/panels/console/ConsoleInsightTeaser.ts +7 -6
- package/front_end/panels/console/ConsoleViewMessage.ts +1 -1
- package/front_end/panels/elements/ClassesPaneWidget.ts +2 -2
- package/front_end/panels/elements/ElementsTreeElement.ts +56 -5
- package/front_end/panels/elements/StylesSidebarPane.ts +1 -1
- package/front_end/panels/elements/components/AdornerManager.ts +1 -0
- package/front_end/panels/emulation/AdvancedApp.ts +3 -3
- package/front_end/panels/emulation/DeviceModeToolbar.ts +2 -11
- package/front_end/panels/emulation/DeviceModeView.ts +234 -75
- package/front_end/panels/emulation/InspectedPagePlaceholder.ts +1 -1
- package/front_end/panels/emulation/deviceModeView.css +4 -21
- package/front_end/panels/emulation/emulation-meta.ts +4 -30
- package/front_end/panels/emulation/emulation.ts +0 -3
- package/front_end/panels/explain/components/ConsoleInsight.ts +11 -7
- package/front_end/panels/layers/LayersPanel.ts +2 -2
- package/front_end/panels/layers/layers-meta.ts +2 -2
- package/front_end/panels/lighthouse/LighthouseController.ts +3 -7
- package/front_end/panels/mobile_throttling/CPUThrottlingSelector.ts +313 -0
- package/front_end/panels/mobile_throttling/NetworkPanelIndicator.ts +0 -10
- package/front_end/panels/mobile_throttling/NetworkThrottlingSelector.ts +23 -10
- package/front_end/panels/mobile_throttling/mobile_throttling.ts +3 -0
- package/front_end/panels/network/NetworkConfigView.ts +1 -71
- package/front_end/panels/network/networkConfigView.css +1 -2
- package/front_end/panels/profiler/HeapDetachedElementsDataGrid.ts +3 -3
- package/front_end/panels/profiler/HeapDetachedElementsView.ts +5 -5
- package/front_end/panels/profiler/HeapProfileView.ts +32 -32
- package/front_end/panels/profiler/HeapProfilerPanel.ts +2 -2
- package/front_end/panels/profiler/HeapSnapshotDataGrids.ts +33 -37
- package/front_end/panels/profiler/HeapSnapshotGridNodes.ts +26 -27
- package/front_end/panels/profiler/HeapSnapshotView.ts +48 -48
- package/front_end/panels/profiler/IsolateSelector.ts +10 -10
- package/front_end/panels/profiler/ModuleUIStrings.ts +25 -25
- package/front_end/panels/profiler/ProfileLauncherView.ts +6 -6
- package/front_end/panels/profiler/ProfilesPanel.ts +6 -6
- package/front_end/panels/profiler/WritableProfileHeader.ts +6 -6
- package/front_end/panels/profiler/profiler-meta.ts +7 -7
- package/front_end/panels/recorder/RecorderPanel.ts +1 -1
- package/front_end/panels/settings/AISettingsTab.ts +27 -23
- package/front_end/panels/settings/emulation/DevicesSettingsTab.ts +463 -13
- package/front_end/panels/timeline/TimelineFlameChartNetworkDataProvider.ts +12 -17
- package/front_end/panels/timeline/TimelinePanel.ts +22 -35
- package/front_end/panels/timeline/components/CWVMetrics.ts +16 -3
- package/front_end/panels/timeline/components/LiveMetricsView.ts +27 -6
- package/front_end/panels/timeline/components/NetworkTrackWidget.ts +1 -1
- package/front_end/panels/timeline/components/components.ts +0 -4
- package/front_end/panels/timeline/components/cwvMetrics.css +4 -0
- package/front_end/panels/timeline/components/liveMetricsView.css +7 -17
- package/front_end/panels/timeline/components/metricValueStyles.css +17 -0
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/third_party/puppeteer/README.chromium +2 -2
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.d.ts +64 -15
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +65 -16
- package/front_end/third_party/puppeteer/package/lib/puppeteer/api/Page.d.ts +50 -7
- package/front_end/third_party/puppeteer/package/lib/puppeteer/api/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/api/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/BidiOverCdp.d.ts +2 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/BidiOverCdp.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/BidiOverCdp.js +5 -5
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/BidiOverCdp.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/Connection.d.ts +2 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/Connection.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/Connection.js +8 -6
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/Connection.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/Dialog.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/Dialog.js +3 -0
- package/front_end/third_party/puppeteer/package/lib/puppeteer/bidi/Dialog.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Browser.js +16 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Connection.d.ts +5 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Connection.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Connection.js +11 -6
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Connection.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Dialog.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Dialog.js +5 -0
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/Dialog.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/NetworkManager.js +10 -0
- package/front_end/third_party/puppeteer/package/lib/puppeteer/cdp/NetworkManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/BrowserConnector.js +4 -3
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/BrowserConnector.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/Debug.d.ts +27 -2
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/Debug.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/Debug.js +12 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/Debug.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/util.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/util.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/util.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/puppeteer/common/util.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/node/ChromeLauncher.js +2 -0
- package/front_end/third_party/puppeteer/package/lib/puppeteer/node/ChromeLauncher.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/node/ScreenRecorder.d.ts +2 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/node/ScreenRecorder.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/node/ScreenRecorder.js +5 -4
- package/front_end/third_party/puppeteer/package/lib/puppeteer/node/ScreenRecorder.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/revisions.d.ts +3 -3
- package/front_end/third_party/puppeteer/package/lib/puppeteer/revisions.js +3 -3
- package/front_end/third_party/puppeteer/package/lib/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/types.d.ts +64 -15
- package/front_end/third_party/puppeteer/package/package.json +2 -2
- package/front_end/third_party/puppeteer/package/src/api/Page.ts +50 -7
- package/front_end/third_party/puppeteer/package/src/bidi/BidiOverCdp.ts +9 -7
- package/front_end/third_party/puppeteer/package/src/bidi/Connection.ts +9 -6
- package/front_end/third_party/puppeteer/package/src/bidi/Dialog.ts +4 -0
- package/front_end/third_party/puppeteer/package/src/cdp/Browser.ts +24 -1
- package/front_end/third_party/puppeteer/package/src/cdp/Connection.ts +11 -6
- package/front_end/third_party/puppeteer/package/src/cdp/Dialog.ts +7 -0
- package/front_end/third_party/puppeteer/package/src/cdp/NetworkManager.ts +11 -0
- package/front_end/third_party/puppeteer/package/src/common/BrowserConnector.ts +7 -3
- package/front_end/third_party/puppeteer/package/src/common/Debug.ts +30 -5
- package/front_end/third_party/puppeteer/package/src/common/util.ts +2 -2
- package/front_end/third_party/puppeteer/package/src/node/ChromeLauncher.ts +2 -0
- package/front_end/third_party/puppeteer/package/src/node/ScreenRecorder.ts +6 -4
- package/front_end/third_party/puppeteer/package/src/revisions.ts +3 -3
- package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
- package/front_end/third_party/source-map-scopes-codec/package/CONTRIBUTING.md +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/LICENSE +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/README.md +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts.map +1 -1
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/scopes.d.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/_dist/src/scopes.d.ts.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/deno.json +1 -1
- package/front_end/third_party/source-map-scopes-codec/package/package.json +1 -1
- package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js +2 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js.map +1 -1
- package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.ts +2 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/codec.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/codec.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/codec.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/mod.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/mod.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/mod.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/scopes.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/scopes.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/scopes.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/util.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/util.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/util.ts +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/vlq.js +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/vlq.js.map +0 -0
- package/front_end/third_party/source-map-scopes-codec/package/src/vlq.ts +0 -0
- package/front_end/ui/components/dialogs/ShortcutDialog.ts +2 -0
- package/front_end/ui/components/settings/SettingCheckbox.ts +4 -12
- package/front_end/ui/components/settings/settingCheckbox.css +0 -7
- package/front_end/ui/legacy/Treeoutline.ts +14 -14
- package/front_end/ui/legacy/UIUtils.ts +2 -47
- package/front_end/ui/legacy/Widget.ts +10 -2
- package/front_end/ui/legacy/components/settings_ui/SettingsUI.ts +1 -1
- package/front_end/ui/lit/Directives.ts +80 -0
- package/front_end/ui/lit/lit.ts +1 -0
- package/front_end/ui/lit/render.ts +8 -0
- package/front_end/ui/visual_logging/KnownContextValues.ts +18 -0
- package/mcp/mcp.ts +1 -0
- package/package.json +1 -1
- package/front_end/panels/common/ThrottlingUtils.ts +0 -51
- package/front_end/panels/emulation/DeviceModeWrapper.ts +0 -248
- package/front_end/panels/timeline/components/CPUThrottlingSelector.ts +0 -235
- package/front_end/panels/timeline/components/NetworkThrottlingSelector.ts +0 -245
- package/front_end/panels/timeline/components/cpuThrottlingSelector.css +0 -30
- package/front_end/panels/timeline/components/networkThrottlingSelector.css +0 -24
- /package/front_end/core/host/{UserMetricsEnums.d.ts → UserMetricsEnums.ts} +0 -0
- /package/front_end/generated/{ARIAProperties.js → ARIAProperties.ts} +0 -0
package/eslint.config.mjs
CHANGED
|
@@ -29,7 +29,7 @@ export default defineConfig([
|
|
|
29
29
|
'front_end/diff/diff_match_patch.js',
|
|
30
30
|
'front_end/models/javascript_metadata/NativeFunctions.js',
|
|
31
31
|
// All of these scripts are auto-generated so don't lint them.
|
|
32
|
-
'front_end/generated/ARIAProperties.
|
|
32
|
+
'front_end/generated/ARIAProperties.ts',
|
|
33
33
|
'front_end/generated/Deprecation.ts',
|
|
34
34
|
'front_end/generated/InspectorBackendCommands.ts',
|
|
35
35
|
'front_end/generated/protocol-mapping.d.ts',
|
|
@@ -197,7 +197,7 @@ export default defineConfig([
|
|
|
197
197
|
radix: 'error',
|
|
198
198
|
'valid-typeof': 'error',
|
|
199
199
|
'no-return-assign': ['error', 'always'],
|
|
200
|
-
'no-implicit-coercion': ['error', {
|
|
200
|
+
'no-implicit-coercion': ['error', {allow: ['!!']}],
|
|
201
201
|
|
|
202
202
|
'no-array-constructor': 'error',
|
|
203
203
|
|
|
@@ -833,7 +833,7 @@ export default defineConfig([
|
|
|
833
833
|
},
|
|
834
834
|
{
|
|
835
835
|
name: 'Supported CSS properties rules',
|
|
836
|
-
files: ['front_end/generated/SupportedCSSProperties.
|
|
836
|
+
files: ['front_end/generated/SupportedCSSProperties.ts'],
|
|
837
837
|
rules: {
|
|
838
838
|
'@devtools/jslog-context-list': 'error',
|
|
839
839
|
},
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import * as i18n from '../i18n/i18n.js';
|
|
6
6
|
import type * as Platform from '../platform/platform.js';
|
|
7
|
-
import * as Root from '../root/root.js';
|
|
8
7
|
|
|
9
8
|
import type {SettingStorageType} from './Settings.js';
|
|
10
9
|
|
|
@@ -78,10 +77,6 @@ const UIStrings = {
|
|
|
78
77
|
* section allows users to see their signed-in account and configure which DevTools data is synced via Chrome Sync.
|
|
79
78
|
*/
|
|
80
79
|
account: 'Account',
|
|
81
|
-
/**
|
|
82
|
-
* @description Title of the Privacy setting category.
|
|
83
|
-
*/
|
|
84
|
-
privacy: 'Privacy',
|
|
85
80
|
} as const;
|
|
86
81
|
const str_ = i18n.i18n.registerUIStrings('core/common/SettingRegistration.ts', UIStrings);
|
|
87
82
|
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
@@ -98,7 +93,7 @@ export function registerSettingExtension(registration: SettingRegistration): voi
|
|
|
98
93
|
}
|
|
99
94
|
|
|
100
95
|
export function getRegisteredSettings(): SettingRegistration[] {
|
|
101
|
-
return registeredSettings
|
|
96
|
+
return registeredSettings;
|
|
102
97
|
}
|
|
103
98
|
|
|
104
99
|
export function registerSettingsForTest(settings: SettingRegistration[], forceReset = false): void {
|
|
@@ -149,7 +144,6 @@ export const enum SettingCategory {
|
|
|
149
144
|
EXTENSIONS = 'EXTENSIONS',
|
|
150
145
|
ADORNER = 'ADORNER',
|
|
151
146
|
ACCOUNT = 'ACCOUNT',
|
|
152
|
-
PRIVACY = 'PRIVACY',
|
|
153
147
|
}
|
|
154
148
|
|
|
155
149
|
export function getLocalizedSettingsCategory(category: SettingCategory): Platform.UIString.LocalizedString {
|
|
@@ -192,8 +186,6 @@ export function getLocalizedSettingsCategory(category: SettingCategory): Platfor
|
|
|
192
186
|
return i18n.i18n.lockedString('');
|
|
193
187
|
case SettingCategory.ACCOUNT:
|
|
194
188
|
return i18nString(UIStrings.account);
|
|
195
|
-
case SettingCategory.PRIVACY:
|
|
196
|
-
return i18nString(UIStrings.privacy);
|
|
197
189
|
}
|
|
198
190
|
}
|
|
199
191
|
|
|
@@ -268,19 +260,6 @@ export interface SettingRegistration {
|
|
|
268
260
|
* Determines if the setting value is stored in the global, local or session storage.
|
|
269
261
|
*/
|
|
270
262
|
storageType?: SettingStorageType;
|
|
271
|
-
/**
|
|
272
|
-
* A condition is a function that will make the setting available if it
|
|
273
|
-
* returns true, and not available, otherwise. Make sure that objects you
|
|
274
|
-
* access from inside the condition function are ready at the time when the
|
|
275
|
-
* setting conditions are checked.
|
|
276
|
-
*/
|
|
277
|
-
condition?: Root.Runtime.Condition;
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* A function that returns true if the setting should be disabled, along with
|
|
281
|
-
* the reason why.
|
|
282
|
-
*/
|
|
283
|
-
disabledCondition?: (config?: Root.Runtime.HostConfig) => DisabledConditionResult;
|
|
284
263
|
|
|
285
264
|
/**
|
|
286
265
|
* See {@link LearnMore} for more info.
|
|
@@ -319,7 +298,3 @@ interface RawSettingExtensionOption {
|
|
|
319
298
|
raw: true;
|
|
320
299
|
}
|
|
321
300
|
export type SettingExtensionOption = LocalizedSettingExtensionOption|RawSettingExtensionOption;
|
|
322
|
-
export type DisabledConditionResult = {
|
|
323
|
-
disabled: true,
|
|
324
|
-
reasons: Platform.UIString.LocalizedString[],
|
|
325
|
-
}|{disabled: false};
|
|
@@ -499,10 +499,7 @@ export class Setting<V> {
|
|
|
499
499
|
#type: SettingType|null = null;
|
|
500
500
|
#requiresUserAction?: boolean;
|
|
501
501
|
#value?: V;
|
|
502
|
-
// TODO(crbug.com/1172300) Type cannot be inferred without changes to consumers. See above.
|
|
503
|
-
#serializer: Serializer<unknown, V> = JSON;
|
|
504
502
|
#hadUserAction?: boolean;
|
|
505
|
-
#disabled?: boolean;
|
|
506
503
|
#loggedInitialAccess = false;
|
|
507
504
|
#logSettingAccess?: (name: string, value: number|string|boolean) => Promise<void>;
|
|
508
505
|
readonly #console: Console;
|
|
@@ -515,10 +512,6 @@ export class Setting<V> {
|
|
|
515
512
|
this.#logSettingAccess = logSettingAccess;
|
|
516
513
|
}
|
|
517
514
|
|
|
518
|
-
setSerializer(serializer: Serializer<unknown, V>): void {
|
|
519
|
-
this.#serializer = serializer;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
515
|
descriptor(): SettingDescriptor<V> {
|
|
523
516
|
return {
|
|
524
517
|
name: this.name,
|
|
@@ -547,38 +540,11 @@ export class Setting<V> {
|
|
|
547
540
|
this.#requiresUserAction = requiresUserAction;
|
|
548
541
|
}
|
|
549
542
|
|
|
550
|
-
disabled(): boolean {
|
|
551
|
-
if (this.#registration?.disabledCondition) {
|
|
552
|
-
const {disabled} = this.#registration.disabledCondition(Root.Runtime.hostConfig);
|
|
553
|
-
// If registration does not disable it, pass through to #disabled
|
|
554
|
-
// attribute check.
|
|
555
|
-
if (disabled) {
|
|
556
|
-
return true;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
return this.#disabled || false;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
disabledReasons(): Platform.UIString.LocalizedString[] {
|
|
563
|
-
if (this.#registration?.disabledCondition) {
|
|
564
|
-
const result = this.#registration.disabledCondition(Root.Runtime.hostConfig);
|
|
565
|
-
if (result.disabled) {
|
|
566
|
-
return result.reasons;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
return [];
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
setDisabled(disabled: boolean): void {
|
|
573
|
-
this.#disabled = disabled;
|
|
574
|
-
this.eventSupport.dispatchEventToListeners(this.name);
|
|
575
|
-
}
|
|
576
|
-
|
|
577
543
|
#maybeLogAccess(value: V): void {
|
|
578
544
|
try {
|
|
579
545
|
const valueToLog = typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' ?
|
|
580
546
|
value :
|
|
581
|
-
|
|
547
|
+
JSON.stringify(value);
|
|
582
548
|
if (valueToLog !== undefined && this.#logSettingAccess) {
|
|
583
549
|
void this.#logSettingAccess(this.name, valueToLog);
|
|
584
550
|
}
|
|
@@ -607,7 +573,7 @@ export class Setting<V> {
|
|
|
607
573
|
this.#value = this.defaultValue;
|
|
608
574
|
if (this.storage.has(this.name)) {
|
|
609
575
|
try {
|
|
610
|
-
this.#value =
|
|
576
|
+
this.#value = JSON.parse(this.storage.get(this.name)) as V;
|
|
611
577
|
} catch {
|
|
612
578
|
this.storage.remove(this.name);
|
|
613
579
|
}
|
|
@@ -616,16 +582,6 @@ export class Setting<V> {
|
|
|
616
582
|
return this.#value;
|
|
617
583
|
}
|
|
618
584
|
|
|
619
|
-
// Prefer this getter for settings which are "disableable". The plain getter returns `this.#value`,
|
|
620
|
-
// even if the setting is disabled, which means the callsite has to explicitly call the `disabled()`
|
|
621
|
-
// getter and add its own logic for the disabled state.
|
|
622
|
-
getIfNotDisabled(): V|undefined {
|
|
623
|
-
if (this.disabled()) {
|
|
624
|
-
return;
|
|
625
|
-
}
|
|
626
|
-
return this.get();
|
|
627
|
-
}
|
|
628
|
-
|
|
629
585
|
async forceGet(): Promise<V> {
|
|
630
586
|
const name = this.name;
|
|
631
587
|
const oldValue = this.storage.get(name);
|
|
@@ -633,7 +589,7 @@ export class Setting<V> {
|
|
|
633
589
|
this.#value = this.defaultValue;
|
|
634
590
|
if (value) {
|
|
635
591
|
try {
|
|
636
|
-
this.#value =
|
|
592
|
+
this.#value = JSON.parse(value) as V;
|
|
637
593
|
} catch {
|
|
638
594
|
this.storage.remove(this.name);
|
|
639
595
|
}
|
|
@@ -652,7 +608,7 @@ export class Setting<V> {
|
|
|
652
608
|
this.#hadUserAction = true;
|
|
653
609
|
this.#value = value;
|
|
654
610
|
try {
|
|
655
|
-
const settingString =
|
|
611
|
+
const settingString = JSON.stringify(value);
|
|
656
612
|
try {
|
|
657
613
|
this.storage.set(this.name, settingString);
|
|
658
614
|
} catch (e) {
|
|
@@ -822,11 +778,6 @@ export {
|
|
|
822
778
|
SettingType,
|
|
823
779
|
};
|
|
824
780
|
|
|
825
|
-
export interface Serializer<I, O> {
|
|
826
|
-
stringify: (value: I) => string;
|
|
827
|
-
parse: (value: string) => O;
|
|
828
|
-
}
|
|
829
|
-
|
|
830
781
|
export interface SimpleSettingOption {
|
|
831
782
|
value: string|boolean;
|
|
832
783
|
title: string;
|