From 999c3a443bf2a4e32d93aa899d6519fae050aa28 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Sun, 26 Mar 2023 15:40:45 +1100 Subject: [PATCH] feat(ui): add socketio types --- .../frontend/web/src/services/events/types.ts | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 invokeai/frontend/web/src/services/events/types.ts diff --git a/invokeai/frontend/web/src/services/events/types.ts b/invokeai/frontend/web/src/services/events/types.ts new file mode 100644 index 0000000000..24b8f08413 --- /dev/null +++ b/invokeai/frontend/web/src/services/events/types.ts @@ -0,0 +1,79 @@ +import { + CollectInvocationOutput, + GraphInvocationOutput, + ImageOutput, + IterateInvocationOutput, + MaskOutput, + PromptOutput, +} from '../api'; + +/** + * A progress image, we get one for each step in the generation + */ +export type ProgressImage = { + dataURL: string; + width: number; + height: number; +}; + +/** + * A `generator_progress` socket.io event. + * + * @example socket.on('generator_progress', (data: GeneratorProgressEvent) => { ... } + */ +export type GeneratorProgressEvent = { + graph_execution_state_id: string; + invocation_id: string; + progress_image?: ProgressImage; + step: number; + total_steps: number; +}; + +/** + * A `invocation_complete` socket.io event. + * + * `result` is a discriminated union with a `type` property as the discriminant. + * + * @example socket.on('invocation_complete', (data: InvocationCompleteEvent) => { ... } + */ +export type InvocationCompleteEvent = { + graph_execution_state_id: string; + invocation_id: string; + result: + | CollectInvocationOutput + | GraphInvocationOutput + | ImageOutput + | IterateInvocationOutput + | MaskOutput + | PromptOutput; +}; + +/** + * A `invocation_error` socket.io event. + * + * @example socket.on('invocation_error', (data: InvocationErrorEvent) => { ... } + */ +export type InvocationErrorEvent = { + graph_execution_state_id: string; + invocation_id: string; + error: string; +}; + +/** + * A `invocation_started` socket.io event. + * + * @example socket.on('invocation_started', (data: InvocationStartedEvent) => { ... } + */ +export type InvocationStartedEvent = { + graph_execution_state_id: string; + invocation_id: string; +}; + +/** + * A `graph_execution_state_complete` socket.io event. + * + * @example socket.on('graph_execution_state_complete', (data: GraphExecutionStateCompleteEvent) => { ... } + */ +export type GraphExecutionStateCompleteEvent = { + graph_execution_state_id: string; +};