"git@developer.sourcefind.cn:chenpangpang/ComfyUI.git" did not exist on "cc127eeabd5cdd42f1a472e43938c6a202e89626"
Commit 8d0a1423 authored by pythongosssss's avatar pythongosssss
Browse files

adds simple access to server from custom nodes

parent dd095efc
......@@ -29,6 +29,8 @@ async def cache_control(request: web.Request, handler):
class PromptServer():
def __init__(self, loop):
PromptServer.instance = self
mimetypes.init();
mimetypes.types_map['.js'] = 'application/javascript; charset=utf-8'
self.prompt_queue = None
......
class ComfyApi extends EventTarget {
#registered = new Set();
constructor() {
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.
*/
......@@ -82,7 +89,11 @@ class ComfyApi extends EventTarget {
this.dispatchEvent(new CustomEvent("executed", { detail: msg.data }));
break;
default:
throw new Error("Unknown message type");
if (this.#registered.has(msg.type)) {
this.dispatchEvent(new CustomEvent(msg.type, { detail: msg.data }));
} else {
throw new Error("Unknown message type");
}
}
} catch (error) {
console.warn("Unhandled message:", event.data);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment