comfy-ts 2.12.0 → 2.14.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/dist/{LogsSt-U1H0mP1m.js → LogsSt-CUeo843w.js} +18 -4
- package/dist/LogsSt-CUeo843w.js.map +1 -0
- package/dist/cli.js +4 -4
- package/dist/index.cjs +123 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +96 -16
- package/dist/index.d.ts +96 -16
- package/dist/index.js +123 -12
- package/dist/index.js.map +1 -1
- package/dist/{run-serve-BeAznay5.js → run-serve-DUqcn0h3.js} +477 -63
- package/dist/run-serve-DUqcn0h3.js.map +1 -0
- package/dist/{run-tui-BTGjvnKk.js → run-tui-D-LaSqgB.js} +4 -4
- package/dist/{run-tui-BTGjvnKk.js.map → run-tui-D-LaSqgB.js.map} +1 -1
- package/dist/{schemaDrift-Cg39vs53.js → schemaDrift-E95iTF7E.js} +4 -1
- package/dist/{schemaDrift-Cg39vs53.js.map → schemaDrift-E95iTF7E.js.map} +1 -1
- package/dist/serve-web.js +378 -141
- package/dist/{state-C7REnHan.js → state-BytbdZ8s.js} +122 -14
- package/dist/state-BytbdZ8s.js.map +1 -0
- package/dist/web.d.ts +96 -16
- package/dist/web.js +123 -12
- package/dist/web.js.map +1 -1
- package/examples/comfy-cloud/sdk.d.ts +163 -163
- package/examples/rvion/10-anima-t2i.cflow.ts +48 -25
- package/examples/rvion/11-yue2-t2a.cflow.ts +105 -0
- package/examples/rvion/12-stable-audio-3-t2a.cflow.ts +78 -0
- package/examples/rvion/13-ace-step-15-xl-t2a.cflow.ts +153 -0
- package/examples/rvion/stableAudio3Prompts.ts +19 -0
- package/package.json +2 -2
- package/src/cli/serve/ServeApp.ts +224 -77
- package/src/cli/serve/byteRange.ts +48 -0
- package/src/cli/serve/resultHistory.ts +125 -0
- package/src/cli/serve/run-serve.ts +12 -3
- package/src/cli/serve/runError.ts +23 -0
- package/src/cli/serve/serveSettings.ts +17 -1
- package/src/cli/serve/web/api.ts +53 -2
- package/src/cli/serve/web/components/App.tsx +311 -160
- package/src/cli/serve/web/components/DraftTabs.tsx +167 -0
- package/src/cli/serve/web/components/Gallery.tsx +75 -25
- package/src/cli/serve/web/components/Icon.tsx +44 -0
- package/src/cli/serve/web/components/MemoryBudget.tsx +98 -0
- package/src/cli/serve/web/components/Omnibox.tsx +70 -20
- package/src/cli/serve/web/components/RunError.tsx +19 -0
- package/src/cli/serve/web/components/ShortcutsModal.tsx +54 -0
- package/src/cli/serve/web/components/SideMenu.tsx +428 -0
- package/src/cli/serve/web/components/TooltipLayer.tsx +3 -2
- package/src/cli/serve/web/components/VarsForm.tsx +141 -404
- package/src/cli/serve/web/components/controls/BasicControls.tsx +8 -1
- package/src/cli/serve/web/components/controls/LorasControl.tsx +30 -25
- package/src/cli/serve/web/promptEditor/promptExtensions.ts +9 -4
- package/src/cli/serve/web/state/EnhancerSt.ts +17 -2
- package/src/cli/serve/web/state/FormSt.ts +22 -2
- package/src/cli/serve/web/state/OmniboxSt.ts +3 -1
- package/src/cli/serve/web/state/RunSt.ts +61 -3
- package/src/cli/serve/web/state/WebSt.ts +198 -35
- package/src/cli/serve/web/state/draftNames.ts +16 -0
- package/src/cli/serve/web/state/draftTabs.ts +75 -0
- package/src/cli/serve/web/state/formRows.ts +9 -0
- package/src/cli/serve/web/state/generateButton.ts +1 -1
- package/src/cli/serve/web/state/keptResults.ts +26 -0
- package/src/cli/serve/web/state/lightbox.ts +17 -0
- package/src/cli/serve/web/state/omnibox.ts +82 -18
- package/src/cli/serve/web/state/shortcutCatalog.ts +100 -0
- package/src/cli/serve/web/state/shortcuts.ts +66 -7
- package/src/cli/serve/web/styles.ts +327 -93
- package/src/cli/serve/workflowTags.ts +42 -0
- package/src/cli/serve/workspaceLabels.ts +23 -0
- package/src/cli/tui/state/DraftsSt.ts +10 -6
- package/src/coreExports.ts +1 -0
- package/src/host/ComfyHost.ts +17 -2
- package/src/host/ResilientWebsocket.ts +54 -4
- package/src/runner/ComfyExecution.ts +60 -0
- package/src/runner/ComfyWorkflow.ts +4 -0
- package/src/runner/ComfyWsApi.ts +2 -0
- package/src/runner/MediaImage.ts +2 -2
- package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +5 -5
- package/src/sdk-generator/comfyui-sdk-codegen.ts +1 -1
- package/src/utils/copyName.ts +12 -0
- package/src/vars/DefinedWorkflow.ts +7 -1
- package/dist/LogsSt-U1H0mP1m.js.map +0 -1
- package/dist/run-serve-BeAznay5.js.map +0 -1
- package/dist/state-C7REnHan.js.map +0 -1
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
// layout root:
|
|
2
|
-
//
|
|
1
|
+
// layout root: the menu column (SideMenu.tsx), then the form and results columns placed by
|
|
2
|
+
// the preview panel's own buttons. At 760px and below the menu is a drawer behind ☰
|
|
3
3
|
import { observer } from 'mobx-react-lite'
|
|
4
|
-
import { useEffect, useState, type ReactNode } from 'react'
|
|
5
|
-
import { Group, Panel, Separator, useDefaultLayout } from 'react-resizable-panels'
|
|
4
|
+
import { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react'
|
|
5
|
+
import { Group, Panel, Separator, useDefaultLayout, usePanelRef } from 'react-resizable-panels'
|
|
6
|
+
import { MenuCards, MenuHead, MenuRail } from 'src/cli/serve/web/components/SideMenu.tsx'
|
|
6
7
|
import { Gallery } from 'src/cli/serve/web/components/Gallery.tsx'
|
|
7
8
|
import { Icon, type IconName } from 'src/cli/serve/web/components/Icon.tsx'
|
|
8
9
|
import { LATENT_MODES, type LatentMode } from 'src/cli/serve/web/state/latentMode.ts'
|
|
9
10
|
import { Omnibox, useOmniboxShortcut } from 'src/cli/serve/web/components/Omnibox.tsx'
|
|
10
11
|
import { TooltipLayer } from 'src/cli/serve/web/components/TooltipLayer.tsx'
|
|
12
|
+
import { MemoryBudgetButton } from 'src/cli/serve/web/components/MemoryBudget.tsx'
|
|
13
|
+
import { RunError } from 'src/cli/serve/web/components/RunError.tsx'
|
|
11
14
|
import { MOD_KEY } from 'src/cli/serve/web/components/modKey.ts'
|
|
15
|
+
import { SHORTCUT_KEYS, shortcutOf } from 'src/cli/serve/web/state/shortcuts.ts'
|
|
16
|
+
import { reaction } from 'mobx'
|
|
12
17
|
import { collapsedPreview } from 'src/cli/serve/web/state/stableSlots.ts'
|
|
13
18
|
import { GenerateButton, VarsForm } from 'src/cli/serve/web/components/VarsForm.tsx'
|
|
14
|
-
import {
|
|
19
|
+
import { DraftTabs, useTabShortcuts } from 'src/cli/serve/web/components/DraftTabs.tsx'
|
|
20
|
+
import { ShortcutsModal } from 'src/cli/serve/web/components/ShortcutsModal.tsx'
|
|
21
|
+
import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
|
|
15
22
|
|
|
16
23
|
/** ⌘A / ctrl+A selects the field you are in. The browser does this on its own until something
|
|
17
24
|
* on the page consumes the event, and this panel has several window-level key handlers plus a
|
|
@@ -43,6 +50,57 @@ function useSelectAllInFields(): void {
|
|
|
43
50
|
/** the workflow's live previews (defineWorkflow({ previews })): text computed from the values
|
|
44
51
|
* on screen, refreshed as you edit. Compact by default, the name inline and every line cut to
|
|
45
52
|
* one; a click opens the full text, remembered. A `- ` line is the negative, as in a prompt */
|
|
53
|
+
/** the console opens at its last line, and follows new ones while you are at the bottom, so a
|
|
54
|
+
* run's progress stays in view. Scrolled up to read, it stays where you put it */
|
|
55
|
+
function ConsoleLines(p: { text: string }): ReactNode {
|
|
56
|
+
const ref = useRef<HTMLPreElement>(null)
|
|
57
|
+
// measured on scroll, before the next lines land: after they land it is always false
|
|
58
|
+
const atBottom = useRef(true)
|
|
59
|
+
useLayoutEffect(() => {
|
|
60
|
+
const el = ref.current
|
|
61
|
+
if (el != null && atBottom.current) el.scrollTop = el.scrollHeight
|
|
62
|
+
}, [p.text])
|
|
63
|
+
return (
|
|
64
|
+
<pre
|
|
65
|
+
ref={ref}
|
|
66
|
+
onScroll={(e) => {
|
|
67
|
+
const el = e.currentTarget
|
|
68
|
+
atBottom.current = el.scrollHeight - el.scrollTop - el.clientHeight < 8
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{p.text}
|
|
72
|
+
</pre>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** the whole preview text, negative lines included, as the prompt box takes it back. The
|
|
77
|
+
* clipboard needs a secure context: localhost is one, LAN http is not, and the button says so */
|
|
78
|
+
function PreviewCopy(p: { text: string }): ReactNode {
|
|
79
|
+
const [copied, setCopied] = useState(false)
|
|
80
|
+
const canCopy = typeof navigator !== 'undefined' && navigator.clipboard != null
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (!copied) return
|
|
83
|
+
const t = setTimeout(() => setCopied(false), 1500)
|
|
84
|
+
return () => clearTimeout(t)
|
|
85
|
+
}, [copied])
|
|
86
|
+
return (
|
|
87
|
+
<button
|
|
88
|
+
type="button"
|
|
89
|
+
className="live-preview-copy"
|
|
90
|
+
disabled={!canCopy}
|
|
91
|
+
data-tip={canCopy ? (copied ? 'copied' : 'copy the full prompt') : 'copy needs localhost or https'}
|
|
92
|
+
onClick={() => {
|
|
93
|
+
navigator.clipboard.writeText(p.text).then(
|
|
94
|
+
() => setCopied(true),
|
|
95
|
+
(e: unknown) => console.error('[comfy-ts] 🔴 copy failed:', e),
|
|
96
|
+
)
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
<Icon name={copied ? 'check' : 'copy'} />
|
|
100
|
+
</button>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
46
104
|
const LivePreviews = observer(function LivePreviews(p: { st: WebSt }) {
|
|
47
105
|
const form = p.st.form
|
|
48
106
|
const names = form == null ? [] : (p.st.moduleByKey(form.moduleKey)?.previews ?? [])
|
|
@@ -58,45 +116,47 @@ const LivePreviews = observer(function LivePreviews(p: { st: WebSt }) {
|
|
|
58
116
|
// gallery; the full text is one click away
|
|
59
117
|
const short = collapsedPreview(text)
|
|
60
118
|
return (
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
</span>
|
|
74
|
-
)}
|
|
75
|
-
</span>
|
|
76
|
-
<span className="live-preview-lines">
|
|
77
|
-
{!expanded ? (
|
|
78
|
-
<>
|
|
79
|
-
<span className="live-preview-line">{short.positive}</span>
|
|
80
|
-
<span className="live-preview-line negative">
|
|
81
|
-
{short.negative === '' ? '' : `− ${short.negative}`}
|
|
119
|
+
<div key={name} className="live-preview-row">
|
|
120
|
+
<button
|
|
121
|
+
type="button"
|
|
122
|
+
className={expanded ? 'live-preview expanded' : 'live-preview'}
|
|
123
|
+
data-tip={expanded ? 'click to show one line each' : 'click for the full text'}
|
|
124
|
+
onClick={() => p.st.togglePreviewExpanded(key)}
|
|
125
|
+
>
|
|
126
|
+
<span className="live-preview-name">
|
|
127
|
+
{name}
|
|
128
|
+
{form.previewError == null ? null : (
|
|
129
|
+
<span className="live-preview-error" data-tip={`preview failed: ${form.previewError}`}>
|
|
130
|
+
🔴
|
|
82
131
|
</span>
|
|
83
|
-
</>
|
|
84
|
-
) : null}
|
|
85
|
-
{expanded &&
|
|
86
|
-
lines.map((line, ix) =>
|
|
87
|
-
line.startsWith('- ') ? (
|
|
88
|
-
// index keys: a preview's lines have no identity of their own
|
|
89
|
-
<span key={ix} className="live-preview-line negative">
|
|
90
|
-
− {line.slice(2)}
|
|
91
|
-
</span>
|
|
92
|
-
) : (
|
|
93
|
-
<span key={ix} className="live-preview-line">
|
|
94
|
-
{line}
|
|
95
|
-
</span>
|
|
96
|
-
),
|
|
97
132
|
)}
|
|
98
|
-
|
|
99
|
-
|
|
133
|
+
</span>
|
|
134
|
+
<span className="live-preview-lines">
|
|
135
|
+
{!expanded ? (
|
|
136
|
+
<>
|
|
137
|
+
<span className="live-preview-line">{short.positive}</span>
|
|
138
|
+
<span className="live-preview-line negative">
|
|
139
|
+
{short.negative === '' ? '' : `− ${short.negative}`}
|
|
140
|
+
</span>
|
|
141
|
+
</>
|
|
142
|
+
) : null}
|
|
143
|
+
{expanded &&
|
|
144
|
+
lines.map((line, ix) =>
|
|
145
|
+
line.startsWith('- ') ? (
|
|
146
|
+
// index keys: a preview's lines have no identity of their own
|
|
147
|
+
<span key={ix} className="live-preview-line negative">
|
|
148
|
+
− {line.slice(2)}
|
|
149
|
+
</span>
|
|
150
|
+
) : (
|
|
151
|
+
<span key={ix} className="live-preview-line">
|
|
152
|
+
{line}
|
|
153
|
+
</span>
|
|
154
|
+
),
|
|
155
|
+
)}
|
|
156
|
+
</span>
|
|
157
|
+
</button>
|
|
158
|
+
<PreviewCopy text={text} />
|
|
159
|
+
</div>
|
|
100
160
|
)
|
|
101
161
|
})}
|
|
102
162
|
</div>
|
|
@@ -108,23 +168,8 @@ const LATENT_ICON: Record<LatentMode, IconName> = { full: 'image', corner: 'pane
|
|
|
108
168
|
const ResultsHead = observer(function ResultsHead(p: { st: WebSt }) {
|
|
109
169
|
return (
|
|
110
170
|
<div className="results-head">
|
|
111
|
-
{/* a caption over each group:
|
|
112
|
-
|
|
113
|
-
<span className="group-caption">preview</span>
|
|
114
|
-
<span className="btn-group">
|
|
115
|
-
{LAYOUTS.map((l) => (
|
|
116
|
-
<button
|
|
117
|
-
key={l.id}
|
|
118
|
-
type="button"
|
|
119
|
-
className={p.st.layout === l.id ? 'sel' : ''}
|
|
120
|
-
data-tip={l.title}
|
|
121
|
-
onClick={() => p.st.setLayout(l.id)}
|
|
122
|
-
>
|
|
123
|
-
<Icon name={l.icon} />
|
|
124
|
-
</button>
|
|
125
|
-
))}
|
|
126
|
-
</span>
|
|
127
|
-
</div>
|
|
171
|
+
{/* a caption over each group: unlabelled icon strips read as one. Placement is page
|
|
172
|
+
layout, so it lives in the menu column */}
|
|
128
173
|
<div className="head-group-labeled">
|
|
129
174
|
<span className="group-caption">while running</span>
|
|
130
175
|
<span className="row-inline head-row">
|
|
@@ -141,74 +186,42 @@ const ResultsHead = observer(function ResultsHead(p: { st: WebSt }) {
|
|
|
141
186
|
</button>
|
|
142
187
|
))}
|
|
143
188
|
</span>
|
|
144
|
-
<span className="btn-group">
|
|
145
|
-
<button
|
|
146
|
-
type="button"
|
|
147
|
-
className={p.st.showLogs ? 'sel' : ''}
|
|
148
|
-
data-tip={p.st.showLogs ? 'hide the ComfyUI console' : 'show the ComfyUI console'}
|
|
149
|
-
onClick={() => p.st.toggleLogs()}
|
|
150
|
-
>
|
|
151
|
-
<Icon name="terminal" />
|
|
152
|
-
</button>
|
|
153
|
-
</span>
|
|
154
189
|
</span>
|
|
155
190
|
</div>
|
|
156
|
-
<
|
|
157
|
-
<
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
191
|
+
<label className="cols-field" data-tip="results side by side: 1 is one image as wide as this panel">
|
|
192
|
+
<Icon name="grid" />
|
|
193
|
+
<input
|
|
194
|
+
type="number"
|
|
195
|
+
min={1}
|
|
196
|
+
max={8}
|
|
197
|
+
step={1}
|
|
198
|
+
value={p.st.resultsColumns}
|
|
199
|
+
onChange={(e) => {
|
|
200
|
+
const n = Number(e.target.value)
|
|
201
|
+
if (e.target.value !== '' && Number.isFinite(n)) p.st.setResultsColumns(n)
|
|
202
|
+
}}
|
|
203
|
+
/>
|
|
204
|
+
cols
|
|
205
|
+
</label>
|
|
206
|
+
<span className="btn-group">
|
|
207
|
+
<button
|
|
208
|
+
type="button"
|
|
209
|
+
className={p.st.blurResults ? 'sel' : ''}
|
|
210
|
+
data-tip={
|
|
211
|
+
p.st.blurResults
|
|
212
|
+
? 'blurred until you hover: click for always clear'
|
|
213
|
+
: 'always clear: click to blur until you hover'
|
|
214
|
+
}
|
|
215
|
+
onClick={() => p.st.toggleBlur()}
|
|
216
|
+
>
|
|
217
|
+
<Icon name={p.st.blurResults ? 'eye-off' : 'eye'} /> blur
|
|
218
|
+
<span className="kbd-hint">
|
|
219
|
+
{MOD_KEY}
|
|
220
|
+
{SHORTCUT_KEYS['toggle-blur']}
|
|
176
221
|
</span>
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
className="setting-range"
|
|
181
|
-
min={120}
|
|
182
|
-
max={640}
|
|
183
|
-
step={20}
|
|
184
|
-
disabled={p.st.resultsView !== 'grid'}
|
|
185
|
-
value={p.st.resultsSize}
|
|
186
|
-
data-tip={
|
|
187
|
-
p.st.resultsView === 'grid' ? `image size ${p.st.resultsSize}px` : 'image size, for the grid view'
|
|
188
|
-
}
|
|
189
|
-
onChange={(e) => p.st.setResultsSize(Number(e.target.value))}
|
|
190
|
-
/>
|
|
191
|
-
</span>
|
|
192
|
-
</div>
|
|
193
|
-
<div className="head-group-labeled">
|
|
194
|
-
<span className="group-caption">
|
|
195
|
-
blur <span className="kbd-hint">{MOD_KEY}B</span>
|
|
196
|
-
</span>
|
|
197
|
-
<span className="btn-group">
|
|
198
|
-
<button
|
|
199
|
-
type="button"
|
|
200
|
-
className={p.st.blurResults ? 'sel' : ''}
|
|
201
|
-
data-tip={
|
|
202
|
-
p.st.blurResults
|
|
203
|
-
? `blurred until you hover: click (or ${MOD_KEY}B) for always clear`
|
|
204
|
-
: `always clear: click (or ${MOD_KEY}B) to blur until you hover`
|
|
205
|
-
}
|
|
206
|
-
onClick={() => p.st.toggleBlur()}
|
|
207
|
-
>
|
|
208
|
-
<Icon name={p.st.blurResults ? 'eye-off' : 'eye'} />
|
|
209
|
-
</button>
|
|
210
|
-
</span>
|
|
211
|
-
</div>
|
|
222
|
+
</button>
|
|
223
|
+
<MemoryBudgetButton st={p.st} />
|
|
224
|
+
</span>
|
|
212
225
|
</div>
|
|
213
226
|
)
|
|
214
227
|
})
|
|
@@ -280,8 +293,133 @@ const SplitWork = observer(function SplitWork(p: { st: WebSt; left: boolean; for
|
|
|
280
293
|
)
|
|
281
294
|
})
|
|
282
295
|
|
|
296
|
+
/** px: the rail is one icon wide, and a column dragged below MENU_MIN snaps to it */
|
|
297
|
+
const MENU_RAIL = 48
|
|
298
|
+
const MENU_MIN = 180
|
|
299
|
+
|
|
300
|
+
/** the menu as a resizable left Panel: its size and its collapsed state are kept in this
|
|
301
|
+
* browser, like the form and results split */
|
|
302
|
+
const MenuLayout = observer(function MenuLayout(p: { st: WebSt; main: ReactNode }) {
|
|
303
|
+
const saved = useDefaultLayout({ id: 'comfy-ts-menu', storage: splitStorage })
|
|
304
|
+
const menuRef = usePanelRef()
|
|
305
|
+
const [collapsed, setCollapsed] = useState(false)
|
|
306
|
+
// a rename (F2) types into the menu: a folded menu opens so the input is on screen
|
|
307
|
+
useEffect(
|
|
308
|
+
() =>
|
|
309
|
+
reaction(
|
|
310
|
+
() => p.st.renamingDraft != null,
|
|
311
|
+
(renaming) => {
|
|
312
|
+
const panel = menuRef.current
|
|
313
|
+
if (renaming && panel != null && panel.isCollapsed()) panel.expand()
|
|
314
|
+
},
|
|
315
|
+
),
|
|
316
|
+
[p.st, menuRef],
|
|
317
|
+
)
|
|
318
|
+
// ⌘B and ☰ bump the tick; folding is the Panel's own state, so it is remembered with its size
|
|
319
|
+
useEffect(
|
|
320
|
+
() =>
|
|
321
|
+
reaction(
|
|
322
|
+
() => p.st.menuFoldTick,
|
|
323
|
+
() => {
|
|
324
|
+
const panel = menuRef.current
|
|
325
|
+
if (panel == null) return
|
|
326
|
+
if (panel.isCollapsed()) panel.expand()
|
|
327
|
+
else panel.collapse()
|
|
328
|
+
},
|
|
329
|
+
),
|
|
330
|
+
[p.st, menuRef],
|
|
331
|
+
)
|
|
332
|
+
return (
|
|
333
|
+
<Group
|
|
334
|
+
id="comfy-ts-menu"
|
|
335
|
+
orientation="horizontal"
|
|
336
|
+
className="menu-layout"
|
|
337
|
+
defaultLayout={saved.defaultLayout}
|
|
338
|
+
onLayoutChanged={saved.onLayoutChanged}
|
|
339
|
+
>
|
|
340
|
+
<Panel
|
|
341
|
+
id="menu"
|
|
342
|
+
panelRef={menuRef}
|
|
343
|
+
defaultSize={220}
|
|
344
|
+
minSize={MENU_MIN}
|
|
345
|
+
maxSize={420}
|
|
346
|
+
collapsible
|
|
347
|
+
collapsedSize={MENU_RAIL}
|
|
348
|
+
groupResizeBehavior="preserve-pixel-size"
|
|
349
|
+
onResize={(size) => setCollapsed(size.inPixels < MENU_MIN - 1)}
|
|
350
|
+
className="menu-panel"
|
|
351
|
+
>
|
|
352
|
+
{collapsed ? (
|
|
353
|
+
<MenuRail st={p.st} onExpand={() => menuRef.current?.expand()} />
|
|
354
|
+
) : (
|
|
355
|
+
<div className="menu-col">
|
|
356
|
+
<MenuHead
|
|
357
|
+
tip={`fold the menu to icons (${MOD_KEY}B), it stays folded in this browser`}
|
|
358
|
+
keyHint={`${MOD_KEY}${SHORTCUT_KEYS['toggle-menu']}`}
|
|
359
|
+
onBurger={() => menuRef.current?.collapse()}
|
|
360
|
+
/>
|
|
361
|
+
<MenuCards st={p.st} />
|
|
362
|
+
</div>
|
|
363
|
+
)}
|
|
364
|
+
</Panel>
|
|
365
|
+
<Separator className="split-handle" />
|
|
366
|
+
<Panel id="main" minSize="40%" className="menu-main">
|
|
367
|
+
{p.main}
|
|
368
|
+
</Panel>
|
|
369
|
+
</Group>
|
|
370
|
+
)
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
/** phones: a slim bar naming where you are, the whole menu one tap away */
|
|
374
|
+
const MobileBar = observer(function MobileBar(p: { st: WebSt }) {
|
|
375
|
+
const form = p.st.form
|
|
376
|
+
return (
|
|
377
|
+
<div className="mobile-bar">
|
|
378
|
+
<button type="button" className="head-icon" aria-label="menu" onClick={() => p.st.setMenuOpen(true)}>
|
|
379
|
+
<Icon name="menu" />
|
|
380
|
+
</button>
|
|
381
|
+
<button type="button" className="mobile-where" onClick={() => p.st.omnibox.open()}>
|
|
382
|
+
<span className="menu-value mobile-workflow">{form?.moduleKey ?? 'no workflow'}</span>
|
|
383
|
+
{form == null ? null : <span className="mobile-draft"> · {form.draft}</span>}
|
|
384
|
+
</button>
|
|
385
|
+
</div>
|
|
386
|
+
)
|
|
387
|
+
})
|
|
388
|
+
|
|
389
|
+
const MenuDrawer = observer(function MenuDrawer(p: { st: WebSt }) {
|
|
390
|
+
if (!p.st.menuOpen) return null
|
|
391
|
+
return (
|
|
392
|
+
<div className="drawer-overlay" onClick={() => p.st.setMenuOpen(false)}>
|
|
393
|
+
<div className="drawer" onClick={(e) => e.stopPropagation()}>
|
|
394
|
+
<MenuHead
|
|
395
|
+
tip="close the menu"
|
|
396
|
+
keyHint={`${MOD_KEY}${SHORTCUT_KEYS['toggle-menu']}`}
|
|
397
|
+
onBurger={() => p.st.setMenuOpen(false)}
|
|
398
|
+
/>
|
|
399
|
+
<MenuCards st={p.st} />
|
|
400
|
+
</div>
|
|
401
|
+
</div>
|
|
402
|
+
)
|
|
403
|
+
})
|
|
404
|
+
|
|
405
|
+
/** ⌘B (ctrl elsewhere) folds the menu column, or opens and closes the drawer on a phone */
|
|
406
|
+
function useMenuShortcut(st: WebSt, narrow: boolean): void {
|
|
407
|
+
useEffect(() => {
|
|
408
|
+
const onKey = (e: KeyboardEvent): void => {
|
|
409
|
+
if (shortcutOf(e) !== 'toggle-menu') return
|
|
410
|
+
e.preventDefault()
|
|
411
|
+
if (narrow) st.setMenuOpen(!st.menuOpen)
|
|
412
|
+
else st.requestMenuFold()
|
|
413
|
+
}
|
|
414
|
+
window.addEventListener('keydown', onKey)
|
|
415
|
+
return () => window.removeEventListener('keydown', onKey)
|
|
416
|
+
}, [st, narrow])
|
|
417
|
+
}
|
|
418
|
+
|
|
283
419
|
export const App = observer(function App(p: { st: WebSt }) {
|
|
284
420
|
const narrow = useNarrow()
|
|
421
|
+
useMenuShortcut(p.st, narrow)
|
|
422
|
+
useTabShortcuts(p.st)
|
|
285
423
|
useSelectAllInFields()
|
|
286
424
|
useOmniboxShortcut(p.st)
|
|
287
425
|
if (p.st.phase === 'loading') return <div className="center">loading…</div>
|
|
@@ -307,7 +445,7 @@ export const App = observer(function App(p: { st: WebSt }) {
|
|
|
307
445
|
</button>
|
|
308
446
|
</div>
|
|
309
447
|
{p.st.logsError != null ? <div className="error">🔴 {p.st.logsError}</div> : null}
|
|
310
|
-
<
|
|
448
|
+
<ConsoleLines text={p.st.logLines.join('\n')} />
|
|
311
449
|
</div>
|
|
312
450
|
) : null}
|
|
313
451
|
</div>
|
|
@@ -318,13 +456,10 @@ export const App = observer(function App(p: { st: WebSt }) {
|
|
|
318
456
|
{p.st.generateInResults ? (
|
|
319
457
|
<div className="results-run">
|
|
320
458
|
<GenerateButton st={p.st} />
|
|
321
|
-
{/* one line, always reserved: an error arriving never pushes the gallery down */}
|
|
322
|
-
<span className="run-error" data-tip={p.st.run.error ?? undefined}>
|
|
323
|
-
{p.st.run.error == null ? '' : `🔴 ${p.st.run.error}`}
|
|
324
|
-
</span>
|
|
325
459
|
</div>
|
|
326
460
|
) : null}
|
|
327
461
|
<LivePreviews st={p.st} />
|
|
462
|
+
<RunError st={p.st} />
|
|
328
463
|
<Gallery st={p.st} compact={layout === 'pinned'} />
|
|
329
464
|
</div>
|
|
330
465
|
)
|
|
@@ -338,46 +473,62 @@ export const App = observer(function App(p: { st: WebSt }) {
|
|
|
338
473
|
// left / right on a screen wide enough: two FULL-HEIGHT panels, each scrolling on its own,
|
|
339
474
|
// split by a handle you drag. Everything else is one scrolling page
|
|
340
475
|
const split = (layout === 'side' || layout === 'left') && !narrow
|
|
476
|
+
const body = split ? (
|
|
477
|
+
<SplitWork
|
|
478
|
+
st={p.st}
|
|
479
|
+
left={layout === 'left'}
|
|
480
|
+
form={
|
|
481
|
+
<>
|
|
482
|
+
{notices}
|
|
483
|
+
{formCol}
|
|
484
|
+
</>
|
|
485
|
+
}
|
|
486
|
+
results={resultsCol}
|
|
487
|
+
/>
|
|
488
|
+
) : (
|
|
489
|
+
<div className="main">
|
|
490
|
+
{notices}
|
|
491
|
+
{/* the layout buttons drive ONE class, and it is the whole truth: the selected
|
|
492
|
+
button always names where the panel is */}
|
|
493
|
+
<div className={`work layout-${layout}`}>
|
|
494
|
+
{formCol}
|
|
495
|
+
{layout === 'off' ? (
|
|
496
|
+
// the panel took its buttons with it: this is the way back
|
|
497
|
+
<button
|
|
498
|
+
type="button"
|
|
499
|
+
className="show-preview"
|
|
500
|
+
data-tip="show the preview panel again"
|
|
501
|
+
onClick={() => p.st.showPreview()}
|
|
502
|
+
>
|
|
503
|
+
<Icon name="panel-side" /> preview
|
|
504
|
+
</button>
|
|
505
|
+
) : (
|
|
506
|
+
resultsCol
|
|
507
|
+
)}
|
|
508
|
+
</div>
|
|
509
|
+
</div>
|
|
510
|
+
)
|
|
341
511
|
return (
|
|
342
512
|
<div className="app">
|
|
513
|
+
{narrow ? <MobileBar st={p.st} /> : null}
|
|
343
514
|
<div className="cols">
|
|
344
|
-
{
|
|
345
|
-
|
|
515
|
+
{narrow ? (
|
|
516
|
+
body
|
|
517
|
+
) : (
|
|
518
|
+
<MenuLayout
|
|
346
519
|
st={p.st}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
{
|
|
351
|
-
|
|
352
|
-
</>
|
|
520
|
+
main={
|
|
521
|
+
<div className="tabs-col">
|
|
522
|
+
<DraftTabs st={p.st} />
|
|
523
|
+
<div className="tabs-body">{body}</div>
|
|
524
|
+
</div>
|
|
353
525
|
}
|
|
354
|
-
results={resultsCol}
|
|
355
526
|
/>
|
|
356
|
-
) : (
|
|
357
|
-
<div className="main">
|
|
358
|
-
{notices}
|
|
359
|
-
{/* the layout buttons drive ONE class, and it is the whole truth: the selected
|
|
360
|
-
button always names where the panel is */}
|
|
361
|
-
<div className={`work layout-${layout}`}>
|
|
362
|
-
{formCol}
|
|
363
|
-
{layout === 'off' ? (
|
|
364
|
-
// the panel took its buttons with it: this is the way back
|
|
365
|
-
<button
|
|
366
|
-
type="button"
|
|
367
|
-
className="show-preview"
|
|
368
|
-
data-tip="show the preview panel again"
|
|
369
|
-
onClick={() => p.st.showPreview()}
|
|
370
|
-
>
|
|
371
|
-
<Icon name="panel-side" /> preview
|
|
372
|
-
</button>
|
|
373
|
-
) : (
|
|
374
|
-
resultsCol
|
|
375
|
-
)}
|
|
376
|
-
</div>
|
|
377
|
-
</div>
|
|
378
527
|
)}
|
|
379
528
|
</div>
|
|
529
|
+
{narrow ? <MenuDrawer st={p.st} /> : null}
|
|
380
530
|
<Omnibox st={p.st} />
|
|
531
|
+
<ShortcutsModal st={p.st} />
|
|
381
532
|
<TooltipLayer />
|
|
382
533
|
</div>
|
|
383
534
|
)
|