comfy-ts 2.11.0 → 2.12.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 +1 -0
- package/dist/{LogsSt-qtFzOKpu.js → LogsSt-U1H0mP1m.js} +35 -5
- package/dist/LogsSt-U1H0mP1m.js.map +1 -0
- package/dist/cli.js +4 -4
- package/dist/index.cjs +473 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +191 -31
- package/dist/index.d.ts +191 -31
- package/dist/index.js +469 -63
- package/dist/index.js.map +1 -1
- package/dist/{run-serve-BK7BA2dn.js → run-serve-BeAznay5.js} +461 -43
- package/dist/run-serve-BeAznay5.js.map +1 -0
- package/dist/{run-tui-CQyvMf0N.js → run-tui-BTGjvnKk.js} +43 -18
- package/dist/run-tui-BTGjvnKk.js.map +1 -0
- package/dist/{schemaDrift-DjjEtwfx.js → schemaDrift-Cg39vs53.js} +470 -60
- package/dist/schemaDrift-Cg39vs53.js.map +1 -0
- package/dist/serve-web.js +508 -134
- package/dist/{state--wrz0BQc.js → state-C7REnHan.js} +7 -3
- package/dist/{state--wrz0BQc.js.map → state-C7REnHan.js.map} +1 -1
- package/dist/web.d.ts +191 -31
- package/dist/web.js +469 -63
- package/dist/web.js.map +1 -1
- package/examples/rvion/06-qwen-image-edit.cflow.ts +3 -2
- package/examples/rvion/10-anima-t2i.cflow.ts +229 -0
- package/extra/README.md +4 -0
- package/extra/comfyui-fresh-model-lists/README.md +25 -0
- package/extra/comfyui-fresh-model-lists/__init__.py +36 -0
- package/extra/comfyui-fresh-model-lists/test_fresh_model_lists.py +97 -0
- package/package.json +15 -7
- package/src/cli/draftMeta.ts +39 -0
- package/src/cli/serve/ServeApp.ts +148 -12
- package/src/cli/serve/applyVarPayload.ts +50 -22
- package/src/cli/serve/describeVar.ts +42 -6
- package/src/cli/serve/llmConfigShape.ts +51 -0
- package/src/cli/serve/llmConfigs.ts +52 -0
- package/src/cli/serve/tagList.ts +92 -0
- package/src/cli/serve/tagSource.ts +69 -0
- package/src/cli/serve/web/api.ts +48 -0
- package/src/cli/serve/web/components/App.tsx +336 -44
- package/src/cli/serve/web/components/Gallery.tsx +105 -28
- package/src/cli/serve/web/components/HistoryPicker.tsx +149 -0
- package/src/cli/serve/web/components/Icon.tsx +18 -2
- package/src/cli/serve/web/components/MenuButton.tsx +53 -0
- package/src/cli/serve/web/components/Omnibox.tsx +85 -0
- package/src/cli/serve/web/components/PromptEnhancer.tsx +476 -180
- package/src/cli/serve/web/components/TooltipLayer.tsx +45 -0
- package/src/cli/serve/web/components/VarIcon.tsx +24 -0
- package/src/cli/serve/web/components/VarsForm.tsx +341 -188
- package/src/cli/serve/web/components/controls/BasicControls.tsx +57 -32
- package/src/cli/serve/web/components/controls/LorasControl.tsx +644 -317
- package/src/cli/serve/web/components/controls/PresetPicker.tsx +1 -1
- package/src/cli/serve/web/components/controls/PromptControl.tsx +279 -0
- package/src/cli/serve/web/components/controls/PromptEditor.tsx +113 -0
- package/src/cli/serve/web/components/controls/SeedControl.tsx +17 -10
- package/src/cli/serve/web/components/controls/SizeControl.tsx +111 -18
- package/src/cli/serve/web/components/modKey.ts +2 -0
- package/src/cli/serve/web/llm.ts +23 -12
- package/src/cli/serve/web/promptEditor/promptExtensions.ts +281 -0
- package/src/cli/serve/web/state/EnhancerSt.ts +415 -100
- package/src/cli/serve/web/state/FormSt.ts +193 -29
- package/src/cli/serve/web/state/OmniboxSt.ts +57 -0
- package/src/cli/serve/web/state/WebSt.ts +219 -74
- package/src/cli/serve/web/state/choiceButtons.ts +61 -0
- package/src/cli/serve/web/state/generateButton.ts +16 -0
- package/src/cli/serve/web/state/history.ts +54 -0
- package/src/cli/serve/web/state/host.ts +5 -2
- package/src/cli/serve/web/state/keptLines.ts +53 -0
- package/src/cli/serve/web/state/latentMode.ts +20 -0
- package/src/cli/serve/web/state/loraSort.ts +18 -0
- package/src/cli/serve/web/state/moduleTree.ts +2 -2
- package/src/cli/serve/web/state/omnibox.ts +69 -0
- package/src/cli/serve/web/state/payload.ts +38 -58
- package/src/cli/serve/web/state/shortcuts.ts +54 -0
- package/src/cli/serve/web/state/sizeStars.ts +31 -0
- package/src/cli/serve/web/state/stableSlots.ts +21 -0
- package/src/cli/serve/web/state/varGroups.ts +24 -0
- package/src/cli/serve/web/styles.ts +457 -118
- package/src/cli/serve/webBundle.ts +54 -10
- package/src/cli/tui/components/PickerOverlays.tsx +9 -2
- package/src/cli/tui/imagePicker/ImagePickerSt.ts +1 -1
- package/src/cli/tui/state/DraftsSt.ts +18 -2
- package/src/cli/tui/state/EditorSt.ts +1 -1
- package/src/cli/tui/state/LorasSt.ts +1 -1
- package/src/cli/tui/state/PickerSt.ts +25 -7
- package/src/cli/tui/state/SettingsSt.ts +1 -1
- package/src/cli/tui/state/TuiSt.ts +10 -0
- package/src/coreExports.ts +20 -0
- package/src/host/loraInfoCache.ts +6 -0
- package/src/state.ts +5 -0
- package/src/vars/ComfyVars.ts +337 -67
- package/src/vars/DefinedWorkflow.ts +40 -19
- package/src/vars/lanes.ts +238 -0
- package/src/vars/loraEntry.ts +101 -0
- package/src/vars/promptSyntax.ts +382 -0
- package/dist/LogsSt-qtFzOKpu.js.map +0 -1
- package/dist/run-serve-BK7BA2dn.js.map +0 -1
- package/dist/run-tui-CQyvMf0N.js.map +0 -1
- package/dist/schemaDrift-DjjEtwfx.js.map +0 -1
- package/src/cli/serve/web/components/Sidebar.tsx +0 -66
|
@@ -6,6 +6,7 @@ import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
|
|
|
6
6
|
import { observer, useLocalObservable } from 'mobx-react-lite'
|
|
7
7
|
import { useEffect, useRef } from 'react'
|
|
8
8
|
import { runPreviewSrc } from 'src/cli/serve/web/api.ts'
|
|
9
|
+
import { asSizeForm } from 'src/cli/serve/web/state/payload.ts'
|
|
9
10
|
import { lightboxView, type LightboxTarget } from 'src/cli/serve/web/state/lightbox.ts'
|
|
10
11
|
import { copyImageToClipboard } from 'src/cli/serve/web/clipboard.ts'
|
|
11
12
|
import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
|
|
@@ -297,11 +298,53 @@ const LiveText = observer(function LiveText(p: { text: string }) {
|
|
|
297
298
|
)
|
|
298
299
|
})
|
|
299
300
|
|
|
301
|
+
/** the corner mode: the run as a small card floating over the gallery's top right corner, on a
|
|
302
|
+
* zero-height sticky anchor, so it takes no room. The last image stays where it is while the
|
|
303
|
+
* next one runs, and the finished one lands at the top in one go */
|
|
304
|
+
const CornerRun = observer(function CornerRun(p: { st: WebSt; local: GalleryLocal; module: string }) {
|
|
305
|
+
const percent = p.st.run.progressPercent
|
|
306
|
+
const node = p.st.run.progressNode
|
|
307
|
+
const count = p.st.run.progressCount
|
|
308
|
+
return (
|
|
309
|
+
<div className="corner-run-anchor">
|
|
310
|
+
<div className="corner-run">
|
|
311
|
+
{p.st.run.hasPreview ? (
|
|
312
|
+
<button
|
|
313
|
+
type="button"
|
|
314
|
+
className="img-button"
|
|
315
|
+
data-tip="the latent so far: click to see it big"
|
|
316
|
+
onClick={() =>
|
|
317
|
+
p.local.openLightbox({
|
|
318
|
+
kind: 'latent',
|
|
319
|
+
module: p.module,
|
|
320
|
+
after: p.st.run.results.filter((r) => r.module === p.module).length,
|
|
321
|
+
})
|
|
322
|
+
}
|
|
323
|
+
>
|
|
324
|
+
<img src={runPreviewSrc({ module: p.module, tick: p.st.run.previewTick })} alt="latent preview" />
|
|
325
|
+
</button>
|
|
326
|
+
) : null}
|
|
327
|
+
<div className="corner-run-meta">
|
|
328
|
+
<span className="run-meta-text">
|
|
329
|
+
{node == null ? p.module : node}
|
|
330
|
+
{count != null ? ` ${count.value}/${count.max}` : ''}
|
|
331
|
+
</span>
|
|
332
|
+
<span>{percent != null ? `${Math.round(percent)}%` : ''}</span>
|
|
333
|
+
</div>
|
|
334
|
+
<div className="progress-track">
|
|
335
|
+
<div className="progress-fill" style={{ width: `${percent ?? 0}%` }} />
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
</div>
|
|
339
|
+
)
|
|
340
|
+
})
|
|
341
|
+
|
|
300
342
|
/** live card while a run is in flight: progress bar + the latest latent frame */
|
|
301
343
|
const RunningCard = observer(function RunningCard(p: { st: WebSt; local: GalleryLocal }) {
|
|
302
344
|
// the RUNNING module, never the selection: switching modules mid-run must not retarget the card
|
|
303
345
|
const moduleKey = p.st.run.runningModule
|
|
304
346
|
if (!p.st.run.isRunning || moduleKey == null) return null
|
|
347
|
+
if (p.st.latentMode === 'corner') return <CornerRun st={p.st} local={p.local} module={moduleKey} />
|
|
305
348
|
const percent = p.st.run.progressPercent
|
|
306
349
|
const previewUrl = runPreviewSrc({ module: moduleKey, tick: p.st.run.previewTick })
|
|
307
350
|
// the node's OWN counter: generated tokens on a text node, sampler steps on a KSampler.
|
|
@@ -309,41 +352,63 @@ const RunningCard = observer(function RunningCard(p: { st: WebSt; local: Gallery
|
|
|
309
352
|
const node = p.st.run.progressNode
|
|
310
353
|
const count = p.st.run.progressCount
|
|
311
354
|
const liveText = p.st.run.progressText
|
|
355
|
+
// the frame is RESERVED from the first moment at the image's own ratio (the size var of the
|
|
356
|
+
// running workflow) and the box a finished image takes (.run-card img: 320px max each way),
|
|
357
|
+
// the bar drawn over its foot, the node counter on the one header line: nothing grows while
|
|
358
|
+
// the run goes and the result lands in the same space
|
|
359
|
+
const form = p.st.form
|
|
360
|
+
const sizeVar = form?.moduleKey === moduleKey ? form.vars.find((v) => v.desc.kind === 'size') : undefined
|
|
361
|
+
const size = sizeVar == null ? null : asSizeForm(sizeVar.value)
|
|
362
|
+
const imageGraph = size != null || p.st.run.hasPreview
|
|
363
|
+
const ratio = size == null ? 1 : size.width / size.height
|
|
312
364
|
return (
|
|
313
365
|
<div className="run-card running">
|
|
314
366
|
<div className="meta">
|
|
315
|
-
<span
|
|
367
|
+
<span className="run-meta-text">
|
|
368
|
+
generating {moduleKey}…
|
|
369
|
+
{node != null ? ` · ${node}${count != null ? ` ${count.value}/${count.max}` : ''}` : ''}
|
|
370
|
+
</span>
|
|
316
371
|
<span>{percent != null ? `${Math.round(percent)}%` : ''}</span>
|
|
317
372
|
</div>
|
|
318
|
-
{node != null ? (
|
|
319
|
-
<div className="run-node">
|
|
320
|
-
{node}
|
|
321
|
-
{count != null ? ` ${count.value}/${count.max}` : ''}
|
|
322
|
-
</div>
|
|
323
|
-
) : null}
|
|
324
373
|
{/* a node streaming its text as it produces it: the answer builds up here before the
|
|
325
374
|
run ends. Same fold as a finished result, so watching and reading look alike */}
|
|
326
375
|
{liveText != null && liveText !== '' ? <LiveText text={liveText} /> : null}
|
|
327
|
-
|
|
328
|
-
<div
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
376
|
+
{imageGraph ? (
|
|
377
|
+
<div
|
|
378
|
+
className="run-frame"
|
|
379
|
+
style={{
|
|
380
|
+
aspectRatio: String(ratio),
|
|
381
|
+
// the box the finished image will take in the current view, so it lands in place
|
|
382
|
+
width:
|
|
383
|
+
p.st.resultsView === 'fit'
|
|
384
|
+
? '100%'
|
|
385
|
+
: `min(100%, ${p.st.resultsSize}px, calc(${p.st.resultsSize}px * ${ratio}))`,
|
|
386
|
+
}}
|
|
387
|
+
>
|
|
388
|
+
{p.st.run.hasPreview && p.st.latentMode === 'full' ? (
|
|
389
|
+
<button
|
|
390
|
+
type="button"
|
|
391
|
+
className="img-button"
|
|
392
|
+
onClick={() =>
|
|
393
|
+
p.local.openLightbox({
|
|
394
|
+
kind: 'latent',
|
|
395
|
+
module: moduleKey,
|
|
396
|
+
after: p.st.run.results.filter((r) => r.module === moduleKey).length,
|
|
397
|
+
})
|
|
398
|
+
}
|
|
399
|
+
>
|
|
400
|
+
<img src={previewUrl} alt="latent preview" />
|
|
401
|
+
</button>
|
|
402
|
+
) : null}
|
|
403
|
+
<div className="progress-track over">
|
|
404
|
+
<div className="progress-fill" style={{ width: `${percent ?? 0}%` }} />
|
|
405
|
+
</div>
|
|
345
406
|
</div>
|
|
346
|
-
) :
|
|
407
|
+
) : (
|
|
408
|
+
<div className="progress-track">
|
|
409
|
+
<div className="progress-fill" style={{ width: `${percent ?? 0}%` }} />
|
|
410
|
+
</div>
|
|
411
|
+
)}
|
|
347
412
|
</div>
|
|
348
413
|
)
|
|
349
414
|
})
|
|
@@ -356,7 +421,11 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
|
|
|
356
421
|
if (p.st.run.results.length === 0 && !p.st.run.isRunning) return null
|
|
357
422
|
const results = p.compact === true ? p.st.run.results.slice(0, 1) : p.st.run.results
|
|
358
423
|
return (
|
|
359
|
-
|
|
424
|
+
// fit: one per row at the panel's width; grid: the slider's size, wrapping. The corner
|
|
425
|
+
// placement keeps its own compact look
|
|
426
|
+
<div
|
|
427
|
+
className={`gallery${p.st.blurResults ? ' blur' : ''}${p.compact === true ? '' : ` view-${p.st.resultsView}`}`}
|
|
428
|
+
>
|
|
360
429
|
<RunningCard st={p.st} local={local} />
|
|
361
430
|
{/* the count and clear-all moved onto the run line beside the generate button: two
|
|
362
431
|
headers for one idea is a header too many */}
|
|
@@ -394,7 +463,15 @@ export const Gallery = observer(function Gallery(p: { st: WebSt; compact?: boole
|
|
|
394
463
|
})
|
|
395
464
|
}}
|
|
396
465
|
>
|
|
397
|
-
<img
|
|
466
|
+
<img
|
|
467
|
+
src={img.url}
|
|
468
|
+
alt={img.filename}
|
|
469
|
+
style={
|
|
470
|
+
p.st.resultsView === 'grid' && p.compact !== true
|
|
471
|
+
? { maxWidth: `min(100%, ${p.st.resultsSize}px)`, maxHeight: p.st.resultsSize }
|
|
472
|
+
: undefined
|
|
473
|
+
}
|
|
474
|
+
/>
|
|
398
475
|
</button>
|
|
399
476
|
{/* the EMBEDDING page's buttons (host protocol): what it does with the
|
|
400
477
|
image is its business — send it somewhere, keep it as something */}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// the history picker: every value submitted this page, searchable. Two columns: the matches on
|
|
2
|
+
// the left (first line, how long ago, where from), the FULL text of the highlighted one on the
|
|
3
|
+
// right, so arrowing down previews exactly what a pick writes. Enter or a click picks
|
|
4
|
+
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
|
5
|
+
import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
|
|
6
|
+
import { searchHistory, timeAgo, type HistoryEntry } from 'src/cli/serve/web/state/history.ts'
|
|
7
|
+
|
|
8
|
+
/** the button that opens it: always there, disabled while nothing was submitted yet. Plain (not
|
|
9
|
+
* an observer) to stay generic: the observer parent reads the list and passes it down */
|
|
10
|
+
export function HistoryButton<V>(p: {
|
|
11
|
+
entries: readonly HistoryEntry<V>[]
|
|
12
|
+
what: string
|
|
13
|
+
onPick(entry: HistoryEntry<V>): void
|
|
14
|
+
compact?: boolean
|
|
15
|
+
}): ReactNode {
|
|
16
|
+
const [open, setOpen] = useState(false)
|
|
17
|
+
const n = p.entries.length
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<button
|
|
21
|
+
type="button"
|
|
22
|
+
className={p.compact === true ? 'link' : 'mini'}
|
|
23
|
+
disabled={n === 0}
|
|
24
|
+
data-tip={
|
|
25
|
+
n === 0
|
|
26
|
+
? `every ${p.what} you submit shows here, until you close the page`
|
|
27
|
+
: `${n} past ${p.what}s: search, preview, restore`
|
|
28
|
+
}
|
|
29
|
+
onClick={() => setOpen(true)}
|
|
30
|
+
>
|
|
31
|
+
<Icon name="history" />
|
|
32
|
+
{p.compact === true ? null : ' history'}
|
|
33
|
+
</button>
|
|
34
|
+
{open ? (
|
|
35
|
+
<HistoryPicker
|
|
36
|
+
entries={p.entries}
|
|
37
|
+
what={p.what}
|
|
38
|
+
onPick={(e) => {
|
|
39
|
+
setOpen(false)
|
|
40
|
+
p.onPick(e)
|
|
41
|
+
}}
|
|
42
|
+
onClose={() => setOpen(false)}
|
|
43
|
+
/>
|
|
44
|
+
) : null}
|
|
45
|
+
</>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function HistoryPicker<V>(p: {
|
|
50
|
+
entries: readonly HistoryEntry<V>[]
|
|
51
|
+
what: string
|
|
52
|
+
onPick(entry: HistoryEntry<V>): void
|
|
53
|
+
onClose(): void
|
|
54
|
+
}): ReactNode {
|
|
55
|
+
const [query, setQuery] = useState('')
|
|
56
|
+
const [cursor, setCursor] = useState(0)
|
|
57
|
+
const [now, setNow] = useState(() => Date.now())
|
|
58
|
+
const listRef = useRef<HTMLDivElement>(null)
|
|
59
|
+
const matches = searchHistory(p.entries, query)
|
|
60
|
+
const sel = matches[Math.min(cursor, Math.max(0, matches.length - 1))] ?? null
|
|
61
|
+
// "3 min ago" keeps being true while the picker stays open
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
const t = setInterval(() => setNow(Date.now()), 10_000)
|
|
64
|
+
return () => clearInterval(t)
|
|
65
|
+
}, [])
|
|
66
|
+
// esc closes THIS, never the modal under it (the enhancer listens on window too): a capture
|
|
67
|
+
// listener runs first and stops the event there
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
const onKey = (e: KeyboardEvent): void => {
|
|
70
|
+
if (e.key !== 'Escape') return
|
|
71
|
+
e.stopImmediatePropagation()
|
|
72
|
+
p.onClose()
|
|
73
|
+
}
|
|
74
|
+
window.addEventListener('keydown', onKey, true)
|
|
75
|
+
return () => window.removeEventListener('keydown', onKey, true)
|
|
76
|
+
}, [p])
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
listRef.current?.querySelector('.hist-row.sel')?.scrollIntoView({ block: 'nearest' })
|
|
79
|
+
}, [cursor, query])
|
|
80
|
+
const move = (delta: number): void => setCursor((c) => Math.max(0, Math.min(matches.length - 1, c + delta)))
|
|
81
|
+
return (
|
|
82
|
+
<div className="modal-overlay top hist-overlay" onClick={() => p.onClose()}>
|
|
83
|
+
<div className="modal hist-modal" onClick={(e) => e.stopPropagation()}>
|
|
84
|
+
<div className="modal-head">
|
|
85
|
+
<Icon name="history" />
|
|
86
|
+
<input
|
|
87
|
+
type="text"
|
|
88
|
+
autoFocus
|
|
89
|
+
placeholder={`search ${p.entries.length} past ${p.what}s, every word must match`}
|
|
90
|
+
value={query}
|
|
91
|
+
onChange={(e) => {
|
|
92
|
+
setQuery(e.target.value)
|
|
93
|
+
setCursor(0)
|
|
94
|
+
}}
|
|
95
|
+
onKeyDown={(e) => {
|
|
96
|
+
if (e.key === 'ArrowDown') {
|
|
97
|
+
e.preventDefault()
|
|
98
|
+
move(1)
|
|
99
|
+
} else if (e.key === 'ArrowUp') {
|
|
100
|
+
e.preventDefault()
|
|
101
|
+
move(-1)
|
|
102
|
+
} else if (e.key === 'Enter') {
|
|
103
|
+
e.preventDefault()
|
|
104
|
+
if (sel != null) p.onPick(sel)
|
|
105
|
+
}
|
|
106
|
+
}}
|
|
107
|
+
/>
|
|
108
|
+
<button type="button" className="modal-close" data-tip="close (esc)" onClick={() => p.onClose()}>
|
|
109
|
+
<Icon name="close" />
|
|
110
|
+
</button>
|
|
111
|
+
</div>
|
|
112
|
+
<div className="hist-cols">
|
|
113
|
+
<div className="hist-list" ref={listRef}>
|
|
114
|
+
{matches.length === 0 ? <div className="hist-empty">nothing matches '{query}'</div> : null}
|
|
115
|
+
{matches.map((e, ix) => (
|
|
116
|
+
<button
|
|
117
|
+
key={e.text}
|
|
118
|
+
type="button"
|
|
119
|
+
className={e === sel ? 'hist-row sel' : 'hist-row'}
|
|
120
|
+
onMouseEnter={() => setCursor(ix)}
|
|
121
|
+
onClick={() => p.onPick(e)}
|
|
122
|
+
>
|
|
123
|
+
<span className="hist-first">{e.text.split('\n')[0]}</span>
|
|
124
|
+
<span className="hist-meta">
|
|
125
|
+
{timeAgo(e.at, now)}
|
|
126
|
+
{e.count > 1 ? ` · ${e.count}×` : ''}
|
|
127
|
+
{e.source === '' ? '' : ` · ${e.source}`}
|
|
128
|
+
</span>
|
|
129
|
+
</button>
|
|
130
|
+
))}
|
|
131
|
+
</div>
|
|
132
|
+
<div className="hist-preview">
|
|
133
|
+
{sel == null ? null : (
|
|
134
|
+
<>
|
|
135
|
+
<pre className="hist-text">{sel.text}</pre>
|
|
136
|
+
<div className="hist-foot">
|
|
137
|
+
<span className="hint">↑↓ to preview, enter or click to restore</span>
|
|
138
|
+
<button type="button" className="primary" onClick={() => p.onPick(sel)}>
|
|
139
|
+
restore this {p.what}
|
|
140
|
+
</button>
|
|
141
|
+
</div>
|
|
142
|
+
</>
|
|
143
|
+
)}
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
)
|
|
149
|
+
}
|
|
@@ -36,7 +36,14 @@ export type IconName =
|
|
|
36
36
|
| 'unlink'
|
|
37
37
|
| 'refresh'
|
|
38
38
|
| 'terminal'
|
|
39
|
-
| '
|
|
39
|
+
| 'search'
|
|
40
|
+
| 'history'
|
|
41
|
+
| 'rows'
|
|
42
|
+
| 'grid'
|
|
43
|
+
| 'eye'
|
|
44
|
+
| 'eye-off'
|
|
45
|
+
| 'more'
|
|
46
|
+
| 'text'
|
|
40
47
|
| 'dot'
|
|
41
48
|
|
|
42
49
|
/** 24x24 viewBox paths, stroked (fill: none) unless the shape reads better solid */
|
|
@@ -133,7 +140,16 @@ const PATHS: Record<IconName, ReactNode> = {
|
|
|
133
140
|
),
|
|
134
141
|
refresh: <path d="M20 11a8 8 0 10-2 6M20 6v5h-5" />,
|
|
135
142
|
terminal: <path d="M4 5h16v14H4zM7 9l3 3-3 3M13 15h4" />,
|
|
136
|
-
|
|
143
|
+
text: <path d="M4 7h16M4 12h10M4 17h13" />,
|
|
144
|
+
more: <path d="M5 12h.01M12 12h.01M19 12h.01" strokeWidth={3.2} />,
|
|
145
|
+
eye: <path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12zM12 9a3 3 0 110 6 3 3 0 010-6z" />,
|
|
146
|
+
'eye-off': (
|
|
147
|
+
<path d="M3 3l18 18M10.6 5.1A10 10 0 0112 5c6.5 0 10 7 10 7a17 17 0 01-3.2 4.2M6.6 6.6C3.9 8.4 2 12 2 12s3.5 7 10 7a9.7 9.7 0 005.4-1.6M9.9 9.9a3 3 0 004.2 4.2" />
|
|
148
|
+
),
|
|
149
|
+
rows: <path d="M4 5h16v6H4zM4 13h16v6H4z" />,
|
|
150
|
+
grid: <path d="M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z" />,
|
|
151
|
+
search: <path d="M10.5 4a6.5 6.5 0 110 13 6.5 6.5 0 010-13zM15.5 15.5L20 20" />,
|
|
152
|
+
history: <path d="M4 12a8 8 0 102.3-5.6M4 4v4h4M12 8v4l3 2" />,
|
|
137
153
|
dot: <circle cx="12" cy="12" r="5" fill="currentColor" stroke="none" />,
|
|
138
154
|
}
|
|
139
155
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// a ⋯ button and the small menu it opens: where the rarely used actions go, so a row shows its
|
|
2
|
+
// content instead of a strip of buttons. A backdrop under the menu closes it on any outside
|
|
3
|
+
// click, no document listener to leak
|
|
4
|
+
import { useState, type ReactNode } from 'react'
|
|
5
|
+
import { Icon } from 'src/cli/serve/web/components/Icon.tsx'
|
|
6
|
+
|
|
7
|
+
export function MenuButton(p: {
|
|
8
|
+
tip: string
|
|
9
|
+
className?: string
|
|
10
|
+
/** the menu body; `close` is handed over so an item can shut the menu after acting */
|
|
11
|
+
children: (close: () => void) => ReactNode
|
|
12
|
+
}): ReactNode {
|
|
13
|
+
const [open, setOpen] = useState(false)
|
|
14
|
+
const close = (): void => setOpen(false)
|
|
15
|
+
return (
|
|
16
|
+
<span
|
|
17
|
+
className={`preset-box menu-box ${p.className ?? ''}`}
|
|
18
|
+
onKeyDown={(e) => (e.key === 'Escape' ? close() : undefined)}
|
|
19
|
+
>
|
|
20
|
+
<button
|
|
21
|
+
type="button"
|
|
22
|
+
className="menu-btn"
|
|
23
|
+
aria-expanded={open}
|
|
24
|
+
data-tip={p.tip}
|
|
25
|
+
onClick={() => setOpen(!open)}
|
|
26
|
+
>
|
|
27
|
+
<Icon name="more" />
|
|
28
|
+
</button>
|
|
29
|
+
{open ? (
|
|
30
|
+
<>
|
|
31
|
+
<div className="preset-backdrop" onClick={close} />
|
|
32
|
+
<div className="preset-menu menu-list">{p.children(close)}</div>
|
|
33
|
+
</>
|
|
34
|
+
) : null}
|
|
35
|
+
</span>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** one menu line: a button, or a checkbox line when `checked` is given */
|
|
40
|
+
export function MenuItem(p: {
|
|
41
|
+
label: ReactNode
|
|
42
|
+
onClick: () => void
|
|
43
|
+
checked?: boolean
|
|
44
|
+
disabled?: boolean
|
|
45
|
+
tip?: string
|
|
46
|
+
}): ReactNode {
|
|
47
|
+
return (
|
|
48
|
+
<button type="button" className="menu-item" disabled={p.disabled} data-tip={p.tip} onClick={p.onClick}>
|
|
49
|
+
<span className="menu-check">{p.checked == null ? '' : p.checked ? '✓' : ''}</span>
|
|
50
|
+
{p.label}
|
|
51
|
+
</button>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// ⌘K / ⌘J: type a few letters of any folder, workflow or draft, Enter opens it.
|
|
2
|
+
// modules that failed to load are listed under the matches, since nothing else shows them
|
|
3
|
+
import { observer } from 'mobx-react-lite'
|
|
4
|
+
import { useEffect, useRef } from 'react'
|
|
5
|
+
import type { WebSt } from 'src/cli/serve/web/state/WebSt.ts'
|
|
6
|
+
|
|
7
|
+
/** ⌘K and ⌘J (ctrl on other systems) from ANY focus, a text field included: it is a jump,
|
|
8
|
+
* not an edit, and the prompt textarea is where the focus usually is */
|
|
9
|
+
export function useOmniboxShortcut(st: WebSt): void {
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const onKey = (e: KeyboardEvent): void => {
|
|
12
|
+
if (!(e.metaKey || e.ctrlKey) || e.altKey || e.shiftKey) return
|
|
13
|
+
if (e.key !== 'k' && e.key !== 'K' && e.key !== 'j' && e.key !== 'J') return
|
|
14
|
+
e.preventDefault()
|
|
15
|
+
st.omnibox.toggle()
|
|
16
|
+
}
|
|
17
|
+
window.addEventListener('keydown', onKey)
|
|
18
|
+
return () => window.removeEventListener('keydown', onKey)
|
|
19
|
+
}, [st])
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const Omnibox = observer(function Omnibox(p: { st: WebSt }) {
|
|
23
|
+
const o = p.st.omnibox
|
|
24
|
+
const listRef = useRef<HTMLDivElement>(null)
|
|
25
|
+
// the lit row stays in view while arrowing through a long list
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
listRef.current?.querySelector('.omni-row.sel')?.scrollIntoView({ block: 'nearest' })
|
|
28
|
+
}, [o.cursor, o.query])
|
|
29
|
+
if (!o.isOpen) return null
|
|
30
|
+
const results = o.results
|
|
31
|
+
const errors = Object.entries(p.st.loadErrors)
|
|
32
|
+
const current = p.st.form
|
|
33
|
+
return (
|
|
34
|
+
<div className="modal-overlay omni-overlay" onClick={() => o.close()}>
|
|
35
|
+
<div className="modal omni" onClick={(e) => e.stopPropagation()}>
|
|
36
|
+
<div className="modal-head">
|
|
37
|
+
<input
|
|
38
|
+
type="text"
|
|
39
|
+
autoFocus
|
|
40
|
+
placeholder="workflow or draft…"
|
|
41
|
+
value={o.query}
|
|
42
|
+
onChange={(e) => o.setQuery(e.target.value)}
|
|
43
|
+
onKeyDown={(e) => {
|
|
44
|
+
if (e.key === 'ArrowDown') o.move(1)
|
|
45
|
+
else if (e.key === 'ArrowUp') o.move(-1)
|
|
46
|
+
else if (e.key === 'Enter') o.pick()
|
|
47
|
+
else if (e.key === 'Escape') o.close()
|
|
48
|
+
else return
|
|
49
|
+
e.preventDefault()
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
52
|
+
</div>
|
|
53
|
+
<div className="modal-body omni-list" ref={listRef}>
|
|
54
|
+
{results.length === 0 ? <div className="hint">no workflow or draft matches</div> : null}
|
|
55
|
+
{results.map((entry, ix) => {
|
|
56
|
+
const open = current?.moduleKey === entry.module && current.draft === entry.draft
|
|
57
|
+
const cls = ['omni-row', ix === o.cursor ? 'sel' : '', open ? 'open' : ''].join(' ')
|
|
58
|
+
return (
|
|
59
|
+
<button
|
|
60
|
+
key={`${entry.module}/${entry.draft}`}
|
|
61
|
+
type="button"
|
|
62
|
+
className={cls}
|
|
63
|
+
onClick={() => o.pick(entry)}
|
|
64
|
+
>
|
|
65
|
+
<span className="omni-label">{entry.label}</span>
|
|
66
|
+
<span className="omni-host">{open ? 'open' : entry.host}</span>
|
|
67
|
+
</button>
|
|
68
|
+
)
|
|
69
|
+
})}
|
|
70
|
+
{errors.length > 0 ? (
|
|
71
|
+
<div className="omni-errors">
|
|
72
|
+
<div className="section-title">failed to load</div>
|
|
73
|
+
{errors.map(([file, msg]) => (
|
|
74
|
+
<div key={file}>
|
|
75
|
+
<div className="file">{file}</div>
|
|
76
|
+
<div className="msg">{msg}</div>
|
|
77
|
+
</div>
|
|
78
|
+
))}
|
|
79
|
+
</div>
|
|
80
|
+
) : null}
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
)
|
|
85
|
+
})
|