forked from lightningpixel/modly
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelectron.d.ts
More file actions
324 lines (308 loc) · 12.9 KB
/
Copy pathelectron.d.ts
File metadata and controls
324 lines (308 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
// Type declarations for the Electron API exposed via preload
export {}
import type {
AssetLibraryListResult,
AssetLibraryOpenRequest,
AssetLibraryOpenResult,
AssetLibraryReadRequest,
AssetLibraryReadResult,
} from './assetLibrary'
// ─── Extension types ──────────────────────────────────────────────────────────
export interface ExtensionNode {
id: string
name: string
input: 'image' | 'text' | 'mesh' | 'audio'
inputs?: ('image' | 'text' | 'mesh' | 'audio')[] // multi-input nodes; overrides input when set
inputLabels?: string[] // display labels per input slot (e.g. positive/negative)
output: 'image' | 'text' | 'mesh' | 'audio'
paramsSchema: ParamSchema[]
paramDefaults?: Record<string, number | string>
hfRepo?: string
downloadCheck?: string
hfSkipPrefixes?: string[]
hfIncludePrefixes?: string[]
/** If set, this capability shares weights with the specified owner capability (format: "ext_id/node_id"). Downloads will go to the owner's directory. */
weight_owner_id?: string
}
export interface ModelExtension {
type: 'model'
id: string
name: string
version?: string
description?: string
author?: string
trusted: boolean
builtin: boolean
source?: string
localPath?: string
nodes: ExtensionNode[]
/** Folder exists but is not a loadable extension — see manifestError */
corrupted?: boolean
/** Why the folder is corrupted: manifest gone, manifest unparseable, or install never completed */
manifestError?: 'missing' | 'invalid' | 'incomplete'
}
export type PickerIntent = 'folder' | 'image' | 'mesh' | 'text'
export interface ParamSchema {
id: string
label: string
type: 'select' | 'int' | 'float' | 'string' | 'file-select'
default: number | string
options?: { value: number | string; label: string }[]
min?: number
max?: number
step?: number
tooltip?: string
show_if?: Record<string, string | number | (string | number)[]>
// string: which native dialog the browse button opens (default: 'folder')
pickerIntent?: PickerIntent
/** snake_case alias of pickerIntent, for manifests that follow show_if/dir_from. */
picker_intent?: PickerIntent
// file-select: dropdown of the files inside the folder held by another param
dir_from?: string // id of the (string) param holding the folder path
extensions?: string[] // file extensions to list (e.g. ["json"])
}
export interface ProcessExtension {
type: 'process'
id: string
name: string
version?: string
description?: string
author?: string
trusted: boolean
builtin: boolean
source?: string
localPath?: string
entry: string
nodes: ExtensionNode[]
/** Folder exists but is not a loadable extension — see manifestError */
corrupted?: boolean
/** Why the folder is corrupted: manifest gone, manifest unparseable, or install never completed */
manifestError?: 'missing' | 'invalid' | 'incomplete'
}
export type AnyExtension = ModelExtension | ProcessExtension
// ─── Process runner types ─────────────────────────────────────────────────────
export interface ProcessInput {
filePath?: string
text?: string
/** Per-slot texts for multi-text-input nodes (index = target handle slot). */
texts?: (string | undefined)[]
nodeId?: string
}
export interface ProcessResult {
filePath?: string
text?: string
}
export interface WFNodeData {
extensionId?: string
inputType?: 'image' | 'text'
enabled: boolean
showInGenerate?: boolean
iterations?: number // While container: auto-loop N times (omit/0 = manual only)
params: Record<string, unknown>
// React Flow requires node data to satisfy Record<string, unknown>.
[key: string]: unknown
}
export interface WFNode {
id: string
type: string
position: { x: number; y: number }
data: WFNodeData
// Sub-flow / group support (While container)
parentId?: string
extent?: 'parent'
width?: number
height?: number
style?: Record<string, unknown>
}
export interface WFEdge {
id: string
source: string
target: string
sourceHandle?: string | null
targetHandle?: string | null
}
export interface Workflow {
id: string
name: string
description: string
/** Display folder in the workflow browser (no folder = root) */
folder?: string
/** Pinned in the workflow browser's Bookmarks section */
bookmarked?: boolean
nodes: WFNode[]
edges: WFEdge[]
createdAt: string
updatedAt: string
}
declare global {
interface Window {
electron: {
shell: {
openExternal: (url: string) => Promise<void>
}
system: {
memory: () => Promise<{ total: number; used: number; available: number }>
}
window: {
minimize: () => void
maximize: () => void
close: () => void
isMaximized: () => Promise<boolean>
onMaximizeChange: (cb: (isMaximized: boolean) => void) => void
offMaximizeChange: () => void
}
notifications: {
show: (title: string, body: string) => Promise<{ success: boolean; error?: string }>
}
ui: {
setZoomFactor: (factor: number) => void
}
python: {
start: () => Promise<{ success: boolean; port?: number; error?: string }>
status: () => Promise<{ ready: boolean; apiUrl: string }>
onCrashed: (cb: (data: { code: number | null }) => void) => void
offCrashed: () => void
onLog: (cb: (line: string) => void) => void
offLog: () => void
}
fs: {
selectImage: () => Promise<string | null>
selectMeshFile: () => Promise<string | null>
saveModel: (defaultName: string) => Promise<string | null>
readFileBase64: (filePath: string) => Promise<string>
selectDirectory: (defaultPath?: string) => Promise<string | null>
savePath: (args: { filters: { name: string; extensions: string[] }[]; defaultPath?: string }) => Promise<string | null>
listDir: (dirPath: string) => Promise<string[]>
listFiles: (dirPath: string, extensions?: string[]) => Promise<string[]>
selectTextFile: () => Promise<string | null>
moveDirectory: (args: { src: string; dest: string }) => Promise<{ success: boolean; error?: string }>
deleteDirectory: (dirPath: string) => Promise<{ success: boolean; error?: string }>
readScreenshotDataUrl: (filename: string) => Promise<string>
}
settings: {
get: () => Promise<{ modelsDir: string; workspaceDir: string; workflowsDir: string; extensionsDir: string; hfToken?: string }>
set: (patch: { modelsDir?: string; workspaceDir?: string; workflowsDir?: string; extensionsDir?: string; hfToken?: string }) => Promise<{ modelsDir: string; workspaceDir: string; workflowsDir: string; extensionsDir: string; hfToken?: string }>
}
cache: {
clear: () => Promise<{ success: boolean; error?: string }>
}
api: {
updatePaths: (patch: { modelsDir?: string; workspaceDir?: string; extensionsDir?: string }) => Promise<{ success: boolean; error?: string }>
}
model: {
export: (args: { outputUrl: string; format: string }) => Promise<{ success: boolean; error?: string }>
listDownloaded: () => Promise<{ id: string; name: string; size_gb: number }[]>
activeDownloads: () => Promise<{ modelId: string; percent: number; file?: string; fileIndex?: number; totalFiles?: number }[]>
isDownloaded: (modelId: string, downloadCheck?: string) => Promise<boolean>
download: (repoId: string, modelId: string, skipPrefixes?: string[], includePrefixes?: string[]) => Promise<{ success: boolean; error?: string }>
pauseDownload: (modelId: string) => Promise<{ success: boolean; error?: string }>
cancelDownload: (modelId: string) => Promise<{ success: boolean; error?: string }>
delete: (modelId: string) => Promise<{ success: boolean; error?: string }>
unloadAll: () => Promise<{ success: boolean; error?: string }>
showInFolder: (modelId: string) => Promise<void>
onProgress: (cb: (data: {
modelId: string
percent: number
file?: string
fileIndex?: number
totalFiles?: number
status?: string
bytesDownloaded?: number
totalBytes?: number
stalledSeconds?: number
paused?: boolean
cancelled?: boolean
}) => void) => void
offProgress: () => void
}
app: {
info: () => Promise<{
version: string
userData: string
modelsDir: string
apiUrl: string
platform: string
arch: string
}>
onError: (cb: (message: string) => void) => void
offError: () => void
}
log: {
error: (message: string) => void
getPath: () => Promise<string>
readAll: (session?: string) => Promise<Record<string, string>>
listSessions: () => Promise<string[]>
}
workspace: {
listCollections: () => Promise<string[]>
createCollection: (name: string) => Promise<void>
renameCollection: (oldName: string, newName: string) => Promise<void>
deleteCollection: (name: string) => Promise<void>
listJobs: (collection: string) => Promise<unknown[]>
saveJobMeta: (collection: string, filename: string, meta: unknown) => Promise<void>
deleteJob: (collection: string, filename: string) => Promise<void>
library: {
list: () => Promise<AssetLibraryListResult>
read: (request: AssetLibraryReadRequest) => Promise<AssetLibraryReadResult>
open: (request: AssetLibraryOpenRequest) => Promise<AssetLibraryOpenResult>
}
}
setup: {
check: () => Promise<{ needed: boolean; defaultDataDir: string; platform: string; arch: string }>
run: () => Promise<{ success: boolean; error?: string }>
saveDataDir: (baseDir: string) => Promise<void>
onProgress: (cb: (data: { step: string; percent: number; currentPackage?: string }) => void) => void
offProgress: () => void
onComplete: (cb: () => void) => void
offComplete: () => void
onError: (cb: (data: { message: string }) => void) => void
offError: () => void
}
workflows: {
list: () => Promise<Workflow[]>
save: (workflow: Workflow) => Promise<{ success: boolean; error?: string }>
delete: (id: string) => Promise<{ success: boolean; error?: string }>
import: () => Promise<{ success: boolean; error?: string; workflow?: Workflow }>
export: (workflow: Workflow) => Promise<{ success: boolean; error?: string }>
}
updater: {
check: () => Promise<{ success: boolean }>
quitAndInstall: () => Promise<void>
onApplying: (cb: (data: { version: string }) => void) => void
offApplying: () => void
onMajorMinorAvailable: (cb: (data: { version: string }) => void) => void
offMajorMinorAvailable: () => void
}
extensions: {
list: () => Promise<AnyExtension[]>
installFromGitHub: (url: string) => Promise<{
success: boolean
error?: string
cancelled?: boolean
extensionId?: string
extension?: AnyExtension
}>
installFromLocal: () => Promise<{
success: boolean
error?: string
cancelled?: boolean
needsRepair?: boolean
extensionId?: string
extension?: AnyExtension
localPath?: string
}>
uninstall: (extensionId: string) => Promise<{ success: boolean; error?: string }>
repair: (extensionId: string) => Promise<{ success: boolean; error?: string }>
reload: () => Promise<{ success: boolean; error?: string; errors?: Record<string, string> }>
runProcess: (extensionId: string, input: ProcessInput, params: Record<string, unknown>) => Promise<{ success: boolean; result?: ProcessResult; error?: string }>
onInstallProgress: (cb: (data: {
step: 'downloading' | 'extracting' | 'validating' | 'setting_up' | 'done' | 'error'
percent?: number
extensionId?: string
message?: string
}) => void) => void
offInstallProgress: () => void
}
}
}
}