mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
tidy(ui): clean up unused code 1
- Only export when necessary - Remove totally usused functions, variables, state, etc - Remove unused packages
This commit is contained in:
@ -1,27 +1 @@
|
||||
/**
|
||||
* Raised when metadata parsing fails.
|
||||
*/
|
||||
export class MetadataParseError extends Error {
|
||||
/**
|
||||
* Create MetadataParseError
|
||||
* @param {String} message
|
||||
*/
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = this.constructor.name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Raised when metadata recall fails.
|
||||
*/
|
||||
export class MetadataRecallError extends Error {
|
||||
/**
|
||||
* Create MetadataRecallError
|
||||
* @param {String} message
|
||||
*/
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = this.constructor.name;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ export type MetadataRecallOptions = MetadataParseOptions;
|
||||
* A function that recalls a parsed and validated metadata value.
|
||||
*
|
||||
* @param value The value to recall.
|
||||
* @throws MetadataRecallError if the value cannot be recalled.
|
||||
*/
|
||||
export type MetadataRecallFunc<T> = (value: T) => void;
|
||||
|
||||
@ -49,7 +48,7 @@ export type MetadataParseFunc<T = unknown> = (metadata: unknown) => Promise<T>;
|
||||
*
|
||||
* @param value The value to validate.
|
||||
* @returns A promise that resolves to the validated value.
|
||||
* @throws MetadataRecallError if the value is invalid.
|
||||
* @throws MetadataParseError if the value is invalid.
|
||||
*/
|
||||
export type MetadataValidateFunc<T> = (value: T) => Promise<T>;
|
||||
|
||||
@ -88,7 +87,6 @@ export type MetadataHandlers<TValue = unknown, TItem = unknown> = {
|
||||
* @param value The value to recall.
|
||||
* @param withToast Whether to show a toast on success or failure.
|
||||
* @returns A promise that resolves when the recall operation is complete.
|
||||
* @throws MetadataRecallError if the value cannot be recalled.
|
||||
*/
|
||||
recall?: (value: TValue, withToast?: boolean) => Promise<void>;
|
||||
/**
|
||||
@ -99,7 +97,6 @@ export type MetadataHandlers<TValue = unknown, TItem = unknown> = {
|
||||
* @param item The item to recall. It should be an item from the array.
|
||||
* @param withToast Whether to show a toast on success or failure.
|
||||
* @returns A promise that resolves when the recall operation is complete.
|
||||
* @throws MetadataRecallError if the value cannot be recalled.
|
||||
*/
|
||||
recallItem?: (item: TItem, withToast?: boolean) => Promise<void>;
|
||||
/**
|
||||
|
@ -4,8 +4,6 @@ import { isModelIdentifier, isModelIdentifierV2 } from 'features/nodes/types/com
|
||||
import { modelsApi } from 'services/api/endpoints/models';
|
||||
import type { AnyModelConfig, BaseModelType, ModelType } from 'services/api/types';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Raised when a model config is unable to be fetched.
|
||||
*/
|
||||
@ -93,19 +91,6 @@ export const fetchModelConfigWithTypeGuard = async <T extends AnyModelConfig>(
|
||||
return modelConfig;
|
||||
};
|
||||
|
||||
/**
|
||||
* Raises an error if the source base model is incompatible with the target base model.
|
||||
* @param sourceBase The source base model.
|
||||
* @param targetBase The target base model.
|
||||
* @param message An optional custom message to include in the error.
|
||||
* @throws {InvalidModelConfigError} If the source base model is incompatible with the target base model.
|
||||
*/
|
||||
export const raiseIfBaseIncompatible = (sourceBase: BaseModelType, targetBase?: BaseModelType, message?: string) => {
|
||||
if (targetBase && sourceBase !== targetBase) {
|
||||
throw new InvalidModelConfigError(message || `Incompatible base models: ${sourceBase} and ${targetBase}`);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches the model key from a model identifier. This includes fetching the key for MM1 format model identifiers.
|
||||
* @param modelIdentifier The model identifier. The MM2 format `{key: string}` simply extracts the key. The MM1 format
|
||||
|
@ -6,12 +6,13 @@ import {
|
||||
} from 'features/controlAdapters/util/buildControlAdapter';
|
||||
import type { LoRA } from 'features/lora/store/loraSlice';
|
||||
import { defaultLoRAConfig } from 'features/lora/store/loraSlice';
|
||||
import { MetadataParseError } from 'features/metadata/exceptions';
|
||||
import type { ControlNetConfigMetadata, IPAdapterConfigMetadata, MetadataParseFunc, T2IAdapterConfigMetadata } from 'features/metadata/types';
|
||||
import {
|
||||
fetchModelConfigWithTypeGuard,
|
||||
getModelKey,
|
||||
} from 'features/metadata/util/modelFetchingHelpers';
|
||||
import type {
|
||||
ControlNetConfigMetadata,
|
||||
IPAdapterConfigMetadata,
|
||||
MetadataParseFunc,
|
||||
T2IAdapterConfigMetadata,
|
||||
} from 'features/metadata/types';
|
||||
import { fetchModelConfigWithTypeGuard, getModelKey } from 'features/metadata/util/modelFetchingHelpers';
|
||||
import {
|
||||
zControlField,
|
||||
zIPAdapterField,
|
||||
@ -74,6 +75,19 @@ import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
export const MetadataParsePendingToken = Symbol('pending');
|
||||
export const MetadataParseFailedToken = Symbol('failed');
|
||||
/**
|
||||
* Raised when metadata parsing fails.
|
||||
*/
|
||||
export class MetadataParseError extends Error {
|
||||
/**
|
||||
* Create MetadataParseError
|
||||
* @param {String} message
|
||||
*/
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = this.constructor.name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An async function that a property from an object and validates its type using a type guard. If the property is missing
|
||||
|
Reference in New Issue
Block a user