comfy-ts 2.11.0 → 2.13.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.
Files changed (122) hide show
  1. package/README.md +1 -0
  2. package/dist/{LogsSt-qtFzOKpu.js → LogsSt-CUeo843w.js} +51 -7
  3. package/dist/LogsSt-CUeo843w.js.map +1 -0
  4. package/dist/cli.js +4 -4
  5. package/dist/index.cjs +595 -73
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +286 -46
  8. package/dist/index.d.ts +286 -46
  9. package/dist/index.js +591 -74
  10. package/dist/index.js.map +1 -1
  11. package/dist/{run-serve-BK7BA2dn.js → run-serve-DlRBv_Nk.js} +738 -58
  12. package/dist/run-serve-DlRBv_Nk.js.map +1 -0
  13. package/dist/{run-tui-CQyvMf0N.js → run-tui-B5uxm2_l.js} +43 -18
  14. package/dist/run-tui-B5uxm2_l.js.map +1 -0
  15. package/dist/{schemaDrift-DjjEtwfx.js → schemaDrift-E95iTF7E.js} +473 -60
  16. package/dist/schemaDrift-E95iTF7E.js.map +1 -0
  17. package/dist/serve-web.js +710 -174
  18. package/dist/{state--wrz0BQc.js → state-CUp2J1Zy.js} +126 -14
  19. package/dist/state-CUp2J1Zy.js.map +1 -0
  20. package/dist/web.d.ts +286 -46
  21. package/dist/web.js +591 -74
  22. package/dist/web.js.map +1 -1
  23. package/examples/comfy-cloud/sdk.d.ts +163 -163
  24. package/examples/rvion/06-qwen-image-edit.cflow.ts +3 -2
  25. package/examples/rvion/10-anima-t2i.cflow.ts +252 -0
  26. package/examples/rvion/11-yue2-t2a.cflow.ts +105 -0
  27. package/examples/rvion/12-stable-audio-3-t2a.cflow.ts +78 -0
  28. package/examples/rvion/13-ace-step-15-xl-t2a.cflow.ts +153 -0
  29. package/examples/rvion/stableAudio3Prompts.ts +19 -0
  30. package/extra/README.md +4 -0
  31. package/extra/comfyui-fresh-model-lists/README.md +25 -0
  32. package/extra/comfyui-fresh-model-lists/__init__.py +36 -0
  33. package/extra/comfyui-fresh-model-lists/test_fresh_model_lists.py +97 -0
  34. package/package.json +15 -7
  35. package/src/cli/draftMeta.ts +39 -0
  36. package/src/cli/serve/ServeApp.ts +305 -30
  37. package/src/cli/serve/applyVarPayload.ts +50 -22
  38. package/src/cli/serve/byteRange.ts +48 -0
  39. package/src/cli/serve/describeVar.ts +42 -6
  40. package/src/cli/serve/llmConfigShape.ts +51 -0
  41. package/src/cli/serve/llmConfigs.ts +52 -0
  42. package/src/cli/serve/run-serve.ts +12 -3
  43. package/src/cli/serve/tagList.ts +92 -0
  44. package/src/cli/serve/tagSource.ts +69 -0
  45. package/src/cli/serve/web/api.ts +72 -0
  46. package/src/cli/serve/web/components/App.tsx +485 -44
  47. package/src/cli/serve/web/components/DraftTabs.tsx +167 -0
  48. package/src/cli/serve/web/components/Gallery.tsx +133 -31
  49. package/src/cli/serve/web/components/HistoryPicker.tsx +149 -0
  50. package/src/cli/serve/web/components/Icon.tsx +58 -2
  51. package/src/cli/serve/web/components/MenuButton.tsx +53 -0
  52. package/src/cli/serve/web/components/Omnibox.tsx +135 -0
  53. package/src/cli/serve/web/components/PromptEnhancer.tsx +476 -180
  54. package/src/cli/serve/web/components/SideMenu.tsx +414 -0
  55. package/src/cli/serve/web/components/TooltipLayer.tsx +46 -0
  56. package/src/cli/serve/web/components/VarIcon.tsx +24 -0
  57. package/src/cli/serve/web/components/VarsForm.tsx +223 -351
  58. package/src/cli/serve/web/components/controls/BasicControls.tsx +57 -32
  59. package/src/cli/serve/web/components/controls/LorasControl.tsx +646 -317
  60. package/src/cli/serve/web/components/controls/PresetPicker.tsx +1 -1
  61. package/src/cli/serve/web/components/controls/PromptControl.tsx +279 -0
  62. package/src/cli/serve/web/components/controls/PromptEditor.tsx +113 -0
  63. package/src/cli/serve/web/components/controls/SeedControl.tsx +17 -10
  64. package/src/cli/serve/web/components/controls/SizeControl.tsx +111 -18
  65. package/src/cli/serve/web/components/modKey.ts +2 -0
  66. package/src/cli/serve/web/llm.ts +23 -12
  67. package/src/cli/serve/web/promptEditor/promptExtensions.ts +284 -0
  68. package/src/cli/serve/web/state/EnhancerSt.ts +431 -101
  69. package/src/cli/serve/web/state/FormSt.ts +214 -30
  70. package/src/cli/serve/web/state/OmniboxSt.ts +59 -0
  71. package/src/cli/serve/web/state/WebSt.ts +364 -80
  72. package/src/cli/serve/web/state/choiceButtons.ts +61 -0
  73. package/src/cli/serve/web/state/draftNames.ts +16 -0
  74. package/src/cli/serve/web/state/draftTabs.ts +75 -0
  75. package/src/cli/serve/web/state/generateButton.ts +16 -0
  76. package/src/cli/serve/web/state/history.ts +54 -0
  77. package/src/cli/serve/web/state/host.ts +5 -2
  78. package/src/cli/serve/web/state/keptLines.ts +53 -0
  79. package/src/cli/serve/web/state/latentMode.ts +20 -0
  80. package/src/cli/serve/web/state/loraSort.ts +18 -0
  81. package/src/cli/serve/web/state/moduleTree.ts +2 -2
  82. package/src/cli/serve/web/state/omnibox.ts +133 -0
  83. package/src/cli/serve/web/state/payload.ts +38 -58
  84. package/src/cli/serve/web/state/shortcuts.ts +103 -0
  85. package/src/cli/serve/web/state/sizeStars.ts +31 -0
  86. package/src/cli/serve/web/state/stableSlots.ts +21 -0
  87. package/src/cli/serve/web/state/varGroups.ts +24 -0
  88. package/src/cli/serve/web/styles.ts +653 -154
  89. package/src/cli/serve/webBundle.ts +54 -10
  90. package/src/cli/serve/workflowTags.ts +42 -0
  91. package/src/cli/serve/workspaceLabels.ts +23 -0
  92. package/src/cli/tui/components/PickerOverlays.tsx +9 -2
  93. package/src/cli/tui/imagePicker/ImagePickerSt.ts +1 -1
  94. package/src/cli/tui/state/DraftsSt.ts +28 -8
  95. package/src/cli/tui/state/EditorSt.ts +1 -1
  96. package/src/cli/tui/state/LorasSt.ts +1 -1
  97. package/src/cli/tui/state/PickerSt.ts +25 -7
  98. package/src/cli/tui/state/SettingsSt.ts +1 -1
  99. package/src/cli/tui/state/TuiSt.ts +10 -0
  100. package/src/coreExports.ts +21 -0
  101. package/src/host/ComfyHost.ts +17 -2
  102. package/src/host/ResilientWebsocket.ts +54 -4
  103. package/src/host/loraInfoCache.ts +6 -0
  104. package/src/runner/ComfyExecution.ts +60 -0
  105. package/src/runner/ComfyWorkflow.ts +4 -0
  106. package/src/runner/ComfyWsApi.ts +2 -0
  107. package/src/runner/MediaImage.ts +2 -2
  108. package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +5 -5
  109. package/src/sdk-generator/comfyui-sdk-codegen.ts +1 -1
  110. package/src/state.ts +5 -0
  111. package/src/utils/copyName.ts +12 -0
  112. package/src/vars/ComfyVars.ts +337 -67
  113. package/src/vars/DefinedWorkflow.ts +47 -20
  114. package/src/vars/lanes.ts +238 -0
  115. package/src/vars/loraEntry.ts +101 -0
  116. package/src/vars/promptSyntax.ts +382 -0
  117. package/dist/LogsSt-qtFzOKpu.js.map +0 -1
  118. package/dist/run-serve-BK7BA2dn.js.map +0 -1
  119. package/dist/run-tui-CQyvMf0N.js.map +0 -1
  120. package/dist/schemaDrift-DjjEtwfx.js.map +0 -1
  121. package/dist/state--wrz0BQc.js.map +0 -1
  122. package/src/cli/serve/web/components/Sidebar.tsx +0 -66
