tidy(ui): clean up unused code 4

variables, types and schemas
This commit is contained in:
psychedelicious 2024-02-27 17:46:13 +11:00
parent dc64089c9d
commit b661d93bd8
26 changed files with 72 additions and 217 deletions

View File

@ -4,16 +4,9 @@ const config: KnipConfig = {
ignore: [ ignore: [
// This file is only used during debugging // This file is only used during debugging
'src/app/store/middleware/debugLoggerMiddleware.ts', 'src/app/store/middleware/debugLoggerMiddleware.ts',
// These are old schemas, used in migrations. Needs cleanup.
'src/features/nodes/types/v2/**/*',
'src/features/nodes/types/v1/**/*',
// We don't want to check the public folder - contains images and translations
'public/**/*',
], ],
compilers: { ignoreDependencies: ['@storybook/addon-docs', '@storybook/blocks', '@storybook/test', 'public/.*'],
// ignoreBinaries: ['only-allow'],
svg: () => '',
},
}; };
export default config; export default config;

View File

@ -3,7 +3,7 @@ import { parseify } from 'common/util/serialize';
import { PersistError, RehydrateError } from 'redux-remember'; import { PersistError, RehydrateError } from 'redux-remember';
import { serializeError } from 'serialize-error'; import { serializeError } from 'serialize-error';
export type StorageErrorArgs = { type StorageErrorArgs = {
key: string; key: string;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */ // any is correct /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ // any is correct
value?: any; value?: any;

View File

@ -1,4 +1,4 @@
import type { ListenerEffect, TypedStartListening, UnknownAction } from '@reduxjs/toolkit'; import type { TypedStartListening } from '@reduxjs/toolkit';
import { createListenerMiddleware } from '@reduxjs/toolkit'; import { createListenerMiddleware } from '@reduxjs/toolkit';
import { addBulkDownloadListeners } from 'app/store/middleware/listenerMiddleware/listeners/bulkDownload'; import { addBulkDownloadListeners } from 'app/store/middleware/listenerMiddleware/listeners/bulkDownload';
import { addGalleryImageClickedListener } from 'app/store/middleware/listenerMiddleware/listeners/galleryImageClicked'; import { addGalleryImageClickedListener } from 'app/store/middleware/listenerMiddleware/listeners/galleryImageClicked';
@ -70,12 +70,10 @@ import { addWorkflowLoadRequestedListener } from './listeners/workflowLoadReques
export const listenerMiddleware = createListenerMiddleware(); export const listenerMiddleware = createListenerMiddleware();
export type AppStartListening = TypedStartListening<RootState, AppDispatch>; type AppStartListening = TypedStartListening<RootState, AppDispatch>;
export const startAppListening = listenerMiddleware.startListening as AppStartListening; export const startAppListening = listenerMiddleware.startListening as AppStartListening;
export type AppListenerEffect = ListenerEffect<UnknownAction, RootState, AppDispatch>;
/** /**
* The RTK listener middleware is a lightweight alternative sagas/observables. * The RTK listener middleware is a lightweight alternative sagas/observables.
* *

View File

@ -185,7 +185,6 @@ export const createStore = (uniqueStoreKey?: string, persist = true) =>
}, },
}); });
export type AppGetState = ReturnType<ReturnType<typeof createStore>['getState']>;
export type RootState = ReturnType<ReturnType<typeof createStore>['getState']>; export type RootState = ReturnType<ReturnType<typeof createStore>['getState']>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
export type AppThunkDispatch = ThunkDispatch<RootState, any, UnknownAction>; export type AppThunkDispatch = ThunkDispatch<RootState, any, UnknownAction>;

View File

@ -1,7 +1,7 @@
// https://stackoverflow.com/a/73731908 // https://stackoverflow.com/a/73731908
import { useCallback, useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
export type UseSingleAndDoubleClickOptions = { type UseSingleAndDoubleClickOptions = {
onSingleClick: () => void; onSingleClick: () => void;
onDoubleClick: () => void; onDoubleClick: () => void;
latency?: number; latency?: number;

View File

@ -1,7 +1,5 @@
export type JSONValue = string | number | boolean | null | JSONValue[] | { [key: string]: JSONValue }; type JSONValue = string | number | boolean | null | JSONValue[] | { [key: string]: JSONValue };
export interface JSONObject { export interface JSONObject {
[k: string]: JSONValue; [k: string]: JSONValue;
} }
export interface JSONArray extends Array<JSONValue> {}

View File

@ -1,7 +1,7 @@
import { NUMPY_RAND_MAX, NUMPY_RAND_MIN } from 'app/constants'; import { NUMPY_RAND_MAX, NUMPY_RAND_MIN } from 'app/constants';
import { random } from 'lodash-es'; import { random } from 'lodash-es';
export type GenerateSeedsArg = { type GenerateSeedsArg = {
count: number; count: number;
start?: number; start?: number;
min?: number; min?: number;

View File

@ -15,7 +15,7 @@ export type BoundingBoxScaleMethod = z.infer<typeof zBoundingBoxScaleMethod>;
export const isBoundingBoxScaleMethod = (v: unknown): v is BoundingBoxScaleMethod => export const isBoundingBoxScaleMethod = (v: unknown): v is BoundingBoxScaleMethod =>
zBoundingBoxScaleMethod.safeParse(v).success; zBoundingBoxScaleMethod.safeParse(v).success;
export type CanvasDrawingTool = 'brush' | 'eraser'; type CanvasDrawingTool = 'brush' | 'eraser';
export type CanvasTool = CanvasDrawingTool | 'move' | 'colorPicker'; export type CanvasTool = CanvasDrawingTool | 'move' | 'colorPicker';
@ -53,7 +53,7 @@ export type CanvasBaseLine = {
clip?: IRect; clip?: IRect;
}; };
export type CanvasFillRect = { type CanvasFillRect = {
kind: 'fillRect'; kind: 'fillRect';
layer: 'base'; layer: 'base';
x: number; x: number;
@ -63,7 +63,7 @@ export type CanvasFillRect = {
color: RgbaColor; color: RgbaColor;
}; };
export type CanvasEraseRect = { type CanvasEraseRect = {
kind: 'eraseRect'; kind: 'eraseRect';
layer: 'base'; layer: 'base';
x: number; x: number;
@ -72,7 +72,7 @@ export type CanvasEraseRect = {
height: number; height: number;
}; };
export type CanvasObject = CanvasImage | CanvasBaseLine | CanvasMaskLine | CanvasFillRect | CanvasEraseRect; type CanvasObject = CanvasImage | CanvasBaseLine | CanvasMaskLine | CanvasFillRect | CanvasEraseRect;
export type CanvasLayerState = { export type CanvasLayerState = {
objects: CanvasObject[]; objects: CanvasObject[];
@ -83,11 +83,6 @@ export type CanvasLayerState = {
}; };
}; };
export type CanvasSession = {
sessionId: string;
boundingBox: IRect;
};
// type guards // type guards
export const isCanvasMaskLine = (obj: CanvasObject): obj is CanvasMaskLine => export const isCanvasMaskLine = (obj: CanvasObject): obj is CanvasMaskLine =>
obj.kind === 'line' && obj.layer === 'mask'; obj.kind === 'line' && obj.layer === 'mask';

View File

@ -17,7 +17,7 @@ import NormalBaeProcessor from './processors/NormalBaeProcessor';
import PidiProcessor from './processors/PidiProcessor'; import PidiProcessor from './processors/PidiProcessor';
import ZoeDepthProcessor from './processors/ZoeDepthProcessor'; import ZoeDepthProcessor from './processors/ZoeDepthProcessor';
export type Props = { type Props = {
id: string; id: string;
}; };

View File

@ -1,6 +1,6 @@
import type { PayloadAction } from '@reduxjs/toolkit'; import type { PayloadAction } from '@reduxjs/toolkit';
import { createSlice } from '@reduxjs/toolkit'; import { createSlice } from '@reduxjs/toolkit';
import type { PersistConfig, RootState } from 'app/store/store'; import type { PersistConfig } from 'app/store/store';
type ModelManagerState = { type ModelManagerState = {
_version: 1; _version: 1;
@ -42,8 +42,6 @@ export const modelManagerV2Slice = createSlice({
export const { setSelectedModelKey, setSearchTerm, setFilteredModelType, setSelectedModelMode } = export const { setSelectedModelKey, setSearchTerm, setFilteredModelType, setSelectedModelMode } =
modelManagerV2Slice.actions; modelManagerV2Slice.actions;
export const selectModelManagerSlice = (state: RootState) => state.modelmanagerV2;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
const migrateModelManagerState = (state: any): any => { const migrateModelManagerState = (state: any): any => {
if (!('_version' in state)) { if (!('_version' in state)) {

View File

@ -3,7 +3,7 @@ import { createSlice } from '@reduxjs/toolkit';
import type { PersistConfig, RootState } from 'app/store/store'; import type { PersistConfig, RootState } from 'app/store/store';
import { z } from 'zod'; import { z } from 'zod';
export const zParamESRGANModelName = z.enum([ const zParamESRGANModelName = z.enum([
'RealESRGAN_x4plus.pth', 'RealESRGAN_x4plus.pth',
'RealESRGAN_x4plus_anime_6B.pth', 'RealESRGAN_x4plus_anime_6B.pth',
'ESRGAN_SRx4_DF2KOST_official-ff704c30.pth', 'ESRGAN_SRx4_DF2KOST_official-ff704c30.pth',
@ -18,7 +18,7 @@ export interface PostprocessingState {
esrganModelName: ParamESRGANModelName; esrganModelName: ParamESRGANModelName;
} }
export const initialPostprocessingState: PostprocessingState = { const initialPostprocessingState: PostprocessingState = {
_version: 1, _version: 1,
esrganModelName: 'RealESRGAN_x4plus.pth', esrganModelName: 'RealESRGAN_x4plus.pth',
}; };
@ -38,7 +38,7 @@ export const { esrganModelNameChanged } = postprocessingSlice.actions;
export const selectPostprocessingSlice = (state: RootState) => state.postprocessing; export const selectPostprocessingSlice = (state: RootState) => state.postprocessing;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
export const migratePostprocessingState = (state: any): any => { const migratePostprocessingState = (state: any): any => {
if (!('_version' in state)) { if (!('_version' in state)) {
state._version = 1; state._version = 1;
} }

View File

@ -16,68 +16,68 @@ import { z } from 'zod';
*/ */
// #region Positive prompt // #region Positive prompt
export const zParameterPositivePrompt = z.string(); const zParameterPositivePrompt = z.string();
export type ParameterPositivePrompt = z.infer<typeof zParameterPositivePrompt>; export type ParameterPositivePrompt = z.infer<typeof zParameterPositivePrompt>;
export const isParameterPositivePrompt = (val: unknown): val is ParameterPositivePrompt => export const isParameterPositivePrompt = (val: unknown): val is ParameterPositivePrompt =>
zParameterPositivePrompt.safeParse(val).success; zParameterPositivePrompt.safeParse(val).success;
// #endregion // #endregion
// #region Negative prompt // #region Negative prompt
export const zParameterNegativePrompt = z.string(); const zParameterNegativePrompt = z.string();
export type ParameterNegativePrompt = z.infer<typeof zParameterNegativePrompt>; export type ParameterNegativePrompt = z.infer<typeof zParameterNegativePrompt>;
export const isParameterNegativePrompt = (val: unknown): val is ParameterNegativePrompt => export const isParameterNegativePrompt = (val: unknown): val is ParameterNegativePrompt =>
zParameterNegativePrompt.safeParse(val).success; zParameterNegativePrompt.safeParse(val).success;
// #endregion // #endregion
// #region Positive style prompt (SDXL) // #region Positive style prompt (SDXL)
export const zParameterPositiveStylePromptSDXL = z.string(); const zParameterPositiveStylePromptSDXL = z.string();
export type ParameterPositiveStylePromptSDXL = z.infer<typeof zParameterPositiveStylePromptSDXL>; export type ParameterPositiveStylePromptSDXL = z.infer<typeof zParameterPositiveStylePromptSDXL>;
export const isParameterPositiveStylePromptSDXL = (val: unknown): val is ParameterPositiveStylePromptSDXL => export const isParameterPositiveStylePromptSDXL = (val: unknown): val is ParameterPositiveStylePromptSDXL =>
zParameterPositiveStylePromptSDXL.safeParse(val).success; zParameterPositiveStylePromptSDXL.safeParse(val).success;
// #endregion // #endregion
// #region Positive style prompt (SDXL) // #region Positive style prompt (SDXL)
export const zParameterNegativeStylePromptSDXL = z.string(); const zParameterNegativeStylePromptSDXL = z.string();
export type ParameterNegativeStylePromptSDXL = z.infer<typeof zParameterNegativeStylePromptSDXL>; export type ParameterNegativeStylePromptSDXL = z.infer<typeof zParameterNegativeStylePromptSDXL>;
export const isParameterNegativeStylePromptSDXL = (val: unknown): val is ParameterNegativeStylePromptSDXL => export const isParameterNegativeStylePromptSDXL = (val: unknown): val is ParameterNegativeStylePromptSDXL =>
zParameterNegativeStylePromptSDXL.safeParse(val).success; zParameterNegativeStylePromptSDXL.safeParse(val).success;
// #endregion // #endregion
// #region Steps // #region Steps
export const zParameterSteps = z.number().int().min(1); const zParameterSteps = z.number().int().min(1);
export type ParameterSteps = z.infer<typeof zParameterSteps>; export type ParameterSteps = z.infer<typeof zParameterSteps>;
export const isParameterSteps = (val: unknown): val is ParameterSteps => zParameterSteps.safeParse(val).success; export const isParameterSteps = (val: unknown): val is ParameterSteps => zParameterSteps.safeParse(val).success;
// #endregion // #endregion
// #region CFG scale parameter // #region CFG scale parameter
export const zParameterCFGScale = z.number().min(1); const zParameterCFGScale = z.number().min(1);
export type ParameterCFGScale = z.infer<typeof zParameterCFGScale>; export type ParameterCFGScale = z.infer<typeof zParameterCFGScale>;
export const isParameterCFGScale = (val: unknown): val is ParameterCFGScale => export const isParameterCFGScale = (val: unknown): val is ParameterCFGScale =>
zParameterCFGScale.safeParse(val).success; zParameterCFGScale.safeParse(val).success;
// #endregion // #endregion
// #region CFG Rescale Multiplier // #region CFG Rescale Multiplier
export const zParameterCFGRescaleMultiplier = z.number().gte(0).lt(1); const zParameterCFGRescaleMultiplier = z.number().gte(0).lt(1);
export type ParameterCFGRescaleMultiplier = z.infer<typeof zParameterCFGRescaleMultiplier>; export type ParameterCFGRescaleMultiplier = z.infer<typeof zParameterCFGRescaleMultiplier>;
export const isParameterCFGRescaleMultiplier = (val: unknown): val is ParameterCFGRescaleMultiplier => export const isParameterCFGRescaleMultiplier = (val: unknown): val is ParameterCFGRescaleMultiplier =>
zParameterCFGRescaleMultiplier.safeParse(val).success; zParameterCFGRescaleMultiplier.safeParse(val).success;
// #endregion // #endregion
// #region Scheduler // #region Scheduler
export const zParameterScheduler = zSchedulerField; const zParameterScheduler = zSchedulerField;
export type ParameterScheduler = z.infer<typeof zParameterScheduler>; export type ParameterScheduler = z.infer<typeof zParameterScheduler>;
export const isParameterScheduler = (val: unknown): val is ParameterScheduler => export const isParameterScheduler = (val: unknown): val is ParameterScheduler =>
zParameterScheduler.safeParse(val).success; zParameterScheduler.safeParse(val).success;
// #endregion // #endregion
// #region seed // #region seed
export const zParameterSeed = z.number().int().min(0).max(NUMPY_RAND_MAX); const zParameterSeed = z.number().int().min(0).max(NUMPY_RAND_MAX);
export type ParameterSeed = z.infer<typeof zParameterSeed>; export type ParameterSeed = z.infer<typeof zParameterSeed>;
export const isParameterSeed = (val: unknown): val is ParameterSeed => zParameterSeed.safeParse(val).success; export const isParameterSeed = (val: unknown): val is ParameterSeed => zParameterSeed.safeParse(val).success;
// #endregion // #endregion
// #region Width // #region Width
export const zParameterWidth = z const zParameterWidth = z
.number() .number()
.min(64) .min(64)
.transform((val) => roundToMultiple(val, 8)); .transform((val) => roundToMultiple(val, 8));
@ -86,96 +86,81 @@ export const isParameterWidth = (val: unknown): val is ParameterWidth => zParame
// #endregion // #endregion
// #region Height // #region Height
export const zParameterHeight = zParameterWidth; const zParameterHeight = zParameterWidth;
export type ParameterHeight = z.infer<typeof zParameterHeight>; export type ParameterHeight = z.infer<typeof zParameterHeight>;
export const isParameterHeight = (val: unknown): val is ParameterHeight => zParameterHeight.safeParse(val).success; export const isParameterHeight = (val: unknown): val is ParameterHeight => zParameterHeight.safeParse(val).success;
// #endregion // #endregion
// #region Aspect Ratio // #region Aspect Ratio
export const zParameterAspectRatio = z.number().int().min(0).max(6); const zParameterAspectRatio = z.number().int().min(0).max(6);
export type ParameterAspectRatio = z.infer<typeof zParameterAspectRatio>; export type ParameterAspectRatio = z.infer<typeof zParameterAspectRatio>;
export const isParameterAspectRatio = (val: unknown): val is ParameterAspectRatio =>
zParameterAspectRatio.safeParse(val).success;
// #endregion // #endregion
// #region Model // #region Model
export const zParameterModel = zModelIdentifierWithBase; export const zParameterModel = zModelIdentifierWithBase;
export type ParameterModel = z.infer<typeof zParameterModel>; export type ParameterModel = z.infer<typeof zParameterModel>;
export const isParameterModel = (val: unknown): val is ParameterModel => zParameterModel.safeParse(val).success;
// #endregion // #endregion
// #region SDXL Refiner Model // #region SDXL Refiner Model
export const zParameterSDXLRefinerModel = zModelIdentifierWithBase; const zParameterSDXLRefinerModel = zModelIdentifierWithBase;
export type ParameterSDXLRefinerModel = z.infer<typeof zParameterSDXLRefinerModel>; export type ParameterSDXLRefinerModel = z.infer<typeof zParameterSDXLRefinerModel>;
export const isParameterSDXLRefinerModel = (val: unknown): val is ParameterSDXLRefinerModel =>
zParameterSDXLRefinerModel.safeParse(val).success;
// #endregion // #endregion
// #region VAE Model // #region VAE Model
export const zParameterVAEModel = zModelIdentifierWithBase; export const zParameterVAEModel = zModelIdentifierWithBase;
export type ParameterVAEModel = z.infer<typeof zParameterVAEModel>; export type ParameterVAEModel = z.infer<typeof zParameterVAEModel>;
export const isParameterVAEModel = (val: unknown): val is ParameterVAEModel =>
zParameterVAEModel.safeParse(val).success;
// #endregion // #endregion
// #region LoRA Model // #region LoRA Model
export const zParameterLoRAModel = zModelIdentifierWithBase; const zParameterLoRAModel = zModelIdentifierWithBase;
export type ParameterLoRAModel = z.infer<typeof zParameterLoRAModel>; export type ParameterLoRAModel = z.infer<typeof zParameterLoRAModel>;
export const isParameterLoRAModel = (val: unknown): val is ParameterLoRAModel =>
zParameterLoRAModel.safeParse(val).success;
// #endregion // #endregion
// #region ControlNet Model // #region ControlNet Model
export const zParameterControlNetModel = zModelIdentifierWithBase; const zParameterControlNetModel = zModelIdentifierWithBase;
export type ParameterControlNetModel = z.infer<typeof zParameterLoRAModel>; export type ParameterControlNetModel = z.infer<typeof zParameterControlNetModel>;
export const isParameterControlNetModel = (val: unknown): val is ParameterControlNetModel =>
zParameterControlNetModel.safeParse(val).success;
// #endregion // #endregion
// #region IP Adapter Model // #region IP Adapter Model
export const zParameterIPAdapterModel = zModelIdentifierWithBase; const zParameterIPAdapterModel = zModelIdentifierWithBase;
export type ParameterIPAdapterModel = z.infer<typeof zParameterIPAdapterModel>; export type ParameterIPAdapterModel = z.infer<typeof zParameterIPAdapterModel>;
export const isParameterIPAdapterModel = (val: unknown): val is ParameterIPAdapterModel =>
zParameterIPAdapterModel.safeParse(val).success;
// #endregion // #endregion
// #region T2I Adapter Model // #region T2I Adapter Model
export const zParameterT2IAdapterModel = zModelIdentifierWithBase; const zParameterT2IAdapterModel = zModelIdentifierWithBase;
export type ParameterT2IAdapterModel = z.infer<typeof zParameterT2IAdapterModel>; export type ParameterT2IAdapterModel = z.infer<typeof zParameterT2IAdapterModel>;
export const isParameterT2IAdapterModel = (val: unknown): val is ParameterT2IAdapterModel =>
zParameterT2IAdapterModel.safeParse(val).success;
// #endregion // #endregion
// #region Strength (l2l strength) // #region Strength (l2l strength)
export const zParameterStrength = z.number().min(0).max(1); const zParameterStrength = z.number().min(0).max(1);
export type ParameterStrength = z.infer<typeof zParameterStrength>; export type ParameterStrength = z.infer<typeof zParameterStrength>;
export const isParameterStrength = (val: unknown): val is ParameterStrength => export const isParameterStrength = (val: unknown): val is ParameterStrength =>
zParameterStrength.safeParse(val).success; zParameterStrength.safeParse(val).success;
// #endregion // #endregion
// #region Precision // #region Precision
export const zParameterPrecision = z.enum(['fp16', 'fp32']); const zParameterPrecision = z.enum(['fp16', 'fp32']);
export type ParameterPrecision = z.infer<typeof zParameterPrecision>; export type ParameterPrecision = z.infer<typeof zParameterPrecision>;
export const isParameterPrecision = (val: unknown): val is ParameterPrecision => export const isParameterPrecision = (val: unknown): val is ParameterPrecision =>
zParameterPrecision.safeParse(val).success; zParameterPrecision.safeParse(val).success;
// #endregion // #endregion
// #region HRF Method // #region HRF Method
export const zParameterHRFMethod = z.enum(['ESRGAN', 'bilinear']); const zParameterHRFMethod = z.enum(['ESRGAN', 'bilinear']);
export type ParameterHRFMethod = z.infer<typeof zParameterHRFMethod>; export type ParameterHRFMethod = z.infer<typeof zParameterHRFMethod>;
export const isParameterHRFMethod = (val: unknown): val is ParameterHRFMethod => export const isParameterHRFMethod = (val: unknown): val is ParameterHRFMethod =>
zParameterHRFMethod.safeParse(val).success; zParameterHRFMethod.safeParse(val).success;
// #endregion // #endregion
// #region HRF Enabled // #region HRF Enabled
export const zParameterHRFEnabled = z.boolean(); const zParameterHRFEnabled = z.boolean();
export type ParameterHRFEnabled = z.infer<typeof zParameterHRFEnabled>; export type ParameterHRFEnabled = z.infer<typeof zParameterHRFEnabled>;
export const isParameterHRFEnabled = (val: unknown): val is boolean => export const isParameterHRFEnabled = (val: unknown): val is boolean =>
zParameterHRFEnabled.safeParse(val).success && val !== null && val !== undefined; zParameterHRFEnabled.safeParse(val).success && val !== null && val !== undefined;
// #endregion // #endregion
// #region SDXL Refiner Positive Aesthetic Score // #region SDXL Refiner Positive Aesthetic Score
export const zParameterSDXLRefinerPositiveAestheticScore = z.number().min(1).max(10); const zParameterSDXLRefinerPositiveAestheticScore = z.number().min(1).max(10);
export type ParameterSDXLRefinerPositiveAestheticScore = z.infer<typeof zParameterSDXLRefinerPositiveAestheticScore>; export type ParameterSDXLRefinerPositiveAestheticScore = z.infer<typeof zParameterSDXLRefinerPositiveAestheticScore>;
export const isParameterSDXLRefinerPositiveAestheticScore = ( export const isParameterSDXLRefinerPositiveAestheticScore = (
val: unknown val: unknown
@ -184,7 +169,7 @@ export const isParameterSDXLRefinerPositiveAestheticScore = (
// #endregion // #endregion
// #region SDXL Refiner Negative Aesthetic Score // #region SDXL Refiner Negative Aesthetic Score
export const zParameterSDXLRefinerNegativeAestheticScore = zParameterSDXLRefinerPositiveAestheticScore; const zParameterSDXLRefinerNegativeAestheticScore = zParameterSDXLRefinerPositiveAestheticScore;
export type ParameterSDXLRefinerNegativeAestheticScore = z.infer<typeof zParameterSDXLRefinerNegativeAestheticScore>; export type ParameterSDXLRefinerNegativeAestheticScore = z.infer<typeof zParameterSDXLRefinerNegativeAestheticScore>;
export const isParameterSDXLRefinerNegativeAestheticScore = ( export const isParameterSDXLRefinerNegativeAestheticScore = (
val: unknown val: unknown
@ -193,28 +178,26 @@ export const isParameterSDXLRefinerNegativeAestheticScore = (
// #endregion // #endregion
// #region SDXL Refiner Start // #region SDXL Refiner Start
export const zParameterSDXLRefinerStart = z.number().min(0).max(1); const zParameterSDXLRefinerStart = z.number().min(0).max(1);
export type ParameterSDXLRefinerStart = z.infer<typeof zParameterSDXLRefinerStart>; export type ParameterSDXLRefinerStart = z.infer<typeof zParameterSDXLRefinerStart>;
export const isParameterSDXLRefinerStart = (val: unknown): val is ParameterSDXLRefinerStart => export const isParameterSDXLRefinerStart = (val: unknown): val is ParameterSDXLRefinerStart =>
zParameterSDXLRefinerStart.safeParse(val).success; zParameterSDXLRefinerStart.safeParse(val).success;
// #endregion // #endregion
// #region Mask Blur Method // #region Mask Blur Method
export const zParameterMaskBlurMethod = z.enum(['box', 'gaussian']); const zParameterMaskBlurMethod = z.enum(['box', 'gaussian']);
export type ParameterMaskBlurMethod = z.infer<typeof zParameterMaskBlurMethod>; export type ParameterMaskBlurMethod = z.infer<typeof zParameterMaskBlurMethod>;
export const isParameterMaskBlurMethod = (val: unknown): val is ParameterMaskBlurMethod =>
zParameterMaskBlurMethod.safeParse(val).success;
// #endregion // #endregion
// #region Canvas Coherence Mode // #region Canvas Coherence Mode
export const zParameterCanvasCoherenceMode = z.enum(['Gaussian Blur', 'Box Blur', 'Staged']); const zParameterCanvasCoherenceMode = z.enum(['Gaussian Blur', 'Box Blur', 'Staged']);
export type ParameterCanvasCoherenceMode = z.infer<typeof zParameterCanvasCoherenceMode>; export type ParameterCanvasCoherenceMode = z.infer<typeof zParameterCanvasCoherenceMode>;
export const isParameterCanvasCoherenceMode = (val: unknown): val is ParameterCanvasCoherenceMode => export const isParameterCanvasCoherenceMode = (val: unknown): val is ParameterCanvasCoherenceMode =>
zParameterCanvasCoherenceMode.safeParse(val).success; zParameterCanvasCoherenceMode.safeParse(val).success;
// #endregion // #endregion
// #region LoRA weight // #region LoRA weight
export const zLoRAWeight = z.number(); const zLoRAWeight = z.number();
export type ParameterLoRAWeight = z.infer<typeof zLoRAWeight>; export type ParameterLoRAWeight = z.infer<typeof zLoRAWeight>;
export const isParameterLoRAWeight = (val: unknown): val is ParameterLoRAWeight => zLoRAWeight.safeParse(val).success; export const isParameterLoRAWeight = (val: unknown): val is ParameterLoRAWeight => zLoRAWeight.safeParse(val).success;
// #endregion // #endregion

View File

@ -1,6 +1,5 @@
import type { PayloadAction } from '@reduxjs/toolkit'; import type { PayloadAction } from '@reduxjs/toolkit';
import { createSlice } from '@reduxjs/toolkit'; import { createSlice } from '@reduxjs/toolkit';
import type { RootState } from 'app/store/store';
export interface QueueState { export interface QueueState {
listCursor: number | undefined; listCursor: number | undefined;
@ -9,18 +8,16 @@ export interface QueueState {
resumeProcessorOnEnqueue: boolean; resumeProcessorOnEnqueue: boolean;
} }
export const initialQueueState: QueueState = { const initialQueueState: QueueState = {
listCursor: undefined, listCursor: undefined,
listPriority: undefined, listPriority: undefined,
selectedQueueItem: undefined, selectedQueueItem: undefined,
resumeProcessorOnEnqueue: true, resumeProcessorOnEnqueue: true,
}; };
const initialState: QueueState = initialQueueState;
export const queueSlice = createSlice({ export const queueSlice = createSlice({
name: 'queue', name: 'queue',
initialState, initialState: initialQueueState,
reducers: { reducers: {
listCursorChanged: (state, action: PayloadAction<number | undefined>) => { listCursorChanged: (state, action: PayloadAction<number | undefined>) => {
state.listCursor = action.payload; state.listCursor = action.payload;
@ -32,25 +29,7 @@ export const queueSlice = createSlice({
state.listCursor = undefined; state.listCursor = undefined;
state.listPriority = undefined; state.listPriority = undefined;
}, },
queueItemSelectionToggled: (state, action: PayloadAction<string | undefined>) => {
if (state.selectedQueueItem === action.payload) {
state.selectedQueueItem = undefined;
} else {
state.selectedQueueItem = action.payload;
}
},
resumeProcessorOnEnqueueChanged: (state, action: PayloadAction<boolean>) => {
state.resumeProcessorOnEnqueue = action.payload;
},
}, },
}); });
export const { export const { listCursorChanged, listPriorityChanged, listParamsReset } = queueSlice.actions;
listCursorChanged,
listPriorityChanged,
listParamsReset,
queueItemSelectionToggled,
resumeProcessorOnEnqueueChanged,
} = queueSlice.actions;
export const selectQueueSlice = (state: RootState) => state.queue;

View File

@ -22,7 +22,7 @@ type SDXLState = {
refinerStart: number; refinerStart: number;
}; };
export const initialSDXLState: SDXLState = { const initialSDXLState: SDXLState = {
_version: 1, _version: 1,
positiveStylePrompt: '', positiveStylePrompt: '',
negativeStylePrompt: '', negativeStylePrompt: '',
@ -89,7 +89,7 @@ export const {
export const selectSdxlSlice = (state: RootState) => state.sdxl; export const selectSdxlSlice = (state: RootState) => state.sdxl;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
export const migrateSDXLState = (state: any): any => { const migrateSDXLState = (state: any): any => {
if (!('_version' in state)) { if (!('_version' in state)) {
state._version = 1; state._version = 1;
} }

View File

@ -2,11 +2,11 @@ import { Flex, Heading } from '@invoke-ai/ui-library';
import type { PropsWithChildren } from 'react'; import type { PropsWithChildren } from 'react';
import { memo } from 'react'; import { memo } from 'react';
export type StickyScrollableHeadingProps = { type StickyScrollableHeadingProps = {
title: string; title: string;
}; };
export const StickyScrollableHeading = memo((props: StickyScrollableHeadingProps) => { const StickyScrollableHeading = memo((props: StickyScrollableHeadingProps) => {
return ( return (
<Flex ps={2} pb={4} position="sticky" zIndex={1} top={0} bg="base.800"> <Flex ps={2} pb={4} position="sticky" zIndex={1} top={0} bg="base.800">
<Heading size="sm">{props.title}</Heading> <Heading size="sm">{props.title}</Heading>
@ -16,9 +16,9 @@ export const StickyScrollableHeading = memo((props: StickyScrollableHeadingProps
StickyScrollableHeading.displayName = 'StickyScrollableHeading'; StickyScrollableHeading.displayName = 'StickyScrollableHeading';
export type StickyScrollableContentProps = PropsWithChildren; type StickyScrollableContentProps = PropsWithChildren;
export const StickyScrollableContent = memo((props: StickyScrollableContentProps) => { const StickyScrollableContent = memo((props: StickyScrollableContentProps) => {
return ( return (
<Flex p={4} borderRadius="base" bg="base.750" flexDir="column" gap={4}> <Flex p={4} borderRadius="base" bg="base.750" flexDir="column" gap={4}>
{props.children} {props.children}

View File

@ -14,7 +14,7 @@ const baseDimensionConfig: NumericalParameterConfig = {
coarseStep: 64, coarseStep: 64,
}; };
export const initialConfigState: AppConfig = { const initialConfigState: AppConfig = {
shouldUpdateImagesOnConnect: false, shouldUpdateImagesOnConnect: false,
shouldFetchMetadataFromApi: false, shouldFetchMetadataFromApi: false,
disabledTabs: [], disabledTabs: [],

View File

@ -24,7 +24,7 @@ import {
import type { Language, SystemState } from './types'; import type { Language, SystemState } from './types';
export const initialSystemState: SystemState = { const initialSystemState: SystemState = {
_version: 1, _version: 1,
isConnected: false, isConnected: false,
shouldConfirmOnDelete: true, shouldConfirmOnDelete: true,
@ -199,7 +199,7 @@ const isAnyServerError = isAnyOf(socketInvocationError, socketSessionRetrievalEr
export const selectSystemSlice = (state: RootState) => state.system; export const selectSystemSlice = (state: RootState) => state.system;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
export const migrateSystemState = (state: any): any => { const migrateSystemState = (state: any): any => {
if (!('_version' in state)) { if (!('_version' in state)) {
state._version = 1; state._version = 1;
} }

View File

@ -15,7 +15,7 @@ export type DenoiseProgress = {
percentage: number; percentage: number;
}; };
export const zLanguage = z.enum([ const zLanguage = z.enum([
'ar', 'ar',
'az', 'az',
'de', 'de',
@ -58,11 +58,3 @@ export interface SystemState {
status: SystemStatus; status: SystemStatus;
shouldEnableInformationalPopovers: boolean; shouldEnableInformationalPopovers: boolean;
} }
export const STATUS_TRANSLATION_KEYS: Record<SystemStatus, string> = {
CONNECTED: 'common.statusConnected',
DISCONNECTED: 'common.statusDisconnected',
PROCESSING: 'common.statusProcessing',
ERROR: 'common.statusError',
LOADING_MODEL: 'common.statusLoadingModel',
};

View File

@ -85,8 +85,8 @@ const enabledTabsSelector = createMemoizedSelector(selectConfigSlice, (config) =
tabs.filter((tab) => !config.disabledTabs.includes(tab.id)) tabs.filter((tab) => !config.disabledTabs.includes(tab.id))
); );
export const NO_GALLERY_PANEL_TABS: InvokeTabName[] = ['modelManager', 'queue']; const NO_GALLERY_PANEL_TABS: InvokeTabName[] = ['modelManager', 'queue'];
export const NO_OPTIONS_PANEL_TABS: InvokeTabName[] = ['modelManager', 'queue']; const NO_OPTIONS_PANEL_TABS: InvokeTabName[] = ['modelManager', 'queue'];
const panelStyles: CSSProperties = { height: '100%', width: '100%' }; const panelStyles: CSSProperties = { height: '100%', width: '100%' };
const GALLERY_MIN_SIZE_PX = 310; const GALLERY_MIN_SIZE_PX = 310;
const GALLERY_MIN_SIZE_PCT = 20; const GALLERY_MIN_SIZE_PCT = 20;

View File

@ -6,7 +6,7 @@ import { initialImageChanged } from 'features/parameters/store/generationSlice';
import type { InvokeTabName } from './tabMap'; import type { InvokeTabName } from './tabMap';
import type { UIState } from './uiTypes'; import type { UIState } from './uiTypes';
export const initialUIState: UIState = { const initialUIState: UIState = {
_version: 1, _version: 1,
activeTab: 'txt2img', activeTab: 'txt2img',
shouldShowImageDetails: false, shouldShowImageDetails: false,
@ -60,7 +60,7 @@ export const {
export const selectUiSlice = (state: RootState) => state.ui; export const selectUiSlice = (state: RootState) => state.ui;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
export const migrateUIState = (state: any): any => { const migrateUIState = (state: any): any => {
if (!('_version' in state)) { if (!('_version' in state)) {
state._version = 1; state._version = 1;
} }

View File

@ -1,11 +1,5 @@
import { ASSETS_CATEGORIES, IMAGE_CATEGORIES } from 'features/gallery/store/types'; import { ASSETS_CATEGORIES, IMAGE_CATEGORIES } from 'features/gallery/store/types';
import type { import type { BoardDTO, OffsetPaginatedResults_ImageDTO_, UpdateBoardArg } from 'services/api/types';
BoardDTO,
ListBoardsArg,
OffsetPaginatedResults_BoardDTO_,
OffsetPaginatedResults_ImageDTO_,
UpdateBoardArg,
} from 'services/api/types';
import { getListImagesUrl } from 'services/api/util'; import { getListImagesUrl } from 'services/api/util';
import type { ApiTagDescription } from '..'; import type { ApiTagDescription } from '..';
@ -24,26 +18,6 @@ export const boardsApi = api.injectEndpoints({
/** /**
* Boards Queries * Boards Queries
*/ */
listBoards: build.query<OffsetPaginatedResults_BoardDTO_, ListBoardsArg>({
query: (arg) => ({ url: buildBoardsUrl(), params: arg }),
providesTags: (result) => {
// any list of boards
const tags: ApiTagDescription[] = [{ type: 'Board', id: LIST_TAG }, 'FetchOnReconnect'];
if (result) {
// and individual tags for each board
tags.push(
...result.items.map(({ board_id }) => ({
type: 'Board' as const,
id: board_id,
}))
);
}
return tags;
},
}),
listAllBoards: build.query<Array<BoardDTO>, void>({ listAllBoards: build.query<Array<BoardDTO>, void>({
query: () => ({ query: () => ({
url: buildBoardsUrl(), url: buildBoardsUrl(),
@ -134,7 +108,6 @@ export const boardsApi = api.injectEndpoints({
}); });
export const { export const {
useListBoardsQuery,
useListAllBoardsQuery, useListAllBoardsQuery,
useGetBoardImagesTotalQuery, useGetBoardImagesTotalQuery,
useGetBoardAssetsTotalQuery, useGetBoardAssetsTotalQuery,

View File

@ -376,40 +376,6 @@ export const imagesApi = api.injectEndpoints({
} }
}, },
}), }),
/**
* Change an image's `session_id` association.
*/
changeImageSessionId: build.mutation<ImageDTO, { imageDTO: ImageDTO; session_id: string }>({
query: ({ imageDTO, session_id }) => ({
url: buildImagesUrl(`i/${imageDTO.image_name}`),
method: 'PATCH',
body: { session_id },
}),
async onQueryStarted({ imageDTO, session_id }, { dispatch, queryFulfilled }) {
/**
* Cache changes for `changeImageSessionId`:
* - *update* getImageDTO
*/
// Store patches so we can undo if the query fails
const patches: PatchCollection[] = [];
// *update* getImageDTO
patches.push(
dispatch(
imagesApi.util.updateQueryData('getImageDTO', imageDTO.image_name, (draft) => {
Object.assign(draft, { session_id });
})
)
);
try {
await queryFulfilled;
} catch {
patches.forEach((patchResult) => patchResult.undo());
}
},
}),
/** /**
* Star a list of images. * Star a list of images.
*/ */
@ -1336,13 +1302,10 @@ export const imagesApi = api.injectEndpoints({
export const { export const {
useGetIntermediatesCountQuery, useGetIntermediatesCountQuery,
useListImagesQuery, useListImagesQuery,
useLazyListImagesQuery,
useGetImageDTOQuery, useGetImageDTOQuery,
useGetImageMetadataQuery, useGetImageMetadataQuery,
useGetImageWorkflowQuery, useGetImageWorkflowQuery,
useLazyGetImageWorkflowQuery, useLazyGetImageWorkflowQuery,
useDeleteImageMutation,
useDeleteImagesMutation,
useUploadImageMutation, useUploadImageMutation,
useClearIntermediatesMutation, useClearIntermediatesMutation,
useAddImagesToBoardMutation, useAddImagesToBoardMutation,
@ -1350,7 +1313,6 @@ export const {
useAddImageToBoardMutation, useAddImageToBoardMutation,
useRemoveImageFromBoardMutation, useRemoveImageFromBoardMutation,
useChangeImageIsIntermediateMutation, useChangeImageIsIntermediateMutation,
useChangeImageSessionIdMutation,
useDeleteBoardAndImagesMutation, useDeleteBoardAndImagesMutation,
useDeleteBoardMutation, useDeleteBoardMutation,
useStarImagesMutation, useStarImagesMutation,

View File

@ -66,50 +66,45 @@ type ScanFolderArg = operations['scan_for_models']['parameters']['query'];
export type GetByAttrsArg = operations['get_model_records_by_attrs']['parameters']['query']; export type GetByAttrsArg = operations['get_model_records_by_attrs']['parameters']['query'];
export const mainModelsAdapter = createEntityAdapter<MainModelConfig, string>({ const mainModelsAdapter = createEntityAdapter<MainModelConfig, string>({
selectId: (entity) => entity.key, selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name), sortComparer: (a, b) => a.name.localeCompare(b.name),
}); });
export const mainModelsAdapterSelectors = mainModelsAdapter.getSelectors(undefined, getSelectorsOptions); export const mainModelsAdapterSelectors = mainModelsAdapter.getSelectors(undefined, getSelectorsOptions);
export const loraModelsAdapter = createEntityAdapter<LoRAModelConfig, string>({ const loraModelsAdapter = createEntityAdapter<LoRAModelConfig, string>({
selectId: (entity) => entity.key, selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name), sortComparer: (a, b) => a.name.localeCompare(b.name),
}); });
export const loraModelsAdapterSelectors = loraModelsAdapter.getSelectors(undefined, getSelectorsOptions); const controlNetModelsAdapter = createEntityAdapter<ControlNetModelConfig, string>({
export const controlNetModelsAdapter = createEntityAdapter<ControlNetModelConfig, string>({
selectId: (entity) => entity.key, selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name), sortComparer: (a, b) => a.name.localeCompare(b.name),
}); });
export const controlNetModelsAdapterSelectors = controlNetModelsAdapter.getSelectors(undefined, getSelectorsOptions); export const controlNetModelsAdapterSelectors = controlNetModelsAdapter.getSelectors(undefined, getSelectorsOptions);
export const ipAdapterModelsAdapter = createEntityAdapter<IPAdapterModelConfig, string>({ const ipAdapterModelsAdapter = createEntityAdapter<IPAdapterModelConfig, string>({
selectId: (entity) => entity.key, selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name), sortComparer: (a, b) => a.name.localeCompare(b.name),
}); });
export const ipAdapterModelsAdapterSelectors = ipAdapterModelsAdapter.getSelectors(undefined, getSelectorsOptions); export const ipAdapterModelsAdapterSelectors = ipAdapterModelsAdapter.getSelectors(undefined, getSelectorsOptions);
export const t2iAdapterModelsAdapter = createEntityAdapter<T2IAdapterModelConfig, string>({ const t2iAdapterModelsAdapter = createEntityAdapter<T2IAdapterModelConfig, string>({
selectId: (entity) => entity.key, selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name), sortComparer: (a, b) => a.name.localeCompare(b.name),
}); });
export const t2iAdapterModelsAdapterSelectors = t2iAdapterModelsAdapter.getSelectors(undefined, getSelectorsOptions); export const t2iAdapterModelsAdapterSelectors = t2iAdapterModelsAdapter.getSelectors(undefined, getSelectorsOptions);
export const textualInversionModelsAdapter = createEntityAdapter<TextualInversionModelConfig, string>({ const textualInversionModelsAdapter = createEntityAdapter<TextualInversionModelConfig, string>({
selectId: (entity) => entity.key, selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name), sortComparer: (a, b) => a.name.localeCompare(b.name),
}); });
export const textualInversionModelsAdapterSelectors = textualInversionModelsAdapter.getSelectors( const vaeModelsAdapter = createEntityAdapter<VAEModelConfig, string>({
undefined,
getSelectorsOptions
);
export const vaeModelsAdapter = createEntityAdapter<VAEModelConfig, string>({
selectId: (entity) => entity.key, selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name), sortComparer: (a, b) => a.name.localeCompare(b.name),
}); });
export const vaeModelsAdapterSelectors = vaeModelsAdapter.getSelectors(undefined, getSelectorsOptions); export const vaeModelsAdapterSelectors = vaeModelsAdapter.getSelectors(undefined, getSelectorsOptions);
export const anyModelConfigAdapter = createEntityAdapter<AnyModelConfig, string>({ const anyModelConfigAdapter = createEntityAdapter<AnyModelConfig, string>({
selectId: (entity) => entity.key, selectId: (entity) => entity.key,
sortComparer: (a, b) => a.name.localeCompare(b.name), sortComparer: (a, b) => a.name.localeCompare(b.name),
}); });
export const anyModelConfigAdapterSelectors = anyModelConfigAdapter.getSelectors(undefined, getSelectorsOptions); const anyModelConfigAdapterSelectors = anyModelConfigAdapter.getSelectors(undefined, getSelectorsOptions);
const buildProvidesTags = const buildProvidesTags =
<TEntity extends AnyModelConfig>(tagType: (typeof tagTypes)[number]) => <TEntity extends AnyModelConfig>(tagType: (typeof tagTypes)[number]) =>
@ -338,7 +333,6 @@ export const modelsApi = api.injectEndpoints({
}); });
export const { export const {
useGetModelConfigByAttrsQuery,
useGetModelConfigQuery, useGetModelConfigQuery,
useGetMainModelsQuery, useGetMainModelsQuery,
useGetControlNetModelsQuery, useGetControlNetModelsQuery,
@ -352,7 +346,6 @@ export const {
useInstallModelMutation, useInstallModelMutation,
useConvertMainModelsMutation, useConvertMainModelsMutation,
useSyncModelsMutation, useSyncModelsMutation,
useScanModelsQuery,
useLazyScanModelsQuery, useLazyScanModelsQuery,
useGetModelImportsQuery, useGetModelImportsQuery,
useGetModelMetadataQuery, useGetModelMetadataQuery,

View File

@ -314,10 +314,8 @@ export const {
useResumeProcessorMutation, useResumeProcessorMutation,
useClearQueueMutation, useClearQueueMutation,
usePruneQueueMutation, usePruneQueueMutation,
useGetCurrentQueueItemQuery,
useGetQueueStatusQuery, useGetQueueStatusQuery,
useGetQueueItemQuery, useGetQueueItemQuery,
useGetNextQueueItemQuery,
useListQueueItemsQuery, useListQueueItemsQuery,
useCancelQueueItemMutation, useCancelQueueItemMutation,
useGetBatchStatusQuery, useGetBatchStatusQuery,

View File

@ -28,5 +28,3 @@ export const utilitiesApi = api.injectEndpoints({
}), }),
}), }),
}); });
export const { useDynamicPromptsQuery } = utilitiesApi;

View File

@ -101,10 +101,6 @@ export const isT2IAdapterModelConfig = (config: AnyModelConfig): config is T2IAd
return config.type === 't2i_adapter'; return config.type === 't2i_adapter';
}; };
export const isTextualInversionModelConfig = (config: AnyModelConfig): config is TextualInversionModelConfig => {
return config.type === 'embedding';
};
export const isNonRefinerMainModelConfig = (config: AnyModelConfig): config is MainModelConfig => { export const isNonRefinerMainModelConfig = (config: AnyModelConfig): config is MainModelConfig => {
return config.type === 'main' && config.base !== 'sdxl-refiner'; return config.type === 'main' && config.base !== 'sdxl-refiner';
}; };