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,99 @@
|
|
|
1
|
+
// a trailer card as `sk review add --trailer` makes it (wiki tools/shipkit/review.md, A trailer): the cut a .trailer file
|
|
2
|
+
// names, a kept version of it, the render it is compared with, each render pinned by its mtime, the shots the change
|
|
3
|
+
// touched. No video is made: the hub plays the pinned renders in the trailer entry's player
|
|
4
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
5
|
+
import { relative, resolve, sep } from 'node:path'
|
|
6
|
+
import type { Shot, Trailer } from '../trailer/grammar.ts'
|
|
7
|
+
import { versionName, versionOf } from '../trailer/versions.ts'
|
|
8
|
+
import { stillAt } from './media.ts'
|
|
9
|
+
import type { TrailerCard, TrailerSide } from './model.ts'
|
|
10
|
+
import { cutOf, parseCut, stripOf, timelineOf, trailerDir, videoOf, viewOf } from './trailer-desk.ts'
|
|
11
|
+
|
|
12
|
+
export interface TrailerCardInput {
|
|
13
|
+
/** a `.trailer` file: a cut of `trailer/<id>/`, or a kept version in its `versions/` */
|
|
14
|
+
file: string
|
|
15
|
+
/** a kept version of that cut, `v<n>` */
|
|
16
|
+
version?: string
|
|
17
|
+
/** the render it is compared with: a kept version `v<n>` of the same cut, or another cut of the folder */
|
|
18
|
+
before?: string
|
|
19
|
+
/** the shots the change touched; absent: the shots whose block differs from the before's */
|
|
20
|
+
shots?: string[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** the trailer and the cuts a card plays, read from the input's words alone */
|
|
24
|
+
export function cardCuts(root: string, cwd: string, o: TrailerCardInput): { trailer: string; after: string; before?: string } {
|
|
25
|
+
const rel = relative(root, resolve(cwd, o.file)).split(sep)
|
|
26
|
+
if (!rel.at(-1)?.endsWith('.trailer') || rel[0] !== 'trailer' || !(rel.length === 3 || (rel.length === 4 && rel[2] === 'versions')))
|
|
27
|
+
throw new Error(`--trailer ${o.file}: a cut is trailer/<name>/<cut>.trailer, or a kept one trailer/<name>/versions/<v>.trailer`)
|
|
28
|
+
const trailer = rel[1] ?? ''
|
|
29
|
+
const name = (rel.at(-1) ?? '').slice(0, -'.trailer'.length)
|
|
30
|
+
const kept = rel.length === 4
|
|
31
|
+
if (kept && o.version !== undefined) throw new Error(`--version: ${o.file} is a kept version already`)
|
|
32
|
+
const stem = kept ? (versionOf(name)?.cut ?? name) : name
|
|
33
|
+
const after = kept ? name : o.version !== undefined ? versionName(stem, o.version) : name
|
|
34
|
+
const before = o.before === undefined ? undefined : /^v\d+$/.test(o.before) ? versionName(stem, o.before) : o.before
|
|
35
|
+
if (before === after) throw new Error(`--before ${o.before}: it is the cut the card plays`)
|
|
36
|
+
return { trailer, after, ...(before !== undefined ? { before } : {}) }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** a .trailer file as a card compares it: its parse and its text */
|
|
40
|
+
export interface CutText {
|
|
41
|
+
trailer: Trailer
|
|
42
|
+
text: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** a shot's block as it compares: its header and indented lines, comments and blank lines left out (a film line the
|
|
46
|
+
* parse cannot read without the project's words is still its text), then every parsed field but the lines it sits on
|
|
47
|
+
* (a length a section fits) */
|
|
48
|
+
function shotKey(s: Shot, lines: readonly string[]): string {
|
|
49
|
+
const block: string[] = []
|
|
50
|
+
for (let i = s.line - 1; i < lines.length; i++) {
|
|
51
|
+
const l = lines[i] ?? ''
|
|
52
|
+
if (i > s.line - 1 && l.trim() !== '' && !/^\s/.test(l)) break
|
|
53
|
+
if (l.trim() !== '' && !l.trim().startsWith('#')) block.push(l.trim())
|
|
54
|
+
}
|
|
55
|
+
return `${block.join('\n')}\n${JSON.stringify(s, (k, v: unknown) => (k === 'line' ? undefined : v))}`
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** the shots of `after` that `before` lacks, or whose block reads differently there, in the order of `after` */
|
|
59
|
+
export function changedShots(before: CutText, after: CutText): string[] {
|
|
60
|
+
const was = new Map<string, string>()
|
|
61
|
+
const old = before.text.split('\n')
|
|
62
|
+
for (const s of before.trailer.shots) if (!was.has(s.name)) was.set(s.name, shotKey(s, old))
|
|
63
|
+
const now = after.text.split('\n')
|
|
64
|
+
return [...new Set(after.trailer.shots.filter((s) => was.get(s.name) !== shotKey(s, now)).map((s) => s.name))]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** the card's trailer, its pinned renders and its shots, and the image the store keeps for it: the cut's contact strip,
|
|
68
|
+
* else a still of its render cut into `still` */
|
|
69
|
+
export async function trailerCardOf(root: string, cwd: string, o: TrailerCardInput, still: string): Promise<{ card: TrailerCard; image: string }> {
|
|
70
|
+
const cuts = cardCuts(root, cwd, o)
|
|
71
|
+
const dir = trailerDir(root, cuts.trailer)
|
|
72
|
+
if (!dir) throw new Error(`--trailer: no trailer folder trailer/${cuts.trailer}`)
|
|
73
|
+
const pin = (cut: string, flag: string): { side: TrailerSide; file: string | null; video: string; strip: string; size: [number, number] } => {
|
|
74
|
+
const c = cutOf(dir, cut)
|
|
75
|
+
if (!c) throw new Error(`${flag}: no cut ${cut} in trailer/${cuts.trailer} (sk trailer keep <v> keeps a version)`)
|
|
76
|
+
const { view, rendering } = viewOf(root, dir, cuts.trailer, c)
|
|
77
|
+
if (rendering) throw new Error(`${flag}: a render of ${cut} is being written: send the card once it is done`)
|
|
78
|
+
if (!view) throw new Error(`${flag}: ${cut} has no render: sk trailer ${c.trailer ? relative(cwd, c.trailer) : cut}`)
|
|
79
|
+
return { side: { cut, render: view.mtime }, file: c.trailer, video: videoOf(dir, c), strip: stripOf(dir, c), size: view.size }
|
|
80
|
+
}
|
|
81
|
+
const after = pin(cuts.after, '--trailer')
|
|
82
|
+
const before = cuts.before !== undefined ? pin(cuts.before, '--before') : null
|
|
83
|
+
const parsed = (f: string | null): CutText | null => (f ? { trailer: parseCut(f).trailer, text: readFileSync(f, 'utf8') } : null)
|
|
84
|
+
let shots: string[]
|
|
85
|
+
if (o.shots !== undefined) {
|
|
86
|
+
const tl = parsed(after.file)?.trailer
|
|
87
|
+
const known = new Set(tl ? timelineOf(tl).shots.map((s) => s.name) : [])
|
|
88
|
+
const unknown = o.shots.filter((s) => !known.has(s))
|
|
89
|
+
if (unknown.length > 0) throw new Error(`--shots: ${unknown.join(', ')} ${unknown.length > 1 ? 'are no shots' : 'is no shot'} of ${cuts.after}`)
|
|
90
|
+
shots = [...new Set(o.shots)]
|
|
91
|
+
} else {
|
|
92
|
+
const a = parsed(after.file)
|
|
93
|
+
const b = before ? parsed(before.file) : null
|
|
94
|
+
shots = a && b ? changedShots(b, a) : []
|
|
95
|
+
}
|
|
96
|
+
if (!existsSync(after.strip)) await stillAt(after.video, 0.5, still)
|
|
97
|
+
const image = existsSync(after.strip) ? after.strip : still
|
|
98
|
+
return { card: { trailer: cuts.trailer, after: after.side, ...(before ? { before: before.side } : {}), shots, size: after.size }, image }
|
|
99
|
+
}
|
|
@@ -10,10 +10,11 @@ import type { MediaFact } from '../media-store/fact.ts'
|
|
|
10
10
|
import { fetchBack, signedUrl } from '../media-store/remote.ts'
|
|
11
11
|
import { parseTrailer, starts, total, type Trailer } from '../trailer/grammar.ts'
|
|
12
12
|
import { THUMB_W } from '../trailer/graph.ts'
|
|
13
|
+
import { ffmpeg } from '../trailer/ffmpeg.ts'
|
|
13
14
|
import { probe, stillAt } from './media.ts'
|
|
14
15
|
import type { FrameSubject } from './model.ts'
|
|
15
16
|
import { readAllCached, storeDir } from './store.ts'
|
|
16
|
-
import { CUT_RE, notesOf, shotAt, TRAILER_ID_RE, type CutInfo, type SectionSpan, type ShotSpan, type Timeline, type TrailerInfo } from './trailer-model.ts'
|
|
17
|
+
import { CUT_RE, notesOf, shotAt, TRAILER_ID_RE, type CutInfo, type PinnedRender, type SectionSpan, type ShotSpan, type Timeline, type TrailerInfo } from './trailer-model.ts'
|
|
17
18
|
|
|
18
19
|
const round = (v: number, d = 4): number => Number(v.toFixed(d))
|
|
19
20
|
|
|
@@ -134,7 +135,7 @@ export const montageOf = (dir: string, c: CutFiles): string => join(dir, 'out',
|
|
|
134
135
|
|
|
135
136
|
/** a cut's .trailer parsed: the film lines need the project CLI's words, which a timeline never does, so their errors
|
|
136
137
|
* are left out */
|
|
137
|
-
function parseCut(file: string): { trailer: Trailer; errors: string[] } {
|
|
138
|
+
export function parseCut(file: string): { trailer: Trailer; errors: string[] } {
|
|
138
139
|
const text = readFileSync(file, 'utf8')
|
|
139
140
|
const lines = text.split('\n')
|
|
140
141
|
const { trailer, errors } = parseTrailer(text, { verbs: null })
|
|
@@ -168,9 +169,32 @@ export interface View {
|
|
|
168
169
|
fps: number
|
|
169
170
|
size: [number, number]
|
|
170
171
|
timeline: Timeline | null
|
|
172
|
+
/** the timing rule its timeline was read with (TIMING); an older one is read again from its unchanged .trailer */
|
|
173
|
+
timing?: number
|
|
171
174
|
media?: ViewMedia
|
|
172
175
|
}
|
|
173
176
|
|
|
177
|
+
/** 2: a shot whose film words the hub does not know keeps its fitted length, as in the build */
|
|
178
|
+
const TIMING = 2
|
|
179
|
+
|
|
180
|
+
/** a record's timeline read with an older rule, read again from its .trailer when that file is the one it was rendered
|
|
181
|
+
* from (saved before it); one saved after may differ, so the old timeline stays */
|
|
182
|
+
function retimed(root: string, id: string, cut: string, v: View): View {
|
|
183
|
+
if (v.timing === TIMING || v.timeline === null) return v
|
|
184
|
+
const dir = trailerDir(root, id)
|
|
185
|
+
const c = dir ? cutOf(dir, cut) : null
|
|
186
|
+
if (!c?.trailer || statSync(c.trailer).mtimeMs > v.mtime) return v
|
|
187
|
+
let timeline: Timeline
|
|
188
|
+
try {
|
|
189
|
+
timeline = timelineOf(parseCut(c.trailer).trailer)
|
|
190
|
+
} catch {
|
|
191
|
+
return v
|
|
192
|
+
}
|
|
193
|
+
const out: View = { ...v, timeline, timing: TIMING }
|
|
194
|
+
writeView(root, id, cut, out)
|
|
195
|
+
return out
|
|
196
|
+
}
|
|
197
|
+
|
|
174
198
|
export const viewBase = (root: string, id: string, cut: string, mtime: number): string => join(viewDir(root), `${id}--${cut}--${Math.round(mtime)}`)
|
|
175
199
|
export const viewVideo = (root: string, id: string, cut: string, mtime: number): string => `${viewBase(root, id, cut, mtime)}.mp4`
|
|
176
200
|
export const viewStrip = (root: string, id: string, cut: string, mtime: number): string => `${viewBase(root, id, cut, mtime)}.strip.png`
|
|
@@ -188,7 +212,7 @@ export function readView(root: string, id: string, cut: string, mtime: number):
|
|
|
188
212
|
const f = `${viewBase(root, id, cut, mtime)}.json`
|
|
189
213
|
if (!existsSync(f)) return null
|
|
190
214
|
const v = JSON.parse(readFileSync(f, 'utf8')) as View
|
|
191
|
-
return v.media?.video || existsSync(viewVideo(root, id, cut, mtime)) ? v : null
|
|
215
|
+
return v.media?.video || existsSync(viewVideo(root, id, cut, mtime)) ? retimed(root, id, cut, v) : null
|
|
192
216
|
}
|
|
193
217
|
|
|
194
218
|
/** a render's record written whole, through a file beside it renamed */
|
|
@@ -252,7 +276,7 @@ export function viewOf(root: string, dir: string, id: string, c: CutFiles, now =
|
|
|
252
276
|
} catch {
|
|
253
277
|
timeline = null
|
|
254
278
|
}
|
|
255
|
-
const view: View = { mtime, ...p, timeline }
|
|
279
|
+
const view: View = { mtime, ...p, timeline, timing: TIMING }
|
|
256
280
|
writeView(root, id, c.cut, view)
|
|
257
281
|
keepStrip(root, dir, id, c, mtime)
|
|
258
282
|
views.set(key, view)
|
|
@@ -356,6 +380,17 @@ export function trailerInfo(root: string, id: string): TrailerInfo | null {
|
|
|
356
380
|
return { id, cuts: cutsOf(dir).map((c) => cutInfo(root, dir, id, c)), notes: notesOf(readAllCached(storeDir(root)).items, id) }
|
|
357
381
|
}
|
|
358
382
|
|
|
383
|
+
/** a render a trailer card pinned: its record, its timeline (else the cut's file as it stands, as on the page), its
|
|
384
|
+
* strip's grid; null when nothing holds its video */
|
|
385
|
+
export function pinnedRender(root: string, id: string, cut: string, mtime: number): PinnedRender | null {
|
|
386
|
+
const v = readView(root, id, cut, mtime)
|
|
387
|
+
const dir = trailerDir(root, id)
|
|
388
|
+
const c = dir ? cutOf(dir, cut) : null
|
|
389
|
+
if (!v || !c) return null
|
|
390
|
+
const tl = v.timeline ?? (c.trailer ? timelineOf(parseCut(c.trailer).trailer) : wholeTimeline(v.duration, v.fps, v.size))
|
|
391
|
+
return { duration: v.duration, fps: v.fps, timeline: tl, strip: stripInfo(viewStrip(root, id, cut, mtime), v, tl) }
|
|
392
|
+
}
|
|
393
|
+
|
|
359
394
|
/** the montage page of a cut, null when its build wrote none */
|
|
360
395
|
export function montagePage(root: string, id: string, cut: string): string | null {
|
|
361
396
|
const dir = trailerDir(root, id)
|
|
@@ -374,6 +409,24 @@ export function frameAt(time: number, fps: number, duration: number): { frame: n
|
|
|
374
409
|
return { frame, time: (frame + 0.5) / fps }
|
|
375
410
|
}
|
|
376
411
|
|
|
412
|
+
/** a still the rail draws a note on is this wide */
|
|
413
|
+
const STILL_W = 320
|
|
414
|
+
|
|
415
|
+
/** frame `frame` of a render, a small jpg cut once beside its record and kept; null when nothing holds the render */
|
|
416
|
+
export async function frameStill(root: string, id: string, cut: string, mtime: number, frame: number): Promise<string | null> {
|
|
417
|
+
const v = readView(root, id, cut, mtime)
|
|
418
|
+
if (!v || !Number.isInteger(frame) || frame < 0) return null
|
|
419
|
+
const f = frameAt((frame + 0.5) / v.fps, v.fps, v.duration)
|
|
420
|
+
const out = `${viewBase(root, id, cut, mtime)}--f${f.frame}.jpg`
|
|
421
|
+
if (existsSync(out)) return out
|
|
422
|
+
const video = await viewMedia(root, id, cut, mtime, 'video', { bytes: true })
|
|
423
|
+
if (!video || !('path' in video)) return null
|
|
424
|
+
const tmp = `${out}.${process.pid}.jpg`
|
|
425
|
+
await ffmpeg(['-y', '-ss', f.time.toFixed(5), '-i', video.path, '-frames:v', '1', '-vf', `scale=${STILL_W}:-2`, '-q:v', '4', tmp])
|
|
426
|
+
renameSync(tmp, out)
|
|
427
|
+
return out
|
|
428
|
+
}
|
|
429
|
+
|
|
377
430
|
export interface NewNote {
|
|
378
431
|
cut: string
|
|
379
432
|
/** the render on screen, by its mtime: the still is cut from that version, whatever came after */
|
|
@@ -4,17 +4,43 @@ import { isFrame, isReply, partyOf, stateOf, type ReviewItem } from './model.ts'
|
|
|
4
4
|
|
|
5
5
|
export type NoteState = 'open' | 'done' | 'wontfix'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
/** what a frame note marks on its frame: a review card's rectangle (x, y, w, h, 0 to 1 over the frame from the left and
|
|
8
|
+
* the top, so any render or size of the player shows it in place); w = h = 0 is a point */
|
|
9
|
+
export interface NoteMark {
|
|
9
10
|
x: number
|
|
10
11
|
y: number
|
|
12
|
+
w: number
|
|
13
|
+
h: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** a mark read from a request, kept inside the frame; undefined when it is none */
|
|
17
|
+
export function noteMarkOf(v: unknown): NoteMark | undefined {
|
|
18
|
+
const m = v as { x?: unknown; y?: unknown; w?: unknown; h?: unknown } | null | undefined
|
|
19
|
+
if (!m || typeof m.x !== 'number' || typeof m.y !== 'number' || !Number.isFinite(m.x) || !Number.isFinite(m.y)) return undefined
|
|
20
|
+
const r4 = (n: number): number => Number(Math.min(1, Math.max(0, n)).toFixed(4))
|
|
21
|
+
const x = r4(m.x)
|
|
22
|
+
const y = r4(m.y)
|
|
23
|
+
const side = (n: unknown, at: number): number => (typeof n === 'number' && Number.isFinite(n) && n > 0 ? r4(Math.min(n, 1 - at)) : 0)
|
|
24
|
+
return { x, y, w: side(m.w, x), h: side(m.h, y) }
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** one marker of the timeline's notes lane, a trailer card's note or a page's frame note: its number in the order of
|
|
28
|
+
* the cut, its time, its tone, its words; `go` lands on its frame */
|
|
29
|
+
export interface LaneMark {
|
|
30
|
+
key: string
|
|
31
|
+
n: number
|
|
32
|
+
at: number
|
|
33
|
+
tone: 'draft' | 'sent' | NoteState
|
|
34
|
+
text: string
|
|
35
|
+
selected: boolean
|
|
36
|
+
go: () => void
|
|
11
37
|
}
|
|
12
38
|
|
|
13
39
|
/** one note as the view shows it: an item of the one store whose subject is a frame */
|
|
14
40
|
export interface TrailerNote {
|
|
15
41
|
/** its item's id */
|
|
16
42
|
id: string
|
|
17
|
-
/** its number on the trailer, in the order written
|
|
43
|
+
/** its number on the trailer, in the order written */
|
|
18
44
|
n: number
|
|
19
45
|
trailer: string
|
|
20
46
|
cut: string
|
|
@@ -26,7 +52,7 @@ export interface TrailerNote {
|
|
|
26
52
|
shotTime: number
|
|
27
53
|
section: string | null
|
|
28
54
|
text: string
|
|
29
|
-
|
|
55
|
+
mark?: NoteMark
|
|
30
56
|
state: NoteState
|
|
31
57
|
/** done: the commit or the answer; wontfix: the reason */
|
|
32
58
|
reply?: string
|
|
@@ -36,14 +62,22 @@ export interface TrailerNote {
|
|
|
36
62
|
still: string
|
|
37
63
|
}
|
|
38
64
|
|
|
39
|
-
/** a
|
|
65
|
+
/** a render as a trailer card pins it: its length, rate, timeline and strip, whatever render the cut has now */
|
|
66
|
+
export interface PinnedRender {
|
|
67
|
+
duration: number
|
|
68
|
+
fps: number
|
|
69
|
+
timeline: Timeline
|
|
70
|
+
strip: CutInfo['strip']
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** a frame item as a note: its words and mark are the owner's latest, its state the lifecycle's (fixed is done); null
|
|
40
74
|
* when the item is no frame */
|
|
41
75
|
export function noteOf(x: ReviewItem, n: number): TrailerNote | null {
|
|
42
76
|
const s = x.item.subject
|
|
43
77
|
if (!isFrame(s)) return null
|
|
44
78
|
const said = x.thread.filter((m) => partyOf(m.who) === 'owner' && m.op === undefined)
|
|
45
79
|
const text = said.filter(isReply).at(-1)?.text ?? ''
|
|
46
|
-
const
|
|
80
|
+
const marked = said.filter((m) => m.rects !== undefined).at(-1)?.rects?.[0]
|
|
47
81
|
const st = stateOf(x, false)
|
|
48
82
|
const closing = st.state === 'closed' ? x.thread.filter((m) => m.op === 'fixed' || m.op === 'wontfix').at(-1) : undefined
|
|
49
83
|
const first = x.item.views[0]
|
|
@@ -58,7 +92,7 @@ export function noteOf(x: ReviewItem, n: number): TrailerNote | null {
|
|
|
58
92
|
shotTime: s.shotTime,
|
|
59
93
|
section: s.section,
|
|
60
94
|
text,
|
|
61
|
-
...(
|
|
95
|
+
...(marked ? { mark: { x: marked.x, y: marked.y, w: marked.w, h: marked.h } } : {}),
|
|
62
96
|
state: closing?.op === 'wontfix' ? 'wontfix' : closing ? 'done' : 'open',
|
|
63
97
|
...(closing?.note ? { reply: closing.note } : {}),
|
|
64
98
|
written: x.item.created,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// a trailer card's notes in the order of the cut (wiki tools/shipkit/review.md, A trailer): the card's own rectangles,
|
|
2
|
+
// sent with its verdicts or still in the draft, as the lane, the rail, the frame and the verdict's rows show them.
|
|
3
|
+
// Pure: the hub and its tests share it
|
|
4
|
+
import { onFrame, type Rect, type Side } from './model.ts'
|
|
5
|
+
|
|
6
|
+
export interface LaneNote {
|
|
7
|
+
/** `s:<verdict>:<k>` for a sent rectangle, `d:<i>` for the draft's i-th */
|
|
8
|
+
key: string
|
|
9
|
+
/** its number in the order of the cut, over every note of the version */
|
|
10
|
+
n: number
|
|
11
|
+
/** seconds on the render it was drawn on */
|
|
12
|
+
t: number
|
|
13
|
+
side?: Side
|
|
14
|
+
shot?: { name: string; time: number }
|
|
15
|
+
rect: Rect
|
|
16
|
+
/** its index in the draft, null once sent */
|
|
17
|
+
draft: number | null
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** every rectangle on a trailer card's frame, sent or drafted, in the order of the cut (its time, then before ahead of
|
|
21
|
+
* after); a rectangle with no time is no trailer note */
|
|
22
|
+
export function laneNotes(sent: readonly { id: string; rects: readonly Rect[] }[], draft: readonly Rect[]): LaneNote[] {
|
|
23
|
+
const all = [
|
|
24
|
+
...sent.flatMap((v) => v.rects.flatMap((r, k) => ((r.view ?? 0) === 0 && r.t !== undefined ? [{ key: `s:${v.id}:${k}`, rect: r, t: r.t, draft: null }] : []))),
|
|
25
|
+
...draft.flatMap((r, i) => ((r.view ?? 0) === 0 && r.t !== undefined ? [{ key: `d:${i}`, rect: r, t: r.t, draft: i }] : [])),
|
|
26
|
+
]
|
|
27
|
+
const sideRank = (r: Rect): number => (r.side === 'before' ? 0 : 1)
|
|
28
|
+
return all
|
|
29
|
+
.sort((a, b) => a.t - b.t || sideRank(a.rect) - sideRank(b.rect))
|
|
30
|
+
.map((x, i) => ({ ...x, n: i + 1, ...(x.rect.side ? { side: x.rect.side } : {}), ...(x.rect.shot ? { shot: x.rect.shot } : {}) }))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** a playing note lights this long either side of its time */
|
|
34
|
+
export const LIT_S = 0.5
|
|
35
|
+
|
|
36
|
+
/** the notes the frame shows now: on the render on screen, on this very frame while paused, within LIT_S while it plays */
|
|
37
|
+
export function notesNow(notes: readonly LaneNote[], at: { time: number; fps: number; paused: boolean; side: Side | undefined }): LaneNote[] {
|
|
38
|
+
return notes.filter((n) => n.side === at.side && (at.paused ? onFrame(n.t, at.time, at.fps) : Math.abs(n.t - at.time) <= LIT_S))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** a draft in the order of the cut once a rectangle joins it: where that rectangle went */
|
|
42
|
+
export function sortedDraft(rects: readonly Rect[], added: Rect): { rects: Rect[]; at: number } {
|
|
43
|
+
const out = [...rects, added].sort((a, b) => (a.t ?? 0) - (b.t ?? 0))
|
|
44
|
+
return { rects: out, at: out.indexOf(added) }
|
|
45
|
+
}
|
|
@@ -7,15 +7,11 @@ import { join, relative } from 'node:path'
|
|
|
7
7
|
import { bad, NO_STORE, ranged } from './http.ts'
|
|
8
8
|
import { ID_RE, isFrame } from './model.ts'
|
|
9
9
|
import { act, appendMessage, deleteRaised, raiseItem, readAllCached, readItem } from './store.ts'
|
|
10
|
-
import { cutOf, frameNote, montagePage, trailerDir, trailerIds, trailerInfo, videoOf, viewMedia } from './trailer-desk.ts'
|
|
11
|
-
import { CUT_RE, noteOf, TRAILER_ID_RE, type
|
|
10
|
+
import { cutOf, frameNote, frameStill, montagePage, pinnedRender, trailerDir, trailerIds, trailerInfo, videoOf, viewMedia } from './trailer-desk.ts'
|
|
11
|
+
import { CUT_RE, noteMarkOf, noteOf, TRAILER_ID_RE, type NoteMark, type NoteState, type TrailerDesk } from './trailer-model.ts'
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const pinOf = (v: unknown): NotePin | undefined => {
|
|
16
|
-
const p = v as { x?: unknown; y?: unknown } | null | undefined
|
|
17
|
-
return p && typeof p.x === 'number' && typeof p.y === 'number' ? { x: p.x, y: p.y } : undefined
|
|
18
|
-
}
|
|
13
|
+
/** a note's mark as its message stores it: a review card's Rect */
|
|
14
|
+
const rectsOf = (m: NoteMark) => [{ ...m, comment: '' }]
|
|
19
15
|
|
|
20
16
|
const STATES: readonly NoteState[] = ['open', 'done', 'wontfix']
|
|
21
17
|
|
|
@@ -59,6 +55,19 @@ export async function trailerRoutes(req: Request, path: string, root: string, di
|
|
|
59
55
|
// a render the disk let go plays from the Space: the signed URL lives an hour, the browser keeps half of it
|
|
60
56
|
return 'path' in at ? ranged(req, at.path) : new Response(null, { status: 302, headers: { Location: at.url, 'Cache-Control': 'private, max-age=1800' } })
|
|
61
57
|
}
|
|
58
|
+
const pinned = /^\/api\/trailer\/render\/([^/]+)\/([^/]+)\/(\d+)$/.exec(path)
|
|
59
|
+
if (pinned && req.method === 'GET') {
|
|
60
|
+
const [, id = '', cut = '', version = ''] = pinned
|
|
61
|
+
const r = TRAILER_ID_RE.test(id) && CUT_RE.test(cut) ? pinnedRender(root, id, cut, Number(version)) : null
|
|
62
|
+
return r ? Response.json(r, { headers: NO_STORE }) : bad(`no render ${id}/${cut} at ${version}: neither the disk nor the media store holds it`, 404)
|
|
63
|
+
}
|
|
64
|
+
const still = /^\/api\/trailer\/still\/([^/]+)\/([^/]+)\/(\d+)\/(\d+)\.jpg$/.exec(path)
|
|
65
|
+
if (still && req.method === 'GET') {
|
|
66
|
+
// one frame of a render, small, cut once and kept: a note's row in the rail and the verdict
|
|
67
|
+
const [, id = '', cut = '', version = '', frame = ''] = still
|
|
68
|
+
const f = TRAILER_ID_RE.test(id) && CUT_RE.test(cut) ? await frameStill(root, id, cut, Number(version), Number(frame)) : null
|
|
69
|
+
return f ? new Response(Bun.file(f), { headers: { 'Content-Type': 'image/jpeg', 'Cache-Control': 'private, max-age=86400' } }) : bad(`no frame ${frame} of ${id}/${cut} at ${version}`, 404)
|
|
70
|
+
}
|
|
62
71
|
const mont = /^\/api\/trailer\/montage\/([^/]+)\/([^/]+)$/.exec(path)
|
|
63
72
|
if (mont && req.method === 'GET') {
|
|
64
73
|
const page = montagePage(root, mont[1] ?? '', mont[2] ?? '')
|
|
@@ -83,7 +92,7 @@ export async function trailerRoutes(req: Request, path: string, root: string, di
|
|
|
83
92
|
if (!trailerDir(root, id)) return bad(`no trailer ${id}`)
|
|
84
93
|
const text = String(b.text ?? '')
|
|
85
94
|
if (text.trim() === '') return bad('a note says something')
|
|
86
|
-
const
|
|
95
|
+
const mark = noteMarkOf(b.mark)
|
|
87
96
|
const tmp = mkdtempSync(join(tmpdir(), 'trailer-note-'))
|
|
88
97
|
try {
|
|
89
98
|
const still = join(tmp, 'still.png')
|
|
@@ -95,7 +104,7 @@ export async function trailerRoutes(req: Request, path: string, root: string, di
|
|
|
95
104
|
topic: 'film',
|
|
96
105
|
title: titleOf(text),
|
|
97
106
|
text,
|
|
98
|
-
...(
|
|
107
|
+
...(mark ? { rects: rectsOf(mark) } : {}),
|
|
99
108
|
image: still,
|
|
100
109
|
...(commit ? { commit } : {}),
|
|
101
110
|
})
|
|
@@ -118,12 +127,12 @@ export async function trailerRoutes(req: Request, path: string, root: string, di
|
|
|
118
127
|
if (typeof b.state === 'string' && !STATES.includes(b.state as NoteState)) return bad(`state ${b.state}?`)
|
|
119
128
|
const text = typeof b.text === 'string' ? b.text.trim() : undefined
|
|
120
129
|
if (text === '') return bad('a note says something')
|
|
121
|
-
const
|
|
122
|
-
if (text !== undefined ||
|
|
130
|
+
const mark = b.mark === null ? null : noteMarkOf(b.mark)
|
|
131
|
+
if (text !== undefined || mark !== undefined)
|
|
123
132
|
appendMessage(dir, nid, {
|
|
124
133
|
who: 'owner',
|
|
125
134
|
...(text !== undefined ? { text } : {}),
|
|
126
|
-
...(
|
|
135
|
+
...(mark !== undefined ? { rects: mark ? rectsOf(mark) : [] } : {}),
|
|
127
136
|
})
|
|
128
137
|
const reply = typeof b.reply === 'string' ? b.reply : undefined
|
|
129
138
|
if (b.state === 'open') act(dir, nid, 'reopen', 'owner')
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// the house secret manager as a repo config spells it: `credsCommand` writes,
|
|
2
|
+
// `credsReadCommand` reads, the repo's own line before the house's. Every
|
|
3
|
+
// write goes through `storeArgv`: `sk secret set` with the terminal on stdin,
|
|
4
|
+
// the hub with the pasted value on stdin. A value never rides argv, a log or
|
|
5
|
+
// an answer: a failure line comes back with it replaced by ‹value›.
|
|
6
|
+
import { existsSync } from 'fs'
|
|
7
|
+
import { basename, join } from 'path'
|
|
8
|
+
import { gitRoot } from '../core/git-root.ts'
|
|
9
|
+
import { houseRootOf } from '../home/home-start.ts'
|
|
10
|
+
import { loadIdentities, speakerOf } from '../identities/identities.ts'
|
|
11
|
+
import { loadRepoConfig, type RepoConfig } from '../repo-config.ts'
|
|
12
|
+
|
|
13
|
+
export type SecretsWhere = { repos: string[]; identity: string | null; own: RepoConfig | null; house: RepoConfig | null }
|
|
14
|
+
|
|
15
|
+
export async function secretsWhere(cwd: string): Promise<SecretsWhere> {
|
|
16
|
+
const root = gitRoot(cwd)?.top ?? cwd
|
|
17
|
+
const own = existsSync(join(root, 'repo.config.ts')) ? await loadRepoConfig(root) : null
|
|
18
|
+
const houseRoot = houseRootOf(cwd)
|
|
19
|
+
const house = houseRoot == null ? null : houseRoot === root ? own : await loadRepoConfig(houseRoot).catch(() => null)
|
|
20
|
+
const identity = speakerOf(own?.speaksAs, await loadIdentities({ cwd }))?.id ?? null
|
|
21
|
+
return { repos: [...new Set([own?.name ?? basename(root), basename(root)])], identity, own, house }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** a refusal said as one line, never a stack */
|
|
25
|
+
export class NoManager extends Error {}
|
|
26
|
+
|
|
27
|
+
export function managerTemplate(w: SecretsWhere, key: 'credsReadCommand' | 'credsCommand'): string {
|
|
28
|
+
const t = w.own?.[key] ?? w.house?.[key]
|
|
29
|
+
if (w.own == null && w.house == null) throw new NoManager('FAIL not inside a house repo: run it from a repo that loads the house wiki')
|
|
30
|
+
if (t == null || t.trim() === '') throw new NoManager(`FAIL no ${key} in this repo's repo.config.ts nor the house's: nothing knows how to reach the secret manager`)
|
|
31
|
+
return t
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** the one argv every write runs; the value goes on its stdin */
|
|
35
|
+
export const storeArgv = (template: string, name: string, account?: string): string[] =>
|
|
36
|
+
[...template.trim().split(/\s+/).map((x) => x.replaceAll('{name}', name)), ...(account != null ? [account] : [])]
|
|
37
|
+
|
|
38
|
+
export type Stored = { ok: true } | { ok: false; why: string }
|
|
39
|
+
export type SecretStore = (name: string, value: string) => Promise<Stored>
|
|
40
|
+
|
|
41
|
+
/** every place the value shows in a line, replaced */
|
|
42
|
+
export const redact = (text: string, value: string): string => (value === '' ? text : text.replaceAll(value, '‹value›'))
|
|
43
|
+
|
|
44
|
+
/** a store through the repo's `credsCommand`, as `sk secret set` runs it, the value on stdin */
|
|
45
|
+
export function managerStore(cwd: string): SecretStore {
|
|
46
|
+
return async (name, value) => {
|
|
47
|
+
let template: string
|
|
48
|
+
try {
|
|
49
|
+
template = managerTemplate(await secretsWhere(cwd), 'credsCommand')
|
|
50
|
+
} catch (e) {
|
|
51
|
+
return { ok: false, why: (e as Error).message }
|
|
52
|
+
}
|
|
53
|
+
const p = Bun.spawn(storeArgv(template, name), { cwd, env: process.env, stdin: new Blob([value]), stdout: 'ignore', stderr: 'pipe' })
|
|
54
|
+
const err = await new Response(p.stderr).text()
|
|
55
|
+
if ((await p.exited) === 0) return { ok: true }
|
|
56
|
+
const tail = err.trim().split('\n').slice(-2).join(' ')
|
|
57
|
+
return { ok: false, why: redact(`${template.trim().split(/\s+/)[0]} exited ${p.exitCode}${tail !== '' ? `: ${tail}` : ''}`, value) }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// the shipkit macOS app's Dock badge and notifications, fed by the page (wiki tools/shipkit/home-pages.md, the
|
|
2
|
+
// shipkit app's Dock badge): the count the rail draws, posted when it changes, and each card that starts waiting.
|
|
3
|
+
// The app's WebKit message handler `shipkit` is the only listener: a browser tab has none, and nothing is posted.
|
|
4
|
+
//
|
|
5
|
+
// the one constraint a reader breaks first: the first answer of the daemon is the seed, so the backlog at app start
|
|
6
|
+
// never notifies; the list this browser kept from its last load is not that answer
|
|
7
|
+
import { reaction } from 'mobx'
|
|
8
|
+
import type { Project } from './projects-svc.ts'
|
|
9
|
+
|
|
10
|
+
/** a card that started waiting, as the app's notification names it; `url` opens it where no page answers */
|
|
11
|
+
export type AppCard = { id: string; title: string; repo: string; url: string }
|
|
12
|
+
/** `seed`: every card waiting at the page's first daemon answer; the app notifies those it never saw, unless it is
|
|
13
|
+
* the first seed of its life (the backlog at start) */
|
|
14
|
+
export type AppNote = { waiting: number; keys: string[] } | { seed: AppCard[] } | { card: AppCard }
|
|
15
|
+
export type Post = (note: AppNote) => void
|
|
16
|
+
/** the absolute address of a card's review page */
|
|
17
|
+
export type CardUrl = (repo: string, id: string) => string
|
|
18
|
+
|
|
19
|
+
/** the app's handler, or null in a browser tab */
|
|
20
|
+
export function appPost(w: unknown = globalThis): Post | null {
|
|
21
|
+
const h = (w as { webkit?: { messageHandlers?: { shipkit?: { postMessage(m: unknown): void } } } }).webkit?.messageHandlers?.shipkit
|
|
22
|
+
return h == null ? null : (note) => h.postMessage(note)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** the house wide count the badge shows: the rail's per repo numbers summed */
|
|
26
|
+
export const waitingOf = (list: Project[]): number => list.reduce((n, p) => n + p.cards.length, 0)
|
|
27
|
+
|
|
28
|
+
/** what one daemon answer posts: the count and the `repo/id` keys waiting when either moved (the app removes the
|
|
29
|
+
* banners of every other card), the seed at the first answer, then each card this page had not seen. The app owns
|
|
30
|
+
* the set of cards notified: this one only keeps a poll from posting them again */
|
|
31
|
+
export class AppBridge {
|
|
32
|
+
private seen: Set<string> | null = null
|
|
33
|
+
private last: string | null = null
|
|
34
|
+
|
|
35
|
+
constructor(private readonly post: Post, private readonly cardUrl: CardUrl) {}
|
|
36
|
+
|
|
37
|
+
update(list: Project[]): void {
|
|
38
|
+
const cards = list.flatMap((p) => p.cards.map((c) => ({ key: `${p.name}/${c.id}`, card: { id: c.id, title: c.title, repo: p.name, url: this.cardUrl(p.name, c.id) } })))
|
|
39
|
+
const keys = cards.map((c) => c.key)
|
|
40
|
+
const now = JSON.stringify(keys)
|
|
41
|
+
if (now !== this.last) {
|
|
42
|
+
this.last = now
|
|
43
|
+
this.post({ waiting: waitingOf(list), keys })
|
|
44
|
+
}
|
|
45
|
+
const seen = this.seen
|
|
46
|
+
if (seen == null) {
|
|
47
|
+
this.seen = new Set(cards.map((c) => c.key))
|
|
48
|
+
this.post({ seed: cards.map((c) => c.card) })
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
for (const c of cards) {
|
|
52
|
+
if (seen.has(c.key)) continue
|
|
53
|
+
seen.add(c.key)
|
|
54
|
+
this.post({ card: c.card })
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** what the app calls on a notification's click: that card in this window, in place, or the inbox */
|
|
60
|
+
export type AppHooks = { openCard(repo: string, id: string): void; openInbox(): void }
|
|
61
|
+
|
|
62
|
+
/** feeds the app from the project list once it is the daemon's, and hands the app the page's hooks; a no-op
|
|
63
|
+
* outside the app. Returns the stop */
|
|
64
|
+
export function startAppBridge(o: { projects: { fresh: boolean; list: Project[] }; hooks: AppHooks; cardUrl: CardUrl; post?: Post | null; w?: unknown }): () => void {
|
|
65
|
+
const w = o.w ?? globalThis
|
|
66
|
+
const post = o.post === undefined ? appPost(w) : o.post
|
|
67
|
+
if (post == null) return () => {}
|
|
68
|
+
const bridge = new AppBridge(post, o.cardUrl)
|
|
69
|
+
;(w as { shipkitApp?: AppHooks }).shipkitApp = o.hooks
|
|
70
|
+
return reaction(() => (o.projects.fresh ? o.projects.list : null), (list) => { if (list != null) bridge.update(list) }, { fireImmediately: true })
|
|
71
|
+
}
|
|
@@ -68,6 +68,16 @@ export const ColCard = observer(({ app, col, id }: { app: RepoSt; col: string; i
|
|
|
68
68
|
) : null}
|
|
69
69
|
{i.artifact?.url != null ? <div className="row"><a href={i.artifact.url} target="_blank" rel="noreferrer">mint ↗</a></div> : null}
|
|
70
70
|
{i.artifact?.steps != null ? <div className="row"><div>{i.artifact.steps.map((s, n) => <span key={n}>{n + 1}. {s}<br /></span>)}</div></div> : null}
|
|
71
|
+
{/* a credential ask takes its value here: a password field per secret it names, sent once, never shown */}
|
|
72
|
+
{askFile != null && i.severity != null ? (i.ask?.secrets ?? []).map((name) => (
|
|
73
|
+
<div className="row" key={name}>
|
|
74
|
+
<input type="password" autoComplete="off" spellCheck={false} placeholder={`paste the token for ${name}`} value={c.secretDrafts.get(name) ?? ''}
|
|
75
|
+
onChange={(e) => c.setSecretDraft(name, e.target.value)}
|
|
76
|
+
onKeyDown={(e) => { if (e.key === 'Enter') void c.storeSecret(askFile, name) }} />
|
|
77
|
+
<button onClick={() => void c.storeSecret(askFile, name)}>store</button>
|
|
78
|
+
</div>
|
|
79
|
+
)) : null}
|
|
80
|
+
{c.secretNote !== '' ? <div className="said">✓ {c.secretNote}</div> : null}
|
|
71
81
|
{askFile != null && i.severity != null ? (
|
|
72
82
|
<div className="row">
|
|
73
83
|
<input placeholder="proof URL (optional)" value={c.proofDraft} onChange={(e) => runInAction(() => { c.proofDraft = e.target.value })} />
|