rvlib-shipkit 2.12.0 → 2.13.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 (290) hide show
  1. package/CHANGELOG.md +48 -13
  2. package/README.md +1 -1
  3. package/package.json +4 -2
  4. package/src/agent-time/store.ts +2 -2
  5. package/src/check.ts +1 -1
  6. package/src/checks/SK001-package-json-shape.check.ts +4 -0
  7. package/src/checks/SK003-claude-md-shape.check.ts +1 -1
  8. package/src/checks/SK004-gitignore-policy.check.ts +27 -2
  9. package/src/checks/SK005-rvlib-versions.check.ts +1 -1
  10. package/src/checks/SK008-reviewer-agent.check.ts +2 -2
  11. package/src/checks/SK012-config-barrel-import.check.ts +1 -1
  12. package/src/checks/SK015-nested-repo.check.ts +1 -1
  13. package/src/checks/SK035-public-clean.check.ts +46 -0
  14. package/src/checks/SK036-draft-media-size.check.ts +28 -0
  15. package/src/cli/cmd_Backup.ts +152 -0
  16. package/src/cli/cmd_Ci.ts +8 -11
  17. package/src/cli/cmd_Drill.ts +145 -0
  18. package/src/cli/cmd_Home.ts +50 -3
  19. package/src/cli/cmd_Media.ts +7 -5
  20. package/src/cli/cmd_Review.ts +4 -2
  21. package/src/cli/cmd_Shot.ts +5 -2
  22. package/src/cli/cmd_Smoke.ts +4 -1
  23. package/src/cli/cmd_Social.ts +226 -0
  24. package/src/cli/cmd_Start.ts +1 -1
  25. package/src/cli/cmd_Time.ts +1 -1
  26. package/src/cli/cmd_Trailer.ts +5 -2
  27. package/src/cli/cmd_Veille.ts +173 -0
  28. package/src/cli/family-pages.ts +3 -0
  29. package/src/cli/registry.ts +13 -2
  30. package/src/cli.ts +5 -2
  31. package/src/collections/actions.ts +1 -49
  32. package/src/collections/checks.ts +2 -1
  33. package/src/collections/collection-types.ts +11 -2
  34. package/src/collections/providers.ts +4 -4
  35. package/src/collections/review.ts +2 -1
  36. package/src/collections/tests.ts +19 -8
  37. package/src/contracts/apply-contracts.ts +1 -3
  38. package/src/contracts/contract-manifests.ts +2 -3
  39. package/src/contracts/contract-types.ts +0 -1
  40. package/src/contracts/contracts-engine.ts +0 -3
  41. package/src/core/app-icon.ts +9 -3
  42. package/src/core/bun-builtins.ts +2 -2
  43. package/src/core/discover-checks.ts +37 -5
  44. package/src/core/fix-scope.ts +4 -2
  45. package/src/core/floor-resolve.ts +68 -48
  46. package/src/core/floor.ts +9 -0
  47. package/src/core/git-root.ts +24 -0
  48. package/src/core/last-good.ts +3 -1
  49. package/src/core/layout.ts +8 -0
  50. package/src/core/log-stamp.ts +36 -0
  51. package/src/core/loop-watch.ts +93 -0
  52. package/src/core/machine-link.ts +134 -0
  53. package/src/core/memory-watch.ts +41 -0
  54. package/src/core/one-way-in-policy.ts +27 -19
  55. package/src/core/run-ci.ts +6 -8
  56. package/src/core/run-fixers.ts +9 -9
  57. package/src/core/slots.ts +21 -0
  58. package/src/core/tree-rev.ts +60 -0
  59. package/src/core/unit-files.ts +42 -0
  60. package/src/drill/render.ts +140 -0
  61. package/src/drill/run.ts +269 -0
  62. package/src/fleet/scan-fleet.ts +6 -5
  63. package/src/home/daemon-jobs.ts +201 -0
  64. package/src/home/global-context.ts +34 -1
  65. package/src/home/home-routes.ts +22 -15
  66. package/src/home/hubs.ts +10 -3
  67. package/src/home/inbox-shape.ts +53 -4
  68. package/src/home/inbox.ts +16 -1
  69. package/src/home/lib-watch.ts +10 -3
  70. package/src/home/machine-stores.ts +15 -29
  71. package/src/home/run-daemon.ts +15 -18
  72. package/src/home/run-pm.ts +2 -0
  73. package/src/home/serve-daemon.ts +4 -3
  74. package/src/home/serve-web.ts +104 -1
  75. package/src/hooks/commit-message.ts +28 -19
  76. package/src/hooks/leak-guard.ts +10 -3
  77. package/src/hooks/run-hooks.ts +2 -6
  78. package/src/identities/identities.ts +334 -0
  79. package/src/identities/machine-route.ts +126 -0
  80. package/src/identities/machine.ts +62 -0
  81. package/src/init-repo.ts +1 -1
  82. package/src/ledger/check-stats.ts +10 -9
  83. package/src/ledger/gate-checks.ts +32 -1
  84. package/src/ledger/record-kept.ts +112 -0
  85. package/src/ledger/repo-view.ts +10 -0
  86. package/src/ledger/run-log.ts +17 -12
  87. package/src/ledger/run-timeline.ts +8 -4
  88. package/src/ledger/store.ts +7 -0
  89. package/src/ledger/suite-log.ts +17 -13
  90. package/src/media-kinds.ts +2 -1
  91. package/src/media-store/backup/daemon.ts +73 -0
  92. package/src/media-store/backup/keys.ts +25 -0
  93. package/src/media-store/backup/manifest.ts +193 -0
  94. package/src/media-store/backup/restore.ts +192 -0
  95. package/src/media-store/backup/run.ts +278 -0
  96. package/src/media-store/backup/secret.ts +86 -0
  97. package/src/media-store/backup/snapshot.ts +64 -0
  98. package/src/media-store/backup/sources.ts +199 -0
  99. package/src/media-store/daemon.ts +56 -70
  100. package/src/media-store/put.ts +4 -2
  101. package/src/media-store/space.ts +23 -4
  102. package/src/pages/forward.ts +35 -0
  103. package/src/pages/frame-client.ts +118 -0
  104. package/src/pages/routes.ts +29 -0
  105. package/src/pages/unit.ts +92 -0
  106. package/src/plan/planner.ts +12 -0
  107. package/src/plan/repo-source.ts +19 -5
  108. package/src/reflect/transcript.ts +35 -10
  109. package/src/release/public-clean.ts +301 -0
  110. package/src/release/published-here.ts +22 -0
  111. package/src/release/run-bump.ts +2 -1
  112. package/src/release/run-release.ts +4 -1
  113. package/src/repo-config.ts +53 -2
  114. package/src/review/http.ts +16 -2
  115. package/src/review/model.ts +15 -4
  116. package/src/review/notes.ts +77 -0
  117. package/src/review/project.ts +6 -38
  118. package/src/review/routes.ts +4 -12
  119. package/src/review/store.ts +41 -1
  120. package/src/review/trailer-media.ts +7 -4
  121. package/src/review/trailer-shots.ts +21 -4
  122. package/src/review/unit.ts +1 -1
  123. package/src/scaffold/files/agent-handoff.md +3 -0
  124. package/src/scaffold/files/agent-index.md +4 -12
  125. package/src/scaffold/project-scaffold.ts +5 -4
  126. package/src/serve/embed.ts +1 -1
  127. package/src/serve/hub-app/col-card.tsx +3 -17
  128. package/src/serve/hub-app/col-tables-view.tsx +2 -1
  129. package/src/serve/hub-app/cols-svc.ts +0 -13
  130. package/src/serve/hub-app/dock-st.ts +4 -2
  131. package/src/serve/hub-app/dock-view.tsx +2 -0
  132. package/src/serve/hub-app/frames-st.ts +35 -0
  133. package/src/serve/hub-app/hash-route.ts +64 -1
  134. package/src/serve/hub-app/home-st.ts +31 -7
  135. package/src/serve/hub-app/home-strip.css +9 -1
  136. package/src/serve/hub-app/home-strip.tsx +7 -6
  137. package/src/serve/hub-app/home.html +5 -0
  138. package/src/serve/hub-app/hub-app.tsx +49 -5
  139. package/src/serve/hub-app/hub.css +29 -11
  140. package/src/serve/hub-app/icons.tsx +16 -1
  141. package/src/serve/hub-app/identities-st.ts +210 -0
  142. package/src/serve/hub-app/identities-view.tsx +352 -0
  143. package/src/serve/hub-app/identities.css +48 -0
  144. package/src/serve/hub-app/identity-address.ts +52 -0
  145. package/src/serve/hub-app/inbox-st.ts +59 -6
  146. package/src/serve/hub-app/inbox-view.tsx +48 -6
  147. package/src/serve/hub-app/inbox.css +12 -1
  148. package/src/serve/hub-app/index.html +3 -0
  149. package/src/serve/hub-app/keys.ts +10 -2
  150. package/src/serve/hub-app/list-walk.ts +89 -0
  151. package/src/serve/hub-app/machine-st.ts +12 -0
  152. package/src/serve/hub-app/media-view.tsx +2 -1
  153. package/src/serve/hub-app/pages-frames.tsx +134 -0
  154. package/src/serve/hub-app/pages-svc.ts +111 -0
  155. package/src/serve/hub-app/palette-st.ts +18 -3
  156. package/src/serve/hub-app/palette-view.tsx +9 -2
  157. package/src/serve/hub-app/planned-view.tsx +2 -1
  158. package/src/serve/hub-app/project-list.css +18 -14
  159. package/src/serve/hub-app/project-list.tsx +88 -49
  160. package/src/serve/hub-app/projects-svc.ts +33 -3
  161. package/src/serve/hub-app/repo-sections.ts +19 -2
  162. package/src/serve/hub-app/repo-st.ts +75 -19
  163. package/src/serve/hub-app/review/review-cells.tsx +3 -3
  164. package/src/serve/hub-app/review/review-kit.ts +30 -7
  165. package/src/serve/hub-app/review/review-page.tsx +1 -1
  166. package/src/serve/hub-app/review/review-st.ts +19 -8
  167. package/src/serve/hub-app/review/review-thread.tsx +11 -9
  168. package/src/serve/hub-app/review/review-views.tsx +84 -19
  169. package/src/serve/hub-app/review/thread-st.ts +1 -10
  170. package/src/serve/hub-app/review/trailer-page.tsx +2 -1
  171. package/src/serve/hub-app/review.css +17 -8
  172. package/src/serve/hub-app/site/site-part.tsx +173 -0
  173. package/src/serve/hub-app/site/site-st.ts +157 -0
  174. package/src/serve/hub-app/site.css +35 -0
  175. package/src/serve/hub-app/social/calendar.tsx +182 -0
  176. package/src/serve/hub-app/social/comms-page.tsx +306 -0
  177. package/src/serve/hub-app/social/kit.tsx +244 -0
  178. package/src/serve/hub-app/social/post-card.tsx +456 -0
  179. package/src/serve/hub-app/social/problems.tsx +60 -0
  180. package/src/serve/hub-app/social/social-model.ts +154 -0
  181. package/src/serve/hub-app/social/social-page.tsx +674 -0
  182. package/src/serve/hub-app/social/social-st.ts +986 -0
  183. package/src/serve/hub-app/social.css +289 -0
  184. package/src/serve/hub-app/stores/stores-page.tsx +311 -0
  185. package/src/serve/hub-app/stores/stores-st.ts +286 -0
  186. package/src/serve/hub-app/stores.css +54 -0
  187. package/src/serve/hub-app/timeline-geometry.ts +1 -1
  188. package/src/serve/hub-app/timeline-view.tsx +3 -2
  189. package/src/serve/hub-app/tree-build.ts +6 -0
  190. package/src/serve/hub-app/tree-row.tsx +27 -4
  191. package/src/serve/hub-app/tree-svc.ts +18 -49
  192. package/src/serve/hub-app/veille/veille-page.tsx +514 -0
  193. package/src/serve/hub-app/veille/veille-st.ts +443 -0
  194. package/src/serve/hub-app/veille.css +84 -0
  195. package/src/serve/hub-runtime.ts +14 -9
  196. package/src/serve/project-gutter-route.ts +44 -12
  197. package/src/serve/run-lanes.ts +7 -4
  198. package/src/serve/same-origin.ts +1 -1
  199. package/src/serve/serve-hub.ts +20 -12
  200. package/src/serve/tracked-watch.ts +24 -3
  201. package/src/serve/warm-cell.ts +5 -1
  202. package/src/shipkit-files.ts +15 -4
  203. package/src/shipkit.ts +0 -1
  204. package/src/shot/box.ts +162 -0
  205. package/src/shot/browser-slot.ts +62 -0
  206. package/src/shot/client.ts +43 -7
  207. package/src/shot/clip-encoder.ts +93 -12
  208. package/src/shot/film-box.ts +188 -0
  209. package/src/shot/shooter.ts +50 -15
  210. package/src/shot/shot-ask.ts +10 -2
  211. package/src/shot/stepped-clip.ts +5 -4
  212. package/src/site/desk.ts +242 -0
  213. package/src/site/routes.ts +66 -0
  214. package/src/site/unit.ts +62 -0
  215. package/src/social/brands.ts +22 -0
  216. package/src/social/compose.ts +97 -0
  217. package/src/social/desk-index.ts +123 -0
  218. package/src/social/desk-wire.ts +64 -0
  219. package/src/social/drafts.ts +183 -0
  220. package/src/social/house.ts +24 -0
  221. package/src/social/load.ts +319 -0
  222. package/src/social/md.ts +70 -0
  223. package/src/social/media-facts.ts +53 -0
  224. package/src/social/media-kind.ts +189 -0
  225. package/src/social/media-limit.ts +42 -0
  226. package/src/social/media-of.ts +30 -0
  227. package/src/social/migrate.ts +123 -0
  228. package/src/social/open.ts +17 -0
  229. package/src/social/post-url.ts +158 -0
  230. package/src/social/presence.ts +332 -0
  231. package/src/social/public-read.ts +53 -0
  232. package/src/social/publish/bluesky.ts +168 -0
  233. package/src/social/publish/discord.ts +76 -0
  234. package/src/social/publish/index.ts +24 -0
  235. package/src/social/publish/secret.ts +13 -0
  236. package/src/social/push.ts +31 -0
  237. package/src/social/richtext.ts +37 -0
  238. package/src/social/routes.ts +180 -0
  239. package/src/social/stats.ts +134 -0
  240. package/src/social/text.ts +267 -0
  241. package/src/social/tracker-route.ts +39 -0
  242. package/src/social/tracker.ts +255 -0
  243. package/src/social/unit.ts +53 -0
  244. package/src/social/writes.ts +130 -0
  245. package/src/start-repo.ts +14 -9
  246. package/src/stores/collection.ts +27 -0
  247. package/src/stores/desk.ts +336 -0
  248. package/src/stores/model.ts +187 -0
  249. package/src/stores/routes.ts +126 -0
  250. package/src/stores/unit.ts +57 -0
  251. package/src/suite/calibrate.ts +127 -0
  252. package/src/suite/core-counters.ts +91 -0
  253. package/src/suite/judge-suites.ts +94 -34
  254. package/src/suite/suite-cli.ts +44 -10
  255. package/src/suite/suite-cpu-preload.ts +34 -9
  256. package/src/trailer/adapter.ts +4 -0
  257. package/src/trailer/build.ts +42 -11
  258. package/src/trailer/ffmpeg.ts +11 -0
  259. package/src/trailer/footage.ts +30 -13
  260. package/src/trailer/grammar.ts +18 -2
  261. package/src/trailer/graph.ts +28 -6
  262. package/src/trailer/passage.ts +17 -5
  263. package/src/trailer/plan.ts +74 -3
  264. package/src/trailer/stitch.ts +67 -26
  265. package/src/trailer/url.ts +1 -1
  266. package/src/trailer/versions.ts +24 -0
  267. package/src/ts/gate-typecheck.ts +32 -0
  268. package/src/ts/typecheck-cli.ts +9 -11
  269. package/src/tui/tui-app.tsx +0 -1
  270. package/src/veille/asks.ts +155 -0
  271. package/src/veille/auto.ts +31 -0
  272. package/src/veille/batch.ts +27 -0
  273. package/src/veille/chrome.ts +127 -0
  274. package/src/veille/collection.ts +28 -0
  275. package/src/veille/desk.ts +242 -0
  276. package/src/veille/identity.ts +80 -0
  277. package/src/veille/import.ts +68 -0
  278. package/src/veille/log.ts +183 -0
  279. package/src/veille/platforms.ts +118 -0
  280. package/src/veille/reads.ts +66 -0
  281. package/src/veille/replied.ts +110 -0
  282. package/src/veille/routes.ts +185 -0
  283. package/src/veille/service.ts +81 -0
  284. package/src/veille/watch.ts +116 -0
  285. package/src/veille/worth.ts +46 -0
  286. package/src/wiki/scan-md.ts +18 -0
  287. package/src/collections/posts.ts +0 -142
  288. package/src/contracts/manifests/social.contract.ts +0 -20
  289. package/src/scaffold/files/agent-coding.md +0 -35
  290. package/src/ts/typecheck-cache.ts +0 -11
