Download frontend/src/lib/comfy-api.ts from turtle89431/Moxie-Multimedia: direct link, hf CLI and curl.
- Browser
- Download file 1.76 kB
-
https://huggingface.co/turtle89431/Moxie-Multimedia/resolve/main/frontend/src/lib/comfy-api.ts
- Command line
-
hf download hf://turtle89431/Moxie-Multimedia/frontend/src/lib/comfy-api.ts
-
curl -L -o comfy-api.ts https://huggingface.co/turtle89431/Moxie-Multimedia/resolve/main/frontend/src/lib/comfy-api.ts
1.76 kB
| import type { ComfyApp } from '@comfyorg/comfyui-frontend-types' | |
| declare global { | |
| // eslint-disable-next-line no-var | |
| var comfyAPI: { app: { app: ComfyApp } } | undefined | |
| } | |
| const app = globalThis.comfyAPI!.app.app | |
| type PromptCallback = (text: string | null) => void | |
| type ConfirmCallback = () => void | |
| export const $prompt = ( | |
| title: string, | |
| message: string, | |
| fn: PromptCallback = () => {} | |
| ): void => { | |
| try { | |
| app.extensionManager.dialog.prompt({ title, message }).then((text: string) => { | |
| fn(text) | |
| }).catch(() => { | |
| fn(null) | |
| }) | |
| } catch { | |
| const text = globalThis.prompt(title, message) | |
| fn(text) | |
| } | |
| } | |
| export const $confirm = ( | |
| title: string, | |
| message: string, | |
| success: ConfirmCallback = () => {}, | |
| cancel: ConfirmCallback = () => {} | |
| ): void => { | |
| try { | |
| app.extensionManager.dialog.confirm({ title, message }).then((value: boolean) => { | |
| if (value) success() | |
| else cancel() | |
| }) | |
| } catch { | |
| success() | |
| } | |
| } | |
| export const $success = (title: string, message: string, life = 3000): void => { | |
| try { | |
| app.extensionManager.toast.add({ | |
| severity: 'success', | |
| summary: title, | |
| detail: message, | |
| life | |
| }) | |
| } catch { | |
| globalThis.alert(title) | |
| } | |
| } | |
| export const $error = (title: string, message: string, life = 3000): void => { | |
| try { | |
| app.extensionManager.toast.add({ | |
| severity: 'error', | |
| summary: title, | |
| detail: message, | |
| life | |
| }) | |
| } catch { | |
| globalThis.alert(title) | |
| } | |
| } | |
| export const $warning = (title: string, message: string, life = 3000): void => { | |
| try { | |
| app.extensionManager.toast.add({ | |
| severity: 'warn', | |
| summary: title, | |
| detail: message, | |
| life | |
| }) | |
| } catch { | |
| globalThis.alert(title) | |
| } | |
| } |