From a01727785163e2693b46c0aa7996891b9bb93fec Mon Sep 17 00:00:00 2001
From: Graham Langford <30706330+grahamlangford@users.noreply.github.com>
Date: Tue, 12 Nov 2024 17:48:10 -0600
Subject: [PATCH] Dependabot manual updates (#9509)
---
applications/browser-extension/package.json | 8 ++--
.../CodeEditorWidget.test.tsx.snap | 1 +
.../src/pageEditor/store/castState.ts | 28 +++++++++++++
.../pageEditor/store/editor/editorSlice.ts | 39 ++++++++++++------
.../store/editor/editorSliceHelpers.ts | 7 ++--
.../src/store/sidebar/sidebarSlice.ts | 41 ++++++++++++-------
.../browser-extension/src/utils/modUtils.ts | 6 ++-
knip.mjs | 1 +
package-lock.json | 41 +++++++++++--------
9 files changed, 121 insertions(+), 51 deletions(-)
create mode 100644 applications/browser-extension/src/pageEditor/store/castState.ts
diff --git a/applications/browser-extension/package.json b/applications/browser-extension/package.json
index b03b2e9268..55ec48becd 100644
--- a/applications/browser-extension/package.json
+++ b/applications/browser-extension/package.json
@@ -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",
@@ -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",
@@ -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",
@@ -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",
@@ -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",
diff --git a/applications/browser-extension/src/components/fields/schemaFields/widgets/__snapshots__/CodeEditorWidget.test.tsx.snap b/applications/browser-extension/src/components/fields/schemaFields/widgets/__snapshots__/CodeEditorWidget.test.tsx.snap
index 2f41d95b19..40736feb27 100644
--- a/applications/browser-extension/src/components/fields/schemaFields/widgets/__snapshots__/CodeEditorWidget.test.tsx.snap
+++ b/applications/browser-extension/src/components/fields/schemaFields/widgets/__snapshots__/CodeEditorWidget.test.tsx.snap
@@ -13,6 +13,7 @@ exports[`CodeEditorWidget renders the AceEditor 1`] = `
.
+ */
+
+import { type EditorState } from "@/pageEditor/store/editor/pageEditorTypes";
+import { type SidebarState } from "@/types/sidebarTypes";
+import { type Draft } from "immer";
+
+function castState(state: Draft): EditorState;
+function castState(state: Draft): SidebarState;
+function castState(state: Draft): T {
+ return state as T;
+}
+
+export default castState;
diff --git a/applications/browser-extension/src/pageEditor/store/editor/editorSlice.ts b/applications/browser-extension/src/pageEditor/store/editor/editorSlice.ts
index 34f585a070..f8f6e07760 100644
--- a/applications/browser-extension/src/pageEditor/store/editor/editorSlice.ts
+++ b/applications/browser-extension/src/pageEditor/store/editor/editorSlice.ts
@@ -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 */
@@ -380,7 +381,9 @@ export const editorSlice = createSlice({
setActiveModComponentId(state, action: PayloadAction) {
const modComponentId = action.payload;
const getModComponentFormStateByModComponentId =
- selectGetModComponentFormStateByModComponentId({ editor: state });
+ selectGetModComponentFormStateByModComponentId({
+ editor: castEditorState(state),
+ });
const modComponentFormState =
getModComponentFormStateByModComponentId(modComponentId);
@@ -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);
@@ -502,7 +507,9 @@ export const editorSlice = createSlice({
markModAsCleanById(state, action: PayloadAction) {
const modId = action.payload;
const getModComponentFormStatesForMod =
- selectGetModComponentFormStatesForMod({ editor: state });
+ selectGetModComponentFormStatesForMod({
+ editor: castEditorState(state),
+ });
const modComponentFormStatesForMod =
getModComponentFormStatesForMod(modId);
@@ -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);
@@ -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);
@@ -735,7 +746,9 @@ export const editorSlice = createSlice({
);
const getModComponentFormStateByModComponentId =
- selectGetModComponentFormStateByModComponentId({ editor: state });
+ selectGetModComponentFormStateByModComponentId({
+ editor: castEditorState(state),
+ });
const modComponentFormState = getModComponentFormStateByModComponentId(
state.activeModComponentId,
);
@@ -788,7 +801,7 @@ export const editorSlice = createSlice({
) {
const { nodeId, direction } = action.payload;
const activeModComponentFormState = selectActiveModComponentFormState({
- editor: state,
+ editor: castEditorState(state),
});
assertNotNullish(
activeModComponentFormState,
@@ -796,7 +809,7 @@ export const editorSlice = createSlice({
);
const activeBrickPipelineUIState = selectActiveBrickPipelineUIState({
- editor: state,
+ editor: castEditorState(state),
});
const node = activeBrickPipelineUIState?.pipelineMap[nodeId];
assertNotNullish(node, `Node not found in pipeline map: ${nodeId}`);
@@ -831,7 +844,7 @@ export const editorSlice = createSlice({
removeNode(state, action: PayloadAction) {
const nodeIdToRemove = action.payload;
const activeModComponentFormState = selectActiveModComponentFormState({
- editor: state,
+ editor: castEditorState(state),
});
assertNotNullish(
activeModComponentFormState,
@@ -839,7 +852,7 @@ export const editorSlice = createSlice({
);
const activeBrickPipelineUIState = selectActiveBrickPipelineUIState({
- editor: state,
+ editor: castEditorState(state),
});
assertNotNullish(
activeBrickPipelineUIState,
@@ -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");
@@ -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 };
diff --git a/applications/browser-extension/src/pageEditor/store/editor/editorSliceHelpers.ts b/applications/browser-extension/src/pageEditor/store/editor/editorSliceHelpers.ts
index e7e7ec6580..eb56e0556f 100644
--- a/applications/browser-extension/src/pageEditor/store/editor/editorSliceHelpers.ts
+++ b/applications/browser-extension/src/pageEditor/store/editor/editorSliceHelpers.ts
@@ -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 */
@@ -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(
diff --git a/applications/browser-extension/src/store/sidebar/sidebarSlice.ts b/applications/browser-extension/src/store/sidebar/sidebarSlice.ts
index aedd902080..6b80c14fe6 100644
--- a/applications/browser-extension/src/store/sidebar/sidebarSlice.ts
+++ b/applications/browser-extension/src/store/sidebar/sidebarSlice.ts
@@ -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,
@@ -207,7 +208,7 @@ const sidebarSlice = createSlice({
selectTab(state, action: PayloadAction) {
// 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;
}
@@ -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) {
@@ -268,7 +272,7 @@ const sidebarSlice = createSlice({
activatePanel(state, { payload }: PayloadAction) {
state.pendingActivePanel = null;
- const visiblePanelCount = getVisiblePanelCount(state);
+ const visiblePanelCount = getVisiblePanelCount(castSidebarState(state));
const isModLauncherOnlyTabVisible =
visiblePanelCount === 1 &&
!state.closedTabs[eventKeyForEntry(MOD_LAUNCHER)];
@@ -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;
@@ -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;
@@ -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(
@@ -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) {
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) {
@@ -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) => {
@@ -398,7 +411,7 @@ const sidebarSlice = createSlice({
const { removedEntry, temporaryPanels } = action.payload;
state.temporaryPanels = castDraft(temporaryPanels);
- fixActiveTabOnRemoveInPlace(state, removedEntry);
+ fixActiveTabOnRemoveInPlace(castSidebarState(state), removedEntry);
}
})
.addCase(resolveTemporaryPanel.fulfilled, (state, action) => {
@@ -406,7 +419,7 @@ const sidebarSlice = createSlice({
const { resolvedEntry, temporaryPanels } = action.payload;
state.temporaryPanels = castDraft(temporaryPanels);
- fixActiveTabOnRemoveInPlace(state, resolvedEntry);
+ fixActiveTabOnRemoveInPlace(castSidebarState(state), resolvedEntry);
}
});
},
diff --git a/applications/browser-extension/src/utils/modUtils.ts b/applications/browser-extension/src/utils/modUtils.ts
index 49707c833e..f14f5d87c3 100644
--- a/applications/browser-extension/src/utils/modUtils.ts
+++ b/applications/browser-extension/src/utils/modUtils.ts
@@ -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 ?? {},
diff --git a/knip.mjs b/knip.mjs
index 775100e46d..410f615587 100644
--- a/knip.mjs
+++ b/knip.mjs
@@ -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
diff --git a/package-lock.json b/package-lock.json
index bf3e63cba9..d697651067 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -56,7 +56,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",
@@ -135,7 +135,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",
@@ -225,6 +225,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",
@@ -237,6 +238,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",
@@ -257,7 +259,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",
@@ -8804,11 +8806,12 @@
"dev": true
},
"node_modules/@types/react": {
- "version": "17.0.37",
- "integrity": "sha512-2FS1oTqBGcH/s0E+CjrCCR9+JMpsu9b69RTFO+40ua43ZqP5MmQ4iUde/dMjWR909KxZwmOQIFq6AV6NjEG5xg==",
+ "version": "17.0.83",
+ "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.83.tgz",
+ "integrity": "sha512-l0m4ArKJvmFtR4e8UmKrj1pB4tUgOhJITf+mADyF/p69Ts1YAR/E+G9XEM0mHXKVRa1dQNHseyyDNzeuAXfXQw==",
"dependencies": {
"@types/prop-types": "*",
- "@types/scheduler": "*",
+ "@types/scheduler": "^0.16",
"csstype": "^3.0.2"
}
},
@@ -9046,8 +9049,9 @@
"dev": true
},
"node_modules/@types/trusted-types": {
- "version": "2.0.2",
- "integrity": "sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg==",
+ "version": "2.0.7",
+ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
+ "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
"dev": true
},
"node_modules/@types/unist": {
@@ -10044,9 +10048,9 @@
}
},
"node_modules/ace-builds": {
- "version": "1.36.3",
- "resolved": "https://registry.npmjs.org/ace-builds/-/ace-builds-1.36.3.tgz",
- "integrity": "sha512-YcdwV2IIaJSfjkWAR1NEYN5IxBiXefTgwXsJ//UlaFrjXDX5hQpvPFvEePHz2ZBUfvO54RjHeRUQGX8MS5HaMQ=="
+ "version": "1.36.4",
+ "resolved": "https://registry.npmjs.org/ace-builds/-/ace-builds-1.36.4.tgz",
+ "integrity": "sha512-eE+iAsLRfNsq30yd34cezKSob6/N9mQatWs44Bp5LUDgKZ3rJtQds/YtcbnwbEWMTe7yCIxG/Cfezd4BsKIiFg=="
},
"node_modules/acorn": {
"version": "8.14.0",
@@ -14839,10 +14843,13 @@
}
},
"node_modules/eslint-plugin-playwright": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/eslint-plugin-playwright/-/eslint-plugin-playwright-2.0.0.tgz",
- "integrity": "sha512-nPa44nSp48mp/U+GSneabrhlyIyGvrcv+Z14u6sgno+jX8N0bH+ooSLEC1L6dvMDSHs7tj+kMIbls3l8gCJJSg==",
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-playwright/-/eslint-plugin-playwright-2.0.1.tgz",
+ "integrity": "sha512-f4a73xgCOK5Ug/5dtC82BVvND62lLqlMqgGkZn42teyvk6ccSyybHZXRHkpE7vKZSCjV57bnbR+3ucwItOhXlA==",
"dev": true,
+ "workspaces": [
+ "examples"
+ ],
"dependencies": {
"globals": "^13.23.0"
},
@@ -24630,9 +24637,9 @@
}
},
"node_modules/react-select": {
- "version": "5.8.2",
- "resolved": "https://registry.npmjs.org/react-select/-/react-select-5.8.2.tgz",
- "integrity": "sha512-a/LkOckoI62710gGPQSQqUp7A10fGbH/ya3/IR49qaq3XoBvwymgD5mJgtiHxBDsutyEQfdKNycWVh8Cg8UCjw==",
+ "version": "5.8.3",
+ "resolved": "https://registry.npmjs.org/react-select/-/react-select-5.8.3.tgz",
+ "integrity": "sha512-lVswnIq8/iTj1db7XCG74M/3fbGB6ZaluCzvwPGT5ZOjCdL/k0CLWhEK0vCBLuU5bHTEf6Gj8jtSvi+3v+tO1w==",
"dependencies": {
"@babel/runtime": "^7.12.0",
"@emotion/cache": "^11.4.0",