@@ -1,6 +1,6 @@
1
1
  // the views of one version, each its own numbered sub cell (`3.2`): a big title and its kind, drawn by kind (an image,
2
- // a pair side by side, as a curtain, an onion skin or the after alone, a clip on its own clock, a sound, a gallery), then
3
- // what was said on it right under it. Images come at the column's size (a 1600 px preview), the full file only on zoom.
2
+ // a pair side by side, as a curtain, an onion skin, the after alone or only its changes, a clip on its own clock, a sound,
3
+ // a gallery), with what was said on it and his word above the view. Images come at the column's size (a 1600 px preview), the full file only on zoom.
4
4
  // The newest version takes his marks: a drag on an image draws a rectangle whose note box opens beside it, a clip pauses
5
5
  // and keeps the frame's time. A choice, or views that each play alone, read as option rows, each image and clip full
6
6
  // under its row
@@ -14,6 +14,7 @@ import { blurOnEscape, FIT_ROOM, keepFocus, PAIR_NAMES, REACTIONS, secs, SIDE_LA
14
14
  import { ZOOMS, type Zoom } from './review-kit.ts'
15
15
  import { COMPARE_MODES, drawnSide, type CompareMode, type CompareSt, type PairSide, type ReviewSt } from './review-st.ts'
16
16
  import { viewDom, viewKind, viewKey, type ThreadSt } from './thread-st.ts'
17
+ import { Caret } from '../icons.tsx'
17
18
 
18
19
  const ZOOM_LABEL: Record<Zoom, string> = { fit: 'Fit', '1': '100 %', '1.5': '150 %', '2': '200 %' }
19
20
  const toneClass = (s: string | undefined): string => (s ? ` re-${s}` : '')
@@ -49,7 +50,7 @@ export const VersionViews = observer(({ ver }: { ver: Ver }) => {
49
50
  ) : null}
50
51
  {rv.phone.on && drawable ? <button className={rv.phone.draw ? 'primary' : ''} onClick={() => rv.phone.toggleDraw()}>Circle</button> : null}
51
52
  <span className="sp" />
52
- <span className="seg" title="the zoom every view starts at">
53
+ <span className="seg" title="the zoom of every view of every card">
53
54
  {ZOOMS.map((z) => <button key={z} className={rv.zoom === z ? 'on' : ''} onMouseDown={keepFocus} onClick={() => rv.setZoom(z)}>{ZOOM_LABEL[z]}</button>)}
54
55
  </span>
55
56
  </div>
@@ -62,21 +63,21 @@ export const VersionViews = observer(({ ver }: { ver: Ver }) => {
62
63
  )
63
64
  })
