rvlib-shipkit 2.19.0 → 2.21.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 (196) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/package.json +1 -1
  3. package/src/annex/annex.ts +227 -0
  4. package/src/annex/offload.ts +279 -0
  5. package/src/checks/SK004-gitignore-policy.check.ts +6 -3
  6. package/src/checks/SK040-release-words.check.ts +43 -0
  7. package/src/checks/SK041-annex-links.check.ts +28 -0
  8. package/src/checks/SK042-post-kinds.check.ts +73 -0
  9. package/src/cli/cmd_Annex.ts +179 -0
  10. package/src/cli/cmd_Commands.ts +4 -1
  11. package/src/cli/cmd_GlobalProcesses.ts +2 -107
  12. package/src/cli/cmd_Home.ts +4 -3
  13. package/src/cli/cmd_Messages.ts +155 -0
  14. package/src/cli/cmd_Overview.ts +2 -1
  15. package/src/cli/cmd_Releases.ts +84 -0
  16. package/src/cli/cmd_Review.ts +176 -12
  17. package/src/cli/cmd_Shot.ts +4 -4
  18. package/src/cli/cmd_Social.ts +151 -8
  19. package/src/cli/cmd_Sound.ts +17 -4
  20. package/src/cli/cmd_Trailer.ts +67 -1
  21. package/src/cli/family-pages.ts +2 -0
  22. package/src/cli/kit/index.ts +1 -1
  23. package/src/cli/kit/verb.ts +11 -3
  24. package/src/cli/registry.ts +7 -1
  25. package/src/collections/collection-types.ts +8 -1
  26. package/src/collections/providers.ts +4 -1
  27. package/src/collections/review.ts +23 -4
  28. package/src/commands/model.ts +36 -0
  29. package/src/commands/registry.ts +49 -0
  30. package/src/commands/routes.ts +59 -0
  31. package/src/commands/runner.ts +35 -0
  32. package/src/commands/runs.ts +112 -0
  33. package/src/core/app-icon.ts +4 -3
  34. package/src/core/icon-type.ts +8 -0
  35. package/src/core/jobs.ts +4 -3
  36. package/src/core/layout.ts +11 -2
  37. package/src/core/squircle.ts +95 -0
  38. package/src/home/daemon-jobs.ts +26 -2
  39. package/src/home/global-units.ts +3 -0
  40. package/src/home/gui-app/ShipkitGui.swift +337 -5
  41. package/src/home/gui-app.ts +64 -33
  42. package/src/home/hmr-keep.ts +134 -0
  43. package/src/home/home-start.ts +2 -2
  44. package/src/home/lib-watch.ts +21 -11
  45. package/src/home/pm-switch.ts +112 -0
  46. package/src/home/pm.ts +1 -1
  47. package/src/home/process-apps.ts +181 -0
  48. package/src/home/resources.ts +3 -3
  49. package/src/home/run-web.ts +7 -4
  50. package/src/home/serve-web.ts +64 -14
  51. package/src/identities/collection.ts +49 -0
  52. package/src/identities/identities.ts +121 -14
  53. package/src/identities/machine.ts +4 -3
  54. package/src/identities/rating.ts +33 -0
  55. package/src/identities/shown.ts +170 -0
  56. package/src/identities/steps.ts +5 -0
  57. package/src/media-store/purge.ts +15 -1
  58. package/src/media-store/remote.ts +22 -6
  59. package/src/messages/brief.ts +117 -0
  60. package/src/messages/collection.ts +40 -0
  61. package/src/messages/model.ts +171 -0
  62. package/src/messages/routes.ts +15 -0
  63. package/src/messages/score.ts +182 -0
  64. package/src/messages/tabs.ts +13 -0
  65. package/src/release/notes.ts +130 -0
  66. package/src/release/run-bump.ts +41 -18
  67. package/src/release/run-release.ts +22 -4
  68. package/src/release/run-releases.ts +17 -15
  69. package/src/release/unit-resolve.ts +9 -0
  70. package/src/releases/add.ts +94 -0
  71. package/src/releases/before.ts +31 -0
  72. package/src/releases/collection.ts +36 -0
  73. package/src/releases/from-card.ts +151 -0
  74. package/src/releases/model.ts +327 -0
  75. package/src/releases/pictures.ts +110 -0
  76. package/src/releases/routes.ts +36 -0
  77. package/src/releases/store.ts +71 -0
  78. package/src/repo-config.ts +5 -0
  79. package/src/review/cells.ts +0 -11
  80. package/src/review/format.ts +10 -6
  81. package/src/review/http.ts +1 -1
  82. package/src/review/model.ts +102 -3
  83. package/src/review/notes.ts +2 -48
  84. package/src/review/routes.ts +28 -10
  85. package/src/review/stage-card.ts +197 -0
  86. package/src/review/stage-routes.ts +123 -0
  87. package/src/review/store.ts +47 -1
  88. package/src/review/trailer-card.ts +99 -0
  89. package/src/review/trailer-desk.ts +76 -4
  90. package/src/review/trailer-model.ts +106 -7
  91. package/src/review/trailer-notes.ts +45 -0
  92. package/src/review/trailer-routes.ts +119 -13
  93. package/src/review/trailer-voices.ts +144 -0
  94. package/src/review/watchers.ts +58 -1
  95. package/src/serve/hub-app/app-bridge.ts +71 -0
  96. package/src/serve/hub-app/benign-errors.ts +22 -0
  97. package/src/serve/hub-app/commands/commands-page.tsx +122 -0
  98. package/src/serve/hub-app/commands/commands-st.ts +177 -0
  99. package/src/serve/hub-app/commands.css +24 -0
  100. package/src/serve/hub-app/hash-route.ts +59 -8
  101. package/src/serve/hub-app/home-st.ts +19 -2
  102. package/src/serve/hub-app/home.html +3 -0
  103. package/src/serve/hub-app/hub-app.tsx +8 -0
  104. package/src/serve/hub-app/icons.tsx +5 -0
  105. package/src/serve/hub-app/identities-view.tsx +4 -1
  106. package/src/serve/hub-app/identities.css +1 -0
  107. package/src/serve/hub-app/index.html +3 -0
  108. package/src/serve/hub-app/keys.ts +2 -2
  109. package/src/serve/hub-app/machine-st.ts +41 -10
  110. package/src/serve/hub-app/messages/messages-page.tsx +354 -0
  111. package/src/serve/hub-app/messages/messages-st.ts +74 -0
  112. package/src/serve/hub-app/messages.css +35 -0
  113. package/src/serve/hub-app/project-list.css +7 -2
  114. package/src/serve/hub-app/project-list.tsx +9 -0
  115. package/src/serve/hub-app/projects-svc.ts +16 -6
  116. package/src/serve/hub-app/releases/releases-page.tsx +187 -0
  117. package/src/serve/hub-app/releases/releases-st.ts +111 -0
  118. package/src/serve/hub-app/releases.css +52 -0
  119. package/src/serve/hub-app/repo-sections.ts +16 -2
  120. package/src/serve/hub-app/repo-st.ts +66 -10
  121. package/src/serve/hub-app/review/clip-st.ts +34 -4
  122. package/src/serve/hub-app/review/kit.tsx +3 -3
  123. package/src/serve/hub-app/review/note-place.ts +31 -0
  124. package/src/serve/hub-app/review/review-cells.tsx +27 -3
  125. package/src/serve/hub-app/review/review-st.ts +77 -2
  126. package/src/serve/hub-app/review/review-thread.tsx +9 -31
  127. package/src/serve/hub-app/review/review-views.tsx +164 -58
  128. package/src/serve/hub-app/review/thread-st.ts +108 -41
  129. package/src/serve/hub-app/review/trailer-card.tsx +187 -0
  130. package/src/serve/hub-app/review/trailer-page.tsx +92 -36
  131. package/src/serve/hub-app/review/trailer-st.ts +306 -34
  132. package/src/serve/hub-app/review/trailer-timeline.tsx +68 -23
  133. package/src/serve/hub-app/review/trailer-voices-st.ts +370 -0
  134. package/src/serve/hub-app/review/trailer-voices.tsx +574 -0
  135. package/src/serve/hub-app/review.css +137 -6
  136. package/src/serve/hub-app/social/comms-page.tsx +65 -28
  137. package/src/serve/hub-app/social/identity-pictures.ts +46 -8
  138. package/src/serve/hub-app/social/kit.tsx +9 -6
  139. package/src/serve/hub-app/social/next-release.tsx +118 -0
  140. package/src/serve/hub-app/social/post-card.tsx +10 -2
  141. package/src/serve/hub-app/social/social-model.ts +39 -3
  142. package/src/serve/hub-app/social/social-page.tsx +179 -65
  143. package/src/serve/hub-app/social/social-st.ts +117 -27
  144. package/src/serve/hub-app/social/stage-popup.tsx +268 -0
  145. package/src/serve/hub-app/social/stage-st.ts +310 -0
  146. package/src/serve/hub-app/social/step-layout.ts +42 -0
  147. package/src/serve/hub-app/social.css +68 -1
  148. package/src/serve/hub-app/tree-build.ts +40 -1
  149. package/src/serve/hub-app/tree-svc.ts +10 -3
  150. package/src/serve/project-gutter-route.ts +12 -2
  151. package/src/serve/project-gutter.ts +4 -2
  152. package/src/serve/same-origin.ts +24 -1
  153. package/src/serve/serve-hub.ts +15 -1
  154. package/src/shipkit-files.ts +9 -7
  155. package/src/shot/box.ts +33 -12
  156. package/src/shot/client.ts +1 -1
  157. package/src/shot/shooter.ts +22 -12
  158. package/src/shot/shot-ask.ts +14 -3
  159. package/src/shot/shot.shipkit.ts +1 -1
  160. package/src/social/desk-index.ts +49 -8
  161. package/src/social/discord-layout.ts +54 -7
  162. package/src/social/drafts.ts +1 -1
  163. package/src/social/fit.ts +84 -0
  164. package/src/social/identity-words.ts +74 -0
  165. package/src/social/kind-pages.ts +41 -0
  166. package/src/social/kinds.ts +93 -0
  167. package/src/social/load.ts +125 -10
  168. package/src/social/media-limit.ts +63 -2
  169. package/src/social/presence.ts +1 -1
  170. package/src/social/publish/bluesky.ts +58 -19
  171. package/src/social/publish/index.ts +47 -6
  172. package/src/social/reach.ts +49 -0
  173. package/src/social/release-stage.ts +277 -0
  174. package/src/social/routes.ts +44 -8
  175. package/src/social/stage.ts +246 -0
  176. package/src/social/strip.ts +85 -0
  177. package/src/social/text.ts +6 -2
  178. package/src/social/unit.ts +57 -1
  179. package/src/social/writes.ts +11 -0
  180. package/src/trailer/bed.ts +111 -0
  181. package/src/trailer/build.ts +72 -40
  182. package/src/trailer/ffmpeg.ts +6 -0
  183. package/src/trailer/grammar.ts +37 -6
  184. package/src/trailer/graph.ts +12 -1
  185. package/src/trailer/public-words.ts +41 -0
  186. package/src/trailer/shot-plan.ts +75 -0
  187. package/src/trailer/shot-state.ts +191 -0
  188. package/src/trailer/sound/audio.ts +28 -0
  189. package/src/trailer/sound/brand.ts +53 -3
  190. package/src/trailer/sound/gen.ts +61 -2
  191. package/src/trailer/sound/index.ts +25 -11
  192. package/src/trailer/sound/presets.ts +86 -5
  193. package/src/trailer/sound/run.ts +1 -1
  194. package/src/trailer/sound/takes.ts +94 -0
  195. package/src/trailer/titles.ts +36 -0
  196. package/src/trailer/url.ts +1 -1
