/* 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 { getThreadPauseState } from "../reducers/pause"; import { getSelectedSource, getSelectedLocation } from "./sources"; import { getBlackBoxRanges } from "./source-blackbox"; import { getSelectedTraceSource } from "./tracer";
// eslint-disable-next-line import { getSelectedLocation as _getSelectedLocation } from "../utils/selected-location"; import { isFrameBlackBoxed } from "../utils/source"; import { createSelector } from "devtools/client/shared/vendor/reselect";
function getGeneratedFrameId(frameId) { if (frameId.includes("-originalFrame")) { // The mapFrames can add original stack frames -- get generated frameId. return frameId.substr(0, frameId.lastIndexOf("-originalFrame"));
} return frameId;
}
export function getGeneratedFrameScope(state, frame) { if (!frame) { returnnull;
} return getFrameScopes(state, frame.thread).generated[
getGeneratedFrameId(frame.id)
];
}
export function getOriginalFrameScope(state, frame) { if (!frame) { returnnull;
} // Only compute original scope if we are currently showing an original source. const source = getSelectedSource(state); if (!source || !source.isOriginal) { returnnull;
}
const original = getFrameScopes(state, frame.thread).original[
getGeneratedFrameId(frame.id)
];
if (original && (original.pending || original.scope)) { return original;
}
returnnull;
}
// This is only used by tests
export function getFrameScopes(state, thread) { return getThreadPauseState(state.pause, thread).frameScopes;
}
export function getSelectedFrameId(state, thread) { return getThreadPauseState(state.pause, thread).selectedFrameId;
}
export function isTopFrameSelected(state, thread) { const selectedFrameId = getSelectedFrameId(state, thread); // Consider that the top frame is selected when none is specified, // which happens when a JS Tracer frame is selected. if (!selectedFrameId) { returntrue;
} const topFrame = getTopFrame(state, thread); return selectedFrameId == topFrame?.id;
}
// getTopFrame wouldn't return the top frame if the frames are still being fetched
export function getCurrentlyFetchedTopFrame(state, thread) { const { frames } = getThreadPauseState(state.pause, thread); return frames?.[0];
}
export function hasFrame(state, frame) { // Don't use getFrames as it returns null when the frames are still loading const { frames } = getThreadPauseState(state.pause, frame.thread); if (!frames) { returnfalse;
} // Compare IDs and not frame objects as they get cloned during mapping return frames.some(f => f.id == frame.id);
}
export function getSkipPausing(state) { return state.pause.skipPausing;
}
export function isMapScopesEnabled(state) { return state.pause.mapScopes;
}
/** * This selector only returns inline previews object for current paused location. * (it ignores the JS Tracer and ignore the selected location, which may different from paused location)
*/
export function getSelectedFrameInlinePreviews(state) { constthread = getCurrentThread(state); const frame = getSelectedFrame(state, thread); if (!frame) { returnnull;
} return getThreadPauseState(state.pause, thread).inlinePreview[
getGeneratedFrameId(frame.id)
];
}
/** * This selector returns the inline previews object for the selected location. * It consider both paused and traced previews and will only return values * if it matches the currently selected location.
*/
export function getInlinePreviews(state) { const selectedSource = getSelectedSource(state); if (!selectedSource) { returnnull;
}
// We first check if a frame in the JS Tracer was selected and generated its previews if (state.tracerFrames?.previews) { const selectedTraceSource = getSelectedTraceSource(state); if (selectedTraceSource) { if (selectedTraceSource.id == selectedSource.id) { return state.tracerFrames?.previews;
}
}
}
// Otherwise, we fallback to look if we were paused and the inline preview is available constthread = getCurrentThread(state); const frame = getSelectedFrame(state, thread); // When we are paused, we also check if the selected source matches the paused original or generated location. if (
!frame ||
(frame.location.source.id != selectedSource.id &&
frame.generatedLocation.source.id != selectedSource.id)
) { returnnull;
} return getThreadPauseState(state.pause, thread).inlinePreview[
getGeneratedFrameId(frame.id)
];
}
export function getLastExpandedScopes(state, thread) { return getThreadPauseState(state.pause, thread).lastExpandedScopes;
}
¤ Dauer der Verarbeitung: 0.24 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.