|
|
@ -1,8 +1,15 @@ |
|
|
|
class ComfyApi extends EventTarget { |
|
|
|
class ComfyApi extends EventTarget { |
|
|
|
|
|
|
|
#registered = new Set(); |
|
|
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
constructor() { |
|
|
|
super(); |
|
|
|
super(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addEventListener(type, callback, options) { |
|
|
|
|
|
|
|
super.addEventListener(type, callback, options); |
|
|
|
|
|
|
|
this.#registered.add(type); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Poll status for colab and other things that don't support websockets. |
|
|
|
* Poll status for colab and other things that don't support websockets. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -82,8 +89,12 @@ class ComfyApi extends EventTarget { |
|
|
|
this.dispatchEvent(new CustomEvent("executed", { detail: msg.data })); |
|
|
|
this.dispatchEvent(new CustomEvent("executed", { detail: msg.data })); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
|
|
|
|
if (this.#registered.has(msg.type)) { |
|
|
|
|
|
|
|
this.dispatchEvent(new CustomEvent(msg.type, { detail: msg.data })); |
|
|
|
|
|
|
|
} else { |
|
|
|
throw new Error("Unknown message type"); |
|
|
|
throw new Error("Unknown message type"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
console.warn("Unhandled message:", event.data); |
|
|
|
console.warn("Unhandled message:", event.data); |
|
|
|
} |
|
|
|
} |
|
|
|