Queue beginnings

This commit is contained in:
space-nuko
2023-04-07 22:01:18 -05:00
parent 838b3ce17b
commit c964343609
12 changed files with 242 additions and 22 deletions

View File

@@ -0,0 +1,53 @@
import type { ComfyAPIQueueStatus } from "$lib/api";
import type { Progress } from "$lib/components/ComfyApp";
import { writable, type Writable } from "svelte/store";
export type QueueItem = {
name: string
}
type QueueStateOps = {
statusUpdated: (status: ComfyAPIQueueStatus) => void,
executingUpdated: (runningNodeId: string | null) => void,
progressUpdated: (progress: Progress | null) => void
}
export type QueueState = {
queueRemaining: number | "X" | null;
runningNodeId: number | null;
progress: Progress | null
}
type WritableQueueStateStore = Writable<QueueState> & QueueStateOps;
const store: Writable<QueueState> = writable({ queueRemaining: null, runningNodeId: null, progress: null })
function statusUpdated(status: ComfyAPIQueueStatus) {
store.update((s) => {
s.queueRemaining = status.exec_info.queue_remaining;
return s
})
}
function executingUpdated(runningNodeId: string | null) {
store.update((s) => {
s.progress = null;
s.runningNodeId = parseInt(runningNodeId);
return s
})
}
function progressUpdated(progress: Progress | null) {
store.update((s) => {
s.progress = progress;
return s
})
}
const queueStateStore: WritableQueueStateStore =
{
...store,
statusUpdated,
executingUpdated,
progressUpdated
}
export default queueStateStore;

View File

@@ -11,6 +11,10 @@ export type WidgetUIState = {
isVirtual: boolean
}
export type WidgetDrawState = {
isNodeExecuting: boolean
}
type NodeID = number;
type WidgetStateOps = {
@@ -24,7 +28,7 @@ type WidgetStateOps = {
export type WidgetStateStore = Record<NodeID, WidgetUIState[]>;
type WritableWidgetStateStore = Writable<WidgetStateStore> & WidgetStateOps;
const store: Writable<Record<NodeID, WidgetUIState[]>> = writable({})
const store: Writable<WidgetStateStore> = writable({})
function clear() {
store.set({})