@holtjs/stage 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,28 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.17.0] - 2026-12-05
10
+
11
+ ### Added & Fixed
12
+ - **Halo-Free Straight-Alpha Transparent GPU Readback & `alpha: true` Video Overlay Export (`@holtjs/stage/webgpu` & `@holtjs/stage/headless`, `src/renderer-webgpu.ts`, `src/headless.ts`)**:
13
+ - Added fixed-point reciprocal LUT `unpremultiplyRgbaInPlace(rgba)` and automatic straight-alpha conversion in `RendererWebGpu.readPixelsSync` / `readPixelsAsync` and `HeadlessStage.toRgba` / `toRgbaInto` (`WEBGL`) whenever `transparent: true` (`camera.transparent`) is active, eliminating `alpha^2` dark-halo fringing on semi-transparent SDF borders, soft glows, and text across PNG, `yuva420p` WebM, and `ffmpeg` `overlay` pipelines.
14
+ - Added `alpha?: boolean` to `stage.encodeVideo()` / `encodeVideoWithFfmpeg()` / `buildFfmpegRawVideoArgs()`, automatically configuring `libvpx-vp9` `yuva420p` (`-auto-alt-ref 0`) for `.webm`, lossless `qtrle` `argb` for `.mov`, and lossless `png` `image2pipe` fallback when `rawvideo` is unavailable.
15
+ - **Declarative Multi-Cut & Alpha-Overlay FFmpeg Compositor (`composeVideoLayers` & `buildFfmpegCompositeArgs`, `@holtjs/stage/headless`)**:
16
+ - Added `composeVideoLayers({ outputPath, cuts, overlays, voiceoverPath, voiceoverSegments, bgmPath, ducking })` compiling external video cuts (`zoom`/`cropY` reframing + `concat`), transparent `@holtjs/stage` Alpha Overlays (auto-injecting `-c:v libvpx-vp9` input decoding so `yuva420p` alpha planes are preserved), sample-accurate `adelay` voiceover segments, and `sidechaincompress` BGM ducking into a single deterministic `ffmpeg` pass.
17
+ - **In-Engine Virtual Camera Director & Spotlight (`createCameraDirector`, `@holtjs/stage/kernel` & `@holtjs/stage`, `src/kernel.ts`)**:
18
+ - Added `createCameraDirector()` (`StagePlugin`) supporting `cutTo`, `panTo` (imperative inside `scene.script(function*)` or scheduled via `atMs`), `follow`, and screen-space `spotlight` / `clearSpotlight` targeting either world `{ x, y }` coordinates or live `trackId` nodes across scene objects and `UiRoot` elements.
19
+
20
+ ## [0.16.0] - 2026-12-05
21
+
22
+ ### Added
23
+ - **Sub-Millisecond `SoaWorld` Binary Snapshots, State Checksums & `RollbackSession` (`@holtjs/stage/ecs` & `@holtjs/stage/kernel`, `src/ecs.ts`, `src/kernel.ts`)**:
24
+ - Added `world.snapshotByteLength()`, `world.snapshot(into?)`, `world.restore(bytes)` (`'HSOA'` 8-byte aligned binary layout with schema-hash validation, preserving generational `EntityId`s and compiled `world.select()` views in `< 0.1 ms`), and `world.checksum()` (canonicalized 32-bit FNV-1a state checksum).
25
+ - Added `RollbackSession<TInput>` (`RollbackSession.fromSoaWorld`, `createRollbackSession`) with preallocated ring-buffer snapshot slots (`advance`, `applyAuthoritativeInput` for GGPO-style rollback netcode prediction & deterministic re-simulation, `rewindTo` for interactive Time-Travel debugging, and `checksumAt` / `currentChecksum`).
26
+ - **Single-Process Zero-Rasterization Batch Balance Rollout Runner (`runHeadlessRollouts`, `@holtjs/stage/headless`, `src/headless.ts`)**:
27
+ - Added `runHeadlessRollouts({ runs, seeds, ticksPerRun, createScene, onTick, extractMetrics })` executing dozens to hundreds of deterministic `stepSimOnly` game rollouts in a single Node.js, Bun, or Deno process with zero pixel rasterization or GPU driver overhead, returning per-run telemetry and aggregated `min / max / mean / p50 / p95 / sum` statistics.
28
+ - **Velocity-Driven Procedural Character Squash, Stretch & Lean (`LocomotionFeel`, `@holtjs/stage/particles` & `@holtjs/stage`, `src/particles.ts`)**:
29
+ - Added `LocomotionFeel` providing area-preserving (`scaleX * scaleY === 1`) log-space damped spring squash-and-stretch (`impulse`), automatic sharp-turn anticipation squash, velocity-proportional landing thud (`wz -> 0`), ground stride hop, and velocity lean (`applyTo(sprite)`).
30
+
9
31
  ## [0.15.0] - 2026-12-05
10
32
 
11
33
  ### Added, Optimized & Fixed
package/dist/ecs.d.ts CHANGED
@@ -228,6 +228,24 @@ export declare class SoaWorld {
228
228
  clear(): void;
229
229
  /** PII-free runtime statistics snapshot. */
230
230
  stats(): SoaWorldStats;
231
+ private computeSchemaHash;
232
+ /** Compute exact byte length required to snapshot the current `SoaWorld` state (`'HSOA'` binary layout). */
233
+ snapshotByteLength(count?: number, nextHandle?: number, freeCount?: number): number;
234
+ /**
235
+ * Capture a complete binary snapshot of all live entities, generational handle tables, and SoA component columns.
236
+ * Pass a reusable `into` `Uint8Array` (`byteLength >= world.snapshotByteLength()`) for zero-GC sub-millisecond capture.
237
+ */
238
+ snapshot(into?: Uint8Array): Uint8Array;
239
+ /**
240
+ * Restore `SoaWorld` in-place from a snapshot produced by `world.snapshot()`.
241
+ * Preserves all compiled `world.select()` / `world.store()` column views and generational `EntityId` validity.
242
+ */
243
+ restore(snapshot: Uint8Array): void;
244
+ /**
245
+ * Compute a fast deterministic 32-bit FNV-1a checksum over all live entities, masks, and active component columns
246
+ * (canonicalizing `-0.0` in float columns for rollback netcode & replay desync verification).
247
+ */
248
+ checksum(): number;
231
249
  }
