rvlib-shipkit 2.8.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +1 -1
  3. package/src/checks/SK005-rvlib-versions.check.ts +17 -11
  4. package/src/cli/cmd_Fleet.ts +8 -5
  5. package/src/cli/cmd_Review.ts +2 -1
  6. package/src/core/update-policy.ts +6 -0
  7. package/src/fleet/commit-bump.ts +123 -0
  8. package/src/fleet/push-fleet.ts +9 -3
  9. package/src/fleet/update-fleet.ts +38 -9
  10. package/src/review/cells.ts +548 -0
  11. package/src/review/format.ts +1 -1
  12. package/src/review/model.ts +29 -4
  13. package/src/review/previews.ts +124 -0
  14. package/src/review/routes.ts +82 -45
  15. package/src/review/store.ts +6 -5
  16. package/src/serve/hub-app/auto-text.tsx +52 -0
  17. package/src/serve/hub-app/hub.css +2 -0
  18. package/src/serve/hub-app/media-view.tsx +3 -11
  19. package/src/serve/hub-app/review/kind-view.tsx +21 -22
  20. package/src/serve/hub-app/review/kit.tsx +11 -12
  21. package/src/serve/hub-app/review/review-board.tsx +15 -13
  22. package/src/serve/hub-app/review/review-cells.tsx +241 -0
  23. package/src/serve/hub-app/review/review-kit.ts +79 -0
  24. package/src/serve/hub-app/review/review-list.tsx +87 -122
  25. package/src/serve/hub-app/review/review-page.tsx +25 -66
  26. package/src/serve/hub-app/review/review-st.ts +269 -668
  27. package/src/serve/hub-app/review/review-thread.tsx +301 -0
  28. package/src/serve/hub-app/review/review-views.tsx +372 -234
  29. package/src/serve/hub-app/review/thread-st.ts +770 -0
  30. package/src/serve/hub-app/review/trailer-page.tsx +5 -4
  31. package/src/serve/hub-app/review.css +252 -90
  32. package/src/serve/hub-app/review/review-answer.tsx +0 -248
@@ -1,140 +1,263 @@
1
- // the review page's middle column: every view of the open card stacked, each under its heading with the owner's reaction and
2
- // its zoom; a view is an image, a clip, a pair (side by side, the curtain, the onion skin, the after alone) or a
3
- // gallery of tiles. A drag on an image draws a rectangle, on a clip it pauses and keeps the frame's time. A choice, or
4
- // views that each play alone, show as thin option rows; the card's header sits on top when the page reads in one column
1
+ // the views of one version, each its own numbered sub cell (`3.2`): a big title and its kind, drawn by kind (an image,
2
+ // a pair side by side, as a curtain, an onion skin or the after alone, a clip on its own clock, a sound, a gallery), then
3
+ // what was said on it right under it. Images come at the column's size (a 1600 px preview), the full file only on zoom.
4
+ // The newest version takes his marks: a drag on an image draws a rectangle whose note box opens beside it, a clip pauses
5
+ // and keeps the frame's time. A choice, or views that each play alone, read as option rows, each image and clip full
6
+ // under its row
5
7
  import { observer } from 'mobx-react-lite'
6
8
  import { useEffect, useRef, useState, type ReactNode } from 'react'
7
- import { isGallery, isPair, onFrame, STARS, thumbFileOf, verdictOf, viewName, type GalleryView, type MediaView, type Rect, type ReviewClip, type ReviewItem, type ReviewMark, type ReviewView, type Side } from '../../../review/model.ts'
8
- import { blurOnEscape, Empty, FIT_ROOM, keepFocus, PAIR_NAMES, REACTIONS, secs } from './kit.tsx'
9
- import { CardHead } from './review-answer.tsx'
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'
11
+ import { AutoText } from '../auto-text.tsx'
10
12
  import type { ClipSt } from './clip-st.ts'
11
- import { CARD_PLACES, COMPARE_MODES, drawnSide, ZOOMS, type CompareMode, type CompareSt, type PairSide, type ReviewSt, type Zoom } from './review-st.ts'
13
+ import { blurOnEscape, FIT_ROOM, keepFocus, PAIR_NAMES, REACTIONS, secs, SIDE_LABEL } from './kit.tsx'
14
+ import { ZOOMS, type Zoom } from './review-kit.ts'
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'
12
17
 
13
18
  const ZOOM_LABEL: Record<Zoom, string> = { fit: 'Fit', '1': '100 %', '1.5': '150 %', '2': '200 %' }
14
19
  const toneClass = (s: string | undefined): string => (s ? ` re-${s}` : '')
15
20
 
