rvlib-shipkit 2.22.1 → 2.23.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 (52) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/package.json +1 -1
  3. package/src/annex/annex.ts +3 -0
  4. package/src/annex/born.ts +464 -0
  5. package/src/annex/flush.ts +46 -0
  6. package/src/annex/offload.ts +171 -38
  7. package/src/annex/snapshots.ts +53 -0
  8. package/src/annex/tidy.ts +368 -0
  9. package/src/checks/SK041-annex-links.check.ts +4 -2
  10. package/src/checks/SK043-scratch-on-the-mac.check.ts +45 -0
  11. package/src/cli/cmd_Annex.ts +60 -9
  12. package/src/cli/cmd_Home.ts +28 -0
  13. package/src/cli/cmd_Rec.ts +17 -7
  14. package/src/cli/cmd_Review.ts +27 -3
  15. package/src/core/machine-db.ts +8 -0
  16. package/src/home/claude-temp.ts +139 -0
  17. package/src/home/daemon-jobs.ts +10 -3
  18. package/src/home/global-units.ts +3 -0
  19. package/src/home/machine-stores.ts +27 -3
  20. package/src/home/pm.ts +4 -1
  21. package/src/home/run-pm.ts +1 -0
  22. package/src/identities/identities.ts +92 -24
  23. package/src/media-store/daemon.ts +2 -2
  24. package/src/media-store/purge.ts +4 -0
  25. package/src/recordings/load.ts +3 -3
  26. package/src/recordings/model.ts +7 -0
  27. package/src/recordings/open.ts +12 -0
  28. package/src/recordings/presets.ts +12 -5
  29. package/src/recordings/recorder-app/Capture.swift +34 -5
  30. package/src/recordings/recorder-app/Clip.swift +126 -17
  31. package/src/recordings/recorder-app/Editor.swift +177 -7
  32. package/src/recordings/recorder-app/Hud.swift +189 -0
  33. package/src/recordings/recorder-app/Tray.swift +179 -36
  34. package/src/recordings/recorder-app/icon.svg +16 -0
  35. package/src/recordings/recorder-app/main.swift +349 -18
  36. package/src/recordings/recorder-app.ts +8 -4
  37. package/src/recordings/recorder.shipkit.ts +2 -1
  38. package/src/recordings/routes.ts +52 -6
  39. package/src/recordings/run-recorder.ts +2 -1
  40. package/src/recordings/share.ts +27 -0
  41. package/src/recordings/take.ts +36 -4
  42. package/src/recordings/view.ts +11 -0
  43. package/src/repo-config.ts +9 -1
  44. package/src/review/model.ts +33 -4
  45. package/src/serve/hub-app/hub.css +4 -0
  46. package/src/serve/hub-app/recordings-st.ts +135 -24
  47. package/src/serve/hub-app/recordings-view.tsx +293 -54
  48. package/src/serve/hub-app/recordings.css +77 -24
  49. package/src/shipkit-files.ts +5 -0
  50. package/src/social/drafts.ts +4 -3
  51. package/src/social/load.ts +7 -2
  52. package/src/social/publish/discord.ts +10 -3
@@ -1,33 +1,60 @@
1
1
  // `/recordings`: one editor window. On top the repo filter, the record buttons and the gallery switch; the capture
2
- // picked (the newest unless the hash names one) big in the middle with its tools (select, arrow, rect, text, step,
3
- // blur, crop), colours and undo; a video's timeline under it, with trim handles and a lane per mark for its span; the
4
- // strip of every capture at the bottom, each thumb with copy file, copy link, Finder and delete. `#gallery` shows
5
- // every thumb big instead. The marks are drawn by marks-draw.ts, the same drawing the export burns in
2
+ // picked (the newest unless the hash names one) big in the middle, framed, under two rows: its tools (select, arrow,
3
+ // rect, text, step, blur, crop), colours, undo, what ⌘C copies and Save; then its name and where it stands (on disk,
4
+ // which save plays, up in the Space, its WebP). A video's timeline under it, with a cuts lane and a lane per mark for
5
+ // its span; the strip of every capture at the bottom, each thumb with copy file, copy link, Finder and delete.
6
+ // `#gallery` shows every thumb big instead. The marks are drawn by marks-draw.ts, the same drawing the export burns in
6
7
  import { autorun } from 'mobx'
7
8
  import { observer } from 'mobx-react-lite'
8
- import { useEffect, useRef, useState } from 'react'
9
+ import { useEffect, useLayoutEffect, useRef, useState } from 'react'
9
10
  import { canvasOf, printTime, type Crop } from '../../recordings/edit.ts'
10
11
  import { drawMark, type Ctx2D } from '../../recordings/marks-draw.ts'
11
12
  import { boundsOf, COLORS, HEX, moved, type Mark, type Pt } from '../../recordings/marks.ts'
12
- import { fileUrl, type RecView } from '../../recordings/view.ts'
13
+ import { ANIM_MAX_SECONDS, fileUrl, parseRecordingHash, type RecView } from '../../recordings/view.ts'
13
14
  import type { HomeSt } from './home-st.ts'
14
- import { TOOLS, type EditorSt, type RecordingsSt, type Tool } from './recordings-st.ts'
15
+ import { COPY_MODES, TOOLS, type CopyMode, type EditorSt, type RecordingsSt, type Tool } from './recordings-st.ts'
15
16
 
17
+ const size = (b: number): string => (b >= 1e6 ? `${(b / 1e6).toFixed(1)} MB` : `${Math.max(1, Math.round(b / 1e3))} KB`)
16
18
  const length = (r: RecView): string => (r.still ? 'still' : printTime(r.seconds).replace(/\.\d$/, ''))
17
19
  const poster = (r: RecView): string => fileUrl(r, 'poster.webp', `${r.current}-${r.edit.length}`)
18
20
 