64
65
 
65
- /** one view as a sub cell: its number and title, its kind, the owner's reaction, its tools, the view, then what was said on it */
66
+ /** 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 */
66
67
  const ViewCell = observer(({ ver, v: live, i, frames }: { ver: Ver; v: ReviewView; i: number; frames?: GalleryView }) => {
67
68
  const { rv, card, cell } = ver
68
69
  const past = frames && card.frame !== null ? frames.gallery[card.frame] : undefined
69
70
  const v: ReviewView = past && !isGallery(live) ? { ...live, files: { image: past.file }, size: past.size } : live
70
71
  const media = isGallery(v) ? null : v
71
72
  const open = card.viewOpen(cell.id, i)
72
- const zoom = card.zoomOf(cell.id, i)
73
+ const zoom = rv.zoom
73
74
  const shown = card.reactionShown(cell, i)
74
75
  const active = ver.live && card.view === i
75
76
  const gone = goneOf(ver, v)
76
77
  return (
77
78
  <section id={viewDom(cell.id, i)} className={`rv-view${toneClass(shown?.status)}${active ? ' active' : ''}${open ? '' : ' folded'}`}>
78
79
  <header className="rv-viewhead">
79
- <button className="rv-foldbtn" aria-label={open ? 'fold this view' : 'unfold this view'} aria-expanded={open} onMouseDown={keepFocus} onClick={() => card.toggleView(cell.id, i)}>{open ? '▾' : '▸'}</button>
80
+ <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>
80
81
  <span className="rv-viewn">{viewTag(cell.n, i)}</span>
81
82
  <h4 className="rv-viewname" onClick={() => card.toggleView(cell.id, i)}>{v.label || <span className="rv-dim">{viewName(v, i)}</span>}</h4>
82
83
  <span className="rv-kind">{viewKind(v, false)}</span>
@@ -84,11 +85,8 @@ const ViewCell = observer(({ ver, v: live, i, frames }: { ver: Ver; v: ReviewVie
84
85
  <span className="sp" />
85
86
  {open && media?.marks && media.marks.length > 0 ? <button className={rv.marksOn ? 'primary' : ''} onMouseDown={keepFocus} onClick={() => rv.toggleMarks()}>marks · M</button> : null}
86
87
  {open && media && isPair(media.files) && !media.audio && !rv.phone.on ? <CompareModes c={rv.compare} /> : null}
87
- {open && media && !media.audio ? (
88
- <button title={zoom === 'fit' ? 'see this image at its own size, the full file' : 'fit this image to the column'} onMouseDown={keepFocus}
89
- onClick={() => card.setViewZoom(cell.id, i, zoom === 'fit' ? '1' : 'fit')}>{zoom === 'fit' ? '100 %' : 'Fit'}</button>
90
- ) : null}
91
88
  </header>
89
+ <ViewNotes ver={ver} i={i} gallery={isGallery(v)} />
92
90
  {open ? (
93
91
  <div className="rv-viewbody">
94
92
  {frames ? <FrameSlider card={card} frames={frames} /> : null}
@@ -96,12 +94,11 @@ const ViewCell = observer(({ ver, v: live, i, frames }: { ver: Ver; v: ReviewVie
96
94
  {media?.note ? <div className="rv-viewnote">{media.note}</div> : null}
97
95
  </div>
98
96
  ) : null}
99
- <ViewNotes ver={ver} i={i} gallery={isGallery(v)} />
100
97
  </section>
101
98
  )
102
99
  })
103
100
 
104
- /** what was said on one view, under it: each answer's rectangles and reactions (a click shows the rectangle), then on
101
+ /** what was said on one view, above it: each answer's rectangles and reactions (a click shows the rectangle), then on
105
102
  * the newest version his draft: each rectangle's word, his word on the view */
106
103
  const ViewNotes = observer(({ ver, i, gallery, word = true }: { ver: Ver; i: number; gallery: boolean; word?: boolean }) => {
107
104
  const { card, cell } = ver
@@ -205,7 +202,7 @@ const OptionRow = observer(({ ver, v, i }: { ver: Ver; v: ReviewView; i: number
205
202
  {choice ? <Stars card={card} view={i} live={ver.live} given={reaction?.stars} /> : ver.live ? <ReactionToggles card={card} view={i} /> : reaction?.status ? <SentReaction status={reaction.status} /> : null}
206
203
  {ver.live ? <button className={`rv-optword${showWord ? ' on' : ''}`} title="a word on this one" onMouseDown={keepFocus} onClick={() => setWord(!word)}>✎ word</button> : null}
207
204
  {playable?.clip || !playable ? (
208
- <button className={unfolded ? 'on' : ''} title={unfolded ? 'fold it back to its row' : 'show it full under its row'} onMouseDown={keepFocus} onClick={() => card.toggleRow(item, i)}>{unfolded ? '▴ fold' : '▾ show'}</button>
205
+ <button className={unfolded ? 'on' : ''} title={unfolded ? 'fold it back to its row' : 'show it full under its row'} onMouseDown={keepFocus} onClick={() => card.toggleRow(item, i)}><Caret v open={unfolded} /> {unfolded ? 'fold' : 'show'}</button>
209
206
  ) : null}
210
207
  {playable?.audio ? <a className="rv-dl" href={rv.fileUrl(id, file)} download={`${id}-${file}`} title="download the sound">⤓</a> : null}
211
208
  {choice && ver.live ? (
@@ -224,7 +221,7 @@ const OptionRow = observer(({ ver, v, i }: { ver: Ver; v: ReviewView; i: number
224
221
  {c && playable?.audio ? <SoundEl clip={c} src={rv.fileUrl(id, file)} /> : null}
225
222
  {unfolded ? (
226
223
  <div className="rv-optbody">
227
- {gone.length > 0 ? <Gone files={gone} /> : isGallery(v) ? <Gallery ver={ver} v={v} view={i} /> : <MediaBody ver={ver} v={v} i={i} zoom={card.zoomOf(id, i)} />}
224
+ {gone.length > 0 ? <Gone files={gone} /> : isGallery(v) ? <Gallery ver={ver} v={v} view={i} /> : <MediaBody ver={ver} v={v} i={i} zoom={ver.rv.zoom} />}
228
225
  </div>
229
226
  ) : null}
230
227
  <ViewNotes ver={ver} i={i} gallery={isGallery(v)} word={false} />
@@ -418,7 +415,7 @@ const MediaBody = observer(({ ver, v, i, zoom }: { ver: Ver; v: MediaView; i: nu
418
415
  <div style={scroll}>
419
416
  <div className="rv-pairgrid" style={{ width: scale ? `${v.size.w * scale * cols + 8 * (cols - 1)}px` : fitW, gridTemplateColumns: `repeat(${cols}, 1fr)` }}>
420
417
  <Compare c={c} base={before} mod={after} names={PAIR_NAMES} aspect={aspect}
421
- draw={(s) => <Marks ver={ver} src={s} side={drawnSide(c.mode, s === before ? 'before' : 'after')} view={i} />}
418
+ draw={(s, face) => <Marks ver={ver} src={s} side={drawnSide(c.mode, s === before ? 'before' : 'after')} view={i} face={face} />}
422
419
  over={(srcs) => (ver.live ? <RectNote card={card} view={i} sides={srcs.map((s) => drawnSide(c.mode, s === before ? 'before' : 'after'))} /> : null)} />
423
420
  </div>
424
421
  </div>
@@ -519,6 +516,7 @@ const MODES: { mode: CompareMode; glyph: string; tip: string }[] = [
519
516
  { mode: 'swipe', glyph: '⇹', tip: 'curtain: drag the line, the before on the left, the after on the right' },
520
517
  { mode: 'onion', glyph: '◐', tip: 'onion skin: the after over the before' },
521
518
  { mode: 'mod', glyph: '▣', tip: 'the after alone: hovering the image shows the before' },
519
+ { mode: 'diff', glyph: '≠', tip: 'only what changed: the after\'s changed pixels in colour, the rest faded' },
522
520
  ]
523
521
 
524
522
  /** the compare modes as tiny buttons, the onion's opacity floating under them */
@@ -527,7 +525,7 @@ const CompareModes = observer(({ c }: { c: CompareSt }) => (
527
525
  <span className="seg">
528
526
  {COMPARE_MODES.map((m) => {
529
527
  const o = MODES.find((x) => x.mode === m)!
530
- return <button key={m} title={o.tip} className={c.mode === m ? 'on' : ''} onMouseDown={keepFocus} onClick={() => c.setMode(m)}>{o.glyph}</button>
528
+ return <button key={m} title={`${o.tip} (D cycles, ⇧D back)`} className={c.mode === m ? 'on' : ''} onMouseDown={keepFocus} onClick={() => c.setMode(m)}>{o.glyph}</button>
531
529
  })}
532
530
  </span>
533
531
  {c.mode === 'onion' ? (
@@ -536,6 +534,65 @@ const CompareModes = observer(({ c }: { c: CompareSt }) => (
536
534
  </span>
537
535
  ))
538
536
 
537
+ /** a channel sum under this is the encoder's noise, never a change */
538
+ const DIFF_NOISE = 24
539
+
540
+ /** the share of the pixels that changed, as the caption says it */
541
+ const changesWords = (share: number | null | undefined): string =>
542
+ 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`
543
+
544
+ /** the after, only where it changed from the before: each changed pixel in its own colour, every other pixel a pale
545
+ * gray of it, so what moved is all that stands out. Read in the browser from the two previews; `say` gets the share
546
+ * that changed, undefined while it reads, null when an image cannot be read */
547
+ const DiffCanvas = ({ base, mod, say }: { base: string; mod: string; say: (share: number | null | undefined) => void }) => {
548
+ const ref = useRef<HTMLCanvasElement>(null)
549
+ useEffect(() => {
550
+ let gone = false
551
+ const load = (src: string): Promise<HTMLImageElement> =>
552
+ new Promise((ok, no) => {
553
+ const img = new Image()
554
+ img.onload = () => ok(img)
555
+ img.onerror = () => no(new Error(src))
556
+ img.src = src
557
+ })
558
+ say(undefined)
559
+ Promise.all([load(base), load(mod)]).then(([a, b]) => {
560
+ const cv = ref.current
561
+ if (gone || cv == null) return
562
+ const w = b.naturalWidth
563
+ const h = b.naturalHeight
564
+ cv.width = w
565
+ cv.height = h
566
+ const ctx = cv.getContext('2d', { willReadFrequently: true })
567
+ if (ctx == null) return say(null)
568
+ ctx.drawImage(a, 0, 0, w, h)
569
+ const pa = ctx.getImageData(0, 0, w, h).data
570
+ ctx.drawImage(b, 0, 0, w, h)
571
+ const out = ctx.getImageData(0, 0, w, h)
572
+ const pb = out.data
573
+ let changed = 0
574
+ for (let i = 0; i < pb.length; i += 4) {
575
+ if (Math.abs(pa[i]! - pb[i]!) + Math.abs(pa[i + 1]! - pb[i + 1]!) + Math.abs(pa[i + 2]! - pb[i + 2]!) > DIFF_NOISE) {
576
+ changed++
577
+ continue
578
+ }
579
+ const v = 228 + (pb[i]! * 0.3 + pb[i + 1]! * 0.59 + pb[i + 2]! * 0.11) * 0.1
580
+ pb[i] = v
581
+ pb[i + 1] = v
582
+ pb[i + 2] = v
583
+ }
584
+ ctx.putImageData(out, 0, 0)
585
+ say(changed / (w * h))
586
+ }, () => {
587
+ if (!gone) say(null)
588
+ })
589
+ return () => {
590
+ gone = true
591
+ }
592
+ }, [base, mod, say])
593
+ return <canvas ref={ref} className="rv-diff" />
594
+ }
595
+
539
596
  /** follows the pointer until it is released */
540
597
  function track(move: (e: PointerEvent) => void): void {
541
598
  const up = (): void => {
@@ -549,8 +606,9 @@ function track(move: (e: PointerEvent) => void): void {
549
606
  /** THE pair: side by side, the curtain clipping both images, the after over the before as an onion skin, or the
550
607
  * after alone (the before while the pointer is over it). One image alone when `mod` is undefined. `over` draws what
551
608
  * sits over a frame unclipped (the picked rectangle's note box), given the images that frame shows */
552
- const Compare = observer(({ c, base, mod, names, aspect, draw, over }: { c: CompareSt; base: string; mod: string | undefined; names?: { base: string; mod: string }; aspect: string; draw: (src: string) => ReactNode; over?: (srcs: string[]) => ReactNode }) => {
609
+ const Compare = observer(({ c, base, mod, names, aspect, draw, over }: { c: CompareSt; base: string; mod: string | undefined; names?: { base: string; mod: string }; aspect: string; draw: (src: string, face?: ReactNode) => ReactNode; over?: (srcs: string[]) => ReactNode }) => {
553
610
  const [peek, setPeek] = useState(false)
611
+ const [share, setShare] = useState<number | null | undefined>(undefined)
554
612
  if (mod === undefined) return <Frame aspect={aspect} caption={null} over={over?.([base])}><div className="rv-fill">{draw(base)}</div></Frame>
555
613
  const n = names ?? PAIR_NAMES
556
614
  if (c.mode === 'side')
@@ -560,6 +618,12 @@ const Compare = observer(({ c, base, mod, names, aspect, draw, over }: { c: Comp
560
618
  <Frame aspect={aspect} caption={n.mod} modCap over={over?.([mod])}><div className="rv-fill">{draw(mod)}</div></Frame>
561
619
  </>
562
620
  )
621
+ if (c.mode === 'diff')
622
+ return (
623
+ <Frame aspect={aspect} caption={<>changes <span className="rv-modcap">{changesWords(share)}</span></>} over={over?.([mod])}>
624
+ <div className="rv-fill">{draw(mod, <DiffCanvas base={base} mod={mod} say={setShare} />)}</div>
625
+ </Frame>
626
+ )
563
627
  if (c.mode === 'mod')
564
628
  return (
565
629
  <Frame aspect={aspect} caption={peek ? n.base : n.mod} modCap={!peek} onPeek={setPeek} over={over?.([peek ? base : mod])}>
@@ -615,7 +679,8 @@ const MIN_DRAG = 0.01
615
679
  /** one image of view `view` and its rectangles: the ones his answers sent (still), and on the newest version his
616
680
  * draft's, a drag drawing one (never in the curtain, whose drag moves the line). A clip view of the newest version that
617
681
  * is not the active one loops on its own: a click makes it active */
618
- const Marks = observer(({ ver, src, side, view }: { ver: Ver; src: string; side: Side | undefined; view: number }) => {
682
+ /** an image or a clip and what is drawn on it; `face` takes the image's place (the changes of a pair) */
683
+ const Marks = observer(({ ver, src, side, view, face }: { ver: Ver; src: string; side: Side | undefined; view: number; face?: ReactNode }) => {
619
684
  const { rv, card, cell } = ver
620
685
  const el = useRef<HTMLDivElement>(null)
621
686
  const [drag, setDrag] = useState<{ x0: number; y0: number; x1: number; y1: number } | null>(null)
@@ -671,7 +736,7 @@ const Marks = observer(({ ver, src, side, view }: { ver: Ver; src: string; side:
671
736
  const live = drawing || (clip !== undefined && ver.live && !active)
672
737
  return (
673
738
  <div ref={el} className={`rv-marks${clip && ver.live && !active ? ' pick' : drawing ? ' draw' : ''}`} onPointerDown={down} style={{ pointerEvents: live ? 'auto' : 'none', touchAction: drawing ? 'none' : undefined }}>
674
- {c ? <ClipVideo key={src} clip={c} src={src} poster={shown?.clip ? rv.fitUrl(cell.id, shown.clip.poster) : undefined} preload={ver.live ? 'auto' : 'none'} /> : <img src={src} alt="" draggable={false} className="rv-markimg" loading="lazy" decoding="async" />}
739
+ {face ?? (c ? <ClipVideo key={src} clip={c} src={src} poster={shown?.clip ? rv.fitUrl(cell.id, shown.clip.poster) : undefined} preload={ver.live ? 'auto' : 'none'} /> : <img src={src} alt="" draggable={false} className="rv-markimg" loading="lazy" decoding="async" />)}
675
740
  {shown && rings.length > 0 ? <Rings marks={rings} w={shown.size.w} h={shown.size.h} /> : null}
676
741
  {sent.map(({ r, n }, k) => <div key={`s${k}`} className={`rv-rect sent${onIts(r) ? '' : ' faint'}`} style={pct(r)} title={r.comment || `rectangle ${n}`}><span className="rv-rectn">{n}</span></div>)}
677
742
  {rects.map(([r, i]) => (
@@ -21,7 +21,7 @@ import {
21
21
  type Side,
22
22
  } from '../../../review/model.ts'
23
23
  import { ClipSt } from './clip-st.ts'
24
- import { etagLoader, postJson, type Zoom } from './review-kit.ts'
24
+ import { etagLoader, postJson } from './review-kit.ts'
25
25
  import type { ReviewSt } from './review-st.ts'
26
26
 
27
27
  export interface Draft {
@@ -115,7 +115,6 @@ export class ThreadSt {
115
115
  rect: number | null = null
116
116
  /** the rectangle whose note box takes the focus once it shows */
117
117
  noteFocus: number | null = null
118
- viewZoom: Record<string, Zoom> = {}
119
118
  /** the gallery tile shown large, `<item>#<view>/<tile>` */
120
119
  bigTile: string | null = null
121
120
  /** a draft card's past frame shown in place of its live one; null is now */
@@ -582,14 +581,6 @@ export class ThreadSt {
582
581
  this.rect = null
583
582
  }
584
583
 
585
- zoomOf(id: string, i: number): Zoom {
586
- return this.viewZoom[viewKey(id, i)] ?? this.rv.zoom
587
- }
588
-
589
- setViewZoom(id: string, i: number, z: Zoom): void {
590
- this.viewZoom = { ...this.viewZoom, [viewKey(id, i)]: z }
591
- }
592
-
593
584
  setFrame(f: number | null): void {
594
585
  this.frame = f
595
586
  }
@@ -14,6 +14,7 @@ import { PANEL, PhoneTop } from './review-page.tsx'
14
14
  import { ClipSound } from './review-views.tsx'
15
15
  import { hueOf, ShotCards, TrailerTimeline } from './trailer-timeline.tsx'
16
16
  import { captionText, type PlacedNote, type TrailerSt } from './trailer-st.ts'
17
+ import { Caret } from '../icons.tsx'
17
18
 
18
19
  export const TrailerPage = observer(({ app }: { app: RepoSt }) => {
19
20
  const tr = app.trailer
@@ -251,7 +252,7 @@ const Montage = observer(({ tr }: { tr: TrailerSt }) => {
251
252
  const m = tr.montage
252
253
  return (
253
254
  <div className="tr-montage">
254
- <button className="ghost" onClick={() => void tr.toggleMontage()}>{tr.montageOpen ? '▾' : '▸'} montage</button>
255
+ <button className="ghost" onClick={() => void tr.toggleMontage()}><Caret open={tr.montageOpen} /> montage</button>
255
256
  {tr.montageOpen ? (m == null ? <span className="spin" /> : m.md == null ? <div className="rv-dim">This render has no montage page.</div> : <div className="md tr-montagebody" dangerouslySetInnerHTML={{ __html: renderMd(m.md) }} />) : null}
256
257
  </div>
257
258
  )
@@ -1,4 +1,4 @@
1
- /* the review page and the trailer page (hub-app/review/): pkm-multi's Revue and Trailer tabs on the hub's tokens.
1
+ /* the review page and the trailer page (hub-app/review/): a project's review and trailer tabs on the hub's tokens.
2
2
  A status, a reaction, a note state and a section each set --tone or --hue, and the parts read it, so no rule here
3
3
  writes a colour (tests/hub-css-invariants.test.ts) */
4
4
  .st-pending{--tone:var(--blue)}
@@ -102,7 +102,9 @@
102
102
  .rv-copyid:hover{color:var(--ink)}
103
103
  .rv-toast{position:fixed;left:50%;bottom:var(--s4);transform:translateX(-50%);z-index:40;max-width:calc(100% - 2 * var(--s4));padding:var(--s1) var(--s3);border-radius:6px;border:1px solid var(--line);background:var(--panel);color:var(--ink);font-size:12.5px;box-shadow:0 6px 20px var(--shadow)}
104
104
  .rv-threadbody{position:relative;flex:1;min-height:0;display:flex}
105
- .rv-cells{position:relative;flex:1;min-width:0;overflow-y:auto;display:flex;flex-direction:column;gap:var(--s3);padding:var(--s3) var(--s4) var(--s4)}
105
+ /* a sticky row inside sticks under the scroller's top padding, and the cells scroll through that band above it:
106
+ --stick pulls it up to the edge, by the same var(--s3) */
107
+ .rv-cells{--stick:calc(-1 * var(--s3));position:relative;flex:1;min-width:0;overflow-y:auto;display:flex;flex-direction:column;gap:var(--s3);padding:var(--s3) var(--s4) var(--s4)}
106
108
  .rv-day{display:flex;align-items:center;gap:var(--s2);margin-top:var(--s2);font-size:10.5px;font-weight:800;text-transform:uppercase;letter-spacing:.08em;color:var(--dim)}
107
109
  .rv-day::before,.rv-day::after{content:'';flex:1;border-top:1px solid var(--line)}
108
110
  .rv-events{display:flex;flex-direction:column;gap:var(--s0)}
@@ -208,15 +210,16 @@
208
210
  .rv-view[class*=' re-']{border-color:color-mix(in srgb,var(--tone) 55%,var(--line))}
209
211
  .rv-view.active{border-color:color-mix(in srgb,var(--accent) 55%,var(--line))}
210
212
  /* one sticky row per view: its label, its title, the owner's verdict on it, the tools; it stays at the top while the view scrolls */
211
- .rv-viewhead{position:sticky;top:0;z-index:4;display:flex;flex-wrap:wrap;gap:var(--s1) var(--s2);align-items:center;padding:var(--s2) var(--s3) var(--s2) var(--s1);border-bottom:1px solid var(--line);border-radius:7px 7px 0 0;background:color-mix(in srgb,var(--panel2) 70%,var(--bg));box-shadow:0 2px 6px var(--shadow)}
213
+ .rv-viewhead{position:sticky;top:var(--stick,0);z-index:4;display:flex;flex-wrap:wrap;gap:var(--s1) var(--s2);align-items:center;padding:var(--s2) var(--s3) var(--s2) var(--s1);border-bottom:1px solid var(--line);border-radius:7px 7px 0 0;background:color-mix(in srgb,var(--panel2) 70%,var(--bg));box-shadow:0 2px 6px var(--shadow)}
212
214
  .rv-view.folded .rv-viewhead{border-bottom:0;border-radius:4px 7px 7px 4px}
213
215
  .rv-viewn{flex:none;font:800 18px/30px ui-monospace,Menlo,monospace;padding:0 var(--s3);border-radius:6px;color:var(--bg);background:var(--ink)}
214
216
  .rv-viewname{margin:0;min-width:0;font-size:16px;line-height:1.3;font-weight:700;color:var(--ink);cursor:pointer}
215
217
  .rv-kind{flex:none;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.07em;color:var(--dim);border:1px solid var(--line);border-radius:10px;padding:0 var(--s2);line-height:18px}
216
218
  .rv-viewbody{padding:var(--s3)}
217
219
  .rv-viewnote{margin-top:var(--s2);font-size:13px;color:var(--ink)}
218
- .rv-viewnotes{display:flex;flex-direction:column;gap:var(--s1);padding:0 var(--s3) var(--s3)}
219
- .rv-view.folded .rv-viewnotes{padding-top:var(--s2)}
220
+ /* above the view, under its head: what was said on it and his word, read and written before the image */
221
+ .rv-viewnotes{display:flex;flex-direction:column;gap:var(--s1);padding:var(--s3) var(--s3) 0}
222
+ .rv-view.folded .rv-viewnotes{padding:var(--s2) var(--s3) var(--s3)}
220
223
  .rv-said{display:flex;gap:var(--s2);align-items:baseline;padding:var(--s1) var(--s2);font-size:13px;line-height:1.4;border-radius:6px;border-left:3px solid var(--tone,var(--k4));background:color-mix(in srgb,var(--tone,var(--k4)) 8%,transparent)}
221
224
  .rv-said.rect{--tone:var(--k4)}
222
225
  .rv-saidmark{flex:none;font-weight:800;color:var(--tone,var(--k4));white-space:nowrap}
@@ -247,6 +250,8 @@ span.rv-react{display:inline-block;border:1px solid;border-radius:4px}
247
250
  .rv-marks.draw{cursor:crosshair}
248
251
  .rv-marks.pick{cursor:pointer}
249
252
  .rv-markimg,.rv-video{display:block;width:100%;height:100%;pointer-events:none}
253
+ /* the changes of a pair: the after's changed pixels on its faded self, drawn in place of the image */
254
+ .rv-diff{display:block;width:100%;height:100%;pointer-events:none}
250
255
  .rv-rings{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
251
256
  .rv-ring{fill:none;stroke:var(--warn);stroke-width:3}
252
257
  .rv-ringshade{fill:none;stroke:var(--solid);stroke-opacity:.35;stroke-width:7}
@@ -295,7 +300,7 @@ span.rv-react{display:inline-block;border:1px solid;border-radius:4px}
295
300
  .rv-opt.picked{--tone:var(--ok);border-color:var(--tone);border-left-color:var(--tone);background:color-mix(in srgb,var(--tone) 9%,var(--bg))}
296
301
  .rv-optrow{display:flex;flex-wrap:wrap;gap:var(--s1) var(--s2);align-items:center;min-height:36px}
297
302
  .rv-optn{flex:none;font:800 16px/28px ui-monospace,Menlo,monospace;padding:0 8px;border-radius:5px;color:var(--bg);background:var(--ink)}
298
- .rv-opt.unfolded > .rv-optrow{position:sticky;top:0;z-index:4;margin:calc(-1 * var(--s1)) calc(-1 * var(--s2)) 0;padding:var(--s1) var(--s2);border-radius:7px 7px 0 0;background:var(--bg);box-shadow:0 2px 6px var(--shadow)}
303
+ .rv-opt.unfolded > .rv-optrow{position:sticky;top:var(--stick,0);z-index:4;margin:calc(-1 * var(--s1)) calc(-1 * var(--s2)) 0;padding:var(--s1) var(--s2);border-radius:7px 7px 0 0;background:var(--bg);box-shadow:0 2px 6px var(--shadow)}
299
304
  .rv-optplay{flex:none;width:32px;height:28px;padding:0;font-size:13px}
300
305
  .rv-optplay.on{color:var(--bg);background:var(--accent);border-color:var(--accent)}
301
306
  .rv-optlabel{flex:0 1 auto;min-width:48px;max-width:30%;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
@@ -332,6 +337,10 @@ span.rv-pick{display:inline-block;border:1px solid;border-radius:4px;font-size:1
332
337
  .rv-outbadge.rect{--tone:var(--warn)}
333
338
  .rv-outbadge.rect.on{--tone:var(--blue)}
334
339
  .rv-x{flex:none;padding:0 var(--s1);border:0}
340
+ /* a seg's icon button (fold every cell, unfold every cell): the icon centred, the row's height kept */
341
+ .rv-iconbtn{display:inline-flex;align-items:center;justify-content:center;padding:0 var(--s2)}
342
+ .rv-fold{flex:none;padding:0 var(--s2);font-size:11px;text-transform:none;letter-spacing:0;color:var(--dim)}
343
+ .rv-fold:hover{color:var(--ink)}
335
344
 
336
345
  /* ── the phone: the page covers the hub's panes, one pane at a time, the verdicts under the thumb ── */
337
346
  .rv-phone,.tr-phone{position:fixed;inset:0;z-index:30;background:var(--bg)}
@@ -347,7 +356,7 @@ span.rv-pick{display:inline-block;border:1px solid;border-radius:4px;font-size:1
347
356
  .rv-phone .rv-cbody{padding:var(--s2)}
348
357
  .rv-phone .rv-chead .rv-copyid{display:none}
349
358
  .rv-phone .rv-viewbody{padding:var(--s1)}
350
- .rv-phone .rv-viewnotes{padding:0 var(--s1) var(--s2)}
359
+ .rv-phone .rv-viewnotes{padding:var(--s2) var(--s1) 0}
351
360
  .rv-phone .rv-viewname{font-size:15px}
352
361
  .rv-phone .rv-composer{padding:var(--s2)}
353
362
  .rv-phone .rv-acts .sp{display:none}
@@ -501,7 +510,7 @@ span.rv-pick{display:inline-block;border:1px solid;border-radius:4px;font-size:1
501
510
  .rv-c.k-version > .rv-cbody{padding:0}
502
511
  .rv-vgrid{display:grid;grid-template-columns:52px minmax(0,1fr)}
503
512
  .rv-gut{border-right:1px solid color-mix(in srgb,var(--who) 35%,var(--line));border-radius:0 0 0 9px;background:color-mix(in srgb,var(--who) 12%,var(--panel2))}
504
- .rv-gutlabel{position:sticky;top:0;display:block;padding:var(--s2) 0;text-align:center;font:800 19px/1.2 ui-monospace,Menlo,monospace;color:var(--who)}
513
+ .rv-gutlabel{position:sticky;top:var(--stick,0);display:block;padding:var(--s2) 0;text-align:center;font:800 19px/1.2 ui-monospace,Menlo,monospace;color:var(--who)}
505
514
  .rv-vmain{min-width:0;display:flex;flex-direction:column;gap:var(--s3);padding:var(--s3)}
506
515
  .rv-phone .rv-vgrid{grid-template-columns:30px minmax(0,1fr)}
507
516
  .rv-phone .rv-gutlabel{font-size:12.5px}
@@ -0,0 +1,173 @@
1
+ // the identity view's site section (wiki build/shipkit/site.md, The section): the facts (the address and whether it
2
+ // answers, the repo that builds it, its Site account), then the desk its repo's site unit gives: the pages on the left,
3
+ // the one picked live from the local preview in the middle, what is online, what changed since and the deploy on the right
4
+ import { observer } from 'mobx-react-lite'
5
+ import { useEffect, type MouseEvent } from 'react'
6
+ import type { MachineIdentity } from '../../../identities/machine-route.ts'
7
+ import type { HomeSt } from '../home-st.ts'
8
+ import { plainClick, repoPage } from '../home-st.ts'
9
+ import { identityAddress } from '../identity-address.ts'
10
+ import { siteStOf, type SitePage, type SiteSt } from './site-st.ts'
11
+
12
+ const when = (iso: string): string => new Date(iso).toLocaleString('en-GB', { dateStyle: 'medium', timeStyle: 'short' })
13
+
14
+ const inPlace = (run: () => void) => (e: MouseEvent): void => {
15
+ if (!plainClick(e)) return
16
+ e.preventDefault()
17
+ run()
18
+ }
19
+
20
+ export const SitePart = observer(({ app, i }: { app: HomeSt; i: MachineIdentity }) => {
21
+ const s = siteStOf(app, i.id)
22
+ useEffect(() => {
23
+ s.start()
24
+ return () => s.stop()
25
+ }, [s])
26
+ const a = s.answer
27
+ return (
28
+ <div className="idpage site">
29
+ <div className="so-colin">
30
+ <h2 className="so-h so-big">{i.name} <span className="rv-dim so-light">· the site</span></h2>
31
+ <Facts app={app} i={i} s={s} />
32
+ {s.loadError != null ? <div className="hnote">{s.loadError}</div> : null}
33
+ {a?.error != null ? <div className="hnote">{a.error}</div> : null}
34
+ {a?.missing != null ? <div className="site-missing">{a.missing}</div> : null}
35
+ {a == null && s.loadError == null ? <div className="iddim"><span className="spin" />reading the site…</div> : null}
36
+ </div>
37
+ {a?.desk != null ? <Desk s={s} /> : null}
38
+ </div>
39
+ )
40
+ })
41
+
42
+ const Facts = observer(({ app, i, s }: { app: HomeSt; i: MachineIdentity; s: SiteSt }) => {
43
+ const a = s.answer
44
+ const account = i.accounts.find((x) => x.id === 'site')
45
+ const online = a?.online
46
+ const repo = a?.repo
47
+ return (
48
+ <dl className="idfacts">
49
+ <dt>address</dt>
50
+ <dd>
51
+ {i.site === '' ? <span className="iddim">none named (site: in identity.md)</span> : <a href={i.site} target="_blank" rel="noreferrer">{i.site} ↗</a>}
52
+ {online == null ? null : (
53
+ <span className={`site-online${online.status != null && online.status < 400 ? ' up' : ''}`} title={`asked ${when(online.at)}`}>
54
+ {online.status == null ? 'no answer' : online.status < 400 ? `answers (${online.status})` : `answers ${online.status}`}
55
+ </span>
56
+ )}
57
+ </dd>
58
+ <dt>built by</dt>
59
+ <dd>
60
+ {i.siteRepo === '' ? <span className="iddim">no repo named (siteRepo: in identity.md)</span>
61
+ : repo?.house ? <a href={repoPage(i.siteRepo)} onClick={inPlace(() => app.select(i.siteRepo))}>{i.siteRepo}</a>
62
+ : <span>{i.siteRepo} <span className="iddim">{repo?.path != null ? `(${repo.path.replace(/^\/Users\/[^/]+/, '~')}, not a house repo)` : '(not on this disk)'}</span></span>}
63
+ </dd>
64
+ {account == null ? null : (
65
+ <>
66
+ <dt>account</dt>
67
+ <dd>
68
+ <a href={identityAddress({ id: i.id, part: 'site', place: null })} onClick={inPlace(() => app.openIdentity({ id: i.id, part: 'site', place: null }))}>
69
+ its Site account, {account.live === '' ? 'to create' : 'online'}
70
+ </a>
71
+ </dd>
72
+ </>
73
+ )}
74
+ </dl>
75
+ )
76
+ })
77
+
78
+ const Desk = observer(({ s }: { s: SiteSt }) => (
79
+ <div className="site-desk">
80
+ <Pages s={s} />
81
+ <Preview s={s} />
82
+ <State s={s} />
83
+ </div>
84
+ ))
85
+
86
+ /** ↑ ↓ walk the pages while the list holds the focus; the identity list's own walk (on the document) never sees them */
87
+ const Pages = observer(({ s }: { s: SiteSt }) => (
88
+ <nav className="site-pages" tabIndex={0} aria-label="the pages of the site" onKeyDown={(e) => {
89
+ const d = e.key === 'ArrowDown' ? 1 : e.key === 'ArrowUp' ? -1 : 0
90
+ if (d === 0 || e.metaKey || e.ctrlKey || e.altKey) return
91
+ e.preventDefault()
92
+ e.stopPropagation()
93
+ s.move(d)
94
+ }}>
95
+ {s.pages.map((p) => <PageRow key={p.path} s={s} p={p} />)}
96
+ </nav>
97
+ ))
98
+
99
+ const PageRow = observer(({ s, p }: { s: SiteSt; p: SitePage }) => {
100
+ const on = s.current?.path === p.path
101
+ const post = /^\/[^/]+\/.+/.test(p.path)
102
+ const changed = s.changed(p)
103
+ return (
104
+ <button className={`site-page${on ? ' on' : ''}${post ? ' sub' : ''}`} onClick={() => s.pick(p.path)}>
105
+ <i className={`site-dot${changed ? ' changed' : ''}`} title={changed ? 'changed since the deploy' : undefined} />
106
+ <span className="site-ptext">
107
+ <b>{p.title}</b>
108
+ <span className="iddim">{p.path}{p.draft ? ' · draft' : ''}</span>
109
+ </span>
110
+ </button>
111
+ )
112
+ })
113
+
114
+ const Preview = observer(({ s }: { s: SiteSt }) => {
115
+ const page = s.current
116
+ const preview = s.answer?.desk?.preview
117
+ return (
118
+ <div className="site-preview">
119
+ <div className="site-bar">
120
+ <b className="so-ellip">{page?.title ?? ''}</b>
121
+ <span className="site-switch" role="group" aria-label="the preview's width">
122
+ <button className={s.phone ? 'ghost' : 'on'} onClick={() => s.setPhone(false)}>desktop</button>
123
+ <button className={s.phone ? 'on' : 'ghost'} onClick={() => s.setPhone(true)}>phone</button>
124
+ </span>
125
+ {s.src != null ? <a className="site-open" href={s.src} target="_blank" rel="noreferrer">open ↗</a> : null}
126
+ </div>
127
+ {preview == null ? <div className="rv-empty">the site unit names no local preview</div>
128
+ : s.previewError != null ? <div className="hnote">{s.previewError}</div>
129
+ : s.src != null ? (
130
+ <div className={`site-frame${s.phone ? ' phone' : ''}`}>
131
+ <iframe key={s.src} src={s.src} title={page?.title} />
132
+ </div>
133
+ ) : <div className="rv-empty"><span className="spin" />{s.starting ? `the preview starts (${preview.url})…` : 'reading…'}</div>}
134
+ </div>
135
+ )
136
+ })
137
+
138
+ const State = observer(({ s }: { s: SiteSt }) => {
139
+ const d = s.answer?.desk
140
+ if (d == null) return null
141
+ const titleOf = (path: string): string => (path === '*' ? 'Every page (code, styles, pictures, accounts)' : (s.pages.find((x) => x.path === path)?.title ?? path))
142
+ const since = d.dated?.since ?? 0
143
+ return (
144
+ <div className="site-state">
145
+ <section>
146
+ <b className="site-h">online</b>
147
+ {d.deployed != null ? (
148
+ <>
149
+ <span>{when(d.deployed.at)}</span>
150
+ <span className="iddim">commit {d.deployed.commit.slice(0, 10)} · {d.deployed.source === 'record' ? 'its deploy record' : 'read on Cloudflare Pages'}</span>
151
+ </>
152
+ ) : <span className="iddim">no deploy known</span>}
153
+ </section>
154
+ <section>
155
+ <b className="site-h">changed since</b>
156
+ {since > 0 ? <span>{since} {d.dated?.words} since</span> : null}
157
+ {d.deployed != null && d.changes.length === 0 && since === 0 ? <span className="iddim">nothing: the site online is up to date</span> : null}
158
+ {d.changes.map((c) => (
159
+ <span key={c.path} title={c.files.join('\n')}>
160
+ {c.path === '*' ? <b>{titleOf(c.path)}</b> : <a href="#" onClick={(e) => { e.preventDefault(); s.pick(c.path) }}>{titleOf(c.path)}</a>}
161
+ <span className="iddim"> · {c.files.length} file{c.files.length === 1 ? '' : 's'}</span>
162
+ </span>
163
+ ))}
164
+ </section>
165
+ {d.deploy == null ? <span className="iddim">the site unit names no deploy</span> : (
166
+ <button className="site-deploy" disabled={s.deploying || d.deploying} onClick={() => void s.deploy()} title={d.deploy.about ?? undefined}>
167
+ {s.deploying || d.deploying ? <><span className="spin" />deploying…</> : 'Deploy'}
168
+ </button>
169
+ )}
170
+ {s.log !== null ? <pre className="site-log">{s.log || '…'}</pre> : null}
171
+ </div>
172
+ )
173
+ })