From 96f6e9e683f8f682057448a36f9967e2b7ba56d6 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 23 Aug 2024 11:34:13 +1000 Subject: [PATCH] tidy(ui): remove unused stuff 2 --- invokeai/frontend/web/knip.ts | 2 ++ .../frontend/web/src/app/hooks/useSocketIO.ts | 6 ---- .../frontend/web/src/app/logging/logger.ts | 2 -- .../src/common/util/roundDownToMultiple.ts | 3 -- .../contexts/EntityAdapterContext.tsx | 2 ++ .../features/controlLayers/konva/constants.ts | 30 ------------------- .../features/controlLayers/konva/filters.ts | 4 --- .../features/controlLayers/konva/naming.ts | 2 -- .../src/features/controlLayers/konva/util.ts | 2 +- 9 files changed, 5 insertions(+), 48 deletions(-) diff --git a/invokeai/frontend/web/knip.ts b/invokeai/frontend/web/knip.ts index db89741fef..4572b23a38 100644 --- a/invokeai/frontend/web/knip.ts +++ b/invokeai/frontend/web/knip.ts @@ -9,6 +9,8 @@ const config: KnipConfig = { 'src/services/api/schema.ts', 'src/features/nodes/types/v1/**', 'src/features/nodes/types/v2/**', + // TODO(psyche): maybe we can clean up these utils after canvas v2 release + 'src/features/controlLayers/konva/util.ts', ], ignoreBinaries: ['only-allow'], paths: { diff --git a/invokeai/frontend/web/src/app/hooks/useSocketIO.ts b/invokeai/frontend/web/src/app/hooks/useSocketIO.ts index 89cb1ae172..2b39f24cc5 100644 --- a/invokeai/frontend/web/src/app/hooks/useSocketIO.ts +++ b/invokeai/frontend/web/src/app/hooks/useSocketIO.ts @@ -10,7 +10,6 @@ import { setEventListeners } from 'services/events/setEventListeners'; import type { ClientToServerEvents, ServerToClientEvents } from 'services/events/types'; import type { ManagerOptions, Socket, SocketOptions } from 'socket.io-client'; import { io } from 'socket.io-client'; -import { assert } from 'tsafe'; // Inject socket options and url into window for debugging declare global { @@ -22,11 +21,6 @@ declare global { export type AppSocket = Socket; export const $socket = atom(null); -export const getSocket = () => { - const socket = $socket.get(); - assert(socket !== null, 'Socket is not initialized'); - return socket; -}; export const $socketOptions = map>({}); const $isSocketInitialized = atom(false); diff --git a/invokeai/frontend/web/src/app/logging/logger.ts b/invokeai/frontend/web/src/app/logging/logger.ts index 074e657630..afc21a2ca9 100644 --- a/invokeai/frontend/web/src/app/logging/logger.ts +++ b/invokeai/frontend/web/src/app/logging/logger.ts @@ -27,9 +27,7 @@ export const zLogNamespace = z.enum([ 'queue', 'workflows', ]); -const zLogNamespacesArray = z.array(zLogNamespace); export type LogNamespace = z.infer; -export const isLogNamespaceArray = (v: unknown): v is LogNamespace[] => zLogNamespacesArray.safeParse(v).success; export const logger = (namespace: LogNamespace) => $logger.get().child({ namespace }); diff --git a/invokeai/frontend/web/src/common/util/roundDownToMultiple.ts b/invokeai/frontend/web/src/common/util/roundDownToMultiple.ts index 01c164d439..33214f1deb 100644 --- a/invokeai/frontend/web/src/common/util/roundDownToMultiple.ts +++ b/invokeai/frontend/web/src/common/util/roundDownToMultiple.ts @@ -1,9 +1,6 @@ export const roundDownToMultiple = (num: number, multiple: number): number => { return Math.floor(num / multiple) * multiple; }; -export const roundDownToMultipleMin = (num: number, multiple: number): number => { - return Math.max(multiple, Math.floor(num / multiple) * multiple); -}; export const roundToMultiple = (num: number, multiple: number): number => { return Math.round(num / multiple) * multiple; diff --git a/invokeai/frontend/web/src/features/controlLayers/contexts/EntityAdapterContext.tsx b/invokeai/frontend/web/src/features/controlLayers/contexts/EntityAdapterContext.tsx index 1a091d284e..a185d6fb69 100644 --- a/invokeai/frontend/web/src/features/controlLayers/contexts/EntityAdapterContext.tsx +++ b/invokeai/frontend/web/src/features/controlLayers/contexts/EntityAdapterContext.tsx @@ -35,6 +35,7 @@ export const EntityLayerAdapterGate = memo(({ children }: PropsWithChildren) => EntityLayerAdapterGate.displayName = 'EntityLayerAdapterGate'; +/** @knipignore */ export const useEntityLayerAdapter = (): CanvasLayerAdapter => { const adapter = useContext(EntityAdapterContext); assert(adapter, 'useEntityLayerAdapter must be used within a EntityLayerAdapterGate'); @@ -68,6 +69,7 @@ export const EntityMaskAdapterGate = memo(({ children }: PropsWithChildren) => { EntityMaskAdapterGate.displayName = 'EntityMaskAdapterGate'; +/** @knipignore */ export const useEntityMaskAdapter = (): CanvasMaskAdapter => { const adapter = useContext(EntityAdapterContext); assert(adapter, 'useEntityMaskAdapter must be used within a CanvasMaskAdapterGate'); diff --git a/invokeai/frontend/web/src/features/controlLayers/konva/constants.ts b/invokeai/frontend/web/src/features/controlLayers/konva/constants.ts index 5f9e2c52e1..1af95a77fa 100644 --- a/invokeai/frontend/web/src/features/controlLayers/konva/constants.ts +++ b/invokeai/frontend/web/src/features/controlLayers/konva/constants.ts @@ -5,11 +5,6 @@ export const TRANSPARENCY_CHECKER_PATTERN = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAEsmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS41LjAiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgeG1sbnM6ZXhpZj0iaHR0cDovL25zLmFkb2JlLmNvbS9leGlmLzEuMC8iCiAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyIKICAgIHhtbG5zOnBob3Rvc2hvcD0iaHR0cDovL25zLmFkb2JlLmNvbS9waG90b3Nob3AvMS4wLyIKICAgIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIKICAgIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY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JrXKrKHHj1wV/AbfKtVJESq53TdywXs9rakv2nJ7zfM73nOfpnOeAPZJRVMPhAzWb18NTAffC4pK7oYiDTjpw4YgqhjYeCgWpaR8P2Kx457Vq1T73rzXHE4YCtkbhMUXT88LTwsG1vGbxrnC7ko7Ghc+F+3W5oPC9pcfKXLQ4VeYvi/VIeALsbcLuVBXHqlhJ66qwvByPmikov/exXuJMZOfnJPaId2MQZooAbmaYZAI/g4zK7MfLEAOyoka+7yd/lpzkKjJrrKOzSoo0efpFLUj1hMSk6AkZGdat/v/tq5EcHipXdwag/sU033qhYQdK26b5eWyapROoe4arbCU/dwQj76JvVzTPIbRuwsV1RYvtweUWdD1pUT36I9WJ25NJeD2DlkVw3ULTcrlnv/ucPkJkQ77qBvYPoE/Ot658AxagZ8FoS/a7AAAACXBIWXMAAC4jAAAuIwF4pT92AAAAL0lEQVQ4jWM8ffo0A25gYmKCR5YJjxxBMKp5ZGhm/P//Px7pM2fO0MrmUc0jQzMAB2EIhZC3pUYAAAAASUVORK5CYII='; -/** - * The color of a bounding box stroke when its object is selected. - */ -export const BBOX_SELECTED_STROKE = 'rgba(78, 190, 255, 1)'; - /** * The inner border color for the brush preview. */ @@ -30,21 +25,6 @@ export const BRUSH_ERASER_BORDER_WIDTH = 1; */ export const BRUSH_SPACING_TARGET_SCALE = 0.1; -/** - * The minimum brush spacing in pixels. - */ -export const MIN_BRUSH_SPACING_PX = 5; - -/** - * The maximum brush spacing in pixels. - */ -export const MAX_BRUSH_SPACING_PX = 15; - -/** - * The debounce time in milliseconds for debounced renderers. - */ -export const DEBOUNCE_MS = 300; - /** * Konva wheel zoom exponential scale factor */ @@ -64,13 +44,3 @@ export const MAX_CANVAS_SCALE = 20; * The fine grid size of the canvas */ export const CANVAS_GRID_SIZE_FINE = 8; - -/** - * The coarse grid size of the canvas - */ -export const CANVAS_GRID_SIZE_COARSE = 64; - -/** - * Document fit padding - */ -export const DOCUMENT_FIT_PADDING_PX = 50; diff --git a/invokeai/frontend/web/src/features/controlLayers/konva/filters.ts b/invokeai/frontend/web/src/features/controlLayers/konva/filters.ts index da374a762b..2fcdf4ce60 100644 --- a/invokeai/frontend/web/src/features/controlLayers/konva/filters.ts +++ b/invokeai/frontend/web/src/features/controlLayers/konva/filters.ts @@ -19,7 +19,3 @@ export const LightnessToAlphaFilter = (imageData: ImageData): void => { imageData.data[i * 4 + 3] = (cMin + cMax) / 2; } }; - -export const FILTER_MAP = { - LightnessToAlphaFilter: LightnessToAlphaFilter, -} as const; diff --git a/invokeai/frontend/web/src/features/controlLayers/konva/naming.ts b/invokeai/frontend/web/src/features/controlLayers/konva/naming.ts index 2fbe23ccff..a60e8456dc 100644 --- a/invokeai/frontend/web/src/features/controlLayers/konva/naming.ts +++ b/invokeai/frontend/web/src/features/controlLayers/konva/naming.ts @@ -12,7 +12,5 @@ export const getEraserLineId = (entityId: string, lineId: string, isBuffer?: boo export const getRectShapeId = (entityId: string, rectId: string, isBuffer?: boolean) => `${isBuffer ? 'buffer_' : ''}rect_${rectId}`; export const getImageObjectId = (entityId: string, imageId: string) => `image_${imageId}`; -export const getObjectGroupId = (entityId: string, groupId: string) => `objectGroup_${groupId}`; -export const getLayerBboxId = (entityId: string) => `${entityId}.bbox`; export const getCAId = (entityId: string) => `control_adapter_${entityId}`; export const getIPAId = (entityId: string) => `ip_adapter_${entityId}`; diff --git a/invokeai/frontend/web/src/features/controlLayers/konva/util.ts b/invokeai/frontend/web/src/features/controlLayers/konva/util.ts index 2c4037242d..5c917dddb7 100644 --- a/invokeai/frontend/web/src/features/controlLayers/konva/util.ts +++ b/invokeai/frontend/web/src/features/controlLayers/konva/util.ts @@ -208,7 +208,7 @@ export const downloadBlob = (blob: Blob, fileName: string) => { /** * Gets an ImageData object from an image dataURL by drawing it to a canvas. */ -export const dataURLToImageData = async (dataURL: string, width: number, height: number): Promise => { +export const dataURLToImageData = (dataURL: string, width: number, height: number): Promise => { return new Promise((resolve, reject) => { const canvas = document.createElement('canvas'); canvas.width = width;