comfy-ts 2.4.2 → 2.6.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/README.md +12 -1
- package/dist/{DefinedWorkflow-CnzmQrBh.js → DefinedWorkflow-BJgt5t0x.js} +14 -3
- package/dist/DefinedWorkflow-BJgt5t0x.js.map +1 -0
- package/dist/{DraftsSt-C1MbWnEp.js → DraftsSt-dizp3VcC.js} +2 -2
- package/dist/{DraftsSt-C1MbWnEp.js.map → DraftsSt-dizp3VcC.js.map} +1 -1
- package/dist/cli.js +4 -4
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/{run-serve-D47Zas-a.js → run-serve-CVu39RNd.js} +330 -16
- package/dist/run-serve-CVu39RNd.js.map +1 -0
- package/dist/{run-tui-BqNO9Ck0.js → run-tui-idFhdO4f.js} +707 -527
- package/dist/run-tui-idFhdO4f.js.map +1 -0
- package/dist/serve-web.js +280 -0
- package/dist/{state-D9w1aJow.js → state-C90kdjtB.js} +3 -13
- package/dist/state-C90kdjtB.js.map +1 -0
- package/dist/web.d.ts +3 -0
- package/dist/web.js +3 -2
- package/dist/web.js.map +1 -1
- package/package.json +9 -7
- package/src/cli/serve/ServeApp.ts +314 -13
- package/src/cli/serve/describeVar.ts +6 -1
- package/src/cli/serve/run-serve.ts +4 -2
- package/src/cli/serve/web/api.ts +105 -0
- package/src/cli/serve/web/clipboard.ts +25 -0
- package/src/cli/serve/web/components/App.tsx +53 -0
- package/src/cli/serve/web/components/Gallery.tsx +186 -0
- package/src/cli/serve/web/components/PromptEnhancer.tsx +210 -0
- package/src/cli/serve/web/components/Sidebar.tsx +42 -0
- package/src/cli/serve/web/components/VarsForm.tsx +173 -0
- package/src/cli/serve/web/components/controls/BasicControls.tsx +95 -0
- package/src/cli/serve/web/components/controls/ImageControl.tsx +71 -0
- package/src/cli/serve/web/components/controls/LorasControl.tsx +340 -0
- package/src/cli/serve/web/components/controls/SeedControl.tsx +43 -0
- package/src/cli/serve/web/components/controls/SizeControl.tsx +49 -0
- package/src/cli/serve/web/main.tsx +18 -0
- package/src/cli/serve/web/openrouter.ts +142 -0
- package/src/cli/serve/web/state/EnhancerSt.ts +370 -0
- package/src/cli/serve/web/state/FormSt.ts +177 -0
- package/src/cli/serve/web/state/RunSt.ts +136 -0
- package/src/cli/serve/web/state/WebSt.ts +210 -0
- package/src/cli/serve/web/state/payload.ts +110 -0
- package/src/cli/serve/web/styles.ts +259 -0
- package/src/cli/serve/web/tsconfig.json +15 -0
- package/src/cli/serve/webBundle.ts +66 -0
- package/src/cli/tui/imageEscapes.ts +105 -0
- package/src/cli/tui/imagePicker/ImagePickerSt.ts +21 -8
- package/src/cli/tui/protocolImage.ts +39 -0
- package/src/cli/tui/protocolImagePainter.ts +56 -23
- package/src/cli/tui/run-tui.tsx +3 -2
- package/src/cli/tui/state/LorasSt.ts +22 -9
- package/src/cli/tui/state/PreviewSt.ts +31 -13
- package/src/cli/tui/state/SettingsSt.ts +1 -1
- package/src/cli/tui/state/TuiSt.ts +4 -4
- package/src/vars/ComfyVars.ts +4 -1
- package/dist/DefinedWorkflow-CnzmQrBh.js.map +0 -1
- package/dist/run-serve-D47Zas-a.js.map +0 -1
- package/dist/run-tui-BqNO9Ck0.js.map +0 -1
- package/dist/state-D9w1aJow.js.map +0 -1
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
// the ONE stylesheet, injected by main.tsx — no css framework on purpose
|
|
2
|
+
// (agent/coding.md: prefer obvious code over a new dependency)
|
|
3
|
+
export const STYLES = /* css */ `
|
|
4
|
+
:root {
|
|
5
|
+
--bg: #101217;
|
|
6
|
+
--panel: #171a21;
|
|
7
|
+
--panel-2: #1d2129;
|
|
8
|
+
--border: #2a2f3a;
|
|
9
|
+
--text: #e8eaf0;
|
|
10
|
+
--dim: #8b93a7;
|
|
11
|
+
--accent: #7aa2f7;
|
|
12
|
+
--accent-dim: #33415e;
|
|
13
|
+
--green: #9ece6a;
|
|
14
|
+
--red: #f7768e;
|
|
15
|
+
--amber: #e0af68;
|
|
16
|
+
}
|
|
17
|
+
* { box-sizing: border-box; }
|
|
18
|
+
html, body { margin: 0; height: 100%; }
|
|
19
|
+
body {
|
|
20
|
+
background: var(--bg);
|
|
21
|
+
color: var(--text);
|
|
22
|
+
font: 14px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
23
|
+
}
|
|
24
|
+
#root { height: 100%; }
|
|
25
|
+
.app { display: flex; flex-direction: column; height: 100%; }
|
|
26
|
+
.topbar {
|
|
27
|
+
display: flex; align-items: baseline; gap: 12px;
|
|
28
|
+
padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--panel);
|
|
29
|
+
}
|
|
30
|
+
.topbar h1 { font-size: 15px; margin: 0; font-weight: 600; }
|
|
31
|
+
.topbar .dim { color: var(--dim); font-size: 12px; }
|
|
32
|
+
.burger { font-size: 16px; padding: 3px 10px; align-self: center; }
|
|
33
|
+
.cols { display: flex; flex: 1; min-height: 0; position: relative; }
|
|
34
|
+
.backdrop { display: none; }
|
|
35
|
+
|
|
36
|
+
.sidebar {
|
|
37
|
+
width: 240px; flex-shrink: 0; overflow-y: auto;
|
|
38
|
+
border-right: 1px solid var(--border); background: var(--panel); padding: 8px 0;
|
|
39
|
+
}
|
|
40
|
+
.side-module { padding: 6px 12px 2px; }
|
|
41
|
+
.side-module .name { font-weight: 600; }
|
|
42
|
+
.side-module .host { color: var(--dim); font-size: 11px; margin-left: 6px; }
|
|
43
|
+
.side-draft {
|
|
44
|
+
display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--text);
|
|
45
|
+
padding: 4px 12px 4px 26px; cursor: pointer; font: inherit; border-radius: 4px;
|
|
46
|
+
}
|
|
47
|
+
.side-draft:hover { background: var(--panel-2); }
|
|
48
|
+
.side-draft.sel { background: var(--accent-dim); color: #fff; }
|
|
49
|
+
.side-errors { margin: 12px; padding: 8px; border: 1px solid var(--red); border-radius: 6px; font-size: 12px; }
|
|
50
|
+
.side-errors .file { color: var(--dim); word-break: break-all; }
|
|
51
|
+
.side-errors .msg { color: var(--red); }
|
|
52
|
+
|
|
53
|
+
.main { flex: 1; overflow-y: auto; padding: 16px 20px 60px; }
|
|
54
|
+
.main h2 { font-size: 14px; margin: 0; color: var(--dim); font-weight: 500; }
|
|
55
|
+
.main h2 b { color: var(--text); }
|
|
56
|
+
.form-head { display: flex; gap: 12px; align-items: baseline; margin-bottom: 12px; flex-wrap: wrap; }
|
|
57
|
+
|
|
58
|
+
.var-row {
|
|
59
|
+
display: grid; grid-template-columns: 170px 1fr; gap: 10px; align-items: start;
|
|
60
|
+
padding: 8px 0; border-bottom: 1px solid var(--border);
|
|
61
|
+
}
|
|
62
|
+
.var-label { padding-top: 5px; overflow-wrap: break-word; }
|
|
63
|
+
.var-label .kind { color: var(--dim); font-size: 11px; display: block; }
|
|
64
|
+
.var-label .dirty-dot { color: var(--amber); margin-left: 4px; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
|
|
65
|
+
.var-label .dirty-dot:hover { color: var(--red); }
|
|
66
|
+
.var-control { min-width: 0; }
|
|
67
|
+
.hint { color: var(--dim); font-size: 11px; margin-top: 3px; }
|
|
68
|
+
|
|
69
|
+
input[type='text'], input[type='number'], textarea, select {
|
|
70
|
+
background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
|
|
71
|
+
border-radius: 6px; padding: 6px 8px; font: inherit; max-width: 100%;
|
|
72
|
+
}
|
|
73
|
+
input[type='text'] { width: 100%; }
|
|
74
|
+
input[type='number'] { width: 110px; }
|
|
75
|
+
textarea { width: 100%; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
|
|
76
|
+
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
|
|
77
|
+
input[type='range'] { width: 100%; accent-color: var(--accent); }
|
|
78
|
+
input[type='checkbox'] { accent-color: var(--accent); width: 16px; height: 16px; }
|
|
79
|
+
.row-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
|
80
|
+
|
|
81
|
+
button {
|
|
82
|
+
background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
|
|
83
|
+
border-radius: 6px; padding: 5px 10px; font: inherit; cursor: pointer;
|
|
84
|
+
}
|
|
85
|
+
button:hover { border-color: var(--accent); }
|
|
86
|
+
button:disabled { opacity: 0.5; cursor: default; }
|
|
87
|
+
button.primary { background: var(--accent); border-color: var(--accent); color: #0d1117; font-weight: 600; padding: 8px 22px; }
|
|
88
|
+
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
|
|
89
|
+
button.mode { padding: 4px 8px; font-size: 12px; }
|
|
90
|
+
button.mode.sel { background: var(--accent-dim); border-color: var(--accent); color: #fff; }
|
|
91
|
+
|
|
92
|
+
.runbar {
|
|
93
|
+
position: sticky; bottom: 0; display: flex; gap: 14px; align-items: center;
|
|
94
|
+
background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
|
|
95
|
+
padding: 10px 14px; margin-top: 14px;
|
|
96
|
+
}
|
|
97
|
+
.runbar .status { color: var(--dim); font-size: 12px; }
|
|
98
|
+
.runbar .error { color: var(--red); font-size: 12px; white-space: pre-wrap; }
|
|
99
|
+
.pulse { animation: pulse 1.2s ease-in-out infinite; }
|
|
100
|
+
@keyframes pulse { 50% { opacity: 0.45; } }
|
|
101
|
+
|
|
102
|
+
.gallery { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
|
|
103
|
+
.gallery-head { display: flex; gap: 12px; align-items: baseline; color: var(--dim); font-size: 12px; }
|
|
104
|
+
.run-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
|
|
105
|
+
.run-card .meta { color: var(--dim); font-size: 12px; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; }
|
|
106
|
+
.run-card .imgs { display: flex; flex-wrap: wrap; gap: 10px; }
|
|
107
|
+
.run-card img { max-width: min(320px, 100%); max-height: 320px; border-radius: 6px; display: block; }
|
|
108
|
+
.run-card .noimg { color: var(--dim); font-style: italic; }
|
|
109
|
+
.run-card.running { border-color: var(--accent-dim); }
|
|
110
|
+
.progress-track { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
|
|
111
|
+
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s ease; }
|
|
112
|
+
.img-cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
|
|
113
|
+
.img-actions { display: flex; gap: 10px; align-items: baseline; font-size: 12px; }
|
|
114
|
+
.img-actions a { color: var(--accent); text-decoration: none; }
|
|
115
|
+
.img-actions button { padding: 2px 8px; font-size: 12px; }
|
|
116
|
+
|
|
117
|
+
.lora-chip {
|
|
118
|
+
display: inline-flex; gap: 6px; align-items: center; max-width: 100%;
|
|
119
|
+
background: var(--accent-dim); border-radius: 12px; padding: 3px 10px; font-size: 12px;
|
|
120
|
+
}
|
|
121
|
+
.lora-chip button { border: 0; background: none; color: inherit; padding: 0; font-size: 11px; }
|
|
122
|
+
.lora-chip button:hover { color: var(--red); }
|
|
123
|
+
/* image mode: the row chip becomes the same preview card as the popup */
|
|
124
|
+
.lora-chip.card {
|
|
125
|
+
flex-direction: column; align-items: stretch; border-radius: 8px; padding: 6px;
|
|
126
|
+
background: var(--panel-2); border: 1px solid var(--border); width: 132px;
|
|
127
|
+
}
|
|
128
|
+
.lora-chip.card .lora-thumb { height: 110px; }
|
|
129
|
+
.lora-chip.card .chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
130
|
+
.chip-title { min-width: 0; }
|
|
131
|
+
/* the whole card is the pause/resume target — the palette gesture */
|
|
132
|
+
.lora-toggle {
|
|
133
|
+
display: flex; flex-direction: column; gap: 4px; align-items: stretch; min-width: 0;
|
|
134
|
+
border: 0; background: none; color: inherit; font: inherit; padding: 0; cursor: pointer; text-align: left;
|
|
135
|
+
}
|
|
136
|
+
.lora-chip:not(.card) .lora-toggle { flex-direction: row; align-items: center; gap: 6px; }
|
|
137
|
+
.lora-toggle:hover .chip-title { color: var(--accent); }
|
|
138
|
+
.chip-state { font-size: 10px; color: var(--green); letter-spacing: 0.04em; }
|
|
139
|
+
.lora-chip.off .chip-state { color: var(--amber); }
|
|
140
|
+
.chip-controls { display: flex; gap: 4px; align-items: center; }
|
|
141
|
+
.chip-controls input[type='number'] { width: 52px; padding: 1px 4px; font-size: 11px; }
|
|
142
|
+
.chip-controls button { border: 0; background: none; color: inherit; padding: 0 2px; font-size: 11px; }
|
|
143
|
+
.chip-controls button:hover { color: var(--red); }
|
|
144
|
+
/* PAUSED: still in the palette, visibly not contributing to the graph */
|
|
145
|
+
.lora-chip.off, .lora-active-row.off { opacity: 0.55; }
|
|
146
|
+
.lora-chip.off { border-style: dashed; }
|
|
147
|
+
.lora-chip.off .lora-thumb, .lora-active-row.off .lora-thumb { filter: grayscale(1); }
|
|
148
|
+
|
|
149
|
+
.queue { margin-top: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
|
|
150
|
+
.queue-head {
|
|
151
|
+
display: flex; gap: 12px; align-items: baseline; justify-content: space-between;
|
|
152
|
+
padding: 6px 10px; border-bottom: 1px solid var(--border); color: var(--dim); font-size: 12px;
|
|
153
|
+
}
|
|
154
|
+
.queue-row { display: flex; gap: 10px; align-items: center; padding: 4px 10px; font-size: 12px; }
|
|
155
|
+
.queue-ix { color: var(--dim); width: 16px; }
|
|
156
|
+
.queue-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
157
|
+
.queue-row button { padding: 1px 8px; font-size: 11px; }
|
|
158
|
+
|
|
159
|
+
.modal-overlay {
|
|
160
|
+
position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.55);
|
|
161
|
+
display: flex; align-items: center; justify-content: center; padding: 20px;
|
|
162
|
+
}
|
|
163
|
+
.modal {
|
|
164
|
+
background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
|
|
165
|
+
width: min(860px, 100%); max-height: min(80vh, 100%); display: flex; flex-direction: column;
|
|
166
|
+
}
|
|
167
|
+
.modal-head { display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid var(--border); }
|
|
168
|
+
.modal-head input { flex: 1; }
|
|
169
|
+
.modal-body { overflow-y: auto; padding: 10px; }
|
|
170
|
+
.section-title { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; margin: 8px 0 6px; }
|
|
171
|
+
|
|
172
|
+
.lora-active-row { display: flex; gap: 10px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--border); }
|
|
173
|
+
.lora-active-text { flex: 1; min-width: 0; }
|
|
174
|
+
.lora-active-row input[type='number'] { width: 64px; padding: 2px 6px; font-size: 12px; }
|
|
175
|
+
.lora-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
|
|
176
|
+
|
|
177
|
+
.lora-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
|
|
178
|
+
.lora-card {
|
|
179
|
+
display: flex; flex-direction: column; gap: 6px; padding: 6px; text-align: left;
|
|
180
|
+
background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; min-width: 0;
|
|
181
|
+
}
|
|
182
|
+
.lora-card:hover { border-color: var(--accent); }
|
|
183
|
+
.lora-thumb { width: 100%; height: 110px; object-fit: cover; border-radius: 6px; display: block; }
|
|
184
|
+
.lora-active-row .lora-thumb { width: 48px; height: 48px; flex-shrink: 0; }
|
|
185
|
+
div.lora-thumb.none {
|
|
186
|
+
display: flex; align-items: center; justify-content: center;
|
|
187
|
+
color: var(--dim); font-size: 11px; background: var(--bg); font-style: italic;
|
|
188
|
+
}
|
|
189
|
+
.st-label { color: var(--dim); font-size: 11px; }
|
|
190
|
+
|
|
191
|
+
.img-button { padding: 0; border: 0; background: none; cursor: zoom-in; display: block; min-width: 0; }
|
|
192
|
+
.lightbox {
|
|
193
|
+
display: flex; flex-direction: column; gap: 8px; max-width: min(1100px, 100%); max-height: 100%;
|
|
194
|
+
}
|
|
195
|
+
.lightbox img { max-width: 100%; max-height: calc(90vh - 60px); object-fit: contain; border-radius: 8px; }
|
|
196
|
+
.lightbox-bar {
|
|
197
|
+
display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap;
|
|
198
|
+
background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
|
|
199
|
+
}
|
|
200
|
+
.lightbox-bar a { color: var(--accent); text-decoration: none; }
|
|
201
|
+
.loras-more { color: var(--dim); font-size: 12px; padding: 4px 10px; }
|
|
202
|
+
|
|
203
|
+
/* prompt enhancer modal */
|
|
204
|
+
.modal-foot {
|
|
205
|
+
display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
|
|
206
|
+
padding: 10px; border-top: 1px solid var(--border);
|
|
207
|
+
}
|
|
208
|
+
.enh-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
|
|
209
|
+
.enh-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
|
|
210
|
+
.enh-cols textarea { width: 100%; }
|
|
211
|
+
.enh-cols textarea[readonly] { color: var(--dim); }
|
|
212
|
+
.enh-think {
|
|
213
|
+
max-height: 160px; overflow-y: auto; white-space: pre-wrap; font-size: 12px;
|
|
214
|
+
color: var(--dim); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.img-preview { margin-top: 8px; }
|
|
218
|
+
.img-preview img { max-width: 220px; max-height: 220px; border-radius: 6px; border: 1px solid var(--border); }
|
|
219
|
+
|
|
220
|
+
.center { display: flex; height: 100%; align-items: center; justify-content: center; color: var(--dim); }
|
|
221
|
+
.center .error { color: var(--red); max-width: 640px; white-space: pre-wrap; }
|
|
222
|
+
|
|
223
|
+
/* results right of the form on wide screens ("bottom or right": right ≥1100px, bottom below) */
|
|
224
|
+
@media (min-width: 1100px) {
|
|
225
|
+
.work { display: flex; gap: 18px; align-items: flex-start; }
|
|
226
|
+
.form-col { flex: 1; min-width: 0; }
|
|
227
|
+
.results-col { width: 380px; flex-shrink: 0; }
|
|
228
|
+
.results-col .gallery { margin-top: 0; }
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* the sidebar becomes a fixed drawer over a backdrop */
|
|
232
|
+
@media (max-width: 800px) {
|
|
233
|
+
.sidebar {
|
|
234
|
+
position: fixed; top: 0; left: 0; bottom: 0; width: 264px; z-index: 30;
|
|
235
|
+
box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5); padding-top: 12px;
|
|
236
|
+
}
|
|
237
|
+
.backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 25; }
|
|
238
|
+
.side-draft { padding: 9px 12px 9px 26px; }
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/* phone: label over control, 16px inputs (below that iOS zooms the page on focus) */
|
|
242
|
+
@media (max-width: 640px) {
|
|
243
|
+
.main { padding: 12px 12px 60px; }
|
|
244
|
+
.var-row { grid-template-columns: 1fr; gap: 4px; }
|
|
245
|
+
.var-label { padding-top: 0; }
|
|
246
|
+
.var-label .kind { display: inline; margin-left: 6px; }
|
|
247
|
+
input[type='text'], input[type='number'], textarea, select { font-size: 16px; }
|
|
248
|
+
input[type='number'] { width: 96px; }
|
|
249
|
+
/* repeated at row specificity: the base 12px rule outranks the bare selector above,
|
|
250
|
+
and a sub-16px input makes iOS zoom the page on focus */
|
|
251
|
+
.lora-active-row input[type='number'] { font-size: 16px; }
|
|
252
|
+
.modal-overlay { padding: 0; }
|
|
253
|
+
.modal { max-height: 100%; height: 100%; width: 100%; border-radius: 0; }
|
|
254
|
+
.lora-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
|
|
255
|
+
.runbar { flex-wrap: wrap; }
|
|
256
|
+
/* side by side prompts do not fit a phone: stack yours over the rewrite */
|
|
257
|
+
.enh-cols { grid-template-columns: 1fr; }
|
|
258
|
+
}
|
|
259
|
+
`
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
// the second dom-typed corner (examples/web is the first): this app runs in
|
|
3
|
+
// a browser. src/ elsewhere stays dom-free by machine — this dir is excluded
|
|
4
|
+
// from the root config and chained into `typecheck:lib`
|
|
5
|
+
"extends": "../../../../tsconfig.json",
|
|
6
|
+
"compilerOptions": {
|
|
7
|
+
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
8
|
+
"paths": {
|
|
9
|
+
"src/*": ["../../../../src/*"],
|
|
10
|
+
"comfy-ts": ["../../../../src/index.ts"]
|
|
11
|
+
},
|
|
12
|
+
"tsBuildInfoFile": "../../../../node_modules/.cache/tsbuildinfo-serve-web.json"
|
|
13
|
+
},
|
|
14
|
+
"include": [".", "../../../../src"]
|
|
15
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// web ui bundle resolution (architecture item 12, web ui): prebuilt
|
|
2
|
+
// dist/serve-web.js next to the running module, else an in-memory Bun.build
|
|
3
|
+
// from source (src/ ships in the npm tarball), else null — the api must serve
|
|
4
|
+
// without a UI, never crash
|
|
5
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
6
|
+
import { fileURLToPath } from 'node:url'
|
|
7
|
+
import { dirname, join } from 'pathe'
|
|
8
|
+
|
|
9
|
+
const WEB_ENTRY = 'src/cli/serve/web/main.tsx'
|
|
10
|
+
|
|
11
|
+
/** nearest dir upward holding a package.json — the comfy-ts package root, from dist/ and src/ alike */
|
|
12
|
+
function packageRoot(fromDir: string): string | null {
|
|
13
|
+
let dir = fromDir
|
|
14
|
+
while (true) {
|
|
15
|
+
if (existsSync(join(dir, 'package.json'))) return dir
|
|
16
|
+
const parent = dirname(dir)
|
|
17
|
+
if (parent === dir) return null
|
|
18
|
+
dir = parent
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** bundle the web app to one browser file. Bun.build reads no tsconfig, so the
|
|
23
|
+
* house 'src/...' absolute imports resolve through the same plugin shape as
|
|
24
|
+
* tests/web-bundle.test.ts */
|
|
25
|
+
export async function buildWebJsText(pkgRoot: string): Promise<string> {
|
|
26
|
+
const result = await Bun.build({
|
|
27
|
+
entrypoints: [join(pkgRoot, WEB_ENTRY)],
|
|
28
|
+
target: 'browser',
|
|
29
|
+
minify: true,
|
|
30
|
+
throw: false,
|
|
31
|
+
define: { 'process.env.NODE_ENV': '"production"' },
|
|
32
|
+
plugins: [
|
|
33
|
+
{
|
|
34
|
+
name: 'repo-src-paths',
|
|
35
|
+
setup(build) {
|
|
36
|
+
build.onResolve({ filter: /^src\// }, (args) => ({ path: join(pkgRoot, args.path) }))
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
})
|
|
41
|
+
if (!result.success || result.outputs[0] == null)
|
|
42
|
+
throw new Error(`web ui bundle failed:\n${result.logs.map((l) => String(l)).join('\n')}`)
|
|
43
|
+
return await result.outputs[0].text()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** the runtime resolution chain; every miss logs loud and degrades to api-only */
|
|
47
|
+
export async function loadOrBuildWebJs(): Promise<string | null> {
|
|
48
|
+
const here = dirname(fileURLToPath(import.meta.url))
|
|
49
|
+
const prebuilt = join(here, 'serve-web.js')
|
|
50
|
+
if (existsSync(prebuilt)) return readFileSync(prebuilt, 'utf8')
|
|
51
|
+
if (typeof Bun === 'undefined') {
|
|
52
|
+
console.error('[serve] 🔴 no serve-web.js next to the cli and not running under bun — api only, no web ui')
|
|
53
|
+
return null
|
|
54
|
+
}
|
|
55
|
+
const pkgRoot = packageRoot(here)
|
|
56
|
+
if (pkgRoot == null || !existsSync(join(pkgRoot, WEB_ENTRY))) {
|
|
57
|
+
console.error(`[serve] 🔴 web ui source not found (looked for ${WEB_ENTRY} above ${here}) — api only, no web ui`)
|
|
58
|
+
return null
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
return await buildWebJsText(pkgRoot)
|
|
62
|
+
} catch (e) {
|
|
63
|
+
console.error('[serve] 🔴 web ui bundle failed — api only:', e)
|
|
64
|
+
return null
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { imageMeta } from 'image-meta'
|
|
2
|
+
|
|
3
|
+
// pure escape builders for the two real-image dialects; the painter owns WHEN
|
|
4
|
+
// to emit them. Kitty rule one: q=2 on every command, kitty answers graphics
|
|
5
|
+
// commands on stdin otherwise, straight into ink's input parser. Accepted
|
|
6
|
+
// tradeoff: q=2 also swallows ERROR replies, so a transmit kitty rejects shows
|
|
7
|
+
// as a blank panel (listening for replies would race ink's stdin handshakes).
|
|
8
|
+
|
|
9
|
+
const ESC = '\u001b'
|
|
10
|
+
/** APC terminator: ESC backslash */
|
|
11
|
+
const ST = '\u001b\\'
|
|
12
|
+
|
|
13
|
+
/** one OSC 1337 paint: cursor save → CUP → image sized in CELLS → cursor restore */
|
|
14
|
+
export function itermImageEscape(bytes: Uint8Array, row: number, col: number, w: number, h: number): string {
|
|
15
|
+
const b64 = Buffer.from(bytes).toString('base64')
|
|
16
|
+
return `${ESC}7${ESC}[${row};${col}H${ESC}]1337;File=inline=1;size=${bytes.byteLength};width=${w};height=${h};preserveAspectRatio=1:${b64}\u0007${ESC}8`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** kitty stretches to the given cell box (no preserveAspectRatio key): fit the
|
|
20
|
+
* box to the image aspect first. Cells are ~1:2 (w:h), same as cornerBox. */
|
|
21
|
+
export function fitCellBox(p: { imgW: number; imgH: number; w: number; h: number }): { w: number; h: number } {
|
|
22
|
+
if (p.imgW <= 0 || p.imgH <= 0) return { w: p.w, h: p.h }
|
|
23
|
+
const aspect = p.imgW / p.imgH
|
|
24
|
+
let w = p.w
|
|
25
|
+
let h = Math.max(1, Math.round(w / aspect / 2))
|
|
26
|
+
if (h > p.h) {
|
|
27
|
+
h = p.h
|
|
28
|
+
w = Math.max(1, Math.min(p.w, Math.round(h * aspect * 2)))
|
|
29
|
+
}
|
|
30
|
+
return { w, h }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const dimsCache = new WeakMap<Uint8Array, { w: number; h: number }>()
|
|
34
|
+
|
|
35
|
+
/** header-only parse, cached per bytes object (the painter runs on every flush) */
|
|
36
|
+
export function imageDims(bytes: Uint8Array): { w: number; h: number } {
|
|
37
|
+
const hit = dimsCache.get(bytes)
|
|
38
|
+
if (hit != null) return hit
|
|
39
|
+
let dims = { w: 0, h: 0 }
|
|
40
|
+
try {
|
|
41
|
+
const meta = imageMeta(bytes)
|
|
42
|
+
if (meta.width != null && meta.height != null) dims = { w: meta.width, h: meta.height }
|
|
43
|
+
} catch {
|
|
44
|
+
// undecodable header → unfitted box, the terminal still gets the bytes
|
|
45
|
+
}
|
|
46
|
+
dimsCache.set(bytes, dims)
|
|
47
|
+
return dims
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** spec cap for one APC payload; continuation chunks carry only the m key */
|
|
51
|
+
const KITTY_CHUNK = 4096
|
|
52
|
+
|
|
53
|
+
/** transmit png data under a fixed image id WITHOUT displaying it (a=t),
|
|
54
|
+
* base64 chunked with m=1/0 continuation */
|
|
55
|
+
export function kittyTransmitEscape(bytes: Uint8Array, id: number): string {
|
|
56
|
+
const b64 = Buffer.from(bytes).toString('base64')
|
|
57
|
+
let out = ''
|
|
58
|
+
for (let i = 0; i < b64.length; i += KITTY_CHUNK) {
|
|
59
|
+
const last = i + KITTY_CHUNK >= b64.length
|
|
60
|
+
const ctrl = i === 0 ? `a=t,f=100,t=d,i=${id},q=2,m=${last ? 0 : 1}` : `m=${last ? 0 : 1}`
|
|
61
|
+
out += `${ESC}_G${ctrl};${b64.slice(i, i + KITTY_CHUNK)}${ST}`
|
|
62
|
+
}
|
|
63
|
+
return out
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** display a transmitted id at the cursor: same i,p replaces the previous
|
|
67
|
+
* placement, so repaints never accumulate; C=1 keeps the cursor put; z pins
|
|
68
|
+
* stacking (same-z overlaps draw newest-on-top, recency is not a contract) */
|
|
69
|
+
export function kittyPlaceEscape(id: number, row: number, col: number, w: number, h: number, z?: number): string {
|
|
70
|
+
const zKey = z == null ? '' : `,z=${z}`
|
|
71
|
+
return `${ESC}7${ESC}[${row};${col}H${ESC}_Ga=p,i=${id},p=1,c=${w},r=${h},C=1,q=2${zKey}${ST}${ESC}8`
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** delete this id's placements AND free its data (uppercase I) */
|
|
75
|
+
export function kittyDeleteEscape(id: number): string {
|
|
76
|
+
return `${ESC}_Ga=d,d=I,i=${id},q=2${ST}`
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** free every image + placement — the quit path: ED does not clear kitty images */
|
|
80
|
+
export const KITTY_DELETE_ALL = `${ESC}_Ga=d,d=A,q=2${ST}`
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* per-id transmit-once bookkeeping: data uploads when the bytes OBJECT changes
|
|
84
|
+
* (delete-before-retransmit sidesteps the spec's underspecified reuse of a live
|
|
85
|
+
* id), a cheap placement re-paints every flush, drop deletes exactly once.
|
|
86
|
+
*/
|
|
87
|
+
export class KittyImageSlot {
|
|
88
|
+
private transmitted: Uint8Array | null = null
|
|
89
|
+
constructor(private id: number) {}
|
|
90
|
+
|
|
91
|
+
show(bytes: Uint8Array, row: number, col: number, w: number, h: number, z?: number): string {
|
|
92
|
+
let out = ''
|
|
93
|
+
if (this.transmitted !== bytes) {
|
|
94
|
+
out += kittyDeleteEscape(this.id) + kittyTransmitEscape(bytes, this.id)
|
|
95
|
+
this.transmitted = bytes
|
|
96
|
+
}
|
|
97
|
+
return out + kittyPlaceEscape(this.id, row, col, w, h, z)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
drop(): string {
|
|
101
|
+
if (this.transmitted == null) return ''
|
|
102
|
+
this.transmitted = null
|
|
103
|
+
return kittyDeleteEscape(this.id)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -7,6 +7,7 @@ import { pickerPrefs } from 'src/cli/tui/imagePicker/pickerPrefs.ts'
|
|
|
7
7
|
import { extractErrorMessage } from 'src/utils/extractErrorMessage.ts'
|
|
8
8
|
import { fuzzyMatch } from 'src/utils/fuzzyMatch.ts'
|
|
9
9
|
import { imageBufferToAnsi } from 'src/utils/ansiImage.ts'
|
|
10
|
+
import { protocolReadyBytes } from 'src/cli/tui/protocolImage.ts'
|
|
10
11
|
import type { ImageVar } from 'src/vars/ComfyVars.ts'
|
|
11
12
|
import type { TuiSt } from 'src/cli/tui/state/TuiSt.ts'
|
|
12
13
|
|
|
@@ -263,22 +264,34 @@ export class ImagePickerSt {
|
|
|
263
264
|
// local file: bytes read directly, no host round-trip
|
|
264
265
|
const bytes = new Uint8Array(readFileSync(path))
|
|
265
266
|
if (this.st.preview.useNative) {
|
|
266
|
-
|
|
267
|
+
// protocolReadyBytes: kitty draws png only, browsed files can be jpeg/webp
|
|
268
|
+
this.st.preview.setOverlayImage(
|
|
269
|
+
{
|
|
270
|
+
bytes: await protocolReadyBytes(bytes),
|
|
271
|
+
ansi: null,
|
|
272
|
+
name: basename(path),
|
|
273
|
+
note: null,
|
|
274
|
+
},
|
|
275
|
+
'overlay-image',
|
|
276
|
+
)
|
|
267
277
|
} else {
|
|
268
278
|
const ansi = await imageBufferToAnsi(bytes, {
|
|
269
279
|
width: this.st.preview.width,
|
|
270
280
|
height: this.st.preview.height,
|
|
271
281
|
})
|
|
272
|
-
this.st.preview.setOverlayImage({ bytes: null, ansi, name: basename(path), note: null })
|
|
282
|
+
this.st.preview.setOverlayImage({ bytes: null, ansi, name: basename(path), note: null }, 'overlay-image')
|
|
273
283
|
}
|
|
274
284
|
} catch (e) {
|
|
275
285
|
// e.g. a file sharp can't decode — placeholder note, never a crash
|
|
276
|
-
this.st.preview.setOverlayImage(
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
286
|
+
this.st.preview.setOverlayImage(
|
|
287
|
+
{
|
|
288
|
+
bytes: null,
|
|
289
|
+
ansi: null,
|
|
290
|
+
name: basename(path),
|
|
291
|
+
note: extractErrorMessage(e),
|
|
292
|
+
},
|
|
293
|
+
'overlay-image',
|
|
294
|
+
)
|
|
282
295
|
} finally {
|
|
283
296
|
this._busy = false
|
|
284
297
|
// the cursor may have moved while we rendered: catch up once
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import sharp from 'sharp'
|
|
2
|
+
|
|
3
|
+
/** which real-image dialect this terminal speaks. Env-only detection: querying
|
|
4
|
+
* the terminal would race ink's own stdin handshakes (kitty keyboard, CSI u). */
|
|
5
|
+
export type ImageProtocol = 'iterm' | 'kitty'
|
|
6
|
+
|
|
7
|
+
export function imageProtocol(): ImageProtocol | null {
|
|
8
|
+
// the one native-images kill switch, whatever the dialect
|
|
9
|
+
if (process.env.COMFY_TS_NO_ITERM_IMAGES === '1') return null
|
|
10
|
+
const term = process.env.TERM ?? ''
|
|
11
|
+
const program = process.env.TERM_PROGRAM ?? ''
|
|
12
|
+
// ghostty speaks the kitty graphics protocol
|
|
13
|
+
const kitty =
|
|
14
|
+
term.includes('kitty') ||
|
|
15
|
+
term.includes('ghostty') ||
|
|
16
|
+
process.env.KITTY_WINDOW_ID != null ||
|
|
17
|
+
process.env.GHOSTTY_RESOURCES_DIR != null
|
|
18
|
+
if (kitty) return 'kitty'
|
|
19
|
+
const iterm =
|
|
20
|
+
program === 'iTerm.app' || program === 'WezTerm' || program === 'vscode' || process.env.LC_TERMINAL === 'iTerm2'
|
|
21
|
+
return iterm ? 'iterm' : null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function protocolCapable(): boolean {
|
|
25
|
+
return imageProtocol() != null
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const PNG_MAGIC = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]
|
|
29
|
+
|
|
30
|
+
export function isPng(bytes: Uint8Array): boolean {
|
|
31
|
+
return PNG_MAGIC.every((byte, ix) => bytes[ix] === byte)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** kitty only draws png (f=100), never jpeg/webp; iterm takes any format.
|
|
35
|
+
* Pass every native-renderer byte source that is not sharp-produced png through here. */
|
|
36
|
+
export async function protocolReadyBytes(bytes: Uint8Array): Promise<Uint8Array> {
|
|
37
|
+
if (imageProtocol() !== 'kitty' || isPng(bytes)) return bytes
|
|
38
|
+
return new Uint8Array(await sharp(bytes).png().toBuffer())
|
|
39
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { reaction } from 'mobx'
|
|
2
|
-
import {
|
|
2
|
+
import { fitCellBox, imageDims, itermImageEscape, KITTY_DELETE_ALL, KittyImageSlot } from 'src/cli/tui/imageEscapes.ts'
|
|
3
|
+
import { imageProtocol } from 'src/cli/tui/protocolImage.ts'
|
|
3
4
|
import type { TuiSt } from 'src/cli/tui/state/TuiSt.ts'
|
|
4
5
|
|
|
5
6
|
type WriteCb = (err?: Error | null) => void
|
|
@@ -9,49 +10,79 @@ const SYNC_END = '\u001b[?2026l'
|
|
|
9
10
|
/** below this a write is a terminal query/reply, not a frame — no cells damaged */
|
|
10
11
|
const MIN_FRAME_BYTES = 64
|
|
11
12
|
|
|
13
|
+
/** kitty image ids: fixed, transmit-once bookkeeping keys */
|
|
14
|
+
const MAIN_ID = 1
|
|
15
|
+
const CORNER_ID = 2
|
|
16
|
+
/** corner placement z: pins the small latent ABOVE the main image (same-z
|
|
17
|
+
* stacking is recency, and a fresh output recreates MAIN after the corner) */
|
|
18
|
+
const CORNER_Z = 1
|
|
19
|
+
|
|
12
20
|
/**
|
|
13
|
-
* paints the REAL image (OSC 1337) over the preview
|
|
14
|
-
* Protocol images cannot go THROUGH ink (layout shreds the
|
|
15
|
-
* ink frame write ERASES the image's cells — so this hooks
|
|
16
|
-
* re-paints SYNCHRONOUSLY within the same flush, the whole
|
|
17
|
-
* DEC 2026 synchronized-update markers: the terminal never
|
|
18
|
-
* erased-frame intermediate state. (The previous deferred
|
|
19
|
-
* repaint WAS the native-mode flicker.) A mobx reaction covers
|
|
21
|
+
* paints the REAL image (iTerm OSC 1337 / kitty APC _G) over the preview
|
|
22
|
+
* panel's cell rect. Protocol images cannot go THROUGH ink (layout shreds the
|
|
23
|
+
* escape) and every ink frame write ERASES the image's cells — so this hooks
|
|
24
|
+
* stdout.write and re-paints SYNCHRONOUSLY within the same flush, the whole
|
|
25
|
+
* batch wrapped in DEC 2026 synchronized-update markers: the terminal never
|
|
26
|
+
* presents the erased-frame intermediate state. (The previous deferred
|
|
27
|
+
* setImmediate repaint WAS the native-mode flicker.) A mobx reaction covers
|
|
20
28
|
* byte-only changes (fresh latent/output/lora bytes with no frame write).
|
|
21
29
|
* NOT React: effects only fire for the component that re-rendered, which is
|
|
22
30
|
* why a useEffect painter missed frames (reported: the image waited for input).
|
|
31
|
+
* Kitty differs from iterm in three ways the code below encodes: data uploads
|
|
32
|
+
* ONCE per bytes object then a tiny placement re-paints per flush (same i,p
|
|
33
|
+
* replaces); kitty draws images OVER later text, so a gone image needs an
|
|
34
|
+
* explicit delete or it covers the menu; the cell box stretches, so it is
|
|
35
|
+
* fitted to the image aspect first.
|
|
23
36
|
*/
|
|
24
37
|
export function installProtocolImagePainter(st: TuiSt): () => void {
|
|
25
38
|
// capability, not current setting: the menu can switch to native at any
|
|
26
39
|
// time — imageEscapes() is empty while pixel/hidden, so painting no-ops
|
|
27
|
-
|
|
40
|
+
const proto = imageProtocol()
|
|
41
|
+
if (proto == null || process.stdout.isTTY !== true) return () => {}
|
|
28
42
|
const original = process.stdout.write.bind(process.stdout)
|
|
29
43
|
|
|
30
|
-
const imageEscape = (bytes: Uint8Array, row: number, col: number, w: number, h: number): string => {
|
|
31
|
-
const b64 = Buffer.from(bytes).toString('base64')
|
|
32
|
-
// cursor save → CUP → image sized in CELLS → cursor restore
|
|
33
|
-
return `\u001b7\u001b[${row};${col}H\u001b]1337;File=inline=1;size=${bytes.byteLength};width=${w};height=${h};preserveAspectRatio=1:${b64}\u0007\u001b8`
|
|
34
|
-
}
|
|
35
|
-
|
|
36
44
|
// first image row: header(3) + panel border(1) + 1 content row — row 6,
|
|
37
45
|
// calibrated by playtest on iTerm2 (2026-07-27: row 5 painted one line too high)
|
|
38
46
|
const CONTENT_ROW = 6
|
|
39
47
|
|
|
40
|
-
|
|
48
|
+
// kitty transmit-once state (KittyImageSlot owns the mechanics, tested pure)
|
|
49
|
+
const kittyMain = new KittyImageSlot(MAIN_ID)
|
|
50
|
+
const kittyCorner = new KittyImageSlot(CORNER_ID)
|
|
51
|
+
|
|
52
|
+
/** both images as ONE escape string ('' when nothing to paint or delete) */
|
|
41
53
|
const imageEscapes = (): string => {
|
|
42
54
|
const pv = st.preview
|
|
43
55
|
const main = pv.protocolImage
|
|
44
56
|
const corner = pv.protocolImageCorner
|
|
45
|
-
if (main == null && corner == null) return ''
|
|
46
57
|
// panel outer left edge +1 border +1 padding
|
|
47
58
|
const col = Math.max(1, st.termCols - (pv.width + 4) + 3)
|
|
59
|
+
if (proto === 'iterm') {
|
|
60
|
+
if (main == null && corner == null) return ''
|
|
61
|
+
let out = ''
|
|
62
|
+
if (main != null) out += itermImageEscape(main, CONTENT_ROW, col, pv.width, pv.height)
|
|
63
|
+
// small latent AFTER the big image so it stays on top; its cell box
|
|
64
|
+
// matches the latent's aspect (cornerBox) — a mismatched rect letterboxes
|
|
65
|
+
if (corner != null) {
|
|
66
|
+
const box = pv.cornerBox
|
|
67
|
+
out += itermImageEscape(corner, CONTENT_ROW, col + pv.width - box.w, box.w, box.h)
|
|
68
|
+
}
|
|
69
|
+
return out
|
|
70
|
+
}
|
|
71
|
+
// kitty: main box fitted to the image dims and centered in the panel rect
|
|
72
|
+
// (iterm letterboxes inside the box itself, kitty stretches)
|
|
48
73
|
let out = ''
|
|
49
|
-
if (main
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
74
|
+
if (main == null) out += kittyMain.drop()
|
|
75
|
+
else {
|
|
76
|
+
const dims = imageDims(main)
|
|
77
|
+
const box = fitCellBox({ imgW: dims.w, imgH: dims.h, w: pv.width, h: pv.height })
|
|
78
|
+
const row = CONTENT_ROW + Math.max(0, Math.floor((pv.height - box.h) / 2))
|
|
79
|
+
const c = col + Math.max(0, Math.floor((pv.width - box.w) / 2))
|
|
80
|
+
out += kittyMain.show(main, row, c, box.w, box.h)
|
|
81
|
+
}
|
|
82
|
+
if (corner == null) out += kittyCorner.drop()
|
|
83
|
+
else {
|
|
84
|
+
const box = pv.cornerBox // already aspect-fitted from the latent dims
|
|
85
|
+
out += kittyCorner.show(corner, CONTENT_ROW, col + pv.width - box.w, box.w, box.h, CORNER_Z)
|
|
55
86
|
}
|
|
56
87
|
return out
|
|
57
88
|
}
|
|
@@ -89,6 +120,8 @@ export function installProtocolImagePainter(st: TuiSt): () => void {
|
|
|
89
120
|
const disposeReaction = reaction(() => [st.preview.protocolImage, st.preview.protocolImageCorner], schedule)
|
|
90
121
|
return () => {
|
|
91
122
|
disposed = true
|
|
123
|
+
// ED at quit clears iterm images but NOT kitty ones: free them explicitly
|
|
124
|
+
if (proto === 'kitty') original(KITTY_DELETE_ALL)
|
|
92
125
|
process.stdout.write = original
|
|
93
126
|
disposeReaction()
|
|
94
127
|
}
|