rvlib-shipkit 2.19.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/package.json +1 -1
- package/src/annex/annex.ts +227 -0
- package/src/annex/offload.ts +279 -0
- package/src/checks/SK004-gitignore-policy.check.ts +6 -3
- 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_Commands.ts +4 -1
- package/src/cli/cmd_GlobalProcesses.ts +2 -107
- package/src/cli/cmd_Home.ts +4 -3
- package/src/cli/cmd_Messages.ts +155 -0
- package/src/cli/cmd_Overview.ts +2 -1
- package/src/cli/cmd_Releases.ts +84 -0
- package/src/cli/cmd_Review.ts +176 -12
- package/src/cli/cmd_Shot.ts +4 -4
- package/src/cli/cmd_Social.ts +151 -8
- package/src/cli/cmd_Sound.ts +17 -4
- package/src/cli/cmd_Trailer.ts +67 -1
- 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 +7 -1
- package/src/collections/collection-types.ts +8 -1
- package/src/collections/providers.ts +4 -1
- package/src/collections/review.ts +23 -4
- 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 +11 -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 +337 -5
- package/src/home/gui-app.ts +64 -33
- package/src/home/hmr-keep.ts +134 -0
- package/src/home/home-start.ts +2 -2
- package/src/home/lib-watch.ts +21 -11
- package/src/home/pm-switch.ts +112 -0
- 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-web.ts +7 -4
- package/src/home/serve-web.ts +64 -14
- package/src/identities/collection.ts +49 -0
- package/src/identities/identities.ts +121 -14
- 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 +182 -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 +94 -0
- package/src/releases/before.ts +31 -0
- package/src/releases/collection.ts +36 -0
- package/src/releases/from-card.ts +151 -0
- package/src/releases/model.ts +327 -0
- package/src/releases/pictures.ts +110 -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 +1 -1
- package/src/review/model.ts +102 -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 +47 -1
- package/src/review/trailer-card.ts +99 -0
- package/src/review/trailer-desk.ts +76 -4
- package/src/review/trailer-model.ts +106 -7
- package/src/review/trailer-notes.ts +45 -0
- package/src/review/trailer-routes.ts +119 -13
- package/src/review/trailer-voices.ts +144 -0
- package/src/review/watchers.ts +58 -1
- package/src/serve/hub-app/app-bridge.ts +71 -0
- package/src/serve/hub-app/benign-errors.ts +22 -0
- 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 +59 -8
- package/src/serve/hub-app/home-st.ts +19 -2
- package/src/serve/hub-app/home.html +3 -0
- package/src/serve/hub-app/hub-app.tsx +8 -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/project-list.css +7 -2
- package/src/serve/hub-app/project-list.tsx +9 -0
- package/src/serve/hub-app/projects-svc.ts +16 -6
- package/src/serve/hub-app/releases/releases-page.tsx +187 -0
- package/src/serve/hub-app/releases/releases-st.ts +111 -0
- package/src/serve/hub-app/releases.css +52 -0
- package/src/serve/hub-app/repo-sections.ts +16 -2
- package/src/serve/hub-app/repo-st.ts +66 -10
- package/src/serve/hub-app/review/clip-st.ts +34 -4
- package/src/serve/hub-app/review/kit.tsx +3 -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 +92 -36
- package/src/serve/hub-app/review/trailer-st.ts +306 -34
- package/src/serve/hub-app/review/trailer-timeline.tsx +68 -23
- 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 +137 -6
- package/src/serve/hub-app/social/comms-page.tsx +65 -28
- package/src/serve/hub-app/social/identity-pictures.ts +46 -8
- package/src/serve/hub-app/social/kit.tsx +9 -6
- package/src/serve/hub-app/social/next-release.tsx +118 -0
- package/src/serve/hub-app/social/post-card.tsx +10 -2
- package/src/serve/hub-app/social/social-model.ts +39 -3
- package/src/serve/hub-app/social/social-page.tsx +179 -65
- package/src/serve/hub-app/social/social-st.ts +117 -27
- 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 -1
- package/src/serve/hub-app/tree-build.ts +40 -1
- package/src/serve/hub-app/tree-svc.ts +10 -3
- package/src/serve/project-gutter-route.ts +12 -2
- package/src/serve/project-gutter.ts +4 -2
- package/src/serve/same-origin.ts +24 -1
- package/src/serve/serve-hub.ts +15 -1
- package/src/shipkit-files.ts +9 -7
- package/src/shot/box.ts +33 -12
- package/src/shot/client.ts +1 -1
- package/src/shot/shooter.ts +22 -12
- package/src/shot/shot-ask.ts +14 -3
- package/src/shot/shot.shipkit.ts +1 -1
- package/src/social/desk-index.ts +49 -8
- package/src/social/discord-layout.ts +54 -7
- package/src/social/drafts.ts +1 -1
- 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 +93 -0
- package/src/social/load.ts +125 -10
- 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/index.ts +47 -6
- package/src/social/reach.ts +49 -0
- package/src/social/release-stage.ts +277 -0
- package/src/social/routes.ts +44 -8
- package/src/social/stage.ts +246 -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/trailer/bed.ts +111 -0
- package/src/trailer/build.ts +72 -40
- package/src/trailer/ffmpeg.ts +6 -0
- package/src/trailer/grammar.ts +37 -6
- package/src/trailer/graph.ts +12 -1
- package/src/trailer/public-words.ts +41 -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
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// the stage popup's two routes (wiki tools/shipkit/review-raised-items.md, A post staged from a card): GET what a card
|
|
2
|
+
// offers a post and where it may go, POST a dry run of his draft or the draft written. The page never names a path:
|
|
3
|
+
// a pick is a key the card names, resolved here through the store's own reads
|
|
4
|
+
import { dirname, join } from 'node:path'
|
|
5
|
+
import { POST_RATINGS, isPostRating } from '../identities/rating.ts'
|
|
6
|
+
import { MESSAGES_DIR, testedLines } from '../messages/model.ts'
|
|
7
|
+
import { draftsOfCard } from '../social/card-drafts.ts'
|
|
8
|
+
import { openDesk } from '../social/open.ts'
|
|
9
|
+
import { addDays, dayOf, slotDays } from '../social/presence.ts'
|
|
10
|
+
import { placesOf } from '../social/reach.ts'
|
|
11
|
+
import { askPolish, fitStage, stageDraft, stageDry, type Staged } from '../social/stage.ts'
|
|
12
|
+
import { NO_STORE } from './http.ts'
|
|
13
|
+
import { stageInputOf, stageOfCard, type StageAsk } from './stage-card.ts'
|
|
14
|
+
import type { ReviewUnit } from './unit.ts'
|
|
15
|
+
|
|
16
|
+
const str = (v: unknown): string | undefined => (typeof v === 'string' && v.trim() !== '' ? v : undefined)
|
|
17
|
+
|
|
18
|
+
/** what one account shows in the popup: where a message lands, its max, the places a picker lists */
|
|
19
|
+
export type StageAccount = { id: string; name: string; group: string; place: string; max: number | null; live: boolean; places: { id: string; ceiling: string; open: boolean }[] }
|
|
20
|
+
|
|
21
|
+
/** the popup's data for one card */
|
|
22
|
+
export async function stageGet(root: string, dir: string, id: string): Promise<Response> {
|
|
23
|
+
const card = stageOfCard(dir, id)
|
|
24
|
+
const voice = await voiceOf(root, { id: card.head, title: card.title })
|
|
25
|
+
return Response.json({ ...card, ...voice, drafts: draftsOfCard(root, new Set([card.head, card.first])) }, { headers: NO_STORE })
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** what the popup shows of the voice whatever the source (a card, a release): who speaks, its accounts and places, the
|
|
29
|
+
* next slots, the repo's tags, the repo's lines for this source */
|
|
30
|
+
export async function voiceOf(root: string, about: { id: string; title: string }): Promise<Record<string, unknown>> {
|
|
31
|
+
const { desk, unit } = await openDesk(root)
|
|
32
|
+
const card = about
|
|
33
|
+
const who = desk.identities.find((i) => i.id === desk.speaksAs) ?? null
|
|
34
|
+
const errors: string[] = []
|
|
35
|
+
const accounts: StageAccount[] = (who?.accounts ?? []).map((a) => ({
|
|
36
|
+
id: a.id,
|
|
37
|
+
name: a.name,
|
|
38
|
+
group: a.group,
|
|
39
|
+
place: a.place,
|
|
40
|
+
max: a.max,
|
|
41
|
+
live: a.automation === 'live',
|
|
42
|
+
places: placesOf(a, errors).map((p) => ({ id: p.id, ceiling: p.ceiling, open: p.open })),
|
|
43
|
+
}))
|
|
44
|
+
const today = dayOf(Date.now())
|
|
45
|
+
const slots = slotDays(desk.weekly, desk.drafts, today, addDays(today, 13)).map((s) => ({ value: `${s.day} ${s.slot.tag}`, what: s.slot.what, taken: s.drafts.length > 0 }))
|
|
46
|
+
const counts = new Map<string, number>()
|
|
47
|
+
for (const d of desk.drafts) for (const t of new Set(d.posts.flatMap((p) => p.tags))) counts.set(t, (counts.get(t) ?? 0) + 1)
|
|
48
|
+
const tags = [...counts].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).slice(0, 10).map(([t]) => t)
|
|
49
|
+
let lines: { text: string; source: string }[] = []
|
|
50
|
+
try {
|
|
51
|
+
// the unit's own lines, else the tested phrasings of the repo's messages store (messages/model.ts)
|
|
52
|
+
lines = [...(unit?.lines?.({ id: card.id, title: card.title }) ?? testedLines(join(root, MESSAGES_DIR)))]
|
|
53
|
+
} catch (e) {
|
|
54
|
+
errors.push(`the repo's lines failed: ${(e as Error).message}`)
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
identity: who == null ? null : { id: who.id, name: who.name, adult: who.adult },
|
|
58
|
+
ratings: POST_RATINGS,
|
|
59
|
+
rating: who?.adult ? null : 'safe',
|
|
60
|
+
// the kinds the repo takes, each with what it is for and its rules page: the popup's kind picker
|
|
61
|
+
kinds: desk.kinds,
|
|
62
|
+
accounts,
|
|
63
|
+
lines,
|
|
64
|
+
slots,
|
|
65
|
+
tags,
|
|
66
|
+
errors,
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** the owner's ask read from the page's body; a field of the wrong shape is refused by name */
|
|
71
|
+
export function askOf(b: Record<string, unknown>): StageAsk & { dry: boolean } {
|
|
72
|
+
const rating = typeof b.rating === 'string' ? b.rating : ''
|
|
73
|
+
if (!isPostRating(rating)) throw new Error(`rating: ${POST_RATINGS.join(', ')}`)
|
|
74
|
+
if (typeof b.text !== 'string') throw new Error('text: the post')
|
|
75
|
+
const place = typeof b.place === 'object' && b.place !== null ? (b.place as Record<string, unknown>) : null
|
|
76
|
+
const pick = str(b.pick)
|
|
77
|
+
const alt = typeof b.alt === 'string' ? b.alt : undefined
|
|
78
|
+
const slot = str(b.slot)
|
|
79
|
+
const tags = str(b.tags)
|
|
80
|
+
const kind = str(b.kind)
|
|
81
|
+
const kindWhy = str(b.kindWhy)
|
|
82
|
+
const p = typeof b.passage === 'object' && b.passage !== null ? (b.passage as Record<string, unknown>) : null
|
|
83
|
+
const passage = p && typeof p.from === 'number' && typeof p.to === 'number' ? { from: p.from, to: p.to } : null
|
|
84
|
+
return {
|
|
85
|
+
text: b.text,
|
|
86
|
+
rating,
|
|
87
|
+
...(kind ? { kind } : {}),
|
|
88
|
+
...(kindWhy ? { kindWhy } : {}),
|
|
89
|
+
...(pick ? { pick } : {}),
|
|
90
|
+
...(alt !== undefined ? { alt } : {}),
|
|
91
|
+
...(slot ? { slot } : {}),
|
|
92
|
+
...(tags ? { tags } : {}),
|
|
93
|
+
...(place && typeof place.account === 'string' && typeof place.place === 'string' ? { place: { account: place.account, place: place.place } } : {}),
|
|
94
|
+
...(b.polish === true ? { polish: true } : {}),
|
|
95
|
+
...(b.fit === true ? { fit: true } : {}),
|
|
96
|
+
...(passage ? { passage } : {}),
|
|
97
|
+
dry: b.dry === true,
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** what the popup reads of a stage: each message, each skip, every problem */
|
|
102
|
+
export const answerOf = (r: Staged, polish?: string): Record<string, unknown> => ({
|
|
103
|
+
slug: r.slug,
|
|
104
|
+
posts: (r.draft?.posts ?? []).map((p) => ({ key: p.key, platform: p.platform, place: p.place, length: p.length, refused: p.refused })),
|
|
105
|
+
skipped: r.draft?.skipped ?? [],
|
|
106
|
+
errors: r.errors,
|
|
107
|
+
...(polish ? { polish } : {}),
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
/** a dry run of his draft (`dry: true`), or the draft written, its polish note raised when he ticked it */
|
|
111
|
+
export async function stagePost(root: string, dir: string, id: string, unit: ReviewUnit | null, body: Record<string, unknown>): Promise<Response> {
|
|
112
|
+
const ask = askOf(body)
|
|
113
|
+
const font = unit?.anim?.font ? join(dirname(dirname(dir)), unit.anim.font) : undefined
|
|
114
|
+
// a dry run reads the whole clip: the passage and the fit are cut once, at Enter
|
|
115
|
+
const { passage: _, fit: __, ...whole } = ask
|
|
116
|
+
const { input } = await stageInputOf(dir, id, ask.dry ? whole : ask, font)
|
|
117
|
+
const opened = await openDesk(root)
|
|
118
|
+
const ctx = { unit: opened.unit, speaksAs: opened.desk.speaksAs ?? undefined }
|
|
119
|
+
if (ask.dry) return Response.json(answerOf(await stageDry(root, input, ctx)), { headers: NO_STORE })
|
|
120
|
+
const r = await stageDraft(root, ask.fit ? await fitStage(root, input, ctx) : input, ctx)
|
|
121
|
+
const polish = ask.polish ? (await askPolish(root, r.slug, input.title, opened.unit)).id : undefined
|
|
122
|
+
return Response.json(answerOf(r, polish), { headers: NO_STORE })
|
|
123
|
+
}
|
package/src/review/store.ts
CHANGED
|
@@ -35,8 +35,10 @@ import {
|
|
|
35
35
|
toAcknowledge,
|
|
36
36
|
verdictMessageOf,
|
|
37
37
|
verdictOf,
|
|
38
|
+
viewIndexOf,
|
|
38
39
|
withdrawnOf,
|
|
39
40
|
type GalleryTile,
|
|
41
|
+
type CardChangelog,
|
|
40
42
|
type Item,
|
|
41
43
|
type Message,
|
|
42
44
|
type Op,
|
|
@@ -48,6 +50,7 @@ import {
|
|
|
48
50
|
type ReviewItem,
|
|
49
51
|
type ReviewMark,
|
|
50
52
|
type ReviewView,
|
|
53
|
+
type TrailerCard,
|
|
51
54
|
type Spec,
|
|
52
55
|
type Subject,
|
|
53
56
|
viewFilesOf,
|
|
@@ -103,6 +106,10 @@ export interface ViewInput {
|
|
|
103
106
|
export interface AddInput {
|
|
104
107
|
title: string
|
|
105
108
|
what: string
|
|
109
|
+
/** the public line for a post of it (`--post`); the caller runs the repo's guard on it first */
|
|
110
|
+
post?: string
|
|
111
|
+
/** the change its approval adds to next.md (`--changelog`); the caller runs the repo's guard on it first */
|
|
112
|
+
changelog?: CardChangelog
|
|
106
113
|
/** what is judged; a plain shot by default */
|
|
107
114
|
subject?: Subject
|
|
108
115
|
topic?: string
|
|
@@ -133,6 +140,10 @@ export interface AddInput {
|
|
|
133
140
|
wip?: { live: string }
|
|
134
141
|
/** every view is an option he picks one of */
|
|
135
142
|
choice?: boolean
|
|
143
|
+
/** on a choice: the option the agent suggests, by its label or its letter */
|
|
144
|
+
agentPick?: string
|
|
145
|
+
/** a trailer card: the cut the hub plays in its body; its one view is the cut's strip */
|
|
146
|
+
trailer?: TrailerCard
|
|
136
147
|
now?: Date
|
|
137
148
|
}
|
|
138
149
|
|
|
@@ -315,6 +326,8 @@ export async function addItem(dir: string, input: AddInput): Promise<Item> {
|
|
|
315
326
|
if (given.length === 0) throw new Error('give --image, --video or --audio, or --before and --after, or --view "<label>" <image>')
|
|
316
327
|
for (const [i, v] of given.entries()) if (i > 0 && !v.label.trim()) throw new Error('--view: every view after the first needs its label')
|
|
317
328
|
if (input.choice && given.length < 2) throw new Error('--choice: a choice has two options or more, one --view each')
|
|
329
|
+
if (input.agentPick !== undefined && !input.choice) throw new Error('--pick: only on a --choice card')
|
|
330
|
+
const agentPick = input.agentPick === undefined ? undefined : pickIndex(given, input.agentPick)
|
|
318
331
|
for (const v of given) if (v.note !== undefined && v.gallery) throw new Error(`--view "${v.label}": a note goes on an image, a clip or a sound, never a gallery`)
|
|
319
332
|
const loaded = await Promise.all(given.map((v, i) => loadView(v, i === 0 ? 'the first view' : `--view "${v.label}"`)))
|
|
320
333
|
if (input.supersedes !== undefined && !existsSync(join(dir, input.supersedes, 'item.json'))) throw new Error(`--supersedes ${input.supersedes}: no such card in ${dir}`)
|
|
@@ -366,6 +379,8 @@ export async function addItem(dir: string, input: AddInput): Promise<Item> {
|
|
|
366
379
|
origin: { by: 'agent', ...(lane ? { lane } : {}), ...(session ? { session } : {}) },
|
|
367
380
|
title: input.title.trim(),
|
|
368
381
|
what: input.what.trim(),
|
|
382
|
+
...(input.post?.trim() ? { post: input.post.trim() } : {}),
|
|
383
|
+
...(input.changelog ? { changelog: { category: input.changelog.category.trim(), line: input.changelog.line.trim(), ...(input.changelog.rating ? { rating: input.changelog.rating } : {}) } } : {}),
|
|
369
384
|
...(topic ? { topic } : {}),
|
|
370
385
|
...(input.commit ? { commit: input.commit } : {}),
|
|
371
386
|
views: loaded.map((v, n) => viewOf(v, n, input.marks?.[n], given[n]?.note)),
|
|
@@ -376,6 +391,8 @@ export async function addItem(dir: string, input: AddInput): Promise<Item> {
|
|
|
376
391
|
...(input.light ? { light: input.light } : {}),
|
|
377
392
|
...(input.wip ? { wip: { live: input.wip.live, frame: 1 } } : {}),
|
|
378
393
|
...(input.choice ? { choice: true as const } : {}),
|
|
394
|
+
...(agentPick !== undefined ? { agentPick } : {}),
|
|
395
|
+
...(input.trailer ? { trailer: input.trailer } : {}),
|
|
379
396
|
}
|
|
380
397
|
const problems = itemProblems(item)
|
|
381
398
|
if (problems.length > 0) throw new Error(problems.join('; '))
|
|
@@ -423,6 +440,25 @@ export async function addView(dir: string, id: string, v: ViewInput, o: { marks?
|
|
|
423
440
|
})
|
|
424
441
|
}
|
|
425
442
|
|
|
443
|
+
/** the option the agent suggests, by its label or its letter; throws naming every option */
|
|
444
|
+
function pickIndex(views: readonly { label: string }[], ref: string, flag = '--pick'): number {
|
|
445
|
+
try {
|
|
446
|
+
return viewIndexOf(views, ref)
|
|
447
|
+
} catch (e) {
|
|
448
|
+
throw new Error(`${flag}: ${(e as Error).message}`)
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/** the agent's pick set on an open choice card, by the view's label or letter; refused once he answered */
|
|
453
|
+
export function setAgentPick(dir: string, id: string, ref: string): Item {
|
|
454
|
+
const x = readItem(dir, id)
|
|
455
|
+
if (!x) throw new Error(`no card ${id}`)
|
|
456
|
+
if (verdictOf(x)) throw new Error(`${id} has his answer already: the pick shows what was suggested, never rewritten after`)
|
|
457
|
+
if (x.item.choice !== true) throw new Error(`${id} is no choice card: a pick names one of its options`)
|
|
458
|
+
const n = pickIndex(x.item.views, ref, 'pick')
|
|
459
|
+
return updateHead(dir, id, (cur) => ({ ...cur, agentPick: n }))
|
|
460
|
+
}
|
|
461
|
+
|
|
426
462
|
/** the head rewritten under the item's lock, from what the file says now: a write that raced this one is never lost */
|
|
427
463
|
export function updateHead(dir: string, id: string, fn: (cur: Item) => Item): Item {
|
|
428
464
|
return locked(dir, id, () => {
|
|
@@ -930,7 +966,7 @@ export function deleteReport(dir: string, id: string): void {
|
|
|
930
966
|
* after it (`…-live-3`): its name first, the whole store only when no name holds it */
|
|
931
967
|
export function itemOfRef(dir: string, ref: string): ReviewItem | null {
|
|
932
968
|
const m = /^([a-z][a-z0-9-]*)#(\d+)$/.exec(ref.trim())
|
|
933
|
-
if (!m) return ID_RE.test(ref) ? readItem(dir, ref) :
|
|
969
|
+
if (!m) return ID_RE.test(ref) ? readItem(dir, ref) : itemOfPrefix(dir, ref)
|
|
934
970
|
const holds = (x: ReviewItem | null): x is ReviewItem => x !== null && x.item.origin.by === 'player' && x.item.origin.server === m[1] && x.item.origin.serverId === Number(m[2])
|
|
935
971
|
const tail = `-${m[1]}-${m[2]}`
|
|
936
972
|
for (const n of existsSync(dir) ? readdirSync(dir).filter((n) => n.endsWith(tail)).sort() : []) {
|
|
@@ -944,6 +980,16 @@ export function itemOfRef(dir: string, ref: string): ReviewItem | null {
|
|
|
944
980
|
return readAll(dir).items.find(holds) ?? null
|
|
945
981
|
}
|
|
946
982
|
|
|
983
|
+
/** an item by its moment alone (`20261108-194005`): the one id of that second; two of them is an error naming both, so
|
|
984
|
+
* a short id never picks one by chance. A longer ref is an exact id: a gone item's id never lands on one it starts */
|
|
985
|
+
function itemOfPrefix(dir: string, ref: string): ReviewItem | null {
|
|
986
|
+
const p = ref.trim()
|
|
987
|
+
if (!/^\d{8}-\d{6}$/.test(p) || !existsSync(dir)) return null
|
|
988
|
+
const hits = readdirSync(dir).filter((n) => n.startsWith(`${p}-`))
|
|
989
|
+
if (hits.length > 1) throw new Error(`${p} starts ${hits.length} items: ${hits.sort().join(', ')}; give more of the id`)
|
|
990
|
+
return hits.length === 1 ? readItem(dir, hits[0]!) : null
|
|
991
|
+
}
|
|
992
|
+
|
|
947
993
|
/** a player's report as the owner names it: `live#85`; any other item by its id */
|
|
948
994
|
export const refOf = (x: ReviewItem): string => (x.item.origin.by === 'player' ? `${x.item.origin.server}#${x.item.origin.serverId}` : x.item.id)
|
|
949
995
|
|
|
@@ -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,13 @@ 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'
|
|
14
|
+
import { answerOf, readFacts, readPlan } from '../trailer/shot-plan.ts'
|
|
15
|
+
import { cutStates, planCutOf, type CutPlan, type CutStates } from '../trailer/shot-state.ts'
|
|
13
16
|
import { probe, stillAt } from './media.ts'
|
|
14
17
|
import type { FrameSubject } from './model.ts'
|
|
15
18
|
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'
|
|
19
|
+
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
20
|
|
|
18
21
|
const round = (v: number, d = 4): number => Number(v.toFixed(d))
|
|
19
22
|
|
|
@@ -134,7 +137,7 @@ export const montageOf = (dir: string, c: CutFiles): string => join(dir, 'out',
|
|
|
134
137
|
|
|
135
138
|
/** a cut's .trailer parsed: the film lines need the project CLI's words, which a timeline never does, so their errors
|
|
136
139
|
* are left out */
|
|
137
|
-
function parseCut(file: string): { trailer: Trailer; errors: string[] } {
|
|
140
|
+
export function parseCut(file: string): { trailer: Trailer; errors: string[] } {
|
|
138
141
|
const text = readFileSync(file, 'utf8')
|
|
139
142
|
const lines = text.split('\n')
|
|
140
143
|
const { trailer, errors } = parseTrailer(text, { verbs: null })
|
|
@@ -168,9 +171,32 @@ export interface View {
|
|
|
168
171
|
fps: number
|
|
169
172
|
size: [number, number]
|
|
170
173
|
timeline: Timeline | null
|
|
174
|
+
/** the timing rule its timeline was read with (TIMING); an older one is read again from its unchanged .trailer */
|
|
175
|
+
timing?: number
|
|
171
176
|
media?: ViewMedia
|
|
172
177
|
}
|
|
173
178
|
|
|
179
|
+
/** 2: a shot whose film words the hub does not know keeps its fitted length, as in the build */
|
|
180
|
+
const TIMING = 2
|
|
181
|
+
|
|
182
|
+
/** a record's timeline read with an older rule, read again from its .trailer when that file is the one it was rendered
|
|
183
|
+
* from (saved before it); one saved after may differ, so the old timeline stays */
|
|
184
|
+
function retimed(root: string, id: string, cut: string, v: View): View {
|
|
185
|
+
if (v.timing === TIMING || v.timeline === null) return v
|
|
186
|
+
const dir = trailerDir(root, id)
|
|
187
|
+
const c = dir ? cutOf(dir, cut) : null
|
|
188
|
+
if (!c?.trailer || statSync(c.trailer).mtimeMs > v.mtime) return v
|
|
189
|
+
let timeline: Timeline
|
|
190
|
+
try {
|
|
191
|
+
timeline = timelineOf(parseCut(c.trailer).trailer)
|
|
192
|
+
} catch {
|
|
193
|
+
return v
|
|
194
|
+
}
|
|
195
|
+
const out: View = { ...v, timeline, timing: TIMING }
|
|
196
|
+
writeView(root, id, cut, out)
|
|
197
|
+
return out
|
|
198
|
+
}
|
|
199
|
+
|
|
174
200
|
export const viewBase = (root: string, id: string, cut: string, mtime: number): string => join(viewDir(root), `${id}--${cut}--${Math.round(mtime)}`)
|
|
175
201
|
export const viewVideo = (root: string, id: string, cut: string, mtime: number): string => `${viewBase(root, id, cut, mtime)}.mp4`
|
|
176
202
|
export const viewStrip = (root: string, id: string, cut: string, mtime: number): string => `${viewBase(root, id, cut, mtime)}.strip.png`
|
|
@@ -188,7 +214,7 @@ export function readView(root: string, id: string, cut: string, mtime: number):
|
|
|
188
214
|
const f = `${viewBase(root, id, cut, mtime)}.json`
|
|
189
215
|
if (!existsSync(f)) return null
|
|
190
216
|
const v = JSON.parse(readFileSync(f, 'utf8')) as View
|
|
191
|
-
return v.media?.video || existsSync(viewVideo(root, id, cut, mtime)) ? v : null
|
|
217
|
+
return v.media?.video || existsSync(viewVideo(root, id, cut, mtime)) ? retimed(root, id, cut, v) : null
|
|
192
218
|
}
|
|
193
219
|
|
|
194
220
|
/** a render's record written whole, through a file beside it renamed */
|
|
@@ -252,7 +278,7 @@ export function viewOf(root: string, dir: string, id: string, c: CutFiles, now =
|
|
|
252
278
|
} catch {
|
|
253
279
|
timeline = null
|
|
254
280
|
}
|
|
255
|
-
const view: View = { mtime, ...p, timeline }
|
|
281
|
+
const view: View = { mtime, ...p, timeline, timing: TIMING }
|
|
256
282
|
writeView(root, id, c.cut, view)
|
|
257
283
|
keepStrip(root, dir, id, c, mtime)
|
|
258
284
|
views.set(key, view)
|
|
@@ -347,7 +373,24 @@ export function cutInfo(root: string, dir: string, id: string, c: CutFiles): Cut
|
|
|
347
373
|
strip: timeline && view ? stripInfo(viewStrip(root, id, c.cut, view.mtime), view, timeline) : null,
|
|
348
374
|
fileMtime,
|
|
349
375
|
version: c.version === true,
|
|
376
|
+
shots: timeline ? shotStates(root, id, c, timeline, errors) : null,
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/** the cut's shots in plain words: its plan (a kept version reads its cut's), its takes as the last check or build read
|
|
381
|
+
* them (a version's takes are kept with it: none read), the answers on the cards a plan names. A plan that does not
|
|
382
|
+
* parse is said in the cut's errors */
|
|
383
|
+
function shotStates(root: string, id: string, c: CutFiles, tl: Timeline, errors: string[]): CutStates {
|
|
384
|
+
const planCut = planCutOf(c.cut, c.version === true)
|
|
385
|
+
let plan: CutPlan = { shots: {} }
|
|
386
|
+
try {
|
|
387
|
+
plan = readPlan(root, id, planCut)
|
|
388
|
+
} catch (e) {
|
|
389
|
+
errors.push((e as Error).message)
|
|
350
390
|
}
|
|
391
|
+
const cards = Object.values(plan.shots).some((e) => e.card) ? readAllCached(storeDir(root)).items : []
|
|
392
|
+
const answer = (card: string) => answerOf(cards.find((x) => x.item.id === card) ?? null)
|
|
393
|
+
return cutStates(tl.shots.map((s) => s.name), plan, planCut, c.version ? null : readFacts(root, id, c.cut), answer)
|
|
351
394
|
}
|
|
352
395
|
|
|
353
396
|
export function trailerInfo(root: string, id: string): TrailerInfo | null {
|
|
@@ -356,6 +399,17 @@ export function trailerInfo(root: string, id: string): TrailerInfo | null {
|
|
|
356
399
|
return { id, cuts: cutsOf(dir).map((c) => cutInfo(root, dir, id, c)), notes: notesOf(readAllCached(storeDir(root)).items, id) }
|
|
357
400
|
}
|
|
358
401
|
|
|
402
|
+
/** a render a trailer card pinned: its record, its timeline (else the cut's file as it stands, as on the page), its
|
|
403
|
+
* strip's grid; null when nothing holds its video */
|
|
404
|
+
export function pinnedRender(root: string, id: string, cut: string, mtime: number): PinnedRender | null {
|
|
405
|
+
const v = readView(root, id, cut, mtime)
|
|
406
|
+
const dir = trailerDir(root, id)
|
|
407
|
+
const c = dir ? cutOf(dir, cut) : null
|
|
408
|
+
if (!v || !c) return null
|
|
409
|
+
const tl = v.timeline ?? (c.trailer ? timelineOf(parseCut(c.trailer).trailer) : wholeTimeline(v.duration, v.fps, v.size))
|
|
410
|
+
return { duration: v.duration, fps: v.fps, timeline: tl, strip: stripInfo(viewStrip(root, id, cut, mtime), v, tl) }
|
|
411
|
+
}
|
|
412
|
+
|
|
359
413
|
/** the montage page of a cut, null when its build wrote none */
|
|
360
414
|
export function montagePage(root: string, id: string, cut: string): string | null {
|
|
361
415
|
const dir = trailerDir(root, id)
|
|
@@ -374,6 +428,24 @@ export function frameAt(time: number, fps: number, duration: number): { frame: n
|
|
|
374
428
|
return { frame, time: (frame + 0.5) / fps }
|
|
375
429
|
}
|
|
376
430
|
|
|
431
|
+
/** a still the rail draws a note on is this wide */
|
|
432
|
+
const STILL_W = 320
|
|
433
|
+
|
|
434
|
+
/** frame `frame` of a render, a small jpg cut once beside its record and kept; null when nothing holds the render */
|
|
435
|
+
export async function frameStill(root: string, id: string, cut: string, mtime: number, frame: number): Promise<string | null> {
|
|
436
|
+
const v = readView(root, id, cut, mtime)
|
|
437
|
+
if (!v || !Number.isInteger(frame) || frame < 0) return null
|
|
438
|
+
const f = frameAt((frame + 0.5) / v.fps, v.fps, v.duration)
|
|
439
|
+
const out = `${viewBase(root, id, cut, mtime)}--f${f.frame}.jpg`
|
|
440
|
+
if (existsSync(out)) return out
|
|
441
|
+
const video = await viewMedia(root, id, cut, mtime, 'video', { bytes: true })
|
|
442
|
+
if (!video || !('path' in video)) return null
|
|
443
|
+
const tmp = `${out}.${process.pid}.jpg`
|
|
444
|
+
await ffmpeg(['-y', '-ss', f.time.toFixed(5), '-i', video.path, '-frames:v', '1', '-vf', `scale=${STILL_W}:-2`, '-q:v', '4', tmp])
|
|
445
|
+
renameSync(tmp, out)
|
|
446
|
+
return out
|
|
447
|
+
}
|
|
448
|
+
|
|
377
449
|
export interface NewNote {
|
|
378
450
|
cut: string
|
|
379
451
|
/** the render on screen, by its mtime: the still is cut from that version, whatever came after */
|
|
@@ -1,20 +1,47 @@
|
|
|
1
1
|
// the trailer view's shapes (wiki tools/trailer/index.md, Frame notes): what the hub answers about a repo's cuts, and a frame
|
|
2
2
|
// note as the view shows it, read from its item of the one store. Pure: the routes and the page share them
|
|
3
3
|
import { isFrame, isReply, partyOf, stateOf, type ReviewItem } from './model.ts'
|
|
4
|
+
import type { CutStates } from '../trailer/shot-state.ts'
|
|
4
5
|
|
|
5
6
|
export type NoteState = 'open' | 'done' | 'wontfix'
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
/** 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
|
|
9
|
+
* the top, so any render or size of the player shows it in place); w = h = 0 is a point */
|
|
10
|
+
export interface NoteMark {
|
|
9
11
|
x: number
|
|
10
12
|
y: number
|
|
13
|
+
w: number
|
|
14
|
+
h: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** a mark read from a request, kept inside the frame; undefined when it is none */
|
|
18
|
+
export function noteMarkOf(v: unknown): NoteMark | undefined {
|
|
19
|
+
const m = v as { x?: unknown; y?: unknown; w?: unknown; h?: unknown } | null | undefined
|
|
20
|
+
if (!m || typeof m.x !== 'number' || typeof m.y !== 'number' || !Number.isFinite(m.x) || !Number.isFinite(m.y)) return undefined
|
|
21
|
+
const r4 = (n: number): number => Number(Math.min(1, Math.max(0, n)).toFixed(4))
|
|
22
|
+
const x = r4(m.x)
|
|
23
|
+
const y = r4(m.y)
|
|
24
|
+
const side = (n: unknown, at: number): number => (typeof n === 'number' && Number.isFinite(n) && n > 0 ? r4(Math.min(n, 1 - at)) : 0)
|
|
25
|
+
return { x, y, w: side(m.w, x), h: side(m.h, y) }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** 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
|
|
29
|
+
* the cut, its time, its tone, its words; `go` lands on its frame */
|
|
30
|
+
export interface LaneMark {
|
|
31
|
+
key: string
|
|
32
|
+
n: number
|
|
33
|
+
at: number
|
|
34
|
+
tone: 'draft' | 'sent' | NoteState
|
|
35
|
+
text: string
|
|
36
|
+
selected: boolean
|
|
37
|
+
go: () => void
|
|
11
38
|
}
|
|
12
39
|
|
|
13
40
|
/** one note as the view shows it: an item of the one store whose subject is a frame */
|
|
14
41
|
export interface TrailerNote {
|
|
15
42
|
/** its item's id */
|
|
16
43
|
id: string
|
|
17
|
-
/** its number on the trailer, in the order written
|
|
44
|
+
/** its number on the trailer, in the order written */
|
|
18
45
|
n: number
|
|
19
46
|
trailer: string
|
|
20
47
|
cut: string
|
|
@@ -26,7 +53,7 @@ export interface TrailerNote {
|
|
|
26
53
|
shotTime: number
|
|
27
54
|
section: string | null
|
|
28
55
|
text: string
|
|
29
|
-
|
|
56
|
+
mark?: NoteMark
|
|
30
57
|
state: NoteState
|
|
31
58
|
/** done: the commit or the answer; wontfix: the reason */
|
|
32
59
|
reply?: string
|
|
@@ -36,14 +63,22 @@ export interface TrailerNote {
|
|
|
36
63
|
still: string
|
|
37
64
|
}
|
|
38
65
|
|
|
39
|
-
/** a
|
|
66
|
+
/** a render as a trailer card pins it: its length, rate, timeline and strip, whatever render the cut has now */
|
|
67
|
+
export interface PinnedRender {
|
|
68
|
+
duration: number
|
|
69
|
+
fps: number
|
|
70
|
+
timeline: Timeline
|
|
71
|
+
strip: CutInfo['strip']
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** 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
75
|
* when the item is no frame */
|
|
41
76
|
export function noteOf(x: ReviewItem, n: number): TrailerNote | null {
|
|
42
77
|
const s = x.item.subject
|
|
43
78
|
if (!isFrame(s)) return null
|
|
44
79
|
const said = x.thread.filter((m) => partyOf(m.who) === 'owner' && m.op === undefined)
|
|
45
80
|
const text = said.filter(isReply).at(-1)?.text ?? ''
|
|
46
|
-
const
|
|
81
|
+
const marked = said.filter((m) => m.rects !== undefined).at(-1)?.rects?.[0]
|
|
47
82
|
const st = stateOf(x, false)
|
|
48
83
|
const closing = st.state === 'closed' ? x.thread.filter((m) => m.op === 'fixed' || m.op === 'wontfix').at(-1) : undefined
|
|
49
84
|
const first = x.item.views[0]
|
|
@@ -58,7 +93,7 @@ export function noteOf(x: ReviewItem, n: number): TrailerNote | null {
|
|
|
58
93
|
shotTime: s.shotTime,
|
|
59
94
|
section: s.section,
|
|
60
95
|
text,
|
|
61
|
-
...(
|
|
96
|
+
...(marked ? { mark: { x: marked.x, y: marked.y, w: marked.w, h: marked.h } } : {}),
|
|
62
97
|
state: closing?.op === 'wontfix' ? 'wontfix' : closing ? 'done' : 'open',
|
|
63
98
|
...(closing?.note ? { reply: closing.note } : {}),
|
|
64
99
|
written: x.item.created,
|
|
@@ -135,6 +170,9 @@ export interface CutInfo {
|
|
|
135
170
|
fileMtime: number
|
|
136
171
|
/** a kept version (`versions/<v>.trailer` and `versions/<v>/`): it never changes */
|
|
137
172
|
version: boolean
|
|
173
|
+
/** each shot of its timeline in plain words: ready, queued, filming, waiting on a card, not filmed (trailer/shot-state.ts);
|
|
174
|
+
* null with no timeline */
|
|
175
|
+
shots: CutStates | null
|
|
138
176
|
}
|
|
139
177
|
|
|
140
178
|
export interface TrailerInfo {
|
|
@@ -147,6 +185,67 @@ export interface TrailerDesk {
|
|
|
147
185
|
trailers: TrailerInfo[]
|
|
148
186
|
}
|
|
149
187
|
|
|
188
|
+
/** the seconds of picture a voice line's passage shows before the line starts, and after the longer of its versions
|
|
189
|
+
* (trailer/bed.ts voicePassage) */
|
|
190
|
+
export const PASSAGE_PAD = 1
|
|
191
|
+
|
|
192
|
+
/** one place a voice line is spoken: its cut, its line, its shot's span and its own start on the cut's timeline */
|
|
193
|
+
export interface VoiceUse {
|
|
194
|
+
cut: string
|
|
195
|
+
line: number
|
|
196
|
+
/** the .trailer file, repo relative */
|
|
197
|
+
file: string
|
|
198
|
+
shot: string
|
|
199
|
+
shotStart: number
|
|
200
|
+
shotEnd: number
|
|
201
|
+
/** seconds on the cut the line starts */
|
|
202
|
+
at: number
|
|
203
|
+
/** seconds it has before the next line starts, or the cut ends */
|
|
204
|
+
room: number
|
|
205
|
+
/** its `volume` in the cut */
|
|
206
|
+
volume: number
|
|
207
|
+
/** the brand voice it names, null for the brand's own */
|
|
208
|
+
by: string | null
|
|
209
|
+
/** it reads a recorded voice: his take, or a standin until he makes one */
|
|
210
|
+
mine: boolean
|
|
211
|
+
/** who the cut plays now, in words */
|
|
212
|
+
reader: string
|
|
213
|
+
/** the sound the cut plays now, its cache key; null until a build makes it */
|
|
214
|
+
made: string | null
|
|
215
|
+
/** a line of a recorded voice: who stands in, and its line's cache key whether it plays or not (null until made) */
|
|
216
|
+
standin: { name: string; made: string | null } | null
|
|
217
|
+
/** the cut's render on screen, null before its first */
|
|
218
|
+
video: { mtime: number } | null
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** one text of a trailer's lines: one take serves every use of the same words */
|
|
222
|
+
export interface VoiceLine {
|
|
223
|
+
/** the take's key: the words alone, tags and case dropped */
|
|
224
|
+
key: string
|
|
225
|
+
/** as written, tags included: a tag is how to say it */
|
|
226
|
+
text: string
|
|
227
|
+
words: string
|
|
228
|
+
/** the recorded voice his take is kept under; null when the brand has none */
|
|
229
|
+
voice: string | null
|
|
230
|
+
/** some use reads a recorded voice: it waits for him until he has a take */
|
|
231
|
+
mine: boolean
|
|
232
|
+
/** his take: the file he recorded; where its own 0 sits on the line's time (`dragged`: his, else at its first
|
|
233
|
+
* sound); the ranges of it he masked, in its own seconds; and the line made of it as the cut plays it, starting at
|
|
234
|
+
* the line's 0 (its cache key; null until made) */
|
|
235
|
+
take: { file: string; mtime: number; offset: number; dragged: boolean; mask: [number, number][]; made: string | null } | null
|
|
236
|
+
uses: VoiceUse[]
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface VoicesDesk {
|
|
240
|
+
trailer: string
|
|
241
|
+
/** the brand's first recorded voice and his name, null when the brand has none */
|
|
242
|
+
recorder: { voice: string; who: string; takes: boolean } | null
|
|
243
|
+
lines: VoiceLine[]
|
|
244
|
+
/** lines of a recorded voice with no take yet */
|
|
245
|
+
waiting: number
|
|
246
|
+
errors: string[]
|
|
247
|
+
}
|
|
248
|
+
|
|
150
249
|
/** the shot on screen at `t`: the last one started */
|
|
151
250
|
export function shotAt(tl: Pick<Timeline, 'shots'>, t: number): ShotSpan | null {
|
|
152
251
|
let out: ShotSpan | null = null
|