From 7bd9bf3ba541fe8105e79461fb21b0e4e82a4a2e Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 27 Feb 2024 16:36:30 +1100 Subject: [PATCH] tidy(ui): clean up unused code 2 types and schemas --- .../src/features/nodes/types/common.test-d.ts | 15 ------- .../web/src/features/nodes/types/common.ts | 44 ------------------- .../web/src/features/nodes/types/constants.ts | 8 ---- .../web/src/features/nodes/types/field.ts | 19 +++----- 4 files changed, 7 insertions(+), 79 deletions(-) diff --git a/invokeai/frontend/web/src/features/nodes/types/common.test-d.ts b/invokeai/frontend/web/src/features/nodes/types/common.test-d.ts index 5e92998657..13c3db52fd 100644 --- a/invokeai/frontend/web/src/features/nodes/types/common.test-d.ts +++ b/invokeai/frontend/web/src/features/nodes/types/common.test-d.ts @@ -7,14 +7,9 @@ import type { ImageField, ImageOutput, IPAdapterField, - ModelInfo, - ModelType, ProgressImage, SchedulerField, - SDXLRefinerModelField, - SubModelType, T2IAdapterField, - VAEField, } from 'features/nodes/types/common'; import type { S } from 'services/api/types'; import type { Equals, Extends } from 'tsafe'; @@ -32,23 +27,13 @@ describe('Common types', () => { test('BoardField', () => assert>()); test('ColorField', () => assert>()); test('SchedulerField', () => assert>>()); - // test('MainModelField', () => assert>()); - test('SDXLRefinerModelField', () => assert>()); - test('VAEField', () => assert>()); test('ControlField', () => assert>()); // @ts-expect-error TODO(psyche): fix types test('IPAdapterField', () => assert>()); test('T2IAdapterField', () => assert>()); - // test('LoRAModelField', () => assert>()); - // test('ControlNetModelField', () => assert>()); - // test('IPAdapterModelField', () => assert>()); - // test('T2IAdapterModelField', () => assert>()); // Model component types test('BaseModel', () => assert>()); - test('ModelType', () => assert>()); - test('SubModelType', () => assert>()); - test('ModelInfo', () => assert>()); // Misc types // @ts-expect-error TODO(psyche): There is no `ProgressImage` in the server types yet diff --git a/invokeai/frontend/web/src/features/nodes/types/common.ts b/invokeai/frontend/web/src/features/nodes/types/common.ts index 923fef3c04..461e804db3 100644 --- a/invokeai/frontend/web/src/features/nodes/types/common.ts +++ b/invokeai/frontend/web/src/features/nodes/types/common.ts @@ -64,7 +64,6 @@ export const zModelType = z.enum([ 'ip_adapter', 'clip_vision', 't2i_adapter', - 'onnx', // TODO(psyche): Remove this when removed from backend ]); export const zModelName = z.string().min(3); export const zModelIdentifier = z.object({ @@ -80,49 +79,6 @@ export type BaseModel = z.infer; export type ModelType = z.infer; export type ModelIdentifier = z.infer; export type ModelIdentifierWithBase = z.infer; -export const zMainModelField = zModelIdentifierWithBase; -export type MainModelField = z.infer; - -export const zSDXLRefinerModelField = zModelIdentifier; -export type SDXLRefinerModelField = z.infer; - -export const zSubModelType = z.enum([ - 'unet', - 'text_encoder', - 'text_encoder_2', - 'tokenizer', - 'tokenizer_2', - 'vae', - 'vae_decoder', - 'vae_encoder', - 'scheduler', - 'safety_checker', -]); -export type SubModelType = z.infer; - -export const zVAEModelField = zModelIdentifierWithBase; - -const zModelInfo = zModelIdentifier.extend({ - submodel_type: zSubModelType.nullish(), -}); -export type ModelInfo = z.infer; - -export const zLoRAModelField = zModelIdentifierWithBase; -export type LoRAModelField = z.infer; - -export const zControlNetModelField = zModelIdentifierWithBase; -export type ControlNetModelField = z.infer; - -export const zIPAdapterModelField = zModelIdentifierWithBase; -export type IPAdapterModelField = z.infer; - -export const zT2IAdapterModelField = zModelIdentifierWithBase; -export type T2IAdapterModelField = z.infer; - -export const zVAEField = z.object({ - vae: zModelInfo, -}); -export type VAEField = z.infer; // #endregion // #region Control Adapters diff --git a/invokeai/frontend/web/src/features/nodes/types/constants.ts b/invokeai/frontend/web/src/features/nodes/types/constants.ts index 35ef9e9fd2..0100c0df7d 100644 --- a/invokeai/frontend/web/src/features/nodes/types/constants.ts +++ b/invokeai/frontend/web/src/features/nodes/types/constants.ts @@ -23,14 +23,6 @@ export const SHARED_NODE_PROPERTIES: Partial = { dragHandle: `.${DRAG_HANDLE_CLASSNAME}`, }; -/** - * Helper for getting the kind of a field. - */ -export const KIND_MAP = { - input: 'inputs' as const, - output: 'outputs' as const, -}; - /** * Model types' handles are rendered as squares in the UI. */ diff --git a/invokeai/frontend/web/src/features/nodes/types/field.ts b/invokeai/frontend/web/src/features/nodes/types/field.ts index aa6164d6e5..e630d59e07 100644 --- a/invokeai/frontend/web/src/features/nodes/types/field.ts +++ b/invokeai/frontend/web/src/features/nodes/types/field.ts @@ -3,14 +3,9 @@ import { z } from 'zod'; import { zBoardField, zColorField, - zControlNetModelField, zImageField, - zIPAdapterModelField, - zLoRAModelField, - zMainModelField, + zModelIdentifierWithBase, zSchedulerField, - zT2IAdapterModelField, - zVAEModelField, } from './common'; /** @@ -313,7 +308,7 @@ export const isColorFieldInputTemplate = (val: unknown): val is ColorFieldInputT export const zMainModelFieldType = zFieldTypeBase.extend({ name: z.literal('MainModelField'), }); -export const zMainModelFieldValue = zMainModelField.optional(); +export const zMainModelFieldValue = zModelIdentifierWithBase.optional(); export const zMainModelFieldInputInstance = zFieldInputInstanceBase.extend({ value: zMainModelFieldValue, }); @@ -391,7 +386,7 @@ export const isSDXLRefinerModelFieldInputTemplate = (val: unknown): val is SDXLR export const zVAEModelFieldType = zFieldTypeBase.extend({ name: z.literal('VAEModelField'), }); -export const zVAEModelFieldValue = zVAEModelField.optional(); +export const zVAEModelFieldValue = zModelIdentifierWithBase.optional(); export const zVAEModelFieldInputInstance = zFieldInputInstanceBase.extend({ value: zVAEModelFieldValue, }); @@ -417,7 +412,7 @@ export const isVAEModelFieldInputTemplate = (val: unknown): val is VAEModelField export const zLoRAModelFieldType = zFieldTypeBase.extend({ name: z.literal('LoRAModelField'), }); -export const zLoRAModelFieldValue = zLoRAModelField.optional(); +export const zLoRAModelFieldValue = zModelIdentifierWithBase.optional(); export const zLoRAModelFieldInputInstance = zFieldInputInstanceBase.extend({ value: zLoRAModelFieldValue, }); @@ -443,7 +438,7 @@ export const isLoRAModelFieldInputTemplate = (val: unknown): val is LoRAModelFie export const zControlNetModelFieldType = zFieldTypeBase.extend({ name: z.literal('ControlNetModelField'), }); -export const zControlNetModelFieldValue = zControlNetModelField.optional(); +export const zControlNetModelFieldValue = zModelIdentifierWithBase.optional(); export const zControlNetModelFieldInputInstance = zFieldInputInstanceBase.extend({ value: zControlNetModelFieldValue, }); @@ -471,7 +466,7 @@ export const isControlNetModelFieldValue = (v: unknown): v is ControlNetModelFie export const zIPAdapterModelFieldType = zFieldTypeBase.extend({ name: z.literal('IPAdapterModelField'), }); -export const zIPAdapterModelFieldValue = zIPAdapterModelField.optional(); +export const zIPAdapterModelFieldValue = zModelIdentifierWithBase.optional(); export const zIPAdapterModelFieldInputInstance = zFieldInputInstanceBase.extend({ value: zIPAdapterModelFieldValue, }); @@ -499,7 +494,7 @@ export const isIPAdapterModelFieldValue = (val: unknown): val is IPAdapterModelF export const zT2IAdapterModelFieldType = zFieldTypeBase.extend({ name: z.literal('T2IAdapterModelField'), }); -export const zT2IAdapterModelFieldValue = zT2IAdapterModelField.optional(); +export const zT2IAdapterModelFieldValue = zModelIdentifierWithBase.optional(); export const zT2IAdapterModelFieldInputInstance = zFieldInputInstanceBase.extend({ value: zT2IAdapterModelFieldValue, });