@bitmagic/cli 0.1.64-dev.7 → 0.1.64-dev.8

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 (41) hide show
  1. package/README.md +2 -2
  2. package/dist/commands/trailer.js +18 -4
  3. package/dist/commands/trailer.js.map +1 -1
  4. package/dist/editor/hud-replay-page.js +317 -22
  5. package/dist/editor/hud-replay-page.js.map +1 -1
  6. package/dist/render/qr-png.d.ts +6 -3
  7. package/dist/render/qr-png.js +8 -8
  8. package/dist/render/qr-png.js.map +1 -1
  9. package/dist/scaffold/skill-files.js +1 -0
  10. package/dist/scaffold/skill-files.js.map +1 -1
  11. package/dist/trailer/hud-raster.d.ts +12 -12
  12. package/dist/trailer/hud-raster.js +85 -32
  13. package/dist/trailer/hud-raster.js.map +1 -1
  14. package/dist/trailer/hud-state.d.ts +75 -4
  15. package/dist/trailer/hud-state.js +132 -17
  16. package/dist/trailer/hud-state.js.map +1 -1
  17. package/dist/trailer/io.d.ts +2 -0
  18. package/dist/trailer/io.js +6 -1
  19. package/dist/trailer/io.js.map +1 -1
  20. package/dist/trailer/link.d.ts +1 -0
  21. package/dist/trailer/link.js +15 -0
  22. package/dist/trailer/link.js.map +1 -0
  23. package/dist/trailer/make.d.ts +2 -0
  24. package/dist/trailer/make.js +1 -0
  25. package/dist/trailer/make.js.map +1 -1
  26. package/dist/trailer/merge.js +32 -11
  27. package/dist/trailer/merge.js.map +1 -1
  28. package/dist/trailer/render.d.ts +2 -0
  29. package/dist/trailer/render.js +94 -48
  30. package/dist/trailer/render.js.map +1 -1
  31. package/dist/trailer/timeline-types.d.ts +19 -0
  32. package/dist/trailer/timeline-types.js +42 -2
  33. package/dist/trailer/timeline-types.js.map +1 -1
  34. package/dist/trailer/title-raster.js +2 -1
  35. package/dist/trailer/title-raster.js.map +1 -1
  36. package/dist/trailer/titles.js +6 -1
  37. package/dist/trailer/titles.js.map +1 -1
  38. package/dist/trailer/video-chain.d.ts +96 -8
  39. package/dist/trailer/video-chain.js +183 -0
  40. package/dist/trailer/video-chain.js.map +1 -1
  41. package/package.json +4 -4
@@ -15,11 +15,14 @@
15
15
  *
16
16
  * Two other hand-rolled PNG encoders exist in this repo — `world-forger-internal`'s vehicle atlas
17
17
  * and `game-play-agent`'s solid-colour tile — and neither is reachable from here: the first is in a
18
- * `private: true` package the CLI does not depend on, the second is server code. A shared home
19
- * would have to be `@bitmagic/asset-core`; that is worth doing when something needs the third copy,
20
- * not for the second.
18
+ * `private: true` package the CLI does not depend on, the second is server code. Within the CLI the
19
+ * chunk/CRC/signature primitives are exported from here and shared with the trailer's transparent
20
+ * frame filler (trailer/video-chain.ts); `ios/icon.ts` predates that and keeps its own.
21
21
  */
22
22
  import { Buffer } from 'buffer';
