rvlib-shipkit 2.26.0 → 2.27.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 (442) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/package.json +1 -1
  3. package/src/agent-time/diet.ts +77 -0
  4. package/src/agent-time/family.ts +72 -0
  5. package/src/agent-time/hooks.ts +6 -4
  6. package/src/agent-time/limits.ts +44 -0
  7. package/src/agent-time/live.ts +1 -3
  8. package/src/agent-time/mask.ts +96 -18
  9. package/src/agent-time/refused.ts +45 -0
  10. package/src/agent-time/render.ts +122 -21
  11. package/src/agent-time/report-cache.ts +57 -0
  12. package/src/agent-time/report.ts +314 -40
  13. package/src/agent-time/shape.ts +50 -3
  14. package/src/agent-time/store.ts +320 -99
  15. package/src/agent-time/timeline.ts +140 -21
  16. package/src/agent-time/turns.ts +18 -8
  17. package/src/annex/offload.ts +17 -6
  18. package/src/annex/tidy.ts +70 -10
  19. package/src/asks/ask-after.ts +40 -0
  20. package/src/asks/asks-queue.ts +205 -47
  21. package/src/assets/kit-config.ts +7 -3
  22. package/src/assets/kits/identity-kit.ts +289 -10
  23. package/src/check.ts +3 -1
  24. package/src/checks/SK004-gitignore-policy.check.ts +12 -5
  25. package/src/checks/SK013-one-way-in-policy.check.ts +8 -3
  26. package/src/checks/SK026-asks-autoclose.check.ts +5 -5
  27. package/src/checks/SK028-readme.check.ts +7 -66
  28. package/src/checks/SK030-cache-audit.check.ts +6 -1
  29. package/src/checks/SK031-trace-audit.check.ts +2 -0
  30. package/src/checks/SK033-global-contribution.check.ts +3 -1
  31. package/src/checks/SK035-public-clean.check.ts +2 -2
  32. package/src/checks/SK043-scratch-on-the-mac.check.ts +59 -4
  33. package/src/checks/SK047-login-in-description.check.ts +36 -0
  34. package/src/checks/SK048-one-local-file.check.ts +36 -0
  35. package/src/cli/cmd_Asks.ts +71 -5
  36. package/src/cli/cmd_Backup.ts +2 -2
  37. package/src/cli/cmd_Capacity.ts +2 -2
  38. package/src/cli/cmd_CrossRepoActivity.ts +5 -4
  39. package/src/cli/cmd_Db.ts +253 -0
  40. package/src/cli/cmd_History.ts +212 -0
  41. package/src/cli/cmd_Home.ts +31 -3
  42. package/src/cli/cmd_Hq.ts +516 -0
  43. package/src/cli/cmd_Machines.ts +36 -0
  44. package/src/cli/cmd_Media.ts +38 -6
  45. package/src/cli/cmd_Reflect.ts +23 -2
  46. package/src/cli/cmd_Review.ts +548 -116
  47. package/src/cli/cmd_Secret.ts +62 -12
  48. package/src/cli/cmd_Social.ts +83 -1
  49. package/src/cli/cmd_Space.ts +324 -0
  50. package/src/cli/cmd_Time.ts +76 -5
  51. package/src/cli/cmd_Tmp.ts +28 -4
  52. package/src/cli/cmd_Trailer.ts +14 -10
  53. package/src/cli/cmd_Urls.ts +56 -0
  54. package/src/cli/cmd_Vault.ts +583 -0
  55. package/src/cli/family-help.ts +4 -2
  56. package/src/cli/family-pages.ts +1 -1
  57. package/src/cli/registry.ts +24 -3
  58. package/src/collections/actions.ts +63 -13
  59. package/src/collections/collection-types.ts +23 -1
  60. package/src/collections/providers.ts +117 -23
  61. package/src/collections/review.ts +4 -4
  62. package/src/contracts/contract-manifests.ts +6 -5
  63. package/src/contracts/contract-types.ts +6 -4
  64. package/src/contracts/contracts-engine.ts +11 -0
  65. package/src/contracts/manifests/chrome-web-store.contract.ts +31 -0
  66. package/src/core/budget.ts +12 -17
  67. package/src/core/capacity.ts +27 -18
  68. package/src/core/check-runner.ts +7 -4
  69. package/src/core/layout.ts +3 -0
  70. package/src/core/machine-busy.ts +127 -0
  71. package/src/core/machine-commit.ts +6 -1
  72. package/src/core/machine-db.ts +368 -20
  73. package/src/core/machine-layout.ts +137 -0
  74. package/src/core/machine-read.ts +81 -0
  75. package/src/core/migrate-layout.ts +1 -1
  76. package/src/core/one-way-in-policy.ts +64 -7
  77. package/src/core/polling-policy.ts +27 -0
  78. package/src/core/retention.ts +16 -2
  79. package/src/core/scope.ts +107 -14
  80. package/src/core/slots.ts +5 -4
  81. package/src/drill/clean.ts +25 -1
  82. package/src/drill/run.ts +1 -1
  83. package/src/drill/seal.ts +27 -4
  84. package/src/home/activity-shape.ts +2 -0
  85. package/src/home/activity.ts +66 -3
  86. package/src/home/app-sign.ts +15 -4
  87. package/src/home/daemon-jobs.ts +149 -7
  88. package/src/home/database-projects.ts +111 -0
  89. package/src/home/database-words.ts +203 -0
  90. package/src/home/databases.ts +460 -0
  91. package/src/home/global-units.ts +6 -0
  92. package/src/home/gui-app/ShipkitGui.swift +122 -1
  93. package/src/home/gui-app.ts +6 -3
  94. package/src/home/home-move.ts +514 -0
  95. package/src/home/home-paths.ts +12 -3
  96. package/src/home/home-routes.ts +68 -0
  97. package/src/home/inbox-shape.ts +24 -14
  98. package/src/home/machine-fold.ts +820 -0
  99. package/src/home/machine-host.ts +20 -5
  100. package/src/home/machine-repair.ts +503 -0
  101. package/src/home/machine-stores.ts +66 -15
  102. package/src/home/machine-temp.ts +547 -86
  103. package/src/home/resume.ts +79 -0
  104. package/src/home/run-daemon.ts +25 -4
  105. package/src/home/run-pm.ts +18 -5
  106. package/src/home/serve-daemon.ts +18 -3
  107. package/src/home/serve-web.ts +175 -7
  108. package/src/home/space-job.ts +115 -0
  109. package/src/home/space-page.ts +257 -0
  110. package/src/home/space-route.ts +167 -0
  111. package/src/home/space-words.ts +103 -0
  112. package/src/home/time-page-shape.ts +202 -0
  113. package/src/home/time-page.ts +64 -0
  114. package/src/home/vault-page.ts +482 -0
  115. package/src/home/vault-words.ts +132 -0
  116. package/src/hooks/leak-guard.ts +40 -13
  117. package/src/hooks/one-way-in-guard.ts +17 -4
  118. package/src/hq/cards.ts +581 -0
  119. package/src/hq/door-route.ts +43 -0
  120. package/src/hq/door.ts +163 -0
  121. package/src/hq/files-send.ts +348 -0
  122. package/src/hq/forgotten-log.ts +35 -0
  123. package/src/hq/history-check.ts +255 -0
  124. package/src/hq/history-place.ts +146 -0
  125. package/src/hq/history-send.ts +487 -0
  126. package/src/hq/hq-db.ts +99 -0
  127. package/src/hq/hq-local.ts +469 -0
  128. package/src/hq/hq-routes.ts +196 -0
  129. package/src/hq/hq-store.ts +599 -0
  130. package/src/hq/kinds/ask.ts +147 -0
  131. package/src/hq/kinds/card-gone.ts +83 -0
  132. package/src/hq/kinds/card-msg.ts +66 -0
  133. package/src/hq/kinds/card.ts +99 -0
  134. package/src/hq/kinds/index.ts +21 -0
  135. package/src/hq/kinds/kind.ts +126 -0
  136. package/src/hq/kinds/media.ts +125 -0
  137. package/src/hq/kinds/prompt.ts +219 -0
  138. package/src/hq/kinds/reflection.ts +128 -0
  139. package/src/hq/kinds/report.ts +55 -0
  140. package/src/hq/kinds/time-day.ts +236 -0
  141. package/src/hq/ledger.ts +473 -0
  142. package/src/hq/machine-key.ts +44 -0
  143. package/src/hq/machine-notes.ts +131 -0
  144. package/src/hq/outbox.ts +372 -0
  145. package/src/hq/replica.ts +168 -0
  146. package/src/hq/repo-id.ts +4 -0
  147. package/src/hq/report-facts.ts +117 -0
  148. package/src/hq/report.ts +274 -0
  149. package/src/hq/switch.ts +151 -0
  150. package/src/hq/vault-grant.ts +92 -0
  151. package/src/identities/identities.ts +15 -3
  152. package/src/identities/steps.ts +31 -0
  153. package/src/ledger/db.ts +73 -26
  154. package/src/ledger/gate-checks.ts +6 -2
  155. package/src/ledger/run-log.ts +11 -3
  156. package/src/ledger/store.ts +26 -4
  157. package/src/media-store/backup/daemon.ts +25 -17
  158. package/src/media-store/backup/kept.ts +241 -0
  159. package/src/media-store/backup/restore.ts +14 -4
  160. package/src/media-store/backup/run.ts +11 -11
  161. package/src/media-store/backup/secret.ts +6 -4
  162. package/src/media-store/backup/snapshot.ts +4 -2
  163. package/src/media-store/backup/sources.ts +67 -16
  164. package/src/media-store/copy/config.ts +77 -0
  165. package/src/media-store/copy/copy.ts +194 -0
  166. package/src/media-store/copy/lifecycle.ts +43 -0
  167. package/src/media-store/copy/night.ts +90 -0
  168. package/src/media-store/copy/proof.ts +151 -0
  169. package/src/media-store/copy/snapshot.ts +152 -0
  170. package/src/media-store/copy/store.ts +62 -0
  171. package/src/media-store/copy/stream.ts +176 -0
  172. package/src/media-store/daemon.ts +66 -16
  173. package/src/media-store/db.ts +22 -11
  174. package/src/media-store/forget.ts +23 -3
  175. package/src/media-store/hand.ts +4 -3
  176. package/src/media-store/hq-find.ts +75 -0
  177. package/src/media-store/hq-send.ts +277 -0
  178. package/src/media-store/kind.ts +2 -0
  179. package/src/media-store/purge.ts +18 -15
  180. package/src/media-store/put.ts +24 -8
  181. package/src/media-store/remote.ts +16 -7
  182. package/src/media-store/space-listing.ts +240 -0
  183. package/src/media-store/space.ts +40 -21
  184. package/src/media-store/sync.ts +5 -5
  185. package/src/media-store/tidy.ts +98 -0
  186. package/src/media-store/upload.ts +3 -3
  187. package/src/media-store/webp.ts +66 -0
  188. package/src/messages/model.ts +16 -7
  189. package/src/messages/routes.ts +14 -4
  190. package/src/messages/score.ts +2 -2
  191. package/src/messages/suggest.ts +96 -0
  192. package/src/pages/frame-client.ts +10 -0
  193. package/src/plan/planner.ts +28 -17
  194. package/src/recordings/media-kind.ts +1 -0
  195. package/src/recordings/model.ts +1 -1
  196. package/src/recordings/recorder-app/Capture.swift +9 -7
  197. package/src/reflect/hq-corpus.ts +56 -0
  198. package/src/reflect/prompt-corpus.ts +3 -1
  199. package/src/reflect/transcript.ts +129 -37
  200. package/src/release/machine-words.ts +67 -0
  201. package/src/release/public-clean.ts +8 -3
  202. package/src/releases/from-card.ts +1 -1
  203. package/src/releases/routes.ts +10 -5
  204. package/src/releases/store.ts +10 -1
  205. package/src/repo-config.ts +32 -2
  206. package/src/review/anim.ts +2 -2
  207. package/src/review/auto.ts +2 -2
  208. package/src/review/card-db.ts +244 -0
  209. package/src/review/card-rows.ts +266 -0
  210. package/src/review/cells.ts +76 -5
  211. package/src/review/draft-card.ts +41 -0
  212. package/src/review/draft-model.ts +78 -0
  213. package/src/review/format.ts +29 -10
  214. package/src/review/gone.ts +98 -0
  215. package/src/review/inbox-hook.ts +4 -4
  216. package/src/review/marks.ts +1 -1
  217. package/src/review/media-kind.ts +7 -5
  218. package/src/review/media-read.ts +9 -7
  219. package/src/review/media.ts +32 -5
  220. package/src/review/model.ts +202 -39
  221. package/src/review/move.ts +491 -0
  222. package/src/review/notes.ts +12 -20
  223. package/src/review/previews.ts +15 -19
  224. package/src/review/project.ts +1 -1
  225. package/src/review/rev.ts +8 -0
  226. package/src/review/role.ts +1 -1
  227. package/src/review/routes.ts +64 -13
  228. package/src/review/stage-card.ts +8 -4
  229. package/src/review/stage-routes.ts +1 -1
  230. package/src/review/store.ts +529 -83
  231. package/src/review/thread-fold.ts +51 -0
  232. package/src/review/threads.ts +147 -9
  233. package/src/review/trailer-auto-mock.ts +63 -0
  234. package/src/review/trailer-card.ts +4 -4
  235. package/src/review/trailer-desk.ts +41 -7
  236. package/src/review/trailer-media.ts +1 -0
  237. package/src/review/trailer-model.ts +8 -0
  238. package/src/review/trailer-notes.ts +1 -1
  239. package/src/review/trailer-routes.ts +9 -1
  240. package/src/review/unit.ts +6 -6
  241. package/src/review/watchers.ts +1 -1
  242. package/src/rules/untrack-generated.ts +92 -8
  243. package/src/secrets/held.ts +16 -0
  244. package/src/secrets/keychain.ts +113 -0
  245. package/src/secrets/list.ts +16 -6
  246. package/src/secrets/manager.ts +24 -10
  247. package/src/secrets/read.ts +257 -0
  248. package/src/secrets/who-reads.ts +49 -0
  249. package/src/serve/door-forward.ts +268 -0
  250. package/src/serve/door-names.ts +47 -0
  251. package/src/serve/embed.ts +1 -1
  252. package/src/serve/hub-app/activity-view.tsx +56 -32
  253. package/src/serve/hub-app/activity.css +7 -1
  254. package/src/serve/hub-app/asks-page.tsx +48 -0
  255. package/src/serve/hub-app/asks-st.ts +25 -0
  256. package/src/serve/hub-app/clock-svc.ts +1 -2
  257. package/src/serve/hub-app/col-card.tsx +64 -13
  258. package/src/serve/hub-app/col-list-page.tsx +122 -0
  259. package/src/serve/hub-app/col-list-st.ts +103 -0
  260. package/src/serve/hub-app/col-tables-view.tsx +10 -41
  261. package/src/serve/hub-app/col-tables.ts +76 -8
  262. package/src/serve/hub-app/cols-svc.ts +70 -16
  263. package/src/serve/hub-app/database-st.ts +260 -0
  264. package/src/serve/hub-app/database-view.tsx +289 -0
  265. package/src/serve/hub-app/database.css +32 -0
  266. package/src/serve/hub-app/entry-bar.css +14 -0
  267. package/src/serve/hub-app/entry-bar.tsx +33 -0
  268. package/src/serve/hub-app/entry-pick.ts +31 -0
  269. package/src/serve/hub-app/floating.tsx +1 -0
  270. package/src/serve/hub-app/hash-route.ts +11 -1
  271. package/src/serve/hub-app/header-bar.tsx +14 -18
  272. package/src/serve/hub-app/home-st.ts +89 -9
  273. package/src/serve/hub-app/home-strip.css +5 -19
  274. package/src/serve/hub-app/home-strip.tsx +58 -92
  275. package/src/serve/hub-app/home.html +7 -0
  276. package/src/serve/hub-app/hub-app.tsx +31 -142
  277. package/src/serve/hub-app/hub-types.ts +3 -1
  278. package/src/serve/hub-app/hub.css +109 -23
  279. package/src/serve/hub-app/icons.tsx +18 -1
  280. package/src/serve/hub-app/identities-st.ts +56 -6
  281. package/src/serve/hub-app/identities-view.tsx +100 -58
  282. package/src/serve/hub-app/identities.css +17 -15
  283. package/src/serve/hub-app/identity-address.ts +5 -0
  284. package/src/serve/hub-app/inbox-st.ts +41 -24
  285. package/src/serve/hub-app/inbox-view.tsx +37 -41
  286. package/src/serve/hub-app/inbox.css +2 -5
  287. package/src/serve/hub-app/index.html +7 -0
  288. package/src/serve/hub-app/kept-cols.tsx +7 -0
  289. package/src/serve/hub-app/keys.ts +28 -15
  290. package/src/serve/hub-app/later.tsx +26 -0
  291. package/src/serve/hub-app/list-filter.tsx +14 -0
  292. package/src/serve/hub-app/list-walk.ts +72 -3
  293. package/src/serve/hub-app/machines-st.ts +251 -0
  294. package/src/serve/hub-app/machines-view.tsx +224 -0
  295. package/src/serve/hub-app/machines.css +76 -0
  296. package/src/serve/hub-app/md-copy.tsx +79 -0
  297. package/src/serve/hub-app/media-view.tsx +2 -0
  298. package/src/serve/hub-app/messages/messages-page.tsx +79 -7
  299. package/src/serve/hub-app/messages/messages-st.ts +99 -3
  300. package/src/serve/hub-app/messages.css +14 -0
  301. package/src/serve/hub-app/page-keys.ts +175 -0
  302. package/src/serve/hub-app/pages-frames.tsx +11 -3
  303. package/src/serve/hub-app/palette-st.ts +58 -11
  304. package/src/serve/hub-app/palette-view.tsx +3 -1
  305. package/src/serve/hub-app/project-list.css +54 -8
  306. package/src/serve/hub-app/project-list.tsx +128 -59
  307. package/src/serve/hub-app/projects-svc.ts +78 -7
  308. package/src/serve/hub-app/reader-chips.tsx +13 -0
  309. package/src/serve/hub-app/readme-view.tsx +2 -3
  310. package/src/serve/hub-app/readme.css +27 -5
  311. package/src/serve/hub-app/reflections-page.tsx +42 -0
  312. package/src/serve/hub-app/reflections-st.ts +17 -0
  313. package/src/serve/hub-app/releases/releases-page.tsx +25 -2
  314. package/src/serve/hub-app/releases/releases-st.ts +1 -1
  315. package/src/serve/hub-app/repo-sections.ts +9 -5
  316. package/src/serve/hub-app/repo-st.ts +35 -8
  317. package/src/serve/hub-app/review/draft-card.tsx +163 -0
  318. package/src/serve/hub-app/review/kit.tsx +50 -7
  319. package/src/serve/hub-app/review/note-place.ts +1 -1
  320. package/src/serve/hub-app/review/review-board.tsx +2 -2
  321. package/src/serve/hub-app/review/review-cells.tsx +145 -65
  322. package/src/serve/hub-app/review/review-kit.ts +27 -1
  323. package/src/serve/hub-app/review/review-list.tsx +68 -30
  324. package/src/serve/hub-app/review/review-page.tsx +7 -8
  325. package/src/serve/hub-app/review/review-st.ts +111 -24
  326. package/src/serve/hub-app/review/review-thread.tsx +49 -19
  327. package/src/serve/hub-app/review/review-views.tsx +475 -144
  328. package/src/serve/hub-app/review/thread-control-st.ts +115 -0
  329. package/src/serve/hub-app/review/thread-control.tsx +74 -0
  330. package/src/serve/hub-app/review/thread-st.ts +73 -26
  331. package/src/serve/hub-app/review/trailer-card.tsx +1 -1
  332. package/src/serve/hub-app/review/trailer-page.tsx +37 -16
  333. package/src/serve/hub-app/review/trailer-st.ts +41 -7
  334. package/src/serve/hub-app/review.css +267 -61
  335. package/src/serve/hub-app/side-lists.ts +72 -0
  336. package/src/serve/hub-app/sidebar.tsx +6 -3
  337. package/src/serve/hub-app/site/site-part.tsx +2 -8
  338. package/src/serve/hub-app/site/site-st.ts +4 -4
  339. package/src/serve/hub-app/social/comms-page.tsx +20 -5
  340. package/src/serve/hub-app/social/kit.tsx +30 -4
  341. package/src/serve/hub-app/social/post-card.tsx +139 -49
  342. package/src/serve/hub-app/social/serial-writes.ts +13 -0
  343. package/src/serve/hub-app/social/social-model.ts +11 -0
  344. package/src/serve/hub-app/social/social-page.tsx +94 -35
  345. package/src/serve/hub-app/social/social-st.ts +120 -36
  346. package/src/serve/hub-app/social/stage-popup.tsx +1 -1
  347. package/src/serve/hub-app/social/stage-st.ts +1 -1
  348. package/src/serve/hub-app/social/step-layout.ts +1 -1
  349. package/src/serve/hub-app/social.css +3 -0
  350. package/src/serve/hub-app/space-st.ts +209 -0
  351. package/src/serve/hub-app/space-view.tsx +196 -0
  352. package/src/serve/hub-app/space.css +27 -0
  353. package/src/serve/hub-app/stores/stores-page.tsx +91 -23
  354. package/src/serve/hub-app/stores/stores-st.ts +44 -19
  355. package/src/serve/hub-app/stores.css +6 -1
  356. package/src/serve/hub-app/theme-st.ts +22 -9
  357. package/src/serve/hub-app/time-charts.tsx +291 -0
  358. package/src/serve/hub-app/time-pages.tsx +749 -0
  359. package/src/serve/hub-app/time-st.ts +162 -0
  360. package/src/serve/hub-app/time-view.tsx +76 -0
  361. package/src/serve/hub-app/time.css +138 -0
  362. package/src/serve/hub-app/tree-build.ts +52 -42
  363. package/src/serve/hub-app/tree-row.tsx +4 -4
  364. package/src/serve/hub-app/tree-svc.ts +18 -9
  365. package/src/serve/hub-app/urls-svc.ts +154 -0
  366. package/src/serve/hub-app/urls-view.tsx +117 -0
  367. package/src/serve/hub-app/urls.css +30 -0
  368. package/src/serve/hub-app/vault-st.ts +127 -0
  369. package/src/serve/hub-app/vault-view.tsx +154 -0
  370. package/src/serve/hub-app/vault.css +38 -0
  371. package/src/serve/hub-app/veille/veille-st.ts +12 -10
  372. package/src/serve/hub-app/waiting-svc.ts +29 -0
  373. package/src/serve/hub-app/wikis-view.tsx +2 -2
  374. package/src/serve/hub-runtime.ts +15 -2
  375. package/src/serve/project-gutter-route.ts +27 -14
  376. package/src/serve/project-gutter.ts +25 -12
  377. package/src/serve/same-origin.ts +10 -0
  378. package/src/serve/serve-hub.ts +13 -4
  379. package/src/shipkit-files.ts +16 -2
  380. package/src/shipkit.ts +1 -1
  381. package/src/shot/shooter.ts +616 -420
  382. package/src/shot/shot-ask.ts +246 -155
  383. package/src/site/desk.ts +2 -2
  384. package/src/smoke/run-smoke.ts +3 -2
  385. package/src/social/cover.ts +202 -0
  386. package/src/social/discord-layout.ts +37 -13
  387. package/src/social/drafts.ts +3 -0
  388. package/src/social/load.ts +23 -2
  389. package/src/social/media-kind.ts +2 -1
  390. package/src/social/publish/discord.ts +5 -2
  391. package/src/social/publish/secret.ts +2 -2
  392. package/src/social/release-stage.ts +28 -13
  393. package/src/social/routes.ts +26 -1
  394. package/src/social/stage.ts +1 -1
  395. package/src/social/stats.ts +12 -9
  396. package/src/social/strip.ts +4 -1
  397. package/src/social/thumbnail.ts +255 -0
  398. package/src/stores/collection.ts +15 -11
  399. package/src/stores/desk.ts +236 -42
  400. package/src/stores/model.ts +72 -6
  401. package/src/stores/routes.ts +37 -12
  402. package/src/stores/unit.ts +14 -8
  403. package/src/suite/judge-suites.ts +41 -11
  404. package/src/suite/select.ts +45 -3
  405. package/src/suite/suite-cli.ts +16 -10
  406. package/src/trailer/bed.ts +1 -1
  407. package/src/trailer/build.ts +134 -21
  408. package/src/trailer/ffmpeg.ts +7 -0
  409. package/src/trailer/fonts.ts +3 -2
  410. package/src/trailer/grammar.ts +201 -2
  411. package/src/trailer/graph.ts +42 -5
  412. package/src/trailer/look.ts +21 -0
  413. package/src/trailer/mock.ts +154 -0
  414. package/src/trailer/passage.ts +65 -26
  415. package/src/trailer/score/heard.ts +89 -0
  416. package/src/trailer/score/sound.ts +14 -8
  417. package/src/trailer/sound/run.ts +16 -6
  418. package/src/trailer/stitch.ts +26 -5
  419. package/src/trailer/titles.ts +82 -19
  420. package/src/trailer/versions.ts +1 -3
  421. package/src/trailer/vertical.ts +3 -1
  422. package/src/urls/frame.ts +195 -0
  423. package/src/urls/routes.ts +43 -0
  424. package/src/urls/rows.ts +171 -0
  425. package/src/urls/unit.ts +73 -0
  426. package/src/vault/house-keys.ts +42 -0
  427. package/src/vault/layout.ts +50 -0
  428. package/src/vault/policy.ts +165 -0
  429. package/src/vault/vault-audit.ts +276 -0
  430. package/src/vault/vault-client.ts +40 -0
  431. package/src/vault/vault-config.ts +159 -0
  432. package/src/vault/vault-destroy.ts +78 -0
  433. package/src/vault/vault-handover.ts +305 -0
  434. package/src/vault/vault-http.ts +352 -0
  435. package/src/vault/vault-import.ts +208 -0
  436. package/src/vault/vault-init.ts +328 -0
  437. package/src/vault/vault-minter.ts +271 -0
  438. package/src/vault/vault-restore.ts +333 -0
  439. package/src/vault/vault-serve.ts +342 -0
  440. package/src/vault/vault-snapshot.ts +281 -0
  441. package/src/veille/asks.ts +1 -1
  442. package/src/veille/desk.ts +2 -2