16
- export const ReviewImage = observer(({ rv }: { rv: ReviewSt }) => {
17
- const x = rv.open
18
- if (!x) return <Empty text={rv.list ? 'No card. An agent adds one with sk review add.' : 'Reading the cards…'} />
19
- const r = x.item
20
- const views = r.views
21
- const drawable = views.some((v) => !isGallery(v) && !v.clip && !v.audio)
22
- const rows = rv.rows
21
+ /** one version as its views draw it: `live` when it takes his marks (the newest version of an agent's card, no draft) */
22
+ export interface Ver {
23
+ rv: ReviewSt
24
+ card: ThreadSt
25
+ cell: VersionCell
26
+ live: boolean
27
+ }
28
+
29
+ const itemOf = (ver: Ver): Item => ver.cell.item
30
+
31
+ /** a version's views: its bar (rows or full, « Circle » on a phone, the zoom), then each view as a sub cell or a row */
32
+ export const VersionViews = observer(({ ver }: { ver: Ver }) => {
33
+ const { rv, card } = ver
34
+ const item = itemOf(ver)
35
+ const views = item.views
36
+ const rows = card.rows(item)
37
+ const drawable = ver.live && views.some((v) => !isGallery(v) && !v.clip && !v.audio)
38
+ // a draft card's history is no view of its own: its frames cycle in place over the live one
39
+ const history = item.wip ? views.find(isGallery) : undefined
40
+ const options = rows || (card.full[item.id] === true)
23
41
  return (
24
42
  <div className="rv-views">
25
- {rv.headInViews ? <CardHead rv={rv} x={x} /> : null}
26
43
  <div className="rv-viewsbar">
27
- {views.length > 1 && !rows ? <JumpList rv={rv} /> : <span />}
28
- <span className="rv-viewsctl">
29
- {asOptionsCard(rv) ? (
30
- <span className="seg" title="the options as thin rows, one below the other, or every view full">
31
- <button className={rows ? 'on' : ''} onMouseDown={keepFocus} onClick={() => rv.setFull(false)}>rows</button>
32
- <button className={rows ? '' : 'on'} onMouseDown={keepFocus} onClick={() => rv.setFull(true)}>full</button>
33
- </span>
34
- ) : null}
35
- {rv.phone.on && drawable ? (
36
- <button className={rv.phone.draw ? 'primary' : ''} onClick={() => rv.phone.toggleDraw()}>Circle</button>
37
- ) : null}
38
- {rv.phone.on ? null : (
39
- <span className="seg" title="the card against its answer: on top of it, left of it, or auto (on top when the page is narrow)">
40
- {CARD_PLACES.map((p) => <button key={p} className={rv.place === p ? 'on' : ''} onMouseDown={keepFocus} onClick={() => rv.setPlace(p)}>{p}</button>)}
41
- </span>
42
- )}
43
- <span className="seg" title="the zoom every view starts at">
44
- {ZOOMS.map((z) => <button key={z} className={rv.zoom === z ? 'on' : ''} onMouseDown={keepFocus} onClick={() => rv.setZoom(z)}>{ZOOM_LABEL[z]}</button>)}
44
+ {options ? (
45
+ <span className="seg" title="the options as thin rows, one below the other, or every view full">
46
+ <button className={rows ? 'on' : ''} onMouseDown={keepFocus} onClick={() => card.setFull(item.id, false)}>rows</button>
47
+ <button className={rows ? '' : 'on'} onMouseDown={keepFocus} onClick={() => card.setFull(item.id, true)}>full</button>
45
48
  </span>
49
+ ) : null}
50
+ {rv.phone.on && drawable ? <button className={rv.phone.draw ? 'primary' : ''} onClick={() => rv.phone.toggleDraw()}>Circle</button> : null}
51
+ <span className="sp" />
52
+ <span className="seg" title="the zoom every view starts at">
53
+ {ZOOMS.map((z) => <button key={z} className={rv.zoom === z ? 'on' : ''} onMouseDown={keepFocus} onClick={() => rv.setZoom(z)}>{ZOOM_LABEL[z]}</button>)}
46
54
  </span>
47
55
  </div>
48
- {rv.answered.map((y) => <Raised key={y.item.id} rv={rv} x={y} />)}
49
56
  {rows ? (
50
- <div className="rv-opts">{views.map((v, i) => <OptionRow key={`${r.id}#${i}`} rv={rv} x={x} v={v} i={i} />)}</div>
57
+ <div className="rv-opts">{views.map((v, i) => <OptionRow key={i} ver={ver} v={v} i={i} />)}</div>
51
58
  ) : (
52
- views.map((v, i) => <ViewBlock key={`${r.id}#${i}`} rv={rv} id={r.id} v={v} i={i} many={views.length > 1} />)
59
+ views.map((v, i) => (v === history ? null : <ViewCell key={i} ver={ver} v={v} i={i} {...(i === 0 && history && isGallery(history) ? { frames: history } : {})} />))
53
60
  )}
54
- {views.length === 0 ? <TextOnly x={x} /> : null}
55
61
  </div>
56
62
  )
57
63
  })
58
64
 
59
- /** the open card may show as rows: a choice, or views that each play alone (the switch shows while it shows full) */
60
- const asOptionsCard = (rv: ReviewSt): boolean => rv.rows || rv.full[rv.open?.item.id ?? ''] === true
65
+ /** one view as a sub cell: its number and title, its kind, the owner's reaction, its tools, the view, then what was said on it */
66
+ const ViewCell = observer(({ ver, v: live, i, frames }: { ver: Ver; v: ReviewView; i: number; frames?: GalleryView }) => {
67
+ const { rv, card, cell } = ver
68
+ const past = frames && card.frame !== null ? frames.gallery[card.frame] : undefined
69
+ const v: ReviewView = past && !isGallery(live) ? { ...live, files: { image: past.file }, size: past.size } : live
70
+ const media = isGallery(v) ? null : v
71
+ const open = card.viewOpen(cell.id, i)
72
+ const zoom = card.zoomOf(cell.id, i)
73
+ const shown = card.reactionShown(cell, i)
74
+ const active = ver.live && card.view === i
75
+ const gone = goneOf(ver, v)
76
+ return (
77
+ <section id={viewDom(cell.id, i)} className={`rv-view${toneClass(shown?.status)}${active ? ' active' : ''}${open ? '' : ' folded'}`}>
78
+ <header className="rv-viewhead">
79
+ <button className="rv-foldbtn" aria-label={open ? 'fold this view' : 'unfold this view'} aria-expanded={open} onMouseDown={keepFocus} onClick={() => card.toggleView(cell.id, i)}>{open ? '▾' : '▸'}</button>
80
+ <span className="rv-viewn">{viewTag(cell.n, i)}</span>
81
+ <h4 className="rv-viewname" onClick={() => card.toggleView(cell.id, i)}>{v.label || <span className="rv-dim">{viewName(v, i)}</span>}</h4>
82
+ <span className="rv-kind">{viewKind(v, false)}</span>
83
+ {ver.live ? <ReactionToggles card={card} view={i} /> : shown?.status ? <SentReaction status={shown.status} /> : null}
84
+ <span className="sp" />
85
+ {open && media?.marks && media.marks.length > 0 ? <button className={rv.marksOn ? 'primary' : ''} onMouseDown={keepFocus} onClick={() => rv.toggleMarks()}>marks · M</button> : null}
86
+ {open && media && isPair(media.files) && !media.audio && !rv.phone.on ? <CompareModes c={rv.compare} /> : null}
87
+ {open && media && !media.audio ? (
88
+ <button title={zoom === 'fit' ? 'see this image at its own size, the full file' : 'fit this image to the column'} onMouseDown={keepFocus}
89
+ onClick={() => card.setViewZoom(cell.id, i, zoom === 'fit' ? '1' : 'fit')}>{zoom === 'fit' ? '100 %' : 'Fit'}</button>
90
+ ) : null}
91
+ </header>
92
+ {open ? (
93
+ <div className="rv-viewbody">
94
+ {frames ? <FrameSlider card={card} frames={frames} /> : null}
95
+ {gone.length > 0 ? <Gone files={gone} /> : isGallery(v) ? <Gallery ver={ver} v={v} view={i} /> : <MediaBody ver={ver} v={v} i={i} zoom={zoom} />}
96
+ {media?.note ? <div className="rv-viewnote">{media.note}</div> : null}
97
+ </div>
98
+ ) : null}
99
+ <ViewNotes ver={ver} i={i} gallery={isGallery(v)} />
100
+ </section>
101
+ )
102
+ })
61
103
 
62
- /** one option of a choice, or one view of a group, as a thin row: its number, ▶ and the clock, its label, a strip that
63
- * scrubs it, its stars and « pick » (a choice) or OK, fix, no (a group), ✎ his word, ⤢ the full view under it */
64
- const OptionRow = observer(({ rv, x, v, i }: { rv: ReviewSt; x: ReviewItem; v: ReviewView; i: number }) => {
104
+ /** what was said on one view, under it: each answer's rectangles and reactions (a click shows the rectangle), then on
105
+ * the newest version his draft: each rectangle's word, his word on the view */
106
+ const ViewNotes = observer(({ ver, i, gallery, word = true }: { ver: Ver; i: number; gallery: boolean; word?: boolean }) => {
107
+ const { card, cell } = ver
108
+ const said = card.saidOn(cell.id, i)
109
+ const views = itemOf(ver).views
110
+ const draft = ver.live ? card.draft.rects.map((r, k) => [r, k] as const).filter(([r]) => (r.view ?? 0) === i) : []
111
+ const reaction = ver.live ? card.reactionOf(i) : null
112
+ if (said.length === 0 && draft.length === 0 && !(ver.live && word)) return null
113
+ return (
114
+ <div className="rv-viewnotes">
115
+ {said.map((s, k) => {
116
+ const tile = s.reaction?.tile
117
+ const where = tile !== undefined && isGalleryView(views[i]) ? (views[i] as GalleryView).gallery[tile]?.label ?? `tile ${tile + 1}` : null
118
+ return (
119
+ <div key={k} className={`rv-said${s.reaction?.status ? ` re-${s.reaction.status}` : s.rect ? ' rect' : ''}`}>
120
+ <span className="rv-saidmark">
121
+ {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}` : ''}`}
122
+ </span>
123
+ <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>
124
+ <span className="rv-saidwho rv-dim">you · {STATUS_LABEL[s.verdict.verdict]} · v{cell.n}</span>
125
+ </div>
126
+ )
127
+ })}
128
+ {draft.length > 0 ? (
129
+ <div className="rv-drafthead">
130
+ <b>your notes</b>
131
+ <span className="rv-dim">a draft: your verdict sends them</span>
132
+ </div>
133
+ ) : null}
134
+ {draft.map(([r, k]) => (
135
+ <div key={`d${k}`} className={`rv-outrow${card.rect === k ? ' on' : ''}`}>
136
+ <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)}>
137
+ {k + 1}{r.side ? ` ${SIDE_LABEL[r.side]}` : ''}{r.t !== undefined ? ` · ${secs(r.t)}` : ''}
138
+ </button>
139
+ <button className="rv-outtext ghost" title="open the note on the image" onMouseDown={keepFocus} onClick={() => card.pickRect(k, true)}>
140
+ {r.comment.trim() ? r.comment : <i className="rv-dim">no word yet</i>}
141
+ </button>
142
+ <button className="ghost rv-x" title="delete this note" aria-label="delete this note" onClick={() => card.removeRect(k)}>✕</button>
143
+ </div>
144
+ ))}
145
+ {ver.live && word ? (
146
+ <AutoText className="rv-word" placeholder={gallery ? 'a word on these images' : 'a word on this view'} value={reaction?.comment ?? ''}
147
+ onKeyDown={blurOnEscape} onText={(t) => card.setReactionComment(i, undefined, t)} />
148
+ ) : null}
149
+ </div>
150
+ )
151
+ })
152
+
153
+ const isGalleryView = (v: ReviewView | undefined): v is GalleryView => v !== undefined && isGallery(v)
154
+
155
+ /** a reaction an older answer gave, as a still pill */
156
+ const SentReaction = ({ status }: { status: string }) => {
157
+ const o = REACTIONS.find((r) => r.status === status)
158
+ return o ? <span className={`rv-react on re-${status}`}>{o.glyph} {o.label}</span> : null
159
+ }
160
+
161
+ /** one option of a choice, or one view of a group, as a row: its number, ▶ and the clock, its label, a strip that
162
+ * scrubs it, its stars and « pick » (a choice) or OK, fix, no (a group), ✎ his word, ⤢ folds or unfolds the full view
163
+ * under it (an image or a clip shows it from the start). An older version's rows show what he gave them */
164
+ const OptionRow = observer(({ ver, v, i }: { ver: Ver; v: ReviewView; i: number }) => {
165
+ const { rv, card, cell } = ver
65
166
  const [word, setWord] = useState(false)
66
- const id = x.item.id
167
+ const item = itemOf(ver)
168
+ const id = item.id
67
169
  const media = isGallery(v) ? null : v
68
170
  const playable = media !== null && !isPair(media.files) && (media.clip !== undefined || media.audio !== undefined) ? media : null
69
- const c = playable ? rv.clipOf(i) : null
70
- const reaction = rv.reactionOf(i)
71
- const choice = rv.choice
72
- const picked = rv.draft.pick === i
73
- const sent = verdictOf(x)?.pick === i
74
- const unfolded = rv.openRows[i] === true
171
+ const c = playable ? card.clipOf(id, i) : null
172
+ const reaction = card.reactionShown(cell, i)
173
+ const choice = isChoice(item)
174
+ const picked = card.pickShown(cell) === i
175
+ const unfolded = card.rowOpen(item, i)
75
176
  const file = playable ? ('video' in playable.files ? playable.files.video : 'audio' in playable.files ? playable.files.audio : '') : ''
76
177
  const duration = playable?.clip?.duration ?? playable?.audio?.duration ?? 0
77
- const showWord = word || (reaction?.comment ?? '') !== ''
178
+ const showWord = ver.live && (word || (reaction?.comment ?? '') !== '')
179
+ const active = ver.live && card.view === i
180
+ // an unfolded clip plays under its own bar: the row keeps no second clock
181
+ const clock2 = c !== null && !(unfolded && playable?.clip)
182
+ const gone = goneOf(ver, v)
78
183
  return (
79
- <div id={`review-view-${i}`} className={`rv-opt${rv.view === i ? ' active' : ''}${picked ? ' picked' : ''}${toneClass(reaction?.status)}`} onMouseDownCapture={() => rv.view !== i && rv.setView(i)}>
184
+ <div id={viewDom(cell.id, i)} className={`rv-opt${active ? ' active' : ''}${picked ? ' picked' : ''}${unfolded ? ' unfolded' : ''}${toneClass(reaction?.status)}`} onMouseDownCapture={() => ver.live && card.view !== i && card.setView(i)}>
80
185
  <div className="rv-optrow">
81
- <span className="rv-optn">{i + 1}</span>
82
- {c ? (
83
- <button className={`rv-optplay${c.paused ? '' : ' on'}`} title={`${c.paused ? 'play' : 'pause'} (${i + 1})`} onMouseDown={keepFocus} onClick={() => rv.listen(i)}>
186
+ <span className="rv-optn">{viewTag(cell.n, i)}</span>
187
+ {c && clock2 ? (
188
+ <button className={`rv-optplay${c.paused ? '' : ' on'}`} title={`${c.paused ? 'play' : 'pause'}${ver.live ? ` (${i + 1})` : ''}`} onMouseDown={keepFocus} onClick={() => card.listen(id, i)}>
84
189
  {c.paused ? '▶' : '❚❚'}
85
190
  </button>
86
191
  ) : null}
87
192
  <b className="rv-optlabel" title={viewName(v, i)}>{viewName(v, i)}</b>
88
193
  {c && playable?.clip && !unfolded ? (
89
- <span className="rv-optthumb" style={{ aspectRatio: `${playable.size.w} / ${playable.size.h}` }} onClick={() => rv.toggleRow(i)} title="the full view">
90
- <ClipVideo clip={c} src={rv.fileUrl(id, file)} poster={rv.fileUrl(id, playable.clip.poster)} loop={false} />
194
+ <span className="rv-optthumb" style={{ aspectRatio: `${playable.size.w} / ${playable.size.h}` }} onClick={() => card.toggleRow(item, i)} title="the full view">
195
+ <ClipVideo clip={c} src={rv.fileUrl(id, file, item.wip)} poster={rv.thumbUrl(id, playable.clip.poster)} loop={false} />
91
196
  </span>
92
197
  ) : null}
93
- {c && playable ? (
198
+ {c && playable && clock2 ? (
94
199
  <Strip clip={c} duration={duration} wave={playable.audio ? rv.fileUrl(id, playable.audio.wave) : undefined} />
95
- ) : (
96
- <span className="rv-optthumb img" onClick={() => rv.toggleRow(i)} title="the full view"><img src={rv.thumbUrl(x, thumbFileOf(v))} alt="" draggable={false} /></span>
200
+ ) : unfolded || c ? <span className="sp" /> : (
201
+ <span className="rv-optthumb img" onClick={() => card.toggleRow(item, i)} title="the full view"><img src={rv.thumbUrl(id, thumbFileOf(v))} alt="" draggable={false} loading="lazy" /></span>
97
202
  )}
98
- {c ? <span className="rv-mono rv-opttime">{clock(c.time)} / {clock(duration)}</span> : null}
203
+ {c && clock2 ? <span className="rv-mono rv-opttime">{clock(c.time)} / {clock(duration)}</span> : null}
99
204
  <span className="rv-optacts">
100
- {choice ? <Stars rv={rv} view={i} /> : <ReactionToggles rv={rv} view={i} small />}
101
- <button className={`rv-optword${showWord ? ' on' : ''}`} title="a word on this one" onMouseDown={keepFocus} onClick={() => setWord(!word)}>✎</button>
205
+ {choice ? <Stars card={card} view={i} live={ver.live} given={reaction?.stars} /> : ver.live ? <ReactionToggles card={card} view={i} /> : reaction?.status ? <SentReaction status={reaction.status} /> : null}
206
+ {ver.live ? <button className={`rv-optword${showWord ? ' on' : ''}`} title="a word on this one" onMouseDown={keepFocus} onClick={() => setWord(!word)}>✎ word</button> : null}
102
207
  {playable?.clip || !playable ? (
103
- <button className={unfolded ? 'on' : ''} title={unfolded ? 'fold it back to its row' : 'the full view'} onMouseDown={keepFocus} onClick={() => rv.toggleRow(i)}>⤢</button>
208
+ <button className={unfolded ? 'on' : ''} title={unfolded ? 'fold it back to its row' : 'show it full under its row'} onMouseDown={keepFocus} onClick={() => card.toggleRow(item, i)}>{unfolded ? '▴ fold' : '▾ show'}</button>
104
209
  ) : null}
105
210
  {playable?.audio ? <a className="rv-dl" href={rv.fileUrl(id, file)} download={`${id}-${file}`} title="download the sound">⤓</a> : null}
106
- {choice ? (
107
- <button className={`rv-pick${picked ? ' on' : ''}`} title={`pick this one: it is your answer (P)${sent ? ', sent' : ''}`} disabled={rv.busy} onClick={() => void rv.choose(i)}>
211
+ {choice && ver.live ? (
212
+ <button className={`rv-pick${picked ? ' on' : ''}`} title="pick this one: it is your answer (P)" disabled={card.busy} onClick={() => void card.choose(i)}>
108
213
  {picked ? '✓ picked' : 'pick'}
109
214
  </button>
110
- ) : null}
215
+ ) : choice && picked ? <span className="rv-pick on">✓ picked</span> : null}
111
216
  </span>
112
217
  </div>
113
218
  {media?.note ? <div className="rv-optnote">{media.note}</div> : null}
219
+ {!ver.live && reaction?.comment ? <div className="rv-optnote rv-saidtext">« {reaction.comment} »</div> : null}
114
220
  {showWord ? (
115
- <textarea className="rv-word" rows={1} placeholder="a word on this one" value={reaction?.comment ?? ''} autoFocus={word && !reaction?.comment}
116
- onKeyDown={blurOnEscape} onChange={(e) => rv.setReactionComment(i, undefined, e.currentTarget.value)} />
221
+ <AutoText className="rv-word" placeholder="a word on this one" value={reaction?.comment ?? ''} autoFocus={word && !reaction?.comment}
222
+ onKeyDown={blurOnEscape} onText={(t) => card.setReactionComment(i, undefined, t)} />
117
223
  ) : null}
118
224
  {c && playable?.audio ? <SoundEl clip={c} src={rv.fileUrl(id, file)} /> : null}
119
225
  {unfolded ? (
120
226
  <div className="rv-optbody">
121
- {isGallery(v) ? <Gallery rv={rv} id={id} v={v} view={i} /> : <MediaBody rv={rv} id={id} v={v} i={i} zoom={rv.zoomOf(i)} />}
227
+ {gone.length > 0 ? <Gone files={gone} /> : isGallery(v) ? <Gallery ver={ver} v={v} view={i} /> : <MediaBody ver={ver} v={v} i={i} zoom={card.zoomOf(id, i)} />}
122
228
  </div>
123
229
  ) : null}
230
+ <ViewNotes ver={ver} i={i} gallery={isGallery(v)} word={false} />
124
231
  </div>
125
232
  )
126
233
  })
127
234
 
235
+ /** the files of a view the store no longer holds */
236
+ const goneOf = (ver: Ver, v: ReviewView): string[] => {
237
+ const missing = ver.card.data?.missing ?? []
238
+ if (missing.length === 0) return []
239
+ const id = itemOf(ver).id
240
+ return viewFilesOf({ ...itemOf(ver), views: [v] }).filter((n) => missing.includes(`${id}/${n}`))
241
+ }
242
+
243
+ /** a view whose media the store no longer holds: said in place of a player that would stay black */
244
+ const Gone = ({ files }: { files: readonly string[] }) => (
245
+ <div className="rv-gone">
246
+ <b>the media is gone from the store</b>
247
+ <span className="rv-dim">{files.join(', ')}: deleted after the card was sent; its words and answers stay</span>
248
+ </div>
249
+ )
250
+
128
251
  /** `1:05`: a time on a row, short */
129
252
  const clock = (t: number): string => `${Math.floor(t / 60)}:${String(Math.floor(t % 60)).padStart(2, '0')}`
130
253
 
131
- /** an option's score: STARS stars, a click on the one given clears it */
132
- const Stars = observer(({ rv, view }: { rv: ReviewSt; view: number }) => {
133
- const n = rv.reactionOf(view)?.stars ?? 0
254
+ /** an option's score: STARS stars, a click on the one given clears it; an older version's stars as he gave them */
255
+ const Stars = observer(({ card, view, live, given }: { card: ThreadSt; view: number; live: boolean; given: number | undefined }) => {
256
+ const n = given ?? 0
134
257
  return (
135
- <span className="rv-stars" title={`your score (⇧1 to ⇧${STARS} on the row playing)`}>
258
+ <span className="rv-stars" title={live ? `your score (⇧1 to ⇧${STARS} on the row playing)` : 'your score'}>
136
259
  {Array.from({ length: STARS }, (_, k) => (
137
- <button key={k} className={k < n ? 'on' : ''} aria-label={`${k + 1} of ${STARS}`} onMouseDown={keepFocus} onClick={() => rv.setStars(view, k + 1)}>{k < n ? '★' : '☆'}</button>
260
+ <button key={k} className={k < n ? 'on' : ''} disabled={!live} aria-label={`${k + 1} of ${STARS}`} onMouseDown={keepFocus} onClick={() => card.setStars(view, k + 1)}>{k < n ? '★' : '☆'}</button>
138
261
  ))}
139
262
  </span>
140
263
  )
@@ -181,84 +304,33 @@ const SoundEl = ({ clip, src }: { clip: ClipSt; src: string }) => {
181
304
  if (!el) return
182
305
  return clip.attach(el)
183
306
  }, [clip, src])
184
- return <audio ref={ref} src={src} preload="metadata" onEnded={() => clip.seek(0)} />
185
- }
186
-
187
- /** a raised item the open card answers, nested above its views: the owner's words, his still */
188
- const Raised = observer(({ rv, x }: { rv: ReviewSt; x: ReviewItem }) => {
189
- const opening = x.thread.find((m) => m.op === undefined && m.text !== undefined)
190
- const first = x.item.views[0]
191
- return (
192
- <div className="rv-raised">
193
- <div className="rv-dim">answers {x.item.origin.by === 'owner' ? 'your note' : 'a report'} · {x.item.title}</div>
194
- {opening?.text ? <div className="rv-pre">{opening.text}</div> : null}
195
- {first && !isGallery(first) && 'image' in first.files ? <img className="rv-raisedimg" src={rv.fileUrl(x.item.id, first.files.image)} alt="" /> : null}
196
- </div>
197
- )
198
- })
199
-
200
- /** an item with no view: its words, full width */
201
- const TextOnly = ({ x }: { x: ReviewItem }) => {
202
- const text = x.item.what ?? x.thread.find((m) => m.text !== undefined)?.text
203
- return text ? <div className="rv-pre">{text}</div> : <Empty text="This item has no image and no text." />
307
+ return <audio ref={ref} src={src} preload="none" onEnded={() => clip.seek(0)} />
204
308
  }
205
309
 
206
- /** the views' labels on top of a card of several: a click scrolls to that view; a dot says the owner's reaction to it */
207
- const JumpList = observer(({ rv }: { rv: ReviewSt }) => {
208
- const x = rv.open
209
- if (!x) return null
210
- return (
211
- <span className="rv-jumps">
212
- {x.item.views.map((v, i) => (
213
- <button key={i} className={`rv-jump${rv.view === i ? ' on' : ''}${toneClass(rv.reactionOf(i)?.status)}`} onMouseDown={keepFocus}
214
- onClick={() => {
215
- rv.setView(i)
216
- document.getElementById(`review-view-${i}`)?.scrollIntoView({ behavior: 'smooth', block: 'start' })
217
- }}>
218
- {rv.reactionOf(i)?.status ? <span className="rv-jdot" /> : null}
219
- {i + 1}. {viewName(v, i)}
220
- </button>
221
- ))}
222
- </span>
223
- )
224
- })
225
-
226
- /** one view: its label, its reaction and zoom, its image, pair, clip or gallery, then his word on it */
227
- const ViewBlock = observer(({ rv, id, v, i, many }: { rv: ReviewSt; id: string; v: ReviewView; i: number; many: boolean }) => {
228
- const reaction = rv.reactionOf(i)
229
- const media = isGallery(v) ? null : v
230
- const zoom = rv.zoomOf(i)
310
+ /** a draft card's frames over its live view: a slider and two arrows cycle them in place, the live one at the right end */
311
+ const FrameSlider = observer(({ card, frames }: { card: ThreadSt; frames: GalleryView }) => {
312
+ const last = frames.gallery.length
313
+ const at = card.frame ?? last
314
+ const go = (f: number): void => card.setFrame(f >= last ? null : Math.max(0, f))
231
315
  return (
232
- <div id={`review-view-${i}`} className={`rv-view${toneClass(reaction?.status)}${rv.view === i && many ? ' active' : ''}`}>
233
- <div className="rv-viewhead">
234
- <b className="rv-viewname">{many ? `${i + 1}. ` : ''}{viewName(v, i)}</b>
235
- <ReactionToggles rv={rv} view={i} />
236
- <span className="sp" />
237
- {media?.marks && media.marks.length > 0 ? (
238
- <button className={rv.marksOn ? 'primary' : ''} onMouseDown={keepFocus} onClick={() => rv.toggleMarks()}>marks · M</button>
239
- ) : null}
240
- {media && isPair(media.files) && !media.audio && !rv.phone.on ? <CompareModes c={rv.compare} /> : null}
241
- {media ? (
242
- <button title={zoom === 'fit' ? 'see this image at its own size' : 'fit this image to the column'} onMouseDown={keepFocus}
243
- onClick={() => rv.setViewZoom(i, zoom === 'fit' ? '1' : 'fit')}>{zoom === 'fit' ? '100 %' : 'Fit'}</button>
244
- ) : null}
245
- </div>
246
- {isGallery(v) ? <Gallery rv={rv} id={id} v={v} view={i} /> : <MediaBody rv={rv} id={id} v={v} i={i} zoom={zoom} />}
247
- <textarea className="rv-word" rows={1} placeholder={isGallery(v) ? 'a word on these images' : 'a word on this image'} value={reaction?.comment ?? ''}
248
- onKeyDown={blurOnEscape} onChange={(e) => rv.setReactionComment(i, undefined, e.currentTarget.value)} />
316
+ <div className="rv-frames">
317
+ <button title="the frame before" disabled={at === 0} onMouseDown={keepFocus} onClick={() => go(at - 1)}>‹</button>
318
+ <input type="range" min={0} max={last} step={1} value={at} aria-label="the draft's frames" onChange={(e) => go(Number(e.currentTarget.value))} onMouseUp={(e) => e.currentTarget.blur()} />
319
+ <button title="the frame after" disabled={at === last} onMouseDown={keepFocus} onClick={() => go(at + 1)}>›</button>
320
+ <span className="rv-dim rv-small">{at === last ? 'now' : (frames.gallery[at]?.label ?? `frame ${at + 1}`)}</span>
249
321
  </div>
250
322
  )
251
323
  })
252
324
 
253
- /** the owner's reaction to one view or tile: OK, fix or no; a click on the chosen one clears it */
254
- const ReactionToggles = observer(({ rv, view, tile, small }: { rv: ReviewSt; view: number; tile?: number; small?: boolean }) => {
255
- const cur = rv.reactionOf(view, tile)?.status
325
+ /** the owner's reaction to one view or tile of the newest version: OK, fix or no; a click on the chosen one clears it */
326
+ const ReactionToggles = observer(({ card, view, tile, small }: { card: ThreadSt; view: number; tile?: number; small?: boolean }) => {
327
+ const cur = card.reactionOf(view, tile)?.status
256
328
  return (
257
329
  <span className="rv-reacts">
258
330
  {REACTIONS.map((o) => (
259
- <button key={o.status} title={o.tip} className={`rv-react re-${o.status}${cur === o.status ? ' on' : ''}${cur && cur !== o.status ? ' off' : ''}`}
260
- onMouseDown={keepFocus} onClick={() => rv.react(view, tile, o.status)}>
261
- {o.glyph}{small ? null : ` ${o.label}`}
331
+ <button key={o.status} title={o.tip} className={`rv-react re-${o.status}${small ? '' : ' big'}${cur === o.status ? ' on' : ''}${cur && cur !== o.status ? ' off' : ''}`}
332
+ onMouseDown={keepFocus} onClick={() => card.react(view, tile, o.status)}>
333
+ {o.glyph} {o.label}
262
334
  </button>
263
335
  ))}
264
336
  </span>
@@ -268,61 +340,73 @@ const ReactionToggles = observer(({ rv, view, tile, small }: { rv: ReviewSt; vie
268
340
  /** a gallery tile's image height */
269
341
  const TILE_H = 170
270
342
 
271
- /** a gallery view: its images as a wrapping grid of small tiles, each with its label and its own reaction; a click
272
- * shows it large */
273
- const Gallery = observer(({ rv, id, v, view }: { rv: ReviewSt; id: string; v: GalleryView; view: number }) => (
274
- <div className="rv-gallery">
275
- {v.gallery.map((t, k) => {
276
- const big = rv.bigTile === `${view}/${k}`
277
- const r = rv.reactionOf(view, k)
278
- const ratio = t.size.w / t.size.h
279
- const w = big ? undefined : Math.round(Math.max(110, Math.min(260, TILE_H * ratio)))
280
- return (
281
- <div key={k} id={`review-tile-${view}-${k}`} className={`rv-tile${big ? ' big' : ''}${toneClass(r?.status)}`} style={big ? undefined : { width: w }}>
282
- <div className="rv-tileimg" onClick={() => rv.toggleTile(view, k)} title={big ? 'click to shrink' : 'click to enlarge'}
283
- style={big ? { width: `min(100%, calc((100vh - ${FIT_ROOM}px) * ${ratio}))` } : { height: TILE_H }}>
284
- <img src={rv.fileUrl(id, t.file)} alt={t.label} draggable={false} />
343
+ /** a gallery view: its images as a wrapping grid of small tiles at the list's size, each with its label and its
344
+ * reaction; a click shows it large at the column's size */
345
+ const Gallery = observer(({ ver, v, view }: { ver: Ver; v: GalleryView; view: number }) => {
346
+ const { rv, card, cell } = ver
347
+ const id = itemOf(ver).id
348
+ return (
349
+ <div className="rv-gallery">
350
+ {v.gallery.map((t, k) => {
351
+ const big = card.bigTile === `${viewKey(id, view)}/${k}`
352
+ const r = card.reactionShown(cell, view, k)
353
+ const ratio = t.size.w / t.size.h
354
+ const w = big ? undefined : Math.round(Math.max(110, Math.min(260, TILE_H * ratio)))
355
+ return (
356
+ <div key={k} className={`rv-tile${big ? ' big' : ''}${toneClass(r?.status)}`} style={big ? undefined : { width: w }}>
357
+ <div className="rv-tileimg" onClick={() => card.toggleTile(id, view, k)} title={big ? 'click to shrink' : 'click to enlarge'}
358
+ style={big ? { width: `min(100%, calc((100vh - ${FIT_ROOM}px) * ${ratio}))`, aspectRatio: `${t.size.w} / ${t.size.h}` } : { height: TILE_H }}>
359
+ <img src={big ? rv.fitUrl(id, t.file) : rv.thumbUrl(id, t.file)} alt={t.label} draggable={false} loading="lazy" />
360
+ </div>
361
+ <div className="rv-tilelabel" title={t.label}>{t.label}</div>
362
+ {ver.live ? (
363
+ <>
364
+ <ReactionToggles card={card} view={view} tile={k} small />
365
+ <AutoText className="rv-word" placeholder="a word" value={r?.comment ?? ''} onKeyDown={blurOnEscape} onText={(t) => card.setReactionComment(view, k, t)} />
366
+ </>
367
+ ) : r?.status ? <SentReaction status={r.status} /> : null}
285
368
  </div>
286
- <div className="rv-tilelabel" title={t.label}>{t.label}</div>
287
- <ReactionToggles rv={rv} view={view} tile={k} small />
288
- <textarea className="rv-word" rows={1} placeholder="a word" value={r?.comment ?? ''} onKeyDown={blurOnEscape}
289
- onChange={(e) => rv.setReactionComment(view, k, e.currentTarget.value)} />
290
- </div>
291
- )
292
- })}
293
- </div>
294
- ))
369
+ )
370
+ })}
371
+ </div>
372
+ )
373
+ })
295
374
 
296
375
  /** one media view: a single image or clip, or the pair in the compare component; fitted to the column on its own, or
297
- * zoomed with its own scroll */
298
- const MediaBody = observer(({ rv, id, v, i, zoom }: { rv: ReviewSt; id: string; v: MediaView; i: number; zoom: Zoom }) => {
299
- if (v.audio) return <SoundBody rv={rv} id={id} v={v} />
376
+ * zoomed (the full file) with its own scroll */
377
+ const MediaBody = observer(({ ver, v, i, zoom }: { ver: Ver; v: MediaView; i: number; zoom: Zoom }) => {
378
+ const { rv, card } = ver
379
+ const item = itemOf(ver)
380
+ const id = item.id
381
+ if (v.audio) return <SoundBody ver={ver} v={v} />
300
382
  const f = v.files
301
383
  const ratio = v.size.w / v.size.h
302
384
  const aspect = `${v.size.w} / ${v.size.h}`
303
385
  const scale = zoom === 'fit' ? null : Number(zoom)
304
386
  const room = FIT_ROOM + (v.clip ? 40 : 0)
305
- const bar = v.clip ? <ClipBar clip={rv.clipOf(i)} info={v.clip} use={() => rv.setView(i)} /> : null
387
+ const src = (name: string): string => (v.clip ? rv.fileUrl(id, name, item.wip) : scale ? rv.fileUrl(id, name, item.wip) : rv.fitUrl(id, name, item.wip))
388
+ const bar = v.clip ? <ClipBar clip={card.clipOf(id, i)} info={v.clip} use={() => ver.live && card.setView(i)} /> : null
306
389
  const scroll = scale ? { overflow: 'auto', maxHeight: `calc(100vh - ${room}px)` } : undefined
307
390
  if (!isPair(f)) {
308
391
  const name = 'image' in f ? f.image : 'video' in f ? f.video : f.audio
309
392
  return (
310
393
  <div style={scroll}>
311
394
  <div style={{ width: scale ? `${v.size.w * scale}px` : `min(100%, calc((100vh - ${room}px) * ${ratio}))`, margin: '0 auto' }}>
312
- <Compare c={rv.compare} base={rv.fileUrl(id, name)} mod={undefined} aspect={aspect} draw={(s) => <Marks rv={rv} src={s} side={undefined} view={i} />} />
395
+ <Compare c={rv.compare} base={src(name)} mod={undefined} aspect={aspect} draw={(s) => <Marks ver={ver} src={s} side={undefined} view={i} />}
396
+ over={() => (ver.live ? <RectNote card={card} view={i} sides={[undefined]} /> : null)} />
313
397
  {bar}
314
- <Downloads rv={rv} id={id} files={[{ file: name }]} />
398
+ <Downloads rv={rv} item={item} files={[{ file: name }]} />
315
399
  </div>
316
400
  </div>
317
401
  )
318
402
  }
319
- const before = rv.fileUrl(id, f.before)
320
- const after = rv.fileUrl(id, f.after)
321
- const saves = <Downloads rv={rv} id={id} files={[{ file: f.before, label: 'before' }, { file: f.after, label: 'after' }]} />
403
+ const before = src(f.before)
404
+ const after = src(f.after)
405
+ const saves = <Downloads rv={rv} item={item} files={[{ file: f.before, label: 'before' }, { file: f.after, label: 'after' }]} />
322
406
  if (rv.phone.on)
323
407
  return (
324
408
  <>
325
- <PhonePair rv={rv} view={i} bar={bar} before={before} after={after} aspect={aspect} size={v.size} scale={scale} />
409
+ <PhonePair ver={ver} view={i} bar={bar} before={before} after={after} aspect={aspect} size={v.size} scale={scale} />
326
410
  {saves}
327
411
  </>
328
412
  )
@@ -334,7 +418,8 @@ const MediaBody = observer(({ rv, id, v, i, zoom }: { rv: ReviewSt; id: string;
334
418
  <div style={scroll}>
335
419
  <div className="rv-pairgrid" style={{ width: scale ? `${v.size.w * scale * cols + 8 * (cols - 1)}px` : fitW, gridTemplateColumns: `repeat(${cols}, 1fr)` }}>
336
420
  <Compare c={c} base={before} mod={after} names={PAIR_NAMES} aspect={aspect}
337
- draw={(s) => <Marks rv={rv} src={s} side={drawnSide(c.mode, s === before ? 'before' : 'after')} view={i} />} />
421
+ draw={(s) => <Marks ver={ver} src={s} side={drawnSide(c.mode, s === before ? 'before' : 'after')} view={i} />}
422
+ over={(srcs) => (ver.live ? <RectNote card={card} view={i} sides={srcs.map((s) => drawnSide(c.mode, s === before ? 'before' : 'after'))} /> : null)} />
338
423
  </div>
339
424
  </div>
340
425
  {bar ? <div style={{ width: fitW, margin: '0 auto' }}>{bar}</div> : null}
@@ -345,39 +430,40 @@ const MediaBody = observer(({ rv, id, v, i, zoom }: { rv: ReviewSt; id: string;
345
430
  })
346
431
 
347
432
  /** a sound view: its waveform over the browser's player, one row a side on a pair, each to download */
348
- const SoundBody = ({ rv, id, v }: { rv: ReviewSt; id: string; v: MediaView }) => {
433
+ const SoundBody = ({ ver, v }: { ver: Ver; v: MediaView }) => {
434
+ const { rv } = ver
435
+ const item = itemOf(ver)
349
436
  const f = v.files
350
437
  const a = v.audio
351
438
  if (!a) return null
352
439
  const rows = isPair(f) ? [{ label: 'before', file: f.before, wave: a.waveBefore ?? a.wave }, { label: 'after', file: f.after, wave: a.wave }] : [{ label: '', file: 'audio' in f ? f.audio : '', wave: a.wave }]
353
440
  return (
354
- <div className="rv-sound">
441
+ <div className="rv-soundview">
355
442
  {rows.map((r) => (
356
443
  <div key={r.file} className="rv-soundrow">
357
444
  {r.label ? <div className="rv-dim">{r.label}</div> : null}
358
445
  <div role="img" aria-label={`the waveform of ${r.file}`} className="rv-wavebox" style={{ aspectRatio: `${v.size.w} / ${v.size.h}` }}>
359
- <Wave src={rv.fileUrl(id, r.wave)} className="rv-stripwave full" />
446
+ <Wave src={rv.fileUrl(item.id, r.wave)} className="rv-stripwave full" />
360
447
  </div>
361
- <audio controls preload="metadata" src={rv.fileUrl(id, r.file)} style={{ width: '100%' }} />
448
+ <audio controls preload="none" src={rv.fileUrl(item.id, r.file)} style={{ width: '100%' }} />
362
449
  </div>
363
450
  ))}
364
451
  <div className="rv-dim">{secs(a.duration)}</div>
365
- <Downloads rv={rv} id={id} files={rows.map((r) => ({ file: r.file, ...(r.label ? { label: r.label } : {}) }))} />
452
+ <Downloads rv={rv} item={item} files={rows.map((r) => ({ file: r.file, ...(r.label ? { label: r.label } : {}) }))} />
366
453
  </div>
367
454
  )
368
455
  }
369
456
 
370
- /** a view's files to save, each under the card's id and its own name */
371
- const Downloads = observer(({ rv, id, files }: { rv: ReviewSt; id: string; files: readonly { file: string; label?: string }[] }) => (
457
+ /** a view's files to save at full size, each under the card's id and its own name */
458
+ const Downloads = observer(({ rv, item, files }: { rv: ReviewSt; item: Item; files: readonly { file: string; label?: string }[] }) => (
372
459
  <div className="rv-downloads">
373
- {/* the Finder is on the desktop only: a phone has none */}
374
- {rv.phone.on ? null : <button className="rv-dl ghost" title="show the card's folder in the Finder" onClick={() => void rv.reveal(id)}>📁</button>}
375
460
  {files.map(({ file, label }) => (
376
- <span key={file}>
377
- <a className="rv-dl" href={rv.fileUrl(id, file)} download={`${id}-${file}`} title="download the file">⤓ {label ?? 'download'}</a>
378
- {rv.phone.on ? null : <button className="rv-dl ghost" title={`show ${file} in the Finder`} onClick={() => void rv.reveal(id, file)}>📂</button>}
379
- </span>
461
+ <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>
380
462
  ))}
463
+ {/* the Finder is on the desktop only: a phone has none */}
464
+ {rv.phone.on || files[0] === undefined ? null : (
465
+ <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>
466
+ )}
381
467
  </div>
382
468
  ))
383
469
 
@@ -388,8 +474,8 @@ const PAIR_SIDES: { value: PairSide; label: string }[] = [
388
474
  ]
389
475
 
390
476
  /** a pair on a phone: one side at a time full width, or the curtain; the zoom scrolls */
391
- const PhonePair = observer(({ rv, view, bar, before, after, aspect, size, scale }: {
392
- rv: ReviewSt
477
+ const PhonePair = observer(({ ver, view, bar, before, after, aspect, size, scale }: {
478
+ ver: Ver
393
479
  view: number
394
480
  bar: ReactNode
395
481
  before: string
@@ -398,6 +484,7 @@ const PhonePair = observer(({ rv, view, bar, before, after, aspect, size, scale
398
484
  size: { w: number; h: number }
399
485
  scale: number | null
400
486
  }) => {
487
+ const { rv, card } = ver
401
488
  const ph = rv.phone
402
489
  const c = rv.compare
403
490
  const side = ph.pair === 'swipe' && c.mode !== 'swipe' ? 'after' : ph.pair
@@ -412,9 +499,11 @@ const PhonePair = observer(({ rv, view, bar, before, after, aspect, size, scale
412
499
  <div style={scale ? { overflow: 'auto', maxHeight: '70vh' } : undefined}>
413
500
  <div style={{ width: scale ? `${size.w * scale}px` : '100%' }}>
414
501
  {side === 'swipe' ? (
415
- <Compare c={c} base={before} mod={after} names={PAIR_NAMES} aspect={aspect} draw={(s) => <Marks rv={rv} src={s} side={s === before ? 'before' : 'after'} view={view} />} />
502
+ <Compare c={c} base={before} mod={after} names={PAIR_NAMES} aspect={aspect} draw={(s) => <Marks ver={ver} src={s} side={s === before ? 'before' : 'after'} view={view} />}
503
+ over={(srcs) => (ver.live ? <RectNote card={card} view={view} sides={srcs.map((s) => (s === before ? 'before' : 'after'))} /> : null)} />
416
504
  ) : (
417
- <Compare key={side} c={c} base={one} mod={undefined} aspect={aspect} draw={(s) => <Marks rv={rv} src={s} side={side} view={view} />} />
505
+ <Compare key={side} c={c} base={one} mod={undefined} aspect={aspect} draw={(s) => <Marks ver={ver} src={s} side={side} view={view} />}
506
+ over={() => (ver.live ? <RectNote card={card} view={view} sides={[side]} /> : null)} />
418
507
  )}
419
508
  {bar}
420
509
  </div>
@@ -458,36 +547,37 @@ function track(move: (e: PointerEvent) => void): void {
458
547
  }
459
548
 
460
549
  /** THE pair: side by side, the curtain clipping both images, the after over the before as an onion skin, or the
461
- * after alone (the before while the pointer is over it). One image alone when `mod` is undefined */
462
- const Compare = observer(({ c, base, mod, names, aspect, draw }: { c: CompareSt; base: string; mod: string | undefined; names?: { base: string; mod: string }; aspect: string; draw: (src: string) => ReactNode }) => {
550
+ * after alone (the before while the pointer is over it). One image alone when `mod` is undefined. `over` draws what
551
+ * sits over a frame unclipped (the picked rectangle's note box), given the images that frame shows */
552
+ 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) => ReactNode; over?: (srcs: string[]) => ReactNode }) => {
463
553
  const [peek, setPeek] = useState(false)
464
- if (mod === undefined) return <Cell aspect={aspect} caption={null}><div className="rv-fill">{draw(base)}</div></Cell>
554
+ if (mod === undefined) return <Frame aspect={aspect} caption={null} over={over?.([base])}><div className="rv-fill">{draw(base)}</div></Frame>
465
555
  const n = names ?? PAIR_NAMES
466
556
  if (c.mode === 'side')
467
557
  return (
468
558
  <>
469
- <Cell aspect={aspect} caption={n.base}><div className="rv-fill">{draw(base)}</div></Cell>
470
- <Cell aspect={aspect} caption={n.mod} modCap><div className="rv-fill">{draw(mod)}</div></Cell>
559
+ <Frame aspect={aspect} caption={n.base} over={over?.([base])}><div className="rv-fill">{draw(base)}</div></Frame>
560
+ <Frame aspect={aspect} caption={n.mod} modCap over={over?.([mod])}><div className="rv-fill">{draw(mod)}</div></Frame>
471
561
  </>
472
562
  )
473
563
  if (c.mode === 'mod')
474
564
  return (
475
- <Cell aspect={aspect} caption={peek ? n.base : n.mod} modCap={!peek} onPeek={setPeek}>
565
+ <Frame aspect={aspect} caption={peek ? n.base : n.mod} modCap={!peek} onPeek={setPeek} over={over?.([peek ? base : mod])}>
476
566
  <div className="rv-fill">{draw(peek ? base : mod)}</div>
477
- </Cell>
567
+ </Frame>
478
568
  )
479
569
  const pct = Math.round(c.split * 100)
480
570
  return (
481
- <Cell aspect={aspect} caption={<>{n.base} {c.mode === 'swipe' ? '◀ ▶' : '+'} <span className="rv-modcap">{n.mod}</span></>} swipe={c.mode === 'swipe' ? c : undefined}>
571
+ <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])}>
482
572
  <div className="rv-fill" style={c.mode === 'swipe' ? { clipPath: `inset(0 ${100 - pct}% 0 0)` } : undefined}>{draw(base)}</div>
483
573
  <div className="rv-fill" style={c.mode === 'swipe' ? { clipPath: `inset(0 0 0 ${pct}%)` } : { opacity: c.opacity }}>{draw(mod)}</div>
484
574
  {c.mode === 'swipe' ? <div className="rv-curtain" style={{ left: `${pct}%` }} /> : null}
485
- </Cell>
575
+ </Frame>
486
576
  )
487
577
  })
488
578
 
489
- /** one frame and its caption; the curtain's line follows the pointer */
490
- const Cell = ({ aspect, caption, modCap, swipe, onPeek, children }: { aspect: string; caption: ReactNode; modCap?: boolean; swipe?: CompareSt | undefined; onPeek?: (on: boolean) => void; children: ReactNode }) => {
579
+ /** one frame and its caption; the curtain's line follows the pointer; `over` sits on the frame, free of its clip */
580
+ const Frame = ({ aspect, caption, modCap, swipe, onPeek, over, children }: { aspect: string; caption: ReactNode; modCap?: boolean; swipe?: CompareSt | undefined; onPeek?: (on: boolean) => void; over?: ReactNode; children: ReactNode }) => {
491
581
  const frame = useRef<HTMLDivElement>(null)
492
582
  const down = (e: React.PointerEvent): void => {
493
583
  const el = frame.current
@@ -502,9 +592,12 @@ const Cell = ({ aspect, caption, modCap, swipe, onPeek, children }: { aspect: st
502
592
  }
503
593
  return (
504
594
  <div className="rv-cell">
505
- <div ref={frame} className={`rv-frame${swipe ? ' swipe' : ''}`} style={{ aspectRatio: aspect }} onPointerDown={down}
506
- onMouseEnter={() => onPeek?.(true)} onMouseLeave={() => onPeek?.(false)}>
507
- {children}
595
+ <div className="rv-framebox">
596
+ <div ref={frame} className={`rv-frame${swipe ? ' swipe' : ''}`} style={{ aspectRatio: aspect }} onPointerDown={down}
597
+ onMouseEnter={() => onPeek?.(true)} onMouseLeave={() => onPeek?.(false)}>
598
+ {children}
599
+ </div>
600
+ {over ? <div className="rv-over">{over}</div> : null}
508
601
  </div>
509
602
  {caption != null ? <div className={`rv-caption${modCap ? ' mod' : ''}`}>{caption}</div> : null}
510
603
  </div>
@@ -519,18 +612,20 @@ const clamp01 = (v: number): number => Math.max(0, Math.min(1, v))
519
612
  /** a drag shorter than this, on either axis, is a click: it picks nothing */
520
613
  const MIN_DRAG = 0.01
521
614
 
522
- /** one image of view `view` and its rectangles; a drag on it draws one (never in the curtain, whose drag moves the
523
- * line). A clip view that is not the active one loops on its own: a click makes it active */
524
- const Marks = observer(({ rv, src, side, view }: { rv: ReviewSt; src: string; side: Side | undefined; view: number }) => {
615
+ /** one image of view `view` and its rectangles: the ones his answers sent (still), and on the newest version his
616
+ * draft's, a drag drawing one (never in the curtain, whose drag moves the line). A clip view of the newest version that
617
+ * is not the active one loops on its own: a click makes it active */
618
+ const Marks = observer(({ ver, src, side, view }: { ver: Ver; src: string; side: Side | undefined; view: number }) => {
619
+ const { rv, card, cell } = ver
525
620
  const el = useRef<HTMLDivElement>(null)
526
621
  const [drag, setDrag] = useState<{ x0: number; y0: number; x1: number; y1: number } | null>(null)
527
622
  const phone = rv.phone
528
- const any = rv.open?.item.views[view]
623
+ const any = itemOf(ver).views[view]
529
624
  const shown = any && !isGallery(any) ? any : undefined
530
625
  const clip = shown?.clip
531
- const active = rv.view === view
532
- const drawing = phone.on ? phone.draw && (side === undefined || phone.pair !== 'swipe' || rv.compare.mode !== 'swipe') : side === undefined || rv.compare.mode !== 'swipe'
533
- const c = rv.clipOf(view)
626
+ const active = card.view === view
627
+ const drawing = ver.live && (phone.on ? phone.draw && (side === undefined || phone.pair !== 'swipe' || rv.compare.mode !== 'swipe') : side === undefined || rv.compare.mode !== 'swipe')
628
+ const c = clip ? card.clipOf(cell.id, view) : null
534
629
  const at = (e: { clientX: number; clientY: number }): { x: number; y: number } => {
535
630
  const b = el.current?.getBoundingClientRect()
536
631
  if (!b) return { x: 0, y: 0 }
@@ -538,16 +633,16 @@ const Marks = observer(({ rv, src, side, view }: { rv: ReviewSt; src: string; si
538
633
  }
539
634
  const down = (e: React.PointerEvent): void => {
540
635
  if (e.button !== 0) return
541
- if (clip && !active) {
636
+ if (clip && ver.live && !active) {
542
637
  e.preventDefault()
543
- rv.setView(view)
638
+ card.setView(view)
544
639
  return
545
640
  }
546
641
  if (!drawing) return
547
642
  e.preventDefault()
548
643
  e.stopPropagation()
549
644
  // he draws on the paused frame: the rectangle keeps its time
550
- if (clip && !c.paused) c.pause()
645
+ if (c && !c.paused) c.pause()
551
646
  const a = at(e)
552
647
  let cur = { x0: a.x, y0: a.y, x1: a.x, y1: a.y }
553
648
  setDrag(cur)
@@ -562,23 +657,25 @@ const Marks = observer(({ rv, src, side, view }: { rv: ReviewSt; src: string; si
562
657
  window.removeEventListener('pointercancel', up)
563
658
  setDrag(null)
564
659
  const r = box(cur)
565
- if (r.w > MIN_DRAG && r.h > MIN_DRAG) rv.addRect(r, side, view)
566
- else rv.pickRect(null)
660
+ if (r.w > MIN_DRAG && r.h > MIN_DRAG) card.addRect(r, side, view)
661
+ else card.pickRect(null)
567
662
  }
568
663
  window.addEventListener('pointermove', move)
569
664
  window.addEventListener('pointerup', up)
570
665
  window.addEventListener('pointercancel', up)
571
666
  }
572
- const rects = rv.draft.rects.map((r, i) => [r, i] as const).filter(([r]) => r.side === side && (r.view ?? 0) === view)
573
- const onIts = (r: Rect): boolean => !clip || r.t === undefined || (c.paused && onFrame(r.t, c.time, clip.fps))
667
+ const rects = ver.live ? card.draft.rects.map((r, i) => [r, i] as const).filter(([r]) => r.side === side && (r.view ?? 0) === view) : []
668
+ const sent = card.sentRects(cell.id, view, side)
669
+ const onIts = (r: Rect): boolean => !clip || !c || r.t === undefined || (c.paused && onFrame(r.t, c.time, clip.fps))
574
670
  const rings = rv.marksOn ? (shown?.marks ?? []).filter((m) => m.side === side) : []
575
- const live = drawing || (clip !== undefined && !active)
671
+ const live = drawing || (clip !== undefined && ver.live && !active)
576
672
  return (
577
- <div ref={el} className={`rv-marks${clip && !active ? ' pick' : drawing ? ' draw' : ''}`} onPointerDown={down} style={{ pointerEvents: live ? 'auto' : 'none', touchAction: drawing ? 'none' : undefined }}>
578
- {clip ? <ClipVideo key={src} clip={c} src={src} /> : <img src={src} alt="" draggable={false} className="rv-markimg" />}
673
+ <div ref={el} className={`rv-marks${clip && ver.live && !active ? ' pick' : drawing ? ' draw' : ''}`} onPointerDown={down} style={{ pointerEvents: live ? 'auto' : 'none', touchAction: drawing ? 'none' : undefined }}>
674
+ {c ? <ClipVideo key={src} clip={c} src={src} poster={shown?.clip ? rv.fitUrl(cell.id, shown.clip.poster) : undefined} preload={ver.live ? 'auto' : 'none'} /> : <img src={src} alt="" draggable={false} className="rv-markimg" loading="lazy" decoding="async" />}
579
675
  {shown && rings.length > 0 ? <Rings marks={rings} w={shown.size.w} h={shown.size.h} /> : null}
676
+ {sent.map(({ r, n }, k) => <div key={`s${k}`} className={`rv-rect sent${onIts(r) ? '' : ' faint'}`} style={pct(r)} title={r.comment || `rectangle ${n}`}><span className="rv-rectn">{n}</span></div>)}
580
677
  {rects.map(([r, i]) => (
581
- <RectMark key={i} r={r} n={i + 1} on={rv.rect === i} faint={!onIts(r)} at={clip && r.t !== undefined ? secs(r.t) : undefined} pick={() => rv.pickRect(i)} />
678
+ <RectMark key={i} r={r} n={i + 1} on={card.rect === i} faint={!onIts(r)} at={clip && r.t !== undefined ? secs(r.t) : undefined} pick={() => card.pickRect(i, true)} />
582
679
  ))}
583
680
  {drag ? <div className="rv-drag" style={pct(box(drag))} /> : null}
584
681
  </div>
@@ -597,26 +694,67 @@ const Rings = ({ marks, w, h }: { marks: readonly ReviewMark[]; w: number; h: nu
597
694
  </svg>
598
695
  )
599
696
 
600
- /** a rectangle of his; on a clip, faint and dashed away from its frame, its time on its number */
697
+ /** a rectangle of his draft; on a clip, faint and dashed away from its frame, its time on its number */
601
698
  const RectMark = ({ r, n, on, faint, at, pick }: { r: Rect; n: number; on: boolean; faint: boolean; at: string | undefined; pick: () => void }) => (
602
- <div className={`rv-rect${on ? ' on' : ''}${faint ? ' faint' : ''}`} style={pct(r)} title={r.comment || `rectangle ${n}`}
603
- onPointerDown={(e) => { e.stopPropagation(); pick() }}>
604
- <span className="rv-rectn">{n}{at ? ` · ${at}` : ''}</span>
699
+ <div className={`rv-rect${on ? ' on' : ''}${faint ? ' faint' : ''}`} style={{ ...pct(r), pointerEvents: 'auto' }} title={r.comment || `rectangle ${n}`}
700
+ onPointerDown={(e) => { e.stopPropagation(); pick() }} onMouseDown={keepFocus}>
701
+ <span className="rv-rectn">{n}{at ? ` · ${at}` : ''}{!on && r.comment.trim() ? <span className="rv-rectword">{firstWords(r.comment)}</span> : null}</span>
605
702
  </div>
606
703
  )
607
704
 
705
+ /** the first words of a note, on its rectangle when its box is shut */
706
+ const firstWords = (s: string): string => {
707
+ const w = s.trim().split(/\s+/)
708
+ return w.length > 5 ? `${w.slice(0, 5).join(' ')}…` : w.join(' ')
709
+ }
710
+
711
+ /** the picked rectangle's note box, beside it on the image: under it, or over it when it sits low, focused once drawn
712
+ * or clicked. Enter or Escape closes it (the rectangle stays), Shift Enter is a new line; `sides` are the sides the
713
+ * frame shows */
714
+ const RectNote = observer(({ card, view, sides }: { card: ThreadSt; view: number; sides: readonly (Side | undefined)[] }) => {
715
+ const box = useRef<HTMLTextAreaElement | null>(null)
716
+ const i = card.rect
717
+ const r = i === null ? undefined : card.draft.rects[i]
718
+ const here = i !== null && r !== undefined && (r.view ?? 0) === view && sides.includes(r.side)
719
+ const focus = here && card.noteFocus === i
720
+ useEffect(() => {
721
+ if (!focus || box.current === null) return
722
+ box.current.focus()
723
+ card.noteFocused()
724
+ }, [focus, card])
725
+ if (!here) return null
726
+ const below = r.y + r.h <= NOTE_LOW || r.y < 1 - NOTE_LOW
727
+ const place = below ? { top: `${(r.y + r.h) * 100}%` } : { bottom: `${(1 - r.y) * 100}%` }
728
+ return (
729
+ <div className={`rv-note${below ? ' below' : ' above'}`} style={{ ...place, ['--nx' as string]: `${r.x * 100}%` }} onPointerDown={(e) => e.stopPropagation()}>
730
+ <span className="rv-noten">{i + 1}{r.t !== undefined ? ` · ${secs(r.t)}` : ''}</span>
731
+ <AutoText el={(t) => (box.current = t)} placeholder="what is wrong here · Enter closes" value={r.comment}
732
+ onText={(t) => card.setRectComment(i, t)}
733
+ onKeyDown={(e) => {
734
+ if ((e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing) || e.key === 'Escape') {
735
+ e.preventDefault()
736
+ card.pickRect(null)
737
+ }
738
+ }} />
739
+ <button className="ghost rv-x" title="delete this rectangle" aria-label="delete this rectangle" onMouseDown={keepFocus} onClick={() => card.removeRect(i)}>✕</button>
740
+ </div>
741
+ )
742
+ })
743
+ /** a rectangle whose bottom is lower than this share of the image opens its note over it, when there is room above */
744
+ const NOTE_LOW = 0.78
745
+
608
746
  // ── a clip ──
609
747
 
610
- /** one video of the open view, driven by the view's one clock; muted until the sound button, inline; looping, or at its
611
- * end waiting at the start */
612
- const ClipVideo = ({ clip, src, poster, loop = true }: { clip: ClipSt; src: string; poster?: string; loop?: boolean }) => {
748
+ /** one video of a view, driven by the view's one clock; muted until the sound button, inline; looping, or at its end
749
+ * waiting at the start. An older version's clip loads nothing until it plays */
750
+ const ClipVideo = ({ clip, src, poster, loop = true, preload = 'auto' }: { clip: ClipSt; src: string; poster?: string | undefined; loop?: boolean; preload?: 'auto' | 'none' }) => {
613
751
  const ref = useRef<HTMLVideoElement>(null)
614
752
  useEffect(() => {
615
753
  const el = ref.current
616
754
  if (!el) return
617
755
  return clip.attach(el)
618
756
  }, [clip, src])
619
- return <video ref={ref} className="rv-video" src={src} poster={poster} muted loop={loop} playsInline preload="auto" onEnded={loop ? undefined : () => clip.seek(0)} />
757
+ return <video ref={ref} className="rv-video" src={src} poster={poster} muted loop={loop} playsInline preload={preload} onEnded={loop ? undefined : () => clip.seek(0)} />
620
758
  }
621
759
 
622
760
  /** the sound button and the volume: a volume moved turns the sound on */