summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/src/selectors/pause.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /devtools/client/debugger/src/selectors/pause.js
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/src/selectors/pause.js')
-rw-r--r--devtools/client/debugger/src/selectors/pause.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/devtools/client/debugger/src/selectors/pause.js b/devtools/client/debugger/src/selectors/pause.js
new file mode 100644
index 0000000000..fa87fcc36e
--- /dev/null
+++ b/devtools/client/debugger/src/selectors/pause.js
@@ -0,0 +1,59 @@
+// @flow
+/* 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/>. */
+
+import { getCurrentThread } from "../reducers/pause";
+import { getSelectedLocation } from "../reducers/sources";
+
+// eslint-disable-next-line
+import { getSelectedLocation as _getSelectedLocation } from "../utils/selected-location";
+import { createSelector } from "reselect";
+
+import type { Frame, SourceLocation, ThreadId } from "../types";
+import type { Selector, State } from "../reducers/types";
+
+export const getSelectedFrames: Selector<{ [string]: ?Frame }> = createSelector(
+ state => state.pause.threads,
+ threadPauseState => {
+ const selectedFrames = {};
+ for (const thread in threadPauseState) {
+ const pausedThread = threadPauseState[thread];
+ const { selectedFrameId, frames } = pausedThread;
+ if (frames) {
+ selectedFrames[thread] = frames.find(
+ frame => frame.id == selectedFrameId
+ );
+ }
+ }
+ return selectedFrames;
+ }
+);
+
+export function getSelectedFrame(state: State, thread: ThreadId): ?Frame {
+ const selectedFrames = getSelectedFrames(state);
+ return selectedFrames[thread];
+}
+
+export const getVisibleSelectedFrame: Selector<?{
+ id: string,
+ location: SourceLocation,
+}> = createSelector(
+ getSelectedLocation,
+ getSelectedFrames,
+ getCurrentThread,
+ (selectedLocation, selectedFrames, thread) => {
+ const selectedFrame = selectedFrames[thread];
+ if (!selectedFrame) {
+ return null;
+ }
+
+ const { id, displayName } = selectedFrame;
+
+ return {
+ id,
+ displayName,
+ location: _getSelectedLocation(selectedFrame, selectedLocation),
+ };
+ }
+);