From 3bd6a9bebb934b5bd5707a96f6d9db8f550bd2d4 Mon Sep 17 00:00:00 2001 From: Graham Langford Date: Wed, 10 Jul 2024 10:19:18 -0500 Subject: [PATCH] Revert "#8783: update `ModComponentRef` property names (#8784)" This reverts commit e8f8e61aad17b1cf07df438582e593d3f5da67b3. --- .../DisplayTemporaryInfo.test.ts | 6 +-- src/components/quickBar/quickBarRegistry.ts | 4 +- src/contentScript/ephemeralPanel.ts | 10 ++-- .../pageEditor/runRendererBrick.ts | 8 +-- src/contentScript/sidebarController.tsx | 49 ++++++++++--------- .../tabs/effect/useDocumentPreviewRunBlock.ts | 6 +-- src/platform/forms/formController.ts | 4 +- src/platform/panels/panelController.ts | 6 +-- src/sidebar/Tabs.tsx | 6 +-- src/sidebar/TemporaryPanelTabPane.tsx | 2 +- .../modLauncher/ActiveSidebarModsList.tsx | 2 +- src/sidebar/sidebarSelectors.ts | 6 +-- .../sidebar/sidebarStarterBrick.test.ts | 2 +- .../sidebar/sidebarStarterBrick.ts | 24 ++++----- src/store/sidebar/eventKeyUtils.test.ts | 8 +-- src/store/sidebar/eventKeyUtils.tsx | 2 +- src/store/sidebar/sidebarSlice.test.ts | 28 +++++------ src/store/sidebar/sidebarSlice.ts | 29 +++++------ src/store/sidebar/thunks/addFormPanel.ts | 2 +- src/store/sidebar/thunks/addTemporaryPanel.ts | 3 +- src/telemetry/telemetryHelpers.test.ts | 12 ++--- .../factories/modComponentFactories.ts | 6 +-- src/types/modComponentTypes.ts | 6 +-- src/utils/modUtils.ts | 23 ++++----- 24 files changed, 129 insertions(+), 125 deletions(-) diff --git a/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.test.ts b/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.test.ts index dcd05c7a9e..526b7f6a11 100644 --- a/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.test.ts +++ b/src/bricks/transformers/temporaryInfo/DisplayTemporaryInfo.test.ts @@ -204,7 +204,7 @@ describe("DisplayTemporaryInfo", () => { expect(waitForTemporaryPanel).toHaveBeenCalledWith({ nonce: expect.toBeString(), - extensionId: modComponentRef.modComponentId, + extensionId: modComponentRef.extensionId, location: "modal", entry: expect.objectContaining({ modComponentRef, @@ -354,8 +354,8 @@ describe("DisplayTemporaryInfo", () => { logger: new ConsoleLogger( mapModComponentRefToMessageContext( modComponentRefFactory({ - modComponentId: extensionId, - modId: null, + extensionId, + blueprintId: null, }), ), ), diff --git a/src/components/quickBar/quickBarRegistry.ts b/src/components/quickBar/quickBarRegistry.ts index 4f59cf6dc0..3a04132ece 100644 --- a/src/components/quickBar/quickBarRegistry.ts +++ b/src/components/quickBar/quickBarRegistry.ts @@ -122,7 +122,7 @@ class QuickBarRegistry implements QuickBarProtocol { removeStarterBrickActions(starterBrickId: RegistryId): void { remove( this.actions, - (x) => x.modComponentRef?.starterBrickId === starterBrickId, + (x) => x.modComponentRef?.extensionPointId === starterBrickId, ); this.notifyListeners(); } @@ -135,7 +135,7 @@ class QuickBarRegistry implements QuickBarProtocol { remove( this.actions, (x) => - x.modComponentRef?.modComponentId === modComponentId && + x.modComponentRef?.extensionId === modComponentId && // Exclude the root action !this.knownGeneratorRootIds.has(x.id), ); diff --git a/src/contentScript/ephemeralPanel.ts b/src/contentScript/ephemeralPanel.ts index 58f84b2e00..d9947b4539 100644 --- a/src/contentScript/ephemeralPanel.ts +++ b/src/contentScript/ephemeralPanel.ts @@ -114,7 +114,7 @@ export async function ephemeralPanel({ registerEmptyTemporaryPanel({ nonce, location, - extensionId: panelEntryMetadata.modComponentRef.modComponentId, + extensionId: panelEntryMetadata.modComponentRef.extensionId, }); await showSidebar(); @@ -125,7 +125,7 @@ export async function ephemeralPanel({ nonce, payload: { key: uuidv4(), - extensionId: panelEntryMetadata.modComponentRef.modComponentId, + extensionId: panelEntryMetadata.modComponentRef.extensionId, loadingMessage: "Loading", }, }); @@ -141,14 +141,14 @@ export async function ephemeralPanel({ // Popover/modal location // Clear existing to remove stale modals/popovers await cancelTemporaryPanelsForExtension( - panelEntryMetadata.modComponentRef.modComponentId, + panelEntryMetadata.modComponentRef.extensionId, ); // Register empty panel for "loading" state registerEmptyTemporaryPanel({ nonce, location, - extensionId: panelEntryMetadata.modComponentRef.modComponentId, + extensionId: panelEntryMetadata.modComponentRef.extensionId, }); // Create a source URL for content that will be loaded in the panel iframe @@ -235,7 +235,7 @@ export async function ephemeralPanel({ nonce, location, entry, - extensionId: entry.modComponentRef.modComponentId, + extensionId: entry.modComponentRef.extensionId, onRegister: onReady, }); return panelAction ?? {}; diff --git a/src/contentScript/pageEditor/runRendererBrick.ts b/src/contentScript/pageEditor/runRendererBrick.ts index 92c6c62d4f..13522a59ac 100644 --- a/src/contentScript/pageEditor/runRendererBrick.ts +++ b/src/contentScript/pageEditor/runRendererBrick.ts @@ -63,7 +63,7 @@ export async function runRendererBrick({ let payload: PanelPayload; try { - await runBrickPreview({ ...args, modId: modComponentRef.modId }); + await runBrickPreview({ ...args, modId: modComponentRef.blueprintId }); // We're expecting a HeadlessModeError (or other error) to be thrown in the line above // noinspection ExceptionCaughtLocallyJS throw new NoRendererError(); @@ -74,14 +74,14 @@ export async function runRendererBrick({ blockId: error.blockId, args: error.args, ctxt: error.ctxt, - extensionId: modComponentRef.modComponentId, + extensionId: modComponentRef.extensionId, runId, }; } else { payload = { key: nonce, error: serializeError(error), - extensionId: modComponentRef.modComponentId, + extensionId: modComponentRef.extensionId, runId, }; } @@ -104,7 +104,7 @@ export async function runRendererBrick({ await waitForTemporaryPanel({ nonce, location, - extensionId: modComponentRef.modComponentId, + extensionId: modComponentRef.extensionId, entry: { modComponentRef, nonce, diff --git a/src/contentScript/sidebarController.tsx b/src/contentScript/sidebarController.tsx index 45d470d00d..e05d3ab8a4 100644 --- a/src/contentScript/sidebarController.tsx +++ b/src/contentScript/sidebarController.tsx @@ -372,7 +372,7 @@ export function removeModComponents(modComponentIds: UUID[]): void { const current = panels.splice(0); panels.push( ...current.filter( - (x) => !modComponentIds.includes(x.modComponentRef.modComponentId), + (x) => !modComponentIds.includes(x.modComponentRef.extensionId), ), ); void renderPanelsIfVisible(); @@ -393,7 +393,7 @@ export function removeStarterBrick( console.debug("sidebarController:removeStarterBrick %s", starterBrickId, { preserveExtensionIds, panels: panels.filter( - (x) => x.modComponentRef.starterBrickId === starterBrickId, + (x) => x.modComponentRef.extensionPointId === starterBrickId, ), }); @@ -402,8 +402,8 @@ export function removeStarterBrick( panels.push( ...current.filter( (x) => - x.modComponentRef.starterBrickId !== starterBrickId || - preserveExtensionIds.includes(x.modComponentRef.modComponentId), + x.modComponentRef.extensionPointId !== starterBrickId || + preserveExtensionIds.includes(x.modComponentRef.extensionId), ), ); @@ -418,22 +418,25 @@ export function reservePanels(refs: ModComponentRef[]): void { return; } - const current = new Set(panels.map((x) => x.modComponentRef.modComponentId)); - for (const modComponentRef of refs) { - const { modComponentId, starterBrickId, modId } = modComponentRef; - if (!current.has(modComponentId)) { + const current = new Set(panels.map((x) => x.modComponentRef.extensionId)); + for (const { extensionId, extensionPointId, blueprintId } of refs) { + if (!current.has(extensionId)) { const entry: PanelEntry = { type: "panel", - modComponentRef, + modComponentRef: { + extensionId, + extensionPointId, + blueprintId, + }, heading: "", payload: null, }; console.debug( "sidebarController:reservePanels: reserve panel %s for %s", - modComponentId, - starterBrickId, - modId, + extensionId, + extensionPointId, + blueprintId, { ...entry }, ); @@ -446,7 +449,7 @@ export function reservePanels(refs: ModComponentRef[]): void { export function updateHeading(extensionId: UUID, heading: string): void { const entry = panels.find( - (x) => x.modComponentRef.modComponentId === extensionId, + (x) => x.modComponentRef.extensionId === extensionId, ); if (entry) { @@ -454,7 +457,7 @@ export function updateHeading(extensionId: UUID, heading: string): void { console.debug( "updateHeading: update heading for panel %s for %s", extensionId, - entry.modComponentRef.starterBrickId, + entry.modComponentRef.extensionPointId, { ...entry }, ); void renderPanelsIfVisible(); @@ -471,30 +474,30 @@ export function upsertPanel( heading: string, payload: PanelPayload, ): void { - const { modComponentId, starterBrickId, modId } = modComponentRef; + const { extensionId, extensionPointId, blueprintId } = modComponentRef; const entry = panels.find( - (panel) => panel.modComponentRef.modComponentId === modComponentId, + (panel) => panel.modComponentRef.extensionId === extensionId, ); if (entry) { entry.payload = payload; entry.heading = heading; console.debug( "sidebarController:upsertPanel: update existing panel %s for %s", - modComponentId, - starterBrickId, - modId, + extensionId, + extensionPointId, + blueprintId, { ...entry }, ); } else { console.debug( "sidebarController:upsertPanel: add new panel %s for %s", - modComponentId, - starterBrickId, - modId, + extensionId, + extensionPointId, + blueprintId, { entry, - starterBrickId, + extensionPointId, heading, payload, }, diff --git a/src/pageEditor/tabs/effect/useDocumentPreviewRunBlock.ts b/src/pageEditor/tabs/effect/useDocumentPreviewRunBlock.ts index 2885e2c7e5..3716603744 100644 --- a/src/pageEditor/tabs/effect/useDocumentPreviewRunBlock.ts +++ b/src/pageEditor/tabs/effect/useDocumentPreviewRunBlock.ts @@ -206,9 +206,9 @@ export default function useDocumentPreviewRunBlock( runId: traceRecord.runId, title, modComponentRef: { - modComponentId, - modId: modMetadata?.id, - starterBrickId, + extensionId: modComponentId, + blueprintId: modMetadata?.id, + extensionPointId: starterBrickId, }, args: { apiVersion, diff --git a/src/platform/forms/formController.ts b/src/platform/forms/formController.ts index edc8222a1b..18ac85b25a 100644 --- a/src/platform/forms/formController.ts +++ b/src/platform/forms/formController.ts @@ -74,8 +74,8 @@ export async function registerForm({ const preexistingForms = [...forms.entries()].filter( ([_, registeredForm]) => - registeredForm.modComponentRef.modComponentId === - modComponentRef.modComponentId, + registeredForm.modComponentRef.extensionId === + modComponentRef.extensionId, ); if (preexistingForms.length > 0) { diff --git a/src/platform/panels/panelController.ts b/src/platform/panels/panelController.ts index 7714f81b23..e4f03df7e6 100644 --- a/src/platform/panels/panelController.ts +++ b/src/platform/panels/panelController.ts @@ -107,8 +107,8 @@ export function updatePanelDefinition( // Panel entry may be undefined if the panel was registered with registerEmptyTemporaryPanel if ( panel.entry && - panel.entry.modComponentRef.modComponentId !== - panelDefinition.modComponentRef.modComponentId + panel.entry.modComponentRef.extensionId !== + panelDefinition.modComponentRef.extensionId ) { throw new Error("extensionId mismatch"); } @@ -205,7 +205,7 @@ function removePanelEntry(panelNonce: UUID): void { const panel = panels.get(panelNonce); if (panel?.entry) { extensionNonces - .get(panel.entry.modComponentRef.modComponentId) + .get(panel.entry.modComponentRef.extensionId) ?.delete(panelNonce); } diff --git a/src/sidebar/Tabs.tsx b/src/sidebar/Tabs.tsx index bda6fcc8ec..0f1c7ec0f5 100644 --- a/src/sidebar/Tabs.tsx +++ b/src/sidebar/Tabs.tsx @@ -211,7 +211,7 @@ const Tabs: React.FC = () => { > {panels.map((panel) => ( @@ -226,7 +226,7 @@ const Tabs: React.FC = () => { {forms.map((form) => ( @@ -311,7 +311,7 @@ const Tabs: React.FC = () => { // un-submitted form state/scroll position unmountOnExit={false} className={cx("full-height flex-grow", styles.paneOverrides)} - key={panel.modComponentRef.modComponentId} + key={panel.modComponentRef.extensionId} eventKey={eventKeyForEntry(panel)} > { reportEvent(Events.VIEW_ERROR, { - ...modComponentRef, + ...mapModComponentRefToMessageContext(modComponentRef), panelType: type, }); }} diff --git a/src/sidebar/modLauncher/ActiveSidebarModsList.tsx b/src/sidebar/modLauncher/ActiveSidebarModsList.tsx index e1fa6cf778..86c1b792a6 100644 --- a/src/sidebar/modLauncher/ActiveSidebarModsList.tsx +++ b/src/sidebar/modLauncher/ActiveSidebarModsList.tsx @@ -124,7 +124,7 @@ export const ActiveSidebarModsList: React.FunctionComponent = () => { tableInstance.prepareRow(row); return ( ); diff --git a/src/sidebar/sidebarSelectors.ts b/src/sidebar/sidebarSelectors.ts index cc33375cca..4def35c70b 100644 --- a/src/sidebar/sidebarSelectors.ts +++ b/src/sidebar/sidebarSelectors.ts @@ -63,7 +63,7 @@ const selectSidebarEntries = ({ sidebar }: SidebarRootState) => [ const extensionForEventKeySelector = createSelector( selectSidebarEntries, selectActivatedModComponents, - (_state: SidebarRootState, eventKey: string) => eventKey, + (state: SidebarRootState, eventKey: string) => eventKey, (entries, extensions, eventKey): ActivatedModComponent | undefined => { // Get sidebar entry by event key const sidebarEntry = entries.find( @@ -76,7 +76,7 @@ const extensionForEventKeySelector = createSelector( return extensions.find( (modComponent) => - modComponent.id === sidebarEntry.modComponentRef.modComponentId, + modComponent.id === sidebarEntry.modComponentRef.extensionId, ); }, ); @@ -102,7 +102,7 @@ export const selectExtensionFromEventKey = return extensions.find( (modComponent) => - modComponent.id === sidebarEntry.modComponentRef.modComponentId, + modComponent.id === sidebarEntry.modComponentRef.extensionId, ); }; diff --git a/src/starterBricks/sidebar/sidebarStarterBrick.test.ts b/src/starterBricks/sidebar/sidebarStarterBrick.test.ts index 80113cf15d..b438e25be1 100644 --- a/src/starterBricks/sidebar/sidebarStarterBrick.test.ts +++ b/src/starterBricks/sidebar/sidebarStarterBrick.test.ts @@ -113,7 +113,7 @@ describe("sidebarExtension", () => { panels: [ expect.objectContaining({ modComponentRef: expect.objectContaining({ - starterBrickId: starterBrick.id, + extensionPointId: starterBrick.id, }), }), ], diff --git a/src/starterBricks/sidebar/sidebarStarterBrick.ts b/src/starterBricks/sidebar/sidebarStarterBrick.ts index 6e98275112..1fddc3ee0d 100644 --- a/src/starterBricks/sidebar/sidebarStarterBrick.ts +++ b/src/starterBricks/sidebar/sidebarStarterBrick.ts @@ -204,10 +204,10 @@ export abstract class SidebarStarterBrickABC extends StarterBrickABC ({ - modComponentId: modComponent.id, - starterBrickId: this.id, - modId: modComponent._recipe?.id, + extensionId: modComponent.id, + extensionPointId: this.id, + blueprintId: modComponent._recipe?.id, })), ); @@ -411,9 +411,9 @@ export abstract class SidebarStarterBrickABC extends StarterBrickABC ({ - modComponentId: components.id, - starterBrickId: this.id, - modId: components._recipe?.id, + extensionId: components.id, + extensionPointId: this.id, + blueprintId: components._recipe?.id, })), ); diff --git a/src/store/sidebar/eventKeyUtils.test.ts b/src/store/sidebar/eventKeyUtils.test.ts index 557217bb71..2141492539 100644 --- a/src/store/sidebar/eventKeyUtils.test.ts +++ b/src/store/sidebar/eventKeyUtils.test.ts @@ -162,8 +162,8 @@ describe("eventKeyForEntry", () => { const extensionPointId = validateRegistryId("@test/test-starter-brick"); const entry = sidebarEntryFactory("panel", { modComponentRef: modComponentRefFactory({ - modComponentId: extensionId, - starterBrickId: extensionPointId, + extensionId, + extensionPointId, }), }); expect(eventKeyForEntry(entry)).toBe(`panel-${extensionId}`); @@ -176,14 +176,14 @@ describe("eventKeyForEntry", () => { const formEntry = sidebarEntryFactory("form", { nonce, modComponentRef: modComponentRefFactory({ - modComponentId: extensionId, + extensionId, }), }); expect(eventKeyForEntry(formEntry)).toBe(`form-${nonce}`); const temporaryPanelEntry = sidebarEntryFactory("temporaryPanel", { nonce, - modComponentRef: modComponentRefFactory({ modComponentId: extensionId }), + modComponentRef: modComponentRefFactory({ extensionId }), }); expect(eventKeyForEntry(temporaryPanelEntry)).toBe( `temporaryPanel-${nonce}`, diff --git a/src/store/sidebar/eventKeyUtils.tsx b/src/store/sidebar/eventKeyUtils.tsx index 63cff133eb..93f5f9c976 100644 --- a/src/store/sidebar/eventKeyUtils.tsx +++ b/src/store/sidebar/eventKeyUtils.tsx @@ -44,7 +44,7 @@ function eventKeyForEntry(entry: Nullishable): string | null { } if (isPanelEntry(entry)) { - return getEventKeyForPanel(entry.modComponentRef.modComponentId); + return getEventKeyForPanel(entry.modComponentRef.extensionId); } if (isStaticPanelEntry(entry)) { diff --git a/src/store/sidebar/sidebarSlice.test.ts b/src/store/sidebar/sidebarSlice.test.ts index fa74d55a00..820e35382d 100644 --- a/src/store/sidebar/sidebarSlice.test.ts +++ b/src/store/sidebar/sidebarSlice.test.ts @@ -103,7 +103,7 @@ describe("sidebarSlice.addTemporaryPanel", () => { const otherExistingPanel = sidebarEntryFactory("temporaryPanel"); const newPanel = sidebarEntryFactory("temporaryPanel", { modComponentRef: modComponentRefFactory({ - modComponentId: existingPanel.modComponentRef.modComponentId, + extensionId: existingPanel.modComponentRef.extensionId, }), }); @@ -198,7 +198,7 @@ describe("removeTemporaryPanel", () => { const otherExistingPanel = sidebarEntryFactory("form"); const newPanel = sidebarEntryFactory("temporaryPanel", { modComponentRef: modComponentRefFactory({ - modComponentId: originalPanel.modComponentRef.modComponentId, + extensionId: originalPanel.modComponentRef.extensionId, }), }); @@ -533,18 +533,18 @@ describe("sidebarSlice.fixActiveTabOnRemove", () => { const modId = validateRegistryId("test/123"); const originalPanel = sidebarEntryFactory("panel", { modComponentRef: modComponentRefFactory({ - modId, + blueprintId: modId, }), }); const otherExistingPanel = sidebarEntryFactory("form", { modComponentRef: modComponentRefFactory({ - modId, + blueprintId: modId, }), }); const newPanel = sidebarEntryFactory("temporaryPanel", { modComponentRef: modComponentRefFactory({ - modComponentId: originalPanel.modComponentRef.modComponentId, - modId, + extensionId: originalPanel.modComponentRef.extensionId, + blueprintId: modId, }), }); @@ -572,12 +572,12 @@ describe("sidebarSlice.fixActiveTabOnRemove", () => { const firstPanel = sidebarEntryFactory("panel"); const matchingPanel = sidebarEntryFactory("panel", { modComponentRef: modComponentRefFactory({ - modId, + blueprintId: modId, }), }); const newPanel = sidebarEntryFactory("temporaryPanel", { modComponentRef: modComponentRefFactory({ - modId, + blueprintId: modId, }), }); @@ -601,24 +601,24 @@ describe("sidebarSlice.fixActiveTabOnRemove", () => { const originalPanel = sidebarEntryFactory("panel", { modComponentRef: modComponentRefFactory({ - modComponentId: extensionId, + extensionId, }), }); const firstFormPanel = sidebarEntryFactory("form", { modComponentRef: modComponentRefFactory({ - modComponentId: extensionId, + extensionId, }), }); const nullModId = sidebarEntryFactory("form", { modComponentRef: modComponentRefFactory({ - modComponentId: extensionId, - modId: null, + extensionId, + blueprintId: null, }), }); const newPanel = sidebarEntryFactory("temporaryPanel", { modComponentRef: modComponentRefFactory({ - modComponentId: extensionId, - modId: null, + extensionId, + blueprintId: null, }), }); diff --git a/src/store/sidebar/sidebarSlice.ts b/src/store/sidebar/sidebarSlice.ts index 2c612b97c0..f0d97c4879 100644 --- a/src/store/sidebar/sidebarSlice.ts +++ b/src/store/sidebar/sidebarSlice.ts @@ -72,21 +72,21 @@ function findNextActiveKey( if (extensionId) { // Prefer form to panel -- however, it would be unusual to target an ephemeral form when reshowing the sidebar const extensionForm = state.forms.find( - (x) => x.modComponentRef.modComponentId === extensionId, + (x) => x.modComponentRef.extensionId === extensionId, ); if (extensionForm) { return eventKeyForEntry(extensionForm); } const extensionTemporaryPanel = state.temporaryPanels.find( - (x) => x.modComponentRef.modComponentId === extensionId, + (x) => x.modComponentRef.extensionId === extensionId, ); if (extensionTemporaryPanel) { return eventKeyForEntry(extensionTemporaryPanel); } const extensionPanel = state.panels.find( - (x) => x.modComponentRef.modComponentId === extensionId, + (x) => x.modComponentRef.extensionId === extensionId, ); if (extensionPanel) { return eventKeyForEntry(extensionPanel); @@ -97,7 +97,8 @@ function findNextActiveKey( if (panelHeading) { const extensionPanel = state.panels .filter( - (x) => blueprintId == null || x.modComponentRef.modId === blueprintId, + (x) => + blueprintId == null || x.modComponentRef.blueprintId === blueprintId, ) .find((x) => x.heading === panelHeading); if (extensionPanel) { @@ -108,7 +109,7 @@ function findNextActiveKey( // Try matching on blueprint if (blueprintId) { const blueprintPanel = state.panels.find( - (x) => x.modComponentRef.modId === blueprintId, + (x) => x.modComponentRef.blueprintId === blueprintId, ); if (blueprintPanel) { return eventKeyForEntry(blueprintPanel); @@ -135,9 +136,9 @@ export function fixActiveTabOnRemoveInPlace( const panels = [...state.forms, ...state.panels, ...state.temporaryPanels]; const matchingExtension = panels.find( - ({ modComponentRef: { modComponentId } }) => + ({ modComponentRef: { extensionId } }) => "modComponentRef" in removedEntry && - modComponentId === removedEntry.modComponentRef.modComponentId, + extensionId === removedEntry.modComponentRef.extensionId, ); if (matchingExtension) { @@ -146,11 +147,11 @@ export function fixActiveTabOnRemoveInPlace( // No mod component match, try finding another panel for the mod const matchingMod = panels.find( - ({ modComponentRef: { modId } }) => + ({ modComponentRef: { blueprintId } }) => "modComponentRef" in removedEntry && - modId === removedEntry.modComponentRef.modId && - // Require modId to avoid switching between panels of standalone mod components - modId, + blueprintId === removedEntry.modComponentRef.blueprintId && + // Require blueprintId to avoid switching between panels of standalone mod components + blueprintId, ); if (matchingMod) { @@ -305,15 +306,15 @@ const sidebarSlice = createSlice({ (oldPanel.isUnavailable || oldPanel.isConnecting) && !action.payload.panels.some( (newPanel) => - newPanel.modComponentRef.modComponentId === - oldPanel.modComponentRef.modComponentId, + newPanel.modComponentRef.extensionId === + oldPanel.modComponentRef.extensionId, ), ); // For now, pick an arbitrary order that's stable. There's no guarantees on which order panels are registered state.panels = sortBy( [...oldPanels, ...castDraft(action.payload.panels)], - (panel) => panel.modComponentRef.modComponentId, + (panel) => panel.modComponentRef.extensionId, ); // Try fulfilling the pendingActivePanel request diff --git a/src/store/sidebar/thunks/addFormPanel.ts b/src/store/sidebar/thunks/addFormPanel.ts index 474bca498d..f9b744a452 100644 --- a/src/store/sidebar/thunks/addFormPanel.ts +++ b/src/store/sidebar/thunks/addFormPanel.ts @@ -44,7 +44,7 @@ const addFormPanel = createAsyncThunk< const [thisModComponentForms, otherForms] = partition( forms, ({ modComponentRef }) => - modComponentRef.modComponentId === form.modComponentRef.modComponentId, + modComponentRef.extensionId === form.modComponentRef.extensionId, ); // The UUID must be fetched synchronously to ensure the `form` Proxy element doesn't expire diff --git a/src/store/sidebar/thunks/addTemporaryPanel.ts b/src/store/sidebar/thunks/addTemporaryPanel.ts index 747c44b154..92807a71f7 100644 --- a/src/store/sidebar/thunks/addTemporaryPanel.ts +++ b/src/store/sidebar/thunks/addTemporaryPanel.ts @@ -40,8 +40,7 @@ const addTemporaryPanel = createAsyncThunk< const [existingExtensionTemporaryPanels, otherTemporaryPanels] = partition( temporaryPanels, - (x) => - x.modComponentRef.modComponentId === panel.modComponentRef.modComponentId, + (x) => x.modComponentRef.extensionId === panel.modComponentRef.extensionId, ); // Cancel all panels for the extension, except if there's a placeholder that was added in setInitialPanels diff --git a/src/telemetry/telemetryHelpers.test.ts b/src/telemetry/telemetryHelpers.test.ts index 883125ff59..50a3c3a829 100644 --- a/src/telemetry/telemetryHelpers.test.ts +++ b/src/telemetry/telemetryHelpers.test.ts @@ -45,20 +45,20 @@ describe("mapModComponentRefToEventData", () => { it("maps fields", () => { const value = modComponentRefFactory(); expect(mapModComponentRefToMessageContext(value)).toStrictEqual({ - modComponentId: value.modComponentId, - modId: value.modId, - starterBrickId: value.starterBrickId, + modComponentId: value.extensionId, + modId: value.blueprintId, + starterBrickId: value.extensionPointId, }); }); it("replaces null with undefined", () => { const value = modComponentRefFactory({ - modId: null, + blueprintId: null, }); expect(mapModComponentRefToMessageContext(value)).toStrictEqual({ - modComponentId: value.modComponentId, + modComponentId: value.extensionId, modId: undefined, - starterBrickId: value.starterBrickId, + starterBrickId: value.extensionPointId, }); }); diff --git a/src/testUtils/factories/modComponentFactories.ts b/src/testUtils/factories/modComponentFactories.ts index e62a550817..d8ece2f8c0 100644 --- a/src/testUtils/factories/modComponentFactories.ts +++ b/src/testUtils/factories/modComponentFactories.ts @@ -36,9 +36,9 @@ import { type StandaloneModDefinition } from "@/types/contract"; import { type Metadata, DefinitionKinds } from "@/types/registryTypes"; export const modComponentRefFactory = define({ - modComponentId: uuidSequence, - modId: registryIdFactory, - starterBrickId: registryIdFactory, + extensionId: uuidSequence, + blueprintId: registryIdFactory, + extensionPointId: registryIdFactory, }); export const modMetadataFactory = extend( diff --git a/src/types/modComponentTypes.ts b/src/types/modComponentTypes.ts index b0db64e90f..74bebb3ec9 100644 --- a/src/types/modComponentTypes.ts +++ b/src/types/modComponentTypes.ts @@ -285,15 +285,15 @@ export type ModComponentRef = { /** * UUID of the ModComponent. */ - modComponentId: UUID; + extensionId: UUID; /** * Mod the ModComponent is from, or nullish for a standalone ModComponent. */ - modId: Nullishable; + blueprintId: Nullishable; /** * Registry id of the mod component's StarterBrick. */ - starterBrickId: RegistryId; + extensionPointId: RegistryId; }; diff --git a/src/utils/modUtils.ts b/src/utils/modUtils.ts index 66a253a7aa..1c990234df 100644 --- a/src/utils/modUtils.ts +++ b/src/utils/modUtils.ts @@ -66,9 +66,9 @@ export function getModComponentRef( modComponent: HydratedModComponent, ): ModComponentRef { return { - modComponentId: modComponent.id, - modId: modComponent._recipe?.id, - starterBrickId: modComponent.extensionPointId, + extensionId: modComponent.id, + blueprintId: modComponent._recipe?.id, + extensionPointId: modComponent.extensionPointId, }; } @@ -94,16 +94,18 @@ export function mapModComponentToMessageContext( /** * Returns the message context for a ModComponentRef. For use with passing to reportEvent * @see selectEventData + * + * TODO: Once we update the shape of ModComponentRef, we need to audit unnecessary usage of this function */ export function mapModComponentRefToMessageContext( modComponentRef: ModComponentRef, ): SetRequired { // Fields are currently named the same. In the future, the fields might temporarily diverge. return { - modComponentId: modComponentRef.modComponentId, - starterBrickId: modComponentRef.starterBrickId, + modComponentId: modComponentRef.extensionId, + starterBrickId: modComponentRef.extensionPointId, // MessageContext expects undefined instead of null/undefined - modId: modComponentRef.modId ?? undefined, + modId: modComponentRef.blueprintId ?? undefined, }; } @@ -113,7 +115,7 @@ export function mapModComponentRefToMessageContext( * * @see getModComponentRef * @see mapModComponentToMessageContext - * @throws TypeError if the modComponentId or starterBrickId is missing + * @throws TypeError if the extensionId or extensionPointId is missing */ export function mapMessageContextToModComponentRef( context: MessageContext, @@ -127,11 +129,10 @@ export function mapMessageContextToModComponentRef( "starterBrickId is required for ModComponentRef", ); - // Can't use "pick" because it doesn't pick up assertNotNullish checks above return { - modComponentId: context.modComponentId, - modId: context.modId, - starterBrickId: context.starterBrickId, + extensionId: context.modComponentId, + blueprintId: context.modId, + extensionPointId: context.starterBrickId, }; }