demowright 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/config.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as QaHudOptions } from "./setup-Dwx0Dt54.mjs";
1
+ import { t as QaHudOptions } from "./setup-8X-3F3M7.mjs";
2
2
  import { PlaywrightTestConfig } from "@playwright/test";
3
3
 
4
4
  //#region src/config.d.ts
package/dist/config.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as defaultOptions } from "./setup-Ce4X1N16.mjs";
1
+ import { n as defaultOptions } from "./setup-c_UpOQ7a.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { execSync } from "node:child_process";
4
4
  import { mkdirSync, readdirSync } from "node:fs";
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { installAutoAnnotate } from "./auto-annotate.mjs";
2
- import { a as AudioWriter, n as TtsProvider, r as applyHud, t as QaHudOptions } from "./setup-Dwx0Dt54.mjs";
2
+ import { a as AudioWriter, n as TtsProvider, r as applyHud, t as QaHudOptions } from "./setup-8X-3F3M7.mjs";
3
3
  import { annotate, caption, clickEl, hudWait, moveTo, moveToEl, narrate, subtitle, typeKeys } from "./helpers.mjs";
4
4
  import { OutroOptions, PaceFn, RenderOptions, TimelineEntry, TitleOptions, VideoScriptResult, buildFfmpegCommand, createVideoScript } from "./video-script.mjs";
5
5
  import { Page as Page$1, expect } from "@playwright/test";
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { r as AudioWriter, t as applyHud } from "./setup-Ce4X1N16.mjs";
1
+ import { r as AudioWriter, t as applyHud } from "./setup-c_UpOQ7a.mjs";
2
2
  import { i as getGlobalTtsProvider, s as init_hud_registry } from "./hud-registry-Wfd4b4Nu.mjs";
3
3
  import { buildFfmpegCommand, createVideoScript, t as init_video_script } from "./video-script.mjs";
4
4
  import { annotate, caption, clickEl, hudWait, moveTo, moveToEl, narrate, subtitle, typeKeys } from "./helpers.mjs";
