From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- devtools/client/performance-new/store/selectors.js | 104 +++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 devtools/client/performance-new/store/selectors.js (limited to 'devtools/client/performance-new/store/selectors.js') diff --git a/devtools/client/performance-new/store/selectors.js b/devtools/client/performance-new/store/selectors.js new file mode 100644 index 0000000000..91f5bc9b65 --- /dev/null +++ b/devtools/client/performance-new/store/selectors.js @@ -0,0 +1,104 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +// @ts-check +"use strict"; + +/** + * @typedef {import("../@types/perf").RecordingState} RecordingState + * @typedef {import("../@types/perf").RecordingSettings} RecordingSettings + * @typedef {import("../@types/perf").InitializedValues} InitializedValues + * @typedef {import("../@types/perf").PerfFront} PerfFront + * @typedef {import("../@types/perf").ReceiveProfile} ReceiveProfile + * @typedef {import("../@types/perf").RestartBrowserWithEnvironmentVariable} RestartBrowserWithEnvironmentVariable + * @typedef {import("../@types/perf").PageContext} PageContext + * @typedef {import("../@types/perf").Presets} Presets + */ +/** + * @template S + * @typedef {import("../@types/perf").Selector} Selector + */ + +/** @type {Selector} */ +const getRecordingState = state => state.recordingState; + +/** @type {Selector} */ +const getRecordingUnexpectedlyStopped = state => + state.recordingUnexpectedlyStopped; + +/** @type {Selector} */ +const getIsSupportedPlatform = state => state.isSupportedPlatform; + +/** @type {Selector} */ +const getRecordingSettings = state => state.recordingSettings; + +/** @type {Selector} */ +const getInterval = state => getRecordingSettings(state).interval; + +/** @type {Selector} */ +const getEntries = state => getRecordingSettings(state).entries; + +/** @type {Selector} */ +const getFeatures = state => getRecordingSettings(state).features; + +/** @type {Selector} */ +const getThreads = state => getRecordingSettings(state).threads; + +/** @type {Selector} */ +const getThreadsString = state => getThreads(state).join(","); + +/** @type {Selector} */ +const getObjdirs = state => getRecordingSettings(state).objdirs; + +/** @type {Selector} */ +const getPresets = state => getInitializedValues(state).presets; + +/** @type {Selector} */ +const getPresetName = state => state.recordingSettings.presetName; + +/** + * When remote profiling, there will be a back button to the settings. + * + * @type {Selector<(() => void) | undefined>} + */ +const getOpenRemoteDevTools = state => + getInitializedValues(state).openRemoteDevTools; + +/** @type {Selector} */ +const getInitializedValues = state => { + const values = state.initializedValues; + if (!values) { + throw new Error("The store must be initialized before it can be used."); + } + return values; +}; + +/** @type {Selector} */ +const getPageContext = state => getInitializedValues(state).pageContext; + +/** @type {Selector} */ +const getSupportedFeatures = state => + getInitializedValues(state).supportedFeatures; + +/** @type {Selector} */ +const getPromptEnvRestart = state => state.promptEnvRestart; + +module.exports = { + getRecordingState, + getRecordingUnexpectedlyStopped, + getIsSupportedPlatform, + getInterval, + getEntries, + getFeatures, + getThreads, + getThreadsString, + getObjdirs, + getPresets, + getPresetName, + getOpenRemoteDevTools, + getRecordingSettings, + getInitializedValues, + getPageContext, + getPromptEnvRestart, + getSupportedFeatures, +}; -- cgit v1.2.3