diff --git a/invokeai/frontend/web/knip.json b/invokeai/frontend/web/knip.json deleted file mode 100644 index b632b8c56a..0000000000 --- a/invokeai/frontend/web/knip.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "$schema": "https://unpkg.com/knip@5/schema.json", - "ignore": ["src/features/nodes/types/v2/**/*", "src/features/nodes/types/v1/**/*"] -} diff --git a/invokeai/frontend/web/knip.ts b/invokeai/frontend/web/knip.ts new file mode 100644 index 0000000000..0f7c8c2354 --- /dev/null +++ b/invokeai/frontend/web/knip.ts @@ -0,0 +1,19 @@ +import type { KnipConfig } from 'knip'; + +const config: KnipConfig = { + ignore: [ + // This file is only used during debugging + '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: { + // + svg: () => '', + }, +}; + +export default config; diff --git a/invokeai/frontend/web/src/features/dynamicPrompts/components/ParamDynamicPromptsCombinatorial.tsx b/invokeai/frontend/web/src/features/dynamicPrompts/components/ParamDynamicPromptsCombinatorial.tsx deleted file mode 100644 index 64901ddb86..0000000000 --- a/invokeai/frontend/web/src/features/dynamicPrompts/components/ParamDynamicPromptsCombinatorial.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { FormControl, FormLabel, Switch } from '@invoke-ai/ui-library'; -import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; -import { combinatorialToggled } from 'features/dynamicPrompts/store/dynamicPromptsSlice'; -import { memo, useCallback } from 'react'; -import { useTranslation } from 'react-i18next'; - -const ParamDynamicPromptsCombinatorial = () => { - const combinatorial = useAppSelector((s) => s.dynamicPrompts.combinatorial); - const dispatch = useAppDispatch(); - const { t } = useTranslation(); - - const handleChange = useCallback(() => { - dispatch(combinatorialToggled()); - }, [dispatch]); - - return ( - - {t('dynamicPrompts.combinatorial')} - - - ); -}; - -export default memo(ParamDynamicPromptsCombinatorial); diff --git a/invokeai/frontend/web/src/features/gallery/components/Boards/NoBoardContextMenuItems.tsx b/invokeai/frontend/web/src/features/gallery/components/Boards/NoBoardContextMenuItems.tsx deleted file mode 100644 index 4c1ae0eb83..0000000000 --- a/invokeai/frontend/web/src/features/gallery/components/Boards/NoBoardContextMenuItems.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { memo } from 'react'; - -const NoBoardContextMenuItems = () => { - return <>; -}; - -export default memo(NoBoardContextMenuItems); diff --git a/invokeai/frontend/web/src/features/metadata/exceptions.ts b/invokeai/frontend/web/src/features/metadata/exceptions.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/AddModelPanel/BaseModelSelect.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/AddModelPanel/BaseModelSelect.tsx deleted file mode 100644 index a2d1176a80..0000000000 --- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/AddModelPanel/BaseModelSelect.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import type { ComboboxOnChange, ComboboxOption } from '@invoke-ai/ui-library'; -import { Combobox, Flex, FormControl, FormLabel } from '@invoke-ai/ui-library'; -import { typedMemo } from 'common/util/typedMemo'; -import { MODEL_TYPE_MAP } from 'features/parameters/types/constants'; -import { useCallback, useMemo } from 'react'; -import type { UseControllerProps } from 'react-hook-form'; -import { useController } from 'react-hook-form'; -import { useTranslation } from 'react-i18next'; -import type { AnyModelConfig } from 'services/api/types'; - -const options: ComboboxOption[] = [ - { value: 'sd-1', label: MODEL_TYPE_MAP['sd-1'] }, - { value: 'sd-2', label: MODEL_TYPE_MAP['sd-2'] }, - { value: 'sdxl', label: MODEL_TYPE_MAP['sdxl'] }, - { value: 'sdxl-refiner', label: MODEL_TYPE_MAP['sdxl-refiner'] }, -]; - -const BaseModelSelect = (props: UseControllerProps) => { - const { t } = useTranslation(); - const { field } = useController(props); - const value = useMemo(() => options.find((o) => o.value === field.value), [field.value]); - const onChange = useCallback( - (v) => { - field.onChange(v?.value); - }, - [field] - ); - return ( - - - {t('modelManager.baseModel')} - - - - ); -}; - -export default typedMemo(BaseModelSelect); diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/AddModelPanel/ModelVariantSelect.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/AddModelPanel/ModelVariantSelect.tsx deleted file mode 100644 index 80cb5a637c..0000000000 --- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/AddModelPanel/ModelVariantSelect.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import type { ComboboxOnChange, ComboboxOption } from '@invoke-ai/ui-library'; -import { Combobox, Flex, FormControl, FormLabel } from '@invoke-ai/ui-library'; -import { typedMemo } from 'common/util/typedMemo'; -import { useCallback, useMemo } from 'react'; -import type { UseControllerProps } from 'react-hook-form'; -import { useController } from 'react-hook-form'; -import { useTranslation } from 'react-i18next'; -import type { CheckpointModelConfig, DiffusersModelConfig } from 'services/api/types'; - -const options: ComboboxOption[] = [ - { value: 'normal', label: 'Normal' }, - { value: 'inpaint', label: 'Inpaint' }, - { value: 'depth', label: 'Depth' }, -]; - -const ModelVariantSelect = (props: UseControllerProps) => { - const { t } = useTranslation(); - const { field } = useController(props); - const value = useMemo(() => options.find((o) => o.value === field.value), [field.value]); - const onChange = useCallback( - (v) => { - field.onChange(v?.value); - }, - [field] - ); - return ( - - - {t('modelManager.variant')} - - - - ); -}; - -export default typedMemo(ModelVariantSelect); diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/AddModelPanel/ScanModels/ScanModels.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/AddModelPanel/ScanModels/ScanModels.tsx deleted file mode 100644 index 0a280a52fd..0000000000 --- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/AddModelPanel/ScanModels/ScanModels.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export const ScanModels = () => { - return null; -}; diff --git a/invokeai/frontend/web/src/features/nodes/hooks/useDoNodeVersionsMatch.ts b/invokeai/frontend/web/src/features/nodes/hooks/useDoNodeVersionsMatch.ts deleted file mode 100644 index 91994cf752..0000000000 --- a/invokeai/frontend/web/src/features/nodes/hooks/useDoNodeVersionsMatch.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { createSelector } from '@reduxjs/toolkit'; -import { useAppSelector } from 'app/store/storeHooks'; -import { compareVersions } from 'compare-versions'; -import { selectNodesSlice } from 'features/nodes/store/nodesSlice'; -import { selectNodeData, selectNodeTemplate } from 'features/nodes/store/selectors'; -import { useMemo } from 'react'; - -export const useDoNodeVersionsMatch = (nodeId: string): boolean => { - const selector = useMemo( - () => - createSelector(selectNodesSlice, (nodes) => { - const data = selectNodeData(nodes, nodeId); - const template = selectNodeTemplate(nodes, nodeId); - if (!template?.version || !data?.version) { - return false; - } - return compareVersions(template.version, data.version) === 0; - }), - [nodeId] - ); - - const nodeTemplate = useAppSelector(selector); - - return nodeTemplate; -}; diff --git a/invokeai/frontend/web/src/features/nodes/hooks/useFieldInputKind.ts b/invokeai/frontend/web/src/features/nodes/hooks/useFieldInputKind.ts deleted file mode 100644 index 08de3d9b20..0000000000 --- a/invokeai/frontend/web/src/features/nodes/hooks/useFieldInputKind.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { createSelector } from '@reduxjs/toolkit'; -import { useAppSelector } from 'app/store/storeHooks'; -import { selectNodesSlice } from 'features/nodes/store/nodesSlice'; -import { selectFieldInputTemplate } from 'features/nodes/store/selectors'; -import type { FieldInput } from 'features/nodes/types/field'; -import { useMemo } from 'react'; - -export const useFieldInputKind = (nodeId: string, fieldName: string) => { - const selector = useMemo( - () => - createSelector(selectNodesSlice, (nodes): FieldInput | null => { - const template = selectFieldInputTemplate(nodes, nodeId, fieldName); - return template?.input ?? null; - }), - [fieldName, nodeId] - ); - - const inputKind = useAppSelector(selector); - - return inputKind; -}; diff --git a/invokeai/frontend/web/src/features/nodes/hooks/useNodeTemplateByType.ts b/invokeai/frontend/web/src/features/nodes/hooks/useNodeTemplateByType.ts deleted file mode 100644 index a0c870f694..0000000000 --- a/invokeai/frontend/web/src/features/nodes/hooks/useNodeTemplateByType.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { createSelector } from '@reduxjs/toolkit'; -import { useAppSelector } from 'app/store/storeHooks'; -import { selectNodesSlice } from 'features/nodes/store/nodesSlice'; -import type { InvocationTemplate } from 'features/nodes/types/invocation'; -import { useMemo } from 'react'; - -export const useNodeTemplateByType = (type: string): InvocationTemplate | null => { - const selector = useMemo( - () => - createSelector(selectNodesSlice, (nodes) => { - return nodes.templates[type] ?? null; - }), - [type] - ); - - const nodeTemplate = useAppSelector(selector); - - return nodeTemplate; -}; diff --git a/invokeai/frontend/web/src/features/nodes/types/common.ts b/invokeai/frontend/web/src/features/nodes/types/common.ts index 461e804db3..82c41096d9 100644 --- a/invokeai/frontend/web/src/features/nodes/types/common.ts +++ b/invokeai/frontend/web/src/features/nodes/types/common.ts @@ -54,8 +54,8 @@ export type SchedulerField = z.infer; // #endregion // #region Model-related schemas -export const zBaseModel = z.enum(['any', 'sd-1', 'sd-2', 'sdxl', 'sdxl-refiner']); -export const zModelType = z.enum([ +const zBaseModel = z.enum(['any', 'sd-1', 'sd-2', 'sdxl', 'sdxl-refiner']); +const zModelType = z.enum([ 'main', 'vae', 'lora', @@ -65,15 +65,14 @@ export const zModelType = z.enum([ 'clip_vision', 't2i_adapter', ]); -export const zModelName = z.string().min(3); -export const zModelIdentifier = z.object({ +const zModelIdentifier = z.object({ key: z.string().min(1), }); export const isModelIdentifier = (field: unknown): field is ModelIdentifier => zModelIdentifier.safeParse(field).success; export const isModelIdentifierV2 = (field: unknown): field is ModelIdentifierV2 => zModelIdentifierV2.safeParse(field).success; -export const zModelFieldBase = zModelIdentifier; +const zModelFieldBase = zModelIdentifier; export const zModelIdentifierWithBase = zModelIdentifier.extend({ base: zBaseModel }); export type BaseModel = z.infer; export type ModelType = z.infer; @@ -123,7 +122,7 @@ export type ProgressImage = z.infer; // #endregion // #region ImageOutput -export const zImageOutput = z.object({ +const zImageOutput = z.object({ image: zImageField, width: z.number().int().gt(0), height: z.number().int().gt(0), diff --git a/invokeai/frontend/web/src/features/nodes/types/field.ts b/invokeai/frontend/web/src/features/nodes/types/field.ts index e630d59e07..83dbf27e1e 100644 --- a/invokeai/frontend/web/src/features/nodes/types/field.ts +++ b/invokeai/frontend/web/src/features/nodes/types/field.ts @@ -1,12 +1,6 @@ import { z } from 'zod'; -import { - zBoardField, - zColorField, - zImageField, - zModelIdentifierWithBase, - zSchedulerField, -} from './common'; +import { zBoardField, zColorField, zImageField, zModelIdentifierWithBase, zSchedulerField } from './common'; /** * zod schemas & inferred types for fields. @@ -35,19 +29,19 @@ import { /** */ // #region Base schemas & misc -export const zFieldInput = z.enum(['connection', 'direct', 'any']); +const zFieldInput = z.enum(['connection', 'direct', 'any']); export type FieldInput = z.infer; -export const zFieldUIComponent = z.enum(['none', 'textarea', 'slider']); +const zFieldUIComponent = z.enum(['none', 'textarea', 'slider']); export type FieldUIComponent = z.infer; -export const zFieldInputInstanceBase = z.object({ +const zFieldInputInstanceBase = z.object({ name: z.string().trim().min(1), label: z.string().nullish(), }); export type FieldInputInstanceBase = z.infer; -export const zFieldTemplateBase = z.object({ +const zFieldTemplateBase = z.object({ name: z.string().min(1), title: z.string().min(1), description: z.string().nullish(), @@ -55,21 +49,21 @@ export const zFieldTemplateBase = z.object({ ui_type: z.string().nullish(), ui_order: z.number().int().nullish(), }); -export const zFieldInputTemplateBase = zFieldTemplateBase.extend({ +const zFieldInputTemplateBase = zFieldTemplateBase.extend({ fieldKind: z.literal('input'), input: zFieldInput, required: z.boolean(), ui_component: zFieldUIComponent.nullish(), ui_choice_labels: z.record(z.string()).nullish(), }); -export const zFieldOutputTemplateBase = zFieldTemplateBase.extend({ +const zFieldOutputTemplateBase = zFieldTemplateBase.extend({ fieldKind: z.literal('output'), }); export type FieldTemplateBase = z.infer; export type FieldInputTemplateBase = z.infer; export type FieldOutputTemplateBase = z.infer; -export const zFieldTypeBase = z.object({ +const zFieldTypeBase = z.object({ isCollection: z.boolean(), isCollectionOrScalar: z.boolean(), }); @@ -79,18 +73,17 @@ export const zFieldIdentifier = z.object({ fieldName: z.string().trim().min(1), }); export type FieldIdentifier = z.infer; -export const isFieldIdentifier = (val: unknown): val is FieldIdentifier => zFieldIdentifier.safeParse(val).success; // #endregion // #region IntegerField -export const zIntegerFieldType = zFieldTypeBase.extend({ +const zIntegerFieldType = zFieldTypeBase.extend({ name: z.literal('IntegerField'), }); export const zIntegerFieldValue = z.number().int(); -export const zIntegerFieldInputInstance = zFieldInputInstanceBase.extend({ +const zIntegerFieldInputInstance = zFieldInputInstanceBase.extend({ value: zIntegerFieldValue, }); -export const zIntegerFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zIntegerFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zIntegerFieldType, default: zIntegerFieldValue, multipleOf: z.number().int().optional(), @@ -99,7 +92,7 @@ export const zIntegerFieldInputTemplate = zFieldInputTemplateBase.extend({ minimum: z.number().int().optional(), exclusiveMinimum: z.number().int().optional(), }); -export const zIntegerFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zIntegerFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zIntegerFieldType, }); export type IntegerFieldType = z.infer; @@ -113,14 +106,14 @@ export const isIntegerFieldInputTemplate = (val: unknown): val is IntegerFieldIn // #endregion // #region FloatField -export const zFloatFieldType = zFieldTypeBase.extend({ +const zFloatFieldType = zFieldTypeBase.extend({ name: z.literal('FloatField'), }); export const zFloatFieldValue = z.number(); -export const zFloatFieldInputInstance = zFieldInputInstanceBase.extend({ +const zFloatFieldInputInstance = zFieldInputInstanceBase.extend({ value: zFloatFieldValue, }); -export const zFloatFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zFloatFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zFloatFieldType, default: zFloatFieldValue, multipleOf: z.number().optional(), @@ -129,7 +122,7 @@ export const zFloatFieldInputTemplate = zFieldInputTemplateBase.extend({ minimum: z.number().optional(), exclusiveMinimum: z.number().optional(), }); -export const zFloatFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zFloatFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zFloatFieldType, }); export type FloatFieldType = z.infer; @@ -144,20 +137,20 @@ export const isFloatFieldInputTemplate = (val: unknown): val is FloatFieldInputT // #endregion // #region StringField -export const zStringFieldType = zFieldTypeBase.extend({ +const zStringFieldType = zFieldTypeBase.extend({ name: z.literal('StringField'), }); export const zStringFieldValue = z.string(); -export const zStringFieldInputInstance = zFieldInputInstanceBase.extend({ +const zStringFieldInputInstance = zFieldInputInstanceBase.extend({ value: zStringFieldValue, }); -export const zStringFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zStringFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zStringFieldType, default: zStringFieldValue, maxLength: z.number().int().optional(), minLength: z.number().int().optional(), }); -export const zStringFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zStringFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zStringFieldType, }); @@ -173,18 +166,18 @@ export const isStringFieldInputTemplate = (val: unknown): val is StringFieldInpu // #endregion // #region BooleanField -export const zBooleanFieldType = zFieldTypeBase.extend({ +const zBooleanFieldType = zFieldTypeBase.extend({ name: z.literal('BooleanField'), }); export const zBooleanFieldValue = z.boolean(); -export const zBooleanFieldInputInstance = zFieldInputInstanceBase.extend({ +const zBooleanFieldInputInstance = zFieldInputInstanceBase.extend({ value: zBooleanFieldValue, }); -export const zBooleanFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zBooleanFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zBooleanFieldType, default: zBooleanFieldValue, }); -export const zBooleanFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zBooleanFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zBooleanFieldType, }); export type BooleanFieldType = z.infer; @@ -199,20 +192,20 @@ export const isBooleanFieldInputTemplate = (val: unknown): val is BooleanFieldIn // #endregion // #region EnumField -export const zEnumFieldType = zFieldTypeBase.extend({ +const zEnumFieldType = zFieldTypeBase.extend({ name: z.literal('EnumField'), }); export const zEnumFieldValue = z.string(); -export const zEnumFieldInputInstance = zFieldInputInstanceBase.extend({ +const zEnumFieldInputInstance = zFieldInputInstanceBase.extend({ value: zEnumFieldValue, }); -export const zEnumFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zEnumFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zEnumFieldType, default: zEnumFieldValue, options: z.array(z.string()), labels: z.record(z.string()).optional(), }); -export const zEnumFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zEnumFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zEnumFieldType, }); export type EnumFieldType = z.infer; @@ -227,18 +220,18 @@ export const isEnumFieldInputTemplate = (val: unknown): val is EnumFieldInputTem // #endregion // #region ImageField -export const zImageFieldType = zFieldTypeBase.extend({ +const zImageFieldType = zFieldTypeBase.extend({ name: z.literal('ImageField'), }); export const zImageFieldValue = zImageField.optional(); -export const zImageFieldInputInstance = zFieldInputInstanceBase.extend({ +const zImageFieldInputInstance = zFieldInputInstanceBase.extend({ value: zImageFieldValue, }); -export const zImageFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zImageFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zImageFieldType, default: zImageFieldValue, }); -export const zImageFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zImageFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zImageFieldType, }); export type ImageFieldType = z.infer; @@ -253,18 +246,18 @@ export const isImageFieldInputTemplate = (val: unknown): val is ImageFieldInputT // #endregion // #region BoardField -export const zBoardFieldType = zFieldTypeBase.extend({ +const zBoardFieldType = zFieldTypeBase.extend({ name: z.literal('BoardField'), }); export const zBoardFieldValue = zBoardField.optional(); -export const zBoardFieldInputInstance = zFieldInputInstanceBase.extend({ +const zBoardFieldInputInstance = zFieldInputInstanceBase.extend({ value: zBoardFieldValue, }); -export const zBoardFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zBoardFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zBoardFieldType, default: zBoardFieldValue, }); -export const zBoardFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zBoardFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zBoardFieldType, }); export type BoardFieldType = z.infer; @@ -279,18 +272,18 @@ export const isBoardFieldInputTemplate = (val: unknown): val is BoardFieldInputT // #endregion // #region ColorField -export const zColorFieldType = zFieldTypeBase.extend({ +const zColorFieldType = zFieldTypeBase.extend({ name: z.literal('ColorField'), }); export const zColorFieldValue = zColorField.optional(); -export const zColorFieldInputInstance = zFieldInputInstanceBase.extend({ +const zColorFieldInputInstance = zFieldInputInstanceBase.extend({ value: zColorFieldValue, }); -export const zColorFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zColorFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zColorFieldType, default: zColorFieldValue, }); -export const zColorFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zColorFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zColorFieldType, }); export type ColorFieldType = z.infer; @@ -305,18 +298,18 @@ export const isColorFieldInputTemplate = (val: unknown): val is ColorFieldInputT // #endregion // #region MainModelField -export const zMainModelFieldType = zFieldTypeBase.extend({ +const zMainModelFieldType = zFieldTypeBase.extend({ name: z.literal('MainModelField'), }); export const zMainModelFieldValue = zModelIdentifierWithBase.optional(); -export const zMainModelFieldInputInstance = zFieldInputInstanceBase.extend({ +const zMainModelFieldInputInstance = zFieldInputInstanceBase.extend({ value: zMainModelFieldValue, }); -export const zMainModelFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zMainModelFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zMainModelFieldType, default: zMainModelFieldValue, }); -export const zMainModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zMainModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zMainModelFieldType, }); export type MainModelFieldType = z.infer; @@ -331,18 +324,18 @@ export const isMainModelFieldInputTemplate = (val: unknown): val is MainModelFie // #endregion // #region SDXLMainModelField -export const zSDXLMainModelFieldType = zFieldTypeBase.extend({ +const zSDXLMainModelFieldType = zFieldTypeBase.extend({ name: z.literal('SDXLMainModelField'), }); -export const zSDXLMainModelFieldValue = zMainModelFieldValue; // TODO: Narrow to SDXL models only. -export const zSDXLMainModelFieldInputInstance = zFieldInputInstanceBase.extend({ +const zSDXLMainModelFieldValue = zMainModelFieldValue; // TODO: Narrow to SDXL models only. +const zSDXLMainModelFieldInputInstance = zFieldInputInstanceBase.extend({ value: zSDXLMainModelFieldValue, }); -export const zSDXLMainModelFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zSDXLMainModelFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zSDXLMainModelFieldType, default: zSDXLMainModelFieldValue, }); -export const zSDXLMainModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zSDXLMainModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zSDXLMainModelFieldType, }); export type SDXLMainModelFieldType = z.infer; @@ -357,18 +350,18 @@ export const isSDXLMainModelFieldInputTemplate = (val: unknown): val is SDXLMain // #endregion // #region SDXLRefinerModelField -export const zSDXLRefinerModelFieldType = zFieldTypeBase.extend({ +const zSDXLRefinerModelFieldType = zFieldTypeBase.extend({ name: z.literal('SDXLRefinerModelField'), }); export const zSDXLRefinerModelFieldValue = zMainModelFieldValue; // TODO: Narrow to SDXL Refiner models only. -export const zSDXLRefinerModelFieldInputInstance = zFieldInputInstanceBase.extend({ +const zSDXLRefinerModelFieldInputInstance = zFieldInputInstanceBase.extend({ value: zSDXLRefinerModelFieldValue, }); -export const zSDXLRefinerModelFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zSDXLRefinerModelFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zSDXLRefinerModelFieldType, default: zSDXLRefinerModelFieldValue, }); -export const zSDXLRefinerModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zSDXLRefinerModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zSDXLRefinerModelFieldType, }); export type SDXLRefinerModelFieldType = z.infer; @@ -383,18 +376,18 @@ export const isSDXLRefinerModelFieldInputTemplate = (val: unknown): val is SDXLR // #endregion // #region VAEModelField -export const zVAEModelFieldType = zFieldTypeBase.extend({ +const zVAEModelFieldType = zFieldTypeBase.extend({ name: z.literal('VAEModelField'), }); export const zVAEModelFieldValue = zModelIdentifierWithBase.optional(); -export const zVAEModelFieldInputInstance = zFieldInputInstanceBase.extend({ +const zVAEModelFieldInputInstance = zFieldInputInstanceBase.extend({ value: zVAEModelFieldValue, }); -export const zVAEModelFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zVAEModelFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zVAEModelFieldType, default: zVAEModelFieldValue, }); -export const zVAEModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zVAEModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zVAEModelFieldType, }); export type VAEModelFieldType = z.infer; @@ -409,18 +402,18 @@ export const isVAEModelFieldInputTemplate = (val: unknown): val is VAEModelField // #endregion // #region LoRAModelField -export const zLoRAModelFieldType = zFieldTypeBase.extend({ +const zLoRAModelFieldType = zFieldTypeBase.extend({ name: z.literal('LoRAModelField'), }); export const zLoRAModelFieldValue = zModelIdentifierWithBase.optional(); -export const zLoRAModelFieldInputInstance = zFieldInputInstanceBase.extend({ +const zLoRAModelFieldInputInstance = zFieldInputInstanceBase.extend({ value: zLoRAModelFieldValue, }); -export const zLoRAModelFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zLoRAModelFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zLoRAModelFieldType, default: zLoRAModelFieldValue, }); -export const zLoRAModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zLoRAModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zLoRAModelFieldType, }); export type LoRAModelFieldType = z.infer; @@ -435,18 +428,18 @@ export const isLoRAModelFieldInputTemplate = (val: unknown): val is LoRAModelFie // #endregion // #region ControlNetModelField -export const zControlNetModelFieldType = zFieldTypeBase.extend({ +const zControlNetModelFieldType = zFieldTypeBase.extend({ name: z.literal('ControlNetModelField'), }); export const zControlNetModelFieldValue = zModelIdentifierWithBase.optional(); -export const zControlNetModelFieldInputInstance = zFieldInputInstanceBase.extend({ +const zControlNetModelFieldInputInstance = zFieldInputInstanceBase.extend({ value: zControlNetModelFieldValue, }); -export const zControlNetModelFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zControlNetModelFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zControlNetModelFieldType, default: zControlNetModelFieldValue, }); -export const zControlNetModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zControlNetModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zControlNetModelFieldType, }); export type ControlNetModelFieldType = z.infer; @@ -458,23 +451,21 @@ export const isControlNetModelFieldInputInstance = (val: unknown): val is Contro zControlNetModelFieldInputInstance.safeParse(val).success; export const isControlNetModelFieldInputTemplate = (val: unknown): val is ControlNetModelFieldInputTemplate => zControlNetModelFieldInputTemplate.safeParse(val).success; -export const isControlNetModelFieldValue = (v: unknown): v is ControlNetModelFieldValue => - zControlNetModelFieldValue.safeParse(v).success; // #endregion // #region IPAdapterModelField -export const zIPAdapterModelFieldType = zFieldTypeBase.extend({ +const zIPAdapterModelFieldType = zFieldTypeBase.extend({ name: z.literal('IPAdapterModelField'), }); export const zIPAdapterModelFieldValue = zModelIdentifierWithBase.optional(); -export const zIPAdapterModelFieldInputInstance = zFieldInputInstanceBase.extend({ +const zIPAdapterModelFieldInputInstance = zFieldInputInstanceBase.extend({ value: zIPAdapterModelFieldValue, }); -export const zIPAdapterModelFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zIPAdapterModelFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zIPAdapterModelFieldType, default: zIPAdapterModelFieldValue, }); -export const zIPAdapterModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zIPAdapterModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zIPAdapterModelFieldType, }); export type IPAdapterModelFieldType = z.infer; @@ -486,23 +477,21 @@ export const isIPAdapterModelFieldInputInstance = (val: unknown): val is IPAdapt zIPAdapterModelFieldInputInstance.safeParse(val).success; export const isIPAdapterModelFieldInputTemplate = (val: unknown): val is IPAdapterModelFieldInputTemplate => zIPAdapterModelFieldInputTemplate.safeParse(val).success; -export const isIPAdapterModelFieldValue = (val: unknown): val is IPAdapterModelFieldValue => - zIPAdapterModelFieldValue.safeParse(val).success; // #endregion // #region T2IAdapterField -export const zT2IAdapterModelFieldType = zFieldTypeBase.extend({ +const zT2IAdapterModelFieldType = zFieldTypeBase.extend({ name: z.literal('T2IAdapterModelField'), }); export const zT2IAdapterModelFieldValue = zModelIdentifierWithBase.optional(); -export const zT2IAdapterModelFieldInputInstance = zFieldInputInstanceBase.extend({ +const zT2IAdapterModelFieldInputInstance = zFieldInputInstanceBase.extend({ value: zT2IAdapterModelFieldValue, }); -export const zT2IAdapterModelFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zT2IAdapterModelFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zT2IAdapterModelFieldType, default: zT2IAdapterModelFieldValue, }); -export const zT2IAdapterModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zT2IAdapterModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zT2IAdapterModelFieldType, }); export type T2IAdapterModelFieldType = z.infer; @@ -517,18 +506,18 @@ export const isT2IAdapterModelFieldInputTemplate = (val: unknown): val is T2IAda // #endregion // #region SchedulerField -export const zSchedulerFieldType = zFieldTypeBase.extend({ +const zSchedulerFieldType = zFieldTypeBase.extend({ name: z.literal('SchedulerField'), }); export const zSchedulerFieldValue = zSchedulerField.optional(); -export const zSchedulerFieldInputInstance = zFieldInputInstanceBase.extend({ +const zSchedulerFieldInputInstance = zFieldInputInstanceBase.extend({ value: zSchedulerFieldValue, }); -export const zSchedulerFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zSchedulerFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zSchedulerFieldType, default: zSchedulerFieldValue, }); -export const zSchedulerFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zSchedulerFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zSchedulerFieldType, }); export type SchedulerFieldType = z.infer; @@ -554,19 +543,19 @@ export const isSchedulerFieldInputTemplate = (val: unknown): val is SchedulerFie * - Reserved fields like IsIntermediate * - Any other field we don't have full-on schemas for */ -export const zStatelessFieldType = zFieldTypeBase.extend({ +const zStatelessFieldType = zFieldTypeBase.extend({ name: z.string().min(1), // stateless --> we accept the field's name as the type }); -export const zStatelessFieldValue = z.undefined().catch(undefined); // stateless --> no value, but making this z.never() introduces a lot of extra TS fanagling -export const zStatelessFieldInputInstance = zFieldInputInstanceBase.extend({ +const zStatelessFieldValue = z.undefined().catch(undefined); // stateless --> no value, but making this z.never() introduces a lot of extra TS fanagling +const zStatelessFieldInputInstance = zFieldInputInstanceBase.extend({ value: zStatelessFieldValue, }); -export const zStatelessFieldInputTemplate = zFieldInputTemplateBase.extend({ +const zStatelessFieldInputTemplate = zFieldInputTemplateBase.extend({ type: zStatelessFieldType, default: zStatelessFieldValue, input: z.literal('connection'), // stateless --> only accepts connection inputs }); -export const zStatelessFieldOutputTemplate = zFieldOutputTemplateBase.extend({ +const zStatelessFieldOutputTemplate = zFieldOutputTemplateBase.extend({ type: zStatelessFieldType, }); @@ -593,7 +582,7 @@ export type StatelessFieldOutputTemplate = z.infer; export const isStatefulFieldType = (val: unknown): val is StatefulFieldType => zStatefulFieldType.safeParse(val).success; -export const zFieldType = z.union([zStatefulFieldType, zStatelessFieldType]); +const zFieldType = z.union([zStatefulFieldType, zStatelessFieldType]); export type FieldType = z.infer; -export const isFieldType = (val: unknown): val is FieldType => zFieldType.safeParse(val).success; // #endregion // #region StatefulFieldValue & FieldValue @@ -642,16 +630,13 @@ export const zStatefulFieldValue = z.union([ zSchedulerFieldValue, ]); export type StatefulFieldValue = z.infer; -export const isStatefulFieldValue = (val: unknown): val is StatefulFieldValue => - zStatefulFieldValue.safeParse(val).success; -export const zFieldValue = z.union([zStatefulFieldValue, zStatelessFieldValue]); +const zFieldValue = z.union([zStatefulFieldValue, zStatelessFieldValue]); export type FieldValue = z.infer; -export const isFieldValue = (val: unknown): val is FieldValue => zFieldValue.safeParse(val).success; // #endregion // #region StatefulFieldInputInstance & FieldInputInstance -export const zStatefulFieldInputInstance = z.union([ +const zStatefulFieldInputInstance = z.union([ zIntegerFieldInputInstance, zFloatFieldInputInstance, zStringFieldInputInstance, @@ -671,8 +656,6 @@ export const zStatefulFieldInputInstance = z.union([ zSchedulerFieldInputInstance, ]); export type StatefulFieldInputInstance = z.infer; -export const isStatefulFieldInputInstance = (val: unknown): val is StatefulFieldInputInstance => - zStatefulFieldInputInstance.safeParse(val).success; export const zFieldInputInstance = z.union([zStatefulFieldInputInstance, zStatelessFieldInputInstance]); export type FieldInputInstance = z.infer; @@ -681,7 +664,7 @@ export const isFieldInputInstance = (val: unknown): val is FieldInputInstance => // #endregion // #region StatefulFieldInputTemplate & FieldInputTemplate -export const zStatefulFieldInputTemplate = z.union([ +const zStatefulFieldInputTemplate = z.union([ zIntegerFieldInputTemplate, zFloatFieldInputTemplate, zStringFieldInputTemplate, @@ -702,8 +685,6 @@ export const zStatefulFieldInputTemplate = z.union([ zStatelessFieldInputTemplate, ]); export type StatefulFieldInputTemplate = z.infer; -export const isStatefulFieldInputTemplate = (val: unknown): val is StatefulFieldInputTemplate => - zStatefulFieldInputTemplate.safeParse(val).success; export const zFieldInputTemplate = z.union([zStatefulFieldInputTemplate, zStatelessFieldInputTemplate]); export type FieldInputTemplate = z.infer; @@ -712,7 +693,7 @@ export const isFieldInputTemplate = (val: unknown): val is FieldInputTemplate => // #endregion // #region StatefulFieldOutputTemplate & FieldOutputTemplate -export const zStatefulFieldOutputTemplate = z.union([ +const zStatefulFieldOutputTemplate = z.union([ zIntegerFieldOutputTemplate, zFloatFieldOutputTemplate, zStringFieldOutputTemplate, @@ -732,11 +713,7 @@ export const zStatefulFieldOutputTemplate = z.union([ zSchedulerFieldOutputTemplate, ]); export type StatefulFieldOutputTemplate = z.infer; -export const isStatefulFieldOutputTemplate = (val: unknown): val is StatefulFieldOutputTemplate => - zStatefulFieldOutputTemplate.safeParse(val).success; export const zFieldOutputTemplate = z.union([zStatefulFieldOutputTemplate, zStatelessFieldOutputTemplate]); export type FieldOutputTemplate = z.infer; -export const isFieldOutputTemplate = (val: unknown): val is FieldOutputTemplate => - zFieldOutputTemplate.safeParse(val).success; // #endregion diff --git a/invokeai/frontend/web/src/features/nodes/types/invocation.ts b/invokeai/frontend/web/src/features/nodes/types/invocation.ts index 5ccb19430d..52db5de5ee 100644 --- a/invokeai/frontend/web/src/features/nodes/types/invocation.ts +++ b/invokeai/frontend/web/src/features/nodes/types/invocation.ts @@ -6,7 +6,7 @@ import { zFieldInputInstance, zFieldInputTemplate, zFieldOutputTemplate } from ' import { zSemVer } from './semver'; // #region InvocationTemplate -export const zInvocationTemplate = z.object({ +const zInvocationTemplate = z.object({ type: z.string(), title: z.string(), description: z.string(), @@ -43,13 +43,13 @@ export const zNotesNodeData = z.object({ isOpen: z.boolean(), notes: z.string(), }); -export const zCurrentImageNodeData = z.object({ +const zCurrentImageNodeData = z.object({ id: z.string().trim().min(1), type: z.literal('current_image'), label: z.string(), isOpen: z.boolean(), }); -export const zAnyNodeData = z.union([zInvocationNodeData, zNotesNodeData, zCurrentImageNodeData]); +const zAnyNodeData = z.union([zInvocationNodeData, zNotesNodeData, zCurrentImageNodeData]); export type NotesNodeData = z.infer; export type InvocationNodeData = z.infer; @@ -64,15 +64,13 @@ export type AnyNode = Node; export const isInvocationNode = (node?: AnyNode | null): node is InvocationNode => Boolean(node && node.type === 'invocation'); export const isNotesNode = (node?: AnyNode | null): node is NotesNode => Boolean(node && node.type === 'notes'); -export const isCurrentImageNode = (node?: AnyNode | null): node is CurrentImageNode => - Boolean(node && node.type === 'current_image'); export const isInvocationNodeData = (node?: AnyNodeData | null): node is InvocationNodeData => Boolean(node && !['notes', 'current_image'].includes(node.type)); // node.type may be 'notes', 'current_image', or any invocation type // #endregion // #region NodeExecutionState export const zNodeStatus = z.enum(['PENDING', 'IN_PROGRESS', 'COMPLETED', 'FAILED']); -export const zNodeExecutionState = z.object({ +const zNodeExecutionState = z.object({ nodeId: z.string().trim().min(1), status: zNodeStatus, progress: z.number().nullable(), @@ -85,7 +83,7 @@ export type NodeStatus = z.infer; // #endregion // #region Edges -export const zInvocationNodeEdgeExtra = z.object({ +const zInvocationNodeEdgeExtra = z.object({ type: z.union([z.literal('default'), z.literal('collapsed')]), }); export type InvocationNodeEdgeExtra = z.infer; diff --git a/invokeai/frontend/web/src/features/nodes/types/workflow.ts b/invokeai/frontend/web/src/features/nodes/types/workflow.ts index adad7c0f21..6bc6be8cd7 100644 --- a/invokeai/frontend/web/src/features/nodes/types/workflow.ts +++ b/invokeai/frontend/web/src/features/nodes/types/workflow.ts @@ -4,7 +4,7 @@ import { zFieldIdentifier } from './field'; import { zInvocationNodeData, zNotesNodeData } from './invocation'; // #region Workflow misc -export const zXYPosition = z +const zXYPosition = z .object({ x: z.number(), y: z.number(), @@ -12,27 +12,27 @@ export const zXYPosition = z .default({ x: 0, y: 0 }); export type XYPosition = z.infer; -export const zDimension = z.number().gt(0).nullish(); +const zDimension = z.number().gt(0).nullish(); export type Dimension = z.infer; -export const zWorkflowCategory = z.enum(['user', 'default', 'project']); +const zWorkflowCategory = z.enum(['user', 'default', 'project']); export type WorkflowCategory = z.infer; // #endregion // #region Workflow Nodes -export const zWorkflowInvocationNode = z.object({ +const zWorkflowInvocationNode = z.object({ id: z.string().trim().min(1), type: z.literal('invocation'), data: zInvocationNodeData, position: zXYPosition, }); -export const zWorkflowNotesNode = z.object({ +const zWorkflowNotesNode = z.object({ id: z.string().trim().min(1), type: z.literal('notes'), data: zNotesNodeData, position: zXYPosition, }); -export const zWorkflowNode = z.union([zWorkflowInvocationNode, zWorkflowNotesNode]); +const zWorkflowNode = z.union([zWorkflowInvocationNode, zWorkflowNotesNode]); export type WorkflowInvocationNode = z.infer; export type WorkflowNotesNode = z.infer; @@ -43,20 +43,20 @@ export const isWorkflowInvocationNode = (val: unknown): val is WorkflowInvocatio // #endregion // #region Workflow Edges -export const zWorkflowEdgeBase = z.object({ +const zWorkflowEdgeBase = z.object({ id: z.string().trim().min(1), source: z.string().trim().min(1), target: z.string().trim().min(1), }); -export const zWorkflowEdgeDefault = zWorkflowEdgeBase.extend({ +const zWorkflowEdgeDefault = zWorkflowEdgeBase.extend({ type: z.literal('default'), sourceHandle: z.string().trim().min(1), targetHandle: z.string().trim().min(1), }); -export const zWorkflowEdgeCollapsed = zWorkflowEdgeBase.extend({ +const zWorkflowEdgeCollapsed = zWorkflowEdgeBase.extend({ type: z.literal('collapsed'), }); -export const zWorkflowEdge = z.union([zWorkflowEdgeDefault, zWorkflowEdgeCollapsed]); +const zWorkflowEdge = z.union([zWorkflowEdgeDefault, zWorkflowEdgeCollapsed]); export type WorkflowEdgeDefault = z.infer; export type WorkflowEdgeCollapsed = z.infer; diff --git a/invokeai/frontend/web/src/features/nodes/util/graph/buildNodesGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graph/buildNodesGraph.ts index 582aa6b217..130da8bf15 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graph/buildNodesGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graph/buildNodesGraph.ts @@ -1,19 +1,10 @@ import type { NodesState } from 'features/nodes/store/types'; -import type { FieldInputInstance } from 'features/nodes/types/field'; import { isInvocationNode } from 'features/nodes/types/invocation'; import { omit, reduce } from 'lodash-es'; import type { Graph } from 'services/api/types'; import type { AnyInvocation } from 'services/events/types'; import { v4 as uuidv4 } from 'uuid'; -/** - * We need to do special handling for some fields - */ -export const parseFieldValue = (field: FieldInputInstance) => { - // Currently, no special handling is needed. - return field.value; -}; - /** * Builds a graph from the node editor state. */ @@ -31,8 +22,7 @@ export const buildNodesGraph = (nodesState: NodesState): Graph => { const transformedInputs = reduce( inputs, (inputsAccumulator, input, name) => { - const parsedValue = parseFieldValue(input); - inputsAccumulator[name] = parsedValue; + inputsAccumulator[name] = input.value; return inputsAccumulator; }, diff --git a/invokeai/frontend/web/src/features/nodes/util/graph/constants.ts b/invokeai/frontend/web/src/features/nodes/util/graph/constants.ts index 767bf25df0..984f8ae7d6 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graph/constants.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graph/constants.ts @@ -13,58 +13,30 @@ export const NSFW_CHECKER = 'nsfw_checker'; export const WATERMARKER = 'invisible_watermark'; export const NOISE = 'noise'; export const NOISE_HRF = 'noise_hrf'; -export const RANDOM_INT = 'rand_int'; -export const RANGE_OF_SIZE = 'range_of_size'; -export const ITERATE = 'iterate'; export const MAIN_MODEL_LOADER = 'main_model_loader'; export const VAE_LOADER = 'vae_loader'; export const LORA_LOADER = 'lora_loader'; export const CLIP_SKIP = 'clip_skip'; export const IMAGE_TO_LATENTS = 'image_to_latents'; -export const LATENTS_TO_LATENTS = 'latents_to_latents'; export const RESIZE = 'resize_image'; export const IMG2IMG_RESIZE = 'img2img_resize'; export const CANVAS_OUTPUT = 'canvas_output'; export const INPAINT_IMAGE = 'inpaint_image'; -export const SCALED_INPAINT_IMAGE = 'scaled_inpaint_image'; export const INPAINT_IMAGE_RESIZE_UP = 'inpaint_image_resize_up'; export const INPAINT_IMAGE_RESIZE_DOWN = 'inpaint_image_resize_down'; export const INPAINT_INFILL = 'inpaint_infill'; export const INPAINT_INFILL_RESIZE_DOWN = 'inpaint_infill_resize_down'; -export const INPAINT_FINAL_IMAGE = 'inpaint_final_image'; export const INPAINT_CREATE_MASK = 'inpaint_create_mask'; -export const INPAINT_MASK = 'inpaint_mask'; -export const CANVAS_COHERENCE_DENOISE_LATENTS = 'canvas_coherence_denoise_latents'; export const CANVAS_COHERENCE_NOISE = 'canvas_coherence_noise'; -export const CANVAS_COHERENCE_NOISE_INCREMENT = 'canvas_coherence_noise_increment'; -export const CANVAS_COHERENCE_MASK_EDGE = 'canvas_coherence_mask_edge'; -export const CANVAS_COHERENCE_INPAINT_CREATE_MASK = 'canvas_coherence_inpaint_create_mask'; export const MASK_FROM_ALPHA = 'tomask'; -export const MASK_EDGE = 'mask_edge'; -export const MASK_BLUR = 'mask_blur'; export const MASK_COMBINE = 'mask_combine'; export const MASK_RESIZE_UP = 'mask_resize_up'; export const MASK_RESIZE_DOWN = 'mask_resize_down'; -export const COLOR_CORRECT = 'color_correct'; -export const PASTE_IMAGE = 'img_paste'; export const CONTROL_NET_COLLECT = 'control_net_collect'; export const IP_ADAPTER_COLLECT = 'ip_adapter_collect'; export const T2I_ADAPTER_COLLECT = 't2i_adapter_collect'; -export const IP_ADAPTER = 'ip_adapter'; -export const DYNAMIC_PROMPT = 'dynamic_prompt'; -export const IMAGE_COLLECTION = 'image_collection'; -export const IMAGE_COLLECTION_ITERATE = 'image_collection_iterate'; export const METADATA = 'core_metadata'; -export const BATCH_METADATA = 'batch_metadata'; -export const BATCH_METADATA_COLLECT = 'batch_metadata_collect'; -export const BATCH_SEED = 'batch_seed'; -export const BATCH_PROMPT = 'batch_prompt'; -export const BATCH_STYLE_PROMPT = 'batch_style_prompt'; -export const METADATA_COLLECT = 'metadata_collect'; -export const MERGE_METADATA = 'merge_metadata'; export const ESRGAN = 'esrgan'; -export const DIVIDE = 'divide'; -export const SCALE = 'scale_image'; export const SDXL_MODEL_LOADER = 'sdxl_model_loader'; export const SDXL_DENOISE_LATENTS = 'sdxl_denoise_latents'; export const SDXL_REFINER_MODEL_LOADER = 'sdxl_refiner_model_loader'; @@ -75,32 +47,6 @@ export const SDXL_REFINER_INPAINT_CREATE_MASK = 'refiner_inpaint_create_mask'; export const SEAMLESS = 'seamless'; export const SDXL_REFINER_SEAMLESS = 'refiner_seamless'; -// these image-outputting nodes are from the linear UI and we should not handle the gallery logic on them -// instead, we wait for LINEAR_UI_OUTPUT node, and handle it like any other image-outputting node -export const nodeIDDenyList = [ - CANVAS_OUTPUT, - LATENTS_TO_IMAGE, - LATENTS_TO_IMAGE_HRF_HR, - NSFW_CHECKER, - WATERMARKER, - ESRGAN, - ESRGAN_HRF, - RESIZE_HRF, - LATENTS_TO_IMAGE_HRF_LR, - IMG2IMG_RESIZE, - INPAINT_IMAGE, - SCALED_INPAINT_IMAGE, - INPAINT_IMAGE_RESIZE_UP, - INPAINT_IMAGE_RESIZE_DOWN, - INPAINT_INFILL, - INPAINT_INFILL_RESIZE_DOWN, - INPAINT_FINAL_IMAGE, - INPAINT_CREATE_MASK, - INPAINT_MASK, - PASTE_IMAGE, - SCALE, -]; - // friendly graph ids export const TEXT_TO_IMAGE_GRAPH = 'text_to_image_graph'; export const IMAGE_TO_IMAGE_GRAPH = 'image_to_image_graph'; diff --git a/invokeai/frontend/web/src/features/nodes/util/node/nodeUpdate.ts b/invokeai/frontend/web/src/features/nodes/util/node/nodeUpdate.ts index 5ece51d0f3..f720bdd188 100644 --- a/invokeai/frontend/web/src/features/nodes/util/node/nodeUpdate.ts +++ b/invokeai/frontend/web/src/features/nodes/util/node/nodeUpdate.ts @@ -11,13 +11,14 @@ export const getNeedsUpdate = (node: InvocationNode, template: InvocationTemplat return true; } return node.data.version !== template.version; -}; /** +}; + +/** * Checks if a node may be updated by comparing its major version with the template's major version. * @param node The node to check. * @param template The invocation template to check against. */ - -export const getMayUpdateNode = (node: InvocationNode, template: InvocationTemplate): boolean => { +const getMayUpdateNode = (node: InvocationNode, template: InvocationTemplate): boolean => { const needsUpdate = getNeedsUpdate(node, template); if (!needsUpdate || node.data.type !== template.type) { return false; @@ -25,7 +26,9 @@ export const getMayUpdateNode = (node: InvocationNode, template: InvocationTempl const templateMajor = zParsedSemver.parse(template.version).major; return satisfies(node.data.version, `^${templateMajor}`); -}; /** +}; + +/** * Updates a node to the latest version of its template: * - Create a new node data object with the latest version of the template. * - Recursively merge new node data object into the node to be updated. @@ -34,7 +37,6 @@ export const getMayUpdateNode = (node: InvocationNode, template: InvocationTempl * @param template The invocation template to update to. * @throws {NodeUpdateError} If the node is not an invocation node. */ - export const updateNode = (node: InvocationNode, template: InvocationTemplate): InvocationNode => { const mayUpdate = getMayUpdateNode(node, template); diff --git a/invokeai/frontend/web/src/features/parameters/components/Canvas/Compositing/MaskAdjustment/ParamMaskBlurMethod.tsx b/invokeai/frontend/web/src/features/parameters/components/Canvas/Compositing/MaskAdjustment/ParamMaskBlurMethod.tsx deleted file mode 100644 index 95b402a1c8..0000000000 --- a/invokeai/frontend/web/src/features/parameters/components/Canvas/Compositing/MaskAdjustment/ParamMaskBlurMethod.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import type { ComboboxOnChange, ComboboxOption } from '@invoke-ai/ui-library'; -import { Combobox, FormControl, FormLabel } from '@invoke-ai/ui-library'; -import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; -import { InformationalPopover } from 'common/components/InformationalPopover/InformationalPopover'; -import { setMaskBlurMethod } from 'features/parameters/store/generationSlice'; -import { isParameterMaskBlurMethod } from 'features/parameters/types/parameterSchemas'; -import { memo, useCallback, useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; - -const ParamMaskBlurMethod = () => { - const maskBlurMethod = useAppSelector((s) => s.generation.maskBlurMethod); - const dispatch = useAppDispatch(); - const { t } = useTranslation(); - - const options: ComboboxOption[] = useMemo( - () => [ - { label: t('parameters.boxBlur'), value: 'box' }, - { label: t('parameters.gaussianBlur'), value: 'gaussian' }, - ], - [t] - ); - - const onChange = useCallback( - (v) => { - if (!isParameterMaskBlurMethod(v?.value)) { - return; - } - dispatch(setMaskBlurMethod(v.value)); - }, - [dispatch] - ); - - const value = useMemo(() => options.find((o) => o.value === maskBlurMethod), [maskBlurMethod, options]); - - return ( - - - {t('parameters.maskBlurMethod')} - - - - ); -}; - -export default memo(ParamMaskBlurMethod); diff --git a/invokeai/frontend/web/src/features/parameters/components/Canvas/InfillAndScaling/ParamScaleBeforeProcessing.tsx b/invokeai/frontend/web/src/features/parameters/components/Canvas/InfillAndScaling/ParamScaleBeforeProcessing.tsx index ade66c2b57..759f541905 100644 --- a/invokeai/frontend/web/src/features/parameters/components/Canvas/InfillAndScaling/ParamScaleBeforeProcessing.tsx +++ b/invokeai/frontend/web/src/features/parameters/components/Canvas/InfillAndScaling/ParamScaleBeforeProcessing.tsx @@ -8,7 +8,7 @@ import { selectOptimalDimension } from 'features/parameters/store/generationSlic import { memo, useCallback, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; -export const OPTIONS: ComboboxOption[] = [ +const OPTIONS: ComboboxOption[] = [ { label: 'None', value: 'none' }, { label: 'Auto', value: 'auto' }, { label: 'Manual', value: 'manual' }, diff --git a/invokeai/frontend/web/src/features/parameters/components/ImageSize/constants.ts b/invokeai/frontend/web/src/features/parameters/components/ImageSize/constants.ts index 133ca1e1ca..b8c46005e6 100644 --- a/invokeai/frontend/web/src/features/parameters/components/ImageSize/constants.ts +++ b/invokeai/frontend/web/src/features/parameters/components/ImageSize/constants.ts @@ -5,8 +5,8 @@ import type { AspectRatioID, AspectRatioState } from './types'; // When the aspect ratio is between these two values, we show the icon (experimentally determined) export const ICON_LOW_CUTOFF = 0.23; export const ICON_HIGH_CUTOFF = 1 / ICON_LOW_CUTOFF; -export const ICON_SIZE_PX = 64; -export const ICON_PADDING_PX = 16; +const ICON_SIZE_PX = 64; +const ICON_PADDING_PX = 16; export const BOX_SIZE_CSS_CALC = `min(${ICON_SIZE_PX}px, calc(100% - ${ICON_PADDING_PX}px))`; export const MOTION_ICON_INITIAL = { opacity: 0, diff --git a/invokeai/frontend/web/src/features/parameters/components/ImageSize/hooks.ts b/invokeai/frontend/web/src/features/parameters/components/ImageSize/hooks.ts deleted file mode 100644 index bc6f1019c6..0000000000 --- a/invokeai/frontend/web/src/features/parameters/components/ImageSize/hooks.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { useMemo } from 'react'; - -import { ICON_HIGH_CUTOFF, ICON_LOW_CUTOFF } from './constants'; - -type Dimensions = { - width: number; - height: number; -}; - -type UseAspectRatioPreviewStateArg = { - width: number; - height: number; - containerSize?: Dimensions; -}; -type UseAspectRatioPreviewState = (arg: UseAspectRatioPreviewStateArg) => Dimensions & { shouldShowIcon: boolean }; - -export const useAspectRatioPreviewState: UseAspectRatioPreviewState = ({ - width: _width, - height: _height, - containerSize, -}) => { - const dimensions = useMemo(() => { - if (!containerSize) { - return { width: 0, height: 0, shouldShowIcon: false }; - } - - const aspectRatio = _width / _height; - let width = _width; - let height = _height; - - if (_width > _height) { - width = containerSize.width; - height = width / aspectRatio; - } else { - height = containerSize.height; - width = height * aspectRatio; - } - - const shouldShowIcon = aspectRatio < ICON_HIGH_CUTOFF && aspectRatio > ICON_LOW_CUTOFF; - - return { width, height, shouldShowIcon }; - }, [_height, _width, containerSize]); - - return dimensions; -}; diff --git a/invokeai/frontend/web/src/features/parameters/components/ImageSize/types.ts b/invokeai/frontend/web/src/features/parameters/components/ImageSize/types.ts index 73322187ff..f219eb9a1a 100644 --- a/invokeai/frontend/web/src/features/parameters/components/ImageSize/types.ts +++ b/invokeai/frontend/web/src/features/parameters/components/ImageSize/types.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; -export const zAspectRatioID = z.enum(['Free', '16:9', '3:2', '4:3', '1:1', '3:4', '2:3', '9:16']); +const zAspectRatioID = z.enum(['Free', '16:9', '3:2', '4:3', '1:1', '3:4', '2:3', '9:16']); export type AspectRatioID = z.infer; export const isAspectRatioID = (v: string): v is AspectRatioID => zAspectRatioID.safeParse(v).success; diff --git a/invokeai/frontend/web/src/features/parameters/hooks/useCoreParametersCollapseLabel.ts b/invokeai/frontend/web/src/features/parameters/hooks/useCoreParametersCollapseLabel.ts deleted file mode 100644 index 794f841451..0000000000 --- a/invokeai/frontend/web/src/features/parameters/hooks/useCoreParametersCollapseLabel.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { useAppSelector } from 'app/store/storeHooks'; -import { useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; - -export const useCoreParametersCollapseLabel = () => { - const { t } = useTranslation(); - const shouldRandomizeSeed = useAppSelector((s) => s.generation.shouldRandomizeSeed); - const iterations = useAppSelector((s) => s.generation.iterations); - - const iterationsLabel = useMemo(() => { - if (iterations === 1) { - return t('parameters.iterationsWithCount_one', { count: 1 }); - } else { - return t('parameters.iterationsWithCount_other', { count: iterations }); - } - }, [iterations, t]); - - const seedLabel = useMemo(() => { - if (shouldRandomizeSeed) { - return t('parameters.randomSeed'); - } else { - return t('parameters.manualSeed'); - } - }, [shouldRandomizeSeed, t]); - - const iterationsAndSeedLabel = useMemo(() => [iterationsLabel, seedLabel].join(', '), [iterationsLabel, seedLabel]); - - return { iterationsAndSeedLabel, iterationsLabel, seedLabel }; -}; diff --git a/invokeai/frontend/web/src/features/parameters/store/generationSlice.ts b/invokeai/frontend/web/src/features/parameters/store/generationSlice.ts index 4041490345..061a291bad 100644 --- a/invokeai/frontend/web/src/features/parameters/store/generationSlice.ts +++ b/invokeai/frontend/web/src/features/parameters/store/generationSlice.ts @@ -11,7 +11,6 @@ import type { ParameterCanvasCoherenceMode, ParameterCFGRescaleMultiplier, ParameterCFGScale, - ParameterMaskBlurMethod, ParameterModel, ParameterPrecision, ParameterScheduler, @@ -25,7 +24,7 @@ import type { ImageDTO } from 'services/api/types'; import type { GenerationState } from './types'; -export const initialGenerationState: GenerationState = { +const initialGenerationState: GenerationState = { _version: 1, cfgScale: 7.5, cfgRescaleMultiplier: 0, @@ -100,27 +99,12 @@ export const generationSlice = createSlice({ setShouldFitToWidthHeight: (state, action: PayloadAction) => { state.shouldFitToWidthHeight = action.payload; }, - resetSeed: (state) => { - state.seed = -1; - }, - resetParametersState: (state) => { - return { - ...state, - ...initialGenerationState, - }; - }, setShouldRandomizeSeed: (state, action: PayloadAction) => { state.shouldRandomizeSeed = action.payload; }, clearInitialImage: (state) => { state.initialImage = undefined; }, - setMaskBlur: (state, action: PayloadAction) => { - state.maskBlur = action.payload; - }, - setMaskBlurMethod: (state, action: PayloadAction) => { - state.maskBlurMethod = action.payload; - }, setCanvasCoherenceMode: (state, action: PayloadAction) => { state.canvasCoherenceMode = action.payload; }, @@ -261,8 +245,6 @@ export const generationSlice = createSlice({ export const { clearInitialImage, - resetParametersState, - resetSeed, setCfgScale, setCfgRescaleMultiplier, setImg2imgStrength, @@ -271,8 +253,6 @@ export const { setPositivePrompt, setNegativePrompt, setScheduler, - setMaskBlur, - setMaskBlurMethod, setCanvasCoherenceMode, setCanvasCoherenceEdgeSize, setCanvasCoherenceMinDenoise, @@ -302,7 +282,7 @@ export const { selectOptimalDimension } = generationSlice.selectors; export const selectGenerationSlice = (state: RootState) => state.generation; /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ -export const migrateGenerationState = (state: any): GenerationState => { +const migrateGenerationState = (state: any): GenerationState => { if (!('_version' in state)) { state._version = 1; state.aspectRatio = initialAspectRatioState; diff --git a/invokeai/frontend/web/src/features/queue/hooks/useIsQueueEmpty.ts b/invokeai/frontend/web/src/features/queue/hooks/useIsQueueEmpty.ts deleted file mode 100644 index c0a32c1eb3..0000000000 --- a/invokeai/frontend/web/src/features/queue/hooks/useIsQueueEmpty.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { useGetQueueStatusQuery } from 'services/api/endpoints/queue'; - -export const useIsQueueEmpty = () => { - const { isEmpty } = useGetQueueStatusQuery(undefined, { - selectFromResult: ({ data }) => { - if (!data) { - return { isEmpty: true }; - } - return { - isEmpty: data.queue.in_progress === 0 && data.queue.pending === 0, - }; - }, - }); - return isEmpty; -}; diff --git a/invokeai/frontend/web/src/features/system/components/SettingsModal/StyledFlex.tsx b/invokeai/frontend/web/src/features/system/components/SettingsModal/StyledFlex.tsx deleted file mode 100644 index 2b2d548323..0000000000 --- a/invokeai/frontend/web/src/features/system/components/SettingsModal/StyledFlex.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { Flex } from '@invoke-ai/ui-library'; -import type { PropsWithChildren } from 'react'; -import { memo } from 'react'; - -const StyledFlex = (props: PropsWithChildren) => { - return ( - - {props.children} - - ); -}; - -export default memo(StyledFlex);