@comfyorg/comfyui-desktop-bridge-types 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/comfyDesktopBridge.d.ts +83 -49
- package/index.d.ts +1 -1
- package/package.json +2 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Comfy Org
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @comfyorg/comfyui-desktop-bridge-types
|
|
2
|
+
|
|
3
|
+
TypeScript definitions for `window.__comfyDesktop2`, the API Comfy Desktop
|
|
4
|
+
exposes to the frontend it hosts.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
npm install --save-dev @comfyorg/comfyui-desktop-bridge-types
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import type { ComfyDesktop2Bridge } from '@comfyorg/comfyui-desktop-bridge-types'
|
|
12
|
+
|
|
13
|
+
declare global {
|
|
14
|
+
interface Window {
|
|
15
|
+
__comfyDesktop2?: ComfyDesktop2Bridge
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Every member is optional for a reason
|
|
21
|
+
|
|
22
|
+
Which members actually exist at runtime is decided by the Desktop binary the
|
|
23
|
+
user is running, and Desktop binaries update far more slowly than the frontend
|
|
24
|
+
that ships into them. Callers must guard every access and carry a fallback —
|
|
25
|
+
including when the member exists but rejects:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
async function openModelAccessPage(url: string): Promise<void> {
|
|
29
|
+
try {
|
|
30
|
+
if ((await window.__comfyDesktop2?.openModelAccessPage?.(url)) === true) return
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error('Desktop could not open the access page:', error)
|
|
33
|
+
}
|
|
34
|
+
window.open(url, '_blank', 'noopener,noreferrer')
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`ComfyDesktop2BridgeImplementation` is the provider-side counterpart: it makes
|
|
39
|
+
every top-level member required, so Desktop's preload cannot claim the contract
|
|
40
|
+
while omitting part of it.
|
|
41
|
+
|
|
42
|
+
## Provenance
|
|
43
|
+
|
|
44
|
+
Generated from `src/types/comfyDesktopBridge.ts` in
|
|
45
|
+
[Comfy-Org/Comfy-Desktop](https://github.com/Comfy-Org/Comfy-Desktop), which is
|
|
46
|
+
the same file the preload implements. Edit that file, run
|
|
47
|
+
`pnpm run bridge-types:gen`, and bump the version in this package's
|
|
48
|
+
`package.json`. Merging to `main` then publishes it; CI refuses a contract
|
|
49
|
+
change that arrives without a bump.
|
package/comfyDesktopBridge.d.ts
CHANGED
|
@@ -1,66 +1,100 @@
|
|
|
1
1
|
export interface ComfyDownloadProgress {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
/** Stable per-job identifier assigned by the desktop app. The download
|
|
3
|
+
* controls accept it in place of the URL. Optional: older desktop
|
|
4
|
+
* versions do not send it. */
|
|
5
|
+
id?: string
|
|
6
|
+
url: string
|
|
7
|
+
filename: string
|
|
8
|
+
directory?: string
|
|
9
|
+
progress: number
|
|
10
|
+
receivedBytes?: number
|
|
11
|
+
totalBytes?: number
|
|
12
|
+
speedBytesPerSec?: number
|
|
13
|
+
etaSeconds?: number
|
|
14
|
+
status: 'pending' | 'downloading' | 'paused' | 'completed' | 'error' | 'cancelled'
|
|
15
|
+
error?: string
|
|
16
|
+
isImage?: boolean
|
|
13
17
|
}
|
|
14
18
|
export interface TerminalRestore {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
buffer: string[]
|
|
20
|
+
size: {
|
|
21
|
+
cols: number
|
|
22
|
+
rows: number
|
|
23
|
+
}
|
|
24
|
+
exited: boolean
|
|
21
25
|
}
|
|
22
26
|
export interface LogsRestore {
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
installationId: string
|
|
28
|
+
buffer: string[]
|
|
25
29
|
}
|
|
26
30
|
export interface LogsOutputMsg {
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
installationId: string
|
|
32
|
+
text: string
|
|
29
33
|
}
|
|
30
|
-
export type ComfyDesktop2TelemetryValue = string | number | boolean | null
|
|
31
|
-
export type ComfyDesktop2TelemetryProperties = Record<
|
|
34
|
+
export type ComfyDesktop2TelemetryValue = string | number | boolean | null
|
|
35
|
+
export type ComfyDesktop2TelemetryProperties = Record<
|
|
36
|
+
string,
|
|
37
|
+
ComfyDesktop2TelemetryValue | ComfyDesktop2TelemetryValue[]
|
|
38
|
+
>
|
|
39
|
+
export type ComfyDesktop2FirebaseAuthState =
|
|
40
|
+
| {
|
|
41
|
+
status: 'pending'
|
|
42
|
+
}
|
|
43
|
+
| {
|
|
44
|
+
status: 'signed_out'
|
|
45
|
+
}
|
|
46
|
+
| {
|
|
47
|
+
status: 'signed_in'
|
|
48
|
+
userId: string
|
|
49
|
+
}
|
|
32
50
|
export interface ComfyDesktop2TerminalBridge {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
51
|
+
subscribe(installationId?: string): Promise<TerminalRestore>
|
|
52
|
+
unsubscribe(installationId?: string): Promise<void>
|
|
53
|
+
write(data: string, installationId?: string): Promise<void>
|
|
54
|
+
resize(cols: number, rows: number, installationId?: string): Promise<void>
|
|
55
|
+
restart(installationId?: string): Promise<TerminalRestore>
|
|
56
|
+
openPopout(): Promise<void>
|
|
57
|
+
onOutput(callback: (data: string) => void): () => void
|
|
58
|
+
onExited(callback: () => void): () => void
|
|
41
59
|
}
|
|
42
60
|
export interface ComfyDesktop2LogsBridge {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
subscribe(installationId?: string): Promise<LogsRestore>
|
|
62
|
+
unsubscribe(installationId?: string): Promise<void>
|
|
63
|
+
openPopout(): Promise<void>
|
|
64
|
+
onOutput(callback: (msg: LogsOutputMsg) => void): () => void
|
|
47
65
|
}
|
|
48
66
|
export interface ComfyDesktop2TelemetryBridge {
|
|
49
|
-
|
|
67
|
+
capture(event: string, properties?: ComfyDesktop2TelemetryProperties): void
|
|
68
|
+
/** Report the hosted view's complete Firebase state for process-wide consensus. */
|
|
69
|
+
reportFirebaseAuthState?(state: ComfyDesktop2FirebaseAuthState): void
|
|
50
70
|
}
|
|
51
71
|
export interface ComfyDesktop2Bridge {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
/** Reports whether the backend server is cloud/remote, not the user's location.
|
|
73
|
+
* Optional: desktop builds predating it are still in the wild. */
|
|
74
|
+
isRemote?(): boolean
|
|
75
|
+
openTerminal?: () => Promise<boolean>
|
|
76
|
+
openMcpSetup?: () => Promise<boolean>
|
|
77
|
+
/** Opens a model provider access page in the hosted frontend's browser session.
|
|
78
|
+
* Resolves `true` when the host has taken ownership of the request.
|
|
79
|
+
* On `false` or rejection the frontend falls back to opening a new tab. */
|
|
80
|
+
openModelAccessPage?: (url: string) => Promise<boolean>
|
|
81
|
+
downloadModel?: (url: string, filename: string, directory: string) => Promise<boolean>
|
|
82
|
+
downloadAsset?: (url: string, filename: string, authToken?: string) => Promise<boolean>
|
|
83
|
+
pauseDownload?: (url: string) => Promise<boolean>
|
|
84
|
+
resumeDownload?: (url: string) => Promise<boolean>
|
|
85
|
+
cancelDownload?: (url: string) => Promise<boolean>
|
|
86
|
+
onDownloadProgress?: (callback: (data: ComfyDownloadProgress) => void) => () => void
|
|
87
|
+
reportTheme?: (bg: string, text: string) => void
|
|
88
|
+
Terminal?: ComfyDesktop2TerminalBridge
|
|
89
|
+
Logs?: ComfyDesktop2LogsBridge
|
|
90
|
+
Telemetry?: ComfyDesktop2TelemetryBridge
|
|
63
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* The `-?` mapper intentionally requires every top-level bridge member.
|
|
94
|
+
* Adding an optional top-level member to `ComfyDesktop2Bridge` is therefore a
|
|
95
|
+
* breaking change for implementations of this type. Optional members of nested
|
|
96
|
+
* bridge types remain optional because the mapper is not recursive.
|
|
97
|
+
*/
|
|
64
98
|
export type ComfyDesktop2BridgeImplementation = {
|
|
65
|
-
|
|
66
|
-
}
|
|
99
|
+
[K in keyof ComfyDesktop2Bridge]-?: NonNullable<ComfyDesktop2Bridge[K]>
|
|
100
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './comfyDesktopBridge'
|
|
1
|
+
export * from './comfyDesktopBridge.js'
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comfyorg/comfyui-desktop-bridge-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "TypeScript definitions for the Comfy Desktop hosted frontend bridge",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"types": "./index.d.ts",
|
|
8
8
|
"files": [
|
|
9
|
-
"
|
|
10
|
-
"index.d.ts",
|
|
9
|
+
"*.d.ts",
|
|
11
10
|
"index.js"
|
|
12
11
|
],
|
|
13
12
|
"publishConfig": {
|