refactor(ui): metadata recall (wip)

just enough let the app run
This commit is contained in:
psychedelicious
2024-06-16 12:24:06 +10:00
parent 11596e45d1
commit 9be3e0050d
9 changed files with 231 additions and 225 deletions

View File

@@ -44,15 +44,14 @@ export const RASTER_LAYER_IMAGE_NAME = 'raster_layer.image';
export const INPAINT_MASK_LAYER_NAME = 'inpaint_mask_layer';
// Getters for non-singleton layer and object IDs
export const getRGLayerId = (layerId: string) => `${RG_LAYER_NAME}_${layerId}`;
export const getRasterLayerId = (layerId: string) => `${RASTER_LAYER_NAME}_${layerId}`;
export const getBrushLineId = (layerId: string, lineId: string) => `${layerId}.brush_line_${lineId}`;
export const getEraserLineId = (layerId: string, lineId: string) => `${layerId}.eraser_line_${lineId}`;
export const getRectShapeId = (layerId: string, lineId: string) => `${layerId}.rect_${lineId}`;
export const getImageObjectId = (layerId: string, imageName: string) => `${layerId}.image_${imageName}`;
export const getObjectGroupId = (layerId: string, groupId: string) => `${layerId}.objectGroup_${groupId}`;
export const getLayerBboxId = (layerId: string) => `${layerId}.bbox`;
export const getCALayerId = (layerId: string) => `control_adapter_layer_${layerId}`;
export const getCALayerImageId = (layerId: string, imageName: string) => `${layerId}.image_${imageName}`;
export const getIILayerImageId = (layerId: string, imageName: string) => `${layerId}.image_${imageName}`;
export const getIPALayerId = (layerId: string) => `ip_adapter_layer_${layerId}`;
export const getRGId = (entityId: string) => `${RG_LAYER_NAME}_${entityId}`;
export const getLayerId = (entityId: string) => `${RASTER_LAYER_NAME}_${entityId}`;
export const getBrushLineId = (entityId: string, lineId: string) => `${entityId}.brush_line_${lineId}`;
export const getEraserLineId = (entityId: string, lineId: string) => `${entityId}.eraser_line_${lineId}`;
export const getRectShapeId = (entityId: string, rectId: string) => `${entityId}.rect_${rectId}`;
export const getImageObjectId = (entityId: string, imageName: string) => `${entityId}.image_${imageName}`;
export const getObjectGroupId = (entityId: string, groupId: string) => `${entityId}.objectGroup_${groupId}`;
export const getLayerBboxId = (entityId: string) => `${entityId}.bbox`;
export const getCAId = (entityId: string) => `control_adapter_${entityId}`;
export const getCAImageId = (entityId: string, imageName: string) => `${entityId}.image_${imageName}`;
export const getIPAId = (entityId: string) => `ip_adapter_${entityId}`;

View File

@@ -1,5 +1,5 @@
import { LightnessToAlphaFilter } from 'features/controlLayers/konva/filters';
import { CA_LAYER_IMAGE_NAME, CA_LAYER_NAME, getCALayerImageId } from 'features/controlLayers/konva/naming';
import { CA_LAYER_IMAGE_NAME, CA_LAYER_NAME, getCAImageId } from 'features/controlLayers/konva/naming';
import type { ControlAdapterData } from 'features/controlLayers/store/types';
import Konva from 'konva';
import type { ImageDTO } from 'services/api/types';
@@ -61,7 +61,7 @@ const updateCALayerImageSource = async (
return;
}
const imageEl = new Image();
const imageId = getCALayerImageId(ca.id, imageName);
const imageId = getCAImageId(ca.id, imageName);
imageEl.onload = () => {
// Find the existing image or create a new one - must find using the name, bc the id may have just changed
const konvaImage =
@@ -144,7 +144,7 @@ export const renderCALayer = (
if (canvasImageSource instanceof HTMLImageElement) {
const image = ca.processedImage ?? ca.image;
if (image && canvasImageSource.id !== getCALayerImageId(ca.id, image.name)) {
if (image && canvasImageSource.id !== getCAImageId(ca.id, image.name)) {
imageSourceNeedsUpdate = true;
} else if (!image) {
imageSourceNeedsUpdate = true;

View File

@@ -574,7 +574,7 @@ const zRect = z.object({
height: z.number().min(1),
});
const zLayerData = z.object({
export const zLayerData = z.object({
id: zId,
type: z.literal('layer'),
isEnabled: z.boolean(),
@@ -587,7 +587,7 @@ const zLayerData = z.object({
});
export type LayerData = z.infer<typeof zLayerData>;
const zIPAdapterData = z.object({
export const zIPAdapterData = z.object({
id: zId,
type: z.literal('ip_adapter'),
isEnabled: z.boolean(),
@@ -637,7 +637,7 @@ const zMaskObject = z
})
.pipe(z.discriminatedUnion('type', [zBrushLine, zEraserline, zRectShape]));
const zRegionalGuidanceData = z.object({
export const zRegionalGuidanceData = z.object({
id: zId,
type: z.literal('regional_guidance'),
isEnabled: z.boolean(),
@@ -709,7 +709,7 @@ const zT2IAdapterData = zControlAdapterDataBase.extend({
});
export type T2IAdapterData = z.infer<typeof zT2IAdapterData>;
const zControlAdapterData = z.discriminatedUnion('adapterType', [zControlNetData, zT2IAdapterData]);
export const zControlAdapterData = z.discriminatedUnion('adapterType', [zControlNetData, zT2IAdapterData]);
export type ControlAdapterData = z.infer<typeof zControlAdapterData>;
export type ControlNetConfig = Pick<
ControlNetData,