rvlib-shipkit 2.20.0 → 2.22.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 +35 -0
- package/package.json +1 -1
- package/src/asks/asks-queue.ts +8 -7
- package/src/assets/kits/identity-kit.ts +158 -2
- package/src/checks/SK004-gitignore-policy.check.ts +6 -3
- package/src/cli/cmd_Bump.ts +3 -3
- package/src/cli/cmd_GlobalProcesses.ts +2 -107
- package/src/cli/cmd_Home.ts +1 -1
- package/src/cli/cmd_Overview.ts +2 -1
- package/src/cli/cmd_Rec.ts +349 -0
- package/src/cli/cmd_Releases.ts +42 -3
- package/src/cli/cmd_Review.ts +22 -13
- package/src/cli/cmd_Secret.ts +10 -3
- package/src/cli/cmd_Sign.ts +24 -0
- package/src/cli/cmd_Social.ts +57 -8
- package/src/cli/cmd_Sound.ts +17 -4
- package/src/cli/cmd_Trailer.ts +67 -1
- package/src/cli/family-pages.ts +1 -0
- package/src/cli/registry.ts +6 -1
- package/src/collections/collection-types.ts +1 -1
- package/src/collections/review.ts +23 -4
- package/src/core/agent-spawn.ts +4 -17
- package/src/core/code-lines.ts +49 -0
- package/src/core/discover-checks.ts +27 -3
- package/src/core/hard-reset.ts +34 -0
- package/src/core/layout.ts +6 -0
- package/src/core/raw-access.ts +3 -13
- package/src/core/throwaway-worktree.ts +72 -0
- package/src/home/app-sign.ts +98 -0
- package/src/home/gui-app/ShipkitGui.swift +35 -0
- package/src/home/gui-app.ts +31 -11
- package/src/home/home-routes.ts +6 -0
- package/src/home/pm-switch.ts +112 -0
- package/src/home/serve-web.ts +1 -1
- package/src/identities/identities.ts +17 -6
- package/src/media-kinds.ts +5 -3
- package/src/media-store/forget.ts +54 -0
- package/src/media-store/put.ts +4 -3
- package/src/media-store/space.ts +63 -24
- package/src/messages/brief.ts +3 -3
- package/src/messages/score.ts +2 -0
- package/src/recordings/delete.ts +19 -0
- package/src/recordings/edit.ts +231 -0
- package/src/recordings/load.ts +37 -0
- package/src/recordings/marks-draw.ts +111 -0
- package/src/recordings/marks-png.ts +25 -0
- package/src/recordings/marks.ts +138 -0
- package/src/recordings/media-kind.ts +67 -0
- package/src/recordings/model.ts +170 -0
- package/src/recordings/open.ts +33 -0
- package/src/recordings/place.ts +89 -0
- package/src/recordings/presets.ts +99 -0
- package/src/recordings/recorder-app/Capture.swift +510 -0
- package/src/recordings/recorder-app/Clip.swift +107 -0
- package/src/recordings/recorder-app/Editor.swift +39 -0
- package/src/recordings/recorder-app/Tray.swift +298 -0
- package/src/recordings/recorder-app/main.swift +859 -0
- package/src/recordings/recorder-app.ts +46 -0
- package/src/recordings/recorder.shipkit.ts +11 -0
- package/src/recordings/routes.ts +140 -0
- package/src/recordings/run-recorder.ts +40 -0
- package/src/recordings/share.ts +107 -0
- package/src/recordings/take.ts +146 -0
- package/src/recordings/view.ts +40 -0
- package/src/release/gate-checkout.ts +74 -0
- package/src/release/release-scope.ts +35 -26
- package/src/release/run-bump.ts +79 -37
- package/src/release/run-release.ts +67 -53
- package/src/releases/add.ts +38 -5
- package/src/releases/before.ts +31 -0
- package/src/releases/from-card.ts +105 -20
- package/src/releases/model.ts +100 -18
- package/src/releases/pictures.ts +29 -8
- package/src/repo-config.ts +7 -3
- package/src/review/http.ts +1 -1
- package/src/review/model.ts +12 -2
- package/src/review/stage-card.ts +1 -1
- package/src/review/store.ts +12 -2
- package/src/review/trailer-desk.ts +20 -0
- package/src/review/trailer-model.ts +67 -0
- package/src/review/trailer-routes.ts +98 -1
- package/src/review/trailer-voices.ts +144 -0
- package/src/review/watchers.ts +58 -1
- package/src/secrets/manager.ts +18 -1
- package/src/serve/hub-app/benign-errors.ts +22 -0
- package/src/serve/hub-app/hash-route.ts +27 -15
- package/src/serve/hub-app/home-st.ts +23 -5
- package/src/serve/hub-app/home.html +1 -0
- package/src/serve/hub-app/hub-app.tsx +8 -1
- package/src/serve/hub-app/icons.tsx +2 -0
- package/src/serve/hub-app/palette-st.ts +1 -0
- package/src/serve/hub-app/project-list.css +7 -2
- package/src/serve/hub-app/project-list.tsx +10 -0
- package/src/serve/hub-app/projects-svc.ts +17 -7
- package/src/serve/hub-app/recordings-st.ts +641 -0
- package/src/serve/hub-app/recordings-view.tsx +504 -0
- package/src/serve/hub-app/recordings.css +82 -0
- package/src/serve/hub-app/releases/releases-page.tsx +121 -28
- package/src/serve/hub-app/releases/releases-st.ts +46 -4
- package/src/serve/hub-app/releases.css +30 -3
- package/src/serve/hub-app/repo-sections.ts +1 -1
- package/src/serve/hub-app/repo-st.ts +16 -11
- package/src/serve/hub-app/review/clip-st.ts +3 -1
- package/src/serve/hub-app/review/kit.tsx +3 -3
- package/src/serve/hub-app/review/trailer-page.tsx +32 -6
- package/src/serve/hub-app/review/trailer-st.ts +184 -8
- package/src/serve/hub-app/review/trailer-timeline.tsx +39 -4
- package/src/serve/hub-app/review/trailer-voices-st.ts +370 -0
- package/src/serve/hub-app/review/trailer-voices.tsx +574 -0
- package/src/serve/hub-app/review.css +90 -0
- package/src/serve/hub-app/social/comms-page.tsx +10 -5
- package/src/serve/hub-app/social/next-release.tsx +118 -0
- package/src/serve/hub-app/social/post-card.tsx +31 -3
- package/src/serve/hub-app/social/social-model.ts +6 -0
- package/src/serve/hub-app/social/social-st.ts +50 -1
- package/src/serve/hub-app/social.css +12 -0
- package/src/serve/hub-app/tree-build.ts +2 -0
- package/src/serve/project-gutter-route.ts +8 -0
- package/src/serve/project-gutter.ts +4 -2
- package/src/shipkit.ts +2 -2
- package/src/shot/box.ts +49 -22
- package/src/shot/browser-slot.ts +13 -3
- package/src/shot/client.ts +1 -1
- package/src/shot/film-box.ts +193 -117
- package/src/shot/shooter.ts +20 -8
- package/src/smoke/run-smoke.ts +8 -6
- package/src/social/compose.ts +14 -0
- package/src/social/desk-index.ts +49 -8
- package/src/social/discord-layout.ts +6 -2
- package/src/social/drafts.ts +1 -1
- package/src/social/kinds.ts +3 -2
- package/src/social/load.ts +42 -9
- package/src/social/publish/index.ts +27 -10
- package/src/social/publish/secret.ts +12 -4
- package/src/social/release-card.ts +69 -0
- package/src/social/release-stage.ts +173 -30
- package/src/social/routes.ts +7 -1
- package/src/social/stage.ts +45 -22
- package/src/trailer/bed.ts +111 -0
- package/src/trailer/build.ts +81 -38
- package/src/trailer/ffmpeg.ts +14 -0
- package/src/trailer/grammar.ts +32 -4
- package/src/trailer/graph.ts +12 -1
- package/src/trailer/look.ts +7 -0
- package/src/trailer/shot-plan.ts +75 -0
- package/src/trailer/shot-state.ts +191 -0
- package/src/trailer/sound/audio.ts +28 -0
- package/src/trailer/sound/brand.ts +53 -3
- package/src/trailer/sound/gen.ts +61 -2
- package/src/trailer/sound/index.ts +25 -11
- package/src/trailer/sound/presets.ts +86 -5
- package/src/trailer/sound/run.ts +1 -1
- package/src/trailer/sound/takes.ts +94 -0
- package/src/trailer/titles.ts +36 -0
- package/src/trailer/url.ts +1 -1
- package/src/veille/chrome.ts +6 -3
package/src/trailer/build.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { filmLineOf, type Recipe, takesOf, trailerCache } from './footage.ts'
|
|
|
8
8
|
import type { BrandLike, TrailerLook } from './look.ts'
|
|
9
9
|
import { fresh, isTake, movedParts, type Refilm, recipeWords, type Take, takeIsStill, takesToFilm, type World, type WorldState, worldFor } from './plan.ts'
|
|
10
10
|
import { decodeStates, edgeChanges } from './states.ts'
|
|
11
|
+
import { type CardAnswer, type CutPlan, shotStatus, type ShotStatus, statusText, summaryOf, summaryText, type TakeFact, type TakeFacts } from './shot-state.ts'
|
|
11
12
|
import { type CompiledScore, compileScore } from './score/score.ts'
|
|
12
13
|
import { GROW_RES, type Source, titleMotions } from './graph.ts'
|
|
13
14
|
import type { TitleMotion } from './motion.ts'
|
|
@@ -118,6 +119,7 @@ export async function load(file: string, root: string, o: { text?: string; dir?:
|
|
|
118
119
|
l.errors.push(...findRecipes(l))
|
|
119
120
|
// the brand is read only for a cut that names one of its text styles: a check stays quick
|
|
120
121
|
if (namedStyles(t).length > 0) l.errors.push(...resolveStyles(t, (await brandStyles(root)) ?? {}))
|
|
122
|
+
if (l.errors.length === 0) l.errors.push(...(await recordingFiles(l)))
|
|
121
123
|
if (l.errors.length === 0) l.errors.push(...checkFiles(l))
|
|
122
124
|
if (l.errors.length === 0 && t.score) {
|
|
123
125
|
const c = compileScore(t.score, t.sections, trailerCache(root, 'score'))
|
|
@@ -261,6 +263,28 @@ export async function fontLines(l: Loaded): Promise<string[]> {
|
|
|
261
263
|
return [...seen.values()]
|
|
262
264
|
}
|
|
263
265
|
|
|
266
|
+
/** each `film recording` shot's file: what the recording plays (its export, else its take), fetched back from the
|
|
267
|
+
* annex or the Space when the disk let it go. A bare name looks in this repo first */
|
|
268
|
+
async function recordingFiles(l: Loaded): Promise<TrailerError[]> {
|
|
269
|
+
const shots = l.t.shots.filter((s) => s.film?.kind === 'clip' && s.film.recording !== undefined)
|
|
270
|
+
if (shots.length === 0) return []
|
|
271
|
+
const { findRecording, currentFile } = await import('../recordings/model.ts')
|
|
272
|
+
const { fileBack } = await import('../recordings/take.ts')
|
|
273
|
+
const out: TrailerError[] = []
|
|
274
|
+
for (const s of shots) {
|
|
275
|
+
const f = s.film as Extract<Film, { kind: 'clip' }>
|
|
276
|
+
try {
|
|
277
|
+
const ref = f.recording!
|
|
278
|
+
const r = await findRecording(ref, ref.includes('/') ? {} : { repo: basename(l.root) }).catch(() => findRecording(ref))
|
|
279
|
+
if (r.still) throw new Error(`${ref} is a still: film image reads one`)
|
|
280
|
+
f.path = await fileBack(r, currentFile(r))
|
|
281
|
+
} catch (e) {
|
|
282
|
+
out.push({ line: f.line, message: `film recording: ${(e as Error).message}` })
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return out
|
|
286
|
+
}
|
|
287
|
+
|
|
264
288
|
/** the clips, images and sound files the lines name, each found where it should be */
|
|
265
289
|
function checkFiles(l: Loaded): TrailerError[] {
|
|
266
290
|
const out: TrailerError[] = []
|
|
@@ -299,15 +323,15 @@ export function soundIds(t: Trailer): { line: number; kind: 'music' | 'sfx' | 'v
|
|
|
299
323
|
}
|
|
300
324
|
|
|
301
325
|
/** a sound that is no plain file: the repo's unit first (an id it knows), else the house's maker (a prompt, a run, a
|
|
302
|
-
* `.mid`, an id the unit answers null) */
|
|
303
|
-
export async function soundFile(l: Pick<Loaded, 'root' | 'file' | 'unit'>, req: SoundRequest, say: Say): Promise<string> {
|
|
326
|
+
* `.mid`, an id the unit answers null); `takes` forces his takes on or off (sound/index.ts brandSound) */
|
|
327
|
+
export async function soundFile(l: Pick<Loaded, 'root' | 'file' | 'unit'>, req: SoundRequest, say: Say, takes?: boolean): Promise<string> {
|
|
304
328
|
const unit = l.unit
|
|
305
329
|
const own = houseOnly(req) ? null : req.kind === 'music' ? unit?.sound?.music && ((x: string) => unit.sound!.music!(x, { ...(req.take ? { take: req.take } : {}), seconds: req.seconds ?? 0 })) : req.kind === 'sfx' ? unit?.sound?.sfx : unit?.sound?.voice
|
|
306
330
|
const got = own ? await own(req.text) : null
|
|
307
331
|
if (got) return got
|
|
308
332
|
const house = await houseSound()
|
|
309
333
|
if (!house) throw new Refused(`${relative(l.root, l.file)}:${req.line}: ${req.kind} ${req.run ? 'run' : req.prompt ? `"${req.text}"` : req.text} is no file, and neither a trailer unit (a <name>.shipkit.ts default-exporting trailer({ sound })) nor the house's sound maker makes it`)
|
|
310
|
-
return house.resolveSound(l.root, req, say)
|
|
334
|
+
return house.resolveSound(l.root, req, say, takes)
|
|
311
335
|
}
|
|
312
336
|
|
|
313
337
|
/** a request the repo's unit never sees: a prompt, a run, a `.mid` */
|
|
@@ -362,9 +386,9 @@ export async function soundLines(l: Loaded): Promise<string[]> {
|
|
|
362
386
|
}
|
|
363
387
|
|
|
364
388
|
/** the house's sound maker (design call 9, src/trailer/sound/index.ts), null until it exists */
|
|
365
|
-
async function houseSound(): Promise<{ resolveSound(root: string, req: SoundRequest, say: Say): Promise<string> } | null> {
|
|
389
|
+
async function houseSound(): Promise<{ resolveSound(root: string, req: SoundRequest, say: Say, takes?: boolean): Promise<string> } | null> {
|
|
366
390
|
const p = join(import.meta.dir, 'sound', 'index.ts')
|
|
367
|
-
return existsSync(p) ? ((await import(p)) as { resolveSound(root: string, req: SoundRequest, say: Say): Promise<string> }) : null
|
|
391
|
+
return existsSync(p) ? ((await import(p)) as { resolveSound(root: string, req: SoundRequest, say: Say, takes?: boolean): Promise<string> }) : null
|
|
368
392
|
}
|
|
369
393
|
|
|
370
394
|
/** the errors, which stop the build, then the warnings, which do not */
|
|
@@ -374,13 +398,9 @@ export function sayErrors(l: Loaded, say: Say, cwd: string): boolean {
|
|
|
374
398
|
return l.errors.length === 0
|
|
375
399
|
}
|
|
376
400
|
|
|
377
|
-
const ago = (iso: string): string => {
|
|
378
|
-
const m = Math.round((Date.now() - Date.parse(iso)) / 60_000)
|
|
379
|
-
return m < 60 ? `${m} min ago` : m < 48 * 60 ? `${Math.round(m / 60)} h ago` : `${Math.round(m / 1440)} days ago`
|
|
380
|
-
}
|
|
381
|
-
|
|
382
401
|
const filmText = (f: Film | null): string => {
|
|
383
402
|
if (!f) return 'nothing'
|
|
403
|
+
if (f.kind === 'clip' && f.recording !== undefined) return `recording ${f.recording}`
|
|
384
404
|
if (f.kind === 'clip' || f.kind === 'image') return `${f.kind} ${f.path}`
|
|
385
405
|
if (f.kind === 'run') return `run "${f.cmd}"${f.still ? ' still' : ''}`
|
|
386
406
|
if (f.kind === 'cli') return f.argv.join(' ')
|
|
@@ -400,46 +420,68 @@ function edgesOf(s: Shot, tk: Take, fps: number, rule: TrailerUnit['states']): s
|
|
|
400
420
|
return found.length > 0 ? `, AT ITS EDGES: ${found.join('; ')}` : ''
|
|
401
421
|
}
|
|
402
422
|
|
|
403
|
-
/**
|
|
404
|
-
*
|
|
405
|
-
export function
|
|
423
|
+
/** each shot's and footage block's take against the world: filmed or not, when, the parts that moved since; what the
|
|
424
|
+
* timeline says and what the hub's trailer page reads (shot-plan.ts writeFacts) */
|
|
425
|
+
export function takeFactsOf(l: Pick<Loaded, 't'>, takes: readonly Take[], world: World | null, now = new Date()): TakeFacts {
|
|
426
|
+
const takeOf = (s: Shot): Take | undefined => takes.find((x) => x.shot === s)
|
|
427
|
+
const filmed = (s: Shot | undefined): boolean => s !== undefined && (!isTake(s.film) || takeOf(s)?.stamp != null)
|
|
428
|
+
const factOf = (s: Shot): TakeFact => {
|
|
429
|
+
const f = s.film
|
|
430
|
+
if (f?.kind === 'grid' || f?.kind === 'split') {
|
|
431
|
+
const cells = gridCells(l.t, f.cells)
|
|
432
|
+
const n = cells.filter(filmed).length
|
|
433
|
+
return { kind: 'grid', filmed: n === cells.length, cells: { of: cells.length, filmed: n } }
|
|
434
|
+
}
|
|
435
|
+
if (!isTake(f)) return { kind: f?.kind === 'card' ? 'drawn' : 'file', filmed: true }
|
|
436
|
+
const tk = takeOf(s)
|
|
437
|
+
if (!tk?.stamp) return { kind: 'take', filmed: false }
|
|
438
|
+
const w = world === null ? null : worldFor(world, tk)
|
|
439
|
+
return { kind: 'take', filmed: true, filmedAt: tk.stamp.filmedAt, ...(w && !fresh(tk.stamp, w) ? { moved: movedParts(tk.stamp, w) ?? [] } : {}) }
|
|
440
|
+
}
|
|
441
|
+
return { at: now.toISOString(), shots: Object.fromEntries([...l.t.shots, ...l.t.footage].map((s) => [s.name, factOf(s)])) }
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/** the timeline with the cut's plan and its cards' answers; the takes' facts written for the hub's trailer page unless
|
|
445
|
+
* `record` is false (a draft's takes are not the cut's) */
|
|
446
|
+
export async function planTimeline(l: Loaded, takes: readonly Take[], world: World | null, cwd: string, record = true): Promise<string[]> {
|
|
447
|
+
const { cutIdOf, readPlan, cardAnswers, writeFacts } = await import('./shot-plan.ts')
|
|
448
|
+
const { trailer, cut } = cutIdOf(l.file)
|
|
449
|
+
if (record) writeFacts(l.root, trailer, cut, takeFactsOf(l, takes, world))
|
|
450
|
+
const plan = readPlan(l.root, trailer, cut)
|
|
451
|
+
return timeline(l, takes, world, cwd, { plan, cards: await cardAnswers(l.root, plan) })
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/** the timeline, one line a shot then one a footage block, each shot's state in plain words (shot-state.ts: the
|
|
455
|
+
* lanes' plan over its take), its take's details: when and on which world it was filmed, its last frame held, a
|
|
456
|
+
* change at its edges; then the cut at a glance */
|
|
457
|
+
export function timeline(l: Loaded, takes: readonly Take[], world: World | null, cwd: string, o: { plan?: CutPlan; cards?: (id: string) => CardAnswer | null } = {}): string[] {
|
|
406
458
|
const st = starts(l.t)
|
|
407
459
|
const out = [`${relative(cwd, l.file)}: ${l.t.shots.length} shots, ${total(l.t).toFixed(2)} s, ${l.t.size.join('x')} at ${l.t.fps} fps`]
|
|
408
460
|
const takeOf = (s: Shot): Take | undefined => takes.find((x) => x.shot === s)
|
|
461
|
+
const facts = takeFactsOf(l, takes, world)
|
|
462
|
+
const statusOf = (s: Shot): ShotStatus => {
|
|
463
|
+
const e = o.plan?.shots[s.name]
|
|
464
|
+
return shotStatus(e, facts.shots[s.name], e?.card ? (o.cards?.(e.card) ?? null) : null)
|
|
465
|
+
}
|
|
409
466
|
const line = (s: Shot, head: string): void => {
|
|
410
467
|
const tk = takeOf(s)
|
|
411
|
-
const
|
|
412
|
-
const
|
|
413
|
-
const
|
|
414
|
-
f?.kind === 'grid' || f?.kind === 'split'
|
|
415
|
-
? `a ${f.kind} of ${cells.length}, ${cells.filter((c) => c?.stamp).length} filmed`
|
|
416
|
-
: !isTake(f)
|
|
417
|
-
? f?.kind === 'card' ? 'drawn' : 'a file'
|
|
418
|
-
: !tk?.stamp
|
|
419
|
-
? 'NOT FILMED'
|
|
420
|
-
: world === null || fresh(tk.stamp, worldFor(world, tk))
|
|
421
|
-
? 'filmed'
|
|
422
|
-
: `filmed on an older world, ${ago(tk.stamp.filmedAt)}${movedText(movedParts(tk.stamp, worldFor(world, tk)))} (--refilm ${s.name})`
|
|
468
|
+
const status = statusOf(s)
|
|
469
|
+
const refilm = facts.shots[s.name]?.moved !== undefined ? ` (--refilm ${s.name})` : ''
|
|
470
|
+
const detail = status.detail.length > 0 ? ` · ${status.detail.join('; ')}${refilm}` : ''
|
|
423
471
|
const held = tk?.stamp && !takeIsStill(tk.film) && tk.stamp.seconds - s.from < s.length - 0.05 ? `, its last frame held ${(s.length - (tk.stamp.seconds - s.from)).toFixed(2)} s` : ''
|
|
424
472
|
const edges = tk ? edgesOf(s, tk, l.t.fps, l.unit?.states) : ''
|
|
425
473
|
const sec = s.section ? ` [section ${s.section.name} at ${+s.section.at.toFixed(3)} s]` : ''
|
|
426
474
|
const fit = s.written !== undefined ? ` (fitted, written ${s.written} s)` : ''
|
|
427
|
-
out.push(` ${head} ${s.name.padEnd(20)} ${s.length.toFixed(2).padStart(5)} s${fit} ${
|
|
475
|
+
out.push(` ${head} ${s.name.padEnd(20)} ${s.length.toFixed(2).padStart(5)} s${fit} ${statusText(status)}${detail}${held}${edges}${sec}`)
|
|
428
476
|
}
|
|
429
477
|
l.t.shots.forEach((s, i) => line(s, `${String(i + 1).padStart(2)} ${st[i]!.toFixed(2).padStart(6)} s `))
|
|
430
478
|
for (const s of l.t.footage) line(s, ' footage ')
|
|
431
479
|
const sc = l.score
|
|
432
480
|
if (sc) out.push(` score: ${sc.sections.length} sections, ${sc.notes.length} notes, ${(sc.seconds - SCORE_LEAD).toFixed(2)} s from the cut's ${(l.t.timelineAt ?? 0).toFixed(2)} s${sc.stop !== null ? `, cut dead at its ${(sc.stop - SCORE_LEAD).toFixed(2)} s` : ''}`)
|
|
481
|
+
out.push(` ${summaryText(summaryOf(l.t.shots.map((s) => ({ name: s.name, status: statusOf(s) }))))}`)
|
|
433
482
|
return out
|
|
434
483
|
}
|
|
435
484
|
|
|
436
|
-
/** the parts of the world that moved, as the timeline says them; nothing when the stamp kept no parts */
|
|
437
|
-
function movedText(parts: string[] | null): string {
|
|
438
|
-
if (parts === null || parts.length === 0) return ''
|
|
439
|
-
const shown = parts.slice(0, 4).join(', ')
|
|
440
|
-
return `: ${shown}${parts.length > 4 ? ` and ${parts.length - 4} more` : ''} moved`
|
|
441
|
-
}
|
|
442
|
-
|
|
443
485
|
function secs(x: number): string {
|
|
444
486
|
return `${+x.toFixed(2)} s`
|
|
445
487
|
}
|
|
@@ -548,9 +590,9 @@ export async function scoreFile(l: Loaded, seconds: number, say: Say): Promise<s
|
|
|
548
590
|
}
|
|
549
591
|
|
|
550
592
|
/** every sound the shots play, made where the house or the unit has to: the music cues, each shot's sfx and voices */
|
|
551
|
-
async function soundsOf(l: Loaded, shots: readonly Shot[], say: Say) {
|
|
593
|
+
export async function soundsOf(l: Loaded, shots: readonly Shot[], say: Say, takes?: boolean) {
|
|
552
594
|
const { durationOf } = await import('./ffmpeg.ts')
|
|
553
|
-
const resolve = (req: SoundRequest): Promise<string> => soundFile(l, req, say)
|
|
595
|
+
const resolve = (req: SoundRequest): Promise<string> => soundFile(l, req, say, takes)
|
|
554
596
|
const ask = (kind: SoundRequest['kind'], text: string, x: { prompt?: true; gen?: SoundGen; run?: SoundRun; line: number }, seconds?: number, take?: string): SoundRequest => soundRequest(kind, text, x, l.dir, seconds, take)
|
|
555
597
|
const music = await timed('sounds', () => Promise.all(
|
|
556
598
|
musicCues(l.t).map(({ cue, at, end }) => {
|
|
@@ -574,7 +616,7 @@ async function soundsOf(l: Loaded, shots: readonly Shot[], say: Say) {
|
|
|
574
616
|
/** everything the stitch reads but its output: sources, titles, sounds (`sounds` when the caller started them), the look */
|
|
575
617
|
async function stitchInput(l: Loaded, takes: readonly Take[], shots: readonly Shot[], silent: boolean, say: Say = () => undefined, sounds?: ReturnType<typeof soundsOf>) {
|
|
576
618
|
const { gridMask, splitMasks } = await import('./stitch.ts')
|
|
577
|
-
const [{ cardPng, titlePng }, { lookOf }, { durationOf }, { trailerCache }, { loadBrand, identityLogo }] = await Promise.all([
|
|
619
|
+
const [{ bandHeight, bandPng, cardPng, titlePng }, { lookOf }, { durationOf }, { trailerCache }, { loadBrand, identityLogo }] = await Promise.all([
|
|
578
620
|
import('./titles.ts'),
|
|
579
621
|
import('./look.ts'),
|
|
580
622
|
import('./ffmpeg.ts'),
|
|
@@ -584,8 +626,9 @@ async function stitchInput(l: Loaded, takes: readonly Take[], shots: readonly Sh
|
|
|
584
626
|
const brand = await loadBrand(l.root)
|
|
585
627
|
if (typeof brand === 'string') throw new Refused(brand)
|
|
586
628
|
const look = lookOf(brand, await identityLogo(l.root))
|
|
587
|
-
const base = { look, brand }
|
|
588
629
|
const titles = trailerCache(l.root, 'titles')
|
|
630
|
+
const b = l.t.band
|
|
631
|
+
const base = { look, brand, ...(b ? { band: { file: bandPng(titles, b.text, l.t.size, look, l.root), h: bandHeight(l.t.size[1]), over: b.over } } : {}) }
|
|
589
632
|
const pieces = trailerCache(l.root, 'pieces')
|
|
590
633
|
const takeOf = (s: Shot): Take | undefined => takes.find((x) => x.shot === s) ?? takes.find((x) => x.shot.name === s.name)
|
|
591
634
|
const sources = await Promise.all(shots.map(async (s): Promise<Source> => {
|
|
@@ -732,7 +775,7 @@ export async function build(l: Loaded, o: BuildOptions): Promise<string> {
|
|
|
732
775
|
}
|
|
733
776
|
}
|
|
734
777
|
if (!small) writeFileSync(join(outDir(l), `${l.t.name}.montage.md`), montage(l.t, basename(l.file)))
|
|
735
|
-
for (const line of
|
|
778
|
+
for (const line of await planTimeline(l, takes, world, o.cwd, !small)) o.say(line)
|
|
736
779
|
const what = small ? `a draft at ${small.size.join('x')}, ` : ''
|
|
737
780
|
o.say(`ok: ${out} (${what}${(finished?.seconds ?? total(lv.t)).toFixed(2)} s) in ${((performance.now() - t0) / 1000).toFixed(1)} s: filming ${((tFilm - t0) / 1000).toFixed(1)} s, ${rendered(done)}${finished ? `, ${finished.note}` : ''}`)
|
|
738
781
|
if (withStrip) o.say(`ok: ${stripFile}`)
|
package/src/trailer/ffmpeg.ts
CHANGED
|
@@ -49,6 +49,14 @@ export function probeMedia(file: string): { duration: number; video: { width: nu
|
|
|
49
49
|
return { duration: d, video: v?.width && v.height ? { width: v.width, height: v.height } : null }
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/** an image's size in pixels, by one ffprobe; throws when it holds no picture */
|
|
53
|
+
export function imageSize(file: string): { width: number; height: number } {
|
|
54
|
+
const r = Bun.spawnSync([FFPROBE, '-v', 'error', '-select_streams', 'v:0', '-show_entries', 'stream=width,height', '-of', 'csv=p=0:s=x', file], { stdout: 'pipe', stderr: 'pipe' })
|
|
55
|
+
const m = /^(\d+)x(\d+)/.exec(r.stdout.toString().trim())
|
|
56
|
+
if (r.exitCode !== 0 || !m) throw new Error(`ffprobe ${file}: ${r.stderr.toString().trim() || 'no picture'}`)
|
|
57
|
+
return { width: Number(m[1]), height: Number(m[2]) }
|
|
58
|
+
}
|
|
59
|
+
|
|
52
60
|
const probed = new Map<string, Promise<number>>()
|
|
53
61
|
|
|
54
62
|
/** a media file's length like `duration`, probed once per file and state in this process, the probes side by side: a
|
|
@@ -88,6 +96,12 @@ export async function loudness(file: string): Promise<{ lufs: number; truePeak:
|
|
|
88
96
|
return { lufs, truePeak }
|
|
89
97
|
}
|
|
90
98
|
|
|
99
|
+
/** each channel's RMS level in dB, in channel order; a silent channel -120 */
|
|
100
|
+
export async function channelLevels(file: string): Promise<number[]> {
|
|
101
|
+
const log = await ffmpeg(['-nostats', '-loglevel', 'info', '-i', file, '-map', '0:a', '-af', 'astats=measure_overall=none:measure_perchannel=RMS_level', '-f', 'null', '-'])
|
|
102
|
+
return [...log.matchAll(/RMS level dB: (\S+)/g)].map((m) => (m[1] === '-inf' ? -120 : Math.max(-120, Number(m[1]))))
|
|
103
|
+
}
|
|
104
|
+
|
|
91
105
|
/** loudness() of a file that never changes under its name (a cached render), kept beside it */
|
|
92
106
|
export async function loudnessKept(file: string): Promise<{ lufs: number; truePeak: number }> {
|
|
93
107
|
const json = `${file}.loudness.json`
|
package/src/trailer/grammar.ts
CHANGED
|
@@ -58,7 +58,7 @@ export type CutKind = 'hard' | 'fade' | 'fade-fast' | 'fade-slow' | 'dissolve' |
|
|
|
58
58
|
| 'open-h' | 'close-h' | 'open-v' | 'close-v' | 'circle' | 'circle-close' | 'circle-crop' | 'rect-crop' | 'pixel' | 'glitch' | 'leak'
|
|
59
59
|
/** a drawn cut's length when its line names none: a whip snaps, a leak burns slowly */
|
|
60
60
|
export const CUT_SECONDS: Partial<Record<CutKind, number>> = { 'whip-left': 0.35, 'whip-right': 0.35, 'whip-up': 0.35, 'whip-down': 0.35, glitch: 0.3, leak: 0.8 }
|
|
61
|
-
export const CORE_FILMS = ['clip', 'image', 'card', 'run', 'url', 'page', 'grid', 'split'] as const
|
|
61
|
+
export const CORE_FILMS = ['clip', 'recording', 'image', 'card', 'run', 'url', 'page', 'grid', 'split'] as const
|
|
62
62
|
|
|
63
63
|
/** the most frames a second a cut runs at */
|
|
64
64
|
export const FPS_MAX = 60
|
|
@@ -93,7 +93,8 @@ export const SPLIT_ANGLE: Readonly<Record<number, number>> = { 2: 56, 3: 14 }
|
|
|
93
93
|
export const SPLIT_SLIDE = 0.3
|
|
94
94
|
|
|
95
95
|
export type Film =
|
|
96
|
-
|
|
96
|
+
/** a video file; `recording`: a take of the screen recorder (`film recording <name>`), its file found at load */
|
|
97
|
+
| { kind: 'clip'; line: number; path: string; recording?: string }
|
|
97
98
|
| { kind: 'image'; line: number; path: string }
|
|
98
99
|
| { kind: 'card'; line: number }
|
|
99
100
|
/** any command that writes the take at `{out}`; `still`: it writes an image, held for the shot; `reads`: the files
|
|
@@ -137,6 +138,14 @@ export interface Vertical {
|
|
|
137
138
|
outro: 'card' | 'none' | { clip: string }
|
|
138
139
|
}
|
|
139
140
|
|
|
141
|
+
/** a thin band of words across the top of every frame (`band "<text>" [over]`): in a strip of its own, the picture
|
|
142
|
+
* scaled under it so it covers nothing; `over`: laid over the picture's top instead */
|
|
143
|
+
export interface Band {
|
|
144
|
+
line: number
|
|
145
|
+
text: string
|
|
146
|
+
over: boolean
|
|
147
|
+
}
|
|
148
|
+
|
|
140
149
|
/** the size a vertical short films at when the file names none */
|
|
141
150
|
export const VERTICAL_SIZE: [number, number] = [1080, 1920]
|
|
142
151
|
|
|
@@ -216,6 +225,9 @@ export interface SoundRun {
|
|
|
216
225
|
reads?: string[]
|
|
217
226
|
/** the work runs on another machine (ElevenLabs, the comfy box): it never waits on this machine's load */
|
|
218
227
|
remote?: true
|
|
228
|
+
/** the work is a second of ffmpeg on this machine (his take levelled): it never waits on the load either, which is
|
|
229
|
+
* for a render that loads it (FluidSynth) */
|
|
230
|
+
light?: true
|
|
219
231
|
}
|
|
220
232
|
|
|
221
233
|
export interface Sfx {
|
|
@@ -410,6 +422,8 @@ export interface Trailer {
|
|
|
410
422
|
timelineAt: number | null
|
|
411
423
|
/** the cut is a vertical short (`vertical`), finished with the brand's lockup, watermark and end card */
|
|
412
424
|
vertical: Vertical | null
|
|
425
|
+
/** the band across the top of every frame (`band "<text>"`); null: none */
|
|
426
|
+
band: Band | null
|
|
413
427
|
/** the global process whose url a `film url` route resolves against (`base <id>`); null: the repo's one */
|
|
414
428
|
base: string | null
|
|
415
429
|
/** the music variants the file names, and the one it was read as (null: it names none) */
|
|
@@ -840,6 +854,12 @@ function coreFilm(kind: string, ws: Word[], line: number): Film {
|
|
|
840
854
|
pairs(`film clip ${path}`, ws.slice(2), {})
|
|
841
855
|
return { kind, line, path }
|
|
842
856
|
}
|
|
857
|
+
case 'recording': {
|
|
858
|
+
const ref = ws[1]?.text ?? ''
|
|
859
|
+
if (!/^([a-z0-9][a-z0-9-]*\/)?[a-z0-9][a-z0-9-]*$/.test(ref)) bad(`film recording wants a recording's name, or <repo>/<name> (sk rec lists them), got ${ref || 'nothing'}`)
|
|
860
|
+
pairs(`film recording ${ref}`, ws.slice(2), {})
|
|
861
|
+
return { kind: 'clip', line, path: '', recording: ref }
|
|
862
|
+
}
|
|
843
863
|
case 'image': {
|
|
844
864
|
const path = pathWord('film image', ws[1])
|
|
845
865
|
if (!/\.(png|jpe?g|webp)$/i.test(path)) bad(`film image wants an image file (.png, .jpg, .webp), got ${path}`)
|
|
@@ -1065,7 +1085,7 @@ export function parseTrailer(text: string, o: ParseOptions = {}): { trailer: Tra
|
|
|
1065
1085
|
const verbs = o.verbs ?? null
|
|
1066
1086
|
const variants = variantsOf(text)
|
|
1067
1087
|
const variant = o.variant ?? variants[0] ?? null
|
|
1068
|
-
const t: Trailer = { name: '', footage: [], size: [1920, 1080], fps: 30, music: null, duck: -10, duckSfx: null, master: null, fadeIn: 0, shots: [], sections: [], score: null, timelineAt: null, vertical: null, base: null, variants, variant }
|
|
1088
|
+
const t: Trailer = { name: '', footage: [], size: [1920, 1080], fps: 30, music: null, duck: -10, duckSfx: null, master: null, fadeIn: 0, shots: [], sections: [], score: null, timelineAt: null, vertical: null, band: null, base: null, variants, variant }
|
|
1069
1089
|
/** a music line of another variant plays elsewhere; one of this variant takes the place of the line with none */
|
|
1070
1090
|
const mine = (m: Music, had: Music | null, what: string): boolean => {
|
|
1071
1091
|
if (m.variant !== undefined && m.variant !== variant) return false
|
|
@@ -1286,6 +1306,14 @@ export function parseTrailer(text: string, o: ParseOptions = {}): { trailer: Tra
|
|
|
1286
1306
|
t.vertical = { line: n, outro: (p.outro as Vertical['outro'] | undefined) ?? 'card', ...(p.mark ? { mark: p.mark as 'left' | 'right' } : {}) }
|
|
1287
1307
|
break
|
|
1288
1308
|
}
|
|
1309
|
+
case 'band': {
|
|
1310
|
+
once('band')
|
|
1311
|
+
const [text, ...more] = rest
|
|
1312
|
+
if (!text?.quoted || text.text.trim() === '' || more.some((w) => w.quoted || w.text !== 'over') || more.length > 1)
|
|
1313
|
+
bad(`band wants its words in quotes, then over or nothing (band "WIP - alpha version"), got ${rest.map((w) => (w.quoted ? `"${w.text}"` : w.text)).join(' ') || 'nothing'}`)
|
|
1314
|
+
t.band = { line: n, text: text!.text, over: more.length === 1 }
|
|
1315
|
+
break
|
|
1316
|
+
}
|
|
1289
1317
|
case 'preset': {
|
|
1290
1318
|
const name = word('preset', rest[0], /^[a-z][a-z0-9-]*$/)
|
|
1291
1319
|
if (presets.has(name)) bad(`preset ${name} is already a preset of this file`)
|
|
@@ -1336,7 +1364,7 @@ export function parseTrailer(text: string, o: ParseOptions = {}): { trailer: Tra
|
|
|
1336
1364
|
break
|
|
1337
1365
|
}
|
|
1338
1366
|
default:
|
|
1339
|
-
bad(`unknown word ${head.text} before the first shot (trailer, size, fps, music, duck, master, fade-in, vertical, base, preset, score, track, drums, section, defaults, shot)`)
|
|
1367
|
+
bad(`unknown word ${head.text} before the first shot (trailer, size, fps, music, duck, master, fade-in, vertical, band, base, preset, score, track, drums, section, defaults, shot)`)
|
|
1340
1368
|
}
|
|
1341
1369
|
continue
|
|
1342
1370
|
}
|
package/src/trailer/graph.ts
CHANGED
|
@@ -51,6 +51,9 @@ export interface StitchInput {
|
|
|
51
51
|
/** each voice line's file and its length, shot by shot */
|
|
52
52
|
voices: { file: string; seconds: number }[][]
|
|
53
53
|
look: TrailerLook
|
|
54
|
+
/** the band across the top of every frame: its PNG (the frame's width, `h` tall); `over` the picture, else in a
|
|
55
|
+
* strip of its own with the picture scaled under it */
|
|
56
|
+
band?: { file: string; h: number; over: boolean }
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
const n3 = (x: number): string => (+x.toFixed(4)).toString()
|
|
@@ -293,7 +296,7 @@ export function titleMotions(t: Pick<Trailer, 'shots' | 'fps'> & Parameters<type
|
|
|
293
296
|
|
|
294
297
|
/** the ffmpeg arguments that render a piece's frames, no sound, and the row of its shots' middle frames for the
|
|
295
298
|
* contact strip (`thumbs`, when a middle falls in it) */
|
|
296
|
-
export function pieceArgs(a: Pick<StitchInput, 't' | 'sources' | 'titles' | 'look'>, p: Piece, out: string, encoder: Encoder = 'draft', thumbs?: string): string[] {
|
|
299
|
+
export function pieceArgs(a: Pick<StitchInput, 't' | 'sources' | 'titles' | 'look' | 'band'>, p: Piece, out: string, encoder: Encoder = 'draft', thumbs?: string): string[] {
|
|
297
300
|
const { t } = a
|
|
298
301
|
const [W, H] = t.size
|
|
299
302
|
const fps = t.fps
|
|
@@ -492,6 +495,14 @@ export function pieceArgs(a: Pick<StitchInput, 't' | 'sources' | 'titles' | 'loo
|
|
|
492
495
|
cur = `v${i}_${j}`
|
|
493
496
|
})
|
|
494
497
|
})
|
|
498
|
+
// the band over every frame, titles and the ending included; in its own strip the picture is scaled under it,
|
|
499
|
+
// centred, so the band covers no face and no row of a page
|
|
500
|
+
if (a.band) {
|
|
501
|
+
const k = input('-i', a.band.file)
|
|
502
|
+
const under = a.band.over ? '' : `scale=${even((W * (H - a.band.h)) / H)}:${H - a.band.h},pad=${W}:${H}:(ow-iw)/2:${a.band.h}:color=${ff(a.look.edge)},setsar=1,`
|
|
503
|
+
graph.push(`[${cur}]${under}format=yuv420p[under]`, `[under][${k}:v]overlay=x=0:y=0:eof_action=repeat[band]`)
|
|
504
|
+
cur = 'band'
|
|
505
|
+
}
|
|
495
506
|
graph.push(`[${cur}]trim=end_frame=${p.to - base},format=yuv420p,${TAGS}[vout]`)
|
|
496
507
|
|
|
497
508
|
// the contact strip's row: the middle frame of each shot whose middle is in the piece, side by side
|
package/src/trailer/look.ts
CHANGED
|
@@ -92,6 +92,13 @@ export function darker(c: string, k: number): string {
|
|
|
92
92
|
return rgb ? hex(rgb.map((v) => v * (1 - k))) : c
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/** the colour mixed toward `toward` by `t`, 0 to 1; a colour that is not hex stays as it is */
|
|
96
|
+
export function mixed(c: string, toward: string, t: number): string {
|
|
97
|
+
const a = rgbOf(c)
|
|
98
|
+
const b = rgbOf(toward)
|
|
99
|
+
return a && b ? hex(a.map((v, i) => v + (b[i]! - v) * t)) : c
|
|
100
|
+
}
|
|
101
|
+
|
|
95
102
|
/** relative luminance, 0 dark to 1 light; 0.5 for a colour that is not hex */
|
|
96
103
|
export function luminance(c: string): number {
|
|
97
104
|
const rgb = rgbOf(c)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// a cut's plan and its takes' facts on disk (wiki tools/trailer/index.md, Shot states): the plan the lanes write through
|
|
2
|
+
// `sk trailer plan`, `.shipkit/trailer-plan/<trailer>/<cut>.json`, and the takes as the last build or check read them,
|
|
3
|
+
// `.shipkit/cache/trailer-takes/<trailer>--<cut>.json`, so the hub reads both without loading a cut. A plan write
|
|
4
|
+
// holds the file's lock over its read and write: two lanes marking at once both land
|
|
5
|
+
import { existsSync, mkdirSync, readFileSync } from 'node:fs'
|
|
6
|
+
import { basename, dirname, join } from 'node:path'
|
|
7
|
+
import { LAYOUT } from '../core/layout.ts'
|
|
8
|
+
import { atomicWrite, withFileLock } from '../core/locked-write.ts'
|
|
9
|
+
import { isApproved, type ReviewItem, verdictOf } from '../review/model.ts'
|
|
10
|
+
import { type CardAnswer, markShots, parsePlan, type CutPlan, type PlanEntry, type TakeFacts } from './shot-state.ts'
|
|
11
|
+
|
|
12
|
+
export const planFile = (root: string, trailer: string, cut: string): string => join(root, LAYOUT.trailerPlan, trailer, `${cut}.json`)
|
|
13
|
+
export const factsFile = (root: string, trailer: string, cut: string): string => join(root, LAYOUT.cache, 'trailer-takes', `${trailer}--${cut}.json`)
|
|
14
|
+
|
|
15
|
+
/** a loaded cut's trailer folder and cut: `trailer/<trailer>/<cut>.trailer` */
|
|
16
|
+
export const cutIdOf = (file: string): { trailer: string; cut: string } => ({ trailer: basename(dirname(file)), cut: basename(file, '.trailer') })
|
|
17
|
+
|
|
18
|
+
/** the cut's plan, empty when no lane wrote one; a file that does not parse fails loud */
|
|
19
|
+
export function readPlan(root: string, trailer: string, cut: string): CutPlan {
|
|
20
|
+
const f = planFile(root, trailer, cut)
|
|
21
|
+
if (!existsSync(f)) return { shots: {} }
|
|
22
|
+
try {
|
|
23
|
+
return parsePlan(readFileSync(f, 'utf8'))
|
|
24
|
+
} catch (e) {
|
|
25
|
+
throw new Error(`${f}: ${(e as Error).message} (sk trailer plan writes it; delete it to start the plan again)`)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** these shots marked in the cut's plan, or their entries dropped (`mark` null); the plan as written */
|
|
30
|
+
export function writePlan(root: string, trailer: string, cut: string, shots: readonly string[], mark: Omit<PlanEntry, 'at'> | null, at = new Date().toISOString()): CutPlan {
|
|
31
|
+
const f = planFile(root, trailer, cut)
|
|
32
|
+
mkdirSync(dirname(f), { recursive: true })
|
|
33
|
+
for (let i = 0; i < 40; i++) {
|
|
34
|
+
const got = withFileLock(f, () => {
|
|
35
|
+
const next = markShots(readPlan(root, trailer, cut), shots, mark, at)
|
|
36
|
+
atomicWrite(f, `${JSON.stringify(next, null, 2)}\n`)
|
|
37
|
+
return next
|
|
38
|
+
})
|
|
39
|
+
if (got.ok) return got.value
|
|
40
|
+
Bun.sleepSync(50)
|
|
41
|
+
}
|
|
42
|
+
throw new Error(`${f} stayed locked by another writer for 2 s: nothing written`)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** the owner's answer on each card a plan names, read from the review store only when one names a card */
|
|
46
|
+
export async function cardAnswers(root: string, plan: CutPlan): Promise<(id: string) => CardAnswer | null> {
|
|
47
|
+
const ids = new Set(Object.values(plan.shots).flatMap((e) => (e.card ? [e.card] : [])))
|
|
48
|
+
if (ids.size === 0) return () => null
|
|
49
|
+
const { readItem, storeDir } = await import('../review/store.ts')
|
|
50
|
+
const got = new Map([...ids].map((id) => [id, answerOf(readItem(storeDir(root), id))]))
|
|
51
|
+
return (id) => got.get(id) ?? null
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** a card's answer as a shot's state reads it: null while he has not answered, or when the store has no such card */
|
|
55
|
+
export function answerOf(x: ReviewItem | null): CardAnswer | null {
|
|
56
|
+
const v = x ? verdictOf(x) : null
|
|
57
|
+
return v ? { status: v.status, approved: isApproved(v.status) } : null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function readFacts(root: string, trailer: string, cut: string): TakeFacts | null {
|
|
61
|
+
const f = factsFile(root, trailer, cut)
|
|
62
|
+
if (!existsSync(f)) return null
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(readFileSync(f, 'utf8')) as TakeFacts
|
|
65
|
+
} catch {
|
|
66
|
+
// a cache file torn by hand: the next check writes it again
|
|
67
|
+
return null
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function writeFacts(root: string, trailer: string, cut: string, facts: TakeFacts): void {
|
|
72
|
+
const f = factsFile(root, trailer, cut)
|
|
73
|
+
mkdirSync(dirname(f), { recursive: true })
|
|
74
|
+
atomicWrite(f, `${JSON.stringify(facts)}\n`)
|
|
75
|
+
}
|