rvlib-shipkit 2.21.0 → 2.22.1
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 +23 -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/cli/cmd_Bump.ts +3 -3
- package/src/cli/cmd_Rec.ts +349 -0
- package/src/cli/cmd_Releases.ts +4 -1
- package/src/cli/cmd_Secret.ts +10 -3
- package/src/cli/cmd_Sign.ts +24 -0
- package/src/cli/cmd_Social.ts +44 -1
- package/src/cli/family-pages.ts +1 -0
- package/src/cli/registry.ts +4 -0
- 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/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.ts +31 -12
- package/src/home/home-routes.ts +6 -0
- package/src/home/serve-web.ts +1 -1
- package/src/identities/identities.ts +6 -0
- 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/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 +162 -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 +862 -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 +7 -2
- package/src/releases/from-card.ts +3 -3
- package/src/releases/model.ts +29 -7
- package/src/repo-config.ts +7 -3
- package/src/review/trailer-desk.ts +1 -0
- package/src/review/trailer-model.ts +2 -0
- package/src/secrets/manager.ts +18 -1
- package/src/serve/hub-app/home-st.ts +15 -5
- package/src/serve/hub-app/home.html +1 -0
- package/src/serve/hub-app/hub-app.tsx +6 -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.tsx +1 -0
- package/src/serve/hub-app/projects-svc.ts +1 -1
- 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/repo-st.ts +1 -1
- package/src/serve/hub-app/review/trailer-page.tsx +1 -0
- package/src/serve/hub-app/review/trailer-st.ts +16 -0
- package/src/serve/hub-app/review/trailer-timeline.tsx +3 -0
- package/src/serve/hub-app/review.css +2 -0
- package/src/serve/hub-app/social/post-card.tsx +31 -3
- package/src/serve/hub-app/social/social-model.ts +4 -0
- package/src/serve/hub-app/social/social-st.ts +12 -0
- package/src/serve/hub-app/social.css +4 -0
- package/src/shipkit.ts +2 -2
- package/src/shot/box.ts +23 -17
- package/src/shot/browser-slot.ts +13 -3
- package/src/shot/film-box.ts +193 -117
- package/src/shot/shooter.ts +5 -3
- package/src/smoke/run-smoke.ts +8 -6
- package/src/social/compose.ts +14 -0
- package/src/social/drafts.ts +1 -1
- package/src/social/load.ts +16 -2
- package/src/social/publish/index.ts +3 -1
- package/src/social/publish/secret.ts +12 -4
- package/src/social/release-card.ts +69 -0
- package/src/social/release-stage.ts +49 -10
- package/src/social/routes.ts +5 -0
- package/src/social/stage.ts +9 -5
- package/src/trailer/build.ts +24 -0
- package/src/trailer/ffmpeg.ts +8 -0
- package/src/trailer/grammar.ts +9 -2
- package/src/trailer/look.ts +7 -0
- package/src/veille/chrome.ts +6 -3
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// the picture of a release post (wiki tools/shipkit/social.md, The release card): the identity kit draws it from the
|
|
2
|
+
// repo's brand (renderReleaseCard), beside the release's first safe still, else as the poster. Only a safe picture is
|
|
3
|
+
// ever its feature: the card goes first in a draft every venue attaches, the safe ones included
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
import { renderReleaseCard } from '../assets/kits/identity-kit.ts'
|
|
7
|
+
import { LAYOUT } from '../core/layout.ts'
|
|
8
|
+
import { localPicture } from '../releases/pictures.ts'
|
|
9
|
+
import { changesOf, isClip, shotFor, type Change, type Release } from '../releases/model.ts'
|
|
10
|
+
|
|
11
|
+
export type CardAsk = {
|
|
12
|
+
version: string
|
|
13
|
+
/** the release's file, when the repo keeps one: its title, changes and safe pictures */
|
|
14
|
+
release: Release | null
|
|
15
|
+
/** the headline when the file gives none: the notes' first line */
|
|
16
|
+
fallback?: string
|
|
17
|
+
/** a SAFE still beside the brand, a file; null, the poster; unset, the file's first safe still */
|
|
18
|
+
feature?: string | null
|
|
19
|
+
headline?: string
|
|
20
|
+
/** where the feature's subject sits across it, 0 to 1 */
|
|
21
|
+
focus?: number
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type Card = {
|
|
25
|
+
/** the rendered png, in the repo's scratch */
|
|
26
|
+
file: string
|
|
27
|
+
/** its name in a draft, without the extension */
|
|
28
|
+
name: string
|
|
29
|
+
headline: string
|
|
30
|
+
/** the still beside the brand; null, the poster */
|
|
31
|
+
feature: string | null
|
|
32
|
+
alt: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** the release's first safe still and the change it shows: a clip never stands in a still picture */
|
|
36
|
+
async function firstSafeStill(root: string, release: Release): Promise<{ file: string; change: Change } | null> {
|
|
37
|
+
for (const change of changesOf(release)) {
|
|
38
|
+
const s = shotFor(change, 'safe')
|
|
39
|
+
if (s && !isClip(s.picture.url)) return { file: await localPicture(root, s.picture.url), change }
|
|
40
|
+
}
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** the card of a release, rendered into `.shipkit/tmp/release-cards/`; null in a repo with no brand. Its headline: the
|
|
45
|
+
* one asked, else the file's title, else the title of the change its feature shows, else the first change's, else
|
|
46
|
+
* the fallback */
|
|
47
|
+
export async function releaseCard(root: string, ask: CardAsk): Promise<Card | null> {
|
|
48
|
+
const { loadBrand, identityLogo } = await import('../assets/run-assets.ts')
|
|
49
|
+
const brand = await loadBrand(root)
|
|
50
|
+
if (brand == null) return null
|
|
51
|
+
if (typeof brand === 'string') throw new Error(brand)
|
|
52
|
+
if (ask.feature && !existsSync(ask.feature)) throw new Error(`no feature ${ask.feature}`)
|
|
53
|
+
const shown = ask.feature !== undefined ? (ask.feature ? { file: ask.feature, change: null } : null) : ask.release ? await firstSafeStill(root, ask.release) : null
|
|
54
|
+
const first = ask.release ? changesOf(ask.release)[0] : undefined
|
|
55
|
+
const headline = (ask.headline ?? (ask.release?.title || shown?.change?.title || first?.title || ask.fallback || '')).replace(/\s+/g, ' ').trim()
|
|
56
|
+
const logo = await identityLogo(root)
|
|
57
|
+
const png = await renderReleaseCard(
|
|
58
|
+
brand,
|
|
59
|
+
root,
|
|
60
|
+
{ version: ask.version, headline, feature: shown ? readFileSync(shown.file) : null, ...(ask.focus !== undefined ? { focus: ask.focus } : {}) },
|
|
61
|
+
logo ? { markFile: join(root, logo) } : {},
|
|
62
|
+
)
|
|
63
|
+
const dir = join(root, LAYOUT.tmp, 'release-cards')
|
|
64
|
+
mkdirSync(dir, { recursive: true })
|
|
65
|
+
const name = `release-${ask.version}`
|
|
66
|
+
const file = join(dir, `${name}.png`)
|
|
67
|
+
writeFileSync(file, png)
|
|
68
|
+
return { file, name, headline, feature: shown?.file ?? null, alt: `${brand.name} ${ask.version}${headline ? `: ${headline}` : ''}` }
|
|
69
|
+
}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
// its polish note raised. Its media: the release file's pictures, each venue the one its place takes (`shotFor`): the
|
|
4
4
|
// safe one for the draft, a heading of its own where the place takes an nsfw one, and the nsfw twin of a venue that
|
|
5
5
|
// cannot (Discord's -nsfw channel), staged to wait for his Publish; else his pick, later, among the approved cards the
|
|
6
|
-
// release ships.
|
|
7
|
-
//
|
|
6
|
+
// release ships. Before all of them, the release card the brand draws (release-card.ts), the picture a heading with no
|
|
7
|
+
// media of its own attaches. Idempotent: one draft a release. A repo with no `release` headings stages nothing. Before
|
|
8
|
+
// the cut, Communications shows next.md as the same input loaded on a scratch copy (`previewNextRelease`), nothing written
|
|
8
9
|
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
9
10
|
import { basename, dirname, join } from 'node:path'
|
|
10
11
|
import { loadIdentities } from '../identities/identities.ts'
|
|
@@ -21,6 +22,7 @@ import { gitBin } from '../core/git-bin.ts'
|
|
|
21
22
|
import { setHeadingText } from './drafts.ts'
|
|
22
23
|
import { DRAFT_NAME, draftsDir, type Draft } from './load.ts'
|
|
23
24
|
import { parseFrontmatter, setMeta } from './md.ts'
|
|
25
|
+
import { releaseCard, type Card } from './release-card.ts'
|
|
24
26
|
import { askPolish, contextOf, draftText, dryLoad, mediaFile, stageDraft, stageDry, type Staged, type StageHeading, type StageInput, type StageMedia } from './stage.ts'
|
|
25
27
|
import { stripCopy } from './strip.ts'
|
|
26
28
|
import { guardWith, type ReleaseHeading, type SocialUnit } from './unit.ts'
|
|
@@ -121,12 +123,17 @@ async function venueMedia(root: string, file: Release | null, headings: readonly
|
|
|
121
123
|
}
|
|
122
124
|
|
|
123
125
|
/** what a release stages: its file's change titles when the repo keeps one (the notes handed in are only its fallback),
|
|
124
|
-
* else its notes' lines, and each venue's picture. The one builder of the stage and of its preview, so both
|
|
125
|
-
* same draft */
|
|
126
|
-
async function releaseInput(root: string, ask: ReleaseAsk, file: Release | null, headings: readonly ReleaseHeading[], o: StageCtx): Promise<StageInput> {
|
|
126
|
+
* else its notes' lines, its card and each venue's picture. The one builder of the stage and of its preview, so both
|
|
127
|
+
* write the same draft. A card that does not render leaves the draft without it, its reason in `warnings` */
|
|
128
|
+
async function releaseInput(root: string, ask: ReleaseAsk, file: Release | null, headings: readonly ReleaseHeading[], o: StageCtx, warnings: string[] = []): Promise<StageInput> {
|
|
127
129
|
const ref = `${ask.unit}@${ask.version}`
|
|
128
130
|
const lines = file ? changesOf(file).map((c) => `- ${c.title}`) : noteLines(ask.notes)
|
|
129
131
|
const m = await venueMedia(root, file, headings, o)
|
|
132
|
+
const fallback = noteLines(ask.message ?? '')[0] ?? noteLines(ask.notes)[0]
|
|
133
|
+
const card: Card | null = await releaseCard(root, { version: ask.version, release: file, ...(fallback ? { fallback: fallback.replace(/^- /, '') } : {}) }).catch((e: unknown) => {
|
|
134
|
+
warnings.push(`no release card: ${(e as Error).message}`)
|
|
135
|
+
return null
|
|
136
|
+
})
|
|
130
137
|
return {
|
|
131
138
|
source: { release: ref },
|
|
132
139
|
title: ask.title ?? (file?.title ? `${file.version}: ${file.title}` : `${ask.unit} ${ask.version}`),
|
|
@@ -135,6 +142,7 @@ async function releaseInput(root: string, ask: ReleaseAsk, file: Release | null,
|
|
|
135
142
|
status: 'draft',
|
|
136
143
|
headings: m.headings,
|
|
137
144
|
...(m.media ? { media: m.media, alt: m.alt } : {}),
|
|
145
|
+
...(card ? { cover: { file: card.file, name: card.name }, alt: card.alt } : {}),
|
|
138
146
|
angle: [`Staged from the release ${ref}${ask.tag ? ` (${ask.since ? `${ask.since}..` : ''}${ask.tag})` : ''}. Its notes:`, '', ...lines].join('\n'),
|
|
139
147
|
...(ask.now ? { now: ask.now } : {}),
|
|
140
148
|
}
|
|
@@ -148,7 +156,8 @@ export async function stageRelease(root: string, unit: SocialUnit | null, ask: R
|
|
|
148
156
|
const ref = `${ask.unit}@${ask.version}`
|
|
149
157
|
const had = releaseDraft(root, ref)
|
|
150
158
|
if (had != null) return { slug: had, files: [], draft: null, errors: [], created: false }
|
|
151
|
-
const
|
|
159
|
+
const warnings: string[] = []
|
|
160
|
+
const input = await releaseInput(root, ask, releaseFileOf(root, ref), headings, o, warnings)
|
|
152
161
|
const r = await stageDraft(root, input, ctxOf(unit, o))
|
|
153
162
|
// the range its media comes from, read back by Communications
|
|
154
163
|
if (ask.tag) {
|
|
@@ -157,7 +166,7 @@ export async function stageRelease(root: string, unit: SocialUnit | null, ask: R
|
|
|
157
166
|
commitPaths([f], `social: ${r.slug} names the range of ${ref}`)
|
|
158
167
|
}
|
|
159
168
|
await askPolish(root, r.slug, input.title, unit, 'release')
|
|
160
|
-
return { ...r, created: true }
|
|
169
|
+
return { ...r, errors: [...warnings, ...r.errors], created: true }
|
|
161
170
|
}
|
|
162
171
|
|
|
163
172
|
/** the release being filled as Communications shows it: next.md, and the draft a release would stage from it */
|
|
@@ -185,14 +194,15 @@ export async function previewNextRelease(root: string, unit: SocialUnit | null,
|
|
|
185
194
|
const ref = `${ask.unit}@${ask.version}`
|
|
186
195
|
if (headings.length === 0) return { release, ref, headings, draft: null, text: '', errors: [] }
|
|
187
196
|
// a picture the disk and the Space cannot give (offline) leaves the preview its words, and says why
|
|
188
|
-
const
|
|
197
|
+
const warnings: string[] = []
|
|
198
|
+
const fetched = await releaseInput(root, ask, release, headings, o, warnings).then(
|
|
189
199
|
(input) => ({ input, why: null }),
|
|
190
|
-
async (e: unknown) => ({ input: await releaseInput(root, ask, null, headings, o).then((i) => ({ ...i, text: changesOf(release).map((c) => `- ${c.title}`).join('\n') || i.text })), why: `its pictures: ${(e as Error).message}` }),
|
|
200
|
+
async (e: unknown) => ({ input: await releaseInput(root, ask, null, headings, o, warnings).then((i) => ({ ...i, text: changesOf(release).map((c) => `- ${c.title}`).join('\n') || i.text })), why: `its pictures: ${(e as Error).message}` }),
|
|
191
201
|
)
|
|
192
202
|
const { input } = fetched
|
|
193
203
|
const r = await stageDry(root, input, ctxOf(unit, o))
|
|
194
204
|
// `next` is no version yet: the load's line on the ref is the one a cut release never meets
|
|
195
|
-
const errors = [...r.errors.filter((e) => !e.includes(`release "${ref}"`)), ...(fetched.why ? [fetched.why] : [])]
|
|
205
|
+
const errors = [...r.errors.filter((e) => !e.includes(`release "${ref}"`)), ...(fetched.why ? [fetched.why] : []), ...new Set(warnings)]
|
|
196
206
|
return { release, ref, headings, draft: r.draft, text: draftText(input, input.media ? mediaFile(input.media) : null), errors }
|
|
197
207
|
}
|
|
198
208
|
|
|
@@ -275,3 +285,32 @@ export async function releaseMedia(
|
|
|
275
285
|
commitPaths([f, join(draftsDir(root), slug, name)], `social: ${slug} takes the media of the card ${card.id}`)
|
|
276
286
|
return { slug, files: [f], draft: null, errors: [] }
|
|
277
287
|
}
|
|
288
|
+
|
|
289
|
+
/** a staged release draft given its card: rendered into its media/, first in its `media`, its `alt` the card's, the two
|
|
290
|
+
* files committed. `feature` a SAFE still (null, the poster; unset, the release file's first safe still) */
|
|
291
|
+
export async function releaseCardDraft(
|
|
292
|
+
root: string,
|
|
293
|
+
slug: string,
|
|
294
|
+
ask: { feature?: string | null; headline?: string; focus?: number } = {},
|
|
295
|
+
o: { unit?: SocialUnit | null } = {},
|
|
296
|
+
): Promise<Card & { media: string; files: string[] }> {
|
|
297
|
+
const f = join(draftsDir(root), slug, 'draft.md')
|
|
298
|
+
if (!DRAFT_NAME.test(slug) || !existsSync(f)) throw new Error(`no draft ${slug}`)
|
|
299
|
+
let raw = readFileSync(f, 'utf8')
|
|
300
|
+
const ref = head(raw).release
|
|
301
|
+
const version = ref ? /^[^@]+@(.+)$/.exec(ref)?.[1] : undefined
|
|
302
|
+
if (version == null) throw new Error(`${slug} names no release: the card is a release post's picture`)
|
|
303
|
+
const card = await releaseCard(root, { version, release: releaseFileOf(root, ref), ...ask })
|
|
304
|
+
if (card == null) throw new Error('the repo has no .shipkit/identity/brand.ts: the card is drawn from its brand')
|
|
305
|
+
const problems = guardWith(o.unit, { alt: card.alt, texts: [card.headline], files: [card.file] })
|
|
306
|
+
if (problems.length > 0) throw new Error(`the repo's guard refuses it: ${problems.join('; ')}`)
|
|
307
|
+
const media = mediaFile({ file: card.file, name: card.name })
|
|
308
|
+
const had = (head(raw).media ?? '').split(',').map((x) => x.trim()).filter((x) => x !== '' && x !== media)
|
|
309
|
+
raw = setMeta(setMeta(raw, 'media', [media, ...had].join(', ')), 'alt', card.alt)
|
|
310
|
+
const at = join(draftsDir(root), slug, media)
|
|
311
|
+
mkdirSync(dirname(at), { recursive: true })
|
|
312
|
+
stripCopy(card.file, at)
|
|
313
|
+
writeFileSync(f, raw)
|
|
314
|
+
commitPaths([f, at], `social: ${slug} takes its release card`)
|
|
315
|
+
return { ...card, media, files: [f, at] }
|
|
316
|
+
}
|
package/src/social/routes.ts
CHANGED
|
@@ -158,6 +158,11 @@ export async function socialRoutes(root: string, req: Request, path: string): Pr
|
|
|
158
158
|
Bun.spawn(['open', '-R', file], { stdout: 'ignore', stderr: 'ignore' })
|
|
159
159
|
return Response.json({ ok: true })
|
|
160
160
|
}
|
|
161
|
+
if (sub === 'media-back') {
|
|
162
|
+
// a draft's media on the disk, brought back from the Space when the disk let it go: its path is pasted
|
|
163
|
+
const { desk } = await openDesk(root)
|
|
164
|
+
return Response.json({ path: await socialMediaBack(root, draftMedia(desk, str(b.slug, 'draft', DRAFT_NAME), str(b.name, 'media'))) })
|
|
165
|
+
}
|
|
161
166
|
const { desk } = await openDesk(root)
|
|
162
167
|
if (sub === 'posted') return Response.json({ files: setPosted(desk, str(b.slug, 'draft', DRAFT_NAME), str(b.key, 'message', KEY), urlOrNull(b.url)) })
|
|
163
168
|
if (sub === 'live') return Response.json({ files: setLive(desk, str(b.identity, 'identity', ID), str(b.account, 'account', ID), urlOrNull(b.url)) })
|
package/src/social/stage.ts
CHANGED
|
@@ -36,6 +36,9 @@ export type StageInput = {
|
|
|
36
36
|
/** his text, under each heading */
|
|
37
37
|
text: string
|
|
38
38
|
media?: StageMedia | null
|
|
39
|
+
/** a picture before the media, the one a heading with no media of its own attaches: a release's card */
|
|
40
|
+
cover?: StageMedia | null
|
|
41
|
+
/** the first media's description: the cover's when there is one */
|
|
39
42
|
alt?: string
|
|
40
43
|
rating: PostRating
|
|
41
44
|
/** unset, its source's: `feature` from a card, `release` from a release (wiki guides/post-kinds/index.md) */
|
|
@@ -58,9 +61,9 @@ export type StageInput = {
|
|
|
58
61
|
* release's nsfw picture on the venue that takes it), its `name` beside another message on the same account */
|
|
59
62
|
export type StageHeading = ReleaseHeading & { name?: string; rating?: PostRating; media?: StageMedia }
|
|
60
63
|
|
|
61
|
-
/** every media a stage copies: the draft's, then each heading's own, once a name */
|
|
62
|
-
export function stageMedia(input: Pick<StageInput, 'media' | 'headings'>): { name: string; file: string }[] {
|
|
63
|
-
const all = [input.media, ...(input.headings ?? []).map((h) => h.media)].filter((m): m is StageMedia => m != null)
|
|
64
|
+
/** every media a stage copies: the draft's (its cover first), then each heading's own, once a name */
|
|
65
|
+
export function stageMedia(input: Pick<StageInput, 'media' | 'cover' | 'headings'>): { name: string; file: string }[] {
|
|
66
|
+
const all = [input.cover, input.media, ...(input.headings ?? []).map((h) => h.media)].filter((m): m is StageMedia => m != null)
|
|
64
67
|
const out = new Map<string, string>()
|
|
65
68
|
for (const m of all) out.set(mediaFile(m), m.file)
|
|
66
69
|
return [...out].map(([name, file]) => ({ name, file }))
|
|
@@ -79,16 +82,17 @@ export const mediaFile = (m: StageMedia): string => {
|
|
|
79
82
|
return `media/${m.name}${m.vertical && ext === '.mp4' ? '-vertical' : ''}${ext === '.jpeg' ? '.jpg' : ext}`
|
|
80
83
|
}
|
|
81
84
|
|
|
82
|
-
/** the draft.md a stage writes, `media` its media name as the draft gives it */
|
|
85
|
+
/** the draft.md a stage writes, `media` its media name as the draft gives it, after its cover's */
|
|
83
86
|
export function draftText(input: StageInput, media: string | null): string {
|
|
84
87
|
const one = (v: string | undefined): string => (v ?? '').replace(/\s*\n\s*/g, ' ').trim()
|
|
88
|
+
const listed = [...(input.cover ? [mediaFile(input.cover)] : []), ...(media ? [media] : [])]
|
|
85
89
|
const head = [
|
|
86
90
|
`title: ${one(input.title)}`,
|
|
87
91
|
`kind: ${stagedKind(input)}`,
|
|
88
92
|
...(one(input.kindWhy) ? [`kindWhy: ${one(input.kindWhy)}`] : []),
|
|
89
93
|
`status: ${input.status ?? 'picked'}`,
|
|
90
94
|
`rating: ${input.rating}`,
|
|
91
|
-
...(
|
|
95
|
+
...(listed.length ? [`media: ${listed.join(', ')}`] : []),
|
|
92
96
|
...(one(input.alt) ? [`alt: ${one(input.alt)}`] : []),
|
|
93
97
|
...(input.slot ? [`slot: ${input.slot}`] : []),
|
|
94
98
|
sourceLine(input.source),
|
package/src/trailer/build.ts
CHANGED
|
@@ -119,6 +119,7 @@ export async function load(file: string, root: string, o: { text?: string; dir?:
|
|
|
119
119
|
l.errors.push(...findRecipes(l))
|
|
120
120
|
// the brand is read only for a cut that names one of its text styles: a check stays quick
|
|
121
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)))
|
|
122
123
|
if (l.errors.length === 0) l.errors.push(...checkFiles(l))
|
|
123
124
|
if (l.errors.length === 0 && t.score) {
|
|
124
125
|
const c = compileScore(t.score, t.sections, trailerCache(root, 'score'))
|
|
@@ -262,6 +263,28 @@ export async function fontLines(l: Loaded): Promise<string[]> {
|
|
|
262
263
|
return [...seen.values()]
|
|
263
264
|
}
|
|
264
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
|
+
|
|
265
288
|
/** the clips, images and sound files the lines name, each found where it should be */
|
|
266
289
|
function checkFiles(l: Loaded): TrailerError[] {
|
|
267
290
|
const out: TrailerError[] = []
|
|
@@ -377,6 +400,7 @@ export function sayErrors(l: Loaded, say: Say, cwd: string): boolean {
|
|
|
377
400
|
|
|
378
401
|
const filmText = (f: Film | null): string => {
|
|
379
402
|
if (!f) return 'nothing'
|
|
403
|
+
if (f.kind === 'clip' && f.recording !== undefined) return `recording ${f.recording}`
|
|
380
404
|
if (f.kind === 'clip' || f.kind === 'image') return `${f.kind} ${f.path}`
|
|
381
405
|
if (f.kind === 'run') return `run "${f.cmd}"${f.still ? ' still' : ''}`
|
|
382
406
|
if (f.kind === 'cli') return f.argv.join(' ')
|
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
|
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
|
|
@@ -853,6 +854,12 @@ function coreFilm(kind: string, ws: Word[], line: number): Film {
|
|
|
853
854
|
pairs(`film clip ${path}`, ws.slice(2), {})
|
|
854
855
|
return { kind, line, path }
|
|
855
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
|
+
}
|
|
856
863
|
case 'image': {
|
|
857
864
|
const path = pathWord('film image', ws[1])
|
|
858
865
|
if (!/\.(png|jpe?g|webp)$/i.test(path)) bad(`film image wants an image file (.png, .jpg, .webp), got ${path}`)
|
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)
|
package/src/veille/chrome.ts
CHANGED
|
@@ -118,10 +118,13 @@ export async function reveal(abs: string): Promise<void> {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
const COPY = 'function run(argv){ObjC.import("AppKit");const pb=$.NSPasteboard.generalPasteboard;pb.clearContents;return pb.writeObjects($([$.NSURL.fileURLWithPath(argv[0])]))}'
|
|
121
|
+
// one clipboard item that is the file and its image: a mail or a chat attaches the file, a terminal pastes the image
|
|
122
|
+
const COPY_IMAGE = 'function run(argv){ObjC.import("AppKit");const pb=$.NSPasteboard.generalPasteboard;pb.clearContents;const it=$.NSPasteboardItem.alloc.init;it.setStringForType($.NSURL.fileURLWithPath(argv[0]).absoluteString,"public.file-url");const d=$.NSData.dataWithContentsOfFile(argv[0]);if(d.isNil())return false;it.setDataForType(d,"public.png");return pb.writeObjects($([it]))}'
|
|
121
123
|
|
|
122
|
-
/** a file on the macOS clipboard as Finder's « Copier » puts it: a paste in Chrome's compose box attaches the file
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
/** a file on the macOS clipboard as Finder's « Copier » puts it: a paste in Chrome's compose box attaches the file;
|
|
125
|
+
* `image`: a PNG, also as its image, for an app that pastes only images (a terminal) */
|
|
126
|
+
export async function copyFile(abs: string, o: { image?: boolean } = {}): Promise<void> {
|
|
127
|
+
const p = Bun.spawn(['osascript', '-l', 'JavaScript', '-e', o.image ? COPY_IMAGE : COPY, abs], { stdout: 'pipe', stderr: 'pipe' })
|
|
125
128
|
const [out, err, code] = [await new Response(p.stdout).text(), await new Response(p.stderr).text(), await p.exited]
|
|
126
129
|
if (code !== 0 || out.trim() !== 'true') throw new Error(`the clipboard refused ${abs}: ${err.trim() || out.trim() || `exit ${code}`}`)
|
|
127
130
|
}
|