diff --git a/invokeai/frontend/web/src/features/nodes/util/graph/addRegionalPromptsToGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graph/addRegionalPromptsToGraph.ts index 263dcde55e..ebd6c5ae84 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graph/addRegionalPromptsToGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graph/addRegionalPromptsToGraph.ts @@ -11,7 +11,7 @@ import { PROMPT_REGION_POSITIVE_COND_INVERTED_PREFIX, PROMPT_REGION_POSITIVE_COND_PREFIX, } from 'features/nodes/util/graph/constants'; -import { isRegionalPromptLayer } from 'features/regionalPrompts/store/regionalPromptsSlice'; +import { isRPLayer } from 'features/regionalPrompts/store/regionalPromptsSlice'; import { getRegionalPromptLayerBlobs } from 'features/regionalPrompts/util/getLayerBlobs'; import { size } from 'lodash-es'; import { imagesApi } from 'services/api/endpoints/images'; @@ -23,7 +23,7 @@ export const addRegionalPromptsToGraph = async (state: RootState, graph: NonNull // TODO: Handle non-SDXL // const isSDXL = state.generation.model?.base === 'sdxl'; const layers = state.regionalPrompts.present.layers - .filter(isRegionalPromptLayer) // We only want the prompt region layers + .filter(isRPLayer) // We only want the prompt region layers .filter((l) => l.isVisible) // Only visible layers are rendered on the canvas .filter((l) => l.negativePrompt || l.positivePrompt); // Only layers with prompts get added to the graph diff --git a/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerAutoNegativeCombobox.tsx b/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerAutoNegativeCombobox.tsx index 161e94598f..f43e75534f 100644 --- a/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerAutoNegativeCombobox.tsx +++ b/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerAutoNegativeCombobox.tsx @@ -4,7 +4,7 @@ import { createSelector } from '@reduxjs/toolkit'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { isParameterAutoNegative } from 'features/parameters/types/parameterSchemas'; import { - isRegionalPromptLayer, + isRPLayer, rpLayerAutoNegativeChanged, selectRegionalPromptsSlice, } from 'features/regionalPrompts/store/regionalPromptsSlice'; @@ -26,7 +26,7 @@ const useAutoNegative = (layerId: string) => { () => createSelector(selectRegionalPromptsSlice, (regionalPrompts) => { const layer = regionalPrompts.present.layers.find((l) => l.id === layerId); - assert(isRegionalPromptLayer(layer), `Layer ${layerId} not found or not an RP layer`); + assert(isRPLayer(layer), `Layer ${layerId} not found or not an RP layer`); return layer.autoNegative; }), [layerId] diff --git a/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerColorPicker.tsx b/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerColorPicker.tsx index c326c407aa..27d88e50dd 100644 --- a/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerColorPicker.tsx +++ b/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerColorPicker.tsx @@ -3,7 +3,7 @@ import { createMemoizedSelector } from 'app/store/createMemoizedSelector'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import RgbColorPicker from 'common/components/RgbColorPicker'; import { - isRegionalPromptLayer, + isRPLayer, rpLayerColorChanged, selectRegionalPromptsSlice, } from 'features/regionalPrompts/store/regionalPromptsSlice'; @@ -21,7 +21,7 @@ export const RPLayerColorPicker = memo(({ layerId }: Props) => { () => createMemoizedSelector(selectRegionalPromptsSlice, (regionalPrompts) => { const layer = regionalPrompts.present.layers.find((l) => l.id === layerId); - assert(isRegionalPromptLayer(layer), `Layer ${layerId} not found or not an RP layer`); + assert(isRPLayer(layer), `Layer ${layerId} not found or not an RP layer`); return layer.color; }), [layerId] diff --git a/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerListItem.tsx b/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerListItem.tsx index b4a23e61f6..e60257959a 100644 --- a/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerListItem.tsx +++ b/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerListItem.tsx @@ -7,7 +7,7 @@ import { RPLayerMenu } from 'features/regionalPrompts/components/RPLayerMenu'; import { RPLayerNegativePrompt } from 'features/regionalPrompts/components/RPLayerNegativePrompt'; import { RPLayerPositivePrompt } from 'features/regionalPrompts/components/RPLayerPositivePrompt'; import { RPLayerVisibilityToggle } from 'features/regionalPrompts/components/RPLayerVisibilityToggle'; -import { isRegionalPromptLayer, rpLayerSelected } from 'features/regionalPrompts/store/regionalPromptsSlice'; +import { isRPLayer, rpLayerSelected } from 'features/regionalPrompts/store/regionalPromptsSlice'; import { memo, useCallback } from 'react'; import { assert } from 'tsafe'; @@ -20,7 +20,7 @@ export const RPLayerListItem = memo(({ layerId }: Props) => { const selectedLayer = useAppSelector((s) => s.regionalPrompts.present.selectedLayer); const color = useAppSelector((s) => { const layer = s.regionalPrompts.present.layers.find((l) => l.id === layerId); - assert(isRegionalPromptLayer(layer), `Layer ${layerId} not found or not an RP layer`); + assert(isRPLayer(layer), `Layer ${layerId} not found or not an RP layer`); return rgbaColorToString({ ...layer.color, a: selectedLayer === layerId ? 1 : 0.35 }); }); const onClickCapture = useCallback(() => { diff --git a/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerMenu.tsx b/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerMenu.tsx index 431e02616f..86409f0c40 100644 --- a/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerMenu.tsx +++ b/invokeai/frontend/web/src/features/regionalPrompts/components/RPLayerMenu.tsx @@ -2,7 +2,7 @@ import { IconButton, Menu, MenuButton, MenuDivider, MenuItem, MenuList } from '@ import { createMemoizedSelector } from 'app/store/createMemoizedSelector'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { - isRegionalPromptLayer, + isRPLayer, layerDeleted, layerMovedBackward, layerMovedForward, @@ -33,7 +33,7 @@ export const RPLayerMenu = memo(({ layerId }: Props) => { () => createMemoizedSelector(selectRegionalPromptsSlice, (regionalPrompts) => { const layer = regionalPrompts.present.layers.find((l) => l.id === layerId); - assert(isRegionalPromptLayer(layer), `Layer ${layerId} not found or not an RP layer`); + assert(isRPLayer(layer), `Layer ${layerId} not found or not an RP layer`); const layerIndex = regionalPrompts.present.layers.findIndex((l) => l.id === layerId); const layerCount = regionalPrompts.present.layers.length; return { diff --git a/invokeai/frontend/web/src/features/regionalPrompts/components/RegionalPromptsEditor.tsx b/invokeai/frontend/web/src/features/regionalPrompts/components/RegionalPromptsEditor.tsx index 90dec61667..5cc123c7a5 100644 --- a/invokeai/frontend/web/src/features/regionalPrompts/components/RegionalPromptsEditor.tsx +++ b/invokeai/frontend/web/src/features/regionalPrompts/components/RegionalPromptsEditor.tsx @@ -10,13 +10,13 @@ import { RPLayerListItem } from 'features/regionalPrompts/components/RPLayerList import { StageComponent } from 'features/regionalPrompts/components/StageComponent'; import { ToolChooser } from 'features/regionalPrompts/components/ToolChooser'; import { UndoRedoButtonGroup } from 'features/regionalPrompts/components/UndoRedoButtonGroup'; -import { isRegionalPromptLayer, selectRegionalPromptsSlice } from 'features/regionalPrompts/store/regionalPromptsSlice'; +import { isRPLayer, selectRegionalPromptsSlice } from 'features/regionalPrompts/store/regionalPromptsSlice'; import { getRegionalPromptLayerBlobs } from 'features/regionalPrompts/util/getLayerBlobs'; import { memo } from 'react'; const selectRPLayerIdsReversed = createMemoizedSelector(selectRegionalPromptsSlice, (regionalPrompts) => regionalPrompts.present.layers - .filter(isRegionalPromptLayer) + .filter(isRPLayer) .map((l) => l.id) .reverse() ); diff --git a/invokeai/frontend/web/src/features/regionalPrompts/components/StageComponent.tsx b/invokeai/frontend/web/src/features/regionalPrompts/components/StageComponent.tsx index 72d2a60c59..018afaea12 100644 --- a/invokeai/frontend/web/src/features/regionalPrompts/components/StageComponent.tsx +++ b/invokeai/frontend/web/src/features/regionalPrompts/components/StageComponent.tsx @@ -6,7 +6,7 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { useMouseEvents } from 'features/regionalPrompts/hooks/mouseEventHooks'; import { $cursorPosition, - isRegionalPromptLayer, + isRPLayer, rpLayerBboxChanged, rpLayerTranslated, selectRegionalPromptsSlice, @@ -25,7 +25,7 @@ const selectSelectedLayerColor = createMemoizedSelector(selectRegionalPromptsSli if (!layer) { return null; } - assert(isRegionalPromptLayer(layer), `Layer ${regionalPrompts.present.selectedLayer} is not an RP layer`); + assert(isRPLayer(layer), `Layer ${regionalPrompts.present.selectedLayer} is not an RP layer`); return layer.color; }); diff --git a/invokeai/frontend/web/src/features/regionalPrompts/hooks/layerStateHooks.ts b/invokeai/frontend/web/src/features/regionalPrompts/hooks/layerStateHooks.ts index 8e82142994..f6be11c07d 100644 --- a/invokeai/frontend/web/src/features/regionalPrompts/hooks/layerStateHooks.ts +++ b/invokeai/frontend/web/src/features/regionalPrompts/hooks/layerStateHooks.ts @@ -1,6 +1,6 @@ import { createSelector } from '@reduxjs/toolkit'; import { useAppSelector } from 'app/store/storeHooks'; -import { isRegionalPromptLayer, selectRegionalPromptsSlice } from 'features/regionalPrompts/store/regionalPromptsSlice'; +import { isRPLayer, selectRegionalPromptsSlice } from 'features/regionalPrompts/store/regionalPromptsSlice'; import { useMemo } from 'react'; import { assert } from 'tsafe'; @@ -9,7 +9,7 @@ export const useLayerPositivePrompt = (layerId: string) => { () => createSelector(selectRegionalPromptsSlice, (regionalPrompts) => { const layer = regionalPrompts.present.layers.find((l) => l.id === layerId); - assert(isRegionalPromptLayer(layer), `Layer ${layerId} not found or not an RP layer`); + assert(isRPLayer(layer), `Layer ${layerId} not found or not an RP layer`); return layer.positivePrompt; }), [layerId] @@ -23,7 +23,7 @@ export const useLayerNegativePrompt = (layerId: string) => { () => createSelector(selectRegionalPromptsSlice, (regionalPrompts) => { const layer = regionalPrompts.present.layers.find((l) => l.id === layerId); - assert(isRegionalPromptLayer(layer), `Layer ${layerId} not found or not an RP layer`); + assert(isRPLayer(layer), `Layer ${layerId} not found or not an RP layer`); return layer.negativePrompt; }), [layerId] @@ -37,7 +37,7 @@ export const useLayerIsVisible = (layerId: string) => { () => createSelector(selectRegionalPromptsSlice, (regionalPrompts) => { const layer = regionalPrompts.present.layers.find((l) => l.id === layerId); - assert(isRegionalPromptLayer(layer), `Layer ${layerId} not found or not an RP layer`); + assert(isRPLayer(layer), `Layer ${layerId} not found or not an RP layer`); return layer.isVisible; }), [layerId] diff --git a/invokeai/frontend/web/src/features/regionalPrompts/store/regionalPromptsSlice.ts b/invokeai/frontend/web/src/features/regionalPrompts/store/regionalPromptsSlice.ts index 9645a547dd..c05130f427 100644 --- a/invokeai/frontend/web/src/features/regionalPrompts/store/regionalPromptsSlice.ts +++ b/invokeai/frontend/web/src/features/regionalPrompts/store/regionalPromptsSlice.ts @@ -80,7 +80,7 @@ export const initialRegionalPromptsState: RegionalPromptsState = { }; const isLine = (obj: LayerObject): obj is LineObject => obj.kind === 'line'; -export const isRegionalPromptLayer = (layer?: Layer): layer is RegionalPromptLayer => +export const isRPLayer = (layer?: Layer): layer is RegionalPromptLayer => layer?.kind === 'regionalPromptLayer'; export const regionalPromptsSlice = createSlice({ @@ -137,19 +137,19 @@ export const regionalPromptsSlice = createSlice({ //#region RP Layers rpLayerSelected: (state, action: PayloadAction) => { const layer = state.layers.find((l) => l.id === action.payload); - if (isRegionalPromptLayer(layer)) { + if (isRPLayer(layer)) { state.selectedLayer = layer.id; } }, rpLayerIsVisibleToggled: (state, action: PayloadAction) => { const layer = state.layers.find((l) => l.id === action.payload); - if (isRegionalPromptLayer(layer)) { + if (isRPLayer(layer)) { layer.isVisible = !layer.isVisible; } }, rpLayerReset: (state, action: PayloadAction) => { const layer = state.layers.find((l) => l.id === action.payload); - if (isRegionalPromptLayer(layer)) { + if (isRPLayer(layer)) { layer.objects = []; layer.bbox = null; layer.isVisible = true; @@ -158,7 +158,7 @@ export const regionalPromptsSlice = createSlice({ rpLayerTranslated: (state, action: PayloadAction<{ layerId: string; x: number; y: number }>) => { const { layerId, x, y } = action.payload; const layer = state.layers.find((l) => l.id === layerId); - if (isRegionalPromptLayer(layer)) { + if (isRPLayer(layer)) { layer.x = x; layer.y = y; } @@ -166,7 +166,7 @@ export const regionalPromptsSlice = createSlice({ rpLayerBboxChanged: (state, action: PayloadAction<{ layerId: string; bbox: IRect | null }>) => { const { layerId, bbox } = action.payload; const layer = state.layers.find((l) => l.id === layerId); - if (isRegionalPromptLayer(layer)) { + if (isRPLayer(layer)) { layer.bbox = bbox; } }, @@ -177,28 +177,28 @@ export const regionalPromptsSlice = createSlice({ rpLayerPositivePromptChanged: (state, action: PayloadAction<{ layerId: string; prompt: string }>) => { const { layerId, prompt } = action.payload; const layer = state.layers.find((l) => l.id === layerId); - if (isRegionalPromptLayer(layer)) { + if (isRPLayer(layer)) { layer.positivePrompt = prompt; } }, rpLayerNegativePromptChanged: (state, action: PayloadAction<{ layerId: string; prompt: string }>) => { const { layerId, prompt } = action.payload; const layer = state.layers.find((l) => l.id === layerId); - if (isRegionalPromptLayer(layer)) { + if (isRPLayer(layer)) { layer.negativePrompt = prompt; } }, rpLayerColorChanged: (state, action: PayloadAction<{ layerId: string; color: RgbColor }>) => { const { layerId, color } = action.payload; const layer = state.layers.find((l) => l.id === layerId); - if (isRegionalPromptLayer(layer)) { + if (isRPLayer(layer)) { layer.color = color; } }, rpLayerLineAdded: { reducer: (state, action: PayloadAction<[number, number, number, number], string, { uuid: string }>) => { const layer = state.layers.find((l) => l.id === state.selectedLayer); - if (isRegionalPromptLayer(layer)) { + if (isRPLayer(layer)) { const lineId = getRPLayerLineId(layer.id, action.meta.uuid); layer.objects.push({ kind: 'line', @@ -218,7 +218,7 @@ export const regionalPromptsSlice = createSlice({ }, rpLayerPointsAdded: (state, action: PayloadAction<[number, number]>) => { const layer = state.layers.find((l) => l.id === state.selectedLayer); - if (isRegionalPromptLayer(layer)) { + if (isRPLayer(layer)) { const lastLine = layer.objects.findLast(isLine); if (!lastLine) { return; @@ -232,7 +232,7 @@ export const regionalPromptsSlice = createSlice({ ) => { const { layerId, autoNegative } = action.payload; const layer = state.layers.find((l) => l.id === layerId); - if (isRegionalPromptLayer(layer)) { + if (isRPLayer(layer)) { layer.autoNegative = autoNegative; } },