232
250
  /**
233
251
  * In-place zero-GC insertion/Ciura-gap Shell sort of `slots[0..count - 1]` ordered ascending by
package/dist/ecs.js CHANGED
@@ -557,6 +557,180 @@ var SoaWorld = class {
557
557
  spatialCells: this.grid ? this.grid.cols * this.grid.rows : 0
558
558
  };
559
559
  }
560
+ computeSchemaHash() {
561
+ let h = 0x811c9dc5;
562
+ for (let i = 0; i < this.stores.length; i++) {
563
+ const def = this.stores[i].def;
564
+ const sig = def.isTag ? `${def.name}:tag` : `${def.name}:${def.fields.map((f) => `${f}=${def.schema[f]}`).join(",")}`;
565
+ for (let c = 0; c < sig.length; c++) {
566
+ h ^= sig.charCodeAt(c);
567
+ h = Math.imul(h, 16777619) >>> 0;
568
+ }
569
+ }
570
+ return h >>> 0;
571
+ }
572
+ /** Compute exact byte length required to snapshot the current `SoaWorld` state (`'HSOA'` binary layout). */
573
+ snapshotByteLength(count = this.count, nextHandle = this.nextHandle, freeCount = this.freeCount) {
574
+ const align8 = (n) => n + 7 & -8;
575
+ let off = 32;
576
+ off = align8(off + count * 4);
577
+ off = align8(off + count * 4);
578
+ off = align8(off + freeCount * 4);
579
+ off = align8(off + nextHandle * 4);
580
+ off = align8(off + nextHandle * 2);
581
+ for (let i = 0; i < this.stores.length; i++) {
582
+ const st = this.stores[i];
583
+ if (st.def.isTag) continue;
584
+ const fields = st.def.fields;
585
+ for (let f = 0; f < fields.length; f++) {
586
+ const bpe = st.columns[fields[f]].BYTES_PER_ELEMENT;
587
+ off = align8(off + count * bpe);
588
+ }
589
+ }
590
+ return off;
591
+ }
592
+ /**
593
+ * Capture a complete binary snapshot of all live entities, generational handle tables, and SoA component columns.
594
+ * Pass a reusable `into` `Uint8Array` (`byteLength >= world.snapshotByteLength()`) for zero-GC sub-millisecond capture.
595
+ */
596
+ snapshot(into) {
597
+ const count = this.count;
598
+ const nextHandle = this.nextHandle;
599
+ const freeCount = this.freeCount;
600
+ const totalBytes = this.snapshotByteLength(count, nextHandle, freeCount);
601
+ const out = into && into.byteLength >= totalBytes ? into.subarray(0, totalBytes) : new Uint8Array(totalBytes);
602
+ const dv = new DataView(out.buffer, out.byteOffset, totalBytes);
603
+ dv.setUint32(0, 0x414f5348, true);
604
+ dv.setUint32(4, 1, true);
605
+ dv.setUint32(8, count, true);
606
+ dv.setUint32(12, nextHandle, true);
607
+ dv.setUint32(16, freeCount, true);
608
+ dv.setUint32(20, this.stores.length, true);
609
+ dv.setUint32(24, this.computeSchemaHash(), true);
610
+ dv.setUint32(28, 0, true);
611
+ let off = 32;
612
+ const writeBytes = (arr, byteLen) => {
613
+ if (byteLen > 0) out.set(new Uint8Array(arr.buffer, arr.byteOffset, byteLen), off);
614
+ const nextOff = off + byteLen + 7 & -8;
615
+ for (let p = off + byteLen; p < nextOff; p++) out[p] = 0;
616
+ off = nextOff;
617
+ };
618
+ writeBytes(this.masks, count * 4);
619
+ writeBytes(this.entities, count * 4);
620
+ writeBytes(this.freeHandles, freeCount * 4);
621
+ writeBytes(this.handleToSlot, nextHandle * 4);
622
+ writeBytes(this.handleGen, nextHandle * 2);
623
+ for (let i = 0; i < this.stores.length; i++) {
624
+ const st = this.stores[i];
625
+ if (st.def.isTag) continue;
626
+ const fields = st.def.fields;
627
+ for (let f = 0; f < fields.length; f++) {
628
+ const col = st.columns[fields[f]];
629
+ writeBytes(col, count * col.BYTES_PER_ELEMENT);
630
+ }
631
+ }
632
+ return out;
633
+ }
634
+ /**
635
+ * Restore `SoaWorld` in-place from a snapshot produced by `world.snapshot()`.
636
+ * Preserves all compiled `world.select()` / `world.store()` column views and generational `EntityId` validity.
637
+ */
638
+ restore(snapshot) {
639
+ if (!snapshot || snapshot.byteLength < 32) throw new Error("SoaWorld.restore: invalid snapshot buffer (< 32 bytes)");
640
+ const dv = new DataView(snapshot.buffer, snapshot.byteOffset, snapshot.byteLength);
641
+ const magic = dv.getUint32(0, true);
642
+ const version = dv.getUint32(4, true);
643
+ if (magic !== 0x414f5348 || version !== 1) throw new Error("SoaWorld.restore: unrecognized HSOA snapshot header");
644
+ const snapCount = dv.getUint32(8, true);
645
+ const snapNextHandle = dv.getUint32(12, true);
646
+ const snapFreeCount = dv.getUint32(16, true);
647
+ const snapStores = dv.getUint32(20, true);
648
+ const snapSchema = dv.getUint32(24, true);
649
+ if (snapStores !== this.stores.length || snapSchema !== this.computeSchemaHash()) throw new Error("SoaWorld.restore: registered component schema does not match snapshot");
650
+ const expectedBytes = this.snapshotByteLength(snapCount, snapNextHandle, snapFreeCount);
651
+ if (snapshot.byteLength < expectedBytes) throw new Error(`SoaWorld.restore: truncated snapshot (${snapshot.byteLength} < ${expectedBytes})`);
652
+ const prevCount = this.count;
653
+ const prevNextHandle = this.nextHandle;
654
+ this.ensureCapacity(Math.max(16, snapCount));
655
+ this.ensureHandleCapacity(Math.max(16, snapNextHandle, snapFreeCount));
656
+ let off = 32;
657
+ const readBytes = (dst, byteLen) => {
658
+ if (byteLen > 0) new Uint8Array(dst.buffer, dst.byteOffset, byteLen).set(snapshot.subarray(off, off + byteLen));
659
+ off = off + byteLen + 7 & -8;
660
+ };
661
+ readBytes(this.masks, snapCount * 4);
662
+ if (prevCount > snapCount) this.masks.fill(0, snapCount, prevCount);
663
+ readBytes(this.entities, snapCount * 4);
664
+ if (prevCount > snapCount) this.entities.fill(0, snapCount, prevCount);
665
+ readBytes(this.freeHandles, snapFreeCount * 4);
666
+ readBytes(this.handleToSlot, snapNextHandle * 4);
667
+ this.handleToSlot.fill(-1, snapNextHandle);
668
+ readBytes(this.handleGen, snapNextHandle * 2);
669
+ if (prevNextHandle > snapNextHandle) this.handleGen.fill(0, snapNextHandle, prevNextHandle);
670
+ for (let i = 0; i < this.stores.length; i++) {
671
+ const st = this.stores[i];
672
+ if (st.def.isTag) continue;
673
+ const fields = st.def.fields;
674
+ for (let f = 0; f < fields.length; f++) {
675
+ const col = st.columns[fields[f]];
676
+ readBytes(col, snapCount * col.BYTES_PER_ELEMENT);
677
+ }
678
+ }
679
+ this.count = snapCount;
680
+ this.nextHandle = snapNextHandle;
681
+ this.freeCount = snapFreeCount;
682
+ this.clearEvents();
683
+ }
684
+ /**
685
+ * Compute a fast deterministic 32-bit FNV-1a checksum over all live entities, masks, and active component columns
686
+ * (canonicalizing `-0.0` in float columns for rollback netcode & replay desync verification).
687
+ */
688
+ checksum() {
689
+ const count = this.count;
690
+ let h = 0x811c9dc5;
691
+ const mixByte = (b) => {
692
+ h ^= b & 255;
693
+ h = Math.imul(h, 16777619) >>> 0;
694
+ };
695
+ const mixU32 = (v) => {
696
+ mixByte(v);
697
+ mixByte(v >>> 8);
698
+ mixByte(v >>> 16);
699
+ mixByte(v >>> 24);
700
+ };
701
+ mixU32(count);
702
+ for (let s = 0; s < count; s++) {
703
+ mixU32(this.masks[s]);
704
+ mixU32(this.entities[s]);
705
+ }
706
+ const fDv = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
707
+ for (let i = 0; i < this.stores.length; i++) {
708
+ const st = this.stores[i];
709
+ if (st.def.isTag) continue;
710
+ const fields = st.def.fields;
711
+ for (let f = 0; f < fields.length; f++) {
712
+ const fname = fields[f];
713
+ const kind = st.def.schema[fname];
714
+ const col = st.columns[fname];
715
+ if (kind === "f32") for (let s = 0; s < count; s++) {
716
+ const v = col[s];
717
+ fDv.setFloat32(0, v === 0 ? 0 : Number.isNaN(v) ? 0 : v, true);
718
+ mixU32(fDv.getUint32(0, true));
719
+ }
720
+ else if (kind === "f64") for (let s = 0; s < count; s++) {
721
+ const v = col[s];
722
+ fDv.setFloat64(0, v === 0 ? 0 : Number.isNaN(v) ? 0 : v, true);
723
+ mixU32(fDv.getUint32(0, true));
724
+ mixU32(fDv.getUint32(4, true));
725
+ }
726
+ else {
727
+ const bytes = new Uint8Array(col.buffer, col.byteOffset, count * col.BYTES_PER_ELEMENT);
728
+ for (let b = 0; b < bytes.length; b++) mixByte(bytes[b]);
729
+ }
730
+ }
731
+ }
732
+ return h >>> 0;
733
+ }
560
734
  };