@@ -0,0 +1,327 @@
1
+ // a release as one markdown file (wiki tools/shipkit/units.md, The release files): `# <version>: <title>`, its date,
2
+ // `## <category>`, `### <change>`, its description, its shots, its bullets, the card it came from in a hidden
3
+ // comment. `next.md` is the version being filled. No fs: store.ts reads the files, the hub page imports this too.
4
+ // A picture is `space:<key>` (private, signed for the hub) until the release makes it a public URL. Every picture
5
+ // carries its rating, and a venue shows only what its ceiling takes: `shotFor`, the one function every venue calls
6
+ import { POST_RATINGS, takes, type PostRating } from '../identities/rating.ts'
7
+
8
+ export const NEXT = 'next'
9
+
10
+ export type ReleaseKind = 'major' | 'minor' | 'patch'
11
+
12
+ export interface Picture {
13
+ /** `space:<key>` while private, the public URL once released */
14
+ url: string
15
+ alt: string
16
+ /** what it shows; null when unrated, which reads explicit (`ratingOf`) */
17
+ rating: PostRating | null
18
+ }
19
+
20
+ /** one picture of a change and the still of what it looked like before, `![alt](url "before <rating>")` right under it */
21
+ export interface Shot {
22
+ picture: Picture
23
+ before: Picture | null
24
+ }
25
+
26
+ export interface Change {
27
+ title: string
28
+ /** its description, markdown, empty when the title says it all */
29
+ text: string
30
+ /** one a rating at most, in the file's order: a safe one for every venue, an nsfw one for those that take it */
31
+ shots: Shot[]
32
+ bullets: string[]
33
+ /** the review card it came from, and the commit that card shows */
34
+ card: string | null
35
+ commit: string | null
36
+ }
37
+
38
+ export interface Category {
39
+ name: string
40
+ changes: Change[]
41
+ }
42
+
43
+ export interface Release {
44
+ /** `next`, or X.Y.Z once released */
45
+ version: string
46
+ /** what kind of release next is, `# next (minor)`; null on a released file or when unsaid */
47
+ kind: ReleaseKind | null
48
+ title: string
49
+ /** YYYY-MM-DD, null on next */
50
+ date: string | null
51
+ categories: Category[]
52
+ }
53
+
54
+ export const SPACE = 'space:'
55
+ export const isPrivate = (p: Picture): boolean => p.url.startsWith(SPACE)
56
+ export const spaceKey = (p: Picture): string | null => (isPrivate(p) ? p.url.slice(SPACE.length) : null)
57
+
58
+ /** a change's pictures, each shot's after then its before: what bump makes public and the guard reads */
59
+ export const picturesOf = (ch: Pick<Change, 'shots'>): Picture[] => ch.shots.flatMap((s) => (s.before ? [s.picture, s.before] : [s.picture]))
60
+
61
+ /** a picture's rating as a venue reads it: unrated is explicit, fail closed */
62
+ export const ratingOf = (p: Pick<Picture, 'rating'>): PostRating => p.rating ?? 'explicit'
63
+
64
+ /** what a venue whose ceiling is `ceiling` shows of a change: the shot of the highest rating it takes, its before only
65
+ * when the venue takes that too; null, its words alone. THE function every venue calls, never a filter of its own */
66
+ export function shotFor(ch: Pick<Change, 'shots'>, ceiling: PostRating): Shot | null {
67
+ const rank = (s: Shot): number => POST_RATINGS.indexOf(ratingOf(s.picture))
68
+ const fit = ch.shots.filter((s) => takes(ceiling, ratingOf(s.picture))).sort((a, b) => rank(b) - rank(a))[0]
69
+ if (!fit) return null
70
+ return { picture: fit.picture, before: fit.before && takes(ceiling, ratingOf(fit.before)) ? fit.before : null }
71
+ }
72
+
73
+ /** the change holds a picture this venue may not show and none it may: the venue says where it is instead */
74
+ export const withheldFrom = (ch: Pick<Change, 'shots'>, ceiling: PostRating): boolean => ch.shots.length > 0 && shotFor(ch, ceiling) == null
75
+
76
+ /** a picture line's title: its rating, a before's `before <rating>`; an unrated one says none */
77
+ const titleOf = (p: Picture, before: boolean): string => {
78
+ const t = [before ? 'before' : '', p.rating ?? ''].filter((w) => w !== '').join(' ')
79
+ return t === '' ? '' : ` "${t}"`
80
+ }
81
+
82
+ /** a change's media is a clip (a card's clip), not a still */
83
+ export const isClip = (url: string): boolean => /\.(mp4|webm|mov)(\?|$)/i.test(url)
84
+
85
+ /** where the hub serves a private picture, its key after it */
86
+ export const PICTURE_ROUTE = '/api/releases/picture/'
87
+ /** the hub path a picture shows by: a private one through the hub, a public one as it is */
88
+ export const pictureRoute = (url: string): string => (url.startsWith(SPACE) ? `${PICTURE_ROUTE}${encodeURIComponent(url.slice(SPACE.length))}` : url)
89
+
90
+ const VERSION = /^\d+\.\d+\.\d+$/
91
+ const HEAD = /^# (next|\d+\.\d+\.\d+)(?: \((major|minor|patch)\))?(?:: (.*))?$/
92
+ const DATE = /^\d{4}-\d{2}-\d{2}$/
93
+ const PICTURE = /^!\[([^\]]*)\]\((\S+)(?: "([^"]*)")?\)$/
94
+ /** a picture line's title: `<rating>`, `before`, `before <rating>`, or none */
95
+ const TITLE = /^(before)?\s*(safe|mild|explicit)?$/
96
+ const MARK = /^<!--\s*(?:card:\s*(\S+))?\s*(?:commit:\s*([0-9a-f]{7,40}))?\s*-->$/
97
+ const BULLET = /^[-*] (.*)$/
98
+
99
+ export const isVersion = (v: string): boolean => v === NEXT || VERSION.test(v)
100
+ export const fileOf = (version: string): string => `${version}.md`
101
+
102
+ export const emptyRelease = (): Release => ({ version: NEXT, kind: null, title: '', date: null, categories: [] })
103
+
104
+ /** a release file read into its parts; a line out of place throws naming it */
105
+ export function parseRelease(md: string, name = 'release'): Release {
106
+ const at = (i: number, why: string): Error => new Error(`${name}:${i + 1}: ${why}`)
107
+ let r: Release | null = null
108
+ let cat: Category | null = null
109
+ let ch: Change | null = null
110
+ let comment = false
111
+ let pictureAt = -1
112
+ let text: string[] = []
113
+ const close = (): void => {
114
+ if (ch) ch.text = text.join('\n').trim()
115
+ text = []
116
+ }
117
+ for (const [i, raw] of md.split('\n').entries()) {
118
+ const line = raw.trimEnd()
119
+ if (comment) {
120
+ comment = !line.includes('-->')
121
+ continue
122
+ }
123
+ if (r == null) {
124
+ if (line === '') continue
125
+ // a file comment before the heading says what the file is for, never a public word
126
+ if (line.startsWith('<!--')) {
127
+ comment = !line.includes('-->')
128
+ continue
129
+ }
130
+ const h = HEAD.exec(line)
131
+ if (!h) throw at(i, `the file opens on "# <version>: <title>" or "# next (<kind>): <title>", not: ${line}`)
132
+ if (h[1] !== NEXT && h[2]) throw at(i, 'a released version says no kind: only next does')
133
+ r = { version: h[1]!, kind: (h[2] as ReleaseKind | undefined) ?? null, title: (h[3] ?? '').trim(), date: null, categories: [] }
134
+ continue
135
+ }
136
+ if (line.startsWith('## ')) {
137
+ close()
138
+ ch = null
139
+ cat = { name: line.slice(3).trim(), changes: [] }
140
+ r.categories.push(cat)
141
+ continue
142
+ }
143
+ if (line.startsWith('### ')) {
144
+ if (!cat) throw at(i, `a change sits under a "## <category>": ${line}`)
145
+ close()
146
+ ch = { title: line.slice(4).trim(), text: '', shots: [], bullets: [], card: null, commit: null }
147
+ cat.changes.push(ch)
148
+ continue
149
+ }
150
+ if (line.startsWith('#')) throw at(i, `one "# " heading a file, then "## <category>" and "### <change>": ${line}`)
151
+ if (!cat) {
152
+ if (line === '') continue
153
+ if (DATE.test(line) && r.date == null && r.version !== NEXT) {
154
+ r.date = line
155
+ continue
156
+ }
157
+ throw at(i, `before the first "## <category>" only the date line of a released version: ${line}`)
158
+ }
159
+ if (!ch) {
160
+ if (line === '') continue
161
+ throw at(i, `under "## ${cat.name}" every line belongs to a "### <change>": ${line}`)
162
+ }
163
+ const m = MARK.exec(line)
164
+ if (m && (m[1] || m[2])) {
165
+ ch.card = m[1] ?? ch.card
166
+ ch.commit = m[2] ?? ch.commit
167
+ continue
168
+ }
169
+ if (line.startsWith('<!--')) throw at(i, `a hidden line of a change is "<!-- card: <id> commit: <sha> -->": ${line}`)
170
+ const p = PICTURE.exec(line)
171
+ if (p) {
172
+ const t = TITLE.exec((p[3] ?? '').trim())
173
+ if (!t) throw at(i, `"${ch.title}": a picture's title is its rating (safe, mild, explicit), a before's "before <rating>": "${p[3]}"`)
174
+ const pic: Picture = { alt: p[1]!.trim(), url: p[2]!, rating: (t[2] as PostRating | undefined) ?? null }
175
+ const last = ch.shots.at(-1)
176
+ if (t[1]) {
177
+ if (pictureAt !== i - 1 || !last || last.before) throw at(i, `"${ch.title}": one before a picture, on the line right under it`)
178
+ if (isClip(pic.url)) throw at(i, `"${ch.title}": a before is a still (png, jpg, webp), not a clip`)
179
+ last.before = pic
180
+ continue
181
+ }
182
+ if (ch.shots.some((s) => ratingOf(s.picture) === ratingOf(pic))) throw at(i, `"${ch.title}" has one picture a rating, and two read ${ratingOf(pic)} (an unrated one reads explicit)`)
183
+ ch.shots.push({ picture: pic, before: null })
184
+ pictureAt = i
185
+ continue
186
+ }
187
+ const b = BULLET.exec(line)
188
+ if (b) {
189
+ ch.bullets.push(b[1]!.trim())
190
+ continue
191
+ }
192
+ if (ch.bullets.length > 0 && line !== '') throw at(i, `"${ch.title}": its description comes before its bullets: ${line}`)
193
+ text.push(line)
194
+ }
195
+ close()
196
+ if (r == null) throw new Error(`${name}: empty, it opens on "# <version>: <title>"`)
197
+ if (r.version !== NEXT && r.date == null) throw new Error(`${name}: a released version carries its date on the line under its heading`)
198
+ return r
199
+ }
200
+
201
+ /** the file's text, in the one order the parser reads: heading, date, then each category and its changes */
202
+ export function renderRelease(r: Release): string {
203
+ const kind = r.kind && r.version === NEXT ? ` (${r.kind})` : ''
204
+ const out = [`# ${r.version}${kind}${r.title ? `: ${r.title}` : ''}`]
205
+ if (r.date) out.push(r.date)
206
+ for (const c of r.categories) {
207
+ out.push('', `## ${c.name}`)
208
+ for (const ch of c.changes) {
209
+ out.push('', `### ${ch.title}`)
210
+ if (ch.card || ch.commit) out.push(`<!--${ch.card ? ` card: ${ch.card}` : ''}${ch.commit ? ` commit: ${ch.commit}` : ''} -->`)
211
+ if (ch.text) out.push(ch.text)
212
+ for (const s of ch.shots) {
213
+ out.push(`![${s.picture.alt}](${s.picture.url}${titleOf(s.picture, false)})`)
214
+ if (s.before) out.push(`![${s.before.alt}](${s.before.url}${titleOf(s.before, true)})`)
215
+ }
216
+ for (const b of ch.bullets) out.push(`- ${b}`)
217
+ }
218
+ }
219
+ return `${out.join('\n')}\n`
220
+ }
221
+
222
+ /** next with one change added under its category: the change of the same card, else of the same title in that
223
+ * category, replaced in place (a card's category can move); a new category goes last */
224
+ export function upsertChange(r: Release, category: string, change: Change): Release {
225
+ const name = category.trim()
226
+ if (name === '') throw new Error('a change needs its category')
227
+ if (change.title.trim() === '') throw new Error('a change needs its title')
228
+ const same = (c: Category, x: Change): boolean => (change.card != null && x.card === change.card) || (c.name === name && x.title === change.title)
229
+ const cats = r.categories.map((c) => ({ ...c, changes: [...c.changes] }))
230
+ let placed = false
231
+ for (const c of cats) {
232
+ const i = c.changes.findIndex((x) => same(c, x))
233
+ if (i === -1) continue
234
+ if (c.name === name && !placed) {
235
+ c.changes[i] = change
236
+ placed = true
237
+ } else c.changes.splice(i, 1)
238
+ }
239
+ if (!placed) {
240
+ let c = cats.find((x) => x.name === name)
241
+ if (!c) cats.push((c = { name, changes: [] }))
242
+ c.changes.push(change)
243
+ }
244
+ return { ...r, categories: cats.filter((c) => c.changes.length > 0) }
245
+ }
246
+
247
+ export const changesOf = (r: Release): Change[] => r.categories.flatMap((c) => c.changes)
248
+
249
+ /** a change's key on a page: its card, else its title */
250
+ export const changeKey = (ch: Pick<Change, 'card' | 'title'>): string => `${ch.card ?? ''}${ch.title}`
251
+
252
+ /** a card id's words: its slug, made from the card's title, which a public repo's file carries in its hidden comment */
253
+ const cardWords = (id: string | null): string => (id ?? '').replace(/^\d{8}-\d{6}-?/, '').replace(/-/g, ' ')
254
+
255
+ /** every word of a release that a stranger reads, each a text the repo's guard runs on. The card ids' slugs only when
256
+ * the file itself is public (a declared public repo): the notes, the post and the page never show the hidden comment */
257
+ export const publicTexts = (r: Release, o: { fileIsPublic?: boolean } = {}): string[] =>
258
+ [r.title, ...r.categories.flatMap((c) => [c.name, ...c.changes.flatMap((ch) => [ch.title, ch.text, ...picturesOf(ch).map((p) => p.alt), ...ch.bullets, o.fileIsPublic ? cardWords(ch.card) : ''])])].filter((t) => t.trim() !== '')
259
+
260
+ /** next named as a version, dated */
261
+ export function promoted(r: Release, version: string, date: string): Release {
262
+ if (r.version !== NEXT) throw new Error(`${r.version} is released already: only next becomes a version`)
263
+ if (!VERSION.test(version)) throw new Error(`${version}: a release is X.Y.Z`)
264
+ if (changesOf(r).length === 0) throw new Error(`${fileOf(NEXT)} holds no change: write what changed, then bump`)
265
+ return { ...r, version, kind: null, date }
266
+ }
267
+
268
+ const newer = (a: string, b: string): number => {
269
+ const [x, y] = [a.split('.').map(Number), b.split('.').map(Number)]
270
+ return y[0]! - x[0]! || y[1]! - x[1]! || y[2]! - x[2]!
271
+ }
272
+
273
+ /** versions newest first, next on top */
274
+ export const byVersion = (a: string, b: string): number => (a === NEXT ? -1 : b === NEXT ? 1 : newer(a, b))
275
+
276
+ /** one release as notes: each category a `### `, each change a bullet of its title and description, the picture the
277
+ * ceiling takes (a clip as a link: markdown shows no video), its own bullets under it. A GitHub release, the staged
278
+ * post and CHANGELOG.md read this, all public: safe */
279
+ export function notesOf(r: Release, ceiling: PostRating = 'safe'): string {
280
+ const out: string[] = []
281
+ for (const c of r.categories) {
282
+ out.push(`### ${c.name}`, '')
283
+ for (const ch of c.changes) {
284
+ out.push(`- **${ch.title}**${ch.text ? `: ${ch.text.replace(/\s*\n\s*/g, ' ')}` : ''}`)
285
+ const pic = shotFor(ch, ceiling)?.picture
286
+ if (pic && !isPrivate(pic)) out.push(isClip(pic.url) ? ` [▶ ${pic.alt}](${pic.url})` : ` ![${pic.alt}](${pic.url})`)
287
+ for (const b of ch.bullets) out.push(` - ${b}`)
288
+ }
289
+ out.push('')
290
+ }
291
+ return out.join('\n').trim()
292
+ }
293
+
294
+ const OLD_SECTION = /^##\s*\[?(\d+\.\d+\.\d+)\]?/
295
+
296
+ /** the `## <version>` sections of a CHANGELOG, each its version and its text */
297
+ function sectionsOf(changelog: string): { version: string; text: string }[] {
298
+ const out: { version: string; text: string }[] = []
299
+ let cur: { version: string; lines: string[] } | null = null
300
+ const close = (): void => void (cur && out.push({ version: cur.version, text: cur.lines.join('\n').trim() }))
301
+ for (const line of changelog.split('\n')) {
302
+ if (line.startsWith('## ')) {
303
+ close()
304
+ const m = OLD_SECTION.exec(line)
305
+ cur = m ? { version: m[1]!, lines: [line] } : null
306
+ continue
307
+ }
308
+ cur?.lines.push(line)
309
+ }
310
+ close()
311
+ return out
312
+ }
313
+
314
+ /** CHANGELOG.md for a unit that publishes to npm, made from its release files: never edited by hand. Every section of
315
+ * the CHANGELOG `before` whose version has no release file is kept as it was written, so the history from before the
316
+ * release files stays; an Unreleased section is not kept (notes.ts refuses a bump while it holds notes) */
317
+ export function changelogOf(releases: readonly Release[], before = ''): string {
318
+ const done = releases.filter((r) => r.version !== NEXT)
319
+ const have = new Set(done.map((r) => r.version))
320
+ const sections = [
321
+ ...done.map((r) => ({ version: r.version, text: `## ${r.version} (${r.date})${r.title ? `: ${r.title}` : ''}\n\n${notesOf(r)}` })),
322
+ ...sectionsOf(before).filter((s) => !have.has(s.version)),
323
+ ].sort((a, b) => byVersion(a.version, b.version))
324
+ const out = ['# Changelog', '', '<!-- made from .shipkit/releases/ by sk bump: edit those files, never this one -->']
325
+ for (const s of sections) out.push('', s.text)
326
+ return `${out.join('\n')}\n`
327
+ }
@@ -0,0 +1,110 @@
1
+ // a change's picture in the Space (wiki tools/shipkit/units.md, The release files): kept PRIVATE when the change is
2
+ // written, by its content, its metadata stripped, a copy in the scratch so the hub and the release read it with no
3
+ // download; made public only when its version ships, after the repo's guard read its bytes. A public URL is out for good
4
+ // once fetched, so nothing unreleased ever gets one
5
+ import { copyFileSync, existsSync, mkdirSync, renameSync, writeFileSync } from 'node:fs'
6
+ import { extname, join } from 'node:path'
7
+ import { LAYOUT } from '../core/layout.ts'
8
+ import { shaOf, shaOfKey } from '../media-store/content.ts'
9
+ import { linkMedia, putMedia } from '../media-store/put.ts'
10
+ import { stripCopy } from '../social/strip.ts'
11
+ import { guardWith, type SocialUnit } from '../social/unit.ts'
12
+ import { isPrivate, ratingOf, SPACE, spaceKey, type Picture, type Release } from './model.ts'
13
+
14
+ /** the media store's label of every release picture, private and public */
15
+ export const RELEASE_KIND = 'release'
16
+
17
+ const STRIPPED = new Set(['.png', '.jpg', '.jpeg', '.webp', '.mp4', '.mov', '.webm'])
18
+
19
+ /** the scratch copy of the pictures, by their sha: never tracked, made again from the Space when gone */
20
+ export const picturesDir = (root: string): string => join(root, LAYOUT.tmp, 'releases')
21
+
22
+ const copyOf = (root: string, sha: string, ext: string): string => join(picturesDir(root), `${sha}${ext}`)
23
+
24
+ /** a file kept as a release picture: stripped, copied by its sha, up to the Space private; its `space:<key>` url */
25
+ export async function keepPicture(root: string, file: string): Promise<string> {
26
+ const ext = extname(file).toLowerCase()
27
+ if (!STRIPPED.has(ext)) throw new Error(`${file}: a release picture is a png, jpg, webp or a clip (mp4, mov, webm)`)
28
+ mkdirSync(picturesDir(root), { recursive: true })
29
+ const tmp = join(picturesDir(root), `.in-${process.pid}${ext}`)
30
+ stripCopy(file, tmp)
31
+ const at = copyOf(root, await shaOf(tmp), ext)
32
+ renameSync(tmp, at)
33
+ const p = await putMedia(at, { kind: RELEASE_KIND })
34
+ return `${SPACE}${p.key}`
35
+ }
36
+
37
+ /** the local file of a kept picture: its scratch copy, else fetched back from the Space into it */
38
+ export async function pictureFile(root: string, key: string): Promise<string> {
39
+ const sha = shaOfKey(key)
40
+ if (sha == null) throw new Error(`${key}: no key of the media store`)
41
+ const at = copyOf(root, sha, extname(key))
42
+ if (existsSync(at)) return at
43
+ const link = await linkMedia(key, { seconds: 300 })
44
+ const r = await fetch(link.url)
45
+ if (!r.ok) throw new Error(`${key}: the Space answered ${r.status}`)
46
+ mkdirSync(picturesDir(root), { recursive: true })
47
+ writeFileSync(at, Buffer.from(await r.arrayBuffer()))
48
+ return at
49
+ }
50
+
51
+ /** the local file of any release picture: a private one's (`pictureFile`), a public one's scratch copy by its sha,
52
+ * else fetched once into it */
53
+ export async function localPicture(root: string, url: string): Promise<string> {
54
+ if (url.startsWith(SPACE)) return pictureFile(root, url.slice(SPACE.length))
55
+ const m = /([0-9a-f]{64})(\.[a-z0-9]+)(?:\?|$)/i.exec(url)
56
+ if (!m) throw new Error(`${url}: no release picture (its name is its sha)`)
57
+ const at = copyOf(root, m[1]!.toLowerCase(), m[2]!.toLowerCase())
58
+ if (existsSync(at)) return at
59
+ const r = await fetch(url)
60
+ if (!r.ok) throw new Error(`${url}: answered ${r.status}`)
61
+ mkdirSync(picturesDir(root), { recursive: true })
62
+ writeFileSync(at, Buffer.from(await r.arrayBuffer()))
63
+ return at
64
+ }
65
+
66
+ /** a signed link for the hub to show a private picture, or its public URL as it is */
67
+ export async function shownUrl(url: string): Promise<string> {
68
+ const key = url.startsWith(SPACE) ? url.slice(SPACE.length) : null
69
+ return key == null ? url : (await linkMedia(key, { seconds: 3600 })).url
70
+ }
71
+
72
+ /** every private picture of a release made public, each after the repo's guard read its bytes: the release with its
73
+ * public URLs. A refusal throws naming the change, and nothing is made public before every picture passed */
74
+ export async function publishPictures(root: string, r: Release, unit: SocialUnit | null): Promise<{ release: Release; published: number }> {
75
+ // only a safe picture gets a public URL: an nsfw one goes to its venues as a file, so it stays private
76
+ const todo = r.categories
77
+ .flatMap((c) => c.changes)
78
+ .flatMap((ch) => ch.shots.flatMap((s) => [s.picture, s.before].filter((p): p is Picture => p != null && isPrivate(p) && ratingOf(p) === 'safe').map((p) => ({ ch, p, before: p === s.before }))))
79
+ const files = new Map<string, string>()
80
+ for (const { ch, p, before } of todo) {
81
+ const key = spaceKey(p)!
82
+ const file = await pictureFile(root, key)
83
+ const problems = guardWith(unit, { title: ch.title, alt: p.alt, files: [file] })
84
+ if (problems.length > 0) throw new Error(`"${ch.title}": the repo's guard refuses its ${before ? 'before' : 'picture'}: ${problems.join('; ')}`)
85
+ files.set(key, file)
86
+ }
87
+ const urls = new Map<string, string>()
88
+ for (const [key, file] of files) {
89
+ // the public copy is put from its own name, so its index row never takes the private one's place
90
+ const pub = join(picturesDir(root), `public-${shaOfKey(key)}${extname(key)}`)
91
+ copyFileSync(file, pub)
92
+ const p = await putMedia(pub, { kind: RELEASE_KIND, public: true })
93
+ if (!p.url) throw new Error(`${key}: the Space gave no public URL`)
94
+ urls.set(key, p.url)
95
+ }
96
+ const release: Release = {
97
+ ...r,
98
+ categories: r.categories.map((c) => ({
99
+ ...c,
100
+ changes: c.changes.map((ch) => {
101
+ const pub = (p: Picture | null): Picture | null => {
102
+ const key = p ? spaceKey(p) : null
103
+ return key && urls.has(key) ? { ...p!, url: urls.get(key)! } : p
104
+ }
105
+ return { ...ch, shots: ch.shots.map((s) => ({ picture: pub(s.picture)!, before: pub(s.before) })) }
106
+ }),
107
+ })),
108
+ }
109
+ return { release, published: urls.size }
110
+ }
@@ -0,0 +1,36 @@
1
+ // the releases page's routes (wiki tools/shipkit/units.md, The release files): every release file read fresh, and a
2
+ // private picture shown from its scratch copy, else through a signed link of the Space. Read only: the files are
3
+ // written by an approval, `sk releases add` or a hand
4
+ import { existsSync } from 'node:fs'
5
+ import { extname, join } from 'node:path'
6
+ import { shaOfKey } from '../media-store/content.ts'
7
+ import { bad, NO_STORE, ranged } from '../review/http.ts'
8
+ import { PICTURE_ROUTE, type Release } from './model.ts'
9
+ import { picturesDir, shownUrl } from './pictures.ts'
10
+ import { readReleases } from './store.ts'
11
+
12
+ /** what the page reads: every release, next first, and each file that does not parse */
13
+ export interface ReleasesView {
14
+ releases: Release[]
15
+ errors: string[]
16
+ }
17
+
18
+ /** the releases routes of the repo at `root`; null for any other path */
19
+ export async function releasesRoutes(root: string, req: Request, path: string): Promise<Response | null> {
20
+ if (path !== '/api/releases' && !path.startsWith('/api/releases/')) return null
21
+ if (req.method !== 'GET') return bad(`releases: no route ${req.method} ${path}`, 404)
22
+ try {
23
+ if (path === '/api/releases') return Response.json(readReleases(root) satisfies ReleasesView, { headers: NO_STORE })
24
+ if (path.startsWith(PICTURE_ROUTE)) {
25
+ const key = decodeURIComponent(path.slice(PICTURE_ROUTE.length))
26
+ const sha = shaOfKey(key)
27
+ if (sha == null || !key.startsWith('release/')) return bad(`${key}: no release picture`, 404)
28
+ const local = join(picturesDir(root), `${sha}${extname(key)}`)
29
+ if (existsSync(local)) return ranged(req, local)
30
+ return Response.redirect(await shownUrl(`space:${key}`), 302)
31
+ }
32
+ return bad(`releases: no route ${path}`, 404)
33
+ } catch (e) {
34
+ return bad(e, 500)
35
+ }
36
+ }
@@ -0,0 +1,71 @@
1
+ // the release files on the disk (wiki tools/shipkit/units.md, The release files): `.shipkit/releases/next.md` and one
2
+ // `<version>.md` a released version, read, written, and a change added to next. Pictures: pictures.ts
3
+ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync } from 'node:fs'
4
+ import { join } from 'node:path'
5
+ import { atomicWrite } from '../core/locked-write.ts'
6
+ import { LAYOUT } from '../core/layout.ts'
7
+ import { byVersion, emptyRelease, fileOf, NEXT, parseRelease, renderRelease, upsertChange, type Change, type Release } from './model.ts'
8
+
9
+ const FILE = /^(next|\d+\.\d+\.\d+)\.md$/
10
+
11
+ export const releasesDir = (root: string): string => join(root, LAYOUT.releases)
12
+
13
+ /** why this repo keeps no release files, null when it declares them (`release: { releases: true }`): declared, never
14
+ * inferred, so a card's approval never starts a folder that would take over the repo's CHANGELOG */
15
+ export async function undeclaredReleases(root: string): Promise<string | null> {
16
+ const { loadRepoConfig } = await import('../repo-config.ts')
17
+ const c = await loadRepoConfig(root)
18
+ return c.release?.releases === true ? null : `${c.name ?? 'this repo'} keeps no release files: add \`release: { releases: true }\` to repo.config.ts first (wiki tools/shipkit/units.md, The release files)`
19
+ }
20
+ export const hasReleases = (root: string): boolean => existsSync(releasesDir(root))
21
+ export const releaseFile = (root: string, version: string): string => join(releasesDir(root), fileOf(version))
22
+
23
+ /** the versions the folder holds a file for, next first, then newest first */
24
+ export function releaseVersions(root: string): string[] {
25
+ const dir = releasesDir(root)
26
+ if (!existsSync(dir)) return []
27
+ return readdirSync(dir)
28
+ .map((f) => FILE.exec(f)?.[1])
29
+ .filter((v): v is string => v != null)
30
+ .sort(byVersion)
31
+ }
32
+
33
+ /** one release file, parsed; null when there is none */
34
+ export function readRelease(root: string, version: string): Release | null {
35
+ const f = releaseFile(root, version)
36
+ if (!existsSync(f)) return null
37
+ const r = parseRelease(readFileSync(f, 'utf8'), `${LAYOUT.releases}/${fileOf(version)}`)
38
+ if (r.version !== version) throw new Error(`${LAYOUT.releases}/${fileOf(version)} opens on "# ${r.version}": a file is named after its version`)
39
+ return r
40
+ }
41
+
42
+ /** every release file, each parsed, and the ones that do not parse as one error each */
43
+ export function readReleases(root: string): { releases: Release[]; errors: string[] } {
44
+ const releases: Release[] = []
45
+ const errors: string[] = []
46
+ for (const v of releaseVersions(root)) {
47
+ try {
48
+ releases.push(readRelease(root, v)!)
49
+ } catch (e) {
50
+ errors.push((e as Error).message)
51
+ }
52
+ }
53
+ return { releases, errors }
54
+ }
55
+
56
+ /** a release written as its file; the absolute path */
57
+ export function writeRelease(root: string, r: Release): string {
58
+ mkdirSync(releasesDir(root), { recursive: true })
59
+ const f = releaseFile(root, r.version)
60
+ atomicWrite(f, renderRelease(r))
61
+ return f
62
+ }
63
+
64
+ export const removeRelease = (root: string, version: string): void => rmSync(releaseFile(root, version), { force: true })
65
+
66
+ /** one change added to next, or put in place of the one of the same card (else of the same title in its category);
67
+ * next.md is made when there is none */
68
+ export function addChange(root: string, category: string, change: Change): { release: Release; file: string } {
69
+ const release = upsertChange(readRelease(root, NEXT) ?? emptyRelease(), category, change)
70
+ return { release, file: writeRelease(root, release) }
71
+ }
@@ -76,6 +76,11 @@ export type ServeConfig = {
76
76
  * media store (review cards, trailer cuts...), read only in the house
77
77
  * config; its key pair read through `credsReadCommand` */
78
78
  mediaSpace?: import('./media-store/space.ts').MediaSpace
79
+ /** folders on external drives for the machine's heavy files, never a db,
80
+ * in order, read only in the house config: the purge moves media there,
81
+ * `sk annex offload` moves scratch there behind a symlink. Present only
82
+ * while `sk annex init` marked the root (wiki tools/shipkit/annex.md) */
83
+ annexes?: import('./annex/annex.ts').AnnexSpec[]
79
84
  /** the secret whose value is a Cloudflare API token, read through
80
85
  * `credsReadCommand`, only in the house config: the site desk asks Pages
81
86
  * for a site's last production deployment with it */
@@ -10,7 +10,6 @@ import {
10
10
  moveOf,
11
11
  partyOf,
12
12
  reworkOf,
13
- isPostSubject,
14
13
  stateOf,
15
14
  STATUS_LABEL,
16
15
  thumbFileOf,
@@ -139,8 +138,6 @@ export interface ThreadView {
139
138
  /** the media files a view names that the store no longer holds, `<item id>/<name>`: the page says so in place of a
140
139
  * broken player (the routes fill it, the model never reads the disk) */
141
140
  missing: string[]
142
- /** the posts he asked from this card (« 📣 post »), oldest first, each with where it stands */
143
- posts: { id: string; state: ItemState }[]
144
141
  /** the social drafts naming this card in their `review:`, oldest first (the routes fill it, the model never reads the disk) */
145
142
  drafts: { slug: string; title: string }[]
146
143
  cells: Cell[]
@@ -305,13 +302,6 @@ export function threadOfId(id: string, threads: readonly Thread[]): Thread | nul
305
302
  return holding.sort((a, b) => b.head.item.created.localeCompare(a.head.item.created))[0] ?? null
306
303
  }
307
304
 
308
- /** the post requests naming one of these items as their card */
309
- const postsOf = (ids: ReadonlySet<string>, items: readonly ReviewItem[], followed: ReadonlySet<string>): ThreadView['posts'] =>
310
- items
311
- .filter((x) => isPostSubject(x.item.subject) && ids.has(x.item.subject.card))
312
- .sort((a, b) => a.item.created.localeCompare(b.item.created))
313
- .map((x) => ({ id: x.item.id, state: stateOf(x, followed.has(x.item.id)) }))
314
-
315
305
  /** one thread for the per card api; `asked` the id the caller named (an old version opens at its cell) */
316
306
  export function threadView(t: Thread, items: readonly ReviewItem[], threads: readonly Thread[], asked: string, now = new Date()): ThreadView {
317
307
  const h = t.head
@@ -342,7 +332,6 @@ export function threadView(t: Thread, items: readonly ReviewItem[], threads: rea
342
332
  .filter((x) => unreadBy(x, 'owner').length > 0)
343
333
  .map((x) => x.item.id),
344
334
  missing: [],
345
- posts: postsOf(new Set(idsOf(t)), items, followed),
346
335
  drafts: [],
347
336
  cells: cellsOf(t, items),
348
337
  }
@@ -14,8 +14,10 @@ const PLAIN: Say = { spec: NO_SPEC, more: () => [] }
14
14
 
15
15
  const flat = (t: string): string => t.replace(/\s+/g, ' ').trim()
16
16
 
17
- /** a rectangle's clip time, ` at 1.25 s`; nothing on an image */
18
- const atText = (t: number | undefined): string => (t === undefined ? '' : ` at ${t.toFixed(2)} s`)
17
+ /** a rectangle's clip time, ` at 1.25 s`, and on a trailer card's frame its shot, ` (shot dress +1.20 s)`; nothing on
18
+ * an image */
19
+ const atText = (t: number | undefined, shot?: Rect['shot']): string =>
20
+ (t === undefined ? '' : ` at ${t.toFixed(2)} s`) + (shot ? ` (shot ${shot.name} +${shot.time.toFixed(2)} s)` : '')
19
21
 
20
22
  /** each reaction to one view or tile: its place by label, its status, its comment */
21
23
  const reactionTexts = (x: ReviewItem): string[] =>
@@ -33,7 +35,7 @@ export function line(x: ReviewItem): string {
33
35
  if (!f) return x.item.id
34
36
  const views = x.item.views
35
37
  const many = views.length > 1
36
- const rects = f.rects.map((q, i) => `#${i + 1}${many || q.tile !== undefined ? ` ${placeText(q, views)}` : ''}${q.side ? ` ${q.side}` : ''}${atText(q.t)} ${flat(q.comment) || '(no comment)'}`)
38
+ const rects = f.rects.map((q, i) => `#${i + 1}${many || q.tile !== undefined ? ` ${placeText(q, views)}` : ''}${q.side ? ` ${q.side}` : ''}${atText(q.t, q.shot)} ${flat(q.comment) || '(no comment)'}`)
37
39
  const pick = pickText(x)
38
40
  const parts = [...(pick ? [pick] : []), ...reactionTexts(x), ...rects]
39
41
  return `${x.item.id} ${f.status} "${x.item.title}": ${flat(f.comment) || '(no overall comment)'}${parts.length ? ` | ${parts.join(' | ')}` : ''}`
@@ -145,12 +147,14 @@ export function detail(x: ReviewItem, dir: string, full = false, followed = fals
145
147
  const views = r.views
146
148
  f.rects.forEach((q, i) => {
147
149
  const v = views[q.view ?? 0] ?? views[0]
148
- const size = v && !isGallery(v) ? v.size : { w: 0, h: 0 }
150
+ // a trailer card's rectangles sit on the cut's frame, not on the strip its view keeps
151
+ const frame = (q.view ?? 0) === 0 ? r.trailer?.size : undefined
152
+ const size = frame ? { w: frame[0], h: frame[1] } : v && !isGallery(v) ? v.size : { w: 0, h: 0 }
149
153
  const on = views.length > 1 ? ` ${placeText(q, views)}` : ''
150
- const side = v && !isGallery(v) && isPair(v.files) ? ` ${q.side ?? '?'}` : ''
154
+ const side = (v && !isGallery(v) && isPair(v.files)) || q.side ? ` ${q.side ?? '?'}` : ''
151
155
  const norm = `${q.x.toFixed(3)},${q.y.toFixed(3)} ${q.w.toFixed(3)}x${q.h.toFixed(3)}`
152
156
  const pix = `${px(q.x, size.w)},${px(q.y, size.h)} ${px(q.w, size.w)}x${px(q.h, size.h)} px`
153
- out.push(` #${i + 1}${on}${side} ${norm} (${pix})${atText(q.t)}: ${q.comment || '(no comment)'}`)
157
+ out.push(` #${i + 1}${on}${side} ${norm} (${pix})${atText(q.t, q.shot)}: ${q.comment || '(no comment)'}`)
154
158
  })
155
159
  const files = views.flatMap((v) => (isGallery(v) ? v.gallery.map((t) => t.file) : Object.values(v.files)))
156
160
  out.push(` files: ${files.map((n) => `${dir}/${r.id}/${n}`).join(' ')}`, ...replies)
@@ -2,7 +2,7 @@
2
2
  // answer under its ETag, a file with byte ranges
3
3
  import { extname } from 'node:path'
4
4
 
5
- export const TYPES: Record<string, string> = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.svg': 'image/svg+xml', '.webm': 'video/webm', '.mp4': 'video/mp4', '.ico': 'image/x-icon' }
5
+ export const TYPES: Record<string, string> = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.svg': 'image/svg+xml', '.webm': 'video/webm', '.mp4': 'video/mp4', '.ico': 'image/x-icon', '.wav': 'audio/wav', '.m4a': 'audio/mp4' }
6
6
  export const NO_STORE = { 'Cache-Control': 'no-store' }
7
7
  /** an item's files never change once written, nor a kept render under its version: a phone keeps what it fetched */
8
8
  export const KEEP = { 'Cache-Control': 'private, max-age=86400' }