rvlib-shipkit 2.11.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 (298) hide show
  1. package/CHANGELOG.md +56 -12
  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 +96 -5
  20. package/src/cli/cmd_Review.ts +8 -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 +9 -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 +61 -6
  68. package/src/home/inbox.ts +75 -4
  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 +110 -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 +9 -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/content.ts +11 -1
  100. package/src/media-store/daemon.ts +56 -70
  101. package/src/media-store/hand.ts +58 -0
  102. package/src/media-store/put.ts +122 -0
  103. package/src/media-store/space.ts +73 -11
  104. package/src/pages/forward.ts +35 -0
  105. package/src/pages/frame-client.ts +118 -0
  106. package/src/pages/routes.ts +29 -0
  107. package/src/pages/unit.ts +92 -0
  108. package/src/plan/planner.ts +12 -0
  109. package/src/plan/repo-source.ts +19 -5
  110. package/src/reflect/transcript.ts +35 -10
  111. package/src/release/public-clean.ts +301 -0
  112. package/src/release/published-here.ts +22 -0
  113. package/src/release/run-bump.ts +2 -1
  114. package/src/release/run-release.ts +4 -1
  115. package/src/repo-config.ts +53 -2
  116. package/src/review/http.ts +16 -2
  117. package/src/review/media-kind.ts +3 -3
  118. package/src/review/media-read.ts +3 -3
  119. package/src/review/model.ts +24 -5
  120. package/src/review/notes.ts +77 -0
  121. package/src/review/project.ts +6 -38
  122. package/src/review/routes.ts +8 -13
  123. package/src/review/store.ts +46 -4
  124. package/src/review/trailer-media.ts +24 -3
  125. package/src/review/trailer-shots.ts +106 -0
  126. package/src/review/unit.ts +1 -1
  127. package/src/scaffold/files/agent-handoff.md +3 -0
  128. package/src/scaffold/files/agent-index.md +4 -12
  129. package/src/scaffold/project-scaffold.ts +5 -4
  130. package/src/serve/embed.ts +1 -1
  131. package/src/serve/hub-app/col-card.tsx +3 -17
  132. package/src/serve/hub-app/col-tables-view.tsx +2 -1
  133. package/src/serve/hub-app/cols-svc.ts +12 -14
  134. package/src/serve/hub-app/dock-st.ts +4 -2
  135. package/src/serve/hub-app/dock-view.tsx +2 -0
  136. package/src/serve/hub-app/frames-st.ts +35 -0
  137. package/src/serve/hub-app/hash-route.ts +64 -1
  138. package/src/serve/hub-app/home-st.ts +31 -7
  139. package/src/serve/hub-app/home-strip.css +9 -1
  140. package/src/serve/hub-app/home-strip.tsx +7 -6
  141. package/src/serve/hub-app/home.html +5 -0
  142. package/src/serve/hub-app/hub-app.tsx +49 -5
  143. package/src/serve/hub-app/hub.css +29 -11
  144. package/src/serve/hub-app/icons.tsx +16 -1
  145. package/src/serve/hub-app/identities-st.ts +210 -0
  146. package/src/serve/hub-app/identities-view.tsx +352 -0
  147. package/src/serve/hub-app/identities.css +48 -0
  148. package/src/serve/hub-app/identity-address.ts +52 -0
  149. package/src/serve/hub-app/inbox-st.ts +59 -6
  150. package/src/serve/hub-app/inbox-view.tsx +48 -6
  151. package/src/serve/hub-app/inbox.css +12 -1
  152. package/src/serve/hub-app/index.html +3 -0
  153. package/src/serve/hub-app/keys.ts +10 -2
  154. package/src/serve/hub-app/list-walk.ts +89 -0
  155. package/src/serve/hub-app/machine-st.ts +12 -0
  156. package/src/serve/hub-app/media-view.tsx +2 -1
  157. package/src/serve/hub-app/pages-frames.tsx +134 -0
  158. package/src/serve/hub-app/pages-svc.ts +111 -0
  159. package/src/serve/hub-app/palette-st.ts +18 -3
  160. package/src/serve/hub-app/palette-view.tsx +9 -2
  161. package/src/serve/hub-app/planned-view.tsx +2 -1
  162. package/src/serve/hub-app/project-list.css +18 -14
  163. package/src/serve/hub-app/project-list.tsx +88 -49
  164. package/src/serve/hub-app/projects-svc.ts +33 -3
  165. package/src/serve/hub-app/repo-sections.ts +19 -2
  166. package/src/serve/hub-app/repo-st.ts +75 -19
  167. package/src/serve/hub-app/review/review-cells.tsx +3 -3
  168. package/src/serve/hub-app/review/review-kit.ts +30 -7
  169. package/src/serve/hub-app/review/review-page.tsx +1 -1
  170. package/src/serve/hub-app/review/review-st.ts +33 -11
  171. package/src/serve/hub-app/review/review-thread.tsx +11 -9
  172. package/src/serve/hub-app/review/review-views.tsx +84 -19
  173. package/src/serve/hub-app/review/thread-st.ts +1 -10
  174. package/src/serve/hub-app/review/trailer-page.tsx +2 -1
  175. package/src/serve/hub-app/review.css +17 -8
  176. package/src/serve/hub-app/site/site-part.tsx +173 -0
  177. package/src/serve/hub-app/site/site-st.ts +157 -0
  178. package/src/serve/hub-app/site.css +35 -0
  179. package/src/serve/hub-app/social/calendar.tsx +182 -0
  180. package/src/serve/hub-app/social/comms-page.tsx +306 -0
  181. package/src/serve/hub-app/social/kit.tsx +244 -0
  182. package/src/serve/hub-app/social/post-card.tsx +456 -0
  183. package/src/serve/hub-app/social/problems.tsx +60 -0
  184. package/src/serve/hub-app/social/social-model.ts +154 -0
  185. package/src/serve/hub-app/social/social-page.tsx +674 -0
  186. package/src/serve/hub-app/social/social-st.ts +986 -0
  187. package/src/serve/hub-app/social.css +289 -0
  188. package/src/serve/hub-app/stores/stores-page.tsx +311 -0
  189. package/src/serve/hub-app/stores/stores-st.ts +286 -0
  190. package/src/serve/hub-app/stores.css +54 -0
  191. package/src/serve/hub-app/test-view.tsx +9 -2
  192. package/src/serve/hub-app/tests-svc.ts +16 -1
  193. package/src/serve/hub-app/timeline-geometry.ts +1 -1
  194. package/src/serve/hub-app/timeline-view.tsx +3 -2
  195. package/src/serve/hub-app/tree-build.ts +6 -0
  196. package/src/serve/hub-app/tree-row.tsx +27 -4
  197. package/src/serve/hub-app/tree-svc.ts +18 -49
  198. package/src/serve/hub-app/veille/veille-page.tsx +514 -0
  199. package/src/serve/hub-app/veille/veille-st.ts +443 -0
  200. package/src/serve/hub-app/veille.css +84 -0
  201. package/src/serve/hub-runtime.ts +14 -9
  202. package/src/serve/project-gutter-route.ts +44 -12
  203. package/src/serve/resources-wire.ts +48 -0
  204. package/src/serve/run-lanes.ts +7 -4
  205. package/src/serve/same-origin.ts +1 -1
  206. package/src/serve/serve-hub.ts +27 -18
  207. package/src/serve/tracked-watch.ts +24 -3
  208. package/src/serve/warm-cell.ts +5 -1
  209. package/src/shipkit-files.ts +15 -4
  210. package/src/shipkit.ts +0 -1
  211. package/src/shot/box.ts +162 -0
  212. package/src/shot/browser-slot.ts +62 -0
  213. package/src/shot/client.ts +43 -7
  214. package/src/shot/clip-encoder.ts +93 -12
  215. package/src/shot/film-box.ts +188 -0
  216. package/src/shot/shooter.ts +50 -15
  217. package/src/shot/shot-ask.ts +10 -2
  218. package/src/shot/stepped-clip.ts +5 -4
  219. package/src/site/desk.ts +242 -0
  220. package/src/site/routes.ts +66 -0
  221. package/src/site/unit.ts +62 -0
  222. package/src/social/brands.ts +22 -0
  223. package/src/social/compose.ts +97 -0
  224. package/src/social/desk-index.ts +123 -0
  225. package/src/social/desk-wire.ts +64 -0
  226. package/src/social/drafts.ts +183 -0
  227. package/src/social/house.ts +24 -0
  228. package/src/social/load.ts +319 -0
  229. package/src/social/md.ts +70 -0
  230. package/src/social/media-facts.ts +53 -0
  231. package/src/social/media-kind.ts +189 -0
  232. package/src/social/media-limit.ts +42 -0
  233. package/src/social/media-of.ts +30 -0
  234. package/src/social/migrate.ts +123 -0
  235. package/src/social/open.ts +17 -0
  236. package/src/social/post-url.ts +158 -0
  237. package/src/social/presence.ts +332 -0
  238. package/src/social/public-read.ts +53 -0
  239. package/src/social/publish/bluesky.ts +168 -0
  240. package/src/social/publish/discord.ts +76 -0
  241. package/src/social/publish/index.ts +24 -0
  242. package/src/social/publish/secret.ts +13 -0
  243. package/src/social/push.ts +31 -0
  244. package/src/social/richtext.ts +37 -0
  245. package/src/social/routes.ts +180 -0
  246. package/src/social/stats.ts +134 -0
  247. package/src/social/text.ts +267 -0
  248. package/src/social/tracker-route.ts +39 -0
  249. package/src/social/tracker.ts +255 -0
  250. package/src/social/unit.ts +53 -0
  251. package/src/social/writes.ts +130 -0
  252. package/src/start-repo.ts +14 -9
  253. package/src/stores/collection.ts +27 -0
  254. package/src/stores/desk.ts +336 -0
  255. package/src/stores/model.ts +187 -0
  256. package/src/stores/routes.ts +126 -0
  257. package/src/stores/unit.ts +57 -0
  258. package/src/suite/calibrate.ts +127 -0
  259. package/src/suite/core-counters.ts +91 -0
  260. package/src/suite/judge-suites.ts +94 -34
  261. package/src/suite/suite-cli.ts +44 -10
  262. package/src/suite/suite-cpu-preload.ts +34 -9
  263. package/src/trailer/adapter.ts +4 -0
  264. package/src/trailer/build.ts +42 -11
  265. package/src/trailer/ffmpeg.ts +11 -0
  266. package/src/trailer/footage.ts +30 -13
  267. package/src/trailer/grammar.ts +18 -2
  268. package/src/trailer/graph.ts +28 -6
  269. package/src/trailer/passage.ts +21 -6
  270. package/src/trailer/plan.ts +74 -3
  271. package/src/trailer/shelf.ts +16 -0
  272. package/src/trailer/stitch.ts +67 -26
  273. package/src/trailer/url.ts +1 -1
  274. package/src/trailer/versions.ts +24 -0
  275. package/src/ts/gate-typecheck.ts +32 -0
  276. package/src/ts/typecheck-cli.ts +9 -11
  277. package/src/tui/tui-app.tsx +0 -1
  278. package/src/veille/asks.ts +155 -0
  279. package/src/veille/auto.ts +31 -0
  280. package/src/veille/batch.ts +27 -0
  281. package/src/veille/chrome.ts +127 -0
  282. package/src/veille/collection.ts +28 -0
  283. package/src/veille/desk.ts +242 -0
  284. package/src/veille/identity.ts +80 -0
  285. package/src/veille/import.ts +68 -0
  286. package/src/veille/log.ts +183 -0
  287. package/src/veille/platforms.ts +118 -0
  288. package/src/veille/reads.ts +66 -0
  289. package/src/veille/replied.ts +110 -0
  290. package/src/veille/routes.ts +185 -0
  291. package/src/veille/service.ts +81 -0
  292. package/src/veille/watch.ts +116 -0
  293. package/src/veille/worth.ts +46 -0
  294. package/src/wiki/scan-md.ts +18 -0
  295. package/src/collections/posts.ts +0 -142
  296. package/src/contracts/manifests/social.contract.ts +0 -20
  297. package/src/scaffold/files/agent-coding.md +0 -35
  298. package/src/ts/typecheck-cache.ts +0 -11
