rvlib-shipkit 2.18.0 → 2.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/package.json +1 -1
  3. package/src/annex/annex.ts +227 -0
  4. package/src/annex/offload.ts +279 -0
  5. package/src/asks/asks-queue.ts +63 -10
  6. package/src/checks/SK040-release-words.check.ts +43 -0
  7. package/src/checks/SK041-annex-links.check.ts +28 -0
  8. package/src/checks/SK042-post-kinds.check.ts +73 -0
  9. package/src/cli/cmd_Annex.ts +179 -0
  10. package/src/cli/cmd_Asks.ts +3 -1
  11. package/src/cli/cmd_Commands.ts +4 -1
  12. package/src/cli/cmd_GlobalProcesses.ts +34 -11
  13. package/src/cli/cmd_Home.ts +41 -4
  14. package/src/cli/cmd_Messages.ts +155 -0
  15. package/src/cli/cmd_Releases.ts +48 -0
  16. package/src/cli/cmd_Review.ts +161 -6
  17. package/src/cli/cmd_Secret.ts +4 -30
  18. package/src/cli/cmd_Shot.ts +4 -4
  19. package/src/cli/cmd_Social.ts +179 -3
  20. package/src/cli/cmd_Trailer.ts +15 -3
  21. package/src/cli/family-pages.ts +2 -0
  22. package/src/cli/kit/index.ts +1 -1
  23. package/src/cli/kit/verb.ts +11 -3
  24. package/src/cli/registry.ts +8 -2
  25. package/src/collections/actions.ts +29 -1
  26. package/src/collections/collection-types.ts +10 -1
  27. package/src/collections/providers.ts +5 -2
  28. package/src/commands/model.ts +36 -0
  29. package/src/commands/registry.ts +49 -0
  30. package/src/commands/routes.ts +59 -0
  31. package/src/commands/runner.ts +35 -0
  32. package/src/commands/runs.ts +112 -0
  33. package/src/core/app-icon.ts +4 -3
  34. package/src/core/icon-type.ts +8 -0
  35. package/src/core/jobs.ts +4 -3
  36. package/src/core/layout.ts +5 -2
  37. package/src/core/squircle.ts +95 -0
  38. package/src/home/daemon-jobs.ts +26 -2
  39. package/src/home/global-units.ts +3 -0
  40. package/src/home/gui-app/ShipkitGui.swift +302 -5
  41. package/src/home/gui-app.ts +63 -33
  42. package/src/home/hmr-keep.ts +134 -0
  43. package/src/home/home-paths.ts +5 -1
  44. package/src/home/home-start.ts +14 -14
  45. package/src/home/lib-watch.ts +21 -11
  46. package/src/home/pm.ts +1 -1
  47. package/src/home/process-apps.ts +181 -0
  48. package/src/home/resources.ts +3 -3
  49. package/src/home/run-daemon.ts +11 -2
  50. package/src/home/run-pm.ts +9 -1
  51. package/src/home/run-web.ts +7 -4
  52. package/src/home/serve-web.ts +64 -14
  53. package/src/home/supervise.ts +3 -1
  54. package/src/identities/collection.ts +49 -0
  55. package/src/identities/identities.ts +130 -11
  56. package/src/identities/machine.ts +4 -3
  57. package/src/identities/rating.ts +33 -0
  58. package/src/identities/shown.ts +170 -0
  59. package/src/identities/steps.ts +5 -0
  60. package/src/media-store/purge.ts +15 -1
  61. package/src/media-store/remote.ts +22 -6
  62. package/src/messages/brief.ts +117 -0
  63. package/src/messages/collection.ts +40 -0
  64. package/src/messages/model.ts +171 -0
  65. package/src/messages/routes.ts +15 -0
  66. package/src/messages/score.ts +180 -0
  67. package/src/messages/tabs.ts +13 -0
  68. package/src/release/notes.ts +130 -0
  69. package/src/release/run-bump.ts +41 -18
  70. package/src/release/run-release.ts +22 -4
  71. package/src/release/run-releases.ts +17 -15
  72. package/src/release/unit-resolve.ts +9 -0
  73. package/src/releases/add.ts +66 -0
  74. package/src/releases/collection.ts +36 -0
  75. package/src/releases/from-card.ts +66 -0
  76. package/src/releases/model.ts +267 -0
  77. package/src/releases/pictures.ts +89 -0
  78. package/src/releases/routes.ts +36 -0
  79. package/src/releases/store.ts +71 -0
  80. package/src/repo-config.ts +5 -0
  81. package/src/review/cells.ts +0 -11
  82. package/src/review/format.ts +10 -6
  83. package/src/review/http.ts +7 -2
  84. package/src/review/model.ts +92 -3
  85. package/src/review/notes.ts +2 -48
  86. package/src/review/routes.ts +28 -10
  87. package/src/review/stage-card.ts +197 -0
  88. package/src/review/stage-routes.ts +123 -0
  89. package/src/review/store.ts +117 -19
  90. package/src/review/trailer-card.ts +99 -0
  91. package/src/review/trailer-desk.ts +57 -4
  92. package/src/review/trailer-model.ts +41 -7
  93. package/src/review/trailer-notes.ts +45 -0
  94. package/src/review/trailer-routes.ts +22 -13
  95. package/src/secrets/manager.ts +59 -0
  96. package/src/secrets/name.ts +2 -0
  97. package/src/serve/hub-app/app-bridge.ts +71 -0
  98. package/src/serve/hub-app/col-card.tsx +10 -0
  99. package/src/serve/hub-app/cols-svc.ts +37 -6
  100. package/src/serve/hub-app/commands/commands-page.tsx +122 -0
  101. package/src/serve/hub-app/commands/commands-st.ts +177 -0
  102. package/src/serve/hub-app/commands.css +24 -0
  103. package/src/serve/hub-app/hash-route.ts +40 -1
  104. package/src/serve/hub-app/home-st.ts +11 -2
  105. package/src/serve/hub-app/home.html +3 -0
  106. package/src/serve/hub-app/hub-app.tsx +6 -0
  107. package/src/serve/hub-app/hub.css +1 -0
  108. package/src/serve/hub-app/icons.tsx +5 -0
  109. package/src/serve/hub-app/identities-view.tsx +4 -1
  110. package/src/serve/hub-app/identities.css +1 -0
  111. package/src/serve/hub-app/index.html +3 -0
  112. package/src/serve/hub-app/keys.ts +2 -2
  113. package/src/serve/hub-app/machine-st.ts +41 -10
  114. package/src/serve/hub-app/messages/messages-page.tsx +354 -0
  115. package/src/serve/hub-app/messages/messages-st.ts +74 -0
  116. package/src/serve/hub-app/messages.css +35 -0
  117. package/src/serve/hub-app/releases/releases-page.tsx +94 -0
  118. package/src/serve/hub-app/releases/releases-st.ts +69 -0
  119. package/src/serve/hub-app/releases.css +25 -0
  120. package/src/serve/hub-app/repo-sections.ts +15 -1
  121. package/src/serve/hub-app/repo-st.ts +56 -5
  122. package/src/serve/hub-app/review/clip-st.ts +31 -3
  123. package/src/serve/hub-app/review/note-place.ts +31 -0
  124. package/src/serve/hub-app/review/review-cells.tsx +27 -3
  125. package/src/serve/hub-app/review/review-st.ts +77 -2
  126. package/src/serve/hub-app/review/review-thread.tsx +9 -31
  127. package/src/serve/hub-app/review/review-views.tsx +164 -58
  128. package/src/serve/hub-app/review/thread-st.ts +108 -41
  129. package/src/serve/hub-app/review/trailer-card.tsx +187 -0
  130. package/src/serve/hub-app/review/trailer-page.tsx +62 -31
  131. package/src/serve/hub-app/review/trailer-st.ts +138 -26
  132. package/src/serve/hub-app/review/trailer-timeline.tsx +39 -26
  133. package/src/serve/hub-app/review.css +49 -6
  134. package/src/serve/hub-app/social/comms-page.tsx +55 -23
  135. package/src/serve/hub-app/social/identity-pictures.ts +112 -0
  136. package/src/serve/hub-app/social/kit.tsx +9 -6
  137. package/src/serve/hub-app/social/post-card.tsx +10 -2
  138. package/src/serve/hub-app/social/social-model.ts +37 -3
  139. package/src/serve/hub-app/social/social-page.tsx +236 -82
  140. package/src/serve/hub-app/social/social-st.ts +79 -26
  141. package/src/serve/hub-app/social/stage-popup.tsx +268 -0
  142. package/src/serve/hub-app/social/stage-st.ts +310 -0
  143. package/src/serve/hub-app/social/step-layout.ts +42 -0
  144. package/src/serve/hub-app/social.css +68 -4
  145. package/src/serve/hub-app/tree-build.ts +38 -1
  146. package/src/serve/hub-app/tree-svc.ts +10 -3
  147. package/src/serve/project-gutter-route.ts +4 -2
  148. package/src/serve/same-origin.ts +24 -1
  149. package/src/serve/serve-hub.ts +27 -3
  150. package/src/shipkit-files.ts +9 -7
  151. package/src/shot/shooter.ts +3 -3
  152. package/src/shot/shot-ask.ts +14 -3
  153. package/src/shot/shot.shipkit.ts +1 -1
  154. package/src/social/discord-layout.ts +282 -0
  155. package/src/social/fit.ts +84 -0
  156. package/src/social/identity-words.ts +74 -0
  157. package/src/social/kind-pages.ts +41 -0
  158. package/src/social/kinds.ts +92 -0
  159. package/src/social/load.ts +105 -9
  160. package/src/social/md.ts +14 -6
  161. package/src/social/media-limit.ts +63 -2
  162. package/src/social/presence.ts +1 -1
  163. package/src/social/publish/bluesky.ts +58 -19
  164. package/src/social/publish/discord.ts +3 -2
  165. package/src/social/publish/index.ts +31 -5
  166. package/src/social/reach.ts +49 -0
  167. package/src/social/release-stage.ts +173 -0
  168. package/src/social/routes.ts +44 -9
  169. package/src/social/stage.ts +227 -0
  170. package/src/social/strip.ts +85 -0
  171. package/src/social/text.ts +6 -2
  172. package/src/social/unit.ts +57 -1
  173. package/src/social/writes.ts +11 -0
  174. package/src/stores/routes.ts +2 -2
  175. package/src/suite/judge-suites.ts +1 -1
  176. package/src/suite/suite-cli.ts +5 -5
  177. package/src/trailer/build.ts +90 -52
  178. package/src/trailer/draft.ts +28 -0
  179. package/src/trailer/footage.ts +4 -2
  180. package/src/trailer/grammar.ts +25 -13
  181. package/src/trailer/graph.ts +32 -9
  182. package/src/trailer/profile.ts +35 -0
  183. package/src/trailer/prune.ts +15 -10
  184. package/src/trailer/public-words.ts +41 -0
  185. package/src/trailer/stitch.ts +22 -10
  186. package/src/trailer/titles.ts +47 -2