19
21
  /** each tool's key alone, and Snagit's own on a Mac with ⌃ (Move ⌃V, Arrow ⌃A, Shape ⌃U, Text ⌃T, Step ⌃S, Blur ⌃B,
20
22
  * Crop ⌃C); ⌃1 to ⌃7 pick the tool at that place, as Snagit does on Windows */
21
- const TOOL_WORDS: Record<Tool, { label: string; name: string; key: string; ctrl: string; title: string }> = {
22
- select: { label: '↖', name: 'Move', key: 'v', ctrl: 'v', title: 'pick a mark, drag it, Delete removes it' },
23
- arrow: { label: '↗', name: 'Arrow', key: 'a', ctrl: 'a', title: 'drag from the tail to the point' },
24
- rect: { label: '▭', name: 'Shape', key: 'r', ctrl: 'u', title: 'drag a rectangle' },
25
- text: { label: 'T', name: 'Text', key: 't', ctrl: 't', title: 'click where the words go, type, Enter' },
26
- step: { label: '①', name: 'Step', key: 'n', ctrl: 's', title: 'click: a numbered step, the next number each time' },
27
- blur: { label: '▒', name: 'Blur', key: 'b', ctrl: 'b', title: 'drag over what must not show' },
28
- crop: { label: '⌗', name: 'Crop', key: 'c', ctrl: 'c', title: 'drag the part of the frame to keep' },
23
+ const TOOL_WORDS: Record<Tool, { name: string; key: string; ctrl: string; title: string }> = {
24
+ select: { name: 'Move', key: 'v', ctrl: 'v', title: 'pick a mark, drag it, Delete removes it' },
25
+ arrow: { name: 'Arrow', key: 'a', ctrl: 'a', title: 'drag from the tail to the point' },
26
+ rect: { name: 'Shape', key: 'r', ctrl: 'u', title: 'drag a rectangle' },
27
+ text: { name: 'Text', key: 't', ctrl: 't', title: 'click where the words go, type, Enter' },
28
+ step: { name: 'Step', key: 'n', ctrl: 's', title: 'click: a numbered step, the next number each time' },
29
+ blur: { name: 'Blur', key: 'b', ctrl: 'b', title: 'drag over what must not show' },
30
+ crop: { name: 'Crop', key: 'c', ctrl: 'c', title: 'drag the part of the frame to keep' },
29
31
  }
30
32
 
33
+ /** the toolbar's pictures, drawn on a 16 grid in the text's colour: a glyph of the font reads too small and too thin */
34
+ const ICONS = {
35
+ select: <path d="M4 2.2v10.6l2.9-2.7 1.8 4 1.7-.8-1.8-3.9h3.9z" fill="currentColor" />,
36
+ arrow: <path d="M3 13 12.5 3.5M6.5 3h6.5v6.5" />,
37
+ rect: <rect x="2.5" y="4" width="11" height="8" rx="1.2" />,
38
+ text: <path d="M3.5 5V3.5h9V5M8 3.5v9M6 12.5h4" />,
39
+ step: <><circle cx="8" cy="8" r="5.5" /><path d="M6.8 6.4 8.3 5.4v5.4" /></>,
40
+ blur: <g fill="currentColor" stroke="none">{[4, 8, 12].flatMap((y, j) => [4, 8, 12].map((x, i) => <circle key={`${x}-${y}`} cx={x} cy={y} r={i === 1 && j === 1 ? 1.6 : (i + j) % 2 === 1 ? 1.2 : 0.8} />))}</g>,
41
+ crop: <path d="M4.5 1.5v10h10M1.5 4.5h10v10" />,
42
+ nocrop: <path d="M4.5 1.5v10h10M1.5 4.5h10v10M2 14 14 2" />,
43
+ undo: <path d="M5.5 3.5 2.5 6.5l3 3M2.5 6.5h7a3.5 3.5 0 0 1 0 7H7" />,
44
+ redo: <path d="M10.5 3.5l3 3-3 3M13.5 6.5h-7a3.5 3.5 0 0 0 0 7H9" />,
45
+ trash: <path d="M3 4.5h10M6.5 4.5V3h3v1.5M4.5 4.5l.6 8.5h5.8l.6-8.5M6.8 7v4M9.2 7v4" />,
46
+ code: <path d="M5.5 4.5 2 8l3.5 3.5M10.5 4.5 14 8l-3.5 3.5" />,
47
+ copy: <><rect x="5.5" y="5.5" width="8" height="8" rx="1.2" /><path d="M10.5 3.5v-1h-8v8h1" /></>,
48
+ link: <path d="M6.8 9.2a2.6 2.6 0 0 0 3.7 0l2-2a2.6 2.6 0 0 0-3.7-3.7l-.7.7M9.2 6.8a2.6 2.6 0 0 0-3.7 0l-2 2a2.6 2.6 0 0 0 3.7 3.7l.7-.7" />,
49
+ folder: <path d="M2 4.5h4l1.5 1.5H14v6.5H2z" />,
50
+ check: <path d="M3.5 8.5l3 3 6-7" />,
51
+ grid: <><rect x="2.5" y="2.5" width="4.5" height="4.5" rx="1" /><rect x="9" y="2.5" width="4.5" height="4.5" rx="1" /><rect x="2.5" y="9" width="4.5" height="4.5" rx="1" /><rect x="9" y="9" width="4.5" height="4.5" rx="1" /></>,
52
+ back: <path d="M7 3.5 2.5 8 7 12.5M2.5 8h11" />,
53
+ play: <path d="M5 3.5v9l7-4.5z" fill="currentColor" />,
54
+ pause: <path d="M5.5 3.5v9M10.5 3.5v9" />,
55
+ }
56
+ const Ico = ({ n }: { n: keyof typeof ICONS }) => <svg className="rcico" viewBox="0 0 16 16" aria-hidden>{ICONS[n]}</svg>
57
+
31
58
  /** a tool's tooltip: its name and both its keys first, then what it does */
32
59
  export const toolTip = (t: Tool): string => `${TOOL_WORDS[t].name} · ${TOOL_WORDS[t].key.toUpperCase()} or ⌃${TOOL_WORDS[t].ctrl.toUpperCase()}: ${TOOL_WORDS[t].title}`
33
60
 
@@ -40,6 +67,74 @@ export function ctrlTool(key: string): Tool | null {
40
67
  return n >= 1 && n <= TOOLS.length ? TOOLS[n - 1]! : null
41
68
  }
42
69
 
70
+ /** the copy modes with the recorder tray's own colours: the file blue, WebP green, a link purple */
71
+ const COPY_WORDS: Record<CopyMode, { label: string; tip: string }> = {
72
+ file: { label: 'File', tip: 'the file: a video, or a screenshot as PNG (a paste attaches it, or pastes the image)' },
73
+ 'webp-hq': { label: 'WebP', tip: `a screenshot as WebP HQ (about a tenth of the PNG), a video as an animated WebP (made on its first copy, up to ${ANIM_MAX_SECONDS} s)` },
74
+ link: { label: 'Link', tip: 'a private link: it plays in a browser for 7 days' },
75
+ }
76
+
77
+ const CopyPick = observer(({ st, r }: { st: RecordingsSt; r: RecView }) => (
78
+ <span className="rccopy" role="radiogroup" aria-label="what ⌘C copies">
79
+ <span className="rckey">⌘C</span>
80
+ <span className="rcseg">
81
+ {COPY_MODES.map((m) => {
82
+ const off = m === 'webp-hq' && !r.still && r.seconds > ANIM_MAX_SECONDS
83
+ // a spinner while this mode cannot answer at once: its copy runs, or a link waits for the upload
84
+ const waits = st.copying === m || (m === 'link' && !r.up)
85
+ const tip = off ? `a video past ${ANIM_MAX_SECONDS} s makes no animated WebP: cut it first, or copy its file` : `⌘C copies ${COPY_WORDS[m].tip}${m === 'link' && !r.up ? ' (once the upload ends)' : ''}`
86
+ return (
87
+ <button key={m} type="button" role="radio" aria-checked={st.copyMode === m} className={`rcmode-${m}${st.copyMode === m ? ' on' : ''}`} disabled={off} onClick={() => st.setCopyMode(m)} data-tip={tip} aria-label={`⌘C copies ${COPY_WORDS[m].label}`}>
88
+ {waits ? <span className="rcspin sm" aria-hidden /> : <i aria-hidden />}
89
+ {COPY_WORDS[m].label}
90
+ </button>
91
+ )
92
+ })}
93
+ </span>
94
+ </span>
95
+ ))
96
+
97
+ type Box = { left: number; top: number; width: number; bottom: number }
98
+
99
+ /** where a w by h tooltip goes for an element at `at` in a vw by vh window: centred under it, above it when no room
100
+ * is left below, and never past an edge */
101
+ export function placeTip(at: Box, w: number, h: number, vw: number, vh: number, gap = 6): { left: number; top: number } {
102
+ const left = Math.max(gap, Math.min(at.left + at.width / 2 - w / 2, vw - w - gap))
103
+ const top = at.bottom + gap + h <= vh ? at.bottom + gap : Math.max(gap, at.top - gap - h)
104
+ return { left, top }
105
+ }
106
+
107
+ /** the page's tooltips: one box for every [data-tip], placed under its element (above when no room is left below)
108
+ * and kept inside the window, where a css box centred on its element runs off the edge */
109
+ const TipLayer = () => {
110
+ const [tip, setTip] = useState<{ text: string; at: DOMRect } | null>(null)
111
+ const box = useRef<HTMLDivElement>(null)
112
+ useEffect(() => {
113
+ const over = (e: PointerEvent): void => {
114
+ const el = (e.target as Element | null)?.closest?.('[data-tip]')
115
+ setTip(el ? { text: el.getAttribute('data-tip') ?? '', at: el.getBoundingClientRect() } : null)
116
+ }
117
+ const away = (): void => setTip(null)
118
+ document.addEventListener('pointerover', over)
119
+ document.addEventListener('pointerdown', away)
120
+ window.addEventListener('scroll', away, true)
121
+ return () => {
122
+ document.removeEventListener('pointerover', over)
123
+ document.removeEventListener('pointerdown', away)
124
+ window.removeEventListener('scroll', away, true)
125
+ }
126
+ }, [])
127
+ useLayoutEffect(() => {
128
+ const el = box.current
129
+ if (!el || !tip) return
130
+ const at = placeTip(tip.at, el.offsetWidth, el.offsetHeight, window.innerWidth, window.innerHeight)
131
+ el.style.left = `${at.left}px`
132
+ el.style.top = `${at.top}px`
133
+ el.style.visibility = 'visible'
134
+ }, [tip])
135
+ return tip && tip.text !== '' ? <div ref={box} className="rctip" role="tooltip">{tip.text}</div> : null
136
+ }
137
+
43
138
  // ---- the strip and the gallery
44
139
 
45
140
  const ThumbActions = observer(({ st, r }: { st: RecordingsSt; r: RecView }) => {
@@ -47,10 +142,10 @@ const ThumbActions = observer(({ st, r }: { st: RecordingsSt; r: RecView }) => {
47
142
  const armed = st.arming === `${r.repo}/${r.id}`
48
143
  return (
49
144
  <span className="rcacts">
50
- <button type="button" disabled={busy} data-tip="Copy the file" aria-label="copy the file" onClick={(e) => { e.stopPropagation(); void st.share(r, 'copy-file') }}>⧉</button>
51
- <button type="button" disabled={busy} data-tip="Copy a link (7 days)" aria-label="copy a link" onClick={(e) => { e.stopPropagation(); void st.share(r, 'link') }}>🔗</button>
52
- <button type="button" disabled={busy} data-tip="Show in Finder" aria-label="show in Finder" onClick={(e) => { e.stopPropagation(); void st.share(r, 'reveal') }}>📁</button>
53
- <button type="button" className={armed ? 'rcarmed' : ''} disabled={busy} data-tip={armed ? 'Click again: deleted for good' : 'Delete (click twice)'} aria-label="delete" onClick={(e) => { e.stopPropagation(); void st.remove(r) }}>{armed ? 'delete?' : '🗑'}</button>
145
+ <button type="button" disabled={busy} data-tip="Copy the file" aria-label="copy the file" onClick={(e) => { e.stopPropagation(); void st.share(r, 'copy-file') }}><Ico n="copy" /></button>
146
+ <button type="button" disabled={busy} data-tip="Copy a link (7 days)" aria-label="copy a link" onClick={(e) => { e.stopPropagation(); void st.share(r, 'link') }}><Ico n="link" /></button>
147
+ <button type="button" disabled={busy} data-tip="Show in Finder" aria-label="show in Finder" onClick={(e) => { e.stopPropagation(); void st.share(r, 'reveal') }}><Ico n="folder" /></button>
148
+ <button type="button" className={armed ? 'rcarmed' : ''} disabled={busy} data-tip={armed ? 'Click again: deleted for good' : 'Delete (click twice)'} aria-label="delete" onClick={(e) => { e.stopPropagation(); void st.remove(r) }}>{armed ? 'delete?' : <Ico n="trash" />}</button>
54
149
  </span>
55
150
  )
56
151
  })
@@ -60,8 +155,8 @@ const Thumb = observer(({ st, r, big }: { st: RecordingsSt; r: RecView; big?: bo
60
155
  return (
61
156
  <div className={`rcthumb${on ? ' on' : ''}${big ? ' big' : ''}`} role="button" tabIndex={0} title={`${r.repo}/${r.name}`} onClick={() => st.select(r)} onKeyDown={(e) => { if (e.key === 'Enter') st.select(r) }}>
62
157
  <img src={poster(r)} alt="" loading="lazy" />
63
- <span className="rctname">{r.name}{st.hasDraft(r) ? <i title="an edit not exported yet"> •</i> : null}</span>
64
- <span className="rctmeta">{r.repo} · {length(r)}{r.edit !== '' ? ' · edited' : ''}{r.local ? '' : ' · ☁︎'}{r.up ? '' : ' · uploading…'}</span>
158
+ <span className="rctname">{r.name}{st.hasDraft(r) ? <i title="an edit not saved yet"> •</i> : null}</span>
159
+ <span className="rctmeta">{r.repo} · {length(r)}{r.version > 0 ? ` · v${r.version}` : ''}{r.local ? '' : ' · ☁︎'}{r.up ? '' : ' · uploading…'}</span>
65
160
  <ThumbActions st={st} r={r} />
66
161
  </div>
67
162
  )
@@ -83,14 +178,17 @@ const Strip = observer(({ st }: { st: RecordingsSt }) => {
83
178
 
84
179
  // ---- the stage
85
180
 
86
- /** the size the frame takes inside its box, its proportions kept */
181
+ /** the ground left around the frame on every side, so its border always shows */
182
+ const STAGE_PAD = 14
183
+
184
+ /** the size the frame takes inside its box, its proportions kept, never past its own size twice over */
87
185
  function useFit(w: number, h: number): [React.RefObject<HTMLDivElement | null>, number] {
88
186
  const box = useRef<HTMLDivElement>(null)
89
187
  const [scale, setScale] = useState(0)
90
188
  useEffect(() => {
91
189
  const el = box.current
92
190
  if (!el) return
93
- const fit = (): void => setScale(Math.min(el.clientWidth / w, el.clientHeight / h))
191
+ const fit = (): void => setScale(Math.max(0, Math.min((el.clientWidth - STAGE_PAD * 2) / w, (el.clientHeight - STAGE_PAD * 2) / h, 2)))
94
192
  fit()
95
193
  const ro = new ResizeObserver(fit)
96
194
  ro.observe(el)
@@ -285,29 +383,44 @@ function dragTime(e: React.PointerEvent, track: HTMLElement, len: number, on: (t
285
383
 
286
384
  const Timeline = observer(({ ed }: { ed: EditorSt }) => {
287
385
  const track = useRef<HTMLDivElement>(null)
288
- const [trim, setTrim] = useState<{ from: number; to: number } | null>(null)
289
386
  const [lane, setLane] = useState<{ i: number; from: number; to: number } | null>(null)
387
+ const [paint, setPaint] = useState<{ from: number; to: number; back: boolean } | null>(null)
290
388
  const len = Math.max(ed.length, 0.001)
291
389
  const pct = (t: number): string => `${(t / len) * 100}%`
292
390
  const kept = ed.kept
293
- const a = trim?.from ?? kept[0]!.from
294
- const b = trim?.to ?? kept.at(-1)!.to
295
391
  const s = ed.selection
392
+ // the cuts lane: a drag paints a part out; started on a red part it puts that span back; a click on a red part
393
+ // puts the whole part back
394
+ const paintCut = (e: React.PointerEvent<HTMLDivElement>): void => {
395
+ const box = e.currentTarget.getBoundingClientRect()
396
+ const t0 = Math.min(ed.length, Math.max(0, ((e.clientX - box.left) / box.width) * ed.length))
397
+ const back = ed.removed.some((c) => t0 >= c.from && t0 <= c.to)
398
+ const span = (t: number): { from: number; to: number } => ({ from: Math.min(t0, t), to: Math.max(t0, t) })
399
+ dragTime(e, e.currentTarget, ed.length, (t) => setPaint({ ...span(t), back }), (t) => {
400
+ setPaint(null)
401
+ const p = span(t)
402
+ if (p.to - p.from >= 0.1) return ed.paint(t0, p)
403
+ const hit = ed.removed.find((c) => t0 >= c.from && t0 <= c.to)
404
+ if (hit) ed.restore(hit)
405
+ })
406
+ }
296
407
  const seek = (e: React.PointerEvent<HTMLDivElement>): void => dragTime(e, e.currentTarget, ed.length, (t) => ed.seek(t), (t) => ed.seek(t))
297
408
  return (
298
409
  <div className="rctl">
299
410
  <div ref={track} className="rcline" onPointerDown={seek} title="click or drag to move the playhead">
300
- <span className="rcout" style={{ left: 0, width: pct(a) }} />
301
- <span className="rcout" style={{ left: pct(b), right: 0 }} />
302
- {kept.map((k, i) => <span key={`k${i}`} className="rckeep" style={{ left: pct(Math.max(k.from, a)), width: pct(Math.max(0, Math.min(k.to, b) - Math.max(k.from, a))) }} />)}
411
+ {kept.map((k, i) => <span key={`k${i}`} className="rckeep" style={{ left: pct(k.from), width: pct(k.to - k.from) }} />)}
303
412
  {ed.edit.speed.map((p, i) => <span key={`s${i}`} className="rcspeed" style={{ left: pct(p.from), width: pct(p.to - p.from) }}>{p.factor}×</span>)}
304
413
  {s ? <span className="rcsel" style={{ left: pct(s.from), width: pct(s.to - s.from) }} /> : null}
305
414
  {ed.mark.in != null ? <span className="rcmark" style={{ left: pct(ed.mark.in) }} /> : null}
306
415
  {ed.mark.out != null ? <span className="rcmark" style={{ left: pct(ed.mark.out) }} /> : null}
307
- <span className="rchandle" style={{ left: pct(a) }} title="drag: where the video starts" onPointerDown={(e) => dragTime(e, track.current!, ed.length, (t) => setTrim({ from: Math.min(t, b - 0.2), to: b }), (t) => { setTrim(null); ed.setTrim(Math.min(t, b - 0.2), b) })} />
308
- <span className="rchandle end" style={{ left: pct(b) }} title="drag: where the video ends" onPointerDown={(e) => dragTime(e, track.current!, ed.length, (t) => setTrim({ from: a, to: Math.max(t, a + 0.2) }), (t) => { setTrim(null); ed.setTrim(a, Math.max(t, a + 0.2)) })} />
309
416
  <span className="rchead" style={{ left: pct(ed.time) }} />
310
417
  </div>
418
+ <div className="rccuts" onPointerDown={paintCut} data-tip="cuts: drag to paint a part red (it never plays, nor saves). Drag from a red part to put that span back, click a red part to put it all back">
419
+ <span className="rccutsname">cuts</span>
420
+ {ed.removed.map((c, i) => <span key={`c${i}`} className="rccut" style={{ left: pct(c.from), width: pct(c.to - c.from) }} />)}
421
+ {paint ? <span className={`rccut ${paint.back ? 'restoring' : 'painting'}`} style={{ left: pct(paint.from), width: pct(paint.to - paint.from) }} /> : null}
422
+ {ed.removed.length === 0 && !paint ? <span className="rccutshint">drag here to cut a part out</span> : null}
423
+ </div>
311
424
  {ed.marks.map((m, i) => {
312
425
  const sp = lane?.i === i ? lane : (m.span ?? { from: 0, to: ed.length })
313
426
  const color = m.kind === 'blur' ? 'var(--dim)' : HEX[m.color]
@@ -338,9 +451,78 @@ const Timeline = observer(({ ed }: { ed: EditorSt }) => {
338
451
  )
339
452
  })
340
453
 
454
+ // ---- where the capture stands
455
+
456
+ type Light = 'ok' | 'busy' | 'todo' | 'warn'
457
+
458
+ /** one step of where the capture stands: a light (green done, spinning now, hollow not yet, amber it waits on you),
459
+ * what the step is, and what is true of it */
460
+ const Chip = ({ light, name, text, tip, onClick, children }: { light: Light; name: string; text: string; tip: string; onClick?: () => void; children?: React.ReactNode }) => (
461
+ <span className={`rcchip ${light}${onClick ? ' act' : ''}`} data-tip={tip} role={onClick ? 'button' : 'status'} tabIndex={onClick ? 0 : undefined} onClick={onClick} onKeyDown={onClick ? (e) => { if (e.key === 'Enter') onClick() } : undefined}>
462
+ {light === 'busy' ? <span className="rcspin sm" aria-hidden /> : <i className="rclight" aria-hidden />}
463
+ <b>{name}</b>
464
+ <span>{text}</span>
465
+ {children}
466
+ </span>
467
+ )
468
+
469
+ const clock = (iso: string): string => {
470
+ const d = new Date(iso)
471
+ return Number.isNaN(d.getTime()) ? '' : `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`
472
+ }
473
+
474
+ /** every save of the edit, the newest first: one picked loads its edit in the editor, ⌘S then makes it play */
475
+ const Versions = observer(({ ed }: { ed: EditorSt }) => {
476
+ const vs = ed.rec.versions
477
+ if (vs.length === 0) return null
478
+ const now = ed.versionNow
479
+ return (
480
+ <select className="rcver" value={now == null ? 'new' : String(now)} aria-label="the saves of this capture" onClick={(e) => e.stopPropagation()} onChange={(e) => ed.loadVersion(Number(e.currentTarget.value))}>
481
+ {now == null ? <option value="new" disabled>v{ed.nextVersion} · new</option> : null}
482
+ {[...vs].reverse().map((v) => <option key={v.n} value={v.n}>v{v.n} · {clock(v.at)}{v.text === '' ? ' · the take whole' : ''}</option>)}
483
+ {vs.some((v) => v.text === '') ? null : <option value="0">the take as shot</option>}
484
+ </select>
485
+ )
486
+ })
487
+
488
+ /** where the capture stands, left to right as it happens: on the disk, which save plays, up in the Space, its WebP.
489
+ * Every step names the save it speaks of, so a change not saved yet never reads as up */
490
+ const Standing = observer(({ st, ed }: { st: RecordingsSt; ed: EditorSt }) => {
491
+ const r = ed.rec
492
+ const v = r.version > 0 ? `v${r.version}` : 'the take'
493
+ const what = r.still ? 'image' : 'video'
494
+ const edit: { light: Light; text: string; tip: string } = ed.exporting
495
+ ? { light: 'busy', text: `saving v${ed.nextVersion}…`, tip: `the ${r.still ? 'marks and the crop' : 'cuts, the speed, the marks and the crop'} are rendered into a new ${what}; the take itself never changes` }
496
+ : ed.parsed.error !== ''
497
+ ? { light: 'warn', text: 'its text has an error', tip: ed.parsed.error }
498
+ : ed.dirty
499
+ ? { light: 'warn', text: 'not saved', tip: `what shows is not in a file yet: ${v} still plays, copies and shares. ⌘S renders it as v${ed.nextVersion} and sends it up` }
500
+ : r.edit !== ''
501
+ ? { light: 'ok', text: 'saved', tip: `the edit is rendered into ${r.current}: it is what plays, copies and shares. ⌘S again changes nothing until the edit changes` }
502
+ : { light: 'todo', text: 'none', tip: 'no edit: the take plays as shot. Draw, cut or crop, then ⌘S saves it as a version' }
503
+ const tooLong = !r.still && r.seconds > ANIM_MAX_SECONDS
504
+ const lazy = `made on demand: the first ⌘C in WebP mode makes it (${r.still ? 'WebP HQ, about a tenth of the PNG' : 'an animated WebP, 15 fps, 800 px wide at most'}), then it is kept until another save plays`
505
+ const webp: { light: Light; text: string; tip: string } =
506
+ st.copying === 'webp-hq' && r.webp == null
507
+ ? { light: 'busy', text: 'making…', tip: lazy }
508
+ : r.webp != null
509
+ ? { light: 'ok', text: `${v} ready · ${size(r.webp)}`, tip: `the WebP of ${v} is made and kept: ⌘C in WebP mode copies it at once` }
510
+ : tooLong
511
+ ? { light: 'todo', text: `none past ${ANIM_MAX_SECONDS} s`, tip: `a video past ${ANIM_MAX_SECONDS} s makes no animated WebP: cut it first` }
512
+ : { light: 'todo', text: 'on first copy', tip: lazy }
513
+ return (
514
+ <span className="rcstanding" aria-label="where this capture stands">
515
+ <Chip light={r.local ? 'ok' : 'todo'} name="Disk" text={r.local ? `${v} · ${size(r.bytes)}` : 'not here'} tip={r.local ? `${r.current} is on the disk (${size(r.bytes)}). Click: show it in the Finder` : `${r.current} is off this disk: it plays from the Space, and comes back on a copy. Click: bring it back and show it in the Finder`} onClick={() => void st.share(r, 'reveal')} />
516
+ <Chip light={edit.light} name="Edit" text={edit.text} tip={`${edit.tip}. Every save that changed something is a version: pick one to load its edit again`}><Versions ed={ed} /></Chip>
517
+ <Chip light={r.up ? 'ok' : 'busy'} name="Space" text={r.up ? `${v} uploaded` : `uploading ${v} · ${size(r.bytes)}…`} tip={r.up ? `${r.current} is in the private Space: a link to it works now` : `${r.current} goes up to the private Space: a link works once it is up; editing and the file copy do not wait`} />
518
+ <Chip light={webp.light} name="WebP" text={webp.text} tip={webp.tip} />
519
+ </span>
520
+ )
521
+ })
522
+
341
523
  // ---- the editor
342
524
 
343
- const Editor = observer(({ st, ed, solo }: { st: RecordingsSt; ed: EditorSt; solo?: boolean }) => {
525
+ const Editor = observer(({ st, ed }: { st: RecordingsSt; ed: EditorSt }) => {
344
526
  const r = ed.rec
345
527
  const [name, setName] = useState(r.name)
346
528
  const [showText, setShowText] = useState(false)
@@ -363,6 +545,11 @@ const Editor = observer(({ st, ed, solo }: { st: RecordingsSt; ed: EditorSt; sol
363
545
  return void ed.save()
364
546
  }
365
547
  if (typing) return
548
+ // ⌘C copies the capture as the mode picked, unless text is selected on the page
549
+ if (e.metaKey && !e.shiftKey && !e.altKey && e.key.toLowerCase() === 'c' && (window.getSelection()?.toString() ?? '') === '') {
550
+ e.preventDefault()
551
+ return void st.copy(r)
552
+ }
366
553
  if (cmd && e.key.toLowerCase() === 'z') {
367
554
  e.preventDefault()
368
555
  return e.shiftKey ? ed.redo() : ed.undo()
@@ -377,6 +564,7 @@ const Editor = observer(({ st, ed, solo }: { st: RecordingsSt; ed: EditorSt; sol
377
564
  k: () => ed.trim(),
378
565
  f: () => ed.speed(2),
379
566
  m: () => ed.toggleMute(),
567
+ g: () => st.setGallery(true),
380
568
  Delete: () => ed.removeSelected(),
381
569
  Backspace: () => ed.removeSelected(),
382
570
  ArrowLeft: () => ed.nudge(e.shiftKey ? -0.1 : -1),
@@ -390,43 +578,57 @@ const Editor = observer(({ st, ed, solo }: { st: RecordingsSt; ed: EditorSt; sol
390
578
  }
391
579
  window.addEventListener('keydown', key)
392
580
  return () => window.removeEventListener('keydown', key)
393
- }, [ed])
581
+ }, [ed, st, r])
394
582
  return (
395
583
  <div className="rced">
396
584
  <div className="rctoolbar">
397
- <input className="rcrename" value={name} aria-label="its name" onChange={(e) => setName(e.currentTarget.value)} onBlur={() => void st.rename(r, name)} onKeyDown={(e) => { if (e.key === 'Enter') e.currentTarget.blur() }} title="its name: what a trailer, a link and this page say" />
398
- <select className="rcrepo" value={r.repo} aria-label="the repo it belongs to" title="the repo it belongs to: a trailer of that repo names it by its name" onChange={(e) => void st.move(r, e.currentTarget.value)}>
399
- {[...new Set([r.repo, ...(st.data?.repos ?? [])])].map((x) => <option key={x} value={x}>{x}</option>)}
400
- </select>
401
- <span className="rcgroup" role="toolbar" aria-label="tools">
585
+ <span className="rcgroup rctools" role="toolbar" aria-label="tools">
402
586
  {TOOLS.map((t) => (
403
- <button key={t} type="button" className={`rctool${ed.tool === t ? ' on' : ''}`} onClick={() => ed.setTool(t)} data-tip={toolTip(t)} aria-label={toolTip(t)}>{TOOL_WORDS[t].label}</button>
587
+ <button key={t} type="button" className={`rctool${ed.tool === t ? ' on' : ''}`} onClick={() => ed.setTool(t)} data-tip={toolTip(t)} aria-label={toolTip(t)}><Ico n={t} /></button>
404
588
  ))}
405
589
  </span>
406
590
  <span className="rcgroup" role="radiogroup" aria-label="colour">
407
591
  {COLORS.map((c) => <button key={c} type="button" className={`rcswatch${ed.color === c ? ' on' : ''}`} style={{ background: HEX[c] }} data-tip={c} aria-label={c} onClick={() => ed.setColor(c)} />)}
408
592
  </span>
409
- <span className="rcgroup">
410
- <button type="button" className="rctool" disabled={!ed.canUndo} onClick={() => ed.undo()} data-tip="Undo · ⌘Z" aria-label="undo">↶</button>
411
- <button type="button" className="rctool" onClick={() => ed.redo()} data-tip="Redo · ⌘⇧Z" aria-label="redo">↷</button>
412
- {ed.selected !== null ? <button type="button" className="rctool" onClick={() => ed.removeSelected()} data-tip="Remove the mark picked · Delete" aria-label="remove the mark">✕</button> : null}
413
- {ed.edit.crop ? <button type="button" className="rctool" onClick={() => ed.setCrop(null)} data-tip="No crop: the whole frame again" aria-label="no crop">⌗✕</button> : null}
593
+ <span className="rcgroup rctools">
594
+ <button type="button" className="rctool" disabled={!ed.canUndo} onClick={() => ed.undo()} data-tip="Undo · ⌘Z" aria-label="undo"><Ico n="undo" /></button>
595
+ <button type="button" className="rctool" onClick={() => ed.redo()} data-tip="Redo · ⌘⇧Z" aria-label="redo"><Ico n="redo" /></button>
596
+ {ed.selected !== null ? <button type="button" className="rctool" onClick={() => ed.removeSelected()} data-tip="Remove the mark picked · Delete" aria-label="remove the mark"><Ico n="trash" /></button> : null}
597
+ {ed.edit.crop ? <button type="button" className="rctool" onClick={() => ed.setCrop(null)} data-tip="No crop: the whole frame again" aria-label="no crop"><Ico n="nocrop" /></button> : null}
414
598
  </span>
415
599
  <span className="sp" />
416
- {st.current && !st.current.up ? <span className="rcup" data-tip="its links work once it is up; editing does not wait"><span className="acring on">↻</span> uploading…</span> : null}
417
- {solo ? <ThumbActions st={st} r={r} /> : null}
418
- <span className="acdim rcinfo">{r.repo} · {length(r)} · {r.width}×{r.height}{r.audio ? ' · sound' : ''}</span>
419
- <button type="button" className={`ghost hsm${showText ? ' on' : ''}`} onClick={() => setShowText(!showText)} title="the edit as text, the same one every tool writes">text</button>
420
- <button type="button" className="hbtn" disabled={!ed.dirty || ed.exporting || ed.parsed.error !== ''} onClick={() => void ed.save()} title="render the edit into what plays and shares (⌘S); the take never changes">
421
- {ed.exporting ? 'exporting…' : ed.dirty ? 'export' : 'exported'}
600
+ <button type="button" className="rctool rcalone" onClick={() => st.setGallery(true)} data-tip="All captures: every one as a grid of thumbnails · G" aria-label="all captures"><Ico n="grid" /></button>
601
+ <button type="button" className={`rctool rcalone${showText ? ' on' : ''}`} onClick={() => setShowText(!showText)} data-tip="The edit as text: the same one every tool writes, and you can type it" aria-label="the edit as text"><Ico n="code" /></button>
602
+ <CopyPick st={st} r={r} />
603
+ <button type="button" className={`rcsave${ed.dirty ? ' dirty' : ''}`} disabled={ed.exporting || ed.parsed.error !== ''} onClick={() => void ed.save()} data-tip={ed.dirty ? `⌘S: what shows (cuts, speed, marks, crop) rendered as v${ed.nextVersion} and sent up; the take never changes` : '⌘S: nothing to save, what shows is what plays and shares'}>
604
+ {ed.exporting ? <span className="rcspin sm" aria-hidden /> : ed.dirty ? null : <Ico n="check" />}
605
+ {ed.exporting ? `Saving v${ed.nextVersion}…` : ed.dirty ? 'Save' : 'Saved'}
606
+ <span className="rckey">⌘S</span>
422
607
  </button>
423
608
  </div>
424
- <Stage ed={ed} />
609
+ <div className="rcinforow">
610
+ <input className="rcrename" value={name} aria-label="its name" onChange={(e) => setName(e.currentTarget.value)} onBlur={() => void st.rename(r, name)} onKeyDown={(e) => { if (e.key === 'Enter') e.currentTarget.blur() }} data-tip="its name: what a trailer, a link and this page say" />
611
+ <select className="rcrepo" value={r.repo} aria-label="the repo it belongs to" data-tip="the repo it belongs to: a trailer of that repo names it by its name" onChange={(e) => void st.move(r, e.currentTarget.value)}>
612
+ {[...new Set([r.repo, ...(st.data?.repos ?? [])])].map((x) => <option key={x} value={x}>{x}</option>)}
613
+ </select>
614
+ <span className="rcinfo">{r.width}×{r.height}{r.still ? '' : ` · ${length(r)}`}{r.audio ? ' · sound' : ''}</span>
615
+ <span className="sp" />
616
+ <Standing st={st} ed={ed} />
617
+ </div>
618
+ <div className="rcstagebox">
619
+ <Stage ed={ed} />
620
+ {ed.exporting ? (
621
+ <div className="rcexporting" role="status">
622
+ <span className="rcspin" aria-hidden />
623
+ <span>saving v{ed.nextVersion}: {r.still ? 'the marks and the crop' : 'the cuts, the speed, the marks and the crop'} rendered into a new {r.still ? 'image' : 'video'}…</span>
624
+ </div>
625
+ ) : null}
626
+ </div>
425
627
  {r.still ? null : (
426
628
  <>
427
629
  <Timeline ed={ed} />
428
630
  <div className="rctransport">
429
- <button type="button" className="acpill" onClick={() => ed.toggle()} title="play or pause, the edit previewed (space)">{ed.playing ? '❚❚' : '▶'}</button>
631
+ <button type="button" className="rctool rcalone" onClick={() => ed.toggle()} data-tip="Play or pause, the edit previewed · Space" aria-label="play or pause"><Ico n={ed.playing ? 'pause' : 'play'} /></button>
430
632
  <span className="rctime">{printTime(ed.time)} / {printTime(ed.length)}</span>
431
633
  <button type="button" className="acpill" onClick={() => ed.setIn()} title="a part starts here (i)">in</button>
432
634
  <button type="button" className="acpill" onClick={() => ed.setOut()} title="the part ends here (o)">out</button>
@@ -448,6 +650,36 @@ const Editor = observer(({ st, ed, solo }: { st: RecordingsSt; ed: EditorSt; sol
448
650
  )
449
651
  })
450
652
 
653
+ // ---- every capture, in the recorder's window
654
+
655
+ /** the recorder window's gallery: every capture as a big thumb, by repo; a click opens one in the editor, Escape or
656
+ * the arrow goes back to the one that was open */
657
+ const SoloGallery = observer(({ st }: { st: RecordingsSt }) => {
658
+ useEffect(() => {
659
+ const key = (e: KeyboardEvent): void => {
660
+ if (e.key === 'Escape') st.setGallery(false)
661
+ }
662
+ window.addEventListener('keydown', key)
663
+ return () => window.removeEventListener('keydown', key)
664
+ }, [st])
665
+ return (
666
+ <>
667
+ <div className="rctop">
668
+ <button type="button" className="rctool rcalone" onClick={() => st.setGallery(false)} data-tip="Back to the editor · Esc" aria-label="back to the editor"><Ico n="back" /></button>
669
+ <b className="rcgtitle">All captures</b>
670
+ <span className="rcinfo">{st.shown.length}</span>
671
+ <div className="seg" role="radiogroup" aria-label="which repo">
672
+ <button role="radio" aria-checked={st.repo === ''} className={st.repo === '' ? 'on' : ''} onClick={() => st.setRepo('')}>all</button>
673
+ {st.repos.map((r) => <button key={r} role="radio" aria-checked={st.repo === r} className={st.repo === r ? 'on' : ''} onClick={() => st.setRepo(r)}>{r}</button>)}
674
+ </div>
675
+ <span className="sp" />
676
+ <span className="rcinfo">click one to edit it</span>
677
+ </div>
678
+ {st.shown.length === 0 ? <p className="acdim rcempty">{st.data == null ? 'reading…' : 'no capture here yet'}</p> : <div className="rcgallery">{st.shown.map((r) => <Thumb key={`${r.repo}/${r.id}`} st={st} r={r} big />)}</div>}
679
+ </>
680
+ )
681
+ })
682
+
451
683
  // ---- the page
452
684
 
453
685
  export const RecordingsView = observer(({ app, solo }: { app: HomeSt; solo?: boolean }) => {
@@ -456,18 +688,25 @@ export const RecordingsView = observer(({ app, solo }: { app: HomeSt; solo?: boo
456
688
  const ed = st.editor
457
689
  // the recorder's editor window: the capture alone, its share buttons in the toolbar, no list around it
458
690
  useEffect(() => {
459
- if (solo) st.fromHash(location.hash)
691
+ if (!solo) return
692
+ // `&draft=<edit text>`: the capture opens with that edit not saved yet, as a hand would leave it
693
+ const draft = new URLSearchParams(location.search).get('draft')
694
+ const open = parseRecordingHash(location.hash)
695
+ if (draft != null && open) st.seedDraft(open, draft)
696
+ st.fromHash(location.hash)
460
697
  }, [solo, st])
461
698
  if (solo)
462
699
  return (
463
700
  <div className="hall recordings rcapp rcsolo">
701
+ <TipLayer />
464
702
  {st.said ? <div className="rcsaid">{st.said}</div> : null}
465
703
  {st.error !== '' ? <div className="hnote">{st.error}</div> : null}
466
- {ed != null ? <Editor key={`${ed.rec.repo}/${ed.rec.id}`} st={st} ed={ed} solo /> : <p className="acdim rcempty">{d == null || st.loading ? 'reading…' : 'no such capture'}</p>}
704
+ {st.gallery ? <SoloGallery st={st} /> : ed != null ? <Editor key={`${ed.rec.repo}/${ed.rec.id}`} st={st} ed={ed} /> : <p className="acdim rcempty">{d == null || st.loading ? 'reading…' : 'no such capture'}</p>}
467
705
  </div>
468
706
  )
469
707
  return (
470
708
  <div className="hall recordings rcapp">
709
+ <TipLayer />
471
710
  <div className="rctop">
472
711
  <div className="seg" role="radiogroup" aria-label="which repo">
473
712
  <button role="radio" aria-checked={st.repo === ''} className={st.repo === '' ? 'on' : ''} onClick={() => st.setRepo('')}>all</button>