@@ -0,0 +1,103 @@
1
+ import { MOD_KEY } from 'src/cli/serve/web/components/modKey.ts'
2
+
3
+ /** the panel's jump keys, with ⌘ (ctrl elsewhere) and no other modifier except the ⇧ an entry
4
+ * names, or a bare function key. Each one works from ANY focus, a prompt editor included: it is
5
+ * a jump, not an edit. Browser defaults they take over (print, open file) are useless here */
6
+ export type Shortcut =
7
+ | 'focus-prompt'
8
+ | 'open-loras'
9
+ | 'open-enhancer'
10
+ | 'rename-draft'
11
+ | 'duplicate-draft'
12
+ | 'toggle-menu'
13
+ | 'toggle-blur'
14
+
15
+ /** the letter as shown after ⌘; a leading ⇧ means shift is part of the chord. A function key
16
+ * (F2) is pressed BARE, with no modifier: it is the rename key everywhere, and a free ⌘ letter
17
+ * that is not already a browser key is hard to find */
18
+ export const SHORTCUT_KEYS: Record<Shortcut, string> = {
19
+ 'focus-prompt': 'P',
20
+ 'open-loras': 'O',
21
+ // the same letter enhances once the enhancer is open (ENHANCER_KEYS): ⌘E, ⌘E
22
+ 'open-enhancer': 'E',
23
+ // F2, as in every editor and the TUI; ⌘R stays the browser's reload
24
+ 'rename-draft': 'F2',
25
+ // ⌘D: the browser's bookmark key, useless here
26
+ 'duplicate-draft': 'D',
27
+ // ⌘B is the sidebar key of every editor
28
+ 'toggle-menu': 'B',
29
+ 'toggle-blur': 'U',
30
+ }
31
+
32
+ const isFunctionKey = (k: string): boolean => /^F\d{1,2}$/.test(k)
33
+
34
+ /** the key cap a hint shows: `⌘D`, or a bare `F2` */
35
+ export function shortcutLabel(s: Shortcut): string {
36
+ const k = SHORTCUT_KEYS[s]
37
+ return isFunctionKey(k) ? k : `${MOD_KEY}${k}`
38
+ }
39
+
40
+ /** ⌘K or ⌘J (ctrl elsewhere) opens the search over every workflow and draft */
41
+ export function isOmniboxKey(e: {
42
+ key: string
43
+ metaKey: boolean
44
+ ctrlKey: boolean
45
+ altKey: boolean
46
+ shiftKey: boolean
47
+ }): boolean {
48
+ return (
49
+ (e.metaKey || e.ctrlKey) &&
50
+ !e.altKey &&
51
+ !e.shiftKey &&
52
+ (e.key.toUpperCase() === 'K' || e.key.toUpperCase() === 'J')
53
+ )
54
+ }
55
+
56
+ export function shortcutOf(e: {
57
+ key: string
58
+ metaKey: boolean
59
+ ctrlKey: boolean
60
+ altKey: boolean
61
+ shiftKey: boolean
62
+ }): Shortcut | null {
63
+ const bare = !(e.metaKey || e.ctrlKey || e.altKey || e.shiftKey)
64
+ for (const [s, k] of Object.entries(SHORTCUT_KEYS) as [Shortcut, string][])
65
+ if (isFunctionKey(k) && bare && e.key === k) return s
66
+ if (!(e.metaKey || e.ctrlKey) || e.altKey) return null
67
+ const key = e.key.toUpperCase()
68
+ for (const [s, k] of Object.entries(SHORTCUT_KEYS) as [Shortcut, string][]) {
69
+ if (isFunctionKey(k)) continue
70
+ const shifted = k.startsWith('⇧')
71
+ if (shifted === e.shiftKey && k.slice(shifted ? 1 : 0) === key) return s
72
+ }
73
+ return null
74
+ }
75
+
76
+ /** which var each jump lands on: the FIRST var of that kind in the order shown, skipping one
77
+ * that is disabled (it takes no focus) */
78
+ export function jumpTargets(vars: readonly { name: string; kind: string; inactive: boolean }[]): {
79
+ prompt: string | null
80
+ loras: string | null
81
+ } {
82
+ const first = (kind: string): string | null => vars.find((v) => v.kind === kind && !v.inactive)?.name ?? null
83
+ return { prompt: first('prompt'), loras: first('loras') }
84
+ }
85
+
86
+ /** the enhancer's own keys, live only while it is open. Never ⌘⏎: that one generates everywhere,
87
+ * and in the enhancer it generates with the rewrite (try, EnhancerSt.generateOverride) */
88
+ export type EnhancerShortcut = 'enhance' | 'apply'
89
+
90
+ export const ENHANCER_KEYS: Record<EnhancerShortcut, string> = { enhance: 'E', apply: 'I' }
91
+
92
+ export function enhancerShortcutOf(e: {
93
+ key: string
94
+ metaKey: boolean
95
+ ctrlKey: boolean
96
+ altKey: boolean
97
+ shiftKey: boolean
98
+ }): EnhancerShortcut | null {
99
+ if (!(e.metaKey || e.ctrlKey) || e.altKey || e.shiftKey) return null
100
+ const key = e.key.toUpperCase()
101
+ for (const [s, k] of Object.entries(ENHANCER_KEYS) as [EnhancerShortcut, string][]) if (k === key) return s
102
+ return null
103
+ }
@@ -0,0 +1,31 @@
1
+ // size presets in the panel: which are starred (quick buttons before the list) and the tiny
2
+ // aspect rectangle each one draws. PURE, tests/serve-web-size-stars.test.ts
3
+
4
+ export type SizePresetLike = { label: string; width: number; height: number }
5
+
6
+ /** the starred presets, in PRESET order: your own stars when you set some, else the var's */
7
+ export function starredPresets<P extends SizePresetLike>(p: {
8
+ presets: readonly P[]
9
+ defaults: readonly string[]
10
+ mine: readonly string[] | undefined
11
+ }): P[] {
12
+ const stars = new Set(p.mine ?? p.defaults)
13
+ return p.presets.filter((pr) => stars.has(pr.label))
14
+ }
15
+
16
+ /** flip one star, starting from whatever is effective right now */
17
+ export function toggleStar(p: {
18
+ defaults: readonly string[]
19
+ mine: readonly string[] | undefined
20
+ label: string
21
+ }): string[] {
22
+ const current = p.mine ?? p.defaults
23
+ return current.includes(p.label) ? current.filter((l) => l !== p.label) : [...current, p.label]
24
+ }
25
+
26
+ /** the rectangle for an aspect icon: the long side fills `box`, the short one keeps the ratio */
27
+ export function aspectBox(width: number, height: number, box: number): { w: number; h: number } {
28
+ if (width <= 0 || height <= 0) return { w: box, h: box }
29
+ const scale = box / Math.max(width, height)
30
+ return { w: Math.max(2, Math.round(width * scale)), h: Math.max(2, Math.round(height * scale)) }
31
+ }
@@ -0,0 +1,21 @@
1
+ // the preview pane never shifts: every part it can show is always there, at one size. These are
2
+ // the pure halves: what a run chip says and what a collapsed prompt preview shows
3
+
4
+ /** a chip's text at a FIXED shape: the count is the only part that changes, and the css gives it
5
+ * a width and tabular digits, so 9 → 10 → 100 never pushes a neighbour */
6
+ export function runChipText(p: { kind: 'queue' | 'results'; count: number }): { label: string; count: string } {
7
+ return { label: p.kind, count: String(Math.max(0, Math.min(999, Math.round(p.count)))) }
8
+ }
9
+
10
+ /** a collapsed preview is ALWAYS two lines, whatever the prompt holds: the positive lines joined,
11
+ * then the negative ones joined (empty when there are none). Typing a line break or a `- ` line
12
+ * changes what the two lines say, never how many there are */
13
+ export function collapsedPreview(text: string): { positive: string; negative: string } {
14
+ const lines = text
15
+ .split('\n')
16
+ .map((l) => l.trim())
17
+ .filter((l) => l !== '')
18
+ const negative = lines.filter((l) => l.startsWith('- ')).map((l) => l.slice(2).trim())
19
+ const positive = lines.filter((l) => !l.startsWith('- '))
20
+ return { positive: positive.join(' · '), negative: negative.join(' · ') }
21
+ }
@@ -0,0 +1,24 @@
1
+ // vars that go together (VarUi.group): CONSECUTIVE rows with the same group share one block.
2
+ // PURE, tests/serve-web-var-groups.test.ts. A group split by a row you dragged between its
3
+ // members becomes two blocks, which is what the eye sees anyway
4
+
5
+ export type GroupPlace = { pos: 'solo' | 'start' | 'mid' | 'end'; color: string | null } | null
6
+
7
+ export function groupPlaces(rows: readonly { group?: string; groupColor?: string }[]): GroupPlace[] {
8
+ const out: GroupPlace[] = rows.map(() => null)
9
+ let i = 0
10
+ while (i < rows.length) {
11
+ const g = rows[i]?.group
12
+ if (g == null) {
13
+ i++
14
+ continue
15
+ }
16
+ let j = i
17
+ while (j + 1 < rows.length && rows[j + 1]?.group === g) j++
18
+ const color = rows.slice(i, j + 1).find((r) => r.groupColor != null)?.groupColor ?? null
19
+ for (let k = i; k <= j; k++)
20
+ out[k] = { pos: i === j ? 'solo' : k === i ? 'start' : k === j ? 'end' : 'mid', color }
21
+ i = j + 1
22
+ }
23
+ return out
24
+ }