rvlib-shipkit 2.18.0 → 2.20.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.
- package/CHANGELOG.md +31 -0
- package/package.json +1 -1
- package/src/annex/annex.ts +227 -0
- package/src/annex/offload.ts +279 -0
- package/src/asks/asks-queue.ts +63 -10
- package/src/checks/SK040-release-words.check.ts +43 -0
- package/src/checks/SK041-annex-links.check.ts +28 -0
- package/src/checks/SK042-post-kinds.check.ts +73 -0
- package/src/cli/cmd_Annex.ts +179 -0
- package/src/cli/cmd_Asks.ts +3 -1
- package/src/cli/cmd_Commands.ts +4 -1
- package/src/cli/cmd_GlobalProcesses.ts +34 -11
- package/src/cli/cmd_Home.ts +41 -4
- package/src/cli/cmd_Messages.ts +155 -0
- package/src/cli/cmd_Releases.ts +48 -0
- package/src/cli/cmd_Review.ts +161 -6
- package/src/cli/cmd_Secret.ts +4 -30
- package/src/cli/cmd_Shot.ts +4 -4
- package/src/cli/cmd_Social.ts +179 -3
- package/src/cli/cmd_Trailer.ts +15 -3
- package/src/cli/family-pages.ts +2 -0
- package/src/cli/kit/index.ts +1 -1
- package/src/cli/kit/verb.ts +11 -3
- package/src/cli/registry.ts +8 -2
- package/src/collections/actions.ts +29 -1
- package/src/collections/collection-types.ts +10 -1
- package/src/collections/providers.ts +5 -2
- package/src/commands/model.ts +36 -0
- package/src/commands/registry.ts +49 -0
- package/src/commands/routes.ts +59 -0
- package/src/commands/runner.ts +35 -0
- package/src/commands/runs.ts +112 -0
- package/src/core/app-icon.ts +4 -3
- package/src/core/icon-type.ts +8 -0
- package/src/core/jobs.ts +4 -3
- package/src/core/layout.ts +5 -2
- package/src/core/squircle.ts +95 -0
- package/src/home/daemon-jobs.ts +26 -2
- package/src/home/global-units.ts +3 -0
- package/src/home/gui-app/ShipkitGui.swift +302 -5
- package/src/home/gui-app.ts +63 -33
- package/src/home/hmr-keep.ts +134 -0
- package/src/home/home-paths.ts +5 -1
- package/src/home/home-start.ts +14 -14
- package/src/home/lib-watch.ts +21 -11
- package/src/home/pm.ts +1 -1
- package/src/home/process-apps.ts +181 -0
- package/src/home/resources.ts +3 -3
- package/src/home/run-daemon.ts +11 -2
- package/src/home/run-pm.ts +9 -1
- package/src/home/run-web.ts +7 -4
- package/src/home/serve-web.ts +64 -14
- package/src/home/supervise.ts +3 -1
- package/src/identities/collection.ts +49 -0
- package/src/identities/identities.ts +130 -11
- package/src/identities/machine.ts +4 -3
- package/src/identities/rating.ts +33 -0
- package/src/identities/shown.ts +170 -0
- package/src/identities/steps.ts +5 -0
- package/src/media-store/purge.ts +15 -1
- package/src/media-store/remote.ts +22 -6
- package/src/messages/brief.ts +117 -0
- package/src/messages/collection.ts +40 -0
- package/src/messages/model.ts +171 -0
- package/src/messages/routes.ts +15 -0
- package/src/messages/score.ts +180 -0
- package/src/messages/tabs.ts +13 -0
- package/src/release/notes.ts +130 -0
- package/src/release/run-bump.ts +41 -18
- package/src/release/run-release.ts +22 -4
- package/src/release/run-releases.ts +17 -15
- package/src/release/unit-resolve.ts +9 -0
- package/src/releases/add.ts +66 -0
- package/src/releases/collection.ts +36 -0
- package/src/releases/from-card.ts +66 -0
- package/src/releases/model.ts +267 -0
- package/src/releases/pictures.ts +89 -0
- package/src/releases/routes.ts +36 -0
- package/src/releases/store.ts +71 -0
- package/src/repo-config.ts +5 -0
- package/src/review/cells.ts +0 -11
- package/src/review/format.ts +10 -6
- package/src/review/http.ts +7 -2
- package/src/review/model.ts +92 -3
- package/src/review/notes.ts +2 -48
- package/src/review/routes.ts +28 -10
- package/src/review/stage-card.ts +197 -0
- package/src/review/stage-routes.ts +123 -0
- package/src/review/store.ts +117 -19
- package/src/review/trailer-card.ts +99 -0
- package/src/review/trailer-desk.ts +57 -4
- package/src/review/trailer-model.ts +41 -7
- package/src/review/trailer-notes.ts +45 -0
- package/src/review/trailer-routes.ts +22 -13
- package/src/secrets/manager.ts +59 -0
- package/src/secrets/name.ts +2 -0
- package/src/serve/hub-app/app-bridge.ts +71 -0
- package/src/serve/hub-app/col-card.tsx +10 -0
- package/src/serve/hub-app/cols-svc.ts +37 -6
- package/src/serve/hub-app/commands/commands-page.tsx +122 -0
- package/src/serve/hub-app/commands/commands-st.ts +177 -0
- package/src/serve/hub-app/commands.css +24 -0
- package/src/serve/hub-app/hash-route.ts +40 -1
- package/src/serve/hub-app/home-st.ts +11 -2
- package/src/serve/hub-app/home.html +3 -0
- package/src/serve/hub-app/hub-app.tsx +6 -0
- package/src/serve/hub-app/hub.css +1 -0
- package/src/serve/hub-app/icons.tsx +5 -0
- package/src/serve/hub-app/identities-view.tsx +4 -1
- package/src/serve/hub-app/identities.css +1 -0
- package/src/serve/hub-app/index.html +3 -0
- package/src/serve/hub-app/keys.ts +2 -2
- package/src/serve/hub-app/machine-st.ts +41 -10
- package/src/serve/hub-app/messages/messages-page.tsx +354 -0
- package/src/serve/hub-app/messages/messages-st.ts +74 -0
- package/src/serve/hub-app/messages.css +35 -0
- package/src/serve/hub-app/releases/releases-page.tsx +94 -0
- package/src/serve/hub-app/releases/releases-st.ts +69 -0
- package/src/serve/hub-app/releases.css +25 -0
- package/src/serve/hub-app/repo-sections.ts +15 -1
- package/src/serve/hub-app/repo-st.ts +56 -5
- package/src/serve/hub-app/review/clip-st.ts +31 -3
- package/src/serve/hub-app/review/note-place.ts +31 -0
- package/src/serve/hub-app/review/review-cells.tsx +27 -3
- package/src/serve/hub-app/review/review-st.ts +77 -2
- package/src/serve/hub-app/review/review-thread.tsx +9 -31
- package/src/serve/hub-app/review/review-views.tsx +164 -58
- package/src/serve/hub-app/review/thread-st.ts +108 -41
- package/src/serve/hub-app/review/trailer-card.tsx +187 -0
- package/src/serve/hub-app/review/trailer-page.tsx +62 -31
- package/src/serve/hub-app/review/trailer-st.ts +138 -26
- package/src/serve/hub-app/review/trailer-timeline.tsx +39 -26
- package/src/serve/hub-app/review.css +49 -6
- package/src/serve/hub-app/social/comms-page.tsx +55 -23
- package/src/serve/hub-app/social/identity-pictures.ts +112 -0
- package/src/serve/hub-app/social/kit.tsx +9 -6
- package/src/serve/hub-app/social/post-card.tsx +10 -2
- package/src/serve/hub-app/social/social-model.ts +37 -3
- package/src/serve/hub-app/social/social-page.tsx +236 -82
- package/src/serve/hub-app/social/social-st.ts +79 -26
- package/src/serve/hub-app/social/stage-popup.tsx +268 -0
- package/src/serve/hub-app/social/stage-st.ts +310 -0
- package/src/serve/hub-app/social/step-layout.ts +42 -0
- package/src/serve/hub-app/social.css +68 -4
- package/src/serve/hub-app/tree-build.ts +38 -1
- package/src/serve/hub-app/tree-svc.ts +10 -3
- package/src/serve/project-gutter-route.ts +4 -2
- package/src/serve/same-origin.ts +24 -1
- package/src/serve/serve-hub.ts +27 -3
- package/src/shipkit-files.ts +9 -7
- package/src/shot/shooter.ts +3 -3
- package/src/shot/shot-ask.ts +14 -3
- package/src/shot/shot.shipkit.ts +1 -1
- package/src/social/discord-layout.ts +282 -0
- package/src/social/fit.ts +84 -0
- package/src/social/identity-words.ts +74 -0
- package/src/social/kind-pages.ts +41 -0
- package/src/social/kinds.ts +92 -0
- package/src/social/load.ts +105 -9
- package/src/social/md.ts +14 -6
- package/src/social/media-limit.ts +63 -2
- package/src/social/presence.ts +1 -1
- package/src/social/publish/bluesky.ts +58 -19
- package/src/social/publish/discord.ts +3 -2
- package/src/social/publish/index.ts +31 -5
- package/src/social/reach.ts +49 -0
- package/src/social/release-stage.ts +173 -0
- package/src/social/routes.ts +44 -9
- package/src/social/stage.ts +227 -0
- package/src/social/strip.ts +85 -0
- package/src/social/text.ts +6 -2
- package/src/social/unit.ts +57 -1
- package/src/social/writes.ts +11 -0
- package/src/stores/routes.ts +2 -2
- package/src/suite/judge-suites.ts +1 -1
- package/src/suite/suite-cli.ts +5 -5
- package/src/trailer/build.ts +90 -52
- package/src/trailer/draft.ts +28 -0
- package/src/trailer/footage.ts +4 -2
- package/src/trailer/grammar.ts +25 -13
- package/src/trailer/graph.ts +32 -9
- package/src/trailer/profile.ts +35 -0
- package/src/trailer/prune.ts +15 -10
- package/src/trailer/public-words.ts +41 -0
- package/src/trailer/stitch.ts +22 -10
- package/src/trailer/titles.ts +47 -2
|
@@ -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
|
+
}
|
package/src/repo-config.ts
CHANGED
|
@@ -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 */
|
package/src/review/cells.ts
CHANGED
|
@@ -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
|
}
|
package/src/review/format.ts
CHANGED
|
@@ -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
|
|
18
|
-
|
|
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
|
-
|
|
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)
|
package/src/review/http.ts
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
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', '.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' }
|
|
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' }
|
|
9
|
+
/** a file rebuilt in place under its name (an identity's picture, a store's asset): the page asks each time, and a
|
|
10
|
+
* 304 answers while its size and mtime hold */
|
|
11
|
+
export const FRESH = { 'Cache-Control': 'no-cache' }
|
|
9
12
|
|
|
10
13
|
/** a json answer under its ETag: 304 when the page holds it, gzipped when the page takes it and it is worth it. A
|
|
11
14
|
* caller that keeps the answer passes `held`, the zip made once for every page that asks the same tag */
|
|
@@ -27,7 +30,9 @@ export async function ranged(req: Request, path: string, headers: Record<string,
|
|
|
27
30
|
const file = Bun.file(path)
|
|
28
31
|
if (!(await file.exists())) return bad(`no ${path.split('/').pop()}`, 404)
|
|
29
32
|
const size = file.size
|
|
30
|
-
const
|
|
33
|
+
const tag = headers === FRESH ? `"${size.toString(36)}-${Math.round(file.lastModified).toString(36)}"` : null
|
|
34
|
+
if (tag && req.headers.get('If-None-Match') === tag) return new Response(null, { status: 304, headers: { ...FRESH, ETag: tag } })
|
|
35
|
+
const head = { 'Content-Type': TYPES[extname(path).toLowerCase()] ?? 'application/octet-stream', 'Accept-Ranges': 'bytes', ...headers, ...(tag ? { ETag: tag } : {}) }
|
|
31
36
|
const range = /^bytes=(\d*)-(\d*)$/.exec(req.headers.get('range') ?? '')
|
|
32
37
|
if (!range) return new Response(file, { headers: { ...head, 'Content-Length': String(size) } })
|
|
33
38
|
const start = range[1] ? Number(range[1]) : Math.max(0, size - Number(range[2]))
|
package/src/review/model.ts
CHANGED
|
@@ -74,7 +74,7 @@ export interface Spec {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/** the kinds every repo has, whatever its unit declares */
|
|
77
|
-
export const BUILTIN_KINDS: Record<string, SpecKind> = { shot: { label: 'images' }, screen: { label: 'screens' }, frame: { label: 'trailer frames' }, store: { label: 'store pages', icon: '🏪' }, post: { label: 'post requests', icon: '📣' } }
|
|
77
|
+
export const BUILTIN_KINDS: Record<string, SpecKind> = { shot: { label: 'images' }, screen: { label: 'screens' }, frame: { label: 'trailer frames' }, trailer: { label: 'trailers', icon: '🎬' }, store: { label: 'store pages', icon: '🏪' }, post: { label: 'post requests', icon: '📣' } }
|
|
78
78
|
|
|
79
79
|
export const NO_SPEC: Spec = { kinds: {}, topics: {}, dispatcher: false }
|
|
80
80
|
|
|
@@ -175,6 +175,19 @@ export const isGallery = (v: ReviewView): v is GalleryView => 'gallery' in v
|
|
|
175
175
|
|
|
176
176
|
export const SHA_RE = /^[0-9a-f]{64}$/
|
|
177
177
|
|
|
178
|
+
/** a card's public change: the release category it goes under and its one line, the `### ` title */
|
|
179
|
+
export interface CardChangelog {
|
|
180
|
+
category: string
|
|
181
|
+
line: string
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** `--changelog "<category>: <line>"` read; a line with no category throws saying the shape */
|
|
185
|
+
export function changelogOfFlag(s: string): CardChangelog {
|
|
186
|
+
const m = /^([^:]+):\s*(.+)$/.exec(s.trim())
|
|
187
|
+
if (!m || m[1]!.trim() === '' || m[2]!.trim() === '') throw new Error(`--changelog "${s}": "<category>: <public line>", like "Studio: Move the body anywhere on the floor"`)
|
|
188
|
+
return { category: m[1]!.trim(), line: m[2]!.trim() }
|
|
189
|
+
}
|
|
190
|
+
|
|
178
191
|
/** `item.json`: the head, written at creation, changed by `add-view`, a draft's refresh and the media facts it lacks */
|
|
179
192
|
export interface Item {
|
|
180
193
|
id: string
|
|
@@ -185,6 +198,11 @@ export interface Item {
|
|
|
185
198
|
title: string
|
|
186
199
|
/** an agent card's markdown: what changed and why */
|
|
187
200
|
what?: string
|
|
201
|
+
/** the public line its agent wrote for a post of it (`--post`), checked by the repo's guard at add */
|
|
202
|
+
post?: string
|
|
203
|
+
/** the change its approval adds to the release being filled (`--changelog "<category>: <line>"`, releases/from-card.ts),
|
|
204
|
+
* checked by the repo's guard at add */
|
|
205
|
+
changelog?: CardChangelog
|
|
188
206
|
topic?: string
|
|
189
207
|
commit?: string
|
|
190
208
|
/** a media view (an image, a clip, a sound, a pair) or a gallery of images, any of them first */
|
|
@@ -202,10 +220,33 @@ export interface Item {
|
|
|
202
220
|
wip?: { live: string; frame: number }
|
|
203
221
|
/** a choice: every view is an option, he scores them and picks one */
|
|
204
222
|
choice?: true
|
|
223
|
+
/** on a choice: the option its agent suggests, the view's index (the hub's « my pick » pill); his own pick is the verdict's */
|
|
224
|
+
agentPick?: number
|
|
225
|
+
/** a trailer card: its body plays this cut in the trailer entry's player, never a compiled clip */
|
|
226
|
+
trailer?: TrailerCard
|
|
205
227
|
/** each media file the views name, by its name: what the Space keeps it under once the disk lets it go */
|
|
206
228
|
media?: Record<string, MediaFact>
|
|
207
229
|
}
|
|
208
230
|
|
|
231
|
+
/** one render a trailer card plays: the cut, and the render pinned by its mtime in ms */
|
|
232
|
+
export interface TrailerSide {
|
|
233
|
+
cut: string
|
|
234
|
+
render: number
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** what a trailer card plays (wiki tools/shipkit/review.md, A trailer): a cut of `trailer/<trailer>/`, the render it is
|
|
238
|
+
* compared with, the shots the change touched by name */
|
|
239
|
+
export interface TrailerCard {
|
|
240
|
+
trailer: string
|
|
241
|
+
after: TrailerSide
|
|
242
|
+
before?: TrailerSide
|
|
243
|
+
shots: string[]
|
|
244
|
+
/** the cut's frame in pixels: what his rectangles on it measure in */
|
|
245
|
+
size?: [number, number]
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export const isTrailerCard = (i: Item): i is Item & { trailer: TrailerCard } => i.trailer !== undefined
|
|
249
|
+
|
|
209
250
|
/** a choice card: he picks one of its views */
|
|
210
251
|
export const isChoice = (i: Item): boolean => i.choice === true
|
|
211
252
|
|
|
@@ -256,6 +297,16 @@ export const viewTag = (n: number, i: number): string => `${n}.${viewLetter(i)}`
|
|
|
256
297
|
/** a view's name as the page and the CLI show it: its label, or « view B » */
|
|
257
298
|
export const viewName = (v: ReviewView | undefined, i: number): string => v?.label || `view ${viewLetter(i)}`
|
|
258
299
|
|
|
300
|
+
/** a view named by its label, else by its letter (`B`); throws naming every view when none matches */
|
|
301
|
+
export function viewIndexOf(views: readonly { label: string }[], ref: string): number {
|
|
302
|
+
const r = ref.trim()
|
|
303
|
+
const byLabel = views.findIndex((v) => v.label === r)
|
|
304
|
+
if (r !== '' && byLabel >= 0) return byLabel
|
|
305
|
+
const byLetter = views.findIndex((_, i) => viewLetter(i) === r.toUpperCase())
|
|
306
|
+
if (r !== '' && byLetter >= 0) return byLetter
|
|
307
|
+
throw new Error(`« ${ref} » names no view: ${views.map((v, i) => `${viewLetter(i)}${v.label ? ` "${v.label}"` : ''}`).join(', ')}`)
|
|
308
|
+
}
|
|
309
|
+
|
|
259
310
|
/** every media file a card's views name: images, pairs, clips and their posters, sounds and their waveforms, tiles */
|
|
260
311
|
export function viewFilesOf(i: Item): string[] {
|
|
261
312
|
return i.views.flatMap((v) => {
|
|
@@ -282,7 +333,8 @@ export const onFrame = (t: number, time: number, fps: number): boolean => Math.f
|
|
|
282
333
|
export type Side = 'before' | 'after'
|
|
283
334
|
|
|
284
335
|
/** a rectangle on a view, normalized 0..1; w = h = 0 is a pin. `view` the index of its view, absent on the first;
|
|
285
|
-
* `side` only on a pair; `t` only on a clip
|
|
336
|
+
* `side` only on a pair (on a trailer card with a before, the render it is drawn on); `t` only on a clip or a trailer
|
|
337
|
+
* card's frame */
|
|
286
338
|
export interface Rect {
|
|
287
339
|
x: number
|
|
288
340
|
y: number
|
|
@@ -293,6 +345,8 @@ export interface Rect {
|
|
|
293
345
|
side?: Side
|
|
294
346
|
/** the clip time it was drawn at, in seconds */
|
|
295
347
|
t?: number
|
|
348
|
+
/** on a trailer card's frame: the shot it sits on and the seconds into it, so a new render places it */
|
|
349
|
+
shot?: { name: string; time: number }
|
|
296
350
|
/** the gallery tile it is drawn on, its coordinates the tile's image */
|
|
297
351
|
tile?: number
|
|
298
352
|
world?: { x0: number; y0: number; x1: number; y1: number }
|
|
@@ -783,6 +837,16 @@ function originProblems(o: unknown): string[] {
|
|
|
783
837
|
return ['origin.by: agent, owner, player or auto']
|
|
784
838
|
}
|
|
785
839
|
|
|
840
|
+
function trailerCardProblems(t: unknown): string[] {
|
|
841
|
+
const side = (v: unknown): boolean => obj(v) && typeof v.cut === 'string' && v.cut !== '' && typeof v.render === 'number' && Number.isFinite(v.render)
|
|
842
|
+
if (!obj(t) || typeof t.trailer !== 'string' || t.trailer === '' || !side(t.after)) return ['trailer: { trailer, after: { cut, render }, before?, shots }']
|
|
843
|
+
const out: string[] = []
|
|
844
|
+
if (t.before !== undefined && !side(t.before)) out.push('trailer.before: { cut, render }, or absent')
|
|
845
|
+
if (!Array.isArray(t.shots) || !t.shots.every((s) => typeof s === 'string' && s !== '')) out.push('trailer.shots: a list of shot names')
|
|
846
|
+
if (t.size !== undefined && !(Array.isArray(t.size) && t.size.length === 2 && t.size.every((n) => Number.isInteger(n) && (n as number) > 0))) out.push('trailer.size: [width, height] in pixels, or absent')
|
|
847
|
+
return out
|
|
848
|
+
}
|
|
849
|
+
|
|
786
850
|
/** every reason an item.json read back is not an item; empty: it is one */
|
|
787
851
|
export function itemProblems(v: unknown): string[] {
|
|
788
852
|
if (!obj(v)) return ['not an object']
|
|
@@ -801,10 +865,15 @@ export function itemProblems(v: unknown): string[] {
|
|
|
801
865
|
})
|
|
802
866
|
if (v.answers !== undefined && !(Array.isArray(v.answers) && v.answers.length > 0 && v.answers.every((a) => typeof a === 'string' && ID_RE.test(a))))
|
|
803
867
|
out.push('answers: a list of item ids')
|
|
804
|
-
for (const k of ['what', 'commit', 'supersedes', 'why', 'keeps']) if (v[k] !== undefined && typeof v[k] !== 'string') out.push(`${k}: a text`)
|
|
868
|
+
for (const k of ['what', 'post', 'commit', 'supersedes', 'why', 'keeps']) if (v[k] !== undefined && typeof v[k] !== 'string') out.push(`${k}: a text`)
|
|
869
|
+
if (v.changelog !== undefined && !(obj(v.changelog) && typeof v.changelog.category === 'string' && v.changelog.category.trim() !== '' && typeof v.changelog.line === 'string' && v.changelog.line.trim() !== ''))
|
|
870
|
+
out.push('changelog: { category, line }, or absent')
|
|
805
871
|
if (v.light !== undefined && v.light !== 'review') out.push('light: review, or absent')
|
|
806
872
|
if (v.wip !== undefined && !(obj(v.wip) && typeof v.wip.live === 'string' && v.wip.live !== '' && Number.isInteger(v.wip.frame))) out.push('wip: { live, frame }, or absent')
|
|
873
|
+
if (v.trailer !== undefined) out.push(...trailerCardProblems(v.trailer))
|
|
807
874
|
if (v.choice !== undefined && !(v.choice === true && Array.isArray(v.views) && v.views.length >= 2)) out.push('choice: true on a card of two views or more, or absent')
|
|
875
|
+
if (v.agentPick !== undefined && !(v.choice === true && Number.isInteger(v.agentPick) && Array.isArray(v.views) && (v.agentPick as number) >= 0 && (v.agentPick as number) < v.views.length))
|
|
876
|
+
out.push('agentPick: the index of one of its views, on a choice card, or absent')
|
|
808
877
|
if (v.media !== undefined) {
|
|
809
878
|
if (!obj(v.media)) out.push('media: { <file name>: { sha, size, type } }, or absent')
|
|
810
879
|
else
|
|
@@ -896,6 +965,21 @@ function viewProblems(v: Record<string, unknown>, at: string): string[] {
|
|
|
896
965
|
}
|
|
897
966
|
|
|
898
967
|
/** the verdict the page sends for an item, checked: every rectangle inside its view, a side exactly on a pair */
|
|
968
|
+
/** what a rectangle on a trailer card's frame carries beyond its box: the time on the cut it was drawn at, the shot and
|
|
969
|
+
* the seconds into it, and with a before the render it sits on; null with its errors pushed */
|
|
970
|
+
function trailerRect(r: Record<string, unknown>, t: TrailerCard, i: number, errors: string[]): Pick<Rect, 't' | 'shot' | 'side'> | null {
|
|
971
|
+
const at = r.t
|
|
972
|
+
const shot = r.shot as { name?: unknown; time?: unknown } | undefined
|
|
973
|
+
const bad: string[] = []
|
|
974
|
+
if (typeof at !== 'number' || !Number.isFinite(at) || at < 0) bad.push(`rects[${i}].t: the time on the cut it was drawn at`)
|
|
975
|
+
if (!obj(shot) || typeof shot.name !== 'string' || shot.name === '' || typeof shot.time !== 'number' || !Number.isFinite(shot.time) || shot.time < 0)
|
|
976
|
+
bad.push(`rects[${i}].shot: { name, time }, the shot it sits on and the seconds into it`)
|
|
977
|
+
if (t.before ? r.side !== 'before' && r.side !== 'after' : r.side !== undefined) bad.push(`rects[${i}].side: ${t.before ? 'before or after, the render it is drawn on' : 'none on a trailer card with no before'}`)
|
|
978
|
+
errors.push(...bad)
|
|
979
|
+
if (bad.length > 0 || !obj(shot)) return null
|
|
980
|
+
return { t: at as number, shot: { name: shot.name as string, time: shot.time as number }, ...(t.before ? { side: r.side as Side } : {}) }
|
|
981
|
+
}
|
|
982
|
+
|
|
899
983
|
export function verdictMessageOf(body: unknown, item: Item): { ok: true; message: Pick<Message, 'verdict' | 'text' | 'rects' | 'reactions' | 'pick'> } | { ok: false; errors: string[] } {
|
|
900
984
|
if (!obj(body)) return { ok: false, errors: ['not an object'] }
|
|
901
985
|
const errors: string[] = []
|
|
@@ -932,6 +1016,11 @@ export function verdictMessageOf(body: unknown, item: Item): { ok: true; message
|
|
|
932
1016
|
errors.push(`rects[${i}].view: no rectangle on a sound, react to the view instead`)
|
|
933
1017
|
continue
|
|
934
1018
|
}
|
|
1019
|
+
if (view === 0 && isTrailerCard(item)) {
|
|
1020
|
+
const r2 = trailerRect(r, item.trailer, i, errors)
|
|
1021
|
+
if (r2) out.push({ x: r.x, y: r.y, w: r.w, h: r.h, comment: typeof r.comment === 'string' ? r.comment : '', ...r2 })
|
|
1022
|
+
continue
|
|
1023
|
+
}
|
|
935
1024
|
const pair = isPair(on.files)
|
|
936
1025
|
if (pair && r.side !== 'before' && r.side !== 'after') errors.push(`rects[${i}].side: before or after, on a pair`)
|
|
937
1026
|
if (!pair && r.side !== undefined) errors.push(`rects[${i}].side: none on a single image`)
|
package/src/review/notes.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// his notes on one thing a desk shows (a store page's picture or field, a draft): the first an item of the one store,
|
|
2
2
|
// its subject the thing, so the review page and `sk review inbox` hold it; the next ones, while that thread is open,
|
|
3
3
|
// his replies on it, never a second item. The one path for a note on a thing (wiki tools/shipkit/stores.md)
|
|
4
|
-
import {
|
|
5
|
-
import { isPostSubject, stateOf, subjectKey, type Origin, type PostSubject, type ReviewItem, type Subject } from './model.ts'
|
|
4
|
+
import { stateOf, subjectKey, type Origin, type ReviewItem, type Subject } from './model.ts'
|
|
6
5
|
import { addMessage, raiseItem, readAll, specOf } from './store.ts'
|
|
7
|
-
import {
|
|
6
|
+
import { membersOf, threadsOf, type Thread } from './threads.ts'
|
|
8
7
|
|
|
9
8
|
/** one note as a desk shows it: the owner's words, where it stands, the agent's last word once answered */
|
|
10
9
|
export type SubjectNote = { id: string; at: string; text: string; state: string; answer?: string }
|
|
@@ -78,48 +77,3 @@ export async function noteOn(
|
|
|
78
77
|
return { id: x.item.id }
|
|
79
78
|
}
|
|
80
79
|
|
|
81
|
-
/** a post the owner asked from a card and no draft answers yet: what Communications lists on top of its drafts */
|
|
82
|
-
export type AskedPost = { id: string; at: string; card: string; title: string; text: string; state: string }
|
|
83
|
-
|
|
84
|
-
/** every post request not closed, oldest first: the card's title as it is now, the owner's words joined */
|
|
85
|
-
export function askedPosts(items: readonly ReviewItem[]): AskedPost[] {
|
|
86
|
-
const threads = threadsOf(items)
|
|
87
|
-
const followed = followedIds(items)
|
|
88
|
-
return items
|
|
89
|
-
.filter((x) => isPostSubject(x.item.subject))
|
|
90
|
-
.map((x) => ({ x, st: stateOf(x, followed.has(x.item.id)) }))
|
|
91
|
-
.filter(({ st }) => st.state !== 'closed')
|
|
92
|
-
.sort((a, b) => a.x.item.created.localeCompare(b.x.item.created))
|
|
93
|
-
.map(({ x, st }) => {
|
|
94
|
-
const card = (x.item.subject as PostSubject).card
|
|
95
|
-
const t = threadOfId(card, threads)
|
|
96
|
-
const words = x.thread.filter((m) => m.who === 'owner' && m.op === undefined && m.verdict === undefined && m.text !== undefined).map((m) => m.text as string)
|
|
97
|
-
return { id: x.item.id, at: x.item.created, card: t?.head.item.id ?? card, title: t?.head.item.title ?? card, text: words.join('\n'), state: st.state }
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** « 📣 post » on a card: a request for its own public post, keyed on the card's first version so every version asks
|
|
102
|
-
* the same one; `topic` the social unit's notes topic, left out where the store's topics lack it */
|
|
103
|
-
export async function askPost(dir: string, o: { card: string; text?: string; topic?: string }): Promise<{ id: string }> {
|
|
104
|
-
const t = threadOfId(o.card, threadsOf(readAll(dir).items))
|
|
105
|
-
if (!t) throw new Error(`post: no card ${o.card}`)
|
|
106
|
-
const head = t.head.item
|
|
107
|
-
if (isPostSubject(head.subject)) throw new Error('post: this card is itself a post request')
|
|
108
|
-
const first = t.versions.at(-1)?.item.id ?? head.id
|
|
109
|
-
const spec = specOf(dir)
|
|
110
|
-
const topic = o.topic !== undefined && (Object.keys(spec.topics).length === 0 || spec.topics[o.topic]) ? o.topic : undefined
|
|
111
|
-
const subject: PostSubject = { kind: 'post', card: first }
|
|
112
|
-
return noteOn(dir, {
|
|
113
|
-
subject,
|
|
114
|
-
origin: { by: 'owner', from: 'review' },
|
|
115
|
-
name: `post « ${head.title} »`,
|
|
116
|
-
text: o.text?.trim() || 'this card deserves its own post',
|
|
117
|
-
...(topic ? { topic } : {}),
|
|
118
|
-
what: [
|
|
119
|
-
`A public post from the card « ${head.title} » (${head.id}).`,
|
|
120
|
-
`- read the card: \`sk review show ${head.id}\`; its views are the post's media`,
|
|
121
|
-
`- write the draft: \`.shipkit/social/drafts/<YYYYMMDD-HHMMSS>-<topic>/draft.md\`, \`review: ${head.id}\` in its front matter, the media in its \`media/\` (wiki tools/shipkit/social.md)`,
|
|
122
|
-
'- close this request: `sk review fixed <this id> --note "draft <slug>"`',
|
|
123
|
-
].join('\n'),
|
|
124
|
-
})
|
|
125
|
-
}
|
package/src/review/routes.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// the hub's review routes (wiki tools/shipkit/review.md, The hub): the store's list, an item's images and clips, the
|
|
2
2
|
// owner's verdicts, replies and read marks appended to its thread. The trailer view's routes: trailer-routes.ts. Paths are
|
|
3
3
|
// relative to the repo hub's base. null: not a path of these
|
|
4
|
-
import { existsSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
|
4
|
+
import { existsSync, mkdtempSync, rmSync, statSync, writeFileSync } from 'node:fs'
|
|
5
5
|
import { tmpdir } from 'node:os'
|
|
6
6
|
import { dirname, extname, join } from 'node:path'
|
|
7
7
|
import { isAnimFormat, isAnimLabels, isAnimMode, pairAnimation } from './anim.ts'
|
|
8
8
|
import { startAuto } from './auto.ts'
|
|
9
9
|
import { bad, KEEP, NO_STORE, ranged, tagged, TYPES } from './http.ts'
|
|
10
10
|
import { viewFilesOf, type Rect, type ReviewItem, type Subject } from './model.ts'
|
|
11
|
-
import {
|
|
11
|
+
import { stageGet, stagePost } from './stage-routes.ts'
|
|
12
12
|
import { pasteHosts } from './paste.ts'
|
|
13
13
|
import { openReview, partFile, viewOfItem } from './project.ts'
|
|
14
14
|
import { isPreviewSize, previewOrRemote, warmPreviews } from './previews.ts'
|
|
@@ -23,8 +23,8 @@ import { trailerRoutes } from './trailer-routes.ts'
|
|
|
23
23
|
import { specData, type ReviewUnit } from './unit.ts'
|
|
24
24
|
import { liveWatchers } from './watchers.ts'
|
|
25
25
|
import { autoRulesOf } from '../veille/auto.ts'
|
|
26
|
-
import { loadSocialUnit } from '../social/unit.ts'
|
|
27
26
|
import { draftsOfCard } from '../social/card-drafts.ts'
|
|
27
|
+
import { draftsDir } from '../social/load.ts'
|
|
28
28
|
|
|
29
29
|
// ── each repo's review unit, read again at most every 5 s; its auto rules scheduled in this server while it serves ──
|
|
30
30
|
|
|
@@ -50,6 +50,19 @@ async function project(root: string): Promise<{ dir: string; unit: ReviewUnit |
|
|
|
50
50
|
return { dir, unit }
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
/** an approved card's changelog line into next.md (releases/from-card.ts), after the verdict answered: a failure says so
|
|
54
|
+
* on the card's thread and in the hub's log, so the change is never lost in silence */
|
|
55
|
+
async function changeOnVerdict(dir: string, id: string): Promise<void> {
|
|
56
|
+
try {
|
|
57
|
+
const { onVerdict } = await import('../releases/from-card.ts')
|
|
58
|
+
await onVerdict(dirname(dirname(dir)), id)
|
|
59
|
+
} catch (e) {
|
|
60
|
+
const why = (e as Error).message
|
|
61
|
+
console.error(`FAIL: the release did not take the change of ${id}: ${why}`)
|
|
62
|
+
addMessage(dir, id, 'releases', `the release did not take this change: ${why}. Run sk releases add --card ${id}`)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
53
66
|
/** an image the page sent as a data url, written to a scratch file the caller removes */
|
|
54
67
|
function dataUrlFile(url: unknown): { file: string; done(): void } | null {
|
|
55
68
|
if (url === undefined || url === null) return null
|
|
@@ -148,7 +161,9 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
148
161
|
}
|
|
149
162
|
const t = threadOfId(id, x.threads)
|
|
150
163
|
if (!t) return bad(`no item ${ref}`, 404)
|
|
151
|
-
|
|
164
|
+
// a draft staged from the card moves the drafts folder, not the store: its time joins the tag
|
|
165
|
+
const staged = statSync(draftsDir(dirname(dirname(dir))), { throwIfNoEntry: false })?.mtimeMs ?? 0
|
|
166
|
+
return tagged(req, `${x.tag.slice(0, -1)}.${Math.round(staged)}"`, () => {
|
|
152
167
|
const members = membersOf(t)
|
|
153
168
|
return { ...threadView(t, readAllCached(dir).items, x.threads, id), missing: missingOf(dir, members), drafts: draftsOfCard(dirname(dirname(dir)), new Set(members.map((m) => m.item.id))) }
|
|
154
169
|
})
|
|
@@ -231,14 +246,10 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
231
246
|
try {
|
|
232
247
|
if (name === 'feedback') {
|
|
233
248
|
const r = writeVerdict(dir, id, await req.json())
|
|
249
|
+
if (r.ok) void changeOnVerdict(dir, id)
|
|
234
250
|
return r.ok ? Response.json(r.message, { headers: NO_STORE }) : Response.json({ error: r.errors.join('\n'), errors: r.errors }, { status: 400, headers: NO_STORE })
|
|
235
251
|
}
|
|
236
|
-
if (name === '
|
|
237
|
-
const b = (await req.json().catch(() => ({}))) as { text?: unknown }
|
|
238
|
-
const social = await loadSocialUnit(dirname(dirname(dir)))
|
|
239
|
-
const text = typeof b.text === 'string' ? b.text : undefined
|
|
240
|
-
return Response.json(await askPost(dir, { card: id, topic: social?.notes ?? 'social', ...(text ? { text } : {}) }), { headers: NO_STORE })
|
|
241
|
-
}
|
|
252
|
+
if (name === 'stage') return await stagePost(dirname(dirname(dir)), dir, id, unit, (await req.json().catch(() => ({}))) as Record<string, unknown>)
|
|
242
253
|
if (name === 'reply') return Response.json(addMessage(dir, id, 'owner', ((await req.json()) as { text?: unknown }).text), { headers: NO_STORE })
|
|
243
254
|
if (name === 'read') {
|
|
244
255
|
// the page names the words it drew: a word that came after them stays unread
|
|
@@ -268,6 +279,13 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
268
279
|
return bad(`POST ${path}?`, 404)
|
|
269
280
|
}
|
|
270
281
|
if (req.method !== 'GET') return null
|
|
282
|
+
if (name === 'stage') {
|
|
283
|
+
try {
|
|
284
|
+
return await stageGet(dirname(dirname(dir)), dir, id)
|
|
285
|
+
} catch (e) {
|
|
286
|
+
return bad(e)
|
|
287
|
+
}
|
|
288
|
+
}
|
|
271
289
|
// a kind's data view of one item, computed here: the page never runs the repo's code
|
|
272
290
|
if (name === 'view') {
|
|
273
291
|
try {
|