@@ -24,6 +24,8 @@ declare class AudioWriter {
24
24
  /**
25
25
  * Called from the browser via page.exposeFunction.
26
26
  * Receives interleaved stereo float32 samples.
27
+ * Each chunk is timestamped with wall-clock time so silence gaps
28
+ * (e.g. during video pause) are preserved in the output.
27
29
  */
28
30
  addChunk(samples: number[], sampleRate: number): void;
29
31
  /** Wall-clock time when first chunk arrived */
@@ -32,13 +34,15 @@ declare class AudioWriter {
32
34
  get rate(): number;
33
35
  /** Total samples collected (interleaved, so / channels for per-channel) */
34
36
  get totalSamples(): number;
37
+ /** Total duration including silence gaps (wall-clock based) */
35
38
  get duration(): number;
36
39
  /**
37
40
  * Write collected audio to a WAV file.
38
41
  */
39
42
  save(filePath: string): void;
40
43
  /**
41
- * Return all chunks concatenated as interleaved stereo float32.
44
+ * Return all audio as interleaved stereo float32, preserving silence gaps
45
+ * between chunks based on their wall-clock timestamps.
42
46
  */
43
47
  toFloat32(): Float32Array;
44
48
  /** Reset for reuse */
@@ -300,11 +300,17 @@ var AudioWriter = class {
300
300
  /**
301
301
  * Called from the browser via page.exposeFunction.
302
302
  * Receives interleaved stereo float32 samples.
303
+ * Each chunk is timestamped with wall-clock time so silence gaps
304
+ * (e.g. during video pause) are preserved in the output.
303
305
  */
304
306
  addChunk(samples, sampleRate) {
305
- if (this.chunks.length === 0) this.startMs = Date.now();
307
+ const now = Date.now();
308
+ if (this.chunks.length === 0) this.startMs = now;
306
309
  this.sampleRate = sampleRate;
307
- this.chunks.push(new Float32Array(samples));
310
+ this.chunks.push({
311
+ samples: new Float32Array(samples),
312
+ timestampMs: now
313
+ });
308
314
  }
309
315
  /** Wall-clock time when first chunk arrived */
310
316
  get captureStartMs() {
@@ -316,22 +322,25 @@ var AudioWriter = class {
316
322
  }
317
323
  /** Total samples collected (interleaved, so / channels for per-channel) */
318
324
  get totalSamples() {
319
- return this.chunks.reduce((sum, c) => sum + c.length, 0);
325
+ return this.chunks.reduce((sum, c) => sum + c.samples.length, 0);
320
326
  }
327
+ /** Total duration including silence gaps (wall-clock based) */
321
328
  get duration() {
322
- return this.totalSamples / this.channels / this.sampleRate;
329
+ if (this.chunks.length === 0) return 0;
330
+ const last = this.chunks[this.chunks.length - 1];
331
+ const lastDurMs = last.samples.length / this.channels / this.sampleRate * 1e3;
332
+ return (last.timestampMs + lastDurMs - this.startMs) / 1e3;
323
333
  }
324
334
  /**
325
335
  * Write collected audio to a WAV file.
326
336
  */
327
337
  save(filePath) {
328
- const totalSamples = this.totalSamples;
329
- if (totalSamples === 0) return;
330
- const int16 = new Int16Array(totalSamples);
331
- let offset = 0;
332
- for (const chunk of this.chunks) for (let i = 0; i < chunk.length; i++) {
333
- const s = Math.max(-1, Math.min(1, chunk[i]));
334
- int16[offset++] = s < 0 ? s * 32768 : s * 32767;
338
+ const float32 = this.toFloat32();
339
+ if (float32.length === 0) return;
340
+ const int16 = new Int16Array(float32.length);
341
+ for (let i = 0; i < float32.length; i++) {
342
+ const s = Math.max(-1, Math.min(1, float32[i]));
343
+ int16[i] = s < 0 ? s * 32768 : s * 32767;
335
344
  }
336
345
  const dataBytes = int16.length * 2;
337
346
  const buffer = Buffer.alloc(44 + dataBytes);
@@ -352,16 +361,20 @@ var AudioWriter = class {
352
361
  writeFileSync(filePath, buffer);
353
362
  }
354
363
  /**
355
- * Return all chunks concatenated as interleaved stereo float32.
364
+ * Return all audio as interleaved stereo float32, preserving silence gaps
365
+ * between chunks based on their wall-clock timestamps.
356
366
  */
357
367
  toFloat32() {
358
- const total = this.totalSamples;
359
- if (total === 0) return new Float32Array(0);
360
- const out = new Float32Array(total);
361
- let off = 0;
368
+ if (this.chunks.length === 0) return new Float32Array(0);
369
+ const last = this.chunks[this.chunks.length - 1];
370
+ const lastDurMs = last.samples.length / this.channels / this.sampleRate * 1e3;
371
+ const totalMs = last.timestampMs + lastDurMs - this.startMs;
372
+ const totalSamples = Math.ceil(totalMs / 1e3 * this.sampleRate) * this.channels;
373
+ const out = new Float32Array(totalSamples);
362
374
  for (const chunk of this.chunks) {
363
- out.set(chunk, off);
364
- off += chunk.length;
375
+ const offsetMs = chunk.timestampMs - this.startMs;
376
+ const offsetSamples = Math.floor(offsetMs / 1e3 * this.sampleRate) * this.channels;
377
+ for (let i = 0; i < chunk.samples.length && offsetSamples + i < out.length; i++) out[offsetSamples + i] += chunk.samples[i];
365
378
  }
366
379
  return out;
367
380
  }
package/dist/setup.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { i as defaultOptions, n as TtsProvider, r as applyHud, t as QaHudOptions } from "./setup-Dwx0Dt54.mjs";
1
+ import { i as defaultOptions, n as TtsProvider, r as applyHud, t as QaHudOptions } from "./setup-8X-3F3M7.mjs";
2
2
  export { QaHudOptions, TtsProvider, applyHud, defaultOptions };
package/dist/setup.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as defaultOptions, t as applyHud } from "./setup-Ce4X1N16.mjs";
1
+ import { n as defaultOptions, t as applyHud } from "./setup-c_UpOQ7a.mjs";
2
2
  export { applyHud, defaultOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "demowright",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Playwright video production plugin — cursor overlay, keystroke badges, TTS narration, and narration-driven video scripts for test recordings",
5
5
  "license": "MIT",
6
6
  "repository": {