From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- devtools/client/debugger/src/selectors/pause.js | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 devtools/client/debugger/src/selectors/pause.js (limited to 'devtools/client/debugger/src/selectors/pause.js') 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 . */ + +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 = 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), + }; + } +); -- cgit v1.2.3