Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | 68x 68x 68x 68x 1x 1x 1x 1x 1x 68x 68x | import { createSlice, original, PayloadAction } from "@reduxjs/toolkit";
import type { SceneMapData, VariableMapData } from "lib/compiler/compileData";
import type { UsageData } from "lib/compiler/buildUsage";
import isEqual from "lodash/isEqual";
import type { DebuggerScriptContext } from "shared/lib/debugger/types";
import type { BuildUsageItemType } from "shared/lib/compiler/buildUsageItems";
export type DebuggerPane = "debugger" | "buildLog" | "romUsage";
export type DataUsageSortKey = "size" | "name" | "filename" | "type";
export type DataUsageFilter = "all" | BuildUsageItemType;
export interface DebuggerState {
initialized: boolean;
variableSymbols: string[];
variableDataBySymbol: Record<string, VariableMapData>;
gbvmScripts: Record<string, string>;
sceneMap: Record<string, SceneMapData>;
vramPreview: string;
backgroundPreview: string;
variablesData: number[];
scriptContexts: DebuggerScriptContext[];
currentSceneSymbol: string;
isPaused: boolean;
activePane: DebuggerPane;
usageData: UsageData | null;
dataUsageSearchTerm: string;
dataUsageFilter: DataUsageFilter;
dataUsageSortKey: DataUsageSortKey;
dataUsageSortAsc: boolean;
}
export const initialState: DebuggerState = {
initialized: false,
variableSymbols: [],
variableDataBySymbol: {},
gbvmScripts: {},
sceneMap: {},
vramPreview: "",
backgroundPreview: "",
variablesData: [],
scriptContexts: [],
currentSceneSymbol: "",
isPaused: true,
activePane: "debugger",
usageData: null,
dataUsageSearchTerm: "",
dataUsageFilter: "all",
dataUsageSortKey: "size",
dataUsageSortAsc: false,
};
const debuggerSlice = createSlice({
name: "debug",
initialState,
reducers: {
disconnect: (state) => {
state.initialized = false;
state.isPaused = false;
},
setSymbols: (
state,
action: PayloadAction<{
variableDataBySymbol: Record<string, VariableMapData>;
sceneMap: Record<string, SceneMapData>;
gbvmScripts: Record<string, string>;
}>,
) => {
state.variableDataBySymbol = action.payload.variableDataBySymbol;
state.sceneMap = action.payload.sceneMap;
state.gbvmScripts = action.payload.gbvmScripts;
state.variableSymbols = Object.keys(state.variableDataBySymbol);
state.initialized = true;
},
setRAMData: (
state,
action: PayloadAction<{
vramPreview: string;
backgroundPreview: string;
variablesData: number[];
scriptContexts: DebuggerScriptContext[];
currentSceneSymbol: string;
isPaused: boolean;
}>,
) => {
if (!state.isPaused && action.payload.isPaused) {
// Debugger became paused, close build log
state.activePane = "debugger";
}
state.isPaused = action.payload.isPaused;
state.vramPreview = action.payload.vramPreview;
state.backgroundPreview = action.payload.backgroundPreview;
if (!isEqual(state.variablesData, action.payload.variablesData)) {
state.variablesData = action.payload.variablesData;
}
if (
!isEqual(original(state.scriptContexts), action.payload.scriptContexts)
) {
state.scriptContexts = action.payload.scriptContexts;
}
state.currentSceneSymbol = action.payload.currentSceneSymbol;
},
setActivePane: (state, action: PayloadAction<DebuggerPane>) => {
state.activePane = action.payload;
},
setUsageData: (state, action: PayloadAction<UsageData>) => {
state.usageData = action.payload;
},
setDataUsageSearchTerm: (state, action: PayloadAction<string>) => {
state.dataUsageSearchTerm = action.payload;
},
setDataUsageFilter: (state, action: PayloadAction<DataUsageFilter>) => {
state.dataUsageFilter = action.payload;
},
setDataUsageSortKey: (state, action: PayloadAction<DataUsageSortKey>) => {
state.dataUsageSortKey = action.payload;
},
setDataUsageSortAsc: (state, action: PayloadAction<boolean>) => {
state.dataUsageSortAsc = action.payload;
},
},
});
export const { actions } = debuggerSlice;
export default debuggerSlice.reducer;
|