@@ -6,19 +6,21 @@
6
6
  // under its row
7
7
  import { observer } from 'mobx-react-lite'
8
8
  import { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react'
9
+ import { createPortal } from 'react-dom'
9
10
  import type { VersionCell } from '../../../review/cells.ts'
10
- import { isChoice, isGallery, isPair, onFrame, STARS, STATUS_LABEL, thumbFileOf, tileName, viewFilesOf, viewName, viewTag, type GalleryTile, type GalleryView, type Item, type MediaView, type Rect, type ReviewClip, type ReviewMark, type ReviewView, type Side } from '../../../review/model.ts'
11
+ import { isChoice, isGallery, isPair, onFrame, STARS, STATUS_LABEL, thumbFileOf, tileName, viewFilesOf, viewName, viewTag, type GalleryTile, type GalleryView, type Item, type MediaView, type Rect, type ReviewClip, type ReviewMark, type ReviewStatus, type ReviewView, type Side } from '../../../review/model.ts'
11
12
  import { AutoText } from '../auto-text.tsx'
12
13
  import type { ClipSt } from './clip-st.ts'
13
- import { blurOnEscape, FIT_ROOM, keepFocus, PAIR_NAMES, REACTIONS, secs, SIDE_LABEL } from './kit.tsx'
14
- import { GALLERY_FITS, GALLERY_MODES, TILE_H, ZOOMS, type GalleryFit, type GalleryMode, type Zoom } from './review-kit.ts'
14
+ import { blurOnEscape, boxReaction, FIT_ROOM, keepFocus, Key, PAIR_NAMES, PLACE_TIPS, REACTIONS, secs, SIDE_LABEL } from './kit.tsx'
15
+ import { BOX_ZOOM, boxStep, GALLERY_FITS, GALLERY_MODES, PREVIEW_H, TILE_H, ZOOMS, type BoxZoom, type GalleryFit, type GalleryMode, type Zoom } from './review-kit.ts'
15
16
  import { notePlace } from './note-place.ts'
16
17
  import { COMPARE_MODES, drawnSide, type CompareMode, type CompareSt, type PairSide, type ReviewSt } from './review-st.ts'
17
- import { TILE_FILTERS, viewDom, viewKind, viewKey, type ThreadSt, type TileFilter } from './thread-st.ts'
18
- import { Caret } from '../icons.tsx'
18
+ import { TILE_FILTERS, viewDom, viewKind, viewKey, type SaidNote, type ThreadSt, type TileFilter } from './thread-st.ts'
19
+ import { Caret, Icon, ICON } from '../icons.tsx'
20
+ import { Pop } from '../floating.tsx'
19
21
 
20
- const ZOOM_LABEL: Record<Zoom, string> = { fit: 'Fit', '1': '100 %', '1.5': '150 %', '2': '200 %' }
21
- const toneClass = (s: string | undefined): string => (s ? ` re-${s}` : '')
22
+ const ZOOM_LABEL: Record<Zoom, string> = { preview: 'Preview', fit: 'Fit', '1': '100 %', '1.5': '150 %', '2': '200 %' }
23
+ export const toneClass = (s: string | undefined): string => (s ? ` re-${s}` : '')
22
24
 
23
25
  /** one version as its views draw it: `live` when his answer goes to it and it draws his draft; `claim` when it is the
24
26
  * newest while his answer sits on an older version: it takes his marks, and the first one brings his answer here */
@@ -32,9 +34,9 @@ export interface Ver {
32
34
 
33
35
  const itemOf = (ver: Ver): Item => ver.cell.item
34
36
  /** the version takes his marks: OK, Fix, No, a rectangle, a word, a star, a pick */
35
- const takes = (ver: Ver): boolean => ver.live || ver.claim
37
+ export const takes = (ver: Ver): boolean => ver.live || ver.claim
36
38
  /** a mark on a claiming version: his answer comes to it first, then the mark lands in its own draft */
37
- const mark = (ver: Ver, f: () => void): void => {
39
+ export const mark = (ver: Ver, f: () => void): void => {
38
40
  if (ver.claim) ver.card.answerNewest()
39
41
  f()
40
42
  }
@@ -84,34 +86,45 @@ export const VersionViews = observer(({ ver }: { ver: Ver }) => {
84
86
  })
85
87
 
86
88
  /** one view as a sub cell: its number and title, its kind, the owner's reaction, its tools, what was said on it and his word, then the view */
87
- export const ViewCell = observer(({ ver, v: live, i, frames, noted = true }: { ver: Ver; v: ReviewView; i: number; frames?: GalleryView; noted?: boolean }) => {
89
+ export const ViewCell = observer(({ ver, v: live, i, frames, noted = true, boxed = false }: { ver: Ver; v: ReviewView; i: number; frames?: GalleryView; noted?: boolean; boxed?: boolean }) => {
88
90
  const { rv, card, cell } = ver
89
91
  const past = frames && card.frame !== null ? frames.gallery[card.frame] : undefined
90
92
  const v: ReviewView = past && !isGallery(live) ? { ...live, files: { image: past.file }, size: past.size } : live
91
93
  const media = isGallery(v) ? null : v
92
94
  const open = card.viewOpen(cell.id, i)
93
- const zoom = rv.zoom
95
+ // the lightbox draws the view at its own size (ViewBox holds the control), whatever the thread's zoom
96
+ const zoom: Zoom | BoxZoom = boxed ? rv.boxZoom : rv.zoom
94
97
  const shown = card.reactionShown(cell, i)
95
98
  const active = ver.live && card.view === i
96
99
  const gone = goneOf(ver, v)
100
+ const body = gone.length > 0 ? <Gone files={gone} /> : isGallery(v) ? <Gallery ver={ver} v={v} view={i} head={!boxed} /> : <MediaBody ver={ver} v={v} i={i} zoom={zoom} boxed={boxed} />
101
+ // the lightbox draws its own bars around the view (ViewBox): the cell is its body alone
102
+ if (boxed)
103
+ return (
104
+ <section className={`rv-view boxed${toneClass(shown?.status)}`}>
105
+ {frames ? <FrameSlider card={card} frames={frames} /> : null}
106
+ {body}
107
+ </section>
108
+ )
97
109
  return (
98
110
  <section id={viewDom(cell.id, i)} className={`rv-view${toneClass(shown?.status)}${active ? ' active' : ''}${open ? '' : ' folded'}`}>
99
111
  <header className="rv-viewhead">
100
112
  <button className="rv-foldbtn" aria-label={open ? 'fold this view' : 'unfold this view'} aria-expanded={open} onMouseDown={keepFocus} onClick={() => card.toggleView(cell.id, i)}><Caret open={open} /></button>
101
- <span className="rv-viewn">{viewTag(cell.n, i)}</span>
102
- <h4 className="rv-viewname" onClick={() => card.toggleView(cell.id, i)}>{v.label || <span className="rv-dim">{viewName(v, i)}</span>}</h4>
103
- <span className="rv-kind">{viewKind(v, false)}</span>
113
+ <h4 className="rv-viewname" onClick={() => card.toggleView(cell.id, i)}>{v.label || <span className="rv-dim">{viewKind(v, false)}</span>}</h4>
114
+ {v.label ? <span className="rv-kind">{viewKind(v, false)}</span> : null}
104
115
  {takes(ver) ? <ReactionToggles ver={ver} view={i} /> : shown?.status ? <SentReaction status={shown.status} /> : null}
105
116
  <span className="sp" />
106
117
  {open && media?.marks && media.marks.length > 0 ? <button className={rv.marksOn ? 'primary' : ''} onMouseDown={keepFocus} onClick={() => rv.toggleMarks()}>marks · M</button> : null}
107
- {open && media && isPair(media.files) && !media.audio && !rv.phone.on ? <CompareModes c={rv.compare} clip={media.clip !== undefined} /> : null}
118
+ {/* the compare modes act on a pair drawn full: a preview has none */}
119
+ {open && zoom !== 'preview' && media && isPair(media.files) && !media.audio && !rv.phone.on ? <CompareModes c={rv.compare} clip={media.clip !== undefined} /> : null}
108
120
  <StageButtons ver={ver} v={v} i={i} />
121
+ <span className="rv-viewn" title={`view ${viewTag(cell.n, i)}`}>{viewTag(cell.n, i)}</span>
109
122
  </header>
110
123
  <ViewNotes ver={ver} i={i} gallery={isGallery(v)} />
111
124
  {open ? (
112
125
  <div className="rv-viewbody">
113
126
  {frames ? <FrameSlider card={card} frames={frames} /> : null}
114
- {gone.length > 0 ? <Gone files={gone} /> : isGallery(v) ? <Gallery ver={ver} v={v} view={i} /> : <MediaBody ver={ver} v={v} i={i} zoom={zoom} />}
127
+ {body}
115
128
  {noted && media?.note ? <div className="rv-viewnote">{media.note}</div> : null}
116
129
  </div>
117
130
  ) : null}
@@ -119,27 +132,26 @@ export const ViewCell = observer(({ ver, v: live, i, frames, noted = true }: { v
119
132
  )
120
133
  })
121
134
 
122
- /** « 📤 » on a view: the stage popup on that media; a pair offers its after, its before, and the wipe of two images; a
123
- * gallery opens on its first tile, the popup's strip holding every other; a sound alone stages nothing */
135
+ /** the stage icon on a view: the stage popup on that media; a pair's icon opens a menu of its after, its before, and
136
+ * the wipe of two images; a gallery opens on its first tile, the popup's strip holding every other; a sound alone
137
+ * stages nothing */
124
138
  const StageButtons = observer(({ ver, v, i }: { ver: Ver; v: ReviewView; i: number }) => {
125
139
  const { rv } = ver
126
140
  const item = itemOf(ver)
127
- if (item.origin.by !== 'agent') return null
141
+ if (item.origin.by !== 'agent' || v.audio) return null
128
142
  const at = `${item.id}#${i}`
129
- const btn = (key: string, label: string, tip: string) => (
130
- <button key={key} className="ghost rv-stagebtn" title={tip} onMouseDown={keepFocus} onClick={() => rv.openStage(key)}>
131
- {label}
132
- </button>
133
- )
134
- if (isGallery(v)) return btn(`${at}/0`, '📤', 'stage a tile of this grid as a post')
135
- if (v.audio) return null
136
- if (!isPair(v.files)) return btn(at, '📤', 'stage this media as a post: a draft in comms, never posted')
143
+ const icon = <Icon d={ICON.stage} />
144
+ if (isGallery(v) || !isPair(v.files))
145
+ return <button className="ghost rv-iconbtn rv-stagebtn" title={isGallery(v) ? 'stage a tile of this grid as a post' : 'stage this media as a post: a draft in comms, never posted'} aria-label="stage as a post" onMouseDown={keepFocus} onClick={() => rv.openStage(isGallery(v) ? `${at}/0` : at)}>{icon}</button>
146
+ const entries: [string, string][] = [[`${at}.after`, 'the after'], [`${at}.before`, 'the before'], ...(v.clip ? [] : [[`${at}.wipe`, 'a wipe from before to after'] as [string, string]])]
137
147
  return (
138
- <>
139
- {btn(`${at}.after`, '📤 after', 'stage the after as a post')}
140
- {btn(`${at}.before`, '📤 before', 'stage the before as a post')}
141
- {v.clip ? null : btn(`${at}.wipe`, '📤 wipe', 'stage the pair as one wipe from before to after')}
142
- </>
148
+ <Pop className="ghost rv-iconbtn rv-stagebtn" aria-label="stage as a post" title="stage as a post: a draft in comms, never posted" label={icon} placement="bottom-end">
149
+ {(close) => (
150
+ <div className="rv-stagemenu">
151
+ {entries.map(([key, words]) => <button key={key} className="ghost" onClick={() => { close(); rv.openStage(key) }}>stage {words}</button>)}
152
+ </div>
153
+ )}
154
+ </Pop>
143
155
  )
144
156
  })
145
157
 
@@ -154,19 +166,7 @@ const ViewNotes = observer(({ ver, i, gallery, word = true }: { ver: Ver; i: num
154
166
  if (said.length === 0 && draft.length === 0 && !(takes(ver) && word)) return null
155
167
  return (
156
168
  <div className="rv-viewnotes">
157
- {said.map((s, k) => {
158
- const tile = s.reaction?.tile ?? s.rect?.r.tile
159
- const where = tileWhere(views[i], tile)
160
- return (
161
- <div key={k} className={`rv-said${s.reaction?.status ? ` re-${s.reaction.status}` : s.rect ? ' rect' : ''}`}>
162
- <span className="rv-saidmark">
163
- {s.rect ? `⬚ ${s.rect.n}${s.rect.r.side ? ` ${SIDE_LABEL[s.rect.r.side]}` : ''}${s.rect.r.t !== undefined ? ` · ${secs(s.rect.r.t)}` : ''}${where ? ` ${where}` : ''}` : `${REACTIONS.find((o) => o.status === s.reaction?.status)?.glyph ?? ''}${s.reaction?.stars ? ` ★${s.reaction.stars}` : ''}${where ? ` ${where}` : ''}`}
164
- </span>
165
- <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>
166
- <span className="rv-saidwho rv-dim">you · {STATUS_LABEL[s.verdict.verdict]} · v{cell.n}</span>
167
- </div>
168
- )
169
- })}
169
+ {said.map((s, k) => <SaidLine key={k} s={s} v={views[i]} n={cell.n} />)}
170
170
  {draft.length > 0 ? (
171
171
  <div className="rv-drafthead">
172
172
  <b>your notes</b>
@@ -192,6 +192,21 @@ const ViewNotes = observer(({ ver, i, gallery, word = true }: { ver: Ver; i: num
192
192
  )
193
193
  })
194
194
 
195
+ /** one thing an answer said on a view: a rectangle or a reaction, its word, whose answer */
196
+ const SaidLine = ({ s, v, n }: { s: SaidNote; v: ReviewView | undefined; n: number }) => {
197
+ const where = tileWhere(v, s.reaction?.tile ?? s.rect?.r.tile)
198
+ const o = REACTIONS.find((x) => x.status === s.reaction?.status)
199
+ return (
200
+ <div className={`rv-said${s.reaction?.status ? ` re-${s.reaction.status}` : s.rect ? ' rect' : ''}`}>
201
+ <span className="rv-saidmark">
202
+ {s.rect ? `⬚ ${s.rect.n}${s.rect.r.side ? ` ${SIDE_LABEL[s.rect.r.side]}` : ''}${s.rect.r.t !== undefined ? ` · ${secs(s.rect.r.t)}` : ''}${where ? ` ${where}` : ''}` : `${o?.glyph ?? ''}${s.reaction?.stars ? ` ★${s.reaction.stars}` : ''}${where ? ` ${where}` : ''}`}
203
+ </span>
204
+ <span className="rv-saidtext">{(s.rect ? s.rect.r.comment : s.reaction?.comment) || <i className="rv-dim">{s.reaction?.status ? o?.tip : 'no word'}</i>}</span>
205
+ <span className="rv-saidwho rv-dim">you · {STATUS_LABEL[s.verdict.verdict]} · v{n}</span>
206
+ </div>
207
+ )
208
+ }
209
+
195
210
  const isGalleryView = (v: ReviewView | undefined): v is GalleryView => v !== undefined && isGallery(v)
196
211
 
197
212
  /** the name of a gallery tile a note is on, or null off a gallery */
@@ -199,7 +214,7 @@ const tileWhere = (v: ReviewView | undefined, tile: number | undefined): string
199
214
  tile !== undefined && isGalleryView(v) ? (v.gallery[tile] ? tileName(v.gallery[tile]) : `tile ${tile + 1}`) : null
200
215
 
201
216
  /** a reaction an older answer gave, as a still pill */
202
- const SentReaction = ({ status }: { status: string }) => {
217
+ export const SentReaction = ({ status }: { status: string }) => {
203
218
  const o = REACTIONS.find((r) => r.status === status)
204
219
  return o ? <span className={`rv-react on re-${status}`}>{o.glyph} {o.label}</span> : null
205
220
  }
@@ -373,16 +388,22 @@ const FrameSlider = observer(({ card, frames }: { card: ThreadSt; frames: Galler
373
388
  )
374
389
  })
375
390
 
376
- /** 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 */
377
- const ReactionToggles = observer(({ ver, view, tile, small }: { ver: Ver; view: number; tile?: number; small?: boolean }) => {
391
+ /** the owner's reaction to one view or tile of the newest version, or to one message of a draft card (`post`): OK, fix
392
+ * or no; a click on the chosen one clears it. `said` hears the reaction a click set */
393
+ export const ReactionToggles = observer(({ ver, view, tile, post, small, keys, said }: { ver: Ver; view: number; tile?: number; post?: string; small?: boolean; keys?: boolean; said?: (status: ReviewStatus) => void }) => {
378
394
  const { card } = ver
379
- const cur = ver.claim ? undefined : card.reactionOf(view, tile)?.status
395
+ const cur = ver.claim ? undefined : card.reactionOf(view, tile, post)?.status
396
+ const tip = (o: (typeof REACTIONS)[number]): string => (post !== undefined ? (PLACE_TIPS[o.status] ?? o.tip) : o.tip)
380
397
  return (
381
398
  <span className="rv-reacts">
382
399
  {REACTIONS.map((o) => (
383
- <button key={o.status} title={o.tip} className={`rv-react re-${o.status}${small ? '' : ' big'}${cur === o.status ? ' on' : ''}${cur && cur !== o.status ? ' off' : ''}`}
384
- onMouseDown={keepFocus} onClick={() => mark(ver, () => card.react(view, tile, o.status))}>
400
+ <button key={o.status} title={keys ? `${tip(o)} (${o.key})` : tip(o)} className={`rv-react re-${o.status}${small ? '' : ' big'}${cur === o.status ? ' on' : ''}${cur && cur !== o.status ? ' off' : ''}`}
401
+ onMouseDown={keepFocus} onClick={() => {
402
+ mark(ver, () => card.react(view, tile, o.status, post))
403
+ if (cur !== o.status) said?.(o.status)
404
+ }}>
385
405
  {o.glyph} {o.label}
406
+ {keys ? <Key k={o.key} /> : null}
386
407
  </button>
387
408
  ))}
388
409
  </span>
@@ -393,39 +414,18 @@ const ReactionToggles = observer(({ ver, view, tile, small }: { ver: Ver; view:
393
414
  * list, one image a row at full width; grid, its tiles at the slider's height, one row per asset when its tiles are
394
415
  * variants (a group each). A head picks the mode and the fit, filters the tiles, flips every tile to its before, adds
395
416
  * the small sizes. A phone has no room for a side list, so its tabs read as the list */
396
- const Gallery = observer(({ ver, v, view }: { ver: Ver; v: GalleryView; view: number }) => {
397
- const { rv, card } = ver
398
- const befores = v.gallery.some((t) => t.before)
417
+ const Gallery = observer(({ ver, v, view, head = true }: { ver: Ver; v: GalleryView; view: number; head?: boolean }) => {
418
+ const { rv } = ver
399
419
  const tiles = v.gallery.map((t, k) => ({ t, k }))
400
420
  const sections = v.gallery.some((t) => t.group) ? [...new Set(v.gallery.map((t) => t.group ?? ''))].map((g) => ({ g, tiles: tiles.filter((x) => (x.t.group ?? '') === g) })) : null
401
- const mode: GalleryMode = rv.galleryMode === 'tabs' && rv.phone.on ? 'list' : rv.galleryMode
421
+ const mode = galleryModeOf(rv)
402
422
  const draw = (xs: typeof tiles): ReactNode =>
403
423
  mode === 'list'
404
424
  ? <div className="rv-gallerylist">{xs.map(({ t, k }) => <Tile key={k} ver={ver} v={v} view={view} t={t} k={k} fill />)}</div>
405
425
  : <div className="rv-gallery">{xs.map(({ t, k }) => <Tile key={k} ver={ver} v={v} view={view} t={t} k={k} />)}</div>
406
426
  return (
407
427
  <div className="rv-gallerywrap">
408
- <div className="rv-galleryhead rv-small">
409
- <span className="seg" role="group" aria-label="how the images show">
410
- {GALLERY_MODES.map((m) => (
411
- <button key={m} data-mode={m} className={rv.galleryMode === m ? 'on' : ''} title={GALLERY_MODE_TITLE[m]} onMouseDown={keepFocus} onClick={() => rv.setGalleryMode(m)}>{m}</button>
412
- ))}
413
- </span>
414
- {mode !== 'grid' ? (
415
- <span className="seg" role="group" aria-label="how a large image fits">
416
- {GALLERY_FITS.map((f) => (
417
- <button key={f} data-fit={f} className={rv.galleryFit === f ? 'on' : ''} title={GALLERY_FIT_TITLE[f]} onMouseDown={keepFocus} onClick={() => rv.setGalleryFit(f)}>{`fit ${f}`}</button>
418
- ))}
419
- </span>
420
- ) : null}
421
- <span className="seg" role="group" aria-label="which tiles show">
422
- {TILE_FILTERS.map((f) => (
423
- <button key={f} className={card.tileFilter === f ? 'on' : ''} onMouseDown={keepFocus} onClick={() => card.setTileFilter(f)}>{TILE_FILTER_LABEL[f]}</button>
424
- ))}
425
- </span>
426
- {befores ? <button className={`rv-chip${card.beforeAll ? ' on' : ''}`} title="every tile shows its before" onMouseDown={keepFocus} onClick={() => card.toggleBeforeAll()}>before</button> : null}
427
- <button className={`rv-chip${rv.tileSmall ? ' on' : ''}`} title="each tile also at 16, 32 and 64 px" onMouseDown={keepFocus} onClick={() => rv.toggleTileSmall()}>real size</button>
428
- </div>
428
+ {head ? <GalleryHead ver={ver} v={v} /> : null}
429
429
  {mode === 'tabs'
430
430
  ? <GalleryTabs ver={ver} v={v} view={view} />
431
431
  : sections
@@ -440,6 +440,39 @@ const Gallery = observer(({ ver, v, view }: { ver: Ver; v: GalleryView; view: nu
440
440
  )
441
441
  })
442
442
 
443
+ /** the mode a gallery draws in: a phone has no room for a side list, so its tabs read as the list */
444
+ const galleryModeOf = (rv: ReviewSt): GalleryMode => (rv.galleryMode === 'tabs' && rv.phone.on ? 'list' : rv.galleryMode)
445
+
446
+ /** a gallery's head: the mode, the fit, which tiles show, every tile at its before, the small sizes; the lightbox
447
+ * draws it in its own top bar */
448
+ const GalleryHead = observer(({ ver, v }: { ver: Ver; v: GalleryView }) => {
449
+ const { rv, card } = ver
450
+ const mode = galleryModeOf(rv)
451
+ return (
452
+ <div className="rv-galleryhead rv-small">
453
+ <span className="seg" role="group" aria-label="how the images show">
454
+ {GALLERY_MODES.map((m) => (
455
+ <button key={m} data-mode={m} className={rv.galleryMode === m ? 'on' : ''} title={GALLERY_MODE_TITLE[m]} onMouseDown={keepFocus} onClick={() => rv.setGalleryMode(m)}>{m}</button>
456
+ ))}
457
+ </span>
458
+ {mode !== 'grid' ? (
459
+ <span className="seg" role="group" aria-label="how a large image fits">
460
+ {GALLERY_FITS.map((f) => (
461
+ <button key={f} data-fit={f} className={rv.galleryFit === f ? 'on' : ''} title={GALLERY_FIT_TITLE[f]} onMouseDown={keepFocus} onClick={() => rv.setGalleryFit(f)}>{`fit ${f}`}</button>
462
+ ))}
463
+ </span>
464
+ ) : null}
465
+ <span className="seg" role="group" aria-label="which tiles show">
466
+ {TILE_FILTERS.map((f) => (
467
+ <button key={f} className={card.tileFilter === f ? 'on' : ''} onMouseDown={keepFocus} onClick={() => card.setTileFilter(f)}>{TILE_FILTER_LABEL[f]}</button>
468
+ ))}
469
+ </span>
470
+ {v.gallery.some((t) => t.before) ? <button className={`rv-chip${card.beforeAll ? ' on' : ''}`} title="every tile shows its before" onMouseDown={keepFocus} onClick={() => card.toggleBeforeAll()}>before</button> : null}
471
+ <button className={`rv-chip${rv.tileSmall ? ' on' : ''}`} title="each tile also at 16, 32 and 64 px" onMouseDown={keepFocus} onClick={() => rv.toggleTileSmall()}>real size</button>
472
+ </div>
473
+ )
474
+ })
475
+
443
476
  const GALLERY_MODE_TITLE: Record<GalleryMode, string> = {
444
477
  tabs: 'a list of the images on the left, the picked one large (↑ ↓ in the list walk it)',
445
478
  list: 'every image one under the other, at full width',
@@ -494,6 +527,8 @@ const TILE_FILTER_LABEL: Record<TileFilter, string> = { all: 'all', unrated: 'un
494
527
  const TILE_CHROME = 12
495
528
  const TILE_MIN_W = 150
496
529
  const TILE_WIDE = 1.6
530
+ /** what a large tile holds under its image: its label, its stars, OK Fix No and its word */
531
+ const TILE_UNDER = 128
497
532
 
498
533
  /** the small sizes an icon lives at */
499
534
  const SMALL_SIZES = [16, 32, 64] as const
@@ -518,7 +553,8 @@ const Tile = observer(({ ver, v, view, t, k, fill = false }: { ver: Ver; v: Gall
518
553
  const src = big || fill || h > TILE_H.thumb ? rv.fitUrl(id, file) : thumb
519
554
  const toggle = (): void => { if (!fill) card.toggleTile(id, view, k) }
520
555
  const aspect = `${t.size.w} / ${t.size.h}`
521
- const screen = { width: `min(100%, calc((100vh - ${FIT_ROOM}px) * ${ratio}))`, aspectRatio: aspect }
556
+ // the height a fit takes: the column's, or the lightbox's stage (--fit-h, review.css), less what sits under the image
557
+ const screen = { width: `min(100%, calc((var(--fit-h, 100vh - ${FIT_ROOM - TILE_UNDER}px) - ${TILE_UNDER}px) * ${ratio}))`, aspectRatio: aspect }
522
558
  const imgStyle = fill ? (rv.galleryFit === 'width' ? { width: '100%', aspectRatio: aspect } : screen) : big ? screen : { width: iw, height: ih }
523
559
  const title = live ? (fill ? 'drag to circle a spot' : 'drag to circle a spot, click to enlarge') : fill ? undefined : big ? 'click to shrink' : 'click to enlarge'
524
560
  return (
@@ -553,67 +589,285 @@ const Tile = observer(({ ver, v, view, t, k, fill = false }: { ver: Ver; v: Gall
553
589
  )
554
590
  })
555
591
 
556
- /** one media view: a single image or clip, or the pair in the compare component; fitted to the column on its own, or
557
- * zoomed (the full file) with its own scroll */
558
- const MediaBody = observer(({ ver, v, i, zoom }: { ver: Ver; v: MediaView; i: number; zoom: Zoom }) => {
592
+ /** one media view: a single image or clip, or the pair in the compare component; fitted to the column on its own, as
593
+ * wide as the column, or zoomed (the full file), the last two with their own scroll. `.rv-zoomface` is the element a
594
+ * size is measured on: its width holds `data-cols` images side by side */
595
+ const MediaBody = observer(({ ver, v, i, zoom, boxed = false }: { ver: Ver; v: MediaView; i: number; zoom: Zoom | BoxZoom; boxed?: boolean }) => {
559
596
  const { rv, card } = ver
560
597
  const item = itemOf(ver)
561
598
  const id = item.id
562
- if (v.audio) return <SoundBody ver={ver} v={v} />
599
+ if (v.audio) return <SoundBody ver={ver} v={v} saves={!boxed} />
600
+ // a still at Preview is a preview a click opens in the lightbox, where it is judged and drawn on; a clip keeps its player
601
+ if (zoom === 'preview' && !v.clip) return <PreviewOf ver={ver} v={v} i={i} />
563
602
  const f = v.files
564
603
  const ratio = v.size.w / v.size.h
565
604
  const aspect = `${v.size.w} / ${v.size.h}`
566
- const scale = zoom === 'fit' ? null : Number(zoom)
605
+ const wide = zoom === 'width'
606
+ const scale = zoom === 'fit' || zoom === 'preview' || wide ? null : Number(zoom)
567
607
  const room = FIT_ROOM + (v.clip ? 40 : 0)
608
+ const c = rv.compare
609
+ const mode = c.modeFor(v.clip !== undefined)
610
+ // the lightbox's stage (--fit-h) less what sits under the image there: a pair's captions, the clip's bar, the curtain's line
611
+ const under = (isPair(v.files) && !rv.phone.on ? 26 : 0) + (v.clip ? 44 : 0) + (isPair(v.files) && mode === 'swipe' ? 22 : 0)
612
+ // the height a view fits in: a preview's, the lightbox's, or the column's
613
+ const fitH = zoom === 'preview' ? `${PREVIEW_H}px` : boxed ? `(var(--fit-h) - ${under}px)` : `(100vh - ${room}px)`
568
614
  // a clip always plays its fit url (its play copy keeps its size and frames), an image is the full file past « fit »
569
- const src = (name: string): string => (scale && !v.clip ? rv.fileUrl(id, name, item.wip) : rv.fitUrl(id, name, item.wip))
570
- const bar = v.clip ? <ClipBar clip={card.clipOf(id, i)} info={v.clip} use={() => ver.live && card.setView(i)} /> : null
571
- const scroll = scale ? { overflow: 'auto', maxHeight: `calc(100vh - ${room}px)` } : undefined
615
+ const src = (name: string): string => ((scale || wide) && !v.clip ? rv.fileUrl(id, name, item.wip) : rv.fitUrl(id, name, item.wip))
616
+ // the page's clip keys reach the version his answer goes to: space when it is no pair, ← → when it has one view
617
+ const page = boxed && ver.cell.id === card.target
618
+ const keys = boxed ? { play: page && !isPair(f), frames: page && item.views.length === 1 } : undefined
619
+ const bar = v.clip ? <ClipBar clip={card.clipOf(id, i)} info={v.clip} use={() => ver.live && card.setView(i)} keys={keys} /> : null
620
+ const scroll = scale || wide ? { overflow: 'auto', maxHeight: boxed ? `calc(var(--fit-h) - ${under}px)` : `calc(100vh - ${room}px)` } : undefined
572
621
  if (!isPair(f)) {
573
622
  const name = 'image' in f ? f.image : 'video' in f ? f.video : f.audio
574
623
  return (
575
624
  <div style={scroll}>
576
- <div style={{ width: scale ? `${v.size.w * scale}px` : `min(100%, calc((100vh - ${room}px) * ${ratio}))`, margin: '0 auto' }}>
625
+ <div className="rv-zoomface" data-cols={1} style={{ width: scale ? `${v.size.w * scale}px` : wide ? '100%' : `min(100%, calc(${fitH} * ${ratio}))`, margin: '0 auto' }}>
577
626
  <Compare c={rv.compare} base={src(name)} mod={undefined} aspect={aspect} draw={(s) => <Marks ver={ver} src={s} side={undefined} view={i} />}
578
627
  over={() => (ver.live ? <RectNote ver={ver} view={i} sides={[undefined]} /> : null)} />
579
628
  {bar}
580
- <Downloads rv={rv} item={item} files={[{ file: name }]} />
629
+ {boxed ? null : <Downloads rv={rv} item={item} files={[{ file: name }]} />}
581
630
  </div>
582
631
  </div>
583
632
  )
584
633
  }
585
634
  const before = src(f.before)
586
635
  const after = src(f.after)
587
- const saves = <Downloads rv={rv} item={item} files={[{ file: f.before, label: 'before' }, { file: f.after, label: 'after' }]} />
636
+ const saves = boxed ? null : <Downloads rv={rv} item={item} files={[{ file: f.before, label: 'before' }, { file: f.after, label: 'after' }]} />
588
637
  if (rv.phone.on)
589
638
  return (
590
639
  <>
591
- <PhonePair ver={ver} view={i} bar={bar} before={before} after={after} aspect={aspect} size={v.size} scale={scale} />
640
+ <PhonePair ver={ver} view={i} bar={bar} before={before} after={after} aspect={aspect} size={v.size} scale={scale} fitH={boxed ? fitH : null} />
592
641
  {saves}
593
642
  </>
594
643
  )
595
- const c = rv.compare
596
- const mode = c.modeFor(v.clip !== undefined)
597
644
  const cols = mode === 'side' ? 2 : 1
598
- const fitW = `min(100%, calc((100vh - ${room}px) * ${ratio * cols}))`
645
+ const fitW = wide ? '100%' : `min(100%, calc(${fitH} * ${ratio * cols}))`
599
646
  return (
600
647
  <>
601
648
  <div style={scroll}>
602
- <div className="rv-pairgrid" style={{ width: scale ? `${v.size.w * scale * cols + 8 * (cols - 1)}px` : fitW, gridTemplateColumns: `repeat(${cols}, 1fr)` }}>
649
+ <div className="rv-pairgrid rv-zoomface" data-cols={cols} style={{ width: scale ? `${v.size.w * scale * cols + 8 * (cols - 1)}px` : fitW, gridTemplateColumns: `repeat(${cols}, 1fr)` }}>
603
650
  <Compare c={c} mode={mode} base={before} mod={after} names={PAIR_NAMES} aspect={aspect}
604
651
  draw={(s, face) => <Marks ver={ver} src={s} side={drawnSide(mode, s === before ? 'before' : 'after')} view={i} face={face} />}
605
652
  over={(srcs) => (ver.live ? <RectNote ver={ver} view={i} sides={srcs.map((s) => drawnSide(mode, s === before ? 'before' : 'after'))} /> : null)} />
606
653
  </div>
607
654
  </div>
608
655
  {bar ? <div style={{ width: fitW, margin: '0 auto' }}>{bar}</div> : null}
609
- <div style={{ width: fitW, margin: '0 auto' }}>{saves}</div>
656
+ {saves ? <div style={{ width: fitW, margin: '0 auto' }}>{saves}</div> : null}
610
657
  {mode === 'swipe' ? <div className="rv-dim rv-center">curtain: a drag moves the line; rectangles are drawn in the other modes</div> : null}
611
658
  </>
612
659
  )
613
660
  })
614
661
 
662
+ /** a view at Preview: its image (a pair's before and after side by side), at most PREVIEW_H tall; a click opens the
663
+ * lightbox on it */
664
+ const PreviewOf = observer(({ ver, v, i }: { ver: Ver; v: MediaView; i: number }) => {
665
+ const { rv } = ver
666
+ const item = itemOf(ver)
667
+ const f = v.files
668
+ const open = (): void => ver.card.openBox(ver.cell.id, i)
669
+ const aspect = { aspectRatio: `${v.size.w} / ${v.size.h}` }
670
+ if (isPair(f)) {
671
+ const before = rv.fitUrl(item.id, f.before, item.wip)
672
+ const after = rv.fitUrl(item.id, f.after, item.wip)
673
+ // one frame on a loop: the before, the changed pixels glowing, then the after (a still after alone when motion is reduced)
674
+ return (
675
+ <button type="button" className="rv-viewpreview" title="the before, what changed, the after: open it full to judge it, draw on it, save it" onMouseDown={keepFocus} onClick={open}>
676
+ <span className="rv-flip" style={{ ...aspect, width: `min(100%, calc(${PREVIEW_H}px * ${v.size.w / v.size.h}))` }}>
677
+ <img className="rv-flipbefore" src={before} alt="" loading="lazy" decoding="async" />
678
+ <img className="rv-flipafter" src={after} alt="" loading="lazy" decoding="async" />
679
+ <GlowCanvas base={before} mod={after} />
680
+ <span className="rv-fliptag before">before</span>
681
+ <span className="rv-fliptag after">after</span>
682
+ </span>
683
+ </button>
684
+ )
685
+ }
686
+ return (
687
+ <button type="button" className="rv-viewpreview" title="open it full: judge it, draw on it, save it" onMouseDown={keepFocus} onClick={open}>
688
+ <img src={rv.fitUrl(item.id, thumbFileOf(v), item.wip)} alt="" loading="lazy" decoding="async" style={aspect} />
689
+ </button>
690
+ )
691
+ })
692
+
693
+ /** the share of its own pixels a view is drawn at now, read off the page: what « fit » and « width » come to */
694
+ function shownScale(box: HTMLElement | null, v: ReviewView | undefined): number | null {
695
+ const face = box?.querySelector<HTMLElement>('.rv-zoomface')
696
+ if (face == null || v === undefined || isGallery(v) || !(v.size.w > 0)) return null
697
+ const cols = Number(face.dataset['cols'] ?? 1) || 1
698
+ const w = (face.getBoundingClientRect().width - 8 * (cols - 1)) / cols
699
+ return w > 0 ? w / v.size.w : null
700
+ }
701
+
702
+ const BOX_LABEL = { fit: 'Fit', width: 'Width' } as const
703
+ const BOX_TIP = { fit: 'the whole view in the window (0)', width: 'as wide as the window, it scrolls' } as const
704
+
705
+ /** the size of the view in the lightbox: whole, wide, its own pixels; a size the wheel or the keys gave shows as its
706
+ * percent; − and + step it. Kept for the repo */
707
+ const BoxZoomBar = observer(({ rv, step }: { rv: ReviewSt; step: (by: 1 | -1) => void }) => {
708
+ const z = rv.boxZoom
709
+ const free = typeof z === 'number' && !(BOX_ZOOM.picks as readonly number[]).includes(z)
710
+ return (
711
+ <span className="rv-boxzoom rv-keyed" title="the size of the view: ⌘ or ctrl with the wheel, a pinch, or + and −">
712
+ <span className="seg">
713
+ {(['fit', 'width'] as const).map((k) => (
714
+ <button key={k} className={z === k ? 'on' : ''} title={BOX_TIP[k]} onMouseDown={keepFocus} onClick={() => rv.setBoxZoom(k)}>{BOX_LABEL[k]}{k === 'fit' ? <Key k="0" /> : null}</button>
715
+ ))}
716
+ {BOX_ZOOM.picks.map((n) => <button key={n} className={z === n ? 'on' : ''} title={`${n * 100} % of its own pixels`} onMouseDown={keepFocus} onClick={() => rv.setBoxZoom(n)}>{n * 100} %</button>)}
717
+ {free ? <button className="on" title="the size the wheel or the keys gave" onMouseDown={keepFocus}>{Math.round(z * 100)} %</button> : null}
718
+ </span>
719
+ <button className="ghost rv-keybtn" title="smaller (−)" aria-label="smaller" onMouseDown={keepFocus} onClick={() => step(-1)}><Key k="−" /><span className="rv-nokey">−</span></button>
720
+ <button className="ghost rv-keybtn" title="larger (+)" aria-label="larger" onMouseDown={keepFocus} onClick={() => step(1)}><Key k="+" /><span className="rv-nokey">+</span></button>
721
+ </span>
722
+ )
723
+ })
724
+
725
+ /** what the lightbox shows: the version and its view, and what that view takes (the steps, a pair's flip and compare
726
+ * modes, a size); null while it is shut */
727
+ function boxOf(rv: ReviewSt, card: ThreadSt) {
728
+ const b = card.boxed
729
+ const cell = b == null ? null : card.versionOf(b.cell)
730
+ const v = b == null || cell == null ? undefined : cell.item.views[b.view]
731
+ if (b == null || cell == null || v === undefined) return null
732
+ const media = isGallery(v) ? null : v
733
+ const views = cell.item.views.length
734
+ const ver: Ver = { rv, card, cell, live: cell.id === card.head?.id && card.takesVerdict, claim: cell.id === card.newest?.id && card.claims }
735
+ const can = { step: views > 1, pair: media !== null && isPair(media.files) && !media.audio, size: media !== null && !media.audio }
736
+ return { at: b.view, cell, v, media, views, ver, can, step: (by: number): void => card.openBox(cell.id, (b.view + by + views) % views) }
737
+ }
738
+
739
+ /** a step of the lightbox's size from the size the view is drawn at now */
740
+ const resizeOf = (rv: ReviewSt, stage: { current: HTMLElement | null }, v: ReviewView) => (by: 1 | -1): void => rv.setBoxZoom(boxStep(shownScale(stage.current, v) ?? 1, by))
741
+
742
+ /** a key in the lightbox, true when it acted. Each acts only where its control shows: ← → the views, space a pair's
743
+ * before or after, V F R (or 1 2 3) OK Fix No on the view, 0 + − the size, Escape closes; V F R never reach the
744
+ * card's verdict from here. The page keeps the rest (D the compare mode, a clip's space, its ← → on a card of one
745
+ * view, A archives the card). A text field (`field`) keeps every key but Escape */
746
+ export function boxKey(rv: ReviewSt, card: ThreadSt, stage: { current: HTMLElement | null }, e: Pick<KeyboardEvent, 'key' | 'metaKey' | 'ctrlKey' | 'altKey'>, field: boolean): boolean {
747
+ const x = boxOf(rv, card)
748
+ if (x == null || e.metaKey || e.ctrlKey || e.altKey || (field && e.key !== 'Escape')) return false
749
+ const { at, ver, can, step } = x
750
+ const said = boxReaction(e.key)
751
+ if (e.key === 'Escape') card.closeBox()
752
+ else if (can.step && (e.key === 'ArrowLeft' || e.key === 'ArrowRight')) step(e.key === 'ArrowLeft' ? -1 : 1)
753
+ else if (can.pair && e.key === ' ') rv.compare.flip()
754
+ else if (can.size && e.key === '0') rv.setBoxZoom('fit')
755
+ else if (can.size && (e.key === '+' || e.key === '=' || e.key === '-')) resizeOf(rv, stage, x.v)(e.key === '-' ? -1 : 1)
756
+ else if (said != null) {
757
+ if (takes(ver)) mark(ver, () => card.react(at, undefined, said))
758
+ } else return false
759
+ return true
760
+ }
761
+
762
+ /** the lightbox over the whole window (BoxFrame draws it), its wheel and its keys */
763
+ export const ViewBox = observer(({ rv, card }: { rv: ReviewSt; card: ThreadSt }) => {
764
+ const stage = useRef<HTMLDivElement>(null)
765
+ const x = boxOf(rv, card)
766
+ const v = x?.v
767
+ // ⌘ or ctrl with the wheel (a pinch on a trackpad arrives as one) sizes the view around the pointer; the plain
768
+ // wheel scrolls. Not passive: the browser would zoom the whole page
769
+ useEffect(() => {
770
+ const el = stage.current
771
+ if (el == null || v === undefined) return
772
+ const wheel = (e: WheelEvent): void => {
773
+ if (!e.ctrlKey && !e.metaKey) return
774
+ const face = el.querySelector<HTMLElement>('.rv-zoomface')
775
+ const from = shownScale(el, v)
776
+ if (face == null || from == null) return
777
+ e.preventDefault()
778
+ const was = face.getBoundingClientRect()
779
+ const fx = (e.clientX - was.left) / was.width
780
+ const fy = (e.clientY - was.top) / was.height
781
+ rv.setBoxZoom(boxStep(from, -e.deltaY / 100))
782
+ // once it is drawn at its new size, the point that was under the pointer is put back under it
783
+ requestAnimationFrame(() => {
784
+ const now = el.querySelector<HTMLElement>('.rv-zoomface')
785
+ const scroller = now?.parentElement
786
+ if (now == null || scroller == null) return
787
+ const is = now.getBoundingClientRect()
788
+ scroller.scrollLeft += is.left + fx * is.width - e.clientX
789
+ scroller.scrollTop += is.top + fy * is.height - e.clientY
790
+ })
791
+ }
792
+ el.addEventListener('wheel', wheel, { passive: false })
793
+ return () => el.removeEventListener('wheel', wheel)
794
+ }, [v, rv])
795
+ // its keys come before the page's (capture): boxKey
796
+ useEffect(() => {
797
+ if (x == null) return
798
+ const key = (e: KeyboardEvent): void => {
799
+ const field = (e.target as HTMLElement | null)?.closest?.('input, textarea, select, [contenteditable]') != null
800
+ if (!boxKey(rv, card, stage, e, field)) return
801
+ e.preventDefault()
802
+ e.stopPropagation()
803
+ }
804
+ window.addEventListener('keydown', key, true)
805
+ return () => window.removeEventListener('keydown', key, true)
806
+ })
807
+ if (x == null) return null
808
+ return createPortal(<BoxFrame rv={rv} card={card} stage={stage} />, document.body)
809
+ })
810
+
811
+ /** the lightbox: the view a preview opened, over the whole window. One bar on top reads as what he does, left to
812
+ * right: where he is (← → the version's views, the view's name, its tag, the card), what he says of it (OK Fix No),
813
+ * how he looks at it (the compare modes, one side alone, the size, a gallery's head), ✕. The view takes the room
814
+ * between, « fit » fitting that room (--fit-h, review.css). One bar under it: his word on the view and its files.
815
+ * Every key is a chip on the control it triggers, shown only where the key acts */
816
+ export const BoxFrame = observer(({ rv, card, stage }: { rv: ReviewSt; card: ThreadSt; stage: React.RefObject<HTMLDivElement | null> }) => {
817
+ const x = boxOf(rv, card)
818
+ if (x == null) return null
819
+ const { at, cell, v, media, views, ver, can, step } = x
820
+ const shown = card.reactionShown(cell, at)
821
+ const kind = viewKind(v, false)
822
+ const name = v.label || kind
823
+ const files = filesOf(v)
824
+ const said = card.saidOn(cell.id, at)
825
+ const tag = viewTag(cell.n, at)
826
+ return (
827
+ <div className={`rv-viewbox${toneClass(shown?.status)}`} role="dialog" aria-modal="true" aria-label={`view ${tag}: ${name}`}>
828
+ <header className="rv-boxbar rv-boxtop">
829
+ <span className="rv-boxwhere">
830
+ {can.step ? <button className="ghost rv-keybtn" title="the view before (←)" aria-label="the view before" onMouseDown={keepFocus} onClick={() => step(-1)}><Key k="←" /><span className="rv-nokey">‹</span></button> : null}
831
+ <span className="rv-boxn rv-dim">{at + 1} of {views}</span>
832
+ {can.step ? <button className="ghost rv-keybtn" title="the view after (→)" aria-label="the view after" onMouseDown={keepFocus} onClick={() => step(1)}><Key k="→" /><span className="rv-nokey">›</span></button> : null}
833
+ <b className="rv-boxname" title={name}>{name}</b>
834
+ {v.label && v.label.toLowerCase() !== kind.toLowerCase() ? <span className="rv-boxkind rv-dim">{kind}</span> : null}
835
+ <span className="rv-boxtag" title={`view ${tag}`}>{tag}</span>
836
+ <span className="rv-boxtitle rv-dim" title={cell.item.title}>{cell.item.title}</span>
837
+ </span>
838
+ {takes(ver) ? <ReactionToggles ver={ver} view={at} keys /> : shown?.status ? <SentReaction status={shown.status} /> : null}
839
+ <span className="rv-boxlook">
840
+ {can.pair && rv.phone.on ? <PhoneSides rv={rv} /> : null}
841
+ {can.pair && !rv.phone.on ? <CompareModes c={rv.compare} clip={media?.clip !== undefined} keys /> : null}
842
+ {can.pair && !rv.phone.on ? <PairFlip c={rv.compare} /> : null}
843
+ {media?.marks && media.marks.length > 0 ? <button className={rv.marksOn ? 'primary' : ''} title="the repo's own rings on the shot (M)" onMouseDown={keepFocus} onClick={() => rv.toggleMarks()}>marks<Key k="M" /></button> : null}
844
+ {/* a phone sizes with a pinch: the size control is the keyboard's and the wheel's */}
845
+ {can.size && !rv.phone.on ? <BoxZoomBar rv={rv} step={resizeOf(rv, stage, v)} /> : null}
846
+ {isGallery(v) ? <GalleryHead ver={ver} v={v} /> : null}
847
+ </span>
848
+ <button className="ghost rv-boxclose" title="close (Escape)" aria-label="close" onClick={() => card.closeBox()}>✕<Key k="esc" /></button>
849
+ </header>
850
+ <div ref={stage} className="rv-boxstage">
851
+ <ViewCell ver={ver} v={v} i={at} boxed />
852
+ </div>
853
+ <footer className="rv-boxbar rv-boxfoot">
854
+ {media?.note ? <span className="rv-boxnote rv-dim" title={media.note}>{media.note}</span> : null}
855
+ {said.length > 0 ? <div className="rv-boxsaid">{said.map((s, k) => <SaidLine key={k} s={s} v={v} n={cell.n} />)}</div> : null}
856
+ {takes(ver) ? (
857
+ <AutoText className="rv-word rv-boxword" placeholder={isGallery(v) ? 'a word on these images' : 'a word on this view'} value={(ver.live ? card.reactionOf(at)?.comment : undefined) ?? ''}
858
+ onKeyDown={blurOnEscape} onText={(t) => mark(ver, () => card.setReactionComment(at, undefined, t))} />
859
+ ) : <span className="sp" />}
860
+ <span className="rv-boxfiles">
861
+ {files.length > 0 ? <Downloads rv={rv} item={cell.item} files={files} /> : null}
862
+ <StageButtons ver={ver} v={v} i={at} />
863
+ </span>
864
+ </footer>
865
+ </div>
866
+ )
867
+ })
868
+
615
869
  /** a sound view: its waveform over the browser's player, one row a side on a pair, each to download */
616
- const SoundBody = ({ ver, v }: { ver: Ver; v: MediaView }) => {
870
+ const SoundBody = ({ ver, v, saves = true }: { ver: Ver; v: MediaView; saves?: boolean }) => {
617
871
  const { rv } = ver
618
872
  const item = itemOf(ver)
619
873
  const f = v.files
@@ -632,11 +886,18 @@ const SoundBody = ({ ver, v }: { ver: Ver; v: MediaView }) => {
632
886
  </div>
633
887
  ))}
634
888
  <div className="rv-dim">{secs(a.duration)}</div>
635
- <Downloads rv={rv} item={item} files={rows.map((r) => ({ file: r.file, ...(r.label ? { label: r.label } : {}) }))} />
889
+ {saves ? <Downloads rv={rv} item={item} files={filesOf(v)} /> : null}
636
890
  </div>
637
891
  )
638
892
  }
639
893
 
894
+ /** the files a view saves, links and shows in the Finder: a pair's two sides, else its one file; a gallery none */
895
+ const filesOf = (v: ReviewView): { file: string; label?: string }[] => {
896
+ if (isGallery(v)) return []
897
+ const f = v.files
898
+ return isPair(f) ? [{ file: f.before, label: 'before' }, { file: f.after, label: 'after' }] : [{ file: 'image' in f ? f.image : 'video' in f ? f.video : f.audio }]
899
+ }
900
+
640
901
  /** a view's files to save at full size, each under the card's id and its own name */
641
902
  const Downloads = observer(({ rv, item, files }: { rv: ReviewSt; item: Item; files: readonly { file: string; label?: string }[] }) => (
642
903
  <div className="rv-downloads">
@@ -665,8 +926,21 @@ const PAIR_SIDES: { value: PairSide; label: string }[] = [
665
926
  { value: 'swipe', label: 'curtain' },
666
927
  ]
667
928
 
668
- /** a pair on a phone: one side at a time full width, or the curtain; the zoom scrolls */
669
- const PhonePair = observer(({ ver, view, bar, before, after, aspect, size, scale }: {
929
+ /** which side of a pair a phone shows: before, after, or the curtain */
930
+ const PhoneSides = observer(({ rv }: { rv: ReviewSt }) => {
931
+ const ph = rv.phone
932
+ const c = rv.compare
933
+ const side = ph.pair === 'swipe' && c.mode !== 'swipe' ? 'after' : ph.pair
934
+ const pick = (s: PairSide): void => {
935
+ if (s === 'swipe') c.setMode('swipe')
936
+ ph.setPair(s)
937
+ }
938
+ return <span className="seg">{PAIR_SIDES.map((s) => <button key={s.value} className={side === s.value ? 'on' : ''} onClick={() => pick(s.value)}>{s.label}</button>)}</span>
939
+ })
940
+
941
+ /** a pair on a phone: one side at a time full width, or the curtain; the zoom scrolls. `fitH`: in the lightbox, the
942
+ * height it fits, its sides chosen in the lightbox's bar */
943
+ const PhonePair = observer(({ ver, view, bar, before, after, aspect, size, scale, fitH }: {
670
944
  ver: Ver
671
945
  view: number
672
946
  bar: ReactNode
@@ -675,21 +949,19 @@ const PhonePair = observer(({ ver, view, bar, before, after, aspect, size, scale
675
949
  aspect: string
676
950
  size: { w: number; h: number }
677
951
  scale: number | null
952
+ fitH: string | null
678
953
  }) => {
679
954
  const { rv } = ver
680
955
  const ph = rv.phone
681
956
  const c = rv.compare
682
957
  const side = ph.pair === 'swipe' && c.mode !== 'swipe' ? 'after' : ph.pair
683
- const pick = (s: PairSide): void => {
684
- if (s === 'swipe') c.setMode('swipe')
685
- ph.setPair(s)
686
- }
687
958
  const one = side === 'before' ? before : after
959
+ const fit = fitH ? `min(100%, calc(${fitH} * ${size.w / size.h}))` : '100%'
688
960
  return (
689
961
  <div className="rv-phonepair">
690
- <span className="seg">{PAIR_SIDES.map((s) => <button key={s.value} className={side === s.value ? 'on' : ''} onClick={() => pick(s.value)}>{s.label}</button>)}</span>
691
- <div style={scale ? { overflow: 'auto', maxHeight: '70vh' } : undefined}>
692
- <div style={{ width: scale ? `${size.w * scale}px` : '100%' }}>
962
+ {fitH ? null : <PhoneSides rv={rv} />}
963
+ <div style={scale ? { overflow: 'auto', maxHeight: fitH ? `calc(${fitH})` : '70vh' } : undefined}>
964
+ <div className={fitH ? 'rv-zoomface' : undefined} data-cols={fitH ? 1 : undefined} style={{ width: scale ? `${size.w * scale}px` : fit, margin: '0 auto' }}>
693
965
  {side === 'swipe' ? (
694
966
  <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} />}
695
967
  over={(srcs) => (ver.live ? <RectNote ver={ver} view={view} sides={srcs.map((s) => (s === before ? 'before' : 'after'))} /> : null)} />
@@ -714,14 +986,17 @@ const MODES: { mode: CompareMode; glyph: string; tip: string }[] = [
714
986
  { mode: 'diff', glyph: '≠', tip: 'only what changed: the after\'s changed pixels in colour, the rest faded' },
715
987
  ]
716
988
 
717
- /** the compare modes as tiny buttons, the onion's opacity floating under them */
718
- const CompareModes = observer(({ c, clip }: { c: CompareSt; clip: boolean }) => (
989
+ /** the compare modes as tiny buttons, the onion's opacity floating under them; `keys`: the D that cycles them beside */
990
+ const CompareModes = observer(({ c, clip, keys }: { c: CompareSt; clip: boolean; keys?: boolean }) => (
719
991
  <span className="rv-modes">
720
- <span className="seg">
721
- {COMPARE_MODES.filter((m) => !(clip && m === 'diff')).map((m) => {
722
- const o = MODES.find((x) => x.mode === m)!
723
- return <button key={m} title={`${o.tip} (D cycles, ⇧D back)`} className={c.modeFor(clip) === m ? 'on' : ''} onMouseDown={keepFocus} onClick={() => c.setMode(m)}>{o.glyph}</button>
724
- })}
992
+ <span className="rv-keyed">
993
+ <span className="seg">
994
+ {COMPARE_MODES.filter((m) => !(clip && m === 'diff')).map((m) => {
995
+ const o = MODES.find((x) => x.mode === m)!
996
+ return <button key={m} title={`${o.tip} (D cycles, ⇧D back)`} className={c.modeFor(clip) === m ? 'on' : ''} onMouseDown={keepFocus} onClick={() => c.setMode(m)}>{o.glyph}</button>
997
+ })}
998
+ </span>
999
+ {keys ? <Key k="D" /> : null}
725
1000
  </span>
726
1001
  {c.mode === 'onion' ? (
727
1002
  <input className="rv-onion" type="range" min={0} max={1} step={0.05} value={c.opacity} title={`after ${Math.round(c.opacity * 100)} %`} onChange={(e) => c.setOpacity(Number(e.currentTarget.value))} />
@@ -729,6 +1004,18 @@ const CompareModes = observer(({ c, clip }: { c: CompareSt; clip: boolean }) =>
729
1004
  </span>
730
1005
  ))
731
1006
 
1007
+ /** one side of a pair alone, the before or the after (the hover mode); space flips them */
1008
+ const PairFlip = observer(({ c }: { c: CompareSt }) => (
1009
+ <span className="rv-keyed">
1010
+ <span className="seg" role="group" aria-label="one side alone">
1011
+ {(['before', 'after'] as const).map((side) => (
1012
+ <button key={side} className={c.shown === side ? 'on' : ''} title={`the ${side} alone (space flips)`} onMouseDown={keepFocus} onClick={() => c.show(side)}>{side}</button>
1013
+ ))}
1014
+ </span>
1015
+ <Key k="space" />
1016
+ </span>
1017
+ ))
1018
+
732
1019
  /** a channel sum under this is the encoder's noise, never a change */
733
1020
  const DIFF_NOISE = 24
734
1021
 
@@ -736,6 +1023,36 @@ const DIFF_NOISE = 24
736
1023
  const changesWords = (share: number | null | undefined): string =>
737
1024
  share === undefined ? 'reading…' : share === null ? 'could not be read' : share === 0 ? 'none: no pixel differs' : `${share < 0.001 ? '< 0.1' : (share * 100).toFixed(1)} % of the pixels`
738
1025
 
1026
+ /** the before's and the after's pixels, drawn at the after's size on `canvas()` (left holding the after), or null when
1027
+ * either cannot be read: a load failed, the canvas is gone, or an image came from another origin (a media the disk let
1028
+ * go is a redirect to the Space), which taints the canvas and makes getImageData throw */
1029
+ const pixelsOf = async (base: string, mod: string, canvas: () => HTMLCanvasElement | null): Promise<{ ctx: CanvasRenderingContext2D; pa: Uint8ClampedArray; out: ImageData; w: number; h: number } | null> => {
1030
+ const load = (src: string): Promise<HTMLImageElement> =>
1031
+ new Promise((ok, no) => {
1032
+ const img = new Image()
1033
+ img.onload = () => ok(img)
1034
+ img.onerror = () => no(new Error(src))
1035
+ img.src = src
1036
+ })
1037
+ try {
1038
+ const [a, b] = await Promise.all([load(base), load(mod)])
1039
+ const cv = canvas()
1040
+ const ctx = cv?.getContext('2d', { willReadFrequently: true })
1041
+ if (cv == null || ctx == null) return null
1042
+ const w = b.naturalWidth
1043
+ const h = b.naturalHeight
1044
+ cv.width = w
1045
+ cv.height = h
1046
+ ctx.drawImage(a, 0, 0, w, h)
1047
+ const pa = ctx.getImageData(0, 0, w, h).data
1048
+ ctx.clearRect(0, 0, w, h)
1049
+ ctx.drawImage(b, 0, 0, w, h)
1050
+ return { ctx, pa, out: ctx.getImageData(0, 0, w, h), w, h }
1051
+ } catch {
1052
+ return null
1053
+ }
1054
+ }
1055
+
739
1056
  /** the after, only where it changed from the before: each changed pixel in its own colour, every other pixel a pale
740
1057
  * gray of it, so what moved is all that stands out. Read in the browser from the two previews; `say` gets the share
741
1058
  * that changed, undefined while it reads, null when an image cannot be read */
@@ -743,27 +1060,11 @@ const DiffCanvas = ({ base, mod, say }: { base: string; mod: string; say: (share
743
1060
  const ref = useRef<HTMLCanvasElement>(null)
744
1061
  useEffect(() => {
745
1062
  let gone = false
746
- const load = (src: string): Promise<HTMLImageElement> =>
747
- new Promise((ok, no) => {
748
- const img = new Image()
749
- img.onload = () => ok(img)
750
- img.onerror = () => no(new Error(src))
751
- img.src = src
752
- })
753
1063
  say(undefined)
754
- Promise.all([load(base), load(mod)]).then(([a, b]) => {
755
- const cv = ref.current
756
- if (gone || cv == null) return
757
- const w = b.naturalWidth
758
- const h = b.naturalHeight
759
- cv.width = w
760
- cv.height = h
761
- const ctx = cv.getContext('2d', { willReadFrequently: true })
762
- if (ctx == null) return say(null)
763
- ctx.drawImage(a, 0, 0, w, h)
764
- const pa = ctx.getImageData(0, 0, w, h).data
765
- ctx.drawImage(b, 0, 0, w, h)
766
- const out = ctx.getImageData(0, 0, w, h)
1064
+ void pixelsOf(base, mod, () => (gone ? null : ref.current)).then((px) => {
1065
+ if (gone) return
1066
+ if (px == null) return say(null)
1067
+ const { ctx, pa, out, w, h } = px
767
1068
  const pb = out.data
768
1069
  let changed = 0
769
1070
  for (let i = 0; i < pb.length; i += 4) {
@@ -778,8 +1079,6 @@ const DiffCanvas = ({ base, mod, say }: { base: string; mod: string; say: (share
778
1079
  }
779
1080
  ctx.putImageData(out, 0, 0)
780
1081
  say(changed / (w * h))
781
- }, () => {
782
- if (!gone) say(null)
783
1082
  })
784
1083
  return () => {
785
1084
  gone = true
@@ -788,6 +1087,28 @@ const DiffCanvas = ({ base, mod, say }: { base: string; mod: string; say: (share
788
1087
  return <canvas ref={ref} className="rv-diff" />
789
1088
  }
790
1089
 
1090
+ /** the pixels that changed from `base` to `mod`, alone on a clear canvas (the rest transparent), for the preview's glow */
1091
+ const GlowCanvas = ({ base, mod }: { base: string; mod: string }) => {
1092
+ const ref = useRef<HTMLCanvasElement>(null)
1093
+ useEffect(() => {
1094
+ let gone = false
1095
+ void pixelsOf(base, mod, () => (gone ? null : ref.current)).then((px) => {
1096
+ if (px == null) return
1097
+ const { ctx, pa, out } = px
1098
+ const pb = out.data
1099
+ for (let i = 0; i < pb.length; i += 4) {
1100
+ const moved = Math.abs(pa[i]! - pb[i]!) + Math.abs(pa[i + 1]! - pb[i + 1]!) + Math.abs(pa[i + 2]! - pb[i + 2]!) > DIFF_NOISE
1101
+ pb[i + 3] = moved ? 255 : 0
1102
+ }
1103
+ ctx.putImageData(out, 0, 0)
1104
+ })
1105
+ return () => {
1106
+ gone = true
1107
+ }
1108
+ }, [base, mod])
1109
+ return <canvas ref={ref} className="rv-flipglow" aria-hidden="true" />
1110
+ }
1111
+
791
1112
  /** follows the pointer until it is released */
792
1113
  function track(move: (e: PointerEvent) => void): void {
793
1114
  const up = (): void => {
@@ -819,12 +1140,15 @@ const Compare = observer(({ c, mode = c.mode, base, mod, names, aspect, draw, ov
819
1140
  <div className="rv-fill">{draw(mod, <DiffCanvas base={base} mod={mod} say={setShare} />)}</div>
820
1141
  </Frame>
821
1142
  )
822
- if (mode === 'mod')
1143
+ if (mode === 'mod') {
1144
+ // the before shows on a hover or after a space, not both: a hover on a flipped pair shows the after again
1145
+ const before = peek !== c.flipped
823
1146
  return (
824
- <Frame aspect={aspect} caption={peek ? n.base : n.mod} modCap={!peek} onPeek={setPeek} over={over?.([peek ? base : mod])}>
825
- <div className="rv-fill">{draw(peek ? base : mod)}</div>
1147
+ <Frame aspect={aspect} caption={before ? n.base : n.mod} modCap={!before} onPeek={setPeek} side={before ? { tone: 'before', name: n.base } : { tone: 'after', name: n.mod }} over={over?.([before ? base : mod])}>
1148
+ <div className="rv-fill">{draw(before ? base : mod)}</div>
826
1149
  </Frame>
827
1150
  )
1151
+ }
828
1152
  const pct = Math.round(c.split * 100)
829
1153
  return (
830
1154
  <Frame aspect={aspect} caption={<>{n.base} {mode === 'swipe' ? '◀ ▶' : '+'} <span className="rv-modcap">{n.mod}</span></>} swipe={mode === 'swipe' ? c : undefined} over={over?.([base, mod])}>
@@ -836,7 +1160,9 @@ const Compare = observer(({ c, mode = c.mode, base, mod, names, aspect, draw, ov
836
1160
  })
837
1161
 
838
1162
  /** one frame and its caption; the curtain's line follows the pointer; `over` sits on the frame, free of its clip */
839
- 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 }) => {
1163
+ /** `side`: which image of a pair the frame shows right now, said on the frame itself: its outline (the before red, the
1164
+ * after green) and its name in a corner tag, both drawn over the image so nothing moves when it changes */
1165
+ const Frame = ({ aspect, caption, modCap, swipe, onPeek, side, over, children }: { aspect: string; caption: ReactNode; modCap?: boolean; swipe?: CompareSt | undefined; onPeek?: (on: boolean) => void; side?: { tone: 'before' | 'after'; name: string }; over?: ReactNode; children: ReactNode }) => {
840
1166
  const frame = useRef<HTMLDivElement>(null)
841
1167
  const down = (e: React.PointerEvent): void => {
842
1168
  const el = frame.current
@@ -852,10 +1178,11 @@ const Frame = ({ aspect, caption, modCap, swipe, onPeek, over, children }: { asp
852
1178
  return (
853
1179
  <div className="rv-cell">
854
1180
  <div className="rv-framebox">
855
- <div ref={frame} className={`rv-frame${swipe ? ' swipe' : ''}`} style={{ aspectRatio: aspect }} onPointerDown={down}
1181
+ <div ref={frame} className={`rv-frame${swipe ? ' swipe' : ''}${side ? ` side-${side.tone}` : ''}`} style={{ aspectRatio: aspect }} onPointerDown={down}
856
1182
  onMouseEnter={() => onPeek?.(true)} onMouseLeave={() => onPeek?.(false)}>
857
1183
  {children}
858
1184
  </div>
1185
+ {side ? <span className={`rv-sidetag side-${side.tone}`} aria-live="polite">{side.name}</span> : null}
859
1186
  {over ? <div className="rv-over">{over}</div> : null}
860
1187
  </div>
861
1188
  {caption != null ? <div className={`rv-caption${modCap ? ' mod' : ''}`}>{caption}</div> : null}
@@ -1115,15 +1442,19 @@ export const ClipSound = observer(({ clip, keyHint }: { clip: ClipSt; keyHint?:
1115
1442
  </span>
1116
1443
  ))
1117
1444
 
1118
- /** under a clip: play or pause, one frame back or on, the scrubber, the time and the frame */
1119
- const ClipBar = observer(({ clip, info, use }: { clip: ClipSt; info: ReviewClip; use: () => void }) => {
1445
+ /** under a clip: play or pause, one frame back or on, the scrubber, the time and the frame. `keys`: in the lightbox,
1446
+ * which of its keys reach the clip there (space flips a pair, ← → step the views of a card that has several), each
1447
+ * shown on its button */
1448
+ const ClipBar = observer(({ clip, info, use, keys }: { clip: ClipSt; info: ReviewClip; use: () => void; keys?: { play: boolean; frames: boolean } | undefined }) => {
1120
1449
  const frames = Math.max(1, Math.round(info.duration * info.fps))
1450
+ const play = keys?.play ?? true
1451
+ const step = keys?.frames ?? true
1121
1452
  return (
1122
1453
  <div className="rv-clipbar" onMouseDownCapture={use} onTouchStartCapture={use}>
1123
- <button title={clip.paused ? 'play (Space)' : 'pause (Space)'} onMouseDown={keepFocus} onClick={() => clip.toggle()}>{clip.paused ? '▶' : '❚❚'}</button>
1454
+ <button title={`${clip.paused ? 'play' : 'pause'}${play ? ' (Space)' : ''}`} onMouseDown={keepFocus} onClick={() => clip.toggle()}>{clip.paused ? '▶' : '❚❚'}{keys && play ? <Key k="space" /> : null}</button>
1124
1455
  <ClipSound clip={clip} />
1125
- <button title="frame back (←)" onMouseDown={keepFocus} onClick={() => clip.step(-1)}>⏮</button>
1126
- <button title="frame on (→)" onMouseDown={keepFocus} onClick={() => clip.step(1)}>⏭</button>
1456
+ <button title={`frame back${step ? ' (←)' : ''}`} onMouseDown={keepFocus} onClick={() => clip.step(-1)}>⏮{keys && step ? <Key k="←" /> : null}</button>
1457
+ <button title={`frame on${step ? ' (→)' : ''}`} onMouseDown={keepFocus} onClick={() => clip.step(1)}>⏭{keys && step ? <Key k="→" /> : null}</button>
1127
1458
  <input className="rv-scrub" type="range" min={0} max={info.duration} step={1 / info.fps} value={Math.min(clip.time, info.duration)}
1128
1459
  onChange={(e) => clip.seek(Number(e.currentTarget.value))} onMouseUp={(e) => e.currentTarget.blur()} />
1129
1460
  <span className="rv-mono">{secs(clip.time)} · frame {clip.frameOf(clip.time) + 1}/{frames}</span>