561
735
  /**
562
736
  * In-place zero-GC insertion/Ciura-gap Shell sort of `slots[0..count - 1]` ordered ascending by
@@ -1383,6 +1383,12 @@ interface WebGpuBootstrapResult {
1383
1383
  * Returns `null` cleanly when WebGPU is unsupported on the current browser/OS.
1384
1384
  */
1385
1385
  declare function requestWebGpuDevice(canvas: HTMLCanvasElement, options?: RequestWebGpuOptions): Promise<WebGpuBootstrapResult | null>;
1386
+ /**
1387
+ * Convert premultiplied-alpha `RGBA8888` pixels (`rgb = straight * a / 255`) into W3C straight-alpha `RGBA8888`
1388
+ * in place using a 16.16 fixed-point reciprocal LUT, preventing `alpha^2` dark-halo fringing when exporting
1389
+ * transparent WebGPU / WebGL2 frames to PNG, `yuva420p` WebM, or `ffmpeg` `overlay` pipelines.
1390
+ */
1391
+ declare function unpremultiplyRgbaInPlace(rgba: Uint8Array): Uint8Array;
1386
1392
  declare class RendererWebGpu extends EventEmitter {
1387
1393
  readonly type = 3;
1388
1394
  readonly isWebGL2 = false;
@@ -1394,8 +1400,10 @@ declare class RendererWebGpu extends EventEmitter {
1394
1400
  readonly device: WebGpuDeviceLike;
1395
1401
  readonly gpuContext: WebGpuCanvasContextLike | null;
1396
1402
  readonly format: string;
1403
+ readonly transparent: boolean;
1397
1404
  width: number;
1398
1405
  height: number;
1406
+ private lastPassTransparent;
1399
1407
  private offscreenTex;
1400
1408
  private offscreenView;
1401
1409
  private offscreenW;
@@ -2351,6 +2359,154 @@ interface InputRecorderPlugin extends StagePlugin {
2351
2359
  declare function createInputRecorder(id?: string): InputRecorderPlugin;
2352
2360
  /** Replays a recorded `RecordedInputEntry[]` log deterministically on matching simulation timestamps. */
2353
2361
  declare function createInputReplay(log: ReadonlyArray<RecordedInputEntry>, id?: string): StagePlugin & InputProvider;
2362
+ interface RollbackStateCodec {
2363
+ /** Save current simulation state into `into` (if large enough) or return a fresh `Uint8Array`. */
2364
+ save(into?: Uint8Array): Uint8Array;
2365
+ /** Restore simulation state in-place from `snapshot`. */
2366
+ load(snapshot: Uint8Array): void;
2367
+ /** Optional deterministic 32-bit state checksum for desync detection. */
2368
+ checksum?(): number;
2369
+ }
2370
+ interface RollbackSessionOptions<TInput> {
2371
+ /** Maximum number of historical frames retained in the ring buffer (`default = 120` = 2.0s @ 60 Hz). */
2372
+ readonly windowFrames?: number;
2373
+ /** Initial simulation frame number (`default = 0`). */
2374
+ readonly initialFrame?: number;
2375
+ /** Equality comparator for `TInput` to skip redundant rollbacks when authoritative input matches prediction. */
2376
+ readonly inputEquals?: (a: TInput, b: TInput) => boolean;
2377
+ /** State serializer/deserializer (or pass a `SoaWorld` to `RollbackSession.fromSoaWorld(...)`). */
2378
+ readonly codec: RollbackStateCodec;
2379
+ /** Pure deterministic single-frame simulation step `(frame, input) => void`. */
2380
+ readonly step: (frame: number, input: TInput) => void;
2381
+ }
2382
+ interface RollbackResult {
2383
+ readonly rolledBack: boolean;
2384
+ readonly targetFrame: number;
2385
+ readonly framesResimulated: number;
2386
+ readonly checksum: number;
2387
+ }
2388
+ interface RollbackStats {
2389
+ readonly currentFrame: number;
2390
+ readonly oldestFrame: number;
2391
+ readonly windowFrames: number;
2392
+ readonly rollbackCount: number;
2393
+ readonly resimulatedFrames: number;
2394
+ readonly maxRollbackDepth: number;
2395
+ }
2396
+ interface SnapshotableWorldLike {
2397
+ snapshot(into?: Uint8Array): Uint8Array;
2398
+ restore(snapshot: Uint8Array): void;
2399
+ checksum?(): number;
2400
+ }
2401
+ /**
2402
+ * Deterministic ring-buffered rollback netcode (GGPO-style prediction + authoritative correction)
2403
+ * and interactive Time-Travel debugger with zero steady-state heap allocations.
2404
+ */
2405
+ declare class RollbackSession<TInput> {
2406
+ readonly windowFrames: number;
2407
+ private curFrame;
2408
+ private minRecordedFrame;
2409
+ private readonly codec;
2410
+ private readonly stepFn;
2411
+ private readonly inputEq;
2412
+ private readonly ringFrames;
2413
+ private readonly ringBufs;
2414
+ private readonly ringLens;
2415
+ private readonly ringChecksums;
2416
+ private readonly ringInputs;
2417
+ private rollbacks;
2418
+ private resimFrames;
2419
+ private maxDepth;
2420
+ constructor(options: RollbackSessionOptions<TInput>);
2421
+ /** Create a `RollbackSession` bound directly to a `SoaWorld` (`world.snapshot` / `world.restore` / `world.checksum`). */
2422
+ static fromSoaWorld<TInput>(world: SnapshotableWorldLike, step: (frame: number, input: TInput) => void, options?: Omit<RollbackSessionOptions<TInput>, 'codec' | 'step'>): RollbackSession<TInput>;
2423
+ get currentFrame(): number;
2424
+ get oldestFrame(): number;
2425
+ private captureAtSlot;
2426
+ /** Save pre-step state for `currentFrame`, execute `step(currentFrame, input)`, and advance `currentFrame`. */
2427
+ advance(input: TInput): number;
2428
+ /** Read the input applied at historical `frame` (within `[oldestFrame .. currentFrame - 1]`). */
2429
+ inputAt(frame: number): TInput | undefined;
2430
+ /** Compute current live state checksum. */
2431
+ currentChecksum(): number;
2432
+ /** Compute checksum of the pre-step snapshot stored at historical `frame` (`null` if evicted). */
2433
+ checksumAt(frame: number): number | null;
2434
+ /**
2435
+ * Time-Travel rewind: restore live simulation state back to `targetFrame` (`oldestFrame <= targetFrame <= currentFrame`),
2436
+ * resetting `currentFrame = targetFrame` so subsequent `advance()` calls branch into a new timeline cleanly.
2437
+ */
2438
+ rewindTo(targetFrame: number): void;
2439
+ /**
2440
+ * Apply an authoritative remote/replay input for `targetFrame`.
2441
+ * If it matches the predicted input already simulated at `targetFrame`, returns immediately (`rolledBack: false`).
2442
+ * Otherwise restores `targetFrame`'s snapshot, updates the input at `targetFrame`, and re-simulates `[targetFrame .. currentFrame - 1]`.
2443
+ */
2444
+ applyAuthoritativeInput(targetFrame: number, actualInput: TInput, equals?: (a: TInput, b: TInput) => boolean): RollbackResult;
2445
+ stats(): RollbackStats;
2446
+ }
2447
+ declare function createRollbackSession<TInput>(options: RollbackSessionOptions<TInput>): RollbackSession<TInput>;
2448
+ type CameraDirectorTarget = string | {
2449
+ readonly x: number;
2450
+ readonly y: number;
2451
+ readonly w?: number;
2452
+ readonly h?: number;
2453
+ };
2454
+ interface CameraCutOptions {
2455
+ readonly zoom?: number;
2456
+ readonly atMs?: number;
2457
+ }
2458
+ interface CameraPanOptions {
2459
+ readonly durationMs?: number;
2460
+ readonly zoom?: number;
2461
+ readonly atMs?: number;
2462
+ readonly easing?: (t: number) => number;
2463
+ }
2464
+ interface CameraFollowCueOptions {
2465
+ readonly lerp?: number;
2466
+ readonly zoom?: number;
2467
+ }
2468
+ interface CameraSpotlightOptions {
2469
+ /** Extra padding in screen pixels around the target bounds (`default = 14`). */
2470
+ readonly padding?: number;
2471
+ /** Dim mask color (`default = 0x080b12`). */
2472
+ readonly dimColor?: number;
2473
+ /** Dim mask alpha in `[0, 1]` (`default = 0.68`). */
2474
+ readonly dimAlpha?: number;
2475
+ /** Highlight frame stroke color (`default = 0xb6ef48`). */
2476
+ readonly borderColor?: number;
2477
+ /** Highlight frame stroke width in pixels (`default = 2.5`; `0` disables border). */
2478
+ readonly borderWidth?: number;
2479
+ /** Optional scheduled start timestamp in simulation ms (omit to activate immediately). */
2480
+ readonly atMs?: number;
2481
+ /** Optional duration in simulation ms before auto-clearing (`0` = stay active until `clearSpotlight()`). */
2482
+ readonly durationMs?: number;
2483
+ }
2484
+ interface CameraDirectorOptions {
2485
+ readonly id?: string;
2486
+ readonly digestOptions?: SceneDigestOptions;
2487
+ }
2488
+ interface CameraDirectorPlugin extends StagePlugin {
2489
+ /** Instant camera framing centered on `target` (`trackId` or `{ x, y }`). */
2490
+ cutTo(target: CameraDirectorTarget, options?: CameraCutOptions): this;
2491
+ /** Smooth deterministic `EngineClock` pan & zoom toward `target` (imperative or scheduled via `atMs`). */
2492
+ panTo(target: CameraDirectorTarget, options?: CameraPanOptions): this;
2493
+ /** Smoothly track a moving `trackId` or `{ x, y }` point every simulation frame. */
2494
+ follow(target: CameraDirectorTarget, options?: CameraFollowCueOptions): this;
2495
+ /** Stop continuous `follow()` tracking. */
2496
+ stopFollow(): this;
2497
+ /** Darken the surrounding viewport while keeping a crisp cutout & accent border around `target`. */
2498
+ spotlight(target: CameraDirectorTarget, options?: CameraSpotlightOptions): this;
2499
+ /** Clear any active spotlight mask. */
2500
+ clearSpotlight(): this;
2501
+ /** Reset camera to center `(width / 2, height / 2)` at `zoom = 1` and clear cues/spotlights. */
2502
+ reset(): this;
2503
+ }
2504
+ /**
2505
+ * In-engine virtual camera choreography & spotlight framing plugin (`StagePlugin`) for product demos,
2506
+ * scientific visualizations, and game cutscenes. Resolves targets either by world coordinates `{ x, y }`
2507
+ * or live `trackId` across scene display nodes and `UiRoot` elements.
2508
+ */
2509
+ declare function createCameraDirector(options?: CameraDirectorOptions): CameraDirectorPlugin;
2354
2510
  type StageRenderer = RendererGl | Renderer2D | RendererWebGpu;
2355
2511
  interface EngineClockSnapshot {
2356
2512
  readonly frameSeq: number;
@@ -2664,4 +2820,4 @@ declare class Game {
2664
2820
  step(time: number, delta: number): void;
2665
2821
  destroy(removeCanvas?: boolean): void;
2666
2822
  }
2667
- export { decodeWorldDeltaBytes as $, Camera as $n, HeadlessWebGpuOptions as $t, createInputRecorder as A, Graphics as An, SceneDigestNode as At, RecipeRegistry as B, RectClipMask as Bn, InputPlugin as Bt, RecordedInputEntry as C, DisplayObjectType as Cn, positiveMod as Ct, TimelineClickOptions as D, DrawStreamOptions as Dn, SceneDigest as Dt, StagePlugin as E, DrawStreamObject as En, valueNoise2D as Et, InventoryContainer as F, MsdfIconObject as Fn, SceneDigestSurfaceSource as Ft, WorkstationSnapshot as G, ShapeBatchStyleDefaults as Gn, RendererWebGpuOptions as Gt, WorkstationInstance as H, SceneHostLike as Hn, Pointer as Ht, ItemDef as I, NineSliceObject as In, SceneDigestSurfaces as It, WorldDeltaSnapshot as J, SpritePlayOptions as Jn, WebGpuCanvasContextLike as Jt, WorldCatalogRuntime as K, SpriteAnimEventListener as Kn, RequestWebGpuOptions as Kt, ItemRegistry as L, PanelObject as Ln, buildSceneDigest as Lt, createInputTimeline as M, InstancedBatchObject as Mn, SceneDigestOverlayStats as Mt, CatalogReloadDiff as N, InstancedColumns as Nn, SceneDigestSandbox as Nt, TimelineDragOptions as O, DrawStreamSpriteOptions as On, SceneDigestActiveFocus as Ot, FrozenWorldCatalog as P, MsdfIconConfig as Pn, SceneDigestSurfaceEntry as Pt, createWorldCatalogRuntime as Q, TileSpriteObject as Qn, HeadlessWebGpuHandle as Qt, ItemStack as R, PanelOpenSide as Rn, sanitizeTrackToken as Rt, InputTimelinePlugin as S, DisplayObject as Sn, packChunkKey as St, StageKernel as T, DrawStreamBulkView as Tn, unpackChunkY as Tt, WorkstationJob as U, ShapeBatchColumns as Un, PointerSample as Ut, TileCellDelta as V, RectangleObject as Vn, KeyboardPlugin as Vt, WorkstationScheduler as W, ShapeBatchObject as Wn, RendererWebGpu as Wt, applyWorldDelta as X, TextObject as Xn, requestWebGpuDevice as Xt, WorldEntityRecord as Y, SyncAttachmentOptions as Yn, WebGpuDeviceLike as Yt, captureWorldDelta as Z, TextStyleConfig as Zn, HeadlessWebGpuBackend as Zt, ActionMap as _, CustomPassCallback as _n, createIslandBiomeGenerator as _t, GameLoop as a, Renderer2D as an, ChunkedTilemap as at, InputTargetSpec as b, DirectionalPlayOptions as bn, hash2D as bt, LoaderPlugin as c, RendererStats as cn, IslandBiomeConfig as ct, SceneCtor as d, AnchorPose2D as dn, SurvivalBiomes as dt, OpenDawnWebGpuOptions as en, CameraFollowOptions as er, defineWorldCatalog as et, SceneInput as f, BindEquipmentOptions as fn, TileCellFlags as ft, ViewportFitResult as g, ContainerFiltersShim as gn, computeDualGridMask as gt, StageRenderer as h, Container as hn, computeBlob47Index as ht, GameConfig as i, requestHeadlessWebGpu as in, ChunkGeneratorFn as it, createInputReplay as j, ImageObject as jn, SceneDigestOptions as jt, TimelineKeyOptions as k, EquipmentBinding as kn, SceneDigestEngineSandbox as kt, ScaleManager as l, Stage2DCustomImageHandler as ln, MountChunkedTilemapOptions as lt, SceneManager as m, Bob as mn, bakeDualGridTileset as mt, EngineClockSnapshot as n, openDawnWebGpu as nn, HiDpiScaleLike as nr, BakeDualGridTilesetOptions as nt, GameObjectFactory as o, RendererGl as on, ChunkedTilemapOptions as ot, SceneLifecycleStats as p, BlitterObject as pn, TileChunk as pt, WorldCatalogSpec as q, SpriteObject as qn, WebGpuBootstrapResult as qt, Game as r, openWgpuNativeFfi as rn, BakedDualGridAtlas as rt, JsonCache as s, RendererGlOptions as sn, DualGridLayerSpec as st, EngineClock as t, OpenWgpuNativeFfiOptions as tn, HiDpiConfigureOptions as tr, encodeWorldDeltaBytes as tt, Scene as u, StageRenderTarget as un, MountedChunkedTilemap as ut, InputProvider as v, CustomPassObject as vn, fbm2D as vt, StageInputEvent as w, DisplaySemantics as wn, unpackChunkX as wt, InputTimelineOptions as x, DisplayList as xn, mountChunkedTilemap as xt, InputRecorderPlugin as y, CustomPassOptions as yn, floorDiv as yt, RecipeDef as z, PanelStyleConfig as zn, InputConfig as zt };
2823
+ export { RecipeDef as $, PanelOpenSide as $n, InputConfig as $t, RecordedInputEntry as A, Container as An, computeDualGridMask as At, TimelineDragOptions as B, DrawStreamBulkView as Bn, valueNoise2D as Bt, CameraPanOptions as C, RendererStats as Cn, MountChunkedTilemapOptions as Ct, InputTargetSpec as D, BindEquipmentOptions as Dn, TileChunk as Dt, InputRecorderPlugin as E, AnchorPose2D as En, TileCellFlags as Et, RollbackStats as F, DirectionalPlayOptions as Fn, mountChunkedTilemap as Ft, createInputTimeline as G, Graphics as Gn, SceneDigestOptions as Gt, createCameraDirector as H, DrawStreamOptions as Hn, SceneDigestActiveFocus as Ht, StageInputEvent as I, DisplayList as In, packChunkKey as It, FrozenWorldCatalog as J, InstancedColumns as Jn, SceneDigestSurfaceEntry as Jt, createRollbackSession as K, ImageObject as Kn, SceneDigestOverlayStats as Kt, StageKernel as L, DisplayObject as Ln, positiveMod as Lt, RollbackSession as M, CustomPassCallback as Mn, fbm2D as Mt, RollbackSessionOptions as N, CustomPassObject as Nn, floorDiv as Nt, InputTimelineOptions as O, BlitterObject as On, bakeDualGridTileset as Ot, RollbackStateCodec as P, CustomPassOptions as Pn, hash2D as Pt, ItemStack as Q, PanelObject as Qn, sanitizeTrackToken as Qt, StagePlugin as R, DisplayObjectType as Rn, unpackChunkX as Rt, CameraFollowCueOptions as S, RendererGlOptions as Sn, IslandBiomeConfig as St, InputProvider as T, StageRenderTarget as Tn, SurvivalBiomes as Tt, createInputRecorder as U, DrawStreamSpriteOptions as Un, SceneDigestEngineSandbox as Ut, TimelineKeyOptions as V, DrawStreamObject as Vn, SceneDigest as Vt, createInputReplay as W, EquipmentBinding as Wn, SceneDigestNode as Wt, ItemDef as X, MsdfIconObject as Xn, SceneDigestSurfaces as Xt, InventoryContainer as Y, MsdfIconConfig as Yn, SceneDigestSurfaceSource as Yt, ItemRegistry as Z, NineSliceObject as Zn, buildSceneDigest as Zt, ActionMap as _, openDawnWebGpu as _n, HiDpiScaleLike as _r, BakedDualGridAtlas as _t, GameLoop as a, RendererWebGpuOptions as an, ShapeBatchObject as ar, WorkstationSnapshot as at, CameraDirectorPlugin as b, Renderer2D as bn, ChunkedTilemapOptions as bt, LoaderPlugin as c, WebGpuCanvasContextLike as cn, SpriteObject as cr, WorldDeltaSnapshot as ct, SceneCtor as d, unpremultiplyRgbaInPlace as dn, TextObject as dr, captureWorldDelta as dt, InputPlugin as en, PanelStyleConfig as er, RecipeRegistry as et, SceneInput as f, HeadlessWebGpuBackend as fn, TextStyleConfig as fr, createWorldCatalogRuntime as ft, ViewportFitResult as g, OpenWgpuNativeFfiOptions as gn, HiDpiConfigureOptions as gr, BakeDualGridTilesetOptions as gt, StageRenderer as h, OpenDawnWebGpuOptions as hn, CameraFollowOptions as hr, encodeWorldDeltaBytes as ht, GameConfig as i, RendererWebGpu as in, ShapeBatchColumns as ir, WorkstationScheduler as it, RollbackResult as j, ContainerFiltersShim as jn, createIslandBiomeGenerator as jt, InputTimelinePlugin as k, Bob as kn, computeBlob47Index as kt, ScaleManager as l, WebGpuDeviceLike as ln, SpritePlayOptions as lr, WorldEntityRecord as lt, SceneManager as m, HeadlessWebGpuOptions as mn, Camera as mr, defineWorldCatalog as mt, EngineClockSnapshot as n, Pointer as nn, RectangleObject as nr, WorkstationInstance as nt, GameObjectFactory as o, RequestWebGpuOptions as on, ShapeBatchStyleDefaults as or, WorldCatalogRuntime as ot, SceneLifecycleStats as p, HeadlessWebGpuHandle as pn, TileSpriteObject as pr, decodeWorldDeltaBytes as pt, CatalogReloadDiff as q, InstancedBatchObject as qn, SceneDigestSandbox as qt, Game as r, PointerSample as rn, SceneHostLike as rr, WorkstationJob as rt, JsonCache as s, WebGpuBootstrapResult as sn, SpriteAnimEventListener as sr, WorldCatalogSpec as st, EngineClock as t, KeyboardPlugin as tn, RectClipMask as tr, TileCellDelta as tt, Scene as u, requestWebGpuDevice as un, SyncAttachmentOptions as ur, applyWorldDelta as ut, CameraCutOptions as v, openWgpuNativeFfi as vn, ChunkGeneratorFn as vt, CameraSpotlightOptions as w, Stage2DCustomImageHandler as wn, MountedChunkedTilemap as wt, CameraDirectorTarget as x, RendererGl as xn, DualGridLayerSpec as xt, CameraDirectorOptions as y, requestHeadlessWebGpu as yn, ChunkedTilemap as yt, TimelineClickOptions as z, DisplaySemantics as zn, unpackChunkY as zt };
@@ -1,6 +1,6 @@
1
1
  import { _ as rgbToCss, a as EventEmitter, c as Scale, h as packColorAbgr, l as Scenes, m as createMatrix2D, o as FilterMode, p as WHITE_RGB, r as BlendModes, u as TintModes } from "./types-CXsCvp1p.js";
2
2
  import { AnimationManager } from "./anims.js";
3
- import { o as Renderer2D, s as Camera, t as RendererWebGpu } from "./renderer-webgpu-q4vdE3kA.js";
3
+ import { c as Camera, s as Renderer2D, t as RendererWebGpu } from "./renderer-webgpu-B4AvHUEt.js";
4
4
  import { _ as TileSpriteObject, c as ImageObject, d as NineSliceObject, f as PanelObject, g as TextObject, h as SpriteObject, i as DisplayList, l as InstancedBatchObject, m as ShapeBatchObject, n as Container, o as DrawStreamObject, p as RectangleObject, r as CustomPassObject, s as Graphics, t as BlitterObject, u as MsdfIconObject } from "./display-CVjvA8ZO.js";
5
5
  import { TweenManager } from "./tween.js";
6
6
  import { ScriptScheduler } from "./coroutine.js";
@@ -1,4 +1,4 @@
1
- import { $t as HeadlessWebGpuOptions, Dt as SceneDigest, E as StagePlugin, Qt as HeadlessWebGpuHandle, Yt as WebGpuDeviceLike, Zt as HeadlessWebGpuBackend, en as OpenDawnWebGpuOptions, f as SceneInput, in as requestHeadlessWebGpu, jt as SceneDigestOptions, n as EngineClockSnapshot, nn as openDawnWebGpu, r as Game, rn as openWgpuNativeFfi, tn as OpenWgpuNativeFfiOptions, u as Scene } from "./game-Ce35GTH4.js";
1
+ import { Gt as SceneDigestOptions, R as StagePlugin, Vt as SceneDigest, _n as openDawnWebGpu, dn as unpremultiplyRgbaInPlace, f as SceneInput, fn as HeadlessWebGpuBackend, gn as OpenWgpuNativeFfiOptions, hn as OpenDawnWebGpuOptions, ln as WebGpuDeviceLike, mn as HeadlessWebGpuOptions, n as EngineClockSnapshot, pn as HeadlessWebGpuHandle, r as Game, u as Scene, vn as openWgpuNativeFfi, yn as requestHeadlessWebGpu } from "./game-BrYrde7y.js";
2
2
  /** Minimal Canvas2D surface compatible with `@napi-rs/canvas`, `node-canvas`, and browser `<canvas>`. */
3
3
  export interface HeadlessCanvasLike {
4
4
  width: number;
@@ -208,7 +208,9 @@ export interface FfmpegRawVideoArgsOptions {
208
208
  readonly inputFormat?: Exclude<FfmpegInputFormat, 'auto'>;
209
209
  /** Optional path to a `.wav` audio file (e.g. written from `AudioTimeline.toWav()`). */
210
210
  readonly audioWavPath?: string;
211
- /** Video codec (default `'libx264'`, or `'libvpx-vp9'` when `outputPath` ends with `.webm`). */
211
+ /** Preserve straight-alpha transparency in the encoded output (`yuva420p` WebM VP9-Alpha or `argb` `qtrle` `.mov`). */
212
+ readonly alpha?: boolean;
213
+ /** Video codec (default `'libx264'`, `'libvpx-vp9'` for `.webm` / `alpha: true`, or `'qtrle'` for `.mov` + `alpha: true`). */
212
214
  readonly videoCodec?: string;
213
215
  /** Encoder preset (default `'veryfast'` for x264/x265). */
214
216
  readonly preset?: string;
@@ -244,7 +246,12 @@ export interface EncodeVideoWithFfmpegOptions {
244
246
  readonly inputFormat?: FfmpegInputFormat;
245
247
  /** JPEG quality `1..100` when `inputFormat` resolves to `'mjpeg'` (`default = 90`). */
246
248
  readonly jpegQuality?: number;
247
- /** Video codec (auto-selects `'libx264'` or `'libvpx-vp9'` based on container and `ffmpeg` capabilities when omitted). */
249
+ /**
250
+ * Preserve straight-alpha transparency in the encoded output (`yuva420p` WebM VP9-Alpha or `argb` `qtrle` `.mov`),
251
+ * ready to composite directly over live-action or screen-recorded footage via `composeVideoLayers()` / `ffmpeg` `overlay`.
252
+ */
253
+ readonly alpha?: boolean;
254
+ /** Video codec (auto-selects `'libx264'`, `'libvpx-vp9'`, or `'qtrle'` based on container, `alpha`, and `ffmpeg` capabilities when omitted). */
248
255
  readonly videoCodec?: string;
249
256
  /** Encoder preset (default `'veryfast'` on x264/x265). */
250
257
  readonly preset?: string;
@@ -287,4 +294,144 @@ export declare function buildFfmpegRawVideoArgs(options: FfmpegRawVideoArgsOptio
287
294
  * `image2pipe` (`mjpeg` + `libvpx-vp9` WebM) when only Playwright's trimmed `ffmpeg` binary is available.
288
295
  */
289
296
  export declare function encodeVideoWithFfmpeg(stage: HeadlessStage, options: EncodeVideoWithFfmpegOptions): Promise<EncodeVideoResult>;
290
- export { type HeadlessWebGpuBackend, type HeadlessWebGpuHandle, type HeadlessWebGpuOptions, type OpenDawnWebGpuOptions, type OpenWgpuNativeFfiOptions, openDawnWebGpu, openWgpuNativeFfi, requestHeadlessWebGpu };
297
+ export interface MetricSummaryStats {
298
+ readonly min: number;
299
+ readonly max: number;
300
+ readonly mean: number;
301
+ readonly p50: number;
302
+ readonly p95: number;
303
+ readonly sum: number;
304
+ }
305
+ export interface HeadlessRolloutRunResult<TMetrics extends Record<string, number>> {
306
+ readonly runIndex: number;
307
+ readonly seed: number;
308
+ readonly ticks: number;
309
+ readonly simTimeMs: number;
310
+ readonly metrics: TMetrics;
311
+ }
312
+ export interface HeadlessRolloutOptions<TMetrics extends Record<string, number>, TScene extends Scene = Scene> {
313
+ /** Number of independent simulation rollouts (`default = seeds?.length ?? 16`). */
314
+ readonly runs?: number;
315
+ /** Optional explicit seed list; defaults to `baseSeed + runIndex`. */
316
+ readonly seeds?: readonly number[];
317
+ /** Starting integer seed when `seeds` is omitted (`default = 1`). */
318
+ readonly baseSeed?: number;
319
+ /** Total deterministic simulation ticks executed per run (`default = 1800` = 30s @ 60 Hz). */
320
+ readonly ticksPerRun?: number;
321
+ /** Simulation tick frequency in Hz (`default = 60`). */
322
+ readonly fps?: number;
323
+ /** Logical viewport width (`default = 1280`). */
324
+ readonly width?: number;
325
+ /** Logical viewport height (`default = 720`). */
326
+ readonly height?: number;
327
+ /** Construct a fresh `Scene` instance for `(runIndex, seed)`. */
328
+ readonly createScene: (runIndex: number, seed: number) => TScene;
329
+ /** Optional per-tick bot/policy hook `(stage, tick, runIndex, seed) => boolean | void` (return `false` for early stop). */
330
+ readonly onTick?: (stage: HeadlessStage, tick: number, runIndex: number, seed: number) => boolean | void;
331
+ /** Extract numeric telemetry metrics `{ survived: 1, kills: 14, ... }` at the end of each rollout. */
332
+ readonly extractMetrics: (scene: TScene, clock: EngineClockSnapshot, runIndex: number, seed: number) => TMetrics;
333
+ }
334
+ export interface HeadlessRolloutReport<TMetrics extends Record<string, number>> {
335
+ readonly runsCompleted: number;
336
+ readonly totalTicks: number;
337
+ readonly elapsedMs: number;
338
+ readonly ticksPerSecond: number;
339
+ readonly summary: { readonly [K in keyof TMetrics]: MetricSummaryStats; };
340
+ readonly results: ReadonlyArray<HeadlessRolloutRunResult<TMetrics>>;
341
+ }
342
+ /**
343
+ * Execute `N` deterministic zero-rasterization headless game rollouts in a single Node.js, Bun, or Deno process
344
+ * (`stepSimOnly` / `fastForward` with a zero-overhead stub canvas — zero pixel rasterization or GPU driver required!),
345
+ * returning per-run results and aggregated `min / max / mean / p50 / p95 / sum` balance statistics.
346
+ */
347
+ export declare function runHeadlessRollouts<TMetrics extends Record<string, number>, TScene extends Scene = Scene>(options: HeadlessRolloutOptions<TMetrics, TScene>): HeadlessRolloutReport<TMetrics>;
348
+ export interface CompositeVideoCut {
349
+ /** Path to source video or image file. */
350
+ readonly path: string;
351
+ /** Trim start timestamp in seconds (`default = 0`). */
352
+ readonly startSec?: number;
353
+ /** Duration in seconds to include from this source (`omit` = until end of clip). */
354
+ readonly durationSec?: number;
355
+ /** Optional zoom factor (`>= 1`, e.g. `1.12` to reframe or crop edge watermarks/captions). */
356
+ readonly zoom?: number;
357
+ /** Normalized vertical crop anchor in `[0, 1]` when `zoom > 1` (`0` = top, `0.5` = center, `1` = bottom; `default = 0.5`). */
358
+ readonly cropY?: number;
359
+ }
360
+ export interface CompositeOverlayLayer {
361
+ /** Path to transparent Alpha Overlay video (`.webm` `yuva420p` or `.mov` `qtrle`/`prores`) or `.png` image. */
362
+ readonly path: string;
363
+ /** Timeline timestamp in seconds where this overlay begins (`default = 0`). */
364
+ readonly startSec?: number;
365
+ /** Optional timeline timestamp in seconds where this overlay hides. */
366
+ readonly endSec?: number;
367
+ /** Horizontal pixel offset on the target canvas (`default = 0`). */
368
+ readonly x?: number;
369
+ /** Vertical pixel offset on the target canvas (`default = 0`). */
370
+ readonly y?: number;
371
+ }
372
+ export interface CompositeVoiceoverSegment {
373
+ /** Path to synthesized TTS / voiceover clip (`.mp3`, `.wav`, `.m4a`, `.ogg`). */
374
+ readonly path: string;
375
+ /** Timeline start timestamp in seconds (`>= 0`). */
376
+ readonly startSec: number;
377
+ /** Linear gain multiplier (`default = 1.0`). */
378
+ readonly gain?: number;
379
+ }
380
+ export interface ComposeVideoLayersOptions {
381
+ /** Output video path (e.g. `'final.mp4'` or `'final.webm'`). */
382
+ readonly outputPath: string;
383
+ /** Ordered sequence of base video cuts scaled, cropped, and concatenated onto a unified timeline. */
384
+ readonly cuts: ReadonlyArray<CompositeVideoCut>;
385
+ /** Optional transparent Alpha Overlay layers (e.g. rendered by `stage.encodeVideo({ alpha: true })`) composited in order. */
386
+ readonly overlays?: ReadonlyArray<CompositeOverlayLayer>;
387
+ /** Optional single continuous voiceover audio file. */
388
+ readonly voiceoverPath?: string;
389
+ /** Linear gain multiplier for `voiceoverPath` (`default = 1.0`). */
390
+ readonly voiceoverGain?: number;
391
+ /** Optional timed per-sentence/chapter voiceover clips positioned with sample-accurate `adelay`. */
392
+ readonly voiceoverSegments?: ReadonlyArray<CompositeVoiceoverSegment>;
393
+ /** Optional background music file mixed underneath narration. */
394
+ readonly bgmPath?: string;
395
+ /** Linear gain multiplier for `bgmPath` (`default = 0.16`). */
396
+ readonly bgmVolume?: number;
397
+ /** Automatically duck `bgmPath` underneath voiceover via `sidechaincompress` (`default = true`). */
398
+ readonly ducking?: boolean;
399
+ /** Target output width in pixels (`default = 1280`). */
400
+ readonly width?: number;
401
+ /** Target output height in pixels (`default = 720`). */
402
+ readonly height?: number;
403
+ /** Target output frame rate (`default = 60`). */
404
+ readonly fps?: number;
405
+ /** Explicit total output duration cap in seconds (`omit` = length of concatenated base `cuts`). */
406
+ readonly totalDurationSec?: number;
407
+ /** Custom `ffmpeg` executable path (auto-discovers system or cached `ffmpeg` when omitted). */
408
+ readonly ffmpegPath?: string;
409
+ /** Video codec (`default = 'libx264'`, or `'libvpx-vp9'` for `.webm`). */
410
+ readonly videoCodec?: string;
411
+ /** Encoder preset (`default = 'veryfast'`). */
412
+ readonly preset?: string;
413
+ /** Constant Rate Factor (`default = 19` for H.264, `28` for VP9). */
414
+ readonly crf?: number;
415
+ /** Audio bitrate (`default = '192k'`). */
416
+ readonly audioBitrate?: string;
417
+ }
418
+ export interface ComposeVideoLayersResult {
419
+ readonly outputPath: string;
420
+ readonly width: number;
421
+ readonly height: number;
422
+ readonly fps: number;
423
+ readonly cutsCount: number;
424
+ readonly overlaysCount: number;
425
+ readonly ffmpegArgs: string[];
426
+ }
427
+ /**
428
+ * Compile a declarative multi-cut + transparent Alpha Overlay + voiceover/BGM ducking specification
429
+ * into a deterministic single-pass `ffmpeg` `filter_complex` argument array.
430
+ */
431
+ export declare function buildFfmpegCompositeArgs(options: ComposeVideoLayersOptions): string[];
432
+ /**
433
+ * Execute a single-pass `ffmpeg` layer composite combining external video cuts, transparent `@holtjs/stage`
434
+ * Alpha Overlays (`yuva420p` WebM / `qtrle` MOV / PNG), sample-accurate voiceover segments, and auto-ducked BGM.
435
+ */
436
+ export declare function composeVideoLayers(options: ComposeVideoLayersOptions): Promise<ComposeVideoLayersResult>;
437
+ export { type HeadlessWebGpuBackend, type HeadlessWebGpuHandle, type HeadlessWebGpuOptions, type OpenDawnWebGpuOptions, type OpenWgpuNativeFfiOptions, openDawnWebGpu, openWgpuNativeFfi, requestHeadlessWebGpu, unpremultiplyRgbaInPlace };