23
+ export declare const PNG_SIGNATURE: Buffer<ArrayBuffer>;
24
+ /** One PNG chunk: length, type, data, and the CRC over type+data (never over the length). */
25
+ export declare function pngChunk(type: string, data: Buffer): Buffer;
23
26
  export interface QrPngOptions {
24
27
  /** Pixels per module. Defaults to `MODULE_PIXELS`. */
25
28
  scale?: number;
@@ -15,9 +15,9 @@
15
15
  *
16
16
  * Two other hand-rolled PNG encoders exist in this repo — `world-forger-internal`'s vehicle atlas
17
17
  * and `game-play-agent`'s solid-colour tile — and neither is reachable from here: the first is in a
18
- * `private: true` package the CLI does not depend on, the second is server code. A shared home
19
- * would have to be `@bitmagic/asset-core`; that is worth doing when something needs the third copy,
20
- * not for the second.
18
+ * `private: true` package the CLI does not depend on, the second is server code. Within the CLI the
19
+ * chunk/CRC/signature primitives are exported from here and shared with the trailer's transparent
20
+ * frame filler (trailer/video-chain.ts); `ios/icon.ts` predates that and keeps its own.
21
21
  */
22
22
  import { Buffer } from 'buffer';
23
23
  import * as zlib from 'zlib';
@@ -28,7 +28,7 @@ const MODULE_PIXELS = 8;
28
28
  * uses — that one is trading margin for terminal columns, and a file has no such constraint.
29
29
  */
30
30
  const QUIET_MODULES = 4;
31
- const PNG_SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
31
+ export const PNG_SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
32
32
  /** The standard CRC-32 table (PNG spec annex D), built once. */
33
33
  function buildCrcTable() {
34
34
  const table = new Uint32Array(256);
@@ -50,7 +50,7 @@ function crc32(bytes) {
50
50
  return (crc ^ 0xffffffff) >>> 0;
51
51
  }
52
52
  /** One PNG chunk: length, type, data, and the CRC over type+data (never over the length). */
53
- function chunk(type, data) {
53
+ export function pngChunk(type, data) {
54
54
  const length = Buffer.alloc(4);
55
55
  length.writeUInt32BE(data.length, 0);
56
56
  const typeAndData = Buffer.concat([Buffer.from(type, 'ascii'), data]);
@@ -101,11 +101,11 @@ export function encodeQrPng(matrix, options = {}) {
101
101
  ihdr[12] = 0; // interlace: none
102
102
  return Buffer.concat([
103
103
  PNG_SIGNATURE,
104
- chunk('IHDR', ihdr),
104
+ pngChunk('IHDR', ihdr),
105
105
  // deflateSync, not fflate's — fflate's `deflateSync` emits RAW deflate with no zlib header,
106
106
  // and an IDAT must carry the zlib wrapper. (fflate's `zlibSync` would also do.)
107
- chunk('IDAT', zlib.deflateSync(raw)),
108
- chunk('IEND', Buffer.alloc(0)),
107
+ pngChunk('IDAT', zlib.deflateSync(raw)),
108
+ pngChunk('IEND', Buffer.alloc(0)),
109
109
  ]);
110
110
  }
111
111
  //# sourceMappingURL=qr-png.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"qr-png.js","sourceRoot":"","sources":["../../src/render/qr-png.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,2FAA2F;AAC3F,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB;;;GAGG;AACH,MAAM,aAAa,G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IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC;gBAAE,GAAG,CAAC,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;QACjE,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC9B,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IACjC,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IACjC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY;IACzB,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,4BAA4B;IACzC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,mDAAmD;IACjE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,sDAAsD;IACpE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,kBAAkB;IAEhC,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,aAAa;QACb,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;QACtB,4FAA4F;QAC5F,gFAAgF;QAChF,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAClC,CAAC,CAAC;AACL,CAAC"}
@@ -256,6 +256,7 @@ The creator talks; you edit \`trailer/shots.json\`, run \`bitmagic trailer make\
256
256
  | "add a title at the start" | a \`title\`-style cue at \`at: 0\` for ~2.5 s, and make the first shot calm enough to read over |
257
257
  | "different music", "more epic / chill" | \`--music-prompt\` with the new direction (spends sparks), or \`--music <file>\`; shots keep their beat counts and re-snap |
258
258
  | "no HUD" / "show the HUD" | drop or add \`--ui\` (per shot: \`"ui": false\`) |
259
+ | "the HUD stutters" / "smoother HUD" | raise \`--ui-keyframe-rate\` on \`make\` or \`render\` (default 30/s; 0 = every change) |
259
260
  | "shorter / longer" | \`--seconds N\` only matters for a fresh auto cut (\`--reset-shots\`); otherwise add or remove shots |
260
261
  | "start over" | \`bitmagic trailer make --reset-shots\` |
261
262
  | "use the other recording" | \`--recording <dir>\`; shots.json from another recording is kept beside a fresh cut |
@@ -1 +1 @@
1
- {"version":3,"file":"skill-files.js","sourceRoot":"","sources":["../../src/scaffold/skill-files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGvD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO;;;;;;;;;;;;;;;;;;CAkBR,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAE,SAAS,EAAE,SAAS,EAAsB;IAC7E,2FAA2F;IAC3F,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC;IAC7F,6FAA6F;IAC7F,0EAA0E;IAC1E,MAAM,WAAW,GACf,QAAQ,CAAC,MAAM,KAAK,CAAC;QACnB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,8FAA8F;YAC9F,mEAAmE;YACnE,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5C,iFAAiF,CAAC;IAExF,OAAO;;sBAEa,SAAS,SAAS,iBAAiB,CAAC,SAAS,CAAC;;;EAGlE,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BZ,CAAC;AACF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C7F,0EAA0E;IAC1E,MAAM,WAAW,GACf,QAAQ,CAAC,MAAM,KAAK,CAAC;QACnB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,8FAA8F;YAC9F,mEAAmE;YACnE,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5C,iFAAiF,CAAC;IAExF,OAAO;;sBAEa,SAAS,SAAS,iBAAiB,CAAC,SAAS,CAAC;;;EAGlE,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BZ,CAAC;AACF,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuJR,CAAC;AACF,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8GR,CAAC;AACF,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,+BAA+B;IAC7C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkER,CAAC;AACF,CAAC"}
@@ -7,22 +7,22 @@ export interface RasterizeOptions {
7
7
  harnessUrl: string;
8
8
  /** Overlay PNGs are written here as ui_NNNN.png, one per keyframe. */
9
9
  outDir: string;
10
- /** Recording resolution — both the browser viewport and the HUD root size. */
10
+ /**
11
+ * CSS-pixel viewport the HUD lays out against — the recorded window's
12
+ * aspect-corrected size when the manifest carries one, else the recording
13
+ * resolution (see computeRasterGeometry in hud-state.ts).
14
+ */
11
15
  width: number;
12
16
  height: number;
17
+ /** PNG pixels per CSS pixel; >1 keeps overlays at/above the recording size. */
18
+ deviceScaleFactor: number;
13
19
  }
14
20
  export declare function uiPngPath(outDir: string, index: number): string;
15
21
  /**
16
22
  * Render one transparent PNG per keyframe, reusing a single browser + page.
17
- * Returns paths in keyframe order, or null when UI overlays must be skipped
18
- * (no Chrome, harness unreachable, or the harness rejected a state).
23
+ * Returns paths in keyframe order — a slot is null when that one keyframe
24
+ * failed (the caller holds the previous overlay across its window) — or null
25
+ * overall when UI must be skipped entirely (no Chrome, harness unreachable, the
26
+ * page died mid-run, or every keyframe failed).
19
27
  */
20
- export declare function rasterizeUiKeyframes(keyframes: readonly UiKeyframe[], options: RasterizeOptions): Promise<string[] | null>;
21
- /**
22
- * Width/height straight out of a PNG's IHDR chunk, so the filtergraph only
23
- * pays for a scale filter when the overlay really is the wrong size.
24
- */
25
- export declare function readPngSize(filePath: string): {
26
- width: number;
27
- height: number;
28
- } | null;
28
+ export declare function rasterizeUiKeyframes(keyframes: readonly UiKeyframe[], options: RasterizeOptions): Promise<Array<string | null> | null>;
@@ -4,12 +4,20 @@
4
4
  * The harness page (`/hud-replay.html` on the running `bitmagic dev` sidecar) owns a real GameHUD,
5
5
  * so the overlay is the game's own UI rather than a reimplementation. Contract:
6
6
  * window.__hudReplayReady === true when the page can accept states
7
- * window.__hudReplay.render(state) synchronous; applies a replay state
7
+ * window.__hudReplay.render(state, ms) synchronous; applies a replay state,
8
+ * `ms` seeding animation phase on the
9
+ * source clock (older harness: ignored)
8
10
  * window.__hudReplay.setViewport(w, h) sizes the HUD root
11
+ * window.__hudReplay.settle() optional; resolves when fonts/images
12
+ * the state started loading are in (or
13
+ * a short deadline passed)
9
14
  * plus a transparent page background, so `omitBackground` yields real alpha.
10
15
  *
11
- * Every failure path here degrades to "no overlays" (returns null) instead of failing the trailer:
12
- * a UI-less video still beats no video. Chrome is the creator's installed browser
16
+ * Failure here degrades instead of failing the trailer: a keyframe that will
17
+ * not rasterize becomes a null slot (the caller holds the previous overlay over
18
+ * its window), and only an unusable page — navigation failed, the page died, or
19
+ * every single keyframe threw — degrades to "no overlays" (null). A UI-less
20
+ * video still beats no video. Chrome is the creator's installed browser
13
21
  * (`channel: 'chrome'`), the same one `bitmagic verify` drives — nothing is downloaded.
14
22
  */
15
23
  import * as fs from 'fs';
@@ -18,20 +26,29 @@ import { chromium } from 'playwright-core';
18
26
  import { out, warn } from './io.js';
19
27
  const NAV_TIMEOUT_MS = 20000;
20
28
  const READY_TIMEOUT_MS = 20000;
29
+ /** Consecutive keyframe failures after which the run gives up on UI entirely. */
30
+ const MAX_CONSECUTIVE_FAILURES = 3;
21
31
  export const CHROME_MISSING_HINT = 'Google Chrome could not be launched — install it from https://www.google.com/chrome/';
22
32
  /**
23
33
  * The state is embedded in the expression rather than passed as an argument:
24
34
  * Playwright treats a string pageFunction as a plain expression and drops the
25
35
  * arg, so an IIFE is the reliable form.
26
36
  */
27
- function applyStateExpression(state, width, height) {
37
+ function applyStateExpression(state, width, height, frameTimeMs, clipIndex) {
28
38
  return ('(() => {' +
29
39
  ' const replay = window.__hudReplay;' +
30
40
  ' if (!replay || typeof replay.render !== "function") throw new Error("window.__hudReplay.render is missing");' +
31
41
  ' if (typeof replay.setViewport === "function") replay.setViewport(' +
32
42
  `${JSON.stringify(width)}, ${JSON.stringify(height)});` +
33
- ` replay.render(${JSON.stringify(state)});` +
34
- ' return true;' +
43
+ // The second and third arguments seed animation phase (source time, and
44
+ // the clip so the harness can tell a new clip's first keyframe from a
45
+ // mid-clip one); an older harness ignores them.
46
+ ` replay.render(${JSON.stringify(state)}, ${JSON.stringify(frameTimeMs)}, ${JSON.stringify(clipIndex)});` +
47
+ // settle() is awaited here rather than in a second round trip: Playwright
48
+ // awaits a thenable returned from a string expression, so this is one
49
+ // protocol call per keyframe instead of two, with identical ordering. An
50
+ // older harness has no settle() and simply returns true.
51
+ ' return typeof replay.settle === "function" ? replay.settle() : true;' +
35
52
  '})()');
36
53
  }
37
54
  /** Headless system Chrome for offscreen rasterization; null (with a warning) when it cannot start. */
@@ -47,36 +64,90 @@ export async function launchRasterBrowser(purpose) {
47
64
  export function uiPngPath(outDir, index) {
48
65
  return path.join(outDir, `ui_${String(index).padStart(4, '0')}.png`);
49
66
  }
67
+ /**
68
+ * Cheap liveness probe. A crashed target or closed browser rejects every
69
+ * protocol call immediately, so this distinguishes "that one state was bad"
70
+ * from "there is no page any more".
71
+ */
72
+ async function pageIsAlive(page) {
73
+ try {
74
+ await page.evaluate('1');
75
+ return true;
76
+ }
77
+ catch {
78
+ return false;
79
+ }
80
+ }
50
81
  /**
51
82
  * Render one transparent PNG per keyframe, reusing a single browser + page.
52
- * Returns paths in keyframe order, or null when UI overlays must be skipped
53
- * (no Chrome, harness unreachable, or the harness rejected a state).
83
+ * Returns paths in keyframe order — a slot is null when that one keyframe
84
+ * failed (the caller holds the previous overlay across its window) — or null
85
+ * overall when UI must be skipped entirely (no Chrome, harness unreachable, the
86
+ * page died mid-run, or every keyframe failed).
54
87
  */
55
88
  export async function rasterizeUiKeyframes(keyframes, options) {
56
89
  if (keyframes.length === 0)
57
90
  return [];
91
+ // Before the browser exists: a throwing mkdir must not leak a Chrome.
92
+ fs.mkdirSync(options.outDir, { recursive: true });
58
93
  const browser = await launchRasterBrowser('ui');
59
94
  if (browser === null) {
60
95
  warn('ui: rendering without HUD overlays');
61
96
  return null;
62
97
  }
63
- fs.mkdirSync(options.outDir, { recursive: true });
64
98
  try {
65
99
  const context = await browser.newContext({
66
100
  viewport: { width: options.width, height: options.height },
67
- deviceScaleFactor: 1
101
+ deviceScaleFactor: options.deviceScaleFactor
68
102
  });
69
103
  const page = await context.newPage();
70
104
  await page.goto(options.harnessUrl, { waitUntil: 'domcontentloaded', timeout: NAV_TIMEOUT_MS });
71
105
  await page.waitForFunction('window.__hudReplayReady === true', undefined, { timeout: READY_TIMEOUT_MS });
72
106
  const paths = [];
107
+ let failed = 0;
108
+ let consecutiveFailures = 0;
73
109
  for (let i = 0; i < keyframes.length; i++) {
74
110
  const pngPath = uiPngPath(options.outDir, i);
75
- await page.evaluate(applyStateExpression(keyframes[i].state, options.width, options.height));
76
- await page.screenshot({ path: pngPath, omitBackground: true, type: 'png' });
77
- paths.push(pngPath);
111
+ try {
112
+ await page.evaluate(applyStateExpression(keyframes[i].state, options.width, options.height, Math.round(keyframes[i].frameTimeMs), keyframes[i].clipIndex));
113
+ await page.screenshot({ path: pngPath, omitBackground: true, type: 'png' });
114
+ paths.push(pngPath);
115
+ consecutiveFailures = 0;
116
+ }
117
+ catch (err) {
118
+ // One bad state must not throw away the overlays already on disk.
119
+ failed++;
120
+ consecutiveFailures++;
121
+ warn(`ui: keyframe ${i} failed to rasterize ` +
122
+ `(${err instanceof Error ? err.message : String(err)}) — holding the previous overlay`);
123
+ paths.push(null);
124
+ // A dead page fails every REMAINING keyframe too, and each null slot
125
+ // extends the last good overlay — which would freeze one stale HUD
126
+ // over the whole rest of the trailer. That is worse than no UI, so
127
+ // probe liveness and bail out whole rather than degrade per keyframe.
128
+ if (!(await pageIsAlive(page))) {
129
+ warn(`ui: the replay page died after ${paths.length - failed} overlay(s) — rendering without UI ` +
130
+ 'rather than freezing the last one over the remaining clips');
131
+ return null;
132
+ }
133
+ // A page that answers evaluate('1') but fails every screenshot (a
134
+ // stalled compositor, an unwritable .ui) would otherwise pay the full
135
+ // screenshot timeout once per remaining keyframe and then freeze the
136
+ // last good overlay across them — hours of waiting for a worse video.
137
+ if (consecutiveFailures >= MAX_CONSECUTIVE_FAILURES) {
138
+ warn(`ui: ${consecutiveFailures} keyframes in a row failed to rasterize — rendering without UI ` +
139
+ 'rather than holding one overlay over everything that follows');
140
+ return null;
141
+ }
142
+ }
143
+ }
144
+ if (failed === keyframes.length) {
145
+ warn(`ui: every keyframe failed to rasterize against ${options.harnessUrl} — rendering without UI`);
146
+ return null;
78
147
  }
79
- out(`ui: rasterized ${paths.length} overlay(s) at ${options.width}x${options.height} from ${options.harnessUrl}`);
148
+ out(`ui: rasterized ${paths.length - failed} overlay(s) at ${options.width}x${options.height}` +
149
+ `${options.deviceScaleFactor !== 1 ? `@${options.deviceScaleFactor.toFixed(2)}x` : ''} ` +
150
+ `from ${options.harnessUrl}${failed > 0 ? ` (${failed} failed, held over)` : ''}`);
80
151
  return paths;
81
152
  }
82
153
  catch (err) {
@@ -93,22 +164,4 @@ export async function rasterizeUiKeyframes(keyframes, options) {
93
164
  }
94
165
  }
95
166
  }
96
- /**
97
- * Width/height straight out of a PNG's IHDR chunk, so the filtergraph only
98
- * pays for a scale filter when the overlay really is the wrong size.
99
- */
100
- export function readPngSize(filePath) {
101
- const header = Buffer.alloc(24);
102
- const fd = fs.openSync(filePath, 'r');
103
- try {
104
- if (fs.readSync(fd, header, 0, 24, 0) < 24)
105
- return null;
106
- }
107
- finally {
108
- fs.closeSync(fd);
109
- }
110
- if (header.readUInt32BE(0) !== 0x89504e47 || header.toString('ascii', 12, 16) !== 'IHDR')
111
- return null;
112
- return { width: header.readUInt32BE(16), height: header.readUInt32BE(20) };
113
- }
114
167
  //# sourceMappingURL=hud-raster.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hud-raster.js","sourceRoot":"","sources":["../../src/trailer/hud-raster.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAgB,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,MAAM,cAAc,GAAG,KAAK,CAAC;AAC7B,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B,MAAM,CAAC,MAAM,mBAAmB,GAC9B,sFAAsF,CAAC;AAEzF;;;;GAIG;AAC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IAAI,CAAC,kDAAkD,OAAO,CAAC,UAAU,yBAAyB,CAAC,CAAC;YACpG,OAAO,IAAI,CAAC;QACd,CAAC;QACD,GAAG,CACD,kBAAkB,KAAK,CAAC,MAAM,GAAG,MAAM,kBAAkB,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE;YACxF,GAAG,OAAO,CAAC,iBAAiB,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG;YACxF,QAAQ,OAAO,CAAC,UAAU,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,qBAAqB,CAAC,CAAC,CAAC,EAAE,EAAE,CACpF,CAAC;QACF,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,CACF,4CAA4C,OAAO,CAAC,UAAU,GAAG;YAC/D,IAAI,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,0BAA0B,CACjF,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,6BAA6B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACxF,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -24,6 +24,8 @@ export interface HudHealthState {
24
24
  current: number;
25
25
  max: number;
26
26
  visible: boolean;
27
+ /** Pixel width from showHealth({width}); absent = the engine default. */
28
+ width?: number;
27
29
  }
28
30
  /**
29
31
  * One HUD element. Keys beyond id/type/anchor/visible are per-kind and are
@@ -52,6 +54,8 @@ export interface HudElementState {
52
54
  export interface HudToastState {
53
55
  message: string;
54
56
  variant?: string;
57
+ /** IGameHUD anchor; absent on recordings that predate anchor capture. */
58
+ anchor?: string;
55
59
  }
56
60
  export interface HudReplayState {
57
61
  version: 1;
@@ -63,7 +67,48 @@ export interface HudReplayState {
63
67
  /** Creation order (= stacking order within an anchor); removed ones dropped. */
64
68
  elements: HudElementState[];
65
69
  toasts: HudToastState[];
70
+ /**
71
+ * Game-authored head stylesheets, first-logged order, last write per id.
72
+ * The harness injects these before drawing — they are what turn
73
+ * custom-element class names into pixels.
74
+ *
75
+ * Shared between snapshots while unchanged, so treat it as frozen: never
76
+ * mutate the array or its entries in place.
77
+ */
78
+ stylesheets: ReadonlyArray<HudStylesheetState>;
79
+ }
80
+ export interface HudStylesheetState {
81
+ id: string;
82
+ css: string;
83
+ }
84
+ export interface RasterGeometry {
85
+ /** CSS-pixel viewport for the harness browser context. */
86
+ viewportWidth: number;
87
+ viewportHeight: number;
88
+ deviceScaleFactor: number;
66
89
  }
90
+ /**
91
+ * Where to lay the HUD out for rasterization.
92
+ *
93
+ * During capture only the CANVAS is resized to the recording resolution — the
94
+ * DOM HUD keeps laying out against the player's window. Rastering at the
95
+ * recording size therefore renders every fixed-pixel HUD metric too small
96
+ * relative to the footage (and flips vw-clamps and media queries). With the
97
+ * recorded window known, raster at an ASPECT-CORRECTED viewport: the window's
98
+ * height (so element size relative to screen height matches what the player
99
+ * saw) at the recording's aspect (raw window dimensions would stretch glyphs
100
+ * non-uniformly under the final scale whenever the aspects differ). The
101
+ * deviceScaleFactor keeps the PNG at or above the recording resolution so
102
+ * ffmpeg only ever downscales.
103
+ *
104
+ * No recorded window → the recording resolution at 1x, bit-for-bit the old
105
+ * behavior.
106
+ */
107
+ export declare function computeRasterGeometry(recordingWidth: number, recordingHeight: number, window?: {
108
+ innerWidth: number;
109
+ innerHeight: number;
110
+ devicePixelRatio: number;
111
+ }): RasterGeometry;
67
112
  /** The engine records `frame` on a 60fps source clock. */
68
113
  export declare const DEFAULT_HUD_FPS = 60;
69
114
  /** IGameHUD.showToast's default duration. */
@@ -78,6 +123,12 @@ export declare function isBlankHudState(state: HudReplayState): boolean;
78
123
  export interface UiKeyframe {
79
124
  /** Source frame whose state this is. */
80
125
  sourceFrame: number;
126
+ /**
127
+ * `sourceFrame` as milliseconds on the SOURCE clock. The harness seeds
128
+ * animation phase from it, so motion stays locked to the footage through a
129
+ * speed ramp — output time would run it fast or slow against the frames.
130
+ */
131
+ frameTimeMs: number;
81
132
  clipIndex: number;
82
133
  /** Output-timeline seconds this overlay becomes visible. */
83
134
  outputStartSec: number;
@@ -88,17 +139,37 @@ export interface UiKeyframe {
88
139
  export interface CollectUiKeyframesOptions {
89
140
  /** Source-clock fps. Default 60. */
90
141
  fps?: number;
91
- /** Ceiling on keyframes per second of OUTPUT time. Default 10. */
142
+ /** Ceiling on keyframes per second of OUTPUT time. Default 30. 0 disables. */
92
143
  maxPerSecond?: number;
93
- /** Hard ceiling per clip. Default 240. */
144
+ /** Hard ceiling per clip. Defaults to what the clip's duration allows at `maxPerSecond`. */
94
145
  maxPerClip?: number;
95
146
  /** Per-clip opt-out; defaults to every clip. */
96
147
  clipEnabled?: (clipIndex: number) => boolean;
97
148
  /** Where truncation notices go. Defaults to stderr. */
98
149
  log?: (line: string) => void;
99
150
  }
100
- export declare const DEFAULT_MAX_KEYFRAMES_PER_SECOND = 10;
101
- export declare const DEFAULT_MAX_KEYFRAMES_PER_CLIP = 240;
151
+ /**
152
+ * 30, not 15: measured on a real cut, the selected footage held 227 distinct
153
+ * HUD states across 15.3 s of output (14.8/s average, four of seven clips over
154
+ * 15/s), so a 15/s ceiling was discarding roughly 45% of the HUD motion the
155
+ * game actually rendered.
156
+ *
157
+ * ffmpeg used to be the reason for a low ceiling — one PNG input plus one
158
+ * serial overlay node per keyframe cost ~23 MB of RSS each and corrupted the
159
+ * render above ~400. The overlays now ride one densified image2 sequence whose
160
+ * cost is flat in keyframe count (measured 2.83 s / 0.94 GB at both 126 and
161
+ * 902 distinct rasters), so the remaining cost is ~25 ms of Playwright per
162
+ * keyframe plus its PNG on disk. 0 disables the limit entirely.
163
+ */
164
+ export declare const DEFAULT_MAX_KEYFRAMES_PER_SECOND = 30;
165
+ /**
166
+ * Sole per-clip ceiling, a backstop for `--ui-keyframe-rate 0`: at any real
167
+ * rate the limiter below admits at most rate·duration+1 keyframes per clip on
168
+ * its own, so nothing else can bind. A fixed 240 used to freeze the overlay
169
+ * after 16 s of any clip busy enough to sustain the default rate — exactly the
170
+ * clip a trailer is cut from. 60 s of output at 60/s.
171
+ */
172
+ export declare const MAX_KEYFRAMES_PER_CLIP_CEILING = 3600;
102
173
  /**
103
174
  * Walk every enabled clip's source range and emit a keyframe wherever the
104
175
  * reduced HUD state changes.