@@ -147,8 +147,8 @@ export interface Title {
147
147
  /** null: to the shot's end */
148
148
  for: number | null
149
149
  style: TitleStyle
150
- /** where a caption sits: the bottom by default */
151
- place?: 'top' | 'bottom'
150
+ /** where a caption sits: the bottom by default; `middle` centres a big title on both axes */
151
+ place?: TitlePlace
152
152
  /** knocked off the frame from this second of its shot: it tips and flies out */
153
153
  knock?: number
154
154
  /** a `progress` line's step: the i-th of n notches filled under its name */
@@ -186,18 +186,20 @@ export interface TitleFx {
186
186
  glow?: { px: number; color?: string }
187
187
  /** the widest share of the frame's width the word takes */
188
188
  fit?: number
189
- /** the subtitle's height to the word's */
189
+ /** the subtitle's height to the word's (a big title: its lines after the first break, to the first's) */
190
190
  sub?: number
191
191
  /** the space between the word and its subtitle, a share of the word's height */
192
192
  gap?: number
193
193
  /** the word's middle at this share of the frame's height (default: the whole block's middle at 0.48) */
194
194
  middle?: number
195
- /** the soft shade round the logo, its radius a share of the frame's longer side; 0 for none */
195
+ /** the soft shade round the logo, its radius a share of the frame's longer side; 0 for none (a big title: a scrim
196
+ * round its words, its alpha at the middle, so they read over a busy picture) */
196
197
  shade?: number
197
198
  }
198
199
 
199
- /** the look words only a logo title reads */
200
+ /** the look words only a logo title reads, `sub` and `shade` a big title too */
200
201
  export const LOGO_WORDS = ['fit', 'sub', 'gap', 'middle', 'shade'] as const
202
+ const BIG_TOO: readonly string[] = ['sub', 'shade']
201
203
 
202
204
  /** how a made sound is made (design call 9): its seed, the voice or engine it is made `by`, its length (`for`), an sfx
203
205
  * trimmed to its first `hit` */
@@ -312,6 +314,9 @@ export interface Shot {
312
314
  music: Music | null
313
315
  /** its own line failed: nothing else is checked against it */
314
316
  broken?: true
317
+ /** broken by its film line alone: its length and its place on the cut still hold, so a parse that does not know a
318
+ * film word (the hub's, with no project CLI) times the cut as the build does */
319
+ filmOnly?: true
315
320
  /** a `footage` block: filmed, never cut in */
316
321
  offcut?: true
317
322
  }
@@ -566,7 +571,7 @@ const TITLE_WORDS: Record<string, (w: Word | undefined, k: string) => unknown> =
566
571
  for: (w, k) => time(k, w),
567
572
  place: (w, k) => {
568
573
  const pl = word(k, w)
569
- return pl === 'top' || pl === 'bottom' ? pl : bad(`${k} wants top|bottom, got ${pl}`)
574
+ return pl === 'top' || pl === 'middle' || pl === 'bottom' ? pl : bad(`${k} wants top|middle|bottom, got ${pl}`)
570
575
  },
571
576
  knock: (w, k) => time(k, w),
572
577
  font: (w, k) => pathWord(k, w),
@@ -636,7 +641,7 @@ const fxOf = (v: Record<string, unknown>): TitleFx => Object.fromEntries(FX_WORD
636
641
  const builtInStyle = (st: string): st is TitleStyle => (TITLE_STYLES as readonly string[]).includes(st)
637
642
  /** a logo word on a title of another style fails: nothing would read it */
638
643
  const logoOnly = (style: TitleStyle, fx: TitleFx | undefined): void => {
639
- const odd = LOGO_WORDS.filter((w) => fx?.[w] !== undefined)
644
+ const odd = LOGO_WORDS.filter((w) => fx?.[w] !== undefined && !(style === 'big' && BIG_TOO.includes(w)))
640
645
  if (style !== 'logo' && odd.length > 0) bad(`title ${odd.join(', ')}: a logo's words, this title is ${style}`)
641
646
  }
642
647
 
@@ -673,7 +678,7 @@ export function resolveStyles(t: Pick<Trailer, 'shots'>, styles: Readonly<Record
673
678
  const fx = { ...fxOf(under), ...ti.fx }
674
679
  logoOnly(ti.style, fx)
675
680
  if (Object.keys(fx).length > 0) ti.fx = fx
676
- if (under.place && !ti.place) ti.place = under.place as 'top' | 'bottom'
681
+ if (under.place && !ti.place) ti.place = under.place as TitlePlace
677
682
  if (under.in && !ti.in) ti.in = under.in as Move
678
683
  if (under.out && !ti.out && ti.knock === undefined) ti.out = under.out as Move
679
684
  } catch (e) {
@@ -1104,7 +1109,7 @@ export function parseTrailer(text: string, o: ParseOptions = {}): { trailer: Tra
1104
1109
  if ('error' in tk) {
1105
1110
  errors.push({ line: n, message: tk.error })
1106
1111
  // its own line failed: the shot is not also told it films nothing
1107
- if (shot && /^\s*film(\s|$)/.test(lines[n - 1]!)) shot.broken = true
1112
+ if (shot && /^\s*film(\s|$)/.test(lines[n - 1]!)) filmFailed(shot)
1108
1113
  continue
1109
1114
  }
1110
1115
  const ws = tk.words
@@ -1379,7 +1384,7 @@ export function parseTrailer(text: string, o: ParseOptions = {}): { trailer: Tra
1379
1384
  // a brand style is laid in by resolveStyles, once the brand is read
1380
1385
  style: builtInStyle(st) ? st : 'caption',
1381
1386
  ...(builtInStyle(st) ? {} : { named: st }),
1382
- ...(p.place ? { place: p.place as 'top' | 'bottom' } : {}),
1387
+ ...(p.place ? { place: p.place as TitlePlace } : {}),
1383
1388
  ...(p.knock !== undefined ? { knock: p.knock as number } : {}),
1384
1389
  ...(p.in ? { in: p.in as Move } : {}),
1385
1390
  ...(p.out ? { out: p.out as Move } : {}),
@@ -1502,7 +1507,7 @@ export function parseTrailer(text: string, o: ParseOptions = {}): { trailer: Tra
1502
1507
  } catch (e) {
1503
1508
  if (!(e instanceof LineError)) throw e
1504
1509
  errors.push({ line: n, message: e.message })
1505
- if (shot && head.text === 'film') shot.broken = true
1510
+ if (shot && head.text === 'film') filmFailed(shot)
1506
1511
  }
1507
1512
  }
1508
1513
  if (!seen.has('trailer')) errors.push({ line: 1, message: 'the file names its trailer first: trailer <name>' })
@@ -1565,6 +1570,12 @@ export function parseTrailer(text: string, o: ParseOptions = {}): { trailer: Tra
1565
1570
  /** the least a fitted shot keeps past its cut out */
1566
1571
  const FIT_MIN_S = 0.3
1567
1572
 
1573
+ /** a shot's film line failed: nothing more is checked against it, and when its own line held, its timing still does */
1574
+ function filmFailed(s: Shot): void {
1575
+ if (!s.broken) s.filmOnly = true
1576
+ s.broken = true
1577
+ }
1578
+
1568
1579
  /** a section's start, or a mark's moment, in the timeline's seconds; null when no section or mark has that name */
1569
1580
  function momentOf(t: Pick<Trailer, 'sections'>, name: string): number | null {
1570
1581
  for (const sec of t.sections) {
@@ -1582,8 +1593,9 @@ function momentOf(t: Pick<Trailer, 'sections'>, name: string): number | null {
1582
1593
  */
1583
1594
  function landShots(t: Trailer): TrailerError[] {
1584
1595
  const out: TrailerError[] = []
1596
+ const timed = (s: Shot): boolean => !s.broken || s.filmOnly === true
1585
1597
  t.shots.forEach((s, i) => {
1586
- if (s.broken) return
1598
+ if (!timed(s)) return
1587
1599
  const land = s.lands ?? (s.section ? { line: s.section.line, on: s.section.name, offset: 0 } : null)
1588
1600
  if (!land) return
1589
1601
  const moment = momentOf(t, land.on)
@@ -1597,7 +1609,7 @@ function landShots(t: Trailer): TrailerError[] {
1597
1609
  return
1598
1610
  }
1599
1611
  const prev = t.shots[i - 1]
1600
- if (!prev || prev.broken) {
1612
+ if (!prev || !timed(prev)) {
1601
1613
  out.push({ line: land.line, message: `shot ${s.name}: no shot before it to fit` })
1602
1614
  return
1603
1615
  }
@@ -529,16 +529,39 @@ export interface MixLevel {
529
529
  /** how close a mix lands to its `master`, LU */
530
530
  export const MASTER_TOLERANCE = 0.3
531
531
 
532
- /** the level of the mix's next pass, from what the last one measured; null: it holds. Over the ceiling, the trim drops
533
- * by the overshoot; off its master, the gain moves by the gap, the limiter taking the peaks it raises */
534
- export function nextMixLevel(master: number | null, m: { lufs: number; truePeak: number }, level: MixLevel): MixLevel | null {
535
- const over = m.truePeak - MIX_TRUE_PEAK
536
- const gap = master === null ? 0 : master - m.lufs
532
+ /** one pass of the mix: its level and what ebur128 measured of it */
533
+ export interface MixPass {
534
+ level: MixLevel
535
+ m: { lufs: number; truePeak: number }
536
+ }
537
+
538
+ /** a dB of gain moves the loudness by less once the limiter takes the peaks it raises: this much at least */
539
+ const MIN_SLOPE = 0.25
540
+
541
+ /** the level of the mix's next pass, from the passes so far (the last one last); null: it holds. Over the ceiling, the
542
+ * trim drops by the overshoot. Off its master, the gain moves by the gap that trim leaves (it lowers the loudness dB
543
+ * for dB), over how much a dB of gain moved the loudness between the last two gains (1 before a second gain). The
544
+ * gaps are rounded to ebur128's tenth, so a mix measured on the tolerance holds */
545
+ export function nextMixLevel(master: number | null, passes: readonly MixPass[]): MixLevel | null {
546
+ const { level, m } = passes.at(-1)!
547
+ const over = +(m.truePeak - MIX_TRUE_PEAK).toFixed(2)
548
+ const gap = master === null ? 0 : +(master - m.lufs).toFixed(2)
537
549
  if (over <= 0 && Math.abs(gap) <= MASTER_TOLERANCE) return null
538
- return {
539
- gain: Math.abs(gap) > MASTER_TOLERANCE ? +(level.gain + gap).toFixed(2) : level.gain,
540
- trim: over > 0 ? +(level.trim - over - 0.1).toFixed(2) : level.trim,
541
- }
550
+ const trim = over > 0 ? +(level.trim - over - 0.1).toFixed(2) : level.trim
551
+ const left = +(gap - (trim - level.trim)).toFixed(2)
552
+ if (master === null || Math.abs(left) <= MASTER_TOLERANCE) return { gain: level.gain, trim }
553
+ const before = passes.findLast((p) => p.level.gain !== level.gain)
554
+ const moved = before ? (m.lufs - level.trim - (before.m.lufs - before.level.trim)) / (level.gain - before.level.gain) : 1
555
+ const slope = Math.min(1, Math.max(MIN_SLOPE, moved))
556
+ return { gain: +(level.gain + left / slope).toFixed(2), trim }
557
+ }
558
+
559
+ /** the pass a mix that never held keeps: under the ceiling and nearest its master, else the lowest peak */
560
+ export function bestMixPass<P extends MixPass>(master: number | null, passes: readonly P[]): P {
561
+ const under = passes.filter((p) => +(p.m.truePeak - MIX_TRUE_PEAK).toFixed(2) <= 0)
562
+ const off = (p: MixPass): number => (master === null ? 0 : Math.abs(master - p.m.lufs))
563
+ if (under.length > 0) return under.reduce((a, b) => (off(b) < off(a) ? b : a))
564
+ return passes.reduce((a, b) => (b.m.truePeak < a.m.truePeak ? b : a))
542
565
  }
543
566
 
544
567
  /** the ffmpeg arguments that mix the cut's sound: the music trimmed, faded and ducked under each voice line, the sfx
@@ -0,0 +1,35 @@
1
+ // a build's phases on one clock, for `sk trailer --profile`: each span its name, its start and its length since the
2
+ // process started. A few performance.now calls a phase, so always recorded, printed only when asked. Spans that run
3
+ // side by side (the takes, the sections, the mix) overlap: their shares sum past 100 %
4
+ export interface Span {
5
+ name: string
6
+ at: number
7
+ ms: number
8
+ }
9
+
10
+ const spans: Span[] = []
11
+
12
+ /** `fn` timed under `name` */
13
+ export async function timed<T>(name: string, fn: () => Promise<T> | T): Promise<T> {
14
+ const at = performance.now()
15
+ try {
16
+ return await fn()
17
+ } finally {
18
+ spans.push({ name, at, ms: performance.now() - at })
19
+ }
20
+ }
21
+
22
+ /** a span measured by its caller: the process's own start, before any module of the build loaded */
23
+ export const span = (name: string, at: number, ms: number): void => void spans.push({ name, at, ms })
24
+
25
+ /** every span by its start, its seconds and its share of the whole run, then the whole run */
26
+ export function profileLines(): string[] {
27
+ const wall = performance.now()
28
+ const s = (ms: number): string => (ms / 1000).toFixed(2).padStart(7)
29
+ const w = Math.max(5, ...spans.map((x) => x.name.length))
30
+ return [
31
+ `profile: ${'phase'.padEnd(w)} start seconds share`,
32
+ ...[...spans].sort((a, b) => a.at - b.at).map((x) => `profile: ${x.name.padEnd(w)} ${s(x.at)} ${s(x.ms)} ${((100 * x.ms) / wall).toFixed(0).padStart(4)} %`),
33
+ `profile: ${'the whole run'.padEnd(w)} ${s(0)} ${s(wall)} 100 %`,
34
+ ]
35
+ }
@@ -29,7 +29,7 @@ export interface Live {
29
29
  /** the live set: each cut read, the name of every cache file its build reads, by the build's own key functions */
30
30
  export async function liveSet(root: string): Promise<Live> {
31
31
  const live: Live = { footage: new Set(), stems: new Set(), sound: new Set(), score: new Set(), titles: new Set(), broken: [] }
32
- const [{ fileOf, takesOfLoaded, titleRequest }, { trailerCache }, { scoreWavFile }, { scoreModuleFile, scoreModule }, titles, { lookOf }, { loadBrand, identityLogo }, fonts, { titleMotions }, { resolveStyles }] = await Promise.all([
32
+ const [{ fileOf, titleRequest }, { trailerCache, takesOf }, { scoreWavFile }, { scoreModuleFile, scoreModule }, titles, { lookOf }, { loadBrand, identityLogo }, fonts, { titleMotions }, { resolveStyles }, { draftOf }] = await Promise.all([
33
33
  import('./build.ts'),
34
34
  import('./footage.ts'),
35
35
  import('./score/sound.ts'),
@@ -40,6 +40,7 @@ export async function liveSet(root: string): Promise<Live> {
40
40
  import('./fonts.ts'),
41
41
  import('./graph.ts'),
42
42
  import('./grammar.ts'),
43
+ import('./draft.ts'),
43
44
  ])
44
45
  const brand = await loadBrand(root)
45
46
  const look = typeof brand === 'string' ? null : lookOf(brand, await identityLogo(root))
@@ -53,19 +54,23 @@ export async function liveSet(root: string): Promise<Live> {
53
54
  continue
54
55
  }
55
56
  const t = l.t
56
- const names = { footage: takesOfLoaded(l).map((tk) => basename(tk.file)), stems: [] as string[], titles: [] as string[], score: [] as string[], sound: [] as string[] }
57
- for (const p of pieces(t)) names.stems.push(`${t.name}-${p.name}`)
58
- names.stems.push(`mix-${t.name}`, `${t.name}-vertical`)
59
- if (look) {
57
+ const names = { footage: [] as string[], stems: [`mix-${t.name}`] as string[], titles: [] as string[], score: [] as string[], sound: [] as string[] }
58
+ // the cut and its draft (draft.ts), each its takes, pieces and titles; the draft plays the cut's mix
59
+ for (const lv of [l, { ...l, t: draftOf(t) }]) {
60
+ const tv = lv.t
61
+ names.footage.push(...takesOf(tv, root, l).map((tk) => basename(tk.file)))
62
+ for (const p of pieces(tv)) names.stems.push(`${tv.name}-${p.name}`)
63
+ names.stems.push(`${tv.name}-vertical`)
64
+ if (!look) continue
60
65
  const dir = trailerCache(root, 'titles')
61
- names.titles.push(basename(titles.cardFile(dir, t.size, look)))
62
- resolveStyles(t, (typeof brand === 'object' && brand?.trailer?.styles) || {})
63
- const motions = titleMotions(t)
64
- t.shots.forEach((s, i) =>
66
+ names.titles.push(basename(titles.cardFile(dir, tv.size, look)))
67
+ resolveStyles(tv, (typeof brand === 'object' && brand?.trailer?.styles) || {})
68
+ const motions = titleMotions(tv)
69
+ tv.shots.forEach((s, i) =>
65
70
  s.titles.forEach((ti, j) => {
66
71
  const f = ti.fx?.font
67
72
  const font = f === undefined ? null : fonts.isFontFile(f) ? fileOf(f, l) : fonts.googleFile(f, ti.fx?.weight ?? 400)
68
- names.titles.push(basename(titles.titleFile(dir, { ...titleRequest(l, ti, look, motions[i]![j]!), font })))
73
+ names.titles.push(basename(titles.titleFile(dir, { ...titleRequest(lv, ti, look, motions[i]![j]!), font })))
69
74
  }),
70
75
  )
71
76
  }
@@ -0,0 +1,41 @@
1
+ // a cut's public words through the repo's one guard (wiki tools/trailer/index.md, Its public words): each title and each
2
+ // voice line of a shot that is cut in, held to the rules of a public word by the social unit's `guard` (social/unit.ts
3
+ // guardWith), never a word list of the trailer's own. A recorded voice is read through its transcript beside the clip
4
+ // (`<clip>.txt`); one with none is said, so no spoken line passes unread in silence. A film line is how a take is made,
5
+ // never on screen: what its words turn on is the repo's own knowledge, read by its trailer unit's `check`
6
+ import { readFileSync } from 'node:fs'
7
+ import { guardWith, type GuardInput, type SocialUnit } from '../social/unit.ts'
8
+ import type { Trailer, TrailerError } from './grammar.ts'
9
+
10
+ /** one word of the cut a stranger reads or hears, at its line, as the guard reads it */
11
+ export type CutWord = { line: number; what: 'title' | 'voice line'; input: Partial<GuardInput> }
12
+
13
+ /** a voice the guard cannot read: a clip with no transcript beside it, a line a command makes */
14
+ export type Unread = { line: number; why: string }
15
+
16
+ const transcriptPath = (file: string): string => file.replace(/\.[^./]+$/, '.txt')
17
+
18
+ /** every title and voice line of the shots that are cut in, in line order, and the voices it cannot read; `find` finds
19
+ * a file as the cut finds its clips */
20
+ export function cutWords(t: Pick<Trailer, 'shots'>, find: (path: string) => string | null): { words: CutWord[]; unread: Unread[] } {
21
+ const words: CutWord[] = []
22
+ const unread: Unread[] = []
23
+ for (const s of t.shots) {
24
+ for (const ti of s.titles) if (ti.text.trim() !== '') words.push({ line: ti.line, what: 'title', input: { texts: [ti.text] } })
25
+ for (const v of s.voices) {
26
+ if (v.text != null && v.text.trim() !== '') words.push({ line: v.line, what: 'voice line', input: { texts: [v.text] } })
27
+ else if (v.file != null) {
28
+ const at = find(transcriptPath(v.file))
29
+ const said = at == null ? '' : readFileSync(at, 'utf8').trim()
30
+ if (said !== '') words.push({ line: v.line, what: 'voice line', input: { texts: [said] } })
31
+ else unread.push({ line: v.line, why: `voice file ${v.file}: no transcript beside it (${transcriptPath(v.file)}), so no guard read what it says` })
32
+ } else if (v.run != null) unread.push({ line: v.line, why: 'a voice a command makes: no guard read what it says' })
33
+ }
34
+ }
35
+ return { words: words.sort((a, b) => a.line - b.line), unread }
36
+ }
37
+
38
+ /** the guard's problems with a cut, each an error at its line; no unit or no guard, none */
39
+ export function cutProblems(unit: SocialUnit | null, words: readonly CutWord[]): TrailerError[] {
40
+ return words.flatMap((w) => guardWith(unit, w.input).map((p) => ({ line: w.line, message: `the repo's guard refuses this ${w.what}: ${p}` })))
41
+ }
@@ -6,9 +6,10 @@ import { availableParallelism } from 'node:os'
6
6
  import { dirname, join } from 'node:path'
7
7
  import sharp from 'sharp'
8
8
  import { ffmpeg, loudnessKept } from './ffmpeg.ts'
9
- import { type Encoder, GRID_RADIUS, gridLayout, type MixLevel, mixArgs, nextMixLevel, pieceArgs, type SplitMasks, splitPane, type StitchInput, THUMB_W } from './graph.ts'
9
+ import { bestMixPass, type Encoder, GRID_RADIUS, gridLayout, type MixLevel, type MixPass, mixArgs, nextMixLevel, pieceArgs, type SplitMasks, splitPane, type StitchInput, THUMB_W } from './graph.ts'
10
10
  import type { TrailerLook } from './look.ts'
11
11
  import { type Piece, pieces, twinStem } from './plan.ts'
12
+ import { timed } from './profile.ts'
12
13
 
13
14
  /** bump when the stitch changes what the same arguments make */
14
15
  const STITCH_VERSION = 1
@@ -182,13 +183,18 @@ export interface StitchRun extends StitchInput {
182
183
  encoder?: Encoder
183
184
  /** no sound at all: a shot's preview */
184
185
  silent?: boolean
186
+ /** the mix its caller started (renderMix of the same sounds), awaited in place of mixing again */
187
+ mixing?: ReturnType<typeof renderMix>
188
+ /** each piece draws its row of the strip (default); false: none, `thumbs` empty */
189
+ thumbs?: boolean
185
190
  }
186
191
 
187
192
  async function renderPieces(a: StitchRun, ps: Piece[]): Promise<Stitched['pieces']> {
193
+ const exts = a.thumbs === false ? ['mp4'] : ['mp4', 'png']
188
194
  return pool(
189
195
  ps.map((p) => async () => {
190
- const { files, made, twin, key } = await cached(a.cache, `${a.t.name}-${p.name}`, ['mp4', 'png'], ([video, row]) => pieceArgs(a, p, video!, a.encoder, row))
191
- return { ...p, made, key, ...(twin !== undefined ? { twin } : {}), file: files[0]!, thumbs: files[1]! }
196
+ const { files, made, twin, key } = await timed(`section ${p.name}`, () => cached(a.cache, `${a.t.name}-${p.name}`, exts, ([video, row]) => pieceArgs(a, p, video!, a.encoder, row)))
197
+ return { ...p, made, key, ...(twin !== undefined ? { twin } : {}), file: files[0]!, thumbs: files[1] ?? '' }
192
198
  }),
193
199
  LANES,
194
200
  )
@@ -196,16 +202,22 @@ async function renderPieces(a: StitchRun, ps: Piece[]): Promise<Stitched['pieces
196
202
 
197
203
  /** the mix, its true peak held under MIX_TRUE_PEAK after the aac encode (the encoder's band limit rings over a limited
198
204
  * harsh sound: a square wave measured +2.1 dB), and with a `master` its integrated loudness on it: each pass measured
199
- * as ebur128 hears it, then made again at the level nextMixLevel says, every pass kept in the cache */
205
+ * as ebur128 hears it, then made again at the level nextMixLevel says, every pass kept in the cache; a mix that never
206
+ * holds keeps its best pass (bestMixPass) */
200
207
  export async function renderMix(a: Pick<StitchRun, 't' | 'music' | 'sfx' | 'voices' | 'cache'>): Promise<{ file: string; key: string; made: boolean; twin?: string }> {
201
- const passes = a.t.master === null ? 3 : 6
208
+ const cap = a.t.master === null ? 3 : 6
209
+ const passes: (MixPass & { r: Render })[] = []
202
210
  let level: MixLevel = { gain: 0, trim: 0 }
203
211
  let made = false
204
212
  for (let pass = 1; ; pass++) {
205
- const r = await cached(join(a.cache, 'mix'), `mix-${a.t.name}`, ['m4a'], ([out]) => mixArgs(a, out!, level))
213
+ const r = await timed(`mix pass ${pass}`, () => cached(join(a.cache, 'mix'), `mix-${a.t.name}`, ['m4a'], ([out]) => mixArgs(a, out!, level)))
206
214
  made ||= r.made
207
- const next = nextMixLevel(a.t.master, await loudnessKept(r.files[0]!), level)
208
- if (next === null || pass === passes) return { file: r.files[0]!, key: r.key, made, ...(r.twin !== undefined && !made ? { twin: r.twin } : {}) }
215
+ passes.push({ level, m: await timed(`mix pass ${pass} measured`, () => loudnessKept(r.files[0]!)), r })
216
+ const next = nextMixLevel(a.t.master, passes)
217
+ if (next === null || pass === cap) {
218
+ const kept = next === null ? r : bestMixPass(a.t.master, passes).r
219
+ return { file: kept.files[0]!, key: kept.key, made, ...(kept.twin !== undefined && !made ? { twin: kept.twin } : {}) }
220
+ }
209
221
  level = next
210
222
  }
211
223
  }
@@ -230,8 +242,8 @@ async function joinPieces(files: string[], sound: { file: string; start?: number
230
242
 
231
243
  /** the whole cut: every piece (rendered where the cache misses it), joined, with its sound */
232
244
  export async function stitch(a: StitchRun): Promise<Stitched> {
233
- const [ps, mix] = await Promise.all([renderPieces(a, pieces(a.t)), a.silent ? null : renderMix(a)])
234
- await joinPieces(ps.map((p) => p.file), mix ? { file: mix.file } : null, a.out)
245
+ const [ps, mix] = await Promise.all([renderPieces(a, pieces(a.t)), a.silent ? null : (a.mixing ?? renderMix(a))])
246
+ await timed('join', () => joinPieces(ps.map((p) => p.file), mix ? { file: mix.file } : null, a.out))
235
247
  return { pieces: ps, ...mixOf(mix) }
236
248
  }
237
249
 
@@ -86,6 +86,20 @@ interface Ctx {
86
86
  const restCtx = (): Ctx => ({ n: 0, i: 0, decor: 1 })
87
87
 
88
88
  /** a plate, a band, a glow or the logo image: faded with the title's decor */
89
+ /** a paint at `s` times its size, every stroke and blur with it */
90
+ function scaled(p: Paint, s: number): Paint {
91
+ return {
92
+ ...p,
93
+ px: p.px * s,
94
+ spacing: p.spacing * s,
95
+ drop: p.drop ? { ...p.drop, dy: p.drop.dy * s } : (p.drop ?? null),
96
+ outline: p.outline ? { ...p.outline, w: p.outline.w * s, ...(p.outline.dy !== undefined ? { dy: p.outline.dy * s } : {}) } : null,
97
+ inner: p.inner ? { ...p.inner, w: p.inner.w * s } : null,
98
+ shadow: p.shadow ? { ...p.shadow, blur: p.shadow.blur * s, dy: p.shadow.dy * s } : null,
99
+ glow: p.glow ? { ...p.glow, blur: p.glow.blur * s } : null,
100
+ }
101
+ }
102
+
89
103
  function decor(cx: Ctx, g: SKRSContext2D, draw: () => void): void {
90
104
  g.save()
91
105
  g.globalAlpha *= cx.decor
@@ -400,9 +414,40 @@ function drawInto(g: SKRSContext2D, d: TitleDraw, [W, H]: readonly [number, numb
400
414
  } else if (style === 'big') {
401
415
  // a strong display line in the upper third: light words in a thick edge outline, an accent stroke inside it
402
416
  const p = own({ ...base((d.fx?.size ?? 112) * k, 900), outline: { w: 22 * k, color: look.edge }, inner: { w: 8 * k, color: look.accent }, shadow: { blur: 26 * k, dy: 10 * k, color: alpha(look.edge, 0.55) } })
417
+ // `place middle` centres the block on both axes; `sub` draws the lines after the first break that much smaller,
418
+ // `shade` lays a soft dark ellipse round the words (its alpha at the middle) so they read over a busy picture
419
+ const fx = d.fx
420
+ const small = fx?.sub !== undefined && more.length > 0 ? scaled(p, fx.sub) : null
403
421
  setFace(g, p)
404
- const lines = wrap(g, text, W * 0.82)
405
- lines.forEach((l, i) => ink(cx, g, p, l, W / 2, H * 0.26 + (i - (lines.length - 1) / 2) * p.px * 1.12))
422
+ const rows: { l: string; p: Paint }[] = (small ? wrap(g, first, W * 0.82) : wrap(g, text, W * 0.82)).map((l) => ({ l, p }))
423
+ if (small) {
424
+ setFace(g, small)
425
+ rows.push(...wrap(g, more.join('\\n'), W * 0.82).map((l) => ({ l, p: small })))
426
+ }
427
+ const block = rows.reduce((s, r) => s + r.p.px * 1.12, 0)
428
+ const cy = d.place === 'middle' ? H * 0.5 : H * 0.26
429
+ if (fx?.shade)
430
+ decor(cx, g, () => {
431
+ const wide = Math.max(...rows.map((r) => (setFace(g, r.p), g.measureText(r.l.replaceAll('*', '')).width)))
432
+ const [rx, ry] = [wide / 2 + 160 * k, block / 2 + 110 * k]
433
+ g.save()
434
+ g.translate(W / 2, cy)
435
+ g.scale(rx / ry, 1)
436
+ const a = Math.min(1, fx.shade!)
437
+ const s = g.createRadialGradient(0, 0, 0, 0, 0, ry)
438
+ s.addColorStop(0, alpha(look.edge, a))
439
+ s.addColorStop(0.55, alpha(look.edge, a * 0.75))
440
+ s.addColorStop(1, alpha(look.edge, 0))
441
+ g.fillStyle = s
442
+ g.fillRect(-ry, -ry, ry * 2, ry * 2)
443
+ g.restore()
444
+ })
445
+ let y = cy - block / 2
446
+ for (const r of rows) {
447
+ setFace(g, r.p)
448
+ ink(cx, g, r.p, r.l, W / 2, y + (r.p.px * 1.12) / 2)
449
+ y += r.p.px * 1.12
450
+ }
406
451
  } else if (style === 'line') {
407
452
  // a tagline: light words centred low on a soft dark band, no plate, the frame stays the picture
408
453
  const p = own({ ...base((d.fx?.size ?? 64) * k, look.font.weight), outline: { w: 9 * k, color: alpha(look.edge, 0.82) }, shadow: { blur: 18 * k, dy: 4 * k, color: alpha(look.edge, 0.85) } })