mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
tidy(ui): clean up unused code 3
variables, types and schemas
This commit is contained in:
parent
bca1737b9c
commit
a106c1126c
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://unpkg.com/knip@5/schema.json",
|
|
||||||
"ignore": ["src/features/nodes/types/v2/**/*", "src/features/nodes/types/v1/**/*"]
|
|
||||||
}
|
|
19
invokeai/frontend/web/knip.ts
Normal file
19
invokeai/frontend/web/knip.ts
Normal file
@ -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;
|
@ -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 (
|
|
||||||
<FormControl>
|
|
||||||
<FormLabel>{t('dynamicPrompts.combinatorial')}</FormLabel>
|
|
||||||
<Switch isChecked={combinatorial} onChange={handleChange} />
|
|
||||||
</FormControl>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default memo(ParamDynamicPromptsCombinatorial);
|
|
@ -1,7 +0,0 @@
|
|||||||
import { memo } from 'react';
|
|
||||||
|
|
||||||
const NoBoardContextMenuItems = () => {
|
|
||||||
return <></>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default memo(NoBoardContextMenuItems);
|
|
@ -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 = <T extends AnyModelConfig>(props: UseControllerProps<T>) => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const { field } = useController(props);
|
|
||||||
const value = useMemo(() => options.find((o) => o.value === field.value), [field.value]);
|
|
||||||
const onChange = useCallback<ComboboxOnChange>(
|
|
||||||
(v) => {
|
|
||||||
field.onChange(v?.value);
|
|
||||||
},
|
|
||||||
[field]
|
|
||||||
);
|
|
||||||
return (
|
|
||||||
<FormControl>
|
|
||||||
<Flex direction="column" width="full">
|
|
||||||
<FormLabel>{t('modelManager.baseModel')}</FormLabel>
|
|
||||||
<Combobox value={value} options={options} onChange={onChange} />
|
|
||||||
</Flex>
|
|
||||||
</FormControl>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default typedMemo(BaseModelSelect);
|
|
@ -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 = <T extends CheckpointModelConfig | DiffusersModelConfig>(props: UseControllerProps<T>) => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const { field } = useController(props);
|
|
||||||
const value = useMemo(() => options.find((o) => o.value === field.value), [field.value]);
|
|
||||||
const onChange = useCallback<ComboboxOnChange>(
|
|
||||||
(v) => {
|
|
||||||
field.onChange(v?.value);
|
|
||||||
},
|
|
||||||
[field]
|
|
||||||
);
|
|
||||||
return (
|
|
||||||
<FormControl>
|
|
||||||
<Flex direction="column" width="full">
|
|
||||||
<FormLabel>{t('modelManager.variant')}</FormLabel>
|
|
||||||
<Combobox value={value} options={options} onChange={onChange} />
|
|
||||||
</Flex>
|
|
||||||
</FormControl>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default typedMemo(ModelVariantSelect);
|
|
@ -1,3 +0,0 @@
|
|||||||
export const ScanModels = () => {
|
|
||||||
return 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;
|
|
||||||
};
|
|
@ -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;
|
|
||||||
};
|
|
@ -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;
|
|
||||||
};
|
|
@ -54,8 +54,8 @@ export type SchedulerField = z.infer<typeof zSchedulerField>;
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Model-related schemas
|
// #region Model-related schemas
|
||||||
export const zBaseModel = z.enum(['any', 'sd-1', 'sd-2', 'sdxl', 'sdxl-refiner']);
|
const zBaseModel = z.enum(['any', 'sd-1', 'sd-2', 'sdxl', 'sdxl-refiner']);
|
||||||
export const zModelType = z.enum([
|
const zModelType = z.enum([
|
||||||
'main',
|
'main',
|
||||||
'vae',
|
'vae',
|
||||||
'lora',
|
'lora',
|
||||||
@ -65,15 +65,14 @@ export const zModelType = z.enum([
|
|||||||
'clip_vision',
|
'clip_vision',
|
||||||
't2i_adapter',
|
't2i_adapter',
|
||||||
]);
|
]);
|
||||||
export const zModelName = z.string().min(3);
|
const zModelIdentifier = z.object({
|
||||||
export const zModelIdentifier = z.object({
|
|
||||||
key: z.string().min(1),
|
key: z.string().min(1),
|
||||||
});
|
});
|
||||||
export const isModelIdentifier = (field: unknown): field is ModelIdentifier =>
|
export const isModelIdentifier = (field: unknown): field is ModelIdentifier =>
|
||||||
zModelIdentifier.safeParse(field).success;
|
zModelIdentifier.safeParse(field).success;
|
||||||
export const isModelIdentifierV2 = (field: unknown): field is ModelIdentifierV2 =>
|
export const isModelIdentifierV2 = (field: unknown): field is ModelIdentifierV2 =>
|
||||||
zModelIdentifierV2.safeParse(field).success;
|
zModelIdentifierV2.safeParse(field).success;
|
||||||
export const zModelFieldBase = zModelIdentifier;
|
const zModelFieldBase = zModelIdentifier;
|
||||||
export const zModelIdentifierWithBase = zModelIdentifier.extend({ base: zBaseModel });
|
export const zModelIdentifierWithBase = zModelIdentifier.extend({ base: zBaseModel });
|
||||||
export type BaseModel = z.infer<typeof zBaseModel>;
|
export type BaseModel = z.infer<typeof zBaseModel>;
|
||||||
export type ModelType = z.infer<typeof zModelType>;
|
export type ModelType = z.infer<typeof zModelType>;
|
||||||
@ -123,7 +122,7 @@ export type ProgressImage = z.infer<typeof zProgressImage>;
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region ImageOutput
|
// #region ImageOutput
|
||||||
export const zImageOutput = z.object({
|
const zImageOutput = z.object({
|
||||||
image: zImageField,
|
image: zImageField,
|
||||||
width: z.number().int().gt(0),
|
width: z.number().int().gt(0),
|
||||||
height: z.number().int().gt(0),
|
height: z.number().int().gt(0),
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
import {
|
import { zBoardField, zColorField, zImageField, zModelIdentifierWithBase, zSchedulerField } from './common';
|
||||||
zBoardField,
|
|
||||||
zColorField,
|
|
||||||
zImageField,
|
|
||||||
zModelIdentifierWithBase,
|
|
||||||
zSchedulerField,
|
|
||||||
} from './common';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* zod schemas & inferred types for fields.
|
* zod schemas & inferred types for fields.
|
||||||
@ -35,19 +29,19 @@ import {
|
|||||||
/** */
|
/** */
|
||||||
|
|
||||||
// #region Base schemas & misc
|
// #region Base schemas & misc
|
||||||
export const zFieldInput = z.enum(['connection', 'direct', 'any']);
|
const zFieldInput = z.enum(['connection', 'direct', 'any']);
|
||||||
export type FieldInput = z.infer<typeof zFieldInput>;
|
export type FieldInput = z.infer<typeof zFieldInput>;
|
||||||
|
|
||||||
export const zFieldUIComponent = z.enum(['none', 'textarea', 'slider']);
|
const zFieldUIComponent = z.enum(['none', 'textarea', 'slider']);
|
||||||
export type FieldUIComponent = z.infer<typeof zFieldUIComponent>;
|
export type FieldUIComponent = z.infer<typeof zFieldUIComponent>;
|
||||||
|
|
||||||
export const zFieldInputInstanceBase = z.object({
|
const zFieldInputInstanceBase = z.object({
|
||||||
name: z.string().trim().min(1),
|
name: z.string().trim().min(1),
|
||||||
label: z.string().nullish(),
|
label: z.string().nullish(),
|
||||||
});
|
});
|
||||||
export type FieldInputInstanceBase = z.infer<typeof zFieldInputInstanceBase>;
|
export type FieldInputInstanceBase = z.infer<typeof zFieldInputInstanceBase>;
|
||||||
|
|
||||||
export const zFieldTemplateBase = z.object({
|
const zFieldTemplateBase = z.object({
|
||||||
name: z.string().min(1),
|
name: z.string().min(1),
|
||||||
title: z.string().min(1),
|
title: z.string().min(1),
|
||||||
description: z.string().nullish(),
|
description: z.string().nullish(),
|
||||||
@ -55,21 +49,21 @@ export const zFieldTemplateBase = z.object({
|
|||||||
ui_type: z.string().nullish(),
|
ui_type: z.string().nullish(),
|
||||||
ui_order: z.number().int().nullish(),
|
ui_order: z.number().int().nullish(),
|
||||||
});
|
});
|
||||||
export const zFieldInputTemplateBase = zFieldTemplateBase.extend({
|
const zFieldInputTemplateBase = zFieldTemplateBase.extend({
|
||||||
fieldKind: z.literal('input'),
|
fieldKind: z.literal('input'),
|
||||||
input: zFieldInput,
|
input: zFieldInput,
|
||||||
required: z.boolean(),
|
required: z.boolean(),
|
||||||
ui_component: zFieldUIComponent.nullish(),
|
ui_component: zFieldUIComponent.nullish(),
|
||||||
ui_choice_labels: z.record(z.string()).nullish(),
|
ui_choice_labels: z.record(z.string()).nullish(),
|
||||||
});
|
});
|
||||||
export const zFieldOutputTemplateBase = zFieldTemplateBase.extend({
|
const zFieldOutputTemplateBase = zFieldTemplateBase.extend({
|
||||||
fieldKind: z.literal('output'),
|
fieldKind: z.literal('output'),
|
||||||
});
|
});
|
||||||
export type FieldTemplateBase = z.infer<typeof zFieldTemplateBase>;
|
export type FieldTemplateBase = z.infer<typeof zFieldTemplateBase>;
|
||||||
export type FieldInputTemplateBase = z.infer<typeof zFieldInputTemplateBase>;
|
export type FieldInputTemplateBase = z.infer<typeof zFieldInputTemplateBase>;
|
||||||
export type FieldOutputTemplateBase = z.infer<typeof zFieldOutputTemplateBase>;
|
export type FieldOutputTemplateBase = z.infer<typeof zFieldOutputTemplateBase>;
|
||||||
|
|
||||||
export const zFieldTypeBase = z.object({
|
const zFieldTypeBase = z.object({
|
||||||
isCollection: z.boolean(),
|
isCollection: z.boolean(),
|
||||||
isCollectionOrScalar: z.boolean(),
|
isCollectionOrScalar: z.boolean(),
|
||||||
});
|
});
|
||||||
@ -79,18 +73,17 @@ export const zFieldIdentifier = z.object({
|
|||||||
fieldName: z.string().trim().min(1),
|
fieldName: z.string().trim().min(1),
|
||||||
});
|
});
|
||||||
export type FieldIdentifier = z.infer<typeof zFieldIdentifier>;
|
export type FieldIdentifier = z.infer<typeof zFieldIdentifier>;
|
||||||
export const isFieldIdentifier = (val: unknown): val is FieldIdentifier => zFieldIdentifier.safeParse(val).success;
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region IntegerField
|
// #region IntegerField
|
||||||
export const zIntegerFieldType = zFieldTypeBase.extend({
|
const zIntegerFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('IntegerField'),
|
name: z.literal('IntegerField'),
|
||||||
});
|
});
|
||||||
export const zIntegerFieldValue = z.number().int();
|
export const zIntegerFieldValue = z.number().int();
|
||||||
export const zIntegerFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zIntegerFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zIntegerFieldValue,
|
value: zIntegerFieldValue,
|
||||||
});
|
});
|
||||||
export const zIntegerFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zIntegerFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zIntegerFieldType,
|
type: zIntegerFieldType,
|
||||||
default: zIntegerFieldValue,
|
default: zIntegerFieldValue,
|
||||||
multipleOf: z.number().int().optional(),
|
multipleOf: z.number().int().optional(),
|
||||||
@ -99,7 +92,7 @@ export const zIntegerFieldInputTemplate = zFieldInputTemplateBase.extend({
|
|||||||
minimum: z.number().int().optional(),
|
minimum: z.number().int().optional(),
|
||||||
exclusiveMinimum: z.number().int().optional(),
|
exclusiveMinimum: z.number().int().optional(),
|
||||||
});
|
});
|
||||||
export const zIntegerFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zIntegerFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zIntegerFieldType,
|
type: zIntegerFieldType,
|
||||||
});
|
});
|
||||||
export type IntegerFieldType = z.infer<typeof zIntegerFieldType>;
|
export type IntegerFieldType = z.infer<typeof zIntegerFieldType>;
|
||||||
@ -113,14 +106,14 @@ export const isIntegerFieldInputTemplate = (val: unknown): val is IntegerFieldIn
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region FloatField
|
// #region FloatField
|
||||||
export const zFloatFieldType = zFieldTypeBase.extend({
|
const zFloatFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('FloatField'),
|
name: z.literal('FloatField'),
|
||||||
});
|
});
|
||||||
export const zFloatFieldValue = z.number();
|
export const zFloatFieldValue = z.number();
|
||||||
export const zFloatFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zFloatFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zFloatFieldValue,
|
value: zFloatFieldValue,
|
||||||
});
|
});
|
||||||
export const zFloatFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zFloatFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zFloatFieldType,
|
type: zFloatFieldType,
|
||||||
default: zFloatFieldValue,
|
default: zFloatFieldValue,
|
||||||
multipleOf: z.number().optional(),
|
multipleOf: z.number().optional(),
|
||||||
@ -129,7 +122,7 @@ export const zFloatFieldInputTemplate = zFieldInputTemplateBase.extend({
|
|||||||
minimum: z.number().optional(),
|
minimum: z.number().optional(),
|
||||||
exclusiveMinimum: z.number().optional(),
|
exclusiveMinimum: z.number().optional(),
|
||||||
});
|
});
|
||||||
export const zFloatFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zFloatFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zFloatFieldType,
|
type: zFloatFieldType,
|
||||||
});
|
});
|
||||||
export type FloatFieldType = z.infer<typeof zFloatFieldType>;
|
export type FloatFieldType = z.infer<typeof zFloatFieldType>;
|
||||||
@ -144,20 +137,20 @@ export const isFloatFieldInputTemplate = (val: unknown): val is FloatFieldInputT
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region StringField
|
// #region StringField
|
||||||
export const zStringFieldType = zFieldTypeBase.extend({
|
const zStringFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('StringField'),
|
name: z.literal('StringField'),
|
||||||
});
|
});
|
||||||
export const zStringFieldValue = z.string();
|
export const zStringFieldValue = z.string();
|
||||||
export const zStringFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zStringFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zStringFieldValue,
|
value: zStringFieldValue,
|
||||||
});
|
});
|
||||||
export const zStringFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zStringFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zStringFieldType,
|
type: zStringFieldType,
|
||||||
default: zStringFieldValue,
|
default: zStringFieldValue,
|
||||||
maxLength: z.number().int().optional(),
|
maxLength: z.number().int().optional(),
|
||||||
minLength: z.number().int().optional(),
|
minLength: z.number().int().optional(),
|
||||||
});
|
});
|
||||||
export const zStringFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zStringFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zStringFieldType,
|
type: zStringFieldType,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -173,18 +166,18 @@ export const isStringFieldInputTemplate = (val: unknown): val is StringFieldInpu
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region BooleanField
|
// #region BooleanField
|
||||||
export const zBooleanFieldType = zFieldTypeBase.extend({
|
const zBooleanFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('BooleanField'),
|
name: z.literal('BooleanField'),
|
||||||
});
|
});
|
||||||
export const zBooleanFieldValue = z.boolean();
|
export const zBooleanFieldValue = z.boolean();
|
||||||
export const zBooleanFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zBooleanFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zBooleanFieldValue,
|
value: zBooleanFieldValue,
|
||||||
});
|
});
|
||||||
export const zBooleanFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zBooleanFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zBooleanFieldType,
|
type: zBooleanFieldType,
|
||||||
default: zBooleanFieldValue,
|
default: zBooleanFieldValue,
|
||||||
});
|
});
|
||||||
export const zBooleanFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zBooleanFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zBooleanFieldType,
|
type: zBooleanFieldType,
|
||||||
});
|
});
|
||||||
export type BooleanFieldType = z.infer<typeof zBooleanFieldType>;
|
export type BooleanFieldType = z.infer<typeof zBooleanFieldType>;
|
||||||
@ -199,20 +192,20 @@ export const isBooleanFieldInputTemplate = (val: unknown): val is BooleanFieldIn
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region EnumField
|
// #region EnumField
|
||||||
export const zEnumFieldType = zFieldTypeBase.extend({
|
const zEnumFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('EnumField'),
|
name: z.literal('EnumField'),
|
||||||
});
|
});
|
||||||
export const zEnumFieldValue = z.string();
|
export const zEnumFieldValue = z.string();
|
||||||
export const zEnumFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zEnumFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zEnumFieldValue,
|
value: zEnumFieldValue,
|
||||||
});
|
});
|
||||||
export const zEnumFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zEnumFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zEnumFieldType,
|
type: zEnumFieldType,
|
||||||
default: zEnumFieldValue,
|
default: zEnumFieldValue,
|
||||||
options: z.array(z.string()),
|
options: z.array(z.string()),
|
||||||
labels: z.record(z.string()).optional(),
|
labels: z.record(z.string()).optional(),
|
||||||
});
|
});
|
||||||
export const zEnumFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zEnumFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zEnumFieldType,
|
type: zEnumFieldType,
|
||||||
});
|
});
|
||||||
export type EnumFieldType = z.infer<typeof zEnumFieldType>;
|
export type EnumFieldType = z.infer<typeof zEnumFieldType>;
|
||||||
@ -227,18 +220,18 @@ export const isEnumFieldInputTemplate = (val: unknown): val is EnumFieldInputTem
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region ImageField
|
// #region ImageField
|
||||||
export const zImageFieldType = zFieldTypeBase.extend({
|
const zImageFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('ImageField'),
|
name: z.literal('ImageField'),
|
||||||
});
|
});
|
||||||
export const zImageFieldValue = zImageField.optional();
|
export const zImageFieldValue = zImageField.optional();
|
||||||
export const zImageFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zImageFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zImageFieldValue,
|
value: zImageFieldValue,
|
||||||
});
|
});
|
||||||
export const zImageFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zImageFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zImageFieldType,
|
type: zImageFieldType,
|
||||||
default: zImageFieldValue,
|
default: zImageFieldValue,
|
||||||
});
|
});
|
||||||
export const zImageFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zImageFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zImageFieldType,
|
type: zImageFieldType,
|
||||||
});
|
});
|
||||||
export type ImageFieldType = z.infer<typeof zImageFieldType>;
|
export type ImageFieldType = z.infer<typeof zImageFieldType>;
|
||||||
@ -253,18 +246,18 @@ export const isImageFieldInputTemplate = (val: unknown): val is ImageFieldInputT
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region BoardField
|
// #region BoardField
|
||||||
export const zBoardFieldType = zFieldTypeBase.extend({
|
const zBoardFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('BoardField'),
|
name: z.literal('BoardField'),
|
||||||
});
|
});
|
||||||
export const zBoardFieldValue = zBoardField.optional();
|
export const zBoardFieldValue = zBoardField.optional();
|
||||||
export const zBoardFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zBoardFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zBoardFieldValue,
|
value: zBoardFieldValue,
|
||||||
});
|
});
|
||||||
export const zBoardFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zBoardFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zBoardFieldType,
|
type: zBoardFieldType,
|
||||||
default: zBoardFieldValue,
|
default: zBoardFieldValue,
|
||||||
});
|
});
|
||||||
export const zBoardFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zBoardFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zBoardFieldType,
|
type: zBoardFieldType,
|
||||||
});
|
});
|
||||||
export type BoardFieldType = z.infer<typeof zBoardFieldType>;
|
export type BoardFieldType = z.infer<typeof zBoardFieldType>;
|
||||||
@ -279,18 +272,18 @@ export const isBoardFieldInputTemplate = (val: unknown): val is BoardFieldInputT
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region ColorField
|
// #region ColorField
|
||||||
export const zColorFieldType = zFieldTypeBase.extend({
|
const zColorFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('ColorField'),
|
name: z.literal('ColorField'),
|
||||||
});
|
});
|
||||||
export const zColorFieldValue = zColorField.optional();
|
export const zColorFieldValue = zColorField.optional();
|
||||||
export const zColorFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zColorFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zColorFieldValue,
|
value: zColorFieldValue,
|
||||||
});
|
});
|
||||||
export const zColorFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zColorFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zColorFieldType,
|
type: zColorFieldType,
|
||||||
default: zColorFieldValue,
|
default: zColorFieldValue,
|
||||||
});
|
});
|
||||||
export const zColorFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zColorFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zColorFieldType,
|
type: zColorFieldType,
|
||||||
});
|
});
|
||||||
export type ColorFieldType = z.infer<typeof zColorFieldType>;
|
export type ColorFieldType = z.infer<typeof zColorFieldType>;
|
||||||
@ -305,18 +298,18 @@ export const isColorFieldInputTemplate = (val: unknown): val is ColorFieldInputT
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region MainModelField
|
// #region MainModelField
|
||||||
export const zMainModelFieldType = zFieldTypeBase.extend({
|
const zMainModelFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('MainModelField'),
|
name: z.literal('MainModelField'),
|
||||||
});
|
});
|
||||||
export const zMainModelFieldValue = zModelIdentifierWithBase.optional();
|
export const zMainModelFieldValue = zModelIdentifierWithBase.optional();
|
||||||
export const zMainModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zMainModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zMainModelFieldValue,
|
value: zMainModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zMainModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zMainModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zMainModelFieldType,
|
type: zMainModelFieldType,
|
||||||
default: zMainModelFieldValue,
|
default: zMainModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zMainModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zMainModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zMainModelFieldType,
|
type: zMainModelFieldType,
|
||||||
});
|
});
|
||||||
export type MainModelFieldType = z.infer<typeof zMainModelFieldType>;
|
export type MainModelFieldType = z.infer<typeof zMainModelFieldType>;
|
||||||
@ -331,18 +324,18 @@ export const isMainModelFieldInputTemplate = (val: unknown): val is MainModelFie
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region SDXLMainModelField
|
// #region SDXLMainModelField
|
||||||
export const zSDXLMainModelFieldType = zFieldTypeBase.extend({
|
const zSDXLMainModelFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('SDXLMainModelField'),
|
name: z.literal('SDXLMainModelField'),
|
||||||
});
|
});
|
||||||
export const zSDXLMainModelFieldValue = zMainModelFieldValue; // TODO: Narrow to SDXL models only.
|
const zSDXLMainModelFieldValue = zMainModelFieldValue; // TODO: Narrow to SDXL models only.
|
||||||
export const zSDXLMainModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zSDXLMainModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zSDXLMainModelFieldValue,
|
value: zSDXLMainModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zSDXLMainModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zSDXLMainModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zSDXLMainModelFieldType,
|
type: zSDXLMainModelFieldType,
|
||||||
default: zSDXLMainModelFieldValue,
|
default: zSDXLMainModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zSDXLMainModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zSDXLMainModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zSDXLMainModelFieldType,
|
type: zSDXLMainModelFieldType,
|
||||||
});
|
});
|
||||||
export type SDXLMainModelFieldType = z.infer<typeof zSDXLMainModelFieldType>;
|
export type SDXLMainModelFieldType = z.infer<typeof zSDXLMainModelFieldType>;
|
||||||
@ -357,18 +350,18 @@ export const isSDXLMainModelFieldInputTemplate = (val: unknown): val is SDXLMain
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region SDXLRefinerModelField
|
// #region SDXLRefinerModelField
|
||||||
export const zSDXLRefinerModelFieldType = zFieldTypeBase.extend({
|
const zSDXLRefinerModelFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('SDXLRefinerModelField'),
|
name: z.literal('SDXLRefinerModelField'),
|
||||||
});
|
});
|
||||||
export const zSDXLRefinerModelFieldValue = zMainModelFieldValue; // TODO: Narrow to SDXL Refiner models only.
|
export const zSDXLRefinerModelFieldValue = zMainModelFieldValue; // TODO: Narrow to SDXL Refiner models only.
|
||||||
export const zSDXLRefinerModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zSDXLRefinerModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zSDXLRefinerModelFieldValue,
|
value: zSDXLRefinerModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zSDXLRefinerModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zSDXLRefinerModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zSDXLRefinerModelFieldType,
|
type: zSDXLRefinerModelFieldType,
|
||||||
default: zSDXLRefinerModelFieldValue,
|
default: zSDXLRefinerModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zSDXLRefinerModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zSDXLRefinerModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zSDXLRefinerModelFieldType,
|
type: zSDXLRefinerModelFieldType,
|
||||||
});
|
});
|
||||||
export type SDXLRefinerModelFieldType = z.infer<typeof zSDXLRefinerModelFieldType>;
|
export type SDXLRefinerModelFieldType = z.infer<typeof zSDXLRefinerModelFieldType>;
|
||||||
@ -383,18 +376,18 @@ export const isSDXLRefinerModelFieldInputTemplate = (val: unknown): val is SDXLR
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region VAEModelField
|
// #region VAEModelField
|
||||||
export const zVAEModelFieldType = zFieldTypeBase.extend({
|
const zVAEModelFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('VAEModelField'),
|
name: z.literal('VAEModelField'),
|
||||||
});
|
});
|
||||||
export const zVAEModelFieldValue = zModelIdentifierWithBase.optional();
|
export const zVAEModelFieldValue = zModelIdentifierWithBase.optional();
|
||||||
export const zVAEModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zVAEModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zVAEModelFieldValue,
|
value: zVAEModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zVAEModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zVAEModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zVAEModelFieldType,
|
type: zVAEModelFieldType,
|
||||||
default: zVAEModelFieldValue,
|
default: zVAEModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zVAEModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zVAEModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zVAEModelFieldType,
|
type: zVAEModelFieldType,
|
||||||
});
|
});
|
||||||
export type VAEModelFieldType = z.infer<typeof zVAEModelFieldType>;
|
export type VAEModelFieldType = z.infer<typeof zVAEModelFieldType>;
|
||||||
@ -409,18 +402,18 @@ export const isVAEModelFieldInputTemplate = (val: unknown): val is VAEModelField
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region LoRAModelField
|
// #region LoRAModelField
|
||||||
export const zLoRAModelFieldType = zFieldTypeBase.extend({
|
const zLoRAModelFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('LoRAModelField'),
|
name: z.literal('LoRAModelField'),
|
||||||
});
|
});
|
||||||
export const zLoRAModelFieldValue = zModelIdentifierWithBase.optional();
|
export const zLoRAModelFieldValue = zModelIdentifierWithBase.optional();
|
||||||
export const zLoRAModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zLoRAModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zLoRAModelFieldValue,
|
value: zLoRAModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zLoRAModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zLoRAModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zLoRAModelFieldType,
|
type: zLoRAModelFieldType,
|
||||||
default: zLoRAModelFieldValue,
|
default: zLoRAModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zLoRAModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zLoRAModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zLoRAModelFieldType,
|
type: zLoRAModelFieldType,
|
||||||
});
|
});
|
||||||
export type LoRAModelFieldType = z.infer<typeof zLoRAModelFieldType>;
|
export type LoRAModelFieldType = z.infer<typeof zLoRAModelFieldType>;
|
||||||
@ -435,18 +428,18 @@ export const isLoRAModelFieldInputTemplate = (val: unknown): val is LoRAModelFie
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region ControlNetModelField
|
// #region ControlNetModelField
|
||||||
export const zControlNetModelFieldType = zFieldTypeBase.extend({
|
const zControlNetModelFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('ControlNetModelField'),
|
name: z.literal('ControlNetModelField'),
|
||||||
});
|
});
|
||||||
export const zControlNetModelFieldValue = zModelIdentifierWithBase.optional();
|
export const zControlNetModelFieldValue = zModelIdentifierWithBase.optional();
|
||||||
export const zControlNetModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zControlNetModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zControlNetModelFieldValue,
|
value: zControlNetModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zControlNetModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zControlNetModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zControlNetModelFieldType,
|
type: zControlNetModelFieldType,
|
||||||
default: zControlNetModelFieldValue,
|
default: zControlNetModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zControlNetModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zControlNetModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zControlNetModelFieldType,
|
type: zControlNetModelFieldType,
|
||||||
});
|
});
|
||||||
export type ControlNetModelFieldType = z.infer<typeof zControlNetModelFieldType>;
|
export type ControlNetModelFieldType = z.infer<typeof zControlNetModelFieldType>;
|
||||||
@ -458,23 +451,21 @@ export const isControlNetModelFieldInputInstance = (val: unknown): val is Contro
|
|||||||
zControlNetModelFieldInputInstance.safeParse(val).success;
|
zControlNetModelFieldInputInstance.safeParse(val).success;
|
||||||
export const isControlNetModelFieldInputTemplate = (val: unknown): val is ControlNetModelFieldInputTemplate =>
|
export const isControlNetModelFieldInputTemplate = (val: unknown): val is ControlNetModelFieldInputTemplate =>
|
||||||
zControlNetModelFieldInputTemplate.safeParse(val).success;
|
zControlNetModelFieldInputTemplate.safeParse(val).success;
|
||||||
export const isControlNetModelFieldValue = (v: unknown): v is ControlNetModelFieldValue =>
|
|
||||||
zControlNetModelFieldValue.safeParse(v).success;
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region IPAdapterModelField
|
// #region IPAdapterModelField
|
||||||
export const zIPAdapterModelFieldType = zFieldTypeBase.extend({
|
const zIPAdapterModelFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('IPAdapterModelField'),
|
name: z.literal('IPAdapterModelField'),
|
||||||
});
|
});
|
||||||
export const zIPAdapterModelFieldValue = zModelIdentifierWithBase.optional();
|
export const zIPAdapterModelFieldValue = zModelIdentifierWithBase.optional();
|
||||||
export const zIPAdapterModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zIPAdapterModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zIPAdapterModelFieldValue,
|
value: zIPAdapterModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zIPAdapterModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zIPAdapterModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zIPAdapterModelFieldType,
|
type: zIPAdapterModelFieldType,
|
||||||
default: zIPAdapterModelFieldValue,
|
default: zIPAdapterModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zIPAdapterModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zIPAdapterModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zIPAdapterModelFieldType,
|
type: zIPAdapterModelFieldType,
|
||||||
});
|
});
|
||||||
export type IPAdapterModelFieldType = z.infer<typeof zIPAdapterModelFieldType>;
|
export type IPAdapterModelFieldType = z.infer<typeof zIPAdapterModelFieldType>;
|
||||||
@ -486,23 +477,21 @@ export const isIPAdapterModelFieldInputInstance = (val: unknown): val is IPAdapt
|
|||||||
zIPAdapterModelFieldInputInstance.safeParse(val).success;
|
zIPAdapterModelFieldInputInstance.safeParse(val).success;
|
||||||
export const isIPAdapterModelFieldInputTemplate = (val: unknown): val is IPAdapterModelFieldInputTemplate =>
|
export const isIPAdapterModelFieldInputTemplate = (val: unknown): val is IPAdapterModelFieldInputTemplate =>
|
||||||
zIPAdapterModelFieldInputTemplate.safeParse(val).success;
|
zIPAdapterModelFieldInputTemplate.safeParse(val).success;
|
||||||
export const isIPAdapterModelFieldValue = (val: unknown): val is IPAdapterModelFieldValue =>
|
|
||||||
zIPAdapterModelFieldValue.safeParse(val).success;
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region T2IAdapterField
|
// #region T2IAdapterField
|
||||||
export const zT2IAdapterModelFieldType = zFieldTypeBase.extend({
|
const zT2IAdapterModelFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('T2IAdapterModelField'),
|
name: z.literal('T2IAdapterModelField'),
|
||||||
});
|
});
|
||||||
export const zT2IAdapterModelFieldValue = zModelIdentifierWithBase.optional();
|
export const zT2IAdapterModelFieldValue = zModelIdentifierWithBase.optional();
|
||||||
export const zT2IAdapterModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zT2IAdapterModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zT2IAdapterModelFieldValue,
|
value: zT2IAdapterModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zT2IAdapterModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zT2IAdapterModelFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zT2IAdapterModelFieldType,
|
type: zT2IAdapterModelFieldType,
|
||||||
default: zT2IAdapterModelFieldValue,
|
default: zT2IAdapterModelFieldValue,
|
||||||
});
|
});
|
||||||
export const zT2IAdapterModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zT2IAdapterModelFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zT2IAdapterModelFieldType,
|
type: zT2IAdapterModelFieldType,
|
||||||
});
|
});
|
||||||
export type T2IAdapterModelFieldType = z.infer<typeof zT2IAdapterModelFieldType>;
|
export type T2IAdapterModelFieldType = z.infer<typeof zT2IAdapterModelFieldType>;
|
||||||
@ -517,18 +506,18 @@ export const isT2IAdapterModelFieldInputTemplate = (val: unknown): val is T2IAda
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region SchedulerField
|
// #region SchedulerField
|
||||||
export const zSchedulerFieldType = zFieldTypeBase.extend({
|
const zSchedulerFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('SchedulerField'),
|
name: z.literal('SchedulerField'),
|
||||||
});
|
});
|
||||||
export const zSchedulerFieldValue = zSchedulerField.optional();
|
export const zSchedulerFieldValue = zSchedulerField.optional();
|
||||||
export const zSchedulerFieldInputInstance = zFieldInputInstanceBase.extend({
|
const zSchedulerFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zSchedulerFieldValue,
|
value: zSchedulerFieldValue,
|
||||||
});
|
});
|
||||||
export const zSchedulerFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zSchedulerFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zSchedulerFieldType,
|
type: zSchedulerFieldType,
|
||||||
default: zSchedulerFieldValue,
|
default: zSchedulerFieldValue,
|
||||||
});
|
});
|
||||||
export const zSchedulerFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zSchedulerFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zSchedulerFieldType,
|
type: zSchedulerFieldType,
|
||||||
});
|
});
|
||||||
export type SchedulerFieldType = z.infer<typeof zSchedulerFieldType>;
|
export type SchedulerFieldType = z.infer<typeof zSchedulerFieldType>;
|
||||||
@ -554,19 +543,19 @@ export const isSchedulerFieldInputTemplate = (val: unknown): val is SchedulerFie
|
|||||||
* - Reserved fields like IsIntermediate
|
* - Reserved fields like IsIntermediate
|
||||||
* - Any other field we don't have full-on schemas for
|
* - 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
|
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
|
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 zStatelessFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zStatelessFieldValue,
|
value: zStatelessFieldValue,
|
||||||
});
|
});
|
||||||
export const zStatelessFieldInputTemplate = zFieldInputTemplateBase.extend({
|
const zStatelessFieldInputTemplate = zFieldInputTemplateBase.extend({
|
||||||
type: zStatelessFieldType,
|
type: zStatelessFieldType,
|
||||||
default: zStatelessFieldValue,
|
default: zStatelessFieldValue,
|
||||||
input: z.literal('connection'), // stateless --> only accepts connection inputs
|
input: z.literal('connection'), // stateless --> only accepts connection inputs
|
||||||
});
|
});
|
||||||
export const zStatelessFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
const zStatelessFieldOutputTemplate = zFieldOutputTemplateBase.extend({
|
||||||
type: zStatelessFieldType,
|
type: zStatelessFieldType,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -593,7 +582,7 @@ export type StatelessFieldOutputTemplate = z.infer<typeof zStatelessFieldOutputT
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// #region StatefulFieldType & FieldType
|
// #region StatefulFieldType & FieldType
|
||||||
export const zStatefulFieldType = z.union([
|
const zStatefulFieldType = z.union([
|
||||||
zIntegerFieldType,
|
zIntegerFieldType,
|
||||||
zFloatFieldType,
|
zFloatFieldType,
|
||||||
zStringFieldType,
|
zStringFieldType,
|
||||||
@ -616,9 +605,8 @@ export type StatefulFieldType = z.infer<typeof zStatefulFieldType>;
|
|||||||
export const isStatefulFieldType = (val: unknown): val is StatefulFieldType =>
|
export const isStatefulFieldType = (val: unknown): val is StatefulFieldType =>
|
||||||
zStatefulFieldType.safeParse(val).success;
|
zStatefulFieldType.safeParse(val).success;
|
||||||
|
|
||||||
export const zFieldType = z.union([zStatefulFieldType, zStatelessFieldType]);
|
const zFieldType = z.union([zStatefulFieldType, zStatelessFieldType]);
|
||||||
export type FieldType = z.infer<typeof zFieldType>;
|
export type FieldType = z.infer<typeof zFieldType>;
|
||||||
export const isFieldType = (val: unknown): val is FieldType => zFieldType.safeParse(val).success;
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region StatefulFieldValue & FieldValue
|
// #region StatefulFieldValue & FieldValue
|
||||||
@ -642,16 +630,13 @@ export const zStatefulFieldValue = z.union([
|
|||||||
zSchedulerFieldValue,
|
zSchedulerFieldValue,
|
||||||
]);
|
]);
|
||||||
export type StatefulFieldValue = z.infer<typeof zStatefulFieldValue>;
|
export type StatefulFieldValue = z.infer<typeof zStatefulFieldValue>;
|
||||||
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<typeof zFieldValue>;
|
export type FieldValue = z.infer<typeof zFieldValue>;
|
||||||
export const isFieldValue = (val: unknown): val is FieldValue => zFieldValue.safeParse(val).success;
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region StatefulFieldInputInstance & FieldInputInstance
|
// #region StatefulFieldInputInstance & FieldInputInstance
|
||||||
export const zStatefulFieldInputInstance = z.union([
|
const zStatefulFieldInputInstance = z.union([
|
||||||
zIntegerFieldInputInstance,
|
zIntegerFieldInputInstance,
|
||||||
zFloatFieldInputInstance,
|
zFloatFieldInputInstance,
|
||||||
zStringFieldInputInstance,
|
zStringFieldInputInstance,
|
||||||
@ -671,8 +656,6 @@ export const zStatefulFieldInputInstance = z.union([
|
|||||||
zSchedulerFieldInputInstance,
|
zSchedulerFieldInputInstance,
|
||||||
]);
|
]);
|
||||||
export type StatefulFieldInputInstance = z.infer<typeof zStatefulFieldInputInstance>;
|
export type StatefulFieldInputInstance = z.infer<typeof zStatefulFieldInputInstance>;
|
||||||
export const isStatefulFieldInputInstance = (val: unknown): val is StatefulFieldInputInstance =>
|
|
||||||
zStatefulFieldInputInstance.safeParse(val).success;
|
|
||||||
|
|
||||||
export const zFieldInputInstance = z.union([zStatefulFieldInputInstance, zStatelessFieldInputInstance]);
|
export const zFieldInputInstance = z.union([zStatefulFieldInputInstance, zStatelessFieldInputInstance]);
|
||||||
export type FieldInputInstance = z.infer<typeof zFieldInputInstance>;
|
export type FieldInputInstance = z.infer<typeof zFieldInputInstance>;
|
||||||
@ -681,7 +664,7 @@ export const isFieldInputInstance = (val: unknown): val is FieldInputInstance =>
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region StatefulFieldInputTemplate & FieldInputTemplate
|
// #region StatefulFieldInputTemplate & FieldInputTemplate
|
||||||
export const zStatefulFieldInputTemplate = z.union([
|
const zStatefulFieldInputTemplate = z.union([
|
||||||
zIntegerFieldInputTemplate,
|
zIntegerFieldInputTemplate,
|
||||||
zFloatFieldInputTemplate,
|
zFloatFieldInputTemplate,
|
||||||
zStringFieldInputTemplate,
|
zStringFieldInputTemplate,
|
||||||
@ -702,8 +685,6 @@ export const zStatefulFieldInputTemplate = z.union([
|
|||||||
zStatelessFieldInputTemplate,
|
zStatelessFieldInputTemplate,
|
||||||
]);
|
]);
|
||||||
export type StatefulFieldInputTemplate = z.infer<typeof zFieldInputTemplate>;
|
export type StatefulFieldInputTemplate = z.infer<typeof zFieldInputTemplate>;
|
||||||
export const isStatefulFieldInputTemplate = (val: unknown): val is StatefulFieldInputTemplate =>
|
|
||||||
zStatefulFieldInputTemplate.safeParse(val).success;
|
|
||||||
|
|
||||||
export const zFieldInputTemplate = z.union([zStatefulFieldInputTemplate, zStatelessFieldInputTemplate]);
|
export const zFieldInputTemplate = z.union([zStatefulFieldInputTemplate, zStatelessFieldInputTemplate]);
|
||||||
export type FieldInputTemplate = z.infer<typeof zFieldInputTemplate>;
|
export type FieldInputTemplate = z.infer<typeof zFieldInputTemplate>;
|
||||||
@ -712,7 +693,7 @@ export const isFieldInputTemplate = (val: unknown): val is FieldInputTemplate =>
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region StatefulFieldOutputTemplate & FieldOutputTemplate
|
// #region StatefulFieldOutputTemplate & FieldOutputTemplate
|
||||||
export const zStatefulFieldOutputTemplate = z.union([
|
const zStatefulFieldOutputTemplate = z.union([
|
||||||
zIntegerFieldOutputTemplate,
|
zIntegerFieldOutputTemplate,
|
||||||
zFloatFieldOutputTemplate,
|
zFloatFieldOutputTemplate,
|
||||||
zStringFieldOutputTemplate,
|
zStringFieldOutputTemplate,
|
||||||
@ -732,11 +713,7 @@ export const zStatefulFieldOutputTemplate = z.union([
|
|||||||
zSchedulerFieldOutputTemplate,
|
zSchedulerFieldOutputTemplate,
|
||||||
]);
|
]);
|
||||||
export type StatefulFieldOutputTemplate = z.infer<typeof zStatefulFieldOutputTemplate>;
|
export type StatefulFieldOutputTemplate = z.infer<typeof zStatefulFieldOutputTemplate>;
|
||||||
export const isStatefulFieldOutputTemplate = (val: unknown): val is StatefulFieldOutputTemplate =>
|
|
||||||
zStatefulFieldOutputTemplate.safeParse(val).success;
|
|
||||||
|
|
||||||
export const zFieldOutputTemplate = z.union([zStatefulFieldOutputTemplate, zStatelessFieldOutputTemplate]);
|
export const zFieldOutputTemplate = z.union([zStatefulFieldOutputTemplate, zStatelessFieldOutputTemplate]);
|
||||||
export type FieldOutputTemplate = z.infer<typeof zFieldOutputTemplate>;
|
export type FieldOutputTemplate = z.infer<typeof zFieldOutputTemplate>;
|
||||||
export const isFieldOutputTemplate = (val: unknown): val is FieldOutputTemplate =>
|
|
||||||
zFieldOutputTemplate.safeParse(val).success;
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
@ -6,7 +6,7 @@ import { zFieldInputInstance, zFieldInputTemplate, zFieldOutputTemplate } from '
|
|||||||
import { zSemVer } from './semver';
|
import { zSemVer } from './semver';
|
||||||
|
|
||||||
// #region InvocationTemplate
|
// #region InvocationTemplate
|
||||||
export const zInvocationTemplate = z.object({
|
const zInvocationTemplate = z.object({
|
||||||
type: z.string(),
|
type: z.string(),
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
description: z.string(),
|
description: z.string(),
|
||||||
@ -43,13 +43,13 @@ export const zNotesNodeData = z.object({
|
|||||||
isOpen: z.boolean(),
|
isOpen: z.boolean(),
|
||||||
notes: z.string(),
|
notes: z.string(),
|
||||||
});
|
});
|
||||||
export const zCurrentImageNodeData = z.object({
|
const zCurrentImageNodeData = z.object({
|
||||||
id: z.string().trim().min(1),
|
id: z.string().trim().min(1),
|
||||||
type: z.literal('current_image'),
|
type: z.literal('current_image'),
|
||||||
label: z.string(),
|
label: z.string(),
|
||||||
isOpen: z.boolean(),
|
isOpen: z.boolean(),
|
||||||
});
|
});
|
||||||
export const zAnyNodeData = z.union([zInvocationNodeData, zNotesNodeData, zCurrentImageNodeData]);
|
const zAnyNodeData = z.union([zInvocationNodeData, zNotesNodeData, zCurrentImageNodeData]);
|
||||||
|
|
||||||
export type NotesNodeData = z.infer<typeof zNotesNodeData>;
|
export type NotesNodeData = z.infer<typeof zNotesNodeData>;
|
||||||
export type InvocationNodeData = z.infer<typeof zInvocationNodeData>;
|
export type InvocationNodeData = z.infer<typeof zInvocationNodeData>;
|
||||||
@ -64,15 +64,13 @@ export type AnyNode = Node<AnyNodeData>;
|
|||||||
export const isInvocationNode = (node?: AnyNode | null): node is InvocationNode =>
|
export const isInvocationNode = (node?: AnyNode | null): node is InvocationNode =>
|
||||||
Boolean(node && node.type === 'invocation');
|
Boolean(node && node.type === 'invocation');
|
||||||
export const isNotesNode = (node?: AnyNode | null): node is NotesNode => Boolean(node && node.type === 'notes');
|
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 =>
|
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
|
Boolean(node && !['notes', 'current_image'].includes(node.type)); // node.type may be 'notes', 'current_image', or any invocation type
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region NodeExecutionState
|
// #region NodeExecutionState
|
||||||
export const zNodeStatus = z.enum(['PENDING', 'IN_PROGRESS', 'COMPLETED', 'FAILED']);
|
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),
|
nodeId: z.string().trim().min(1),
|
||||||
status: zNodeStatus,
|
status: zNodeStatus,
|
||||||
progress: z.number().nullable(),
|
progress: z.number().nullable(),
|
||||||
@ -85,7 +83,7 @@ export type NodeStatus = z.infer<typeof zNodeStatus>;
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Edges
|
// #region Edges
|
||||||
export const zInvocationNodeEdgeExtra = z.object({
|
const zInvocationNodeEdgeExtra = z.object({
|
||||||
type: z.union([z.literal('default'), z.literal('collapsed')]),
|
type: z.union([z.literal('default'), z.literal('collapsed')]),
|
||||||
});
|
});
|
||||||
export type InvocationNodeEdgeExtra = z.infer<typeof zInvocationNodeEdgeExtra>;
|
export type InvocationNodeEdgeExtra = z.infer<typeof zInvocationNodeEdgeExtra>;
|
||||||
|
@ -4,7 +4,7 @@ import { zFieldIdentifier } from './field';
|
|||||||
import { zInvocationNodeData, zNotesNodeData } from './invocation';
|
import { zInvocationNodeData, zNotesNodeData } from './invocation';
|
||||||
|
|
||||||
// #region Workflow misc
|
// #region Workflow misc
|
||||||
export const zXYPosition = z
|
const zXYPosition = z
|
||||||
.object({
|
.object({
|
||||||
x: z.number(),
|
x: z.number(),
|
||||||
y: z.number(),
|
y: z.number(),
|
||||||
@ -12,27 +12,27 @@ export const zXYPosition = z
|
|||||||
.default({ x: 0, y: 0 });
|
.default({ x: 0, y: 0 });
|
||||||
export type XYPosition = z.infer<typeof zXYPosition>;
|
export type XYPosition = z.infer<typeof zXYPosition>;
|
||||||
|
|
||||||
export const zDimension = z.number().gt(0).nullish();
|
const zDimension = z.number().gt(0).nullish();
|
||||||
export type Dimension = z.infer<typeof zDimension>;
|
export type Dimension = z.infer<typeof zDimension>;
|
||||||
|
|
||||||
export const zWorkflowCategory = z.enum(['user', 'default', 'project']);
|
const zWorkflowCategory = z.enum(['user', 'default', 'project']);
|
||||||
export type WorkflowCategory = z.infer<typeof zWorkflowCategory>;
|
export type WorkflowCategory = z.infer<typeof zWorkflowCategory>;
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Workflow Nodes
|
// #region Workflow Nodes
|
||||||
export const zWorkflowInvocationNode = z.object({
|
const zWorkflowInvocationNode = z.object({
|
||||||
id: z.string().trim().min(1),
|
id: z.string().trim().min(1),
|
||||||
type: z.literal('invocation'),
|
type: z.literal('invocation'),
|
||||||
data: zInvocationNodeData,
|
data: zInvocationNodeData,
|
||||||
position: zXYPosition,
|
position: zXYPosition,
|
||||||
});
|
});
|
||||||
export const zWorkflowNotesNode = z.object({
|
const zWorkflowNotesNode = z.object({
|
||||||
id: z.string().trim().min(1),
|
id: z.string().trim().min(1),
|
||||||
type: z.literal('notes'),
|
type: z.literal('notes'),
|
||||||
data: zNotesNodeData,
|
data: zNotesNodeData,
|
||||||
position: zXYPosition,
|
position: zXYPosition,
|
||||||
});
|
});
|
||||||
export const zWorkflowNode = z.union([zWorkflowInvocationNode, zWorkflowNotesNode]);
|
const zWorkflowNode = z.union([zWorkflowInvocationNode, zWorkflowNotesNode]);
|
||||||
|
|
||||||
export type WorkflowInvocationNode = z.infer<typeof zWorkflowInvocationNode>;
|
export type WorkflowInvocationNode = z.infer<typeof zWorkflowInvocationNode>;
|
||||||
export type WorkflowNotesNode = z.infer<typeof zWorkflowNotesNode>;
|
export type WorkflowNotesNode = z.infer<typeof zWorkflowNotesNode>;
|
||||||
@ -43,20 +43,20 @@ export const isWorkflowInvocationNode = (val: unknown): val is WorkflowInvocatio
|
|||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Workflow Edges
|
// #region Workflow Edges
|
||||||
export const zWorkflowEdgeBase = z.object({
|
const zWorkflowEdgeBase = z.object({
|
||||||
id: z.string().trim().min(1),
|
id: z.string().trim().min(1),
|
||||||
source: z.string().trim().min(1),
|
source: z.string().trim().min(1),
|
||||||
target: z.string().trim().min(1),
|
target: z.string().trim().min(1),
|
||||||
});
|
});
|
||||||
export const zWorkflowEdgeDefault = zWorkflowEdgeBase.extend({
|
const zWorkflowEdgeDefault = zWorkflowEdgeBase.extend({
|
||||||
type: z.literal('default'),
|
type: z.literal('default'),
|
||||||
sourceHandle: z.string().trim().min(1),
|
sourceHandle: z.string().trim().min(1),
|
||||||
targetHandle: z.string().trim().min(1),
|
targetHandle: z.string().trim().min(1),
|
||||||
});
|
});
|
||||||
export const zWorkflowEdgeCollapsed = zWorkflowEdgeBase.extend({
|
const zWorkflowEdgeCollapsed = zWorkflowEdgeBase.extend({
|
||||||
type: z.literal('collapsed'),
|
type: z.literal('collapsed'),
|
||||||
});
|
});
|
||||||
export const zWorkflowEdge = z.union([zWorkflowEdgeDefault, zWorkflowEdgeCollapsed]);
|
const zWorkflowEdge = z.union([zWorkflowEdgeDefault, zWorkflowEdgeCollapsed]);
|
||||||
|
|
||||||
export type WorkflowEdgeDefault = z.infer<typeof zWorkflowEdgeDefault>;
|
export type WorkflowEdgeDefault = z.infer<typeof zWorkflowEdgeDefault>;
|
||||||
export type WorkflowEdgeCollapsed = z.infer<typeof zWorkflowEdgeCollapsed>;
|
export type WorkflowEdgeCollapsed = z.infer<typeof zWorkflowEdgeCollapsed>;
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
import type { NodesState } from 'features/nodes/store/types';
|
import type { NodesState } from 'features/nodes/store/types';
|
||||||
import type { FieldInputInstance } from 'features/nodes/types/field';
|
|
||||||
import { isInvocationNode } from 'features/nodes/types/invocation';
|
import { isInvocationNode } from 'features/nodes/types/invocation';
|
||||||
import { omit, reduce } from 'lodash-es';
|
import { omit, reduce } from 'lodash-es';
|
||||||
import type { Graph } from 'services/api/types';
|
import type { Graph } from 'services/api/types';
|
||||||
import type { AnyInvocation } from 'services/events/types';
|
import type { AnyInvocation } from 'services/events/types';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
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.
|
* Builds a graph from the node editor state.
|
||||||
*/
|
*/
|
||||||
@ -31,8 +22,7 @@ export const buildNodesGraph = (nodesState: NodesState): Graph => {
|
|||||||
const transformedInputs = reduce(
|
const transformedInputs = reduce(
|
||||||
inputs,
|
inputs,
|
||||||
(inputsAccumulator, input, name) => {
|
(inputsAccumulator, input, name) => {
|
||||||
const parsedValue = parseFieldValue(input);
|
inputsAccumulator[name] = input.value;
|
||||||
inputsAccumulator[name] = parsedValue;
|
|
||||||
|
|
||||||
return inputsAccumulator;
|
return inputsAccumulator;
|
||||||
},
|
},
|
||||||
|
@ -13,58 +13,30 @@ export const NSFW_CHECKER = 'nsfw_checker';
|
|||||||
export const WATERMARKER = 'invisible_watermark';
|
export const WATERMARKER = 'invisible_watermark';
|
||||||
export const NOISE = 'noise';
|
export const NOISE = 'noise';
|
||||||
export const NOISE_HRF = 'noise_hrf';
|
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 MAIN_MODEL_LOADER = 'main_model_loader';
|
||||||
export const VAE_LOADER = 'vae_loader';
|
export const VAE_LOADER = 'vae_loader';
|
||||||
export const LORA_LOADER = 'lora_loader';
|
export const LORA_LOADER = 'lora_loader';
|
||||||
export const CLIP_SKIP = 'clip_skip';
|
export const CLIP_SKIP = 'clip_skip';
|
||||||
export const IMAGE_TO_LATENTS = 'image_to_latents';
|
export const IMAGE_TO_LATENTS = 'image_to_latents';
|
||||||
export const LATENTS_TO_LATENTS = 'latents_to_latents';
|
|
||||||
export const RESIZE = 'resize_image';
|
export const RESIZE = 'resize_image';
|
||||||
export const IMG2IMG_RESIZE = 'img2img_resize';
|
export const IMG2IMG_RESIZE = 'img2img_resize';
|
||||||
export const CANVAS_OUTPUT = 'canvas_output';
|
export const CANVAS_OUTPUT = 'canvas_output';
|
||||||
export const INPAINT_IMAGE = 'inpaint_image';
|
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_UP = 'inpaint_image_resize_up';
|
||||||
export const INPAINT_IMAGE_RESIZE_DOWN = 'inpaint_image_resize_down';
|
export const INPAINT_IMAGE_RESIZE_DOWN = 'inpaint_image_resize_down';
|
||||||
export const INPAINT_INFILL = 'inpaint_infill';
|
export const INPAINT_INFILL = 'inpaint_infill';
|
||||||
export const INPAINT_INFILL_RESIZE_DOWN = 'inpaint_infill_resize_down';
|
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_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 = '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_FROM_ALPHA = 'tomask';
|
||||||
export const MASK_EDGE = 'mask_edge';
|
|
||||||
export const MASK_BLUR = 'mask_blur';
|
|
||||||
export const MASK_COMBINE = 'mask_combine';
|
export const MASK_COMBINE = 'mask_combine';
|
||||||
export const MASK_RESIZE_UP = 'mask_resize_up';
|
export const MASK_RESIZE_UP = 'mask_resize_up';
|
||||||
export const MASK_RESIZE_DOWN = 'mask_resize_down';
|
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 CONTROL_NET_COLLECT = 'control_net_collect';
|
||||||
export const IP_ADAPTER_COLLECT = 'ip_adapter_collect';
|
export const IP_ADAPTER_COLLECT = 'ip_adapter_collect';
|
||||||
export const T2I_ADAPTER_COLLECT = 't2i_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 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 ESRGAN = 'esrgan';
|
||||||
export const DIVIDE = 'divide';
|
|
||||||
export const SCALE = 'scale_image';
|
|
||||||
export const SDXL_MODEL_LOADER = 'sdxl_model_loader';
|
export const SDXL_MODEL_LOADER = 'sdxl_model_loader';
|
||||||
export const SDXL_DENOISE_LATENTS = 'sdxl_denoise_latents';
|
export const SDXL_DENOISE_LATENTS = 'sdxl_denoise_latents';
|
||||||
export const SDXL_REFINER_MODEL_LOADER = 'sdxl_refiner_model_loader';
|
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 SEAMLESS = 'seamless';
|
||||||
export const SDXL_REFINER_SEAMLESS = 'refiner_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
|
// friendly graph ids
|
||||||
export const TEXT_TO_IMAGE_GRAPH = 'text_to_image_graph';
|
export const TEXT_TO_IMAGE_GRAPH = 'text_to_image_graph';
|
||||||
export const IMAGE_TO_IMAGE_GRAPH = 'image_to_image_graph';
|
export const IMAGE_TO_IMAGE_GRAPH = 'image_to_image_graph';
|
||||||
|
@ -11,13 +11,14 @@ export const getNeedsUpdate = (node: InvocationNode, template: InvocationTemplat
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return node.data.version !== template.version;
|
return node.data.version !== template.version;
|
||||||
}; /**
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
* Checks if a node may be updated by comparing its major version with the template's major 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 node The node to check.
|
||||||
* @param template The invocation template to check against.
|
* @param template The invocation template to check against.
|
||||||
*/
|
*/
|
||||||
|
const getMayUpdateNode = (node: InvocationNode, template: InvocationTemplate): boolean => {
|
||||||
export const getMayUpdateNode = (node: InvocationNode, template: InvocationTemplate): boolean => {
|
|
||||||
const needsUpdate = getNeedsUpdate(node, template);
|
const needsUpdate = getNeedsUpdate(node, template);
|
||||||
if (!needsUpdate || node.data.type !== template.type) {
|
if (!needsUpdate || node.data.type !== template.type) {
|
||||||
return false;
|
return false;
|
||||||
@ -25,7 +26,9 @@ export const getMayUpdateNode = (node: InvocationNode, template: InvocationTempl
|
|||||||
const templateMajor = zParsedSemver.parse(template.version).major;
|
const templateMajor = zParsedSemver.parse(template.version).major;
|
||||||
|
|
||||||
return satisfies(node.data.version, `^${templateMajor}`);
|
return satisfies(node.data.version, `^${templateMajor}`);
|
||||||
}; /**
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
* Updates a node to the latest version of its template:
|
* Updates a node to the latest version of its template:
|
||||||
* - Create a new node data object with the latest version of the 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.
|
* - 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.
|
* @param template The invocation template to update to.
|
||||||
* @throws {NodeUpdateError} If the node is not an invocation node.
|
* @throws {NodeUpdateError} If the node is not an invocation node.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const updateNode = (node: InvocationNode, template: InvocationTemplate): InvocationNode => {
|
export const updateNode = (node: InvocationNode, template: InvocationTemplate): InvocationNode => {
|
||||||
const mayUpdate = getMayUpdateNode(node, template);
|
const mayUpdate = getMayUpdateNode(node, template);
|
||||||
|
|
||||||
|
@ -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<ComboboxOnChange>(
|
|
||||||
(v) => {
|
|
||||||
if (!isParameterMaskBlurMethod(v?.value)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dispatch(setMaskBlurMethod(v.value));
|
|
||||||
},
|
|
||||||
[dispatch]
|
|
||||||
);
|
|
||||||
|
|
||||||
const value = useMemo(() => options.find((o) => o.value === maskBlurMethod), [maskBlurMethod, options]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FormControl>
|
|
||||||
<InformationalPopover feature="compositingBlurMethod">
|
|
||||||
<FormLabel>{t('parameters.maskBlurMethod')}</FormLabel>
|
|
||||||
</InformationalPopover>
|
|
||||||
<Combobox value={value} onChange={onChange} options={options} />
|
|
||||||
</FormControl>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default memo(ParamMaskBlurMethod);
|
|
@ -8,7 +8,7 @@ import { selectOptimalDimension } from 'features/parameters/store/generationSlic
|
|||||||
import { memo, useCallback, useMemo } from 'react';
|
import { memo, useCallback, useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
export const OPTIONS: ComboboxOption[] = [
|
const OPTIONS: ComboboxOption[] = [
|
||||||
{ label: 'None', value: 'none' },
|
{ label: 'None', value: 'none' },
|
||||||
{ label: 'Auto', value: 'auto' },
|
{ label: 'Auto', value: 'auto' },
|
||||||
{ label: 'Manual', value: 'manual' },
|
{ label: 'Manual', value: 'manual' },
|
||||||
|
@ -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)
|
// 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_LOW_CUTOFF = 0.23;
|
||||||
export const ICON_HIGH_CUTOFF = 1 / ICON_LOW_CUTOFF;
|
export const ICON_HIGH_CUTOFF = 1 / ICON_LOW_CUTOFF;
|
||||||
export const ICON_SIZE_PX = 64;
|
const ICON_SIZE_PX = 64;
|
||||||
export const ICON_PADDING_PX = 16;
|
const ICON_PADDING_PX = 16;
|
||||||
export const BOX_SIZE_CSS_CALC = `min(${ICON_SIZE_PX}px, calc(100% - ${ICON_PADDING_PX}px))`;
|
export const BOX_SIZE_CSS_CALC = `min(${ICON_SIZE_PX}px, calc(100% - ${ICON_PADDING_PX}px))`;
|
||||||
export const MOTION_ICON_INITIAL = {
|
export const MOTION_ICON_INITIAL = {
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
|
@ -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;
|
|
||||||
};
|
|
@ -1,6 +1,6 @@
|
|||||||
import { z } from 'zod';
|
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<typeof zAspectRatioID>;
|
export type AspectRatioID = z.infer<typeof zAspectRatioID>;
|
||||||
export const isAspectRatioID = (v: string): v is AspectRatioID => zAspectRatioID.safeParse(v).success;
|
export const isAspectRatioID = (v: string): v is AspectRatioID => zAspectRatioID.safeParse(v).success;
|
||||||
|
|
||||||
|
@ -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 };
|
|
||||||
};
|
|
@ -11,7 +11,6 @@ import type {
|
|||||||
ParameterCanvasCoherenceMode,
|
ParameterCanvasCoherenceMode,
|
||||||
ParameterCFGRescaleMultiplier,
|
ParameterCFGRescaleMultiplier,
|
||||||
ParameterCFGScale,
|
ParameterCFGScale,
|
||||||
ParameterMaskBlurMethod,
|
|
||||||
ParameterModel,
|
ParameterModel,
|
||||||
ParameterPrecision,
|
ParameterPrecision,
|
||||||
ParameterScheduler,
|
ParameterScheduler,
|
||||||
@ -25,7 +24,7 @@ import type { ImageDTO } from 'services/api/types';
|
|||||||
|
|
||||||
import type { GenerationState } from './types';
|
import type { GenerationState } from './types';
|
||||||
|
|
||||||
export const initialGenerationState: GenerationState = {
|
const initialGenerationState: GenerationState = {
|
||||||
_version: 1,
|
_version: 1,
|
||||||
cfgScale: 7.5,
|
cfgScale: 7.5,
|
||||||
cfgRescaleMultiplier: 0,
|
cfgRescaleMultiplier: 0,
|
||||||
@ -100,27 +99,12 @@ export const generationSlice = createSlice({
|
|||||||
setShouldFitToWidthHeight: (state, action: PayloadAction<boolean>) => {
|
setShouldFitToWidthHeight: (state, action: PayloadAction<boolean>) => {
|
||||||
state.shouldFitToWidthHeight = action.payload;
|
state.shouldFitToWidthHeight = action.payload;
|
||||||
},
|
},
|
||||||
resetSeed: (state) => {
|
|
||||||
state.seed = -1;
|
|
||||||
},
|
|
||||||
resetParametersState: (state) => {
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
...initialGenerationState,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
setShouldRandomizeSeed: (state, action: PayloadAction<boolean>) => {
|
setShouldRandomizeSeed: (state, action: PayloadAction<boolean>) => {
|
||||||
state.shouldRandomizeSeed = action.payload;
|
state.shouldRandomizeSeed = action.payload;
|
||||||
},
|
},
|
||||||
clearInitialImage: (state) => {
|
clearInitialImage: (state) => {
|
||||||
state.initialImage = undefined;
|
state.initialImage = undefined;
|
||||||
},
|
},
|
||||||
setMaskBlur: (state, action: PayloadAction<number>) => {
|
|
||||||
state.maskBlur = action.payload;
|
|
||||||
},
|
|
||||||
setMaskBlurMethod: (state, action: PayloadAction<ParameterMaskBlurMethod>) => {
|
|
||||||
state.maskBlurMethod = action.payload;
|
|
||||||
},
|
|
||||||
setCanvasCoherenceMode: (state, action: PayloadAction<ParameterCanvasCoherenceMode>) => {
|
setCanvasCoherenceMode: (state, action: PayloadAction<ParameterCanvasCoherenceMode>) => {
|
||||||
state.canvasCoherenceMode = action.payload;
|
state.canvasCoherenceMode = action.payload;
|
||||||
},
|
},
|
||||||
@ -261,8 +245,6 @@ export const generationSlice = createSlice({
|
|||||||
|
|
||||||
export const {
|
export const {
|
||||||
clearInitialImage,
|
clearInitialImage,
|
||||||
resetParametersState,
|
|
||||||
resetSeed,
|
|
||||||
setCfgScale,
|
setCfgScale,
|
||||||
setCfgRescaleMultiplier,
|
setCfgRescaleMultiplier,
|
||||||
setImg2imgStrength,
|
setImg2imgStrength,
|
||||||
@ -271,8 +253,6 @@ export const {
|
|||||||
setPositivePrompt,
|
setPositivePrompt,
|
||||||
setNegativePrompt,
|
setNegativePrompt,
|
||||||
setScheduler,
|
setScheduler,
|
||||||
setMaskBlur,
|
|
||||||
setMaskBlurMethod,
|
|
||||||
setCanvasCoherenceMode,
|
setCanvasCoherenceMode,
|
||||||
setCanvasCoherenceEdgeSize,
|
setCanvasCoherenceEdgeSize,
|
||||||
setCanvasCoherenceMinDenoise,
|
setCanvasCoherenceMinDenoise,
|
||||||
@ -302,7 +282,7 @@ export const { selectOptimalDimension } = generationSlice.selectors;
|
|||||||
export const selectGenerationSlice = (state: RootState) => state.generation;
|
export const selectGenerationSlice = (state: RootState) => state.generation;
|
||||||
|
|
||||||
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||||
export const migrateGenerationState = (state: any): GenerationState => {
|
const migrateGenerationState = (state: any): GenerationState => {
|
||||||
if (!('_version' in state)) {
|
if (!('_version' in state)) {
|
||||||
state._version = 1;
|
state._version = 1;
|
||||||
state.aspectRatio = initialAspectRatioState;
|
state.aspectRatio = initialAspectRatioState;
|
||||||
|
@ -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;
|
|
||||||
};
|
|
@ -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 (
|
|
||||||
<Flex flexDirection="column" gap={2} p={4} borderRadius="base" bg="base.900">
|
|
||||||
{props.children}
|
|
||||||
</Flex>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default memo(StyledFlex);
|
|
Loading…
Reference in New Issue
Block a user