@@ -6,6 +6,10 @@
6
6
  // a canvas through the page's WebCodecs (clip-encoder.ts), any other page
7
7
  // through chromium's screencast and ffmpeg (dom-clip.ts).
8
8
  //
9
+ // A stepped clip (`step`) films a canvas page the same way, frame by frame
10
+ // through the page's hook, and any other page a screenshot a frame
11
+ // (stepped-clip.ts).
12
+ //
9
13
  // it never slows the machine's other work: the browser runs niced, the page
10
14
  // stays live only LIVE_MS after a request and is then frozen (no frame, no
11
15
  // timer, no cpu), a frozen page is loaded again before its next still (an
@@ -21,6 +25,7 @@ import { dirname } from 'path'
21
25
  import { loadPlaywright } from '../smoke/run-smoke.ts'
22
26
  import { CLIP_INIT, CLIP_QUANTIZER, clipDone, installClip, KEY_EVERY, muxArgs, type PageClipAsk, type PageClipDone, TAKE, takeClip } from './clip-encoder.ts'
23
27
  import { type ClipPath, clipPathOf, domEncodeArgs, FrameTimeline, largestCanvas, screencastParams } from './dom-clip.ts'
28
+ import { openBrowser, type PwBrowser } from './box.ts'
24
29
  import { capMsOf, type ClipAsk, pageMove, readMark, type ShotAsk, slotKey, Turns, waitReady } from './shot-ask.ts'
25
30
 
26
31
  /** the slice of playwright the shots touch, so the lib types nothing it does not ship */
@@ -39,13 +44,13 @@ type Page = {
39
44
  isClosed(): boolean
40
45
  }
41
46
  type Context = { newPage(): Promise<Page>; newCDPSession(p: Page): Promise<Cdp>; addInitScript(s: { content: string }): Promise<void>; close(): Promise<void> }
42
- type Browser = {
47
+ export type Browser = {
43
48
  newContext(o: { viewport: { width: number; height: number }; deviceScaleFactor: number; locale?: string }): Promise<Context>
44
49
  close(): Promise<void>
45
50
  isConnected(): boolean
46
51
  on(event: 'disconnected', cb: () => void): void
47
52
  }
48
- type Playwright = { chromium: { launch(o: { headless: boolean; args: string[] }): Promise<Browser> } }
53
+ type Playwright = { chromium: { launch(o: { headless: boolean; args: string[] }): Promise<Browser>; connectOverCDP(url: string): Promise<PwBrowser> } }
49
54
 
50
55
  /** WebGL on the GPU over metal on a mac: in software a 3D page crawls. Audio plays with no gesture */
51
56
  export const BROWSER_ARGS = [...(process.platform === 'darwin' ? ['--use-angle=metal', '--enable-gpu', '--ignore-gpu-blocklist'] : []), '--autoplay-policy=no-user-gesture-required']
@@ -81,17 +86,27 @@ const ms = (t0: number): number => Math.round(performance.now() - t0)
81
86
  const withCap = <T>(what: string, capMs: number, p: Promise<T>): Promise<T> =>
82
87
  Promise.race([p, new Promise<T>((_, fail) => setTimeout(() => fail(new Error(`${what} took past ${capMs / 1000} s`)), capMs).unref?.())])
83
88
 
89
+ /** the repo a Shooter's browser works for, and the name its browser slot is held under */
90
+ export type BrowserFor = { root: string; who: string; say?: (l: string) => void }
91
+
84
92
  export class Shooter {
85
93
  readonly #roots: string[]
86
94
  readonly #turns = new Turns()
95
+ readonly #for: BrowserFor | null
87
96
  #browser: Browser | null = null
88
97
  #launching: Promise<Browser> | null = null
98
+ #held: (() => void) | null = null
99
+ /** before a page goes to a url: the box route forwards this machine's localhost port to the box */
100
+ #reach: (url: string) => Promise<void> = async () => undefined
89
101
  #slot: Slot | null = null
90
102
  #idle: ReturnType<typeof setTimeout> | null = null
91
103
  #live: ReturnType<typeof setTimeout> | null = null
92
104
 
93
- constructor(roots: string[]) {
105
+ /** `slot`: the repo whose browser cap (browser-slot.ts) this browser counts against, one slot held from its launch
106
+ * to its close; the warm service passes none, each of its askers holds one instead */
107
+ constructor(roots: string[], o: { slot?: BrowserFor } = {}) {
94
108
  this.#roots = roots
109
+ this.#for = o.slot ?? null
95
110
  }
96
111
 
97
112
  get warm(): { browser: boolean; url: string | null; waiting: number } {
@@ -115,6 +130,13 @@ export class Shooter {
115
130
  const b = this.#browser
116
131
  this.#browser = null
117
132
  await b?.close().catch(() => undefined)
133
+ this.#free()
134
+ }
135
+
136
+ #free(): void {
137
+ const held = this.#held
138
+ this.#held = null
139
+ held?.()
118
140
  }
119
141
 
120
142
  #touch(): void {
@@ -140,11 +162,20 @@ export class Shooter {
140
162
  try {
141
163
  setPriority(SHOT_NICE)
142
164
  } catch {}
143
- const b = await pw.chromium.launch({ headless: true, args: BROWSER_ARGS })
165
+ const f = this.#for
166
+ let b: Browser
167
+ if (f != null) {
168
+ // the repo's browser: on its box from a Mac (box.ts), else launched here, its slot held until close
169
+ const o = await openBrowser<Browser>(pw, { root: f.root, who: f.who, args: BROWSER_ARGS, ...(f.say ? { say: f.say } : {}) })
170
+ b = o.browser
171
+ this.#reach = (url) => o.reach(url)
172
+ this.#held = () => void o.close()
173
+ } else b = await pw.chromium.launch({ headless: true, args: BROWSER_ARGS })
144
174
  b.on('disconnected', () => {
145
175
  if (this.#browser === b) {
146
176
  this.#browser = null
147
177
  this.#slot = null
178
+ this.#free()
148
179
  }
149
180
  })
150
181
  this.#browser = b
@@ -196,7 +227,10 @@ export class Shooter {
196
227
  const t = performance.now()
197
228
  slot.url = a.url
198
229
  if (move === 'reload') await slot.page.reload({ waitUntil: 'load', timeout: 60_000 })
199
- else await slot.page.goto(a.url, { waitUntil: 'load', timeout: 60_000 })
230
+ else {
231
+ await this.#reach(a.url)
232
+ await slot.page.goto(a.url, { waitUntil: 'load', timeout: 60_000 })
233
+ }
200
234
  phases['load'] = ms(t)
201
235
  }
202
236
  let t = performance.now()
@@ -230,21 +264,19 @@ export class Shooter {
230
264
  const page = await ctx.newPage()
231
265
  Shooter.#listen(page, errors)
232
266
  let t = performance.now()
267
+ await this.#reach(a.url)
233
268
  await page.goto(a.url, { waitUntil: 'load', timeout: 60_000 })
234
269
  await waitReady(() => page.evaluate(readMark), a.waitMs, { now: () => performance.now(), sleep: (n) => page.waitForTimeout(n) })
235
270
  phases['load'] = ms(t)
236
271
  t = performance.now()
237
- if (a.step) {
238
- const note = await (await import('./stepped-clip.ts')).stepPage(await ctx.newCDPSession(page), page, a as ClipAsk & { step: string })
239
- phases['film'] = ms(t)
240
- return { out: a.out, ms: ms(t0), phases, errors, note, stepped: true }
241
- }
272
+ const stepped = a.step ? { stepped: true as const } : {}
242
273
  const path: ClipPath = clipPathOf({ dom: a.dom === true, canvas: await page.evaluate(largestCanvas), viewport: a.viewport })
243
- const why = path === 'canvas' ? await page.evaluate(installClip, { seconds: a.seconds, fps: a.fps, quantizer: CLIP_QUANTIZER, keyEvery: KEY_EVERY } satisfies PageClipAsk) : null
274
+ const why = path === 'canvas' ? await page.evaluate(installClip, { seconds: a.seconds, fps: a.fps, quantizer: CLIP_QUANTIZER, keyEvery: KEY_EVERY, ...(a.step ? { step: a.step } : {}) } satisfies PageClipAsk) : null
244
275
  if (path === 'dom' || why != null) {
245
- const note = await filmPage(await ctx.newCDPSession(page), page, a)
276
+ const cdp = await ctx.newCDPSession(page)
277
+ const note = a.step ? await (await import('./stepped-clip.ts')).stepPage(cdp, page, a as ClipAsk & { step: string }) : await filmPage(cdp, page, a)
246
278
  phases['film'] = ms(t)
247
- return { out: a.out, ms: ms(t0), phases, errors, note: why == null ? note : `${note}; the canvas path refused: ${why}` }
279
+ return { out: a.out, ms: ms(t0), phases, errors, note: why == null ? note : `${note}; the canvas path refused: ${why}`, ...stepped }
248
280
  }
249
281
  const parts: Buffer[] = []
250
282
  let done: PageClipDone | null = null
@@ -273,8 +305,11 @@ export class Shooter {
273
305
  phases['mux'] = ms(t)
274
306
  const d = done as unknown as PageClipDone
275
307
  const mb = (stream.length / 2 ** 20).toFixed(1)
276
- const note = `${d.frames} frames ${d.width}x${d.height} at ${a.fps} fps (${d.repeated} repeated for a slow page), canvas ${d.canvasOfViewport}, ${mb} MB H.264 from the page's WebCodecs, muxed`
277
- return { out: a.out, ms: ms(t0), phases, errors, note }
308
+ const how = a.step
309
+ ? `each stepped through window.${a.step}(t) and its ready mark (${d.msPerFrame?.toFixed(0)} ms a frame, ${d.repeated} the page did not draw again)`
310
+ : `(${d.repeated} repeated for a slow page)`
311
+ const note = `${d.frames} frames ${d.width}x${d.height} at ${a.fps} fps ${how}, canvas ${d.canvasOfViewport}, ${mb} MB H.264 from the page's WebCodecs, muxed`
312
+ return { out: a.out, ms: ms(t0), phases, errors, note, ...stepped }
278
313
  } finally {
279
314
  await ctx.close().catch(() => undefined)
280
315
  }
@@ -87,6 +87,8 @@ export type ShotFlags = {
87
87
  fps?: string
88
88
  long?: boolean
89
89
  dom?: boolean
90
+ step?: string
91
+ at?: string
90
92
  }
91
93
 
92
94
  const positive = (flag: string, s: string, max: number): number => {
@@ -102,6 +104,11 @@ export function askOf(f: ShotFlags, cwd: string): ShotAsk | ClipAsk {
102
104
  if (seconds != null && seconds > MAX_CLIP_SECONDS && f.long !== true) throw new Error(`--video ${seconds}: a clip past ${MAX_CLIP_SECONDS} s needs --long (a long clip is a long wait and a big file)`)
103
105
  if (seconds == null && f.fps != null) throw new Error('--fps only applies to a clip: add --video <seconds>')
104
106
  if (seconds == null && f.dom === true) throw new Error('--dom only applies to a clip: add --video <seconds>')
107
+ if (f.step != null && !/^[A-Za-z_$][\w$]*$/.test(f.step)) throw new Error(`--step '${f.step}' is not a window function name, like __trailerStep`)
108
+ if (f.at != null && f.step == null) throw new Error('--at only applies to a stepped still: add --step <hook>')
109
+ if (f.at != null && seconds != null) throw new Error('--at only applies to a still: a stepped clip draws every time from 0')
110
+ const at = f.at == null ? undefined : Number(f.at)
111
+ if (at !== undefined && !(Number.isFinite(at) && at >= 0)) throw new Error(`--at '${f.at}' must be seconds, 0 or more`)
105
112
  const base: ShotAsk = {
106
113
  url,
107
114
  viewport: f.viewport == null ? DEFAULT_VIEWPORT : parseViewport(f.viewport),
@@ -110,9 +117,10 @@ export function askOf(f: ShotFlags, cwd: string): ShotAsk | ClipAsk {
110
117
  reload: f.reload === true,
111
118
  waitMs: f.wait == null ? DEFAULT_WAIT_MS : f.wait === '0' ? 0 : positive('--wait', f.wait, 60_000),
112
119
  }
113
- if (seconds == null) return base
120
+ const step = f.step == null ? {} : { step: f.step }
121
+ if (seconds == null) return { ...base, ...step, ...(f.step == null ? {} : { at: at ?? 0 }) }
114
122
  if (!base.out.endsWith('.mp4')) throw new Error(`--out '${f.out}': a clip is an mp4 (H.264)`)
115
- return { ...base, seconds, fps: f.fps == null ? DEFAULT_FPS : positive('--fps', f.fps, 60), dom: f.dom === true }
123
+ return { ...base, seconds, fps: f.fps == null ? DEFAULT_FPS : positive('--fps', f.fps, 60), dom: f.dom === true, ...step }
116
124
  }
117
125
 
118
126
  export const isClip = (a: ShotAsk | ClipAsk): a is ClipAsk => 'seconds' in a
@@ -1,7 +1,8 @@
1
- // a clip filmed frame by frame (wiki build/trailer.md, film page): before each frame the page is asked to draw the
2
- // frame's time, `window[step](t)`, then the shot service waits for its ready mark and two painted frames, takes one
3
- // screenshot, and ffmpeg encodes the frames in order. The page's own speed never shows: a frame that takes a second to
4
- // draw sits beside one that took a millisecond. The page owns its clock while it is stepped
1
+ // a stepped clip of a page whose canvas is not the page (wiki build/trailer.md, film page): before each frame the page
2
+ // is asked to draw the frame's time, `window[step](t)`, then the shot service waits for its ready mark and two painted
3
+ // frames, takes one screenshot, and ffmpeg encodes the frames in order. A canvas page is stepped inside the page and
4
+ // encoded by its own WebCodecs instead (clip-encoder.ts installClip). The page's own speed never shows: a frame that
5
+ // takes a second to draw sits beside one that took a millisecond. The page owns its clock while it is stepped
5
6
  import { mkdirSync } from 'fs'
6
7
  import { dirname } from 'path'
7
8
  import { domEncodeArgs } from './dom-clip.ts'
@@ -0,0 +1,242 @@
1
+ // the site desk read (wiki build/shipkit/site.md): an identity's site, its address asked online, the repo that builds
2
+ // it, and through that repo's site unit its pages, its preview, what is online and what changed since. Nothing here
3
+ // writes: the preview and the deploy are the unit's own commands (routes.ts)
4
+ import { existsSync, readFileSync } from 'node:fs'
5
+ import { homedir } from 'node:os'
6
+ import { join } from 'node:path'
7
+ import { importFresh, repoUnitFiles } from '../core/discover-checks.ts'
8
+ import { loadIdentities, type Identity } from '../identities/identities.ts'
9
+ import { houseRepoRoots } from '../social/house.ts'
10
+ import { siteProblem, type SiteDated, type SitePage, type SiteUnit } from './unit.ts'
11
+
12
+ export type { SiteDated, SitePage }
13
+
14
+ export type Deployed = { commit: string; at: string; url: string; source: 'record' | 'cloudflare' }
15
+
16
+ /** a page a changed file touches (`*` every page), and the files */
17
+ export type SiteChange = { path: string; files: string[] }
18
+
19
+ export type SiteRepo = { name: string; house: boolean; path: string | null }
20
+
21
+ export type SiteDesk = {
22
+ pages: SitePage[]
23
+ preview: { url: string; up: boolean } | null
24
+ deploy: { about: string | null } | null
25
+ deployed: Deployed | null
26
+ changes: SiteChange[]
27
+ dated: { since: number; words: string } | null
28
+ deploying: boolean
29
+ }
30
+
31
+ export type SiteAnswer = {
32
+ id: string
33
+ name: string
34
+ address: string
35
+ /** the address asked online: its status, null when nothing answered; null with no address */
36
+ online: { status: number | null; at: string } | null
37
+ repo: SiteRepo | null
38
+ /** why there is no desk, in words; null when there is one */
39
+ missing: string | null
40
+ desk: SiteDesk | null
41
+ error: string | null
42
+ }
43
+
44
+ const UNIT = /\bsite\s*\(|kind:\s*['"]site['"]/
45
+ const FIVE_MIN = 5 * 60_000
46
+
47
+ /** the repo's site unit, null when it has none */
48
+ export async function loadSiteUnit(root: string): Promise<SiteUnit | null> {
49
+ const found: { file: string; unit: SiteUnit }[] = []
50
+ for (const f of repoUnitFiles(root)) {
51
+ if (f.endsWith('.check.shipkit.ts') || !UNIT.test(readFileSync(f, 'utf8'))) continue
52
+ const d = (await importFresh(f)) as { kind?: unknown } | undefined
53
+ if (d?.kind !== 'site') continue
54
+ const why = siteProblem(d as SiteUnit)
55
+ if (why !== null) throw new Error(`${f}: ${why}`)
56
+ found.push({ file: f, unit: d as SiteUnit })
57
+ }
58
+ if (found.length > 1) throw new Error(`two site units: ${found.map((x) => x.file).join(' and ')}; keep one`)
59
+ return found[0]?.unit ?? null
60
+ }
61
+
62
+ export async function run(cmd: readonly string[], cwd: string): Promise<{ ok: boolean; out: string; err: string }> {
63
+ try {
64
+ const p = Bun.spawn([...cmd], { cwd, stdin: 'ignore', stdout: 'pipe', stderr: 'pipe' })
65
+ const [out, err, code] = await Promise.all([new Response(p.stdout).text(), new Response(p.stderr).text(), p.exited])
66
+ return { ok: code === 0, out, err: err.trim() }
67
+ } catch (e) {
68
+ return { ok: false, out: '', err: (e as Error).message }
69
+ }
70
+ }
71
+
72
+ export const answers = (url: string, ms = 800): Promise<boolean> =>
73
+ fetch(url, { signal: AbortSignal.timeout(ms) }).then(
74
+ () => true,
75
+ () => false,
76
+ )
77
+
78
+ const probes = new Map<string, { at: number; status: number | null }>()
79
+
80
+ /** the address asked online, at most every five minutes */
81
+ async function probe(address: string): Promise<{ status: number | null; at: string }> {
82
+ let p = probes.get(address)
83
+ if (p == null || Date.now() - p.at > FIVE_MIN) {
84
+ const status = await fetch(address, { redirect: 'follow', signal: AbortSignal.timeout(4000) }).then(
85
+ (r) => r.status,
86
+ () => null,
87
+ )
88
+ p = { at: Date.now(), status }
89
+ probes.set(address, p)
90
+ }
91
+ return { status: p.status, at: new Date(p.at).toISOString() }
92
+ }
93
+
94
+ const cloudflare = new Map<string, { at: number; value: Deployed | null }>()
95
+
96
+ /** a deploy ended: what Cloudflare says is asked again */
97
+ export const forgetDeployed = (): void => cloudflare.clear()
98
+
99
+ /** the Cloudflare token the house config names (`serve.cloudflareToken`), read through its `credsReadCommand`; null when either is missing */
100
+ async function cloudflareToken(cwd: string): Promise<string | null> {
101
+ const { houseRootOf } = await import('../home/home-start.ts')
102
+ const { loadRepoConfig } = await import('../repo-config.ts')
103
+ const { readSecret } = await import('../smoke/run-smoke.ts')
104
+ const house = houseRootOf(cwd)
105
+ if (!house) return null
106
+ const c = await loadRepoConfig(house)
107
+ const name = c.serve?.cloudflareToken
108
+ if (!name || !c.credsReadCommand) return null
109
+ try {
110
+ return readSecret(c.credsReadCommand, name)
111
+ } catch {
112
+ return null
113
+ }
114
+ }
115
+
116
+ /** the last production deployment Cloudflare Pages reports, asked at most every five minutes */
117
+ async function fromCloudflare(pages: { account: string; project: string }, cwd: string): Promise<Deployed | null> {
118
+ const key = `${pages.account}/${pages.project}`
119
+ const kept = cloudflare.get(key)
120
+ if (kept && Date.now() - kept.at < FIVE_MIN) return kept.value
121
+ const token = await cloudflareToken(cwd)
122
+ let value: Deployed | null = null
123
+ if (token != null) {
124
+ const url = `https://api.cloudflare.com/client/v4/accounts/${pages.account}/pages/projects/${pages.project}/deployments?env=production&per_page=1`
125
+ const r = await fetch(url, { headers: { Authorization: `Bearer ${token}` }, signal: AbortSignal.timeout(5000) }).catch(() => null)
126
+ const d = r?.ok ? ((await r.json()) as { result?: { created_on: string; url: string; deployment_trigger?: { metadata?: { commit_hash?: string } } }[] }) : null
127
+ const last = d?.result?.[0]
128
+ const commit = last?.deployment_trigger?.metadata?.commit_hash
129
+ if (last && commit) value = { commit, at: last.created_on, url: last.url, source: 'cloudflare' }
130
+ }
131
+ cloudflare.set(key, { at: Date.now(), value })
132
+ return value
133
+ }
134
+
135
+ async function deployedOf(unit: SiteUnit, root: string): Promise<Deployed | null> {
136
+ const rec = unit.online?.record
137
+ if (rec != null && existsSync(join(root, rec))) {
138
+ const d = JSON.parse(readFileSync(join(root, rec), 'utf8')) as Omit<Deployed, 'source'>
139
+ return { commit: d.commit, at: d.at, url: d.url, source: 'record' }
140
+ }
141
+ return unit.online?.pages ? fromCloudflare(unit.online.pages, root) : null
142
+ }
143
+
144
+ const lines = (s: string): string[] => s.split('\n').filter(Boolean)
145
+
146
+ /** the files of the unit's sources that differ from the deployed commit, the working tree's and the new ones included;
147
+ * no rename detection: both sides of a move changed the site, and it costs 0.7 s on a big repo */
148
+ async function changedFiles(root: string, commit: string, sources: readonly string[]): Promise<string[]> {
149
+ if (sources.length === 0) return []
150
+ const [diff, fresh] = await Promise.all([run(['git', 'diff', '--no-renames', '--name-only', commit, '--', ...sources], root), run(['git', 'ls-files', '--others', '--exclude-standard', '--', ...sources], root)])
151
+ return [...new Set([...lines(diff.out), ...lines(fresh.out)])]
152
+ }
153
+
154
+ /** the files of the identity's folder the site reads, changed since the deploy: committed since, or not committed */
155
+ async function identityChanges(i: Identity, files: readonly string[], since: string): Promise<string[]> {
156
+ if (files.length === 0) return []
157
+ const [log, status] = await Promise.all([run(['git', 'log', `--since=${since}`, '--format=', '--name-only', '--', ...files], i.dir), run(['git', 'status', '--porcelain', '--', ...files], i.dir)])
158
+ return [...new Set([...lines(log.out), ...lines(status.out).map((l) => l.slice(3))])]
159
+ }
160
+
161
+ /** each changed file grouped under the page it touches; a file that touches none is left out */
162
+ export function changesOf(files: readonly string[], touches: SiteUnit['touches'], ctx: { pages: readonly SitePage[]; dated: readonly SiteDated[] }): SiteChange[] {
163
+ const by = new Map<string, string[]>()
164
+ for (const f of files) {
165
+ const path = touches == null ? '*' : touches(f, ctx)
166
+ if (path != null) by.set(path, [...(by.get(path) ?? []), f])
167
+ }
168
+ return [...by].map(([path, fs]) => ({ path, files: fs }))
169
+ }
170
+
171
+ const deploying = new Set<string>()
172
+ export const isDeploying = (id: string): boolean => deploying.has(id)
173
+ export const setDeploying = (id: string, on: boolean): void => void (on ? deploying.add(id) : deploying.delete(id))
174
+
175
+ /** the repo that builds an identity's site: a house repo, else a folder of `~/dev` by that name, else null */
176
+ export async function siteRepoOf(root: string, name: string): Promise<SiteRepo | null> {
177
+ if (name === '') return null
178
+ const house = (await houseRepoRoots(root)).find((r) => r.name === name)
179
+ if (house) return { name, house: true, path: house.path }
180
+ const dev = join(homedir(), 'dev', name)
181
+ return { name, house: false, path: existsSync(dev) ? dev : null }
182
+ }
183
+
184
+ async function deskOf(i: Identity, root: string, unit: SiteUnit): Promise<SiteDesk> {
185
+ const listed = await run(unit.pages, root)
186
+ if (!listed.ok) throw new Error(`${unit.pages.join(' ')}: ${listed.err || 'failed'}`)
187
+ const { pages, dated = [] } = JSON.parse(listed.out) as { pages: SitePage[]; dated?: SiteDated[] }
188
+ const [live, up] = await Promise.all([deployedOf(unit, root), unit.preview ? answers(unit.preview.url) : Promise.resolve(false)])
189
+ const [files, ids] = live ? await Promise.all([changedFiles(root, live.commit, unit.sources ?? []), identityChanges(i, unit.identityFiles ?? [], live.at)]) : [[], []]
190
+ const changes = changesOf(files, unit.touches, { pages, dated })
191
+ if (ids.length > 0) {
192
+ const every = changes.find((c) => c.path === '*')
193
+ if (every) every.files.push(...ids)
194
+ else changes.push({ path: '*', files: ids })
195
+ }
196
+ return {
197
+ pages,
198
+ preview: unit.preview ? { url: unit.preview.url, up } : null,
199
+ deploy: unit.deploy ? { about: unit.deploy.about ?? null } : null,
200
+ deployed: live,
201
+ changes,
202
+ dated: unit.dated && live ? { since: dated.filter((d) => d.at > live.at).length, words: unit.dated } : null,
203
+ deploying: deploying.has(i.id),
204
+ }
205
+ }
206
+
207
+ /** the identity named, its unit and the repo that holds it: what the preview and the deploy act on */
208
+ export async function siteTarget(root: string, id: string): Promise<{ i: Identity; repo: SiteRepo | null; unit: SiteUnit | null; unitError: string | null }> {
209
+ const ids = await loadIdentities({ cwd: root })
210
+ const i = ids.identities.find((x) => x.id === id)
211
+ if (i == null) throw new Error(`no identity ${id} (${ids.identities.map((x) => x.id).join(', ') || 'none'})`)
212
+ const repo = await siteRepoOf(root, i.siteRepo)
213
+ if (!repo?.house || repo.path == null) return { i, repo, unit: null, unitError: null }
214
+ try {
215
+ return { i, repo, unit: await loadSiteUnit(repo.path), unitError: null }
216
+ } catch (e) {
217
+ return { i, repo, unit: null, unitError: (e as Error).message }
218
+ }
219
+ }
220
+
221
+ /** why an identity's site has no desk, in words */
222
+ function missingOf(i: Identity, repo: SiteRepo | null): string {
223
+ if (repo == null) return `no repo builds it: siteRepo: in ${i.id}'s identity.md`
224
+ if (repo.path == null) return `${repo.name} is not on this disk`
225
+ if (!repo.house) return `${repo.name} is not wired to shipkit: no site unit, so no pages, no preview and no deploy here`
226
+ return `${repo.name} declares no site unit: a site({...}) in a .shipkit.ts (build/shipkit/site.md)`
227
+ }
228
+
229
+ export async function siteAnswer(root: string, id: string): Promise<SiteAnswer> {
230
+ const { i, repo, unit, unitError } = await siteTarget(root, id)
231
+ const online = i.site === '' ? Promise.resolve(null) : probe(i.site)
232
+ let desk: SiteDesk | null = null
233
+ let error = unitError
234
+ if (unit && repo?.path) {
235
+ try {
236
+ desk = await deskOf(i, repo.path, unit)
237
+ } catch (e) {
238
+ error = (e as Error).message
239
+ }
240
+ }
241
+ return { id: i.id, name: i.name, address: i.site, online: await online, repo, missing: unit || unitError ? null : missingOf(i, repo), desk, error }
242
+ }
@@ -0,0 +1,66 @@
1
+ // the site desk's routes (wiki build/shipkit/site.md, Routes), on the home daemon: an identity's site read, its local
2
+ // preview started when down, its deploy run on his press with the log streamed. Each names an identity, never a path
3
+ // or a command: the commands are the site unit's
4
+ import { bad, NO_STORE } from '../review/http.ts'
5
+ import { answers, forgetDeployed, isDeploying, setDeploying, siteAnswer, siteTarget } from './desk.ts'
6
+
7
+ const BASE = '/api/home/sites/'
8
+
9
+ /** the preview answers, started when down: detached, so it outlives the daemon */
10
+ async function preview(root: string, id: string): Promise<Response> {
11
+ const { repo, unit } = await siteTarget(root, id)
12
+ const p = unit?.preview
13
+ if (!p || !repo?.path) return bad(`${id}'s site has no local preview: a preview in its site unit`, 404)
14
+ if (await answers(p.url)) return Response.json({ ok: true, url: p.url }, { headers: NO_STORE })
15
+ Bun.spawn(['sh', '-c', 'nohup "$@" >/dev/null 2>&1 &', 'sh', ...p.start], { cwd: repo.path, stdin: 'ignore', stdout: 'ignore', stderr: 'ignore' })
16
+ for (let n = 0; n < 40; n++) {
17
+ await Bun.sleep(500)
18
+ if (await answers(p.url)) return Response.json({ ok: true, url: p.url }, { headers: NO_STORE })
19
+ }
20
+ return bad(`the preview did not answer on ${p.url} in 20 s: run « ${p.start.join(' ')} » in ${repo.name} to see why`, 500)
21
+ }
22
+
23
+ /** the unit's deploy, only on his press, one at a time per identity, its output streamed as it comes */
24
+ async function deploy(root: string, id: string): Promise<Response> {
25
+ const { repo, unit } = await siteTarget(root, id)
26
+ const d = unit?.deploy
27
+ if (!d || !repo?.path) return bad(`${id}'s site has no deploy: a deploy in its site unit`, 404)
28
+ if (isDeploying(id)) return bad(`${id}'s site is being deployed already`, 409)
29
+ let proc: ReturnType<typeof Bun.spawn<'ignore', 'pipe', 'pipe'>>
30
+ try {
31
+ proc = Bun.spawn([...d.cmd], { cwd: repo.path, stdin: 'ignore', stdout: 'pipe', stderr: 'pipe' })
32
+ } catch (e) {
33
+ return bad(`deploy: ${d.cmd.join(' ')}: ${(e as Error).message}`, 500)
34
+ }
35
+ setDeploying(id, true)
36
+ const enc = new TextEncoder()
37
+ const stream = new ReadableStream<Uint8Array>({
38
+ async start(c) {
39
+ const pump = async (s: ReadableStream<Uint8Array>): Promise<void> => {
40
+ for await (const chunk of s) c.enqueue(chunk)
41
+ }
42
+ await Promise.all([pump(proc.stdout), pump(proc.stderr)])
43
+ const code = await proc.exited
44
+ forgetDeployed()
45
+ setDeploying(id, false)
46
+ c.enqueue(enc.encode(code === 0 ? '\n✓ deployed\n' : `\n✗ failed (exit ${code})\n`))
47
+ c.close()
48
+ },
49
+ })
50
+ return new Response(stream, { headers: { 'Content-Type': 'text/plain; charset=utf-8', ...NO_STORE } })
51
+ }
52
+
53
+ /** null when the path is not this route's */
54
+ export async function siteRoutes(req: Request, path: string, root: string): Promise<Response | null> {
55
+ if (!path.startsWith(BASE)) return null
56
+ const [id = '', verb = ''] = path.slice(BASE.length).split('/').map(decodeURIComponent)
57
+ if (!/^[a-z0-9][a-z0-9-]*$/.test(id)) return bad(`sites: ${id} is no identity id`, 404)
58
+ try {
59
+ if (verb === '' && req.method === 'GET') return Response.json(await siteAnswer(root, id), { headers: NO_STORE })
60
+ if (verb === 'preview' && req.method === 'POST') return await preview(root, id)
61
+ if (verb === 'deploy' && req.method === 'POST') return await deploy(root, id)
62
+ return bad(`sites: no route ${req.method} ${path}`, 404)
63
+ } catch (e) {
64
+ return bad(e, (e as Error).message.startsWith('no identity') ? 404 : 500)
65
+ }
66
+ }
@@ -0,0 +1,62 @@
1
+ // a repo's parts of the site desk (wiki build/shipkit/site.md, What a project adds): the command that lists its pages,
2
+ // its local preview, its deploy, where what is online is read, what a deploy ships and the page a changed file touches.
3
+ // Every unit file imports this module, so it stays light: desk.ts finds and reads the unit
4
+
5
+ /** a page of the site, as the unit's `pages` command prints it */
6
+ export interface SitePage {
7
+ path: string
8
+ title: string
9
+ draft?: boolean
10
+ /** the repo folder the page is made from, when it has one */
11
+ dir?: string | null
12
+ }
13
+
14
+ /** a dated entry the site shows (a News message): counted when it is newer than the deploy */
15
+ export interface SiteDated {
16
+ id: string
17
+ at: string
18
+ }
19
+
20
+ export interface SiteDef {
21
+ /** argv from the repo root; prints `{ pages: SitePage[], dated?: SiteDated[] }` */
22
+ pages: readonly string[]
23
+ /** the local preview: its url, and the argv that serves it (detached, so it outlives the daemon) */
24
+ preview?: { url: string; start: readonly string[] }
25
+ /** the project's own deploy: argv from the repo root, and how long it takes in words */
26
+ deploy?: { cmd: readonly string[]; about?: string }
27
+ /** what is online: a record `{ commit, at, url }` the deploy writes, else a Cloudflare Pages project */
28
+ online?: { record?: string; pages?: { account: string; project: string } }
29
+ /** what a deploy ships, repo relative: a file there that differs from the deployed commit is a change */
30
+ sources?: readonly string[]
31
+ /** what the site reads from its identity's folder: a change there since the deploy touches every page */
32
+ identityFiles?: readonly string[]
33
+ /** the words for the dated entries newer than the deploy */
34
+ dated?: string
35
+ /** the page a changed file touches: its path, `*` every page, null none. Pure: it runs in the daemon */
36
+ touches?: (file: string, ctx: { pages: readonly SitePage[]; dated: readonly SiteDated[] }) => string | null
37
+ }
38
+
39
+ export type SiteUnit = SiteDef & { kind: 'site' }
40
+
41
+ const REL = /^(?!\/)(?!.*(^|\/)\.\.(\/|$)).+$/
42
+ const argv = (v: unknown): boolean => Array.isArray(v) && v.length > 0 && v.every((a) => typeof a === 'string' && a !== '')
43
+
44
+ /** why a site unit cannot be read, or null */
45
+ export function siteProblem(d: SiteDef): string | null {
46
+ if (!argv(d.pages)) return 'site: pages is an argv that prints the pages'
47
+ if (d.preview !== undefined && (typeof d.preview.url !== 'string' || !/^https?:\/\//.test(d.preview.url) || !argv(d.preview.start))) return 'site: preview is { url: an http url, start: an argv }'
48
+ if (d.deploy !== undefined && !argv(d.deploy.cmd)) return 'site: deploy.cmd is an argv'
49
+ if (d.online?.record !== undefined && !REL.test(d.online.record)) return `site: online.record '${d.online.record}' is a repo relative file`
50
+ const pages = d.online?.pages
51
+ if (pages !== undefined && (typeof pages.account !== 'string' || pages.account === '' || typeof pages.project !== 'string' || pages.project === '')) return 'site: online.pages is { account, project }'
52
+ for (const [key, list] of [['sources', d.sources], ['identityFiles', d.identityFiles]] as const)
53
+ for (const s of list ?? []) if (typeof s !== 'string' || !REL.test(s)) return `site: ${key} '${String(s)}' is a relative path`
54
+ if (d.touches !== undefined && typeof d.touches !== 'function') return 'site: touches is a function of a file'
55
+ return null
56
+ }
57
+
58
+ export function site(d: SiteDef): SiteUnit {
59
+ const why = siteProblem(d)
60
+ if (why !== null) throw new Error(why)
61
+ return { ...d, kind: 'site' }
62
+ }
@@ -0,0 +1,22 @@
1
+ // each platform's mark and color, for the social desks and a site's links: the logos are simple-icons 13.0.0
2
+ // (CC0), 24 unit paths, the site's globe Material Icons (Apache 2.0); a brand whose own color is black takes its known
3
+ // accent (Patreon coral, Steam blue, TikTok red) so a card keeps a color
4
+
5
+ export const BRANDS: Readonly<Record<string, { hex: string; d: string }>> = {
6
+ bluesky: { hex: '#0285FF', d: 'M12 10.8c-1.087-2.114-4.046-6.053-6.798-7.995C2.566.944 1.561 1.266.902 1.565.139 1.908 0 3.08 0 3.768c0 .69.378 5.65.624 6.479.815 2.736 3.713 3.66 6.383 3.364.136-.02.275-.039.415-.056-.138.022-.276.04-.415.056-3.912.58-7.387 2.005-2.83 7.078 5.013 5.19 6.87-1.113 7.823-4.308.953 3.195 2.05 9.271 7.733 4.308 4.267-4.308 1.172-6.498-2.74-7.078a8.741 8.741 0 0 1-.415-.056c.14.017.279.036.415.056 2.67.297 5.568-.628 6.383-3.364.246-.828.624-5.79.624-6.478 0-.69-.139-1.861-.902-2.206-.659-.298-1.664-.62-4.3 1.24C16.046 4.748 13.087 8.687 12 10.8Z' },
7
+ discord: { hex: '#5865F2', d: 'M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z' },
8
+ instagram: { hex: '#E4405F', d: 'M7.0301.084c-1.2768.0602-2.1487.264-2.911.5634-.7888.3075-1.4575.72-2.1228 1.3877-.6652.6677-1.075 1.3368-1.3802 2.127-.2954.7638-.4956 1.6365-.552 2.914-.0564 1.2775-.0689 1.6882-.0626 4.947.0062 3.2586.0206 3.6671.0825 4.9473.061 1.2765.264 2.1482.5635 2.9107.308.7889.72 1.4573 1.388 2.1228.6679.6655 1.3365 1.0743 2.1285 1.38.7632.295 1.6361.4961 2.9134.552 1.2773.056 1.6884.069 4.9462.0627 3.2578-.0062 3.668-.0207 4.9478-.0814 1.28-.0607 2.147-.2652 2.9098-.5633.7889-.3086 1.4578-.72 2.1228-1.3881.665-.6682 1.0745-1.3378 1.3795-2.1284.2957-.7632.4966-1.636.552-2.9124.056-1.2809.0692-1.6898.063-4.948-.0063-3.2583-.021-3.6668-.0817-4.9465-.0607-1.2797-.264-2.1487-.5633-2.9117-.3084-.7889-.72-1.4568-1.3876-2.1228C21.2982 1.33 20.628.9208 19.8378.6165 19.074.321 18.2017.1197 16.9244.0645 15.6471.0093 15.236-.005 11.977.0014 8.718.0076 8.31.0215 7.0301.0839m.1402 21.6932c-1.17-.0509-1.8053-.2453-2.2287-.408-.5606-.216-.96-.4771-1.3819-.895-.422-.4178-.6811-.8186-.9-1.378-.1644-.4234-.3624-1.058-.4171-2.228-.0595-1.2645-.072-1.6442-.079-4.848-.007-3.2037.0053-3.583.0607-4.848.05-1.169.2456-1.805.408-2.2282.216-.5613.4762-.96.895-1.3816.4188-.4217.8184-.6814 1.3783-.9003.423-.1651 1.0575-.3614 2.227-.4171 1.2655-.06 1.6447-.072 4.848-.079 3.2033-.007 3.5835.005 4.8495.0608 1.169.0508 1.8053.2445 2.228.408.5608.216.96.4754 1.3816.895.4217.4194.6816.8176.9005 1.3787.1653.4217.3617 1.056.4169 2.2263.0602 1.2655.0739 1.645.0796 4.848.0058 3.203-.0055 3.5834-.061 4.848-.051 1.17-.245 1.8055-.408 2.2294-.216.5604-.4763.96-.8954 1.3814-.419.4215-.8181.6811-1.3783.9-.4224.1649-1.0577.3617-2.2262.4174-1.2656.0595-1.6448.072-4.8493.079-3.2045.007-3.5825-.006-4.848-.0608M16.953 5.5864A1.44 1.44 0 1 0 18.39 4.144a1.44 1.44 0 0 0-1.437 1.4424M5.8385 12.012c.0067 3.4032 2.7706 6.1557 6.173 6.1493 3.4026-.0065 6.157-2.7701 6.1506-6.1733-.0065-3.4032-2.771-6.1565-6.174-6.1498-3.403.0067-6.156 2.771-6.1496 6.1738M8 12.0077a4 4 0 1 1 4.008 3.9921A3.9996 3.9996 0 0 1 8 12.0077' },
9
+ itch: { hex: '#FA5C5C', d: 'M3.13 1.338C2.08 1.96.02 4.328 0 4.95v1.03c0 1.303 1.22 2.45 2.325 2.45 1.33 0 2.436-1.102 2.436-2.41 0 1.308 1.07 2.41 2.4 2.41 1.328 0 2.362-1.102 2.362-2.41 0 1.308 1.137 2.41 2.466 2.41h.024c1.33 0 2.466-1.102 2.466-2.41 0 1.308 1.034 2.41 2.363 2.41 1.33 0 2.4-1.102 2.4-2.41 0 1.308 1.106 2.41 2.435 2.41C22.78 8.43 24 7.282 24 5.98V4.95c-.02-.62-2.082-2.99-3.13-3.612-3.253-.114-5.508-.134-8.87-.133-3.362 0-7.945.053-8.87.133zm6.376 6.477a2.74 2.74 0 0 1-.468.602c-.5.49-1.19.795-1.947.795a2.786 2.786 0 0 1-1.95-.795c-.182-.178-.32-.37-.446-.59-.127.222-.303.412-.486.59a2.788 2.788 0 0 1-1.95.795c-.092 0-.187-.025-.264-.052-.107 1.113-.152 2.176-.168 2.95v.005l-.006 1.167c.02 2.334-.23 7.564 1.03 8.85 1.952.454 5.545.662 9.15.663 3.605 0 7.198-.21 9.15-.664 1.26-1.284 1.01-6.514 1.03-8.848l-.006-1.167v-.004c-.016-.775-.06-1.838-.168-2.95-.077.026-.172.052-.263.052a2.788 2.788 0 0 1-1.95-.795c-.184-.178-.36-.368-.486-.59-.127.22-.265.412-.447.59a2.786 2.786 0 0 1-1.95.794c-.76 0-1.446-.303-1.948-.793a2.74 2.74 0 0 1-.468-.602 2.738 2.738 0 0 1-.463.602 2.787 2.787 0 0 1-1.95.794h-.16a2.787 2.787 0 0 1-1.95-.793 2.738 2.738 0 0 1-.464-.602zm-2.004 2.59v.002c.795.002 1.5 0 2.373.953.687-.072 1.406-.108 2.125-.107.72 0 1.438.035 2.125.107.873-.953 1.578-.95 2.372-.953.376 0 1.876 0 2.92 2.934l1.123 4.028c.832 2.995-.266 3.068-1.636 3.07-2.03-.075-3.156-1.55-3.156-3.025-1.124.184-2.436.276-3.748.277-1.312 0-2.624-.093-3.748-.277 0 1.475-1.125 2.95-3.156 3.026-1.37-.004-2.468-.077-1.636-3.072l1.122-4.027c1.045-2.934 2.545-2.934 2.92-2.934zM12 12.714c-.002.002-2.14 1.964-2.523 2.662l1.4-.056v1.22c0 .056.56.033 1.123.007.562.026 1.124.05 1.124-.008v-1.22l1.4.055C14.138 14.677 12 12.713 12 12.713z' },
10
+ mastodon: { hex: '#6364FF', d: 'M23.268 5.313c-.35-2.578-2.617-4.61-5.304-5.004C17.51.242 15.792 0 11.813 0h-.03c-3.98 0-4.835.242-5.288.309C3.882.692 1.496 2.518.917 5.127.64 6.412.61 7.837.661 9.143c.074 1.874.088 3.745.26 5.611.118 1.24.325 2.47.62 3.68.55 2.237 2.777 4.098 4.96 4.857 2.336.792 4.849.923 7.256.38.265-.061.527-.132.786-.213.585-.184 1.27-.39 1.774-.753a.057.057 0 0 0 .023-.043v-1.809a.052.052 0 0 0-.02-.041.053.053 0 0 0-.046-.01 20.282 20.282 0 0 1-4.709.545c-2.73 0-3.463-1.284-3.674-1.818a5.593 5.593 0 0 1-.319-1.433.053.053 0 0 1 .066-.054c1.517.363 3.072.546 4.632.546.376 0 .75 0 1.125-.01 1.57-.044 3.224-.124 4.768-.422.038-.008.077-.015.11-.024 2.435-.464 4.753-1.92 4.989-5.604.008-.145.03-1.52.03-1.67.002-.512.167-3.63-.024-5.545zm-3.748 9.195h-2.561V8.29c0-1.309-.55-1.976-1.67-1.976-1.23 0-1.846.79-1.846 2.35v3.403h-2.546V8.663c0-1.56-.617-2.35-1.848-2.35-1.112 0-1.668.668-1.67 1.977v6.218H4.822V8.102c0-1.31.337-2.35 1.011-3.12.696-.77 1.608-1.164 2.74-1.164 1.311 0 2.302.5 2.962 1.498l.638 1.06.638-1.06c.66-.999 1.65-1.498 2.96-1.498 1.13 0 2.043.395 2.74 1.164.675.77 1.012 1.81 1.012 3.12z' },
11
+ patreon: { hex: '#FF424D', d: 'M22.957 7.21c-.004-3.064-2.391-5.576-5.191-6.482-3.478-1.125-8.064-.962-11.384.604C2.357 3.231 1.093 7.391 1.046 11.54c-.039 3.411.302 12.396 5.369 12.46 3.765.047 4.326-4.804 6.068-7.141 1.24-1.662 2.836-2.132 4.801-2.618 3.376-.836 5.678-3.501 5.673-7.031Z' },
12
+ reddit: { hex: '#FF4500', d: 'M12 0C5.373 0 0 5.373 0 12c0 3.314 1.343 6.314 3.515 8.485l-2.286 2.286C.775 23.225 1.097 24 1.738 24H12c6.627 0 12-5.373 12-12S18.627 0 12 0Zm4.388 3.199c1.104 0 1.999.895 1.999 1.999 0 1.105-.895 2-1.999 2-.946 0-1.739-.657-1.947-1.539v.002c-1.147.162-2.032 1.15-2.032 2.341v.007c1.776.067 3.4.567 4.686 1.363.473-.363 1.064-.58 1.707-.58 1.547 0 2.802 1.254 2.802 2.802 0 1.117-.655 2.081-1.601 2.531-.088 3.256-3.637 5.876-7.997 5.876-4.361 0-7.905-2.617-7.998-5.87-.954-.447-1.614-1.415-1.614-2.538 0-1.548 1.255-2.802 2.803-2.802.645 0 1.239.218 1.712.585 1.275-.79 2.881-1.291 4.64-1.365v-.01c0-1.663 1.263-3.034 2.88-3.207.188-.911.993-1.595 1.959-1.595Zm-8.085 8.376c-.784 0-1.459.78-1.506 1.797-.047 1.016.64 1.429 1.426 1.429.786 0 1.371-.369 1.418-1.385.047-1.017-.553-1.841-1.338-1.841Zm7.406 0c-.786 0-1.385.824-1.338 1.841.047 1.017.634 1.385 1.418 1.385.785 0 1.473-.413 1.426-1.429-.046-1.017-.721-1.797-1.506-1.797Zm-3.703 4.013c-.974 0-1.907.048-2.77.135-.147.015-.241.168-.183.305.483 1.154 1.622 1.964 2.953 1.964 1.33 0 2.47-.81 2.953-1.964.057-.137-.037-.29-.184-.305-.863-.087-1.795-.135-2.769-.135Z' },
13
+ site: { hex: '#E9739A', d: 'M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56zm2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z' },
14
+ steam: { hex: '#1A9FFF', d: 'M11.979 0C5.678 0 .511 4.86.022 11.037l6.432 2.658c.545-.371 1.203-.59 1.912-.59.063 0 .125.004.188.006l2.861-4.142V8.91c0-2.495 2.028-4.524 4.524-4.524 2.494 0 4.524 2.031 4.524 4.527s-2.03 4.525-4.524 4.525h-.105l-4.076 2.911c0 .052.004.105.004.159 0 1.875-1.515 3.396-3.39 3.396-1.635 0-3.016-1.173-3.331-2.727L.436 15.27C1.862 20.307 6.486 24 11.979 24c6.627 0 11.999-5.373 11.999-12S18.605 0 11.979 0zM7.54 18.21l-1.473-.61c.262.543.714.999 1.314 1.25 1.297.539 2.793-.076 3.332-1.375.263-.63.264-1.319.005-1.949s-.75-1.121-1.377-1.383c-.624-.26-1.29-.249-1.878-.03l1.523.63c.956.4 1.409 1.5 1.009 2.455-.397.957-1.497 1.41-2.454 1.012H7.54zm11.415-9.303c0-1.662-1.353-3.015-3.015-3.015-1.665 0-3.015 1.353-3.015 3.015 0 1.665 1.35 3.015 3.015 3.015 1.663 0 3.015-1.35 3.015-3.015zm-5.273-.005c0-1.252 1.013-2.266 2.265-2.266 1.249 0 2.266 1.014 2.266 2.266 0 1.251-1.017 2.265-2.266 2.265-1.253 0-2.265-1.014-2.265-2.265z' },
15
+ threads: { hex: '#14171A', d: 'M12.186 24h-.007c-3.581-.024-6.334-1.205-8.184-3.509C2.35 18.44 1.5 15.586 1.472 12.01v-.017c.03-3.579.879-6.43 2.525-8.482C5.845 1.205 8.6.024 12.18 0h.014c2.746.02 5.043.725 6.826 2.098 1.677 1.29 2.858 3.13 3.509 5.467l-2.04.569c-1.104-3.96-3.898-5.984-8.304-6.015-2.91.022-5.11.936-6.54 2.717C4.307 6.504 3.616 8.914 3.589 12c.027 3.086.718 5.496 2.057 7.164 1.43 1.783 3.631 2.698 6.54 2.717 2.623-.02 4.358-.631 5.8-2.045 1.647-1.613 1.618-3.593 1.09-4.798-.31-.71-.873-1.3-1.634-1.75-.192 1.352-.622 2.446-1.284 3.272-.886 1.102-2.14 1.704-3.73 1.79-1.202.065-2.361-.218-3.259-.801-1.063-.689-1.685-1.74-1.752-2.964-.065-1.19.408-2.285 1.33-3.082.88-.76 2.119-1.207 3.583-1.291a13.853 13.853 0 0 1 3.02.142c-.126-.742-.375-1.332-.75-1.757-.513-.586-1.308-.883-2.359-.89h-.029c-.844 0-1.992.232-2.721 1.32L7.734 7.847c.98-1.454 2.568-2.256 4.478-2.256h.044c3.194.02 5.097 1.975 5.287 5.388.108.046.216.094.321.142 1.49.7 2.58 1.761 3.154 3.07.797 1.82.871 4.79-1.548 7.158-1.85 1.81-4.094 2.628-7.277 2.65Zm1.003-11.69c-.242 0-.487.007-.739.021-1.836.103-2.98.946-2.916 2.143.067 1.256 1.452 1.839 2.784 1.767 1.224-.065 2.818-.543 3.086-3.71a10.5 10.5 0 0 0-2.215-.221z' },
16
+ tiktok: { hex: '#FE2C55', d: 'M12.525.02c1.31-.02 2.61-.01 3.91-.02.08 1.53.63 3.09 1.75 4.17 1.12 1.11 2.7 1.62 4.24 1.79v4.03c-1.44-.05-2.89-.35-4.2-.97-.57-.26-1.1-.59-1.62-.93-.01 2.92.01 5.84-.02 8.75-.08 1.4-.54 2.79-1.35 3.94-1.31 1.92-3.58 3.17-5.91 3.21-1.43.08-2.86-.31-4.08-1.03-2.02-1.19-3.44-3.37-3.65-5.71-.02-.5-.03-1-.01-1.49.18-1.9 1.12-3.72 2.58-4.96 1.66-1.44 3.98-2.13 6.15-1.72.02 1.48-.04 2.96-.04 4.44-.99-.32-2.15-.23-3.02.37-.63.41-1.11 1.04-1.36 1.75-.21.51-.15 1.07-.14 1.61.24 1.64 1.82 3.02 3.5 2.87 1.12-.01 2.19-.66 2.77-1.61.19-.33.4-.67.41-1.06.1-1.79.06-3.57.07-5.36.01-4.03-.01-8.05.02-12.07z' },
17
+ x: { hex: '#14171A', d: 'M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z' },
18
+ youtube: { hex: '#FF0000', d: 'M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z' },
19
+ }
20
+
21
+ /** the platform's color, gray for one without a mark */
22
+ export const brandHex = (id: string): string => BRANDS[id]?.hex ?? '#868E96'