rvlib-shipkit 2.16.0 → 2.17.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.
@@ -7,13 +7,13 @@
7
7
  import { observer } from 'mobx-react-lite'
8
8
  import { useEffect, useRef, useState, type ReactNode } from 'react'
9
9
  import type { VersionCell } from '../../../review/cells.ts'
10
- import { isChoice, isGallery, isPair, onFrame, STARS, STATUS_LABEL, thumbFileOf, viewFilesOf, viewName, viewTag, type GalleryView, type Item, type MediaView, type Rect, type ReviewClip, type ReviewMark, type ReviewView, type Side } from '../../../review/model.ts'
10
+ import { isChoice, isGallery, isPair, onFrame, STARS, STATUS_LABEL, thumbFileOf, tileName, viewFilesOf, viewName, viewTag, type GalleryTile, type GalleryView, type Item, type MediaView, type Rect, type ReviewClip, type ReviewMark, type ReviewView, type Side } from '../../../review/model.ts'
11
11
  import { AutoText } from '../auto-text.tsx'
12
12
  import type { ClipSt } from './clip-st.ts'
13
13
  import { blurOnEscape, FIT_ROOM, keepFocus, PAIR_NAMES, REACTIONS, secs, SIDE_LABEL } from './kit.tsx'
14
- import { ZOOMS, type Zoom } from './review-kit.ts'
14
+ import { TILE_H, ZOOMS, type Zoom } from './review-kit.ts'
15
15
  import { COMPARE_MODES, drawnSide, type CompareMode, type CompareSt, type PairSide, type ReviewSt } from './review-st.ts'
16
- import { viewDom, viewKind, viewKey, type ThreadSt } from './thread-st.ts'
16
+ import { TILE_FILTERS, viewDom, viewKind, viewKey, type ThreadSt, type TileFilter } from './thread-st.ts'
17
17
  import { Caret } from '../icons.tsx'
18
18
 
19
19
  const ZOOM_LABEL: Record<Zoom, string> = { fit: 'Fit', '1': '100 %', '1.5': '150 %', '2': '200 %' }
@@ -44,7 +44,7 @@ export const VersionViews = observer(({ ver }: { ver: Ver }) => {
44
44
  const item = itemOf(ver)
45
45
  const views = item.views
46
46
  const rows = card.rows(item)
47
- const drawable = takes(ver) && views.some((v) => !isGallery(v) && !v.clip && !v.audio)
47
+ const drawable = takes(ver) && views.some((v) => isGallery(v) || (!v.clip && !v.audio))
48
48
  // a draft card's history is no view of its own: its frames cycle in place over the live one
49
49
  const history = item.wip ? views.find(isGallery) : undefined
50
50
  const options = rows || (card.full[item.id] === true)
@@ -59,9 +59,17 @@ export const VersionViews = observer(({ ver }: { ver: Ver }) => {
59
59
  ) : null}
60
60
  {rv.phone.on && drawable ? <button className={rv.phone.draw ? 'primary' : ''} onClick={() => rv.phone.toggleDraw()}>Circle</button> : null}
61
61
  <span className="sp" />
62
- <span className="seg" title="the zoom of every view of every card">
63
- {ZOOMS.map((z) => <button key={z} className={rv.zoom === z ? 'on' : ''} onMouseDown={keepFocus} onClick={() => rv.setZoom(z)}>{ZOOM_LABEL[z]}</button>)}
64
- </span>
62
+ {views.some(isGallery) ? (
63
+ <label className="rv-tilesize" title="the size of every tile of every grid, kept for this repo">
64
+ tiles
65
+ <input type="range" min={TILE_H.min} max={TILE_H.max} step={10} value={rv.tileH} onChange={(e) => rv.setTileH(Number(e.target.value))} />
66
+ </label>
67
+ ) : null}
68
+ {views.some((v) => !isGallery(v)) ? (
69
+ <span className="seg" title="the zoom of every view of every card">
70
+ {ZOOMS.map((z) => <button key={z} className={rv.zoom === z ? 'on' : ''} onMouseDown={keepFocus} onClick={() => rv.setZoom(z)}>{ZOOM_LABEL[z]}</button>)}
71
+ </span>
72
+ ) : null}
65
73
  </div>
66
74
  {rows ? (
67
75
  <div className="rv-opts">{views.map((v, i) => <OptionRow key={i} ver={ver} v={v} i={i} />)}</div>
@@ -93,7 +101,7 @@ const ViewCell = observer(({ ver, v: live, i, frames }: { ver: Ver; v: ReviewVie
93
101
  {takes(ver) ? <ReactionToggles ver={ver} view={i} /> : shown?.status ? <SentReaction status={shown.status} /> : null}
94
102
  <span className="sp" />
95
103
  {open && media?.marks && media.marks.length > 0 ? <button className={rv.marksOn ? 'primary' : ''} onMouseDown={keepFocus} onClick={() => rv.toggleMarks()}>marks · M</button> : null}
96
- {open && media && isPair(media.files) && !media.audio && !rv.phone.on ? <CompareModes c={rv.compare} /> : null}
104
+ {open && media && isPair(media.files) && !media.audio && !rv.phone.on ? <CompareModes c={rv.compare} clip={media.clip !== undefined} /> : null}
97
105
  </header>
98
106
  <ViewNotes ver={ver} i={i} gallery={isGallery(v)} />
99
107
  {open ? (
@@ -119,12 +127,12 @@ const ViewNotes = observer(({ ver, i, gallery, word = true }: { ver: Ver; i: num
119
127
  return (
120
128
  <div className="rv-viewnotes">
121
129
  {said.map((s, k) => {
122
- const tile = s.reaction?.tile
123
- const where = tile !== undefined && isGalleryView(views[i]) ? (views[i] as GalleryView).gallery[tile]?.label ?? `tile ${tile + 1}` : null
130
+ const tile = s.reaction?.tile ?? s.rect?.r.tile
131
+ const where = tileWhere(views[i], tile)
124
132
  return (
125
133
  <div key={k} className={`rv-said${s.reaction?.status ? ` re-${s.reaction.status}` : s.rect ? ' rect' : ''}`}>
126
134
  <span className="rv-saidmark">
127
- {s.rect ? `⬚ ${s.rect.n}${s.rect.r.side ? ` ${SIDE_LABEL[s.rect.r.side]}` : ''}${s.rect.r.t !== undefined ? ` · ${secs(s.rect.r.t)}` : ''}` : `${REACTIONS.find((o) => o.status === s.reaction?.status)?.glyph ?? ''}${s.reaction?.stars ? ` ★${s.reaction.stars}` : ''}${where ? ` ${where}` : ''}`}
135
+ {s.rect ? `⬚ ${s.rect.n}${s.rect.r.side ? ` ${SIDE_LABEL[s.rect.r.side]}` : ''}${s.rect.r.t !== undefined ? ` · ${secs(s.rect.r.t)}` : ''}${where ? ` ${where}` : ''}` : `${REACTIONS.find((o) => o.status === s.reaction?.status)?.glyph ?? ''}${s.reaction?.stars ? ` ★${s.reaction.stars}` : ''}${where ? ` ${where}` : ''}`}
128
136
  </span>
129
137
  <span className="rv-saidtext">{(s.rect ? s.rect.r.comment : s.reaction?.comment) || <i className="rv-dim">{s.reaction?.status ? REACTIONS.find((o) => o.status === s.reaction?.status)?.tip : 'no word'}</i>}</span>
130
138
  <span className="rv-saidwho rv-dim">you · {STATUS_LABEL[s.verdict.verdict]} · v{cell.n}</span>
@@ -140,7 +148,7 @@ const ViewNotes = observer(({ ver, i, gallery, word = true }: { ver: Ver; i: num
140
148
  {draft.map(([r, k]) => (
141
149
  <div key={`d${k}`} className={`rv-outrow${card.rect === k ? ' on' : ''}`}>
142
150
  <button className={`rv-outbadge rect${card.rect === k ? ' on' : ''}`} title={r.t !== undefined ? 'go to this moment and open the note' : 'open the note on the image'} onMouseDown={keepFocus} onClick={() => card.pickRect(k, true)}>
143
- {k + 1}{r.side ? ` ${SIDE_LABEL[r.side]}` : ''}{r.t !== undefined ? ` · ${secs(r.t)}` : ''}
151
+ {k + 1}{r.side ? ` ${SIDE_LABEL[r.side]}` : ''}{r.t !== undefined ? ` · ${secs(r.t)}` : ''}{r.tile !== undefined ? ` ${tileWhere(views[i], r.tile) ?? ''}` : ''}
144
152
  </button>
145
153
  <button className="rv-outtext ghost" title="open the note on the image" onMouseDown={keepFocus} onClick={() => card.pickRect(k, true)}>
146
154
  {r.comment.trim() ? r.comment : <i className="rv-dim">no word yet</i>}
@@ -158,6 +166,10 @@ const ViewNotes = observer(({ ver, i, gallery, word = true }: { ver: Ver; i: num
158
166
 
159
167
  const isGalleryView = (v: ReviewView | undefined): v is GalleryView => v !== undefined && isGallery(v)
160
168
 
169
+ /** the name of a gallery tile a note is on, or null off a gallery */
170
+ const tileWhere = (v: ReviewView | undefined, tile: number | undefined): string | null =>
171
+ tile !== undefined && isGalleryView(v) ? (v.gallery[tile] ? tileName(v.gallery[tile]) : `tile ${tile + 1}`) : null
172
+
161
173
  /** a reaction an older answer gave, as a still pill */
162
174
  const SentReaction = ({ status }: { status: string }) => {
163
175
  const o = REACTIONS.find((r) => r.status === status)
@@ -258,14 +270,14 @@ const Gone = ({ files }: { files: readonly string[] }) => (
258
270
  const clock = (t: number): string => `${Math.floor(t / 60)}:${String(Math.floor(t % 60)).padStart(2, '0')}`
259
271
 
260
272
  /** an option's score: STARS stars, a click on the one given clears it; an older version's stars as he gave them */
261
- const Stars = observer(({ ver, view, given }: { ver: Ver; view: number; given: number | undefined }) => {
273
+ const Stars = observer(({ ver, view, tile, given }: { ver: Ver; view: number; tile?: number; given: number | undefined }) => {
262
274
  const { card } = ver
263
275
  const live = takes(ver)
264
276
  const n = given ?? 0
265
277
  return (
266
- <span className="rv-stars" title={live ? `your score (⇧1 to ⇧${STARS} on the row playing)` : 'your score'}>
278
+ <span className="rv-stars" title={live ? (tile === undefined ? `your score (⇧1 to ⇧${STARS} on the row playing)` : `your score (1 to ${STARS} with the pointer on the tile)`) : 'your score'}>
267
279
  {Array.from({ length: STARS }, (_, k) => (
268
- <button key={k} className={k < n ? 'on' : ''} disabled={!live} aria-label={`${k + 1} of ${STARS}`} onMouseDown={keepFocus} onClick={() => mark(ver, () => card.setStars(view, k + 1))}>{k < n ? '★' : '☆'}</button>
280
+ <button key={k} className={k < n ? 'on' : ''} disabled={!live} aria-label={`${k + 1} of ${STARS}`} onMouseDown={keepFocus} onClick={() => mark(ver, () => card.setStars(view, k + 1, tile))}>{k < n ? '★' : '☆'}</button>
269
281
  ))}
270
282
  </span>
271
283
  )
@@ -346,37 +358,95 @@ const ReactionToggles = observer(({ ver, view, tile, small }: { ver: Ver; view:
346
358
  )
347
359
  })
348
360
 
349
- /** a gallery tile's image height */
350
- const TILE_H = 170
351
-
352
- /** a gallery view: its images as a wrapping grid of small tiles at the list's size, each with its label and its
353
- * reaction; a click shows it large at the column's size */
361
+ /** a gallery view: its tiles at the size he sets (kept per repo), as one wrapping grid, or one row per asset when its
362
+ * tiles are variants (a group each); a head filters the tiles, flips every tile to its before, adds the small sizes */
354
363
  const Gallery = observer(({ ver, v, view }: { ver: Ver; v: GalleryView; view: number }) => {
364
+ const { rv, card } = ver
365
+ const befores = v.gallery.some((t) => t.before)
366
+ const tiles = v.gallery.map((t, k) => ({ t, k }))
367
+ const rows = v.gallery.some((t) => t.group) ? [...new Set(v.gallery.map((t) => t.group ?? ''))].map((g) => ({ g, tiles: tiles.filter((x) => (x.t.group ?? '') === g) })) : null
368
+ const grid = (xs: typeof tiles): ReactNode => <div className="rv-gallery">{xs.map(({ t, k }) => <Tile key={k} ver={ver} v={v} view={view} t={t} k={k} />)}</div>
369
+ return (
370
+ <div className="rv-gallerywrap">
371
+ <div className="rv-galleryhead rv-small">
372
+ <span className="seg" role="group" aria-label="which tiles show">
373
+ {TILE_FILTERS.map((f) => (
374
+ <button key={f} className={card.tileFilter === f ? 'on' : ''} onMouseDown={keepFocus} onClick={() => card.setTileFilter(f)}>{TILE_FILTER_LABEL[f]}</button>
375
+ ))}
376
+ </span>
377
+ {befores ? <button className={`rv-chip${card.beforeAll ? ' on' : ''}`} title="every tile shows its before" onMouseDown={keepFocus} onClick={() => card.toggleBeforeAll()}>before</button> : null}
378
+ <button className={`rv-chip${rv.tileSmall ? ' on' : ''}`} title="each tile also at 16, 32 and 64 px" onMouseDown={keepFocus} onClick={() => rv.toggleTileSmall()}>real size</button>
379
+ </div>
380
+ {rows
381
+ ? rows.map(({ g, tiles: xs }) => (
382
+ <div key={g} className="rv-galleryrow">
383
+ <div className="rv-rowlabel">{g || 'others'}</div>
384
+ {grid(xs)}
385
+ </div>
386
+ ))
387
+ : grid(tiles)}
388
+ </div>
389
+ )
390
+ })
391
+
392
+ const TILE_FILTER_LABEL: Record<TileFilter, string> = { all: 'all', unrated: 'unrated', low: 'under 3★', fix: 'fix or no' }
393
+
394
+ /** a tile's frame around its image (padding and border, both sides), its narrowest width for its controls, and the
395
+ * widest image it shows, as a share of its height */
396
+ const TILE_CHROME = 12
397
+ const TILE_MIN_W = 150
398
+ const TILE_WIDE = 1.6
399
+
400
+ /** the small sizes an icon lives at */
401
+ const SMALL_SIZES = [16, 32, 64] as const
402
+
403
+ /** one gallery tile: its image (its before while flipped or peeked), the small sizes, its label, stars, the variant
404
+ * pick on a row, OK fix or no and a word; a click shows it large at the column's size */
405
+ const Tile = observer(({ ver, v, view, t, k }: { ver: Ver; v: GalleryView; view: number; t: GalleryTile; k: number }) => {
355
406
  const { rv, card, cell } = ver
356
407
  const id = itemOf(ver).id
408
+ const big = card.bigTile === `${viewKey(id, view)}/${k}`
409
+ const r = card.reactionShown(cell, view, k)
410
+ if (!big && !card.tileShown(r)) return null
411
+ const live = takes(ver)
412
+ const h = rv.tileH
413
+ const ratio = t.size.w / t.size.h
414
+ // the image box takes the image's own ratio, so a rectangle's coordinates are the image's; a very wide one is narrowed
415
+ const iw = Math.round(Math.min(h * ratio, h * TILE_WIDE))
416
+ const ih = Math.round(iw / ratio)
417
+ const file = t.before && card.showsBefore(view, k) ? t.before : t.file
418
+ const thumb = rv.thumbUrl(id, file)
419
+ const src = big || h > TILE_H.thumb ? rv.fitUrl(id, file) : thumb
420
+ const toggle = (): void => card.toggleTile(id, view, k)
357
421
  return (
358
- <div className="rv-gallery">
359
- {v.gallery.map((t, k) => {
360
- const big = card.bigTile === `${viewKey(id, view)}/${k}`
361
- const r = card.reactionShown(cell, view, k)
362
- const ratio = t.size.w / t.size.h
363
- const w = big ? undefined : Math.round(Math.max(110, Math.min(260, TILE_H * ratio)))
364
- return (
365
- <div key={k} className={`rv-tile${big ? ' big' : ''}${toneClass(r?.status)}`} style={big ? undefined : { width: w }}>
366
- <div className="rv-tileimg" onClick={() => card.toggleTile(id, view, k)} title={big ? 'click to shrink' : 'click to enlarge'}
367
- style={big ? { width: `min(100%, calc((100vh - ${FIT_ROOM}px) * ${ratio}))`, aspectRatio: `${t.size.w} / ${t.size.h}` } : { height: TILE_H }}>
368
- <img src={big ? rv.fitUrl(id, t.file) : rv.thumbUrl(id, t.file)} alt={t.label} draggable={false} loading="lazy" />
369
- </div>
370
- <div className="rv-tilelabel" title={t.label}>{t.label}</div>
371
- {takes(ver) ? (
372
- <>
373
- <ReactionToggles ver={ver} view={view} tile={k} small />
374
- <AutoText className="rv-word" placeholder="a word" value={r?.comment ?? ''} onKeyDown={blurOnEscape} onText={(t) => mark(ver, () => card.setReactionComment(view, k, t))} />
375
- </>
376
- ) : r?.status ? <SentReaction status={r.status} /> : null}
377
- </div>
378
- )
379
- })}
422
+ <div className={`rv-tile${big ? ' big' : ''}${r?.picked ? ' picked' : ''}${toneClass(r?.status)}`} style={big ? undefined : { width: Math.max(iw, TILE_MIN_W) + TILE_CHROME }}
423
+ onMouseEnter={live ? () => card.setHoverTile({ view, tile: k }) : undefined} onMouseLeave={live ? () => card.setHoverTile(null) : undefined}>
424
+ <div className="rv-tileimg" onClick={live ? undefined : toggle} title={live ? 'drag to circle a spot, click to enlarge' : big ? 'click to shrink' : 'click to enlarge'}
425
+ style={big ? { width: `min(100%, calc((100vh - ${FIT_ROOM}px) * ${ratio}))`, aspectRatio: `${t.size.w} / ${t.size.h}` } : { width: iw, height: ih }}>
426
+ <Marks ver={ver} src={src} side={undefined} view={view} tile={k} onTap={toggle} />
427
+ {ver.live ? <div className="rv-over"><RectNote ver={ver} view={view} sides={[undefined]} tile={k} /></div> : null}
428
+ {t.before ? (
429
+ <span className={`rv-beforechip${file === t.before ? ' on' : ''}`} title="the pointer here shows the before" onClick={(e) => e.stopPropagation()}
430
+ onMouseEnter={() => card.setPeekTile(view, k)} onMouseLeave={() => card.setPeekTile(view, null)}>before</span>
431
+ ) : null}
432
+ </div>
433
+ {rv.tileSmall ? (
434
+ <div className="rv-tilesmall">
435
+ {SMALL_SIZES.map((px) => <img key={px} src={thumb} alt="" width={px} height={px} title={`${px} px`} draggable={false} loading="lazy" />)}
436
+ </div>
437
+ ) : null}
438
+ <div className="rv-tilelabel" title={t.label}>{t.label}</div>
439
+ {live || r?.stars ? <Stars ver={ver} view={view} tile={k} given={r?.stars} /> : null}
440
+ {t.group && (live || r?.picked) ? (
441
+ <button className={`rv-chip rv-keep${r?.picked ? ' on' : ''}`} disabled={!live} title={`keep this one for ${t.group}: one a row`} onMouseDown={keepFocus}
442
+ onClick={() => mark(ver, () => card.pickTile(view, k, t.group ?? '', v.gallery))}>{r?.picked ? '✓ kept' : 'keep'}</button>
443
+ ) : null}
444
+ {live ? (
445
+ <>
446
+ <ReactionToggles ver={ver} view={view} tile={k} small />
447
+ <AutoText className="rv-word" placeholder="a word" value={r?.comment ?? ''} onKeyDown={blurOnEscape} onText={(t) => mark(ver, () => card.setReactionComment(view, k, t))} />
448
+ </>
449
+ ) : r?.status ? <SentReaction status={r.status} /> : null}
380
450
  </div>
381
451
  )
382
452
  })
@@ -420,20 +490,21 @@ const MediaBody = observer(({ ver, v, i, zoom }: { ver: Ver; v: MediaView; i: nu
420
490
  </>
421
491
  )
422
492
  const c = rv.compare
423
- const cols = c.mode === 'side' ? 2 : 1
493
+ const mode = c.modeFor(v.clip !== undefined)
494
+ const cols = mode === 'side' ? 2 : 1
424
495
  const fitW = `min(100%, calc((100vh - ${room}px) * ${ratio * cols}))`
425
496
  return (
426
497
  <>
427
498
  <div style={scroll}>
428
499
  <div className="rv-pairgrid" style={{ width: scale ? `${v.size.w * scale * cols + 8 * (cols - 1)}px` : fitW, gridTemplateColumns: `repeat(${cols}, 1fr)` }}>
429
- <Compare c={c} base={before} mod={after} names={PAIR_NAMES} aspect={aspect}
430
- draw={(s, face) => <Marks ver={ver} src={s} side={drawnSide(c.mode, s === before ? 'before' : 'after')} view={i} face={face} />}
431
- over={(srcs) => (ver.live ? <RectNote ver={ver} view={i} sides={srcs.map((s) => drawnSide(c.mode, s === before ? 'before' : 'after'))} /> : null)} />
500
+ <Compare c={c} mode={mode} base={before} mod={after} names={PAIR_NAMES} aspect={aspect}
501
+ draw={(s, face) => <Marks ver={ver} src={s} side={drawnSide(mode, s === before ? 'before' : 'after')} view={i} face={face} />}
502
+ over={(srcs) => (ver.live ? <RectNote ver={ver} view={i} sides={srcs.map((s) => drawnSide(mode, s === before ? 'before' : 'after'))} /> : null)} />
432
503
  </div>
433
504
  </div>
434
505
  {bar ? <div style={{ width: fitW, margin: '0 auto' }}>{bar}</div> : null}
435
506
  <div style={{ width: fitW, margin: '0 auto' }}>{saves}</div>
436
- {c.mode === 'swipe' ? <div className="rv-dim rv-center">curtain: a drag moves the line; rectangles are drawn in the other modes</div> : null}
507
+ {mode === 'swipe' ? <div className="rv-dim rv-center">curtain: a drag moves the line; rectangles are drawn in the other modes</div> : null}
437
508
  </>
438
509
  )
439
510
  })
@@ -469,6 +540,15 @@ const Downloads = observer(({ rv, item, files }: { rv: ReviewSt; item: Item; fil
469
540
  {files.map(({ file, label }) => (
470
541
  <a key={file} className="rv-dl" href={rv.fileUrl(item.id, file, item.wip)} download={`${item.id}-${file}`} title={`download ${file} at full size`}>⤓ save {label ?? (file.split('.').pop() ?? 'file')}</a>
471
542
  ))}
543
+ {files.map(({ file, label }) => {
544
+ const s = rv.shared.get(`${item.id}/${file}`)
545
+ return (
546
+ <button key={`share-${file}`} className="rv-dl ghost" disabled={s === 'sending'} onClick={() => void rv.share(item.id, file)}
547
+ title={s && s !== 'sending' ? `copy again: ${s}` : `publish ${file} in the Space and copy its link: a permanent public url, anyone who has it downloads the file`}>
548
+ {s === 'sending' ? 'uploading…' : `🔗 ${label ? `link ${label}` : 'copy link'}`}
549
+ </button>
550
+ )
551
+ })}
472
552
  {/* the Finder is on the desktop only: a phone has none */}
473
553
  {rv.phone.on || files[0] === undefined ? null : (
474
554
  <button className="rv-dl ghost" title={`open the card's folder in the Finder, ${files[0].file} selected`} onClick={() => void rv.reveal(item.id, files[0]!.file)}>show in Finder</button>
@@ -532,12 +612,12 @@ const MODES: { mode: CompareMode; glyph: string; tip: string }[] = [
532
612
  ]
533
613
 
534
614
  /** the compare modes as tiny buttons, the onion's opacity floating under them */
535
- const CompareModes = observer(({ c }: { c: CompareSt }) => (
615
+ const CompareModes = observer(({ c, clip }: { c: CompareSt; clip: boolean }) => (
536
616
  <span className="rv-modes">
537
617
  <span className="seg">
538
- {COMPARE_MODES.map((m) => {
618
+ {COMPARE_MODES.filter((m) => !(clip && m === 'diff')).map((m) => {
539
619
  const o = MODES.find((x) => x.mode === m)!
540
- return <button key={m} title={`${o.tip} (D cycles, ⇧D back)`} className={c.mode === m ? 'on' : ''} onMouseDown={keepFocus} onClick={() => c.setMode(m)}>{o.glyph}</button>
620
+ return <button key={m} title={`${o.tip} (D cycles, ⇧D back)`} className={c.modeFor(clip) === m ? 'on' : ''} onMouseDown={keepFocus} onClick={() => c.setMode(m)}>{o.glyph}</button>
541
621
  })}
542
622
  </span>
543
623
  {c.mode === 'onion' ? (
@@ -618,25 +698,25 @@ function track(move: (e: PointerEvent) => void): void {
618
698
  /** THE pair: side by side, the curtain clipping both images, the after over the before as an onion skin, or the
619
699
  * after alone (the before while the pointer is over it). One image alone when `mod` is undefined. `over` draws what
620
700
  * sits over a frame unclipped (the picked rectangle's note box), given the images that frame shows */
621
- const Compare = observer(({ c, base, mod, names, aspect, draw, over }: { c: CompareSt; base: string; mod: string | undefined; names?: { base: string; mod: string }; aspect: string; draw: (src: string, face?: ReactNode) => ReactNode; over?: (srcs: string[]) => ReactNode }) => {
701
+ const Compare = observer(({ c, mode = c.mode, base, mod, names, aspect, draw, over }: { c: CompareSt; mode?: CompareMode; base: string; mod: string | undefined; names?: { base: string; mod: string }; aspect: string; draw: (src: string, face?: ReactNode) => ReactNode; over?: (srcs: string[]) => ReactNode }) => {
622
702
  const [peek, setPeek] = useState(false)
623
703
  const [share, setShare] = useState<number | null | undefined>(undefined)
624
704
  if (mod === undefined) return <Frame aspect={aspect} caption={null} over={over?.([base])}><div className="rv-fill">{draw(base)}</div></Frame>
625
705
  const n = names ?? PAIR_NAMES
626
- if (c.mode === 'side')
706
+ if (mode === 'side')
627
707
  return (
628
708
  <>
629
709
  <Frame aspect={aspect} caption={n.base} over={over?.([base])}><div className="rv-fill">{draw(base)}</div></Frame>
630
710
  <Frame aspect={aspect} caption={n.mod} modCap over={over?.([mod])}><div className="rv-fill">{draw(mod)}</div></Frame>
631
711
  </>
632
712
  )
633
- if (c.mode === 'diff')
713
+ if (mode === 'diff')
634
714
  return (
635
715
  <Frame aspect={aspect} caption={<>changes <span className="rv-modcap">{changesWords(share)}</span></>} over={over?.([mod])}>
636
716
  <div className="rv-fill">{draw(mod, <DiffCanvas base={base} mod={mod} say={setShare} />)}</div>
637
717
  </Frame>
638
718
  )
639
- if (c.mode === 'mod')
719
+ if (mode === 'mod')
640
720
  return (
641
721
  <Frame aspect={aspect} caption={peek ? n.base : n.mod} modCap={!peek} onPeek={setPeek} over={over?.([peek ? base : mod])}>
642
722
  <div className="rv-fill">{draw(peek ? base : mod)}</div>
@@ -644,10 +724,10 @@ const Compare = observer(({ c, base, mod, names, aspect, draw, over }: { c: Comp
644
724
  )
645
725
  const pct = Math.round(c.split * 100)
646
726
  return (
647
- <Frame aspect={aspect} caption={<>{n.base} {c.mode === 'swipe' ? '◀ ▶' : '+'} <span className="rv-modcap">{n.mod}</span></>} swipe={c.mode === 'swipe' ? c : undefined} over={over?.([base, mod])}>
648
- <div className="rv-fill" style={c.mode === 'swipe' ? { clipPath: `inset(0 ${100 - pct}% 0 0)` } : undefined}>{draw(base)}</div>
649
- <div className="rv-fill" style={c.mode === 'swipe' ? { clipPath: `inset(0 0 0 ${pct}%)` } : { opacity: c.opacity }}>{draw(mod)}</div>
650
- {c.mode === 'swipe' ? <div className="rv-curtain" style={{ left: `${pct}%` }} /> : null}
727
+ <Frame aspect={aspect} caption={<>{n.base} {mode === 'swipe' ? '◀ ▶' : '+'} <span className="rv-modcap">{n.mod}</span></>} swipe={mode === 'swipe' ? c : undefined} over={over?.([base, mod])}>
728
+ <div className="rv-fill" style={mode === 'swipe' ? { clipPath: `inset(0 ${100 - pct}% 0 0)` } : undefined}>{draw(base)}</div>
729
+ <div className="rv-fill" style={mode === 'swipe' ? { clipPath: `inset(0 0 0 ${pct}%)` } : { opacity: c.opacity }}>{draw(mod)}</div>
730
+ {mode === 'swipe' ? <div className="rv-curtain" style={{ left: `${pct}%` }} /> : null}
651
731
  </Frame>
652
732
  )
653
733
  })
@@ -693,7 +773,7 @@ const MIN_DRAG = 0.01
693
773
  * that version that is not the active one loops on its own: a click makes it active. On a claiming version (the newest,
694
774
  * his answer on an older one) a drag draws at once and brings his answer here. `face` takes the image's place (the
695
775
  * changes of a pair) */
696
- const Marks = observer(({ ver, src, side, view, face }: { ver: Ver; src: string; side: Side | undefined; view: number; face?: ReactNode }) => {
776
+ const Marks = observer(({ ver, src, side, view, face, tile, onTap }: { ver: Ver; src: string; side: Side | undefined; view: number; face?: ReactNode; tile?: number; onTap?: () => void }) => {
697
777
  const { rv, card, cell } = ver
698
778
  const el = useRef<HTMLDivElement>(null)
699
779
  const [drag, setDrag] = useState<{ x0: number; y0: number; x1: number; y1: number } | null>(null)
@@ -736,15 +816,16 @@ const Marks = observer(({ ver, src, side, view, face }: { ver: Ver; src: string;
736
816
  window.removeEventListener('pointercancel', up)
737
817
  setDrag(null)
738
818
  const r = box(cur)
739
- if (r.w > MIN_DRAG && r.h > MIN_DRAG) card.addRect(r, side, view)
819
+ if (r.w > MIN_DRAG && r.h > MIN_DRAG) card.addRect(r, side, view, tile)
820
+ else if (onTap) onTap()
740
821
  else card.pickRect(null)
741
822
  }
742
823
  window.addEventListener('pointermove', move)
743
824
  window.addEventListener('pointerup', up)
744
825
  window.addEventListener('pointercancel', up)
745
826
  }
746
- const rects = ver.live ? card.draft.rects.map((r, i) => [r, i] as const).filter(([r]) => r.side === side && (r.view ?? 0) === view) : []
747
- const sent = card.sentRects(cell.id, view, side)
827
+ const rects = ver.live ? card.draft.rects.map((r, i) => [r, i] as const).filter(([r]) => r.side === side && (r.view ?? 0) === view && r.tile === tile) : []
828
+ const sent = card.sentRects(cell.id, view, side, tile)
748
829
  const onIts = (r: Rect): boolean => !clip || !c || r.t === undefined || (c.paused && onFrame(r.t, c.time, clip.fps))
749
830
  const rings = rv.marksOn ? (shown?.marks ?? []).filter((m) => m.side === side) : []
750
831
  const live = drawing || (clip !== undefined && ver.live && !active)
@@ -791,12 +872,12 @@ const firstWords = (s: string): string => {
791
872
  * or clicked. Enter or Escape closes it (the rectangle stays), Shift Enter is a new line; `sides` are the sides the
792
873
  * frame shows. Its tag names the side it marks (before or after), and a second row repeats the view's OK, Fix and No
793
874
  * under the hand that drew it (ReactionToggles, the head's own) */
794
- const RectNote = observer(({ ver, view, sides }: { ver: Ver; view: number; sides: readonly (Side | undefined)[] }) => {
875
+ const RectNote = observer(({ ver, view, sides, tile }: { ver: Ver; view: number; sides: readonly (Side | undefined)[]; tile?: number }) => {
795
876
  const { card } = ver
796
877
  const box = useRef<HTMLTextAreaElement | null>(null)
797
878
  const i = card.rect
798
879
  const r = i === null ? undefined : card.draft.rects[i]
799
- const here = i !== null && r !== undefined && (r.view ?? 0) === view && sides.includes(r.side)
880
+ const here = i !== null && r !== undefined && (r.view ?? 0) === view && sides.includes(r.side) && r.tile === tile
800
881
  const focus = here && card.noteFocus === i
801
882
  useEffect(() => {
802
883
  if (!focus || box.current === null) return
@@ -39,6 +39,10 @@ const isDirty = (d: Draft | undefined): boolean => d !== undefined && (d.rects.l
39
39
  /** a framed cell: every kind but the thin event line */
40
40
  export type Framed = VersionCell | VerdictCell | ReplyCell | NoteCell
41
41
 
42
+ /** the gallery filter: every tile, the ones not scored nor marked, under 3 stars, marked fix or no */
43
+ export const TILE_FILTERS = ['all', 'unrated', 'low', 'fix'] as const
44
+ export type TileFilter = (typeof TILE_FILTERS)[number]
45
+
42
46
  /** one line of the thread as drawn: a day's divider, a run of state changes, or a framed cell */
43
47
  export type Line = { kind: 'day'; day: string } | { kind: 'events'; cells: EventCell[] } | { kind: 'cell'; cell: Framed }
44
48
 
@@ -116,6 +120,14 @@ export class ThreadSt {
116
120
  noteFocus: number | null = null
117
121
  /** the gallery tile shown large, `<item>#<view>/<tile>` */
118
122
  bigTile: string | null = null
123
+ /** the gallery tile under the pointer of the newest version: 1 to 5 score it */
124
+ hoverTile: { view: number; tile: number } | null = null
125
+ /** which gallery tiles show: all, the ones he has not scored nor marked, under 3 stars, the ones marked fix or no */
126
+ tileFilter: TileFilter = 'all'
127
+ /** every tile of the card shows its before; a tile's « before » chip peeks at one alone */
128
+ beforeAll = false
129
+ /** the tile whose before shows while the pointer is on its chip, `<view>/<tile>` */
130
+ peekTile: string | null = null
119
131
  /** a draft card's past frame shown in place of its live one; null is now */
120
132
  frame: number | null = null
121
133
  /** a card of options shown full, by item id */
@@ -394,12 +406,14 @@ export class ThreadSt {
394
406
  if (h?.kind !== 'version' || h.item.wip) return []
395
407
  const sent = this.verdictsOn(h.id).findLast((v) => v.current)
396
408
  const choice = isChoice(h.item)
397
- return h.item.views.map((_, i) => {
409
+ return h.item.views.map((v, i) => {
398
410
  const own = this.reactionOf(i)
399
411
  const given = sent?.reactions.find((r) => r.view === i && r.tile === undefined)
400
412
  const r = own ?? given
401
413
  const picked = this.pickShown(h) === i
402
- const answer: ViewMark['answer'] = picked ? 'picked' : r?.status ? r.status : choice && r?.stars ? 'scored' : sent ? 'sent' : 'none'
414
+ // a gallery is answered tile by tile: one tile scored or marked answers the view
415
+ const tiles = isGallery(v) && [...(this.draft.reactions ?? []), ...(sent?.reactions ?? [])].some((q) => q.view === i && q.tile !== undefined && (q.status || q.stars || q.picked))
416
+ const answer: ViewMark['answer'] = picked ? 'picked' : r?.status ? r.status : (choice && r?.stars) || tiles ? 'scored' : sent ? 'sent' : 'none'
403
417
  const noted = this.draft.rects.some((q) => (q.view ?? 0) === i) || (own?.comment ?? '').trim() !== ''
404
418
  return { view: i, tag: viewTag(h.n, i), answer, noted }
405
419
  })
@@ -428,8 +442,8 @@ export class ThreadSt {
428
442
  }
429
443
 
430
444
  /** the sent rectangles drawn over a view of a version, with their number in their verdict */
431
- sentRects(id: string, view: number, side: Side | undefined): { r: Rect; n: number }[] {
432
- return this.verdictsOn(id).flatMap((v) => v.rects.flatMap((r, k) => ((r.view ?? 0) === view && r.side === side ? [{ r, n: k + 1 }] : [])))
445
+ sentRects(id: string, view: number, side: Side | undefined, tile?: number): { r: Rect; n: number }[] {
446
+ return this.verdictsOn(id).flatMap((v) => v.rects.flatMap((r, k) => ((r.view ?? 0) === view && r.side === side && r.tile === tile ? [{ r, n: k + 1 }] : [])))
433
447
  }
434
448
 
435
449
  /** the reaction a view shows: his draft's on the newest version, else the latest verdict's */
@@ -513,12 +527,12 @@ export class ThreadSt {
513
527
  }
514
528
 
515
529
  /** a rectangle on a view of the newest version, which becomes the active one; on a clip it keeps the frame's time */
516
- addRect(r: { x: number; y: number; w: number; h: number }, side: Side | undefined, on: number): void {
530
+ addRect(r: { x: number; y: number; w: number; h: number }, side: Side | undefined, on: number, tile?: number): void {
517
531
  if (on !== this.view) this.setView(on)
518
532
  const view = on > 0 ? { view: on } : {}
519
- const clip = this.clipKey ? this.clipOf(this.target ?? '', on) : null
533
+ const clip = tile === undefined && this.clipKey ? this.clipOf(this.target ?? '', on) : null
520
534
  const t = clip ? { t: Math.round(clip.time * 1000) / 1000 } : {}
521
- this.edit((d) => ({ ...d, rects: [...d.rects, { ...r, comment: '', ...view, ...(side ? { side } : {}), ...t }] }))
535
+ this.edit((d) => ({ ...d, rects: [...d.rects, { ...r, comment: '', ...view, ...(side ? { side } : {}), ...t, ...(tile !== undefined ? { tile } : {}) }] }))
522
536
  this.rect = this.draft.rects.length - 1
523
537
  this.noteFocus = this.rect
524
538
  }
@@ -563,19 +577,19 @@ export class ThreadSt {
563
577
  this.putReaction(view, tile, { ...this.reactionOf(view, tile), comment })
564
578
  }
565
579
 
566
- /** an option's stars; the same number again clears them */
567
- setStars(view: number, n: number): void {
568
- const cur = this.reactionOf(view)
569
- this.putReaction(view, undefined, { ...cur, comment: cur?.comment ?? '', stars: cur?.stars === n ? undefined : n })
580
+ /** an option's or a gallery tile's stars; the same number again clears them */
581
+ setStars(view: number, n: number, tile?: number): void {
582
+ const cur = this.reactionOf(view, tile)
583
+ this.putReaction(view, tile, { ...cur, comment: cur?.comment ?? '', stars: cur?.stars === n ? undefined : n })
570
584
  }
571
585
 
572
586
  removeReaction(view: number, tile: number | undefined): void {
573
587
  this.putReaction(view, tile, { comment: '' })
574
588
  }
575
589
 
576
- private putReaction(view: number, tile: number | undefined, r: { status?: ReviewStatus | undefined; comment: string; stars?: number | undefined }): void {
577
- const next: ReviewReaction = { view, ...(tile !== undefined ? { tile } : {}), ...(r.status ? { status: r.status } : {}), comment: r.comment, ...(r.stars ? { stars: r.stars } : {}) }
578
- const empty = !r.status && r.comment === '' && !r.stars
590
+ private putReaction(view: number, tile: number | undefined, r: { status?: ReviewStatus | undefined; comment: string; stars?: number | undefined; picked?: true | undefined }): void {
591
+ const next: ReviewReaction = { view, ...(tile !== undefined ? { tile } : {}), ...(r.status ? { status: r.status } : {}), comment: r.comment, ...(r.stars ? { stars: r.stars } : {}), ...(r.picked ? { picked: true as const } : {}) }
592
+ const empty = !r.status && r.comment === '' && !r.stars && !r.picked
579
593
  this.edit((d) => {
580
594
  const rest = (d.reactions ?? []).filter((q) => !sameSpot(q, view, tile))
581
595
  return { ...d, reactions: empty ? rest : [...rest, next] }
@@ -606,6 +620,50 @@ export class ThreadSt {
606
620
  this.frame = f
607
621
  }
608
622
 
623
+ setHoverTile(t: { view: number; tile: number } | null): void {
624
+ this.hoverTile = t
625
+ }
626
+
627
+ setTileFilter(f: TileFilter): void {
628
+ this.tileFilter = f
629
+ }
630
+
631
+ toggleBeforeAll(): void {
632
+ this.beforeAll = !this.beforeAll
633
+ }
634
+
635
+ setPeekTile(view: number, tile: number | null): void {
636
+ this.peekTile = tile === null ? null : `${view}/${tile}`
637
+ }
638
+
639
+ /** a tile shows its before: all of them flipped, or this one peeked */
640
+ showsBefore(view: number, tile: number): boolean {
641
+ return this.beforeAll || this.peekTile === `${view}/${tile}`
642
+ }
643
+
644
+ /** whether a tile passes the filter, by the reaction it shows */
645
+ tileShown(r: ReviewReaction | null): boolean {
646
+ const f = this.tileFilter
647
+ if (f === 'all') return true
648
+ if (f === 'unrated') return !r?.stars && !r?.status && !r?.picked
649
+ if (f === 'low') return r?.stars !== undefined && r.stars < 3
650
+ return r?.status === 'approved-with-fix' || r?.status === 'rejected'
651
+ }
652
+
653
+ /** a variant kept for its row: the row's other pick clears; the same tile again clears it */
654
+ pickTile(view: number, tile: number, group: string, tiles: readonly { group?: string }[]): void {
655
+ const was = this.reactionOf(view, tile)?.picked === true
656
+ tiles.forEach((t, k) => {
657
+ if (t.group !== group) return
658
+ const cur = this.reactionOf(view, k)
659
+ if (cur?.picked) this.putReaction(view, k, { ...cur, picked: undefined })
660
+ })
661
+ if (!was) {
662
+ const cur = this.reactionOf(view, tile)
663
+ this.putReaction(view, tile, { ...cur, comment: cur?.comment ?? '', picked: true })
664
+ }
665
+ }
666
+
609
667
  toggleTile(id: string, view: number, tile: number): void {
610
668
  const k = `${viewKey(id, view)}/${tile}`
611
669
  this.bigTile = this.bigTile === k ? null : k
@@ -787,7 +845,7 @@ export class ThreadSt {
787
845
  }
788
846
 
789
847
  /** the keys a card takes (ReviewSt.key routes them): 1 to 9 play an option row of the newest version, ⇧1 to ⇧5
790
- * score the row playing, P picks it; on a clip Space plays, ← → a frame (a sound: two seconds) */
848
+ * score the row playing, P picks it; 1 to 5 score the gallery tile under the pointer; on a clip Space plays, ← → a frame (a sound: two seconds) */
791
849
  key(e: Pick<KeyboardEvent, 'key' | 'shiftKey'> & { code?: string }): boolean {
792
850
  const h = this.head
793
851
  if (h?.kind !== 'version') return false
@@ -796,7 +854,9 @@ export class ThreadSt {
796
854
  const digit = Number(/^Digit([1-9])$/.exec(e.code ?? '')?.[1] ?? (/^[1-9]$/.test(e.key) ? e.key : 0))
797
855
  const clip = this.clip
798
856
  const sound = this.openView?.audio !== undefined
799
- if (rows && digit > 0 && !e.shiftKey) {
857
+ const tile = this.hoverTile
858
+ if (tile && !rows && digit > 0 && digit <= STARS && !e.shiftKey) this.setStars(tile.view, digit, tile.tile)
859
+ else if (rows && digit > 0 && !e.shiftKey) {
800
860
  if (digit <= h.item.views.length) this.listen(h.id, digit - 1)
801
861
  } else if (choice && rows && digit > 0 && e.shiftKey) {
802
862
  if (digit <= STARS) this.setStars(this.view, digit)
@@ -279,9 +279,24 @@ span.rv-react{display:inline-block;border:1px solid;border-radius:4px}
279
279
  .rv-noten.before{background:var(--warn)}
280
280
  /* the view's OK, Fix and No again, on their own row under the words */
281
281
  .rv-notereacts{flex:1 1 100%;display:flex;justify-content:flex-end}
282
- .rv-downloads{display:flex;gap:var(--s2);justify-content:flex-end;margin-top:var(--s1)}
283
- .rv-dl{font-size:11.5px;text-decoration:none}
282
+ .rv-downloads{display:flex;flex-wrap:wrap;align-items:center;gap:var(--s2);justify-content:flex-end;margin-top:var(--s1)}
283
+ .rv-dl{font-size:11.5px;text-decoration:none;white-space:nowrap}
284
284
  .rv-gallery{display:flex;flex-wrap:wrap;gap:var(--s2);align-items:flex-start}
285
+ .rv-gallerywrap{display:flex;flex-direction:column;gap:var(--s1)}
286
+ .rv-tilesize{display:flex;align-items:center;gap:var(--s1);align-self:flex-end}
287
+ .rv-tilesize input{width:140px}
288
+ .rv-galleryhead{display:flex;flex-wrap:wrap;align-items:center;gap:var(--s2)}
289
+ .rv-galleryrow{display:flex;flex-direction:column;gap:var(--s1);padding-top:var(--s1);border-top:1px solid var(--line)}
290
+ .rv-rowlabel{font-weight:600}
291
+ .rv-tile.picked{box-shadow:0 0 0 2px var(--ok)}
292
+ .rv-tileimg{position:relative;align-self:center}
293
+ .rv-tile .rv-over .rv-note{min-width:220px}
294
+ .rv-beforechip{position:absolute;top:4px;left:4px;font-size:10px;line-height:16px;padding:0 var(--s1);border-radius:4px;background:color-mix(in srgb,var(--bg) 80%,transparent);border:1px solid var(--line);cursor:default}
295
+ .rv-beforechip.on{background:var(--warn);color:var(--bg)}
296
+ .rv-galleryhead .rv-chip.on,.rv-keep.on{color:var(--bg);background:var(--accent);border-color:var(--accent)}
297
+ .rv-keep.on{background:var(--ok);border-color:var(--ok)}
298
+ .rv-tilesmall{display:flex;align-items:flex-end;gap:var(--s2);background:repeating-conic-gradient(var(--chk1) 0 25%,var(--chk2) 0 50%) 0 0/8px 8px;padding:var(--s1);border-radius:4px}
299
+ .rv-tilesmall img{object-fit:contain;image-rendering:auto}
285
300
  .rv-tile{display:flex;flex-direction:column;gap:var(--s1);padding:var(--s1);border-radius:6px;border:2px solid var(--line)}
286
301
  .rv-tile[class*=' re-']{border-color:var(--tone);background:color-mix(in srgb,var(--tone) 8%,transparent)}
287
302
  .rv-tile.big{width:100%}
package/src/shipkit.ts CHANGED
@@ -58,7 +58,7 @@ export type { Ask, CreateOpts } from './asks/asks-queue.ts'
58
58
  // assets surface (folded in from the standalone atelier lib; that npm
59
59
  // package is frozen). A repo's .shipkit/assets/kit.ts imports defineKit and
60
60
  // declares its kinds; `shipkit assets …` derives the rest.
61
- export { defineKit, defineKind, comfy, canvas, manual, gemini, mediaOf, MEDIA_EXTS, geometryPanel, gridPanel, customPanel, validateKit, missingPanelScripts, loadKit, findAsset, allAssets, categoriesOf } from './assets/kit-config.ts'
61
+ export { defineKit, defineKind, comfy, canvas, svg, manual, gemini, mediaOf, MEDIA_EXTS, geometryPanel, gridPanel, customPanel, validateKit, missingPanelScripts, loadKit, findAsset, allAssets, categoriesOf } from './assets/kit-config.ts'
62
62
  export type { KitConfig, ResolvedKit, Kind, KindMeta, Media, AssetSpec, GeneratorSpec, ComfyGen, CanvasGen, ManualGen, GeminiGen, PanelSpec, GeometryPanelSpec, GridPanelSpec, CustomPanelSpec, FoundAsset, ShipContext, ShipFn } from './assets/kit-config.ts'
63
63
  export { identityKinds, renderIdentity, renderIdentityFromMark, NO_PICK_FIX, FAVICON_SIZE, OG_W, OG_H, LOGO_SIZE } from './assets/kits/identity-kit.ts'
64
64
  export type { Brand } from './assets/kits/identity-kit.ts'