Skip to content

Commit

Permalink
Dependabot manual updates (#9509)
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamlangford authored Nov 12, 2024
1 parent 2196577 commit a017277
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 51 deletions.
8 changes: 5 additions & 3 deletions applications/browser-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@vespaiach/axios-fetch-adapter": "^0.3.1",
"@xobotyi/scrollbar-width": "^1.9.5",
"abort-utils": "^1.2.0",
"ace-builds": "^1.36.3",
"ace-builds": "^1.36.4",
"autocompleter": "^9.3.2",
"axios": "^0.28.1",
"axios-auth-refresh": "^3.3.6",
Expand Down Expand Up @@ -133,7 +133,7 @@
"react-redux": "^8.1.3",
"react-router": "5.3.4",
"react-router-dom": "^5.3.4",
"react-select": "^5.8.2",
"react-select": "^5.8.3",
"react-select-virtualized": "^5.6.0",
"react-shadow": "^20.5.0",
"react-spinners": "^0.13.0",
Expand Down Expand Up @@ -223,6 +223,7 @@
"@types/object-hash": "^3.0.6",
"@types/papaparse": "^5.3.15",
"@types/psl": "^1.1.3",
"@types/react": "^17.0.83",
"@types/react-autosuggest": "^10.1.11",
"@types/react-dom": "^17.0.9",
"@types/react-outside-click-handler": "^1.3.4",
Expand All @@ -235,6 +236,7 @@
"@types/redux-state-sync": "^3.1.10",
"@types/semver": "^7.5.8",
"@types/sinonjs__fake-timers": "^8.1.5",
"@types/trusted-types": "^2.0.7",
"@types/use-sync-external-store": "^0.0.6",
"@types/webextension-polyfill": "^0.12.1",
"@types/webpack": "^5.28.5",
Expand All @@ -255,7 +257,7 @@
"eslint": "^8.57.0",
"eslint-config-pixiebrix": "^0.41.1",
"eslint-plugin-local-rules": "^3.0.2",
"eslint-plugin-playwright": "^2.0.0",
"eslint-plugin-playwright": "^2.0.1",
"fake-indexeddb": "^6.0.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.7.0",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions applications/browser-extension/src/pageEditor/store/castState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2024 PixieBrix, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { type EditorState } from "@/pageEditor/store/editor/pageEditorTypes";
import { type SidebarState } from "@/types/sidebarTypes";
import { type Draft } from "immer";

function castState(state: Draft<EditorState>): EditorState;
function castState(state: Draft<SidebarState>): SidebarState;
function castState<T>(state: Draft<T>): T {
return state as T;
}

export default castState;
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import {
initialEphemeralState,
initialState,
} from "@/store/editorInitialState";
import castEditorState from "@/pageEditor/store/castState";

/* eslint-disable security/detect-object-injection -- lots of immer-style code here dealing with Records */

Expand Down Expand Up @@ -380,7 +381,9 @@ export const editorSlice = createSlice({
setActiveModComponentId(state, action: PayloadAction<UUID>) {
const modComponentId = action.payload;
const getModComponentFormStateByModComponentId =
selectGetModComponentFormStateByModComponentId({ editor: state });
selectGetModComponentFormStateByModComponentId({
editor: castEditorState(state),
});
const modComponentFormState =
getModComponentFormStateByModComponentId(modComponentId);

Expand Down Expand Up @@ -481,7 +484,9 @@ export const editorSlice = createSlice({
) {
const { modId, modMetadata } = action.payload;
const getModComponentFormStatesForMod =
selectGetModComponentFormStatesForMod({ editor: state });
selectGetModComponentFormStatesForMod({
editor: castEditorState(state),
});
const modComponentFormStatesForMod =
getModComponentFormStatesForMod(modId);

Expand All @@ -502,7 +507,9 @@ export const editorSlice = createSlice({
markModAsCleanById(state, action: PayloadAction<RegistryId>) {
const modId = action.payload;
const getModComponentFormStatesForMod =
selectGetModComponentFormStatesForMod({ editor: state });
selectGetModComponentFormStatesForMod({
editor: castEditorState(state),
});
const modComponentFormStatesForMod =
getModComponentFormStatesForMod(modId);

Expand All @@ -525,7 +532,9 @@ export const editorSlice = createSlice({
const modId = action.payload;

const getModComponentFormStatesForMod =
selectGetModComponentFormStatesForMod({ editor: state });
selectGetModComponentFormStatesForMod({
editor: castEditorState(state),
});
const modComponentFormStatesForMod =
getModComponentFormStatesForMod(modId);

Expand Down Expand Up @@ -655,7 +664,9 @@ export const editorSlice = createSlice({
const modComponentId = action.payload;

const getModComponentFormStateByModComponentId =
selectGetModComponentFormStateByModComponentId({ editor: state });
selectGetModComponentFormStateByModComponentId({
editor: castEditorState(state),
});
const modComponentFormState =
getModComponentFormStateByModComponentId(modComponentId);

Expand Down Expand Up @@ -735,7 +746,9 @@ export const editorSlice = createSlice({
);

const getModComponentFormStateByModComponentId =
selectGetModComponentFormStateByModComponentId({ editor: state });
selectGetModComponentFormStateByModComponentId({
editor: castEditorState(state),
});
const modComponentFormState = getModComponentFormStateByModComponentId(
state.activeModComponentId,
);
Expand Down Expand Up @@ -788,15 +801,15 @@ export const editorSlice = createSlice({
) {
const { nodeId, direction } = action.payload;
const activeModComponentFormState = selectActiveModComponentFormState({
editor: state,
editor: castEditorState(state),
});
assertNotNullish(
activeModComponentFormState,
"Active mod component form state not found",
);

const activeBrickPipelineUIState = selectActiveBrickPipelineUIState({
editor: state,
editor: castEditorState(state),
});
const node = activeBrickPipelineUIState?.pipelineMap[nodeId];
assertNotNullish(node, `Node not found in pipeline map: ${nodeId}`);
Expand Down Expand Up @@ -831,15 +844,15 @@ export const editorSlice = createSlice({
removeNode(state, action: PayloadAction<UUID>) {
const nodeIdToRemove = action.payload;
const activeModComponentFormState = selectActiveModComponentFormState({
editor: state,
editor: castEditorState(state),
});
assertNotNullish(
activeModComponentFormState,
"Active mod component form state not found",
);

const activeBrickPipelineUIState = selectActiveBrickPipelineUIState({
editor: state,
editor: castEditorState(state),
});
assertNotNullish(
activeBrickPipelineUIState,
Expand Down Expand Up @@ -899,7 +912,7 @@ export const editorSlice = createSlice({
{ payload }: PayloadAction<{ id: string; isExpanded: boolean }>,
) {
const uiState = selectActiveBrickConfigurationUIState({
editor: state,
editor: castEditorState(state),
});
assertNotNullish(uiState, "Active node UI state not found");

Expand Down Expand Up @@ -982,7 +995,9 @@ export const editorSlice = createSlice({
setDataPanelTabFindQuery(state, action: PayloadAction<{ query: string }>) {
const { query } = action.payload;

const currentModId = selectCurrentModId({ editor: state });
const currentModId = selectCurrentModId({
editor: castEditorState(state),
});
assertNotNullish(currentModId, "Expected currentModId");

state.findInModQueryByModId[currentModId] = { query };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { clearModComponentTraces } from "@/telemetry/trace";
import { assertNotNullish } from "@/utils/nullishUtils";
import { remove } from "lodash";
import { selectGetModComponentFormStateByModComponentId } from "@/pageEditor/store/editor/editorSelectors";
import castEditorState from "@/pageEditor/store/castState";

/* eslint-disable security/detect-object-injection -- lots of immer-style code here dealing with Records */

Expand All @@ -43,9 +44,9 @@ export function ensureBrickPipelineUIState(
makeInitialBrickPipelineUIState();

const modComponentFormState =
selectGetModComponentFormStateByModComponentId({ editor: state })(
modComponentId,
);
selectGetModComponentFormStateByModComponentId({
editor: castEditorState(state),
})(modComponentId);
const pipeline = modComponentFormState?.modComponent.brickPipeline;

assertNotNullish(
Expand Down
41 changes: 27 additions & 14 deletions applications/browser-extension/src/store/sidebar/sidebarSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import resolveTemporaryPanel from "@/store/sidebar/thunks/resolveTemporaryPanel"
import { initialSidebarState } from "@/store/sidebar/initialState";
import removeFormPanel from "@/store/sidebar/thunks/removeFormPanel";
import { type ModComponentRef } from "@/types/modComponentTypes";
import castSidebarState from "@/pageEditor/store/castState";

function findNextActiveKey(
state: SidebarState,
Expand Down Expand Up @@ -207,7 +208,7 @@ const sidebarSlice = createSlice({
selectTab(state, action: PayloadAction<string>) {
// We were seeing some automatic calls to selectTab with a stale event key...
// Calling selectTab with a stale event key shouldn't change the current tab
if (eventKeyExists(state, action.payload)) {
if (eventKeyExists(castSidebarState(state), action.payload)) {
state.activeKey = action.payload;
state.closedTabs[action.payload] = false;
}
Expand All @@ -220,7 +221,10 @@ const sidebarSlice = createSlice({

const entry = remove(state.forms, (form) => form.nonce === nonce)[0];

fixActiveTabOnRemoveInPlace(state, entry);
fixActiveTabOnRemoveInPlace(
castSidebarState(state),
entry as FormPanelEntry,
);
},
invalidatePanels(state) {
for (const panel of state.panels) {
Expand Down Expand Up @@ -268,7 +272,7 @@ const sidebarSlice = createSlice({
activatePanel(state, { payload }: PayloadAction<ActivatePanelOptions>) {
state.pendingActivePanel = null;

const visiblePanelCount = getVisiblePanelCount(state);
const visiblePanelCount = getVisiblePanelCount(castSidebarState(state));
const isModLauncherOnlyTabVisible =
visiblePanelCount === 1 &&
!state.closedTabs[eventKeyForEntry(MOD_LAUNCHER)];
Expand All @@ -285,7 +289,7 @@ const sidebarSlice = createSlice({
state.closedTabs[eventKeyForEntry(MOD_LAUNCHER)] = true;
}

const next = findNextActiveKey(state, payload);
const next = findNextActiveKey(castSidebarState(state), payload);

if (next) {
state.activeKey = next;
Expand Down Expand Up @@ -316,7 +320,10 @@ const sidebarSlice = createSlice({

// Try fulfilling the pendingActivePanel request
if (state.pendingActivePanel) {
const next = findNextActiveKey(state, state.pendingActivePanel);
const next = findNextActiveKey(
castSidebarState(state),
state.pendingActivePanel,
);
if (next) {
state.activeKey = next;
state.pendingActivePanel = null;
Expand All @@ -325,8 +332,11 @@ const sidebarSlice = createSlice({
}

// If a panel is no longer available, reset the current tab to a valid tab.
if (!eventKeyExists(state, state.activeKey)) {
state.activeKey = defaultEventKey(state, state.closedTabs);
if (!eventKeyExists(castSidebarState(state), state.activeKey)) {
state.activeKey = defaultEventKey(
castSidebarState(state),
state.closedTabs,
);
}
},
showModActivationPanel(
Expand All @@ -343,25 +353,28 @@ const sidebarSlice = createSlice({
const { modActivationPanel: entry, closedTabs } = state;
state.modActivationPanel = null;

if (getVisiblePanelCount(state) === 0) {
if (getVisiblePanelCount(castSidebarState(state)) === 0) {
closedTabs[eventKeyForEntry(MOD_LAUNCHER)] = false;
}

fixActiveTabOnRemoveInPlace(state, entry);
fixActiveTabOnRemoveInPlace(castSidebarState(state), entry);
},
closeTab(state, action: PayloadAction<string>) {
state.closedTabs[action.payload] = true;

const modLauncherEventKey = eventKeyForEntry(MOD_LAUNCHER);
if (
getVisiblePanelCount(state) === 0 &&
getVisiblePanelCount(castSidebarState(state)) === 0 &&
action.payload !== modLauncherEventKey
) {
state.closedTabs[eventKeyForEntry(MOD_LAUNCHER)] = false;
}

if (state.activeKey === action.payload) {
state.activeKey = defaultEventKey(state, state.closedTabs);
state.activeKey = defaultEventKey(
castSidebarState(state),
state.closedTabs,
);
}
},
openTab(state, action: PayloadAction<string>) {
Expand All @@ -383,7 +396,7 @@ const sidebarSlice = createSlice({
const { removedEntry, forms } = action.payload;

state.forms = castDraft(forms);
fixActiveTabOnRemoveInPlace(state, removedEntry);
fixActiveTabOnRemoveInPlace(castSidebarState(state), removedEntry);
}
})
.addCase(addTemporaryPanel.fulfilled, (state, action) => {
Expand All @@ -398,15 +411,15 @@ const sidebarSlice = createSlice({
const { removedEntry, temporaryPanels } = action.payload;

state.temporaryPanels = castDraft(temporaryPanels);
fixActiveTabOnRemoveInPlace(state, removedEntry);
fixActiveTabOnRemoveInPlace(castSidebarState(state), removedEntry);
}
})
.addCase(resolveTemporaryPanel.fulfilled, (state, action) => {
if (action.payload) {
const { resolvedEntry, temporaryPanels } = action.payload;

state.temporaryPanels = castDraft(temporaryPanels);
fixActiveTabOnRemoveInPlace(state, resolvedEntry);
fixActiveTabOnRemoveInPlace(castSidebarState(state), resolvedEntry);
}
});
},
Expand Down
6 changes: 4 additions & 2 deletions applications/browser-extension/src/utils/modUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,10 @@ export function normalizeModDefinition<
T extends UnsavedModDefinition = UnsavedModDefinition,
>(definition: T): T {
return produce(definition, (draft) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- type error due to nested readonly string array
draft.options = normalizeModOptionsDefinition(draft.options) as any;
draft.options = normalizeModOptionsDefinition(
draft.options as ModDefinition["options"] | null,
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- type error due to nested readonly string array
) as any;
draft.variables ??= emptyModVariablesDefinitionFactory();
draft.definitions = mapValues(
draft.definitions ?? {},
Expand Down
1 change: 1 addition & 0 deletions knip.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const knipConfig = {
// Browser environment types
"@types/chrome",
"@types/dom-navigation",
"@types/trusted-types",
// Provides require.context, etc.
"@types/webpack-env",
// Used by src/contrib/google/sheets/core/types.ts
Expand Down
Loading

0 comments on commit a017277

Please sign in to comment.