mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
tidy(ui): clean up unused code 6
unused files
This commit is contained in:
parent
d435a479f1
commit
4a506eb0a7
@ -1,80 +0,0 @@
|
|||||||
import type { Node } from 'reactflow';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* How long to wait before showing a tooltip when hovering a field handle.
|
|
||||||
*/
|
|
||||||
export const HANDLE_TOOLTIP_OPEN_DELAY = 500;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The width of a node in the UI in pixels.
|
|
||||||
*/
|
|
||||||
export const NODE_WIDTH = 320;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class name is special - reactflow uses it to identify the drag handle of a node,
|
|
||||||
* applying the appropriate listeners to it.
|
|
||||||
*/
|
|
||||||
export const DRAG_HANDLE_CLASSNAME = 'node-drag-handle';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* reactflow-specifc properties shared between all node types.
|
|
||||||
*/
|
|
||||||
export const SHARED_NODE_PROPERTIES: Partial<Node> = {
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
export const MODEL_TYPES = [
|
|
||||||
'IPAdapterModelField',
|
|
||||||
'ControlNetModelField',
|
|
||||||
'LoRAModelField',
|
|
||||||
'MainModelField',
|
|
||||||
'SDXLMainModelField',
|
|
||||||
'SDXLRefinerModelField',
|
|
||||||
'VaeModelField',
|
|
||||||
'UNetField',
|
|
||||||
'VaeField',
|
|
||||||
'ClipField',
|
|
||||||
'T2IAdapterModelField',
|
|
||||||
'IPAdapterModelField',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Colors for each field type - applies to their handles and edges.
|
|
||||||
*/
|
|
||||||
export const FIELD_COLORS: { [key: string]: string } = {
|
|
||||||
BoardField: 'purple.500',
|
|
||||||
BooleanField: 'green.500',
|
|
||||||
ClipField: 'green.500',
|
|
||||||
ColorField: 'pink.300',
|
|
||||||
ConditioningField: 'cyan.500',
|
|
||||||
ControlField: 'teal.500',
|
|
||||||
ControlNetModelField: 'teal.500',
|
|
||||||
EnumField: 'blue.500',
|
|
||||||
FloatField: 'orange.500',
|
|
||||||
ImageField: 'purple.500',
|
|
||||||
IntegerField: 'red.500',
|
|
||||||
IPAdapterField: 'teal.500',
|
|
||||||
IPAdapterModelField: 'teal.500',
|
|
||||||
LatentsField: 'pink.500',
|
|
||||||
LoRAModelField: 'teal.500',
|
|
||||||
MainModelField: 'teal.500',
|
|
||||||
SDXLMainModelField: 'teal.500',
|
|
||||||
SDXLRefinerModelField: 'teal.500',
|
|
||||||
StringField: 'yellow.500',
|
|
||||||
T2IAdapterField: 'teal.500',
|
|
||||||
T2IAdapterModelField: 'teal.500',
|
|
||||||
UNetField: 'red.500',
|
|
||||||
VaeField: 'blue.500',
|
|
||||||
VaeModelField: 'teal.500',
|
|
||||||
};
|
|
@ -1,58 +0,0 @@
|
|||||||
/**
|
|
||||||
* Invalid Workflow Version Error
|
|
||||||
* Raised when a workflow version is not recognized.
|
|
||||||
*/
|
|
||||||
export class WorkflowVersionError extends Error {
|
|
||||||
/**
|
|
||||||
* Create WorkflowVersionError
|
|
||||||
* @param {String} message
|
|
||||||
*/
|
|
||||||
constructor(message: string) {
|
|
||||||
super(message);
|
|
||||||
this.name = this.constructor.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Workflow Migration Error
|
|
||||||
* Raised when a workflow migration fails.
|
|
||||||
*/
|
|
||||||
export class WorkflowMigrationError extends Error {
|
|
||||||
/**
|
|
||||||
* Create WorkflowMigrationError
|
|
||||||
* @param {String} message
|
|
||||||
*/
|
|
||||||
constructor(message: string) {
|
|
||||||
super(message);
|
|
||||||
this.name = this.constructor.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unable to Update Node Error
|
|
||||||
* Raised when a node cannot be updated.
|
|
||||||
*/
|
|
||||||
export class NodeUpdateError extends Error {
|
|
||||||
/**
|
|
||||||
* Create NodeUpdateError
|
|
||||||
* @param {String} message
|
|
||||||
*/
|
|
||||||
constructor(message: string) {
|
|
||||||
super(message);
|
|
||||||
this.name = this.constructor.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* FieldParseError
|
|
||||||
* Raised when a field cannot be parsed from a field schema.
|
|
||||||
*/
|
|
||||||
export class FieldParseError extends Error {
|
|
||||||
/**
|
|
||||||
* Create FieldTypeParseError
|
|
||||||
* @param {String} message
|
|
||||||
*/
|
|
||||||
constructor(message: string) {
|
|
||||||
super(message);
|
|
||||||
this.name = this.constructor.name;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
import { z } from 'zod';
|
|
||||||
|
|
||||||
import {
|
|
||||||
zControlField,
|
|
||||||
zIPAdapterField,
|
|
||||||
zLoRAModelField,
|
|
||||||
zMainModelField,
|
|
||||||
zSDXLRefinerModelField,
|
|
||||||
zT2IAdapterField,
|
|
||||||
zVAEModelField,
|
|
||||||
} from './common';
|
|
||||||
|
|
||||||
// #region Metadata-optimized versions of schemas
|
|
||||||
// TODO: It's possible that `deepPartial` will be deprecated:
|
|
||||||
// - https://github.com/colinhacks/zod/issues/2106
|
|
||||||
// - https://github.com/colinhacks/zod/issues/2854
|
|
||||||
export const zLoRAMetadataItem = z.object({
|
|
||||||
lora: zLoRAModelField.deepPartial(),
|
|
||||||
weight: z.number(),
|
|
||||||
});
|
|
||||||
const zControlNetMetadataItem = zControlField.deepPartial();
|
|
||||||
const zIPAdapterMetadataItem = zIPAdapterField.deepPartial();
|
|
||||||
const zT2IAdapterMetadataItem = zT2IAdapterField.deepPartial();
|
|
||||||
const zSDXLRefinerModelMetadataItem = zSDXLRefinerModelField.deepPartial();
|
|
||||||
const zModelMetadataItem = zMainModelField.deepPartial();
|
|
||||||
const zVAEModelMetadataItem = zVAEModelField.deepPartial();
|
|
||||||
export type LoRAMetadataItem = z.infer<typeof zLoRAMetadataItem>;
|
|
||||||
export type ControlNetMetadataItem = z.infer<typeof zControlNetMetadataItem>;
|
|
||||||
export type IPAdapterMetadataItem = z.infer<typeof zIPAdapterMetadataItem>;
|
|
||||||
export type T2IAdapterMetadataItem = z.infer<typeof zT2IAdapterMetadataItem>;
|
|
||||||
export type SDXLRefinerModelMetadataItem = z.infer<typeof zSDXLRefinerModelMetadataItem>;
|
|
||||||
export type ModelMetadataItem = z.infer<typeof zModelMetadataItem>;
|
|
||||||
export type VAEModelMetadataItem = z.infer<typeof zVAEModelMetadataItem>;
|
|
||||||
// #endregion
|
|
||||||
|
|
||||||
// #region CoreMetadata
|
|
||||||
export const zCoreMetadata = z
|
|
||||||
.object({
|
|
||||||
app_version: z.string().nullish().catch(null),
|
|
||||||
generation_mode: z.string().nullish().catch(null),
|
|
||||||
created_by: z.string().nullish().catch(null),
|
|
||||||
positive_prompt: z.string().nullish().catch(null),
|
|
||||||
negative_prompt: z.string().nullish().catch(null),
|
|
||||||
width: z.number().int().nullish().catch(null),
|
|
||||||
height: z.number().int().nullish().catch(null),
|
|
||||||
seed: z.number().int().nullish().catch(null),
|
|
||||||
rand_device: z.string().nullish().catch(null),
|
|
||||||
cfg_scale: z.number().nullish().catch(null),
|
|
||||||
cfg_rescale_multiplier: z.number().nullish().catch(null),
|
|
||||||
steps: z.number().int().nullish().catch(null),
|
|
||||||
scheduler: z.string().nullish().catch(null),
|
|
||||||
clip_skip: z.number().int().nullish().catch(null),
|
|
||||||
model: zModelMetadataItem.nullish().catch(null),
|
|
||||||
controlnets: z.array(zControlNetMetadataItem).nullish().catch(null),
|
|
||||||
ipAdapters: z.array(zIPAdapterMetadataItem).nullish().catch(null),
|
|
||||||
t2iAdapters: z.array(zT2IAdapterMetadataItem).nullish().catch(null),
|
|
||||||
loras: z.array(zLoRAMetadataItem).nullish().catch(null),
|
|
||||||
vae: zVAEModelMetadataItem.nullish().catch(null),
|
|
||||||
strength: z.number().nullish().catch(null),
|
|
||||||
hrf_enabled: z.boolean().nullish().catch(null),
|
|
||||||
hrf_strength: z.number().nullish().catch(null),
|
|
||||||
hrf_method: z.string().nullish().catch(null),
|
|
||||||
init_image: z.string().nullish().catch(null),
|
|
||||||
positive_style_prompt: z.string().nullish().catch(null),
|
|
||||||
negative_style_prompt: z.string().nullish().catch(null),
|
|
||||||
refiner_model: zSDXLRefinerModelMetadataItem.nullish().catch(null),
|
|
||||||
refiner_cfg_scale: z.number().nullish().catch(null),
|
|
||||||
refiner_steps: z.number().int().nullish().catch(null),
|
|
||||||
refiner_scheduler: z.string().nullish().catch(null),
|
|
||||||
refiner_positive_aesthetic_score: z.number().nullish().catch(null),
|
|
||||||
refiner_negative_aesthetic_score: z.number().nullish().catch(null),
|
|
||||||
refiner_start: z.number().nullish().catch(null),
|
|
||||||
})
|
|
||||||
.passthrough();
|
|
||||||
export type CoreMetadata = z.infer<typeof zCoreMetadata>;
|
|
||||||
|
|
||||||
// #endregion
|
|
@ -1,86 +0,0 @@
|
|||||||
import type { OpenAPIV3_1 } from 'openapi-types';
|
|
||||||
import type {
|
|
||||||
InputFieldJSONSchemaExtra,
|
|
||||||
InvocationJSONSchemaExtra,
|
|
||||||
OutputFieldJSONSchemaExtra,
|
|
||||||
} from 'services/api/types';
|
|
||||||
|
|
||||||
// Janky customization of OpenAPI Schema :/
|
|
||||||
|
|
||||||
export type InvocationSchemaExtra = InvocationJSONSchemaExtra & {
|
|
||||||
output: OpenAPIV3_1.ReferenceObject; // the output of the invocation
|
|
||||||
title: string;
|
|
||||||
category?: string;
|
|
||||||
tags?: string[];
|
|
||||||
version: string;
|
|
||||||
properties: Omit<
|
|
||||||
NonNullable<OpenAPIV3_1.SchemaObject['properties']> & (InputFieldJSONSchemaExtra | OutputFieldJSONSchemaExtra),
|
|
||||||
'type'
|
|
||||||
> & {
|
|
||||||
type: Omit<OpenAPIV3_1.SchemaObject, 'default'> & {
|
|
||||||
default: string;
|
|
||||||
};
|
|
||||||
use_cache: Omit<OpenAPIV3_1.SchemaObject, 'default'> & {
|
|
||||||
default: boolean;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export type InvocationSchemaType = {
|
|
||||||
default: string; // the type of the invocation
|
|
||||||
};
|
|
||||||
|
|
||||||
export type InvocationBaseSchemaObject = Omit<OpenAPIV3_1.BaseSchemaObject, 'title' | 'type' | 'properties'> &
|
|
||||||
InvocationSchemaExtra;
|
|
||||||
|
|
||||||
export type InvocationOutputSchemaObject = Omit<OpenAPIV3_1.SchemaObject, 'properties'> & {
|
|
||||||
properties: OpenAPIV3_1.SchemaObject['properties'] & {
|
|
||||||
type: Omit<OpenAPIV3_1.SchemaObject, 'default'> & {
|
|
||||||
default: string;
|
|
||||||
};
|
|
||||||
} & {
|
|
||||||
class: 'output';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export type InvocationFieldSchema = OpenAPIV3_1.SchemaObject & InputFieldJSONSchemaExtra;
|
|
||||||
|
|
||||||
export type OpenAPIV3_1SchemaOrRef = OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject;
|
|
||||||
|
|
||||||
export interface ArraySchemaObject extends InvocationBaseSchemaObject {
|
|
||||||
type: OpenAPIV3_1.ArraySchemaObjectType;
|
|
||||||
items: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject;
|
|
||||||
}
|
|
||||||
export interface NonArraySchemaObject extends InvocationBaseSchemaObject {
|
|
||||||
type?: OpenAPIV3_1.NonArraySchemaObjectType;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type InvocationSchemaObject = (ArraySchemaObject | NonArraySchemaObject) & { class: 'invocation' };
|
|
||||||
|
|
||||||
export const isSchemaObject = (
|
|
||||||
obj: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject | undefined
|
|
||||||
): obj is OpenAPIV3_1.SchemaObject => Boolean(obj && !('$ref' in obj));
|
|
||||||
|
|
||||||
export const isArraySchemaObject = (
|
|
||||||
obj: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject | undefined
|
|
||||||
): obj is OpenAPIV3_1.ArraySchemaObject => Boolean(obj && !('$ref' in obj) && obj.type === 'array');
|
|
||||||
|
|
||||||
export const isNonArraySchemaObject = (
|
|
||||||
obj: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject | undefined
|
|
||||||
): obj is OpenAPIV3_1.NonArraySchemaObject => Boolean(obj && !('$ref' in obj) && obj.type !== 'array');
|
|
||||||
|
|
||||||
export const isRefObject = (
|
|
||||||
obj: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject | undefined
|
|
||||||
): obj is OpenAPIV3_1.ReferenceObject => Boolean(obj && '$ref' in obj);
|
|
||||||
|
|
||||||
export const isInvocationSchemaObject = (
|
|
||||||
obj: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject | InvocationSchemaObject
|
|
||||||
): obj is InvocationSchemaObject => 'class' in obj && obj.class === 'invocation';
|
|
||||||
|
|
||||||
export const isInvocationOutputSchemaObject = (
|
|
||||||
obj: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject | InvocationOutputSchemaObject
|
|
||||||
): obj is InvocationOutputSchemaObject => 'class' in obj && obj.class === 'output';
|
|
||||||
|
|
||||||
export const isInvocationFieldSchema = (
|
|
||||||
obj: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject
|
|
||||||
): obj is InvocationFieldSchema => !('$ref' in obj);
|
|
Loading…
Reference in New Issue
Block a user