@holtjs/stage 0.16.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 +11 -0
- package/dist/{game-Dxh9e0Hv.d.ts → game-BrYrde7y.d.ts} +71 -1
- package/dist/{game-CFxS641c.js → game-ChUlbQwx.js} +1 -1
- package/dist/headless.d.ts +100 -4
- package/dist/headless.js +184 -12
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/joystick.d.ts +1 -1
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +303 -1
- package/dist/lighting.d.ts +1 -1
- package/dist/projection.d.ts +1 -1
- package/dist/{renderer-webgpu-q4vdE3kA.js → renderer-webgpu-B4AvHUEt.js} +48 -7
- package/dist/renderer-webgpu.d.ts +2 -2
- package/dist/renderer-webgpu.js +1 -1
- package/dist/rig2d.d.ts +1 -1
- package/dist/tilemap.d.ts +1 -1
- package/dist/trace.d.ts +1 -1
- package/dist/world.d.ts +1 -1
- package/package.json +2 -2
- package/skills/stage/references/subpaths.md +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,17 @@ 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
|
+
|
|
9
20
|
## [0.16.0] - 2026-12-05
|
|
10
21
|
|
|
11
22
|
### Added
|
|
@@ -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;
|
|
@@ -2437,6 +2445,68 @@ declare class RollbackSession<TInput> {
|
|
|
2437
2445
|
stats(): RollbackStats;
|
|
2438
2446
|
}
|
|
2439
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;
|
|
2440
2510
|
type StageRenderer = RendererGl | Renderer2D | RendererWebGpu;
|
|
2441
2511
|
interface EngineClockSnapshot {
|
|
2442
2512
|
readonly frameSeq: number;
|
|
@@ -2750,4 +2820,4 @@ declare class Game {
|
|
|
2750
2820
|
step(time: number, delta: number): void;
|
|
2751
2821
|
destroy(removeCanvas?: boolean): void;
|
|
2752
2822
|
}
|
|
2753
|
-
export {
|
|
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 {
|
|
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";
|
package/dist/headless.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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;
|
|
@@ -338,4 +345,93 @@ export interface HeadlessRolloutReport<TMetrics extends Record<string, number>>
|
|
|
338
345
|
* returning per-run results and aggregated `min / max / mean / p50 / p95 / sum` balance statistics.
|
|
339
346
|
*/
|
|
340
347
|
export declare function runHeadlessRollouts<TMetrics extends Record<string, number>, TScene extends Scene = Scene>(options: HeadlessRolloutOptions<TMetrics, TScene>): HeadlessRolloutReport<TMetrics>;
|
|
341
|
-
export
|
|
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 };
|
package/dist/headless.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./types-CXsCvp1p.js";
|
|
2
|
-
import { n as Game } from "./game-
|
|
3
|
-
import { a as
|
|
2
|
+
import { n as Game } from "./game-ChUlbQwx.js";
|
|
3
|
+
import { a as openWgpuNativeFfi, i as openDawnWebGpu, o as requestHeadlessWebGpu, r as unpremultiplyRgbaInPlace } from "./renderer-webgpu-B4AvHUEt.js";
|
|
4
4
|
import { buildSceneDigest } from "./trace.js";
|
|
5
5
|
// src/headless.ts
|
|
6
6
|
let pngCrcTable = null;
|
|
@@ -266,7 +266,7 @@ function createHeadlessStage(options) {
|
|
|
266
266
|
if (game.renderer.type === 2 && game.renderer.gl) {
|
|
267
267
|
const gl = game.renderer.gl;
|
|
268
268
|
gl.readPixels(0, 0, cw, ch, gl.RGBA, gl.UNSIGNED_BYTE, dst);
|
|
269
|
-
return dst;
|
|
269
|
+
return game.transparent || primaryScene.cameras.main.transparent ? unpremultiplyRgbaInPlace(dst) : dst;
|
|
270
270
|
}
|
|
271
271
|
const ctx = rootCanvas.getContext("2d");
|
|
272
272
|
if (!ctx) throw new Error("HeadlessStage.toRgbaInto: 2D context unavailable");
|
|
@@ -282,7 +282,7 @@ function createHeadlessStage(options) {
|
|
|
282
282
|
const gl = game.renderer.gl;
|
|
283
283
|
const out = new Uint8Array(cw * ch * 4);
|
|
284
284
|
gl.readPixels(0, 0, cw, ch, gl.RGBA, gl.UNSIGNED_BYTE, out);
|
|
285
|
-
return out;
|
|
285
|
+
return game.transparent || primaryScene.cameras.main.transparent ? unpremultiplyRgbaInPlace(out) : out;
|
|
286
286
|
}
|
|
287
287
|
const ctx = rootCanvas.getContext("2d");
|
|
288
288
|
if (!ctx) throw new Error("HeadlessStage.toRgba: 2D context unavailable");
|
|
@@ -636,25 +636,35 @@ function buildFfmpegRawVideoArgs(options) {
|
|
|
636
636
|
const h = Math.max(1, Math.round(options.height));
|
|
637
637
|
const fps = Math.max(1, Math.round(options.fps));
|
|
638
638
|
const inFmt = options.inputFormat ?? "rawvideo";
|
|
639
|
+
const wantAlpha = Boolean(options.alpha);
|
|
639
640
|
const isWebm = /\.webm$/i.test(options.outputPath);
|
|
640
|
-
const
|
|
641
|
+
const isMov = /\.mov$/i.test(options.outputPath);
|
|
642
|
+
const vCodec = options.videoCodec ?? (wantAlpha ? isMov ? "qtrle" : "libvpx-vp9" : isWebm ? "libvpx-vp9" : "libx264");
|
|
641
643
|
const isVp9 = vCodec.includes("vp9") || vCodec.includes("vp8");
|
|
644
|
+
const isQtrle = vCodec === "qtrle" || vCodec === "png";
|
|
645
|
+
const isProres = vCodec.includes("prores");
|
|
642
646
|
const args = ["-y"];
|
|
643
647
|
if (inFmt === "mjpeg" || inFmt === "png") args.push("-f", "image2pipe", "-vcodec", inFmt, "-r", String(fps), "-i", "pipe:0");
|
|
644
648
|
else args.push("-f", "rawvideo", "-pix_fmt", "rgba", "-s", `${w}x${h}`, "-r", String(fps), "-i", "pipe:0");
|
|
645
649
|
if (options.audioWavPath) args.push("-i", options.audioWavPath);
|
|
646
650
|
args.push("-c:v", vCodec);
|
|
647
|
-
if (
|
|
648
|
-
else
|
|
651
|
+
if (isQtrle) args.push("-pix_fmt", options.outputPixelFormat ?? (vCodec === "png" ? "rgba" : "argb"));
|
|
652
|
+
else if (isProres) args.push("-pix_fmt", options.outputPixelFormat ?? (wantAlpha ? "yuva444p10le" : "yuv422p10le"));
|
|
653
|
+
else if (isVp9) {
|
|
654
|
+
args.push("-b:v", "0", "-crf", String(options.crf ?? (wantAlpha ? 24 : 28)), "-deadline", "realtime", "-cpu-used", "8");
|
|
655
|
+
if (wantAlpha) args.push("-auto-alt-ref", "0");
|
|
656
|
+
args.push("-pix_fmt", options.outputPixelFormat ?? (wantAlpha ? "yuva420p" : "yuv420p"));
|
|
657
|
+
} else {
|
|
649
658
|
if (options.preset !== "") args.push("-preset", options.preset ?? "veryfast");
|
|
650
659
|
args.push("-crf", String(options.crf ?? 19), "-pix_fmt", options.outputPixelFormat ?? "yuv420p");
|
|
651
660
|
}
|
|
652
661
|
if (options.audioWavPath) args.push("-c:a", options.audioCodec ?? (isWebm ? "libopus" : "aac"), "-b:a", options.audioBitrate ?? "160k", "-shortest");
|
|
653
662
|
if (options.extraArgs && options.extraArgs.length > 0) args.push(...options.extraArgs);
|
|
654
|
-
if (isWebm || isVp9) {
|
|
663
|
+
if (isWebm || isVp9 && !isMov) {
|
|
655
664
|
if (isWebm) args.push("-f", "webm");
|
|
656
665
|
args.push(options.outputPath);
|
|
657
|
-
} else args.push(
|
|
666
|
+
} else if (isMov || isQtrle || isProres) args.push(options.outputPath);
|
|
667
|
+
else args.push("-movflags", "+faststart", options.outputPath);
|
|
658
668
|
return args;
|
|
659
669
|
}
|
|
660
670
|
const JPEG_ZIGZAG = new Uint8Array([
|
|
@@ -1642,8 +1652,10 @@ async function encodeVideoWithFfmpeg(stage, options) {
|
|
|
1642
1652
|
}
|
|
1643
1653
|
}
|
|
1644
1654
|
const isWebm = /\.webm$/i.test(options.outputPath);
|
|
1645
|
-
const
|
|
1646
|
-
const
|
|
1655
|
+
const isMov = /\.mov$/i.test(options.outputPath);
|
|
1656
|
+
const wantAlpha = options.alpha !== void 0 ? Boolean(options.alpha) : Boolean((stage.game.transparent || stage.scene.cameras.main.transparent) && (isWebm || isMov));
|
|
1657
|
+
const resolvedInputFormat = options.inputFormat && options.inputFormat !== "auto" ? options.inputFormat : caps && !caps.rawvideo && caps.image2pipe ? wantAlpha ? "png" : caps.mjpegDec ? "mjpeg" : "png" : "rawvideo";
|
|
1658
|
+
const resolvedVideoCodec = options.videoCodec ?? (wantAlpha ? isMov ? "qtrle" : "libvpx-vp9" : isWebm ? "libvpx-vp9" : caps?.found && !caps.libx264 && caps.libvpxVp9 ? "libvpx-vp9" : "libx264");
|
|
1647
1659
|
const canMuxAudio = Boolean(options.audio) && (!caps?.found || Boolean(options.audioCodec) || caps.aac || caps.libopus);
|
|
1648
1660
|
let tempWavPath = null;
|
|
1649
1661
|
let audioWavPath;
|
|
@@ -1662,6 +1674,7 @@ async function encodeVideoWithFfmpeg(stage, options) {
|
|
|
1662
1674
|
height: ch,
|
|
1663
1675
|
fps: stage.fps,
|
|
1664
1676
|
outputPath: options.outputPath,
|
|
1677
|
+
alpha: wantAlpha,
|
|
1665
1678
|
inputFormat: resolvedInputFormat,
|
|
1666
1679
|
audioWavPath,
|
|
1667
1680
|
videoCodec: resolvedVideoCodec,
|
|
@@ -1971,4 +1984,163 @@ function runHeadlessRollouts(options) {
|
|
|
1971
1984
|
results
|
|
1972
1985
|
};
|
|
1973
1986
|
}
|
|
1974
|
-
|
|
1987
|
+
/**
|
|
1988
|
+
* Compile a declarative multi-cut + transparent Alpha Overlay + voiceover/BGM ducking specification
|
|
1989
|
+
* into a deterministic single-pass `ffmpeg` `filter_complex` argument array.
|
|
1990
|
+
*/
|
|
1991
|
+
function buildFfmpegCompositeArgs(options) {
|
|
1992
|
+
if (!options.cuts || options.cuts.length === 0) throw new Error("buildFfmpegCompositeArgs: cuts array must contain at least one video cut");
|
|
1993
|
+
const w = Math.max(2, Math.round((options.width ?? 1280) / 2) * 2);
|
|
1994
|
+
const h = Math.max(2, Math.round((options.height ?? 720) / 2) * 2);
|
|
1995
|
+
const fps = Math.max(1, Math.round(options.fps ?? 60));
|
|
1996
|
+
const isWebm = /\.webm$/i.test(options.outputPath);
|
|
1997
|
+
const vCodec = options.videoCodec ?? (isWebm ? "libvpx-vp9" : "libx264");
|
|
1998
|
+
const isVp9 = vCodec.includes("vp9") || vCodec.includes("vp8");
|
|
1999
|
+
const args = ["-y"];
|
|
2000
|
+
const filters = [];
|
|
2001
|
+
let nextInputIdx = 0;
|
|
2002
|
+
const cutLabels = [];
|
|
2003
|
+
for (let i = 0; i < options.cuts.length; i++) {
|
|
2004
|
+
const cut = options.cuts[i];
|
|
2005
|
+
if (cut.startSec !== void 0 && cut.startSec > 0) args.push("-ss", cut.startSec.toFixed(3));
|
|
2006
|
+
if (cut.durationSec !== void 0 && cut.durationSec > 0) args.push("-t", cut.durationSec.toFixed(3));
|
|
2007
|
+
if (/\.png$|\.jpg$|\.jpeg$|\.webp$/i.test(cut.path) && cut.durationSec) args.push("-loop", "1");
|
|
2008
|
+
args.push("-i", cut.path);
|
|
2009
|
+
const idx = nextInputIdx++;
|
|
2010
|
+
const z = Math.max(1, cut.zoom ?? 1);
|
|
2011
|
+
const cy = Math.max(0, Math.min(1, cut.cropY ?? .5));
|
|
2012
|
+
const sw = Math.max(w, Math.round(w * z / 2) * 2);
|
|
2013
|
+
const sh = Math.max(h, Math.round(h * z / 2) * 2);
|
|
2014
|
+
const cropExpr = z > 1.0001 ? `crop=${w}:${h}:(iw-${w})/2:(ih-${h})*${cy.toFixed(4)}` : `crop=${w}:${h}`;
|
|
2015
|
+
const lbl = `[vcut${i}]`;
|
|
2016
|
+
filters.push(`[${idx}:v]scale=${sw}:${sh}:force_original_aspect_ratio=increase,${cropExpr},fps=${fps},setsar=1,format=yuv420p,setpts=PTS-STARTPTS${lbl}`);
|
|
2017
|
+
cutLabels.push(lbl);
|
|
2018
|
+
}
|
|
2019
|
+
let curVideo = cutLabels[0];
|
|
2020
|
+
if (cutLabels.length > 1) {
|
|
2021
|
+
filters.push(`${cutLabels.join("")}concat=n=${cutLabels.length}:v=1:a=0[vcat]`);
|
|
2022
|
+
curVideo = "[vcat]";
|
|
2023
|
+
}
|
|
2024
|
+
const overlays = options.overlays ?? [];
|
|
2025
|
+
for (let j = 0; j < overlays.length; j++) {
|
|
2026
|
+
const ov = overlays[j];
|
|
2027
|
+
const startSec = Math.max(0, ov.startSec ?? 0);
|
|
2028
|
+
if (startSec > 0) args.push("-itsoffset", startSec.toFixed(3));
|
|
2029
|
+
if (/\.webm$/i.test(ov.path)) args.push("-c:v", "libvpx-vp9");
|
|
2030
|
+
else if (/\.png$/i.test(ov.path)) args.push("-loop", "1");
|
|
2031
|
+
args.push("-i", ov.path);
|
|
2032
|
+
const idx = nextInputIdx++;
|
|
2033
|
+
const ox = Math.round(ov.x ?? 0);
|
|
2034
|
+
const oy = Math.round(ov.y ?? 0);
|
|
2035
|
+
let enableOpt = "";
|
|
2036
|
+
if (ov.startSec !== void 0 && ov.endSec !== void 0) enableOpt = `:enable='between(t,${ov.startSec.toFixed(3)},${ov.endSec.toFixed(3)})'`;
|
|
2037
|
+
else if (ov.startSec !== void 0 && ov.startSec > 0) enableOpt = `:enable='gte(t,${ov.startSec.toFixed(3)})'`;
|
|
2038
|
+
else if (ov.endSec !== void 0) enableOpt = `:enable='lte(t,${ov.endSec.toFixed(3)})'`;
|
|
2039
|
+
const nextLbl = `[vov${j}]`;
|
|
2040
|
+
filters.push(`${curVideo}[${idx}:v]overlay=${ox}:${oy}:format=auto:eof_action=pass${enableOpt}${nextLbl}`);
|
|
2041
|
+
curVideo = nextLbl;
|
|
2042
|
+
}
|
|
2043
|
+
filters.push(`${curVideo}format=yuv420p[vout]`);
|
|
2044
|
+
const voTrackLabels = [];
|
|
2045
|
+
if (options.voiceoverPath) {
|
|
2046
|
+
args.push("-i", options.voiceoverPath);
|
|
2047
|
+
const idx = nextInputIdx++;
|
|
2048
|
+
const gain = options.voiceoverGain ?? 1;
|
|
2049
|
+
filters.push(`[${idx}:a]aresample=44100,aformat=sample_fmts=fltp:channel_layouts=stereo,volume=${gain.toFixed(3)}[avofull]`);
|
|
2050
|
+
voTrackLabels.push("[avofull]");
|
|
2051
|
+
}
|
|
2052
|
+
const segs = options.voiceoverSegments ?? [];
|
|
2053
|
+
for (let k = 0; k < segs.length; k++) {
|
|
2054
|
+
const seg = segs[k];
|
|
2055
|
+
args.push("-i", seg.path);
|
|
2056
|
+
const idx = nextInputIdx++;
|
|
2057
|
+
const delayMs = Math.max(0, Math.round(seg.startSec * 1e3));
|
|
2058
|
+
const gain = seg.gain ?? 1;
|
|
2059
|
+
const lbl = `[aseg${k}]`;
|
|
2060
|
+
filters.push(`[${idx}:a]aresample=44100,aformat=sample_fmts=fltp:channel_layouts=stereo,volume=${gain.toFixed(3)},adelay=${delayMs}|${delayMs}${lbl}`);
|
|
2061
|
+
voTrackLabels.push(lbl);
|
|
2062
|
+
}
|
|
2063
|
+
let voBus = null;
|
|
2064
|
+
if (voTrackLabels.length === 1) {
|
|
2065
|
+
filters.push(`${voTrackLabels[0]}apad[avo]`);
|
|
2066
|
+
voBus = "[avo]";
|
|
2067
|
+
} else if (voTrackLabels.length > 1) {
|
|
2068
|
+
filters.push(`${voTrackLabels.join("")}amix=inputs=${voTrackLabels.length}:duration=longest:dropout_transition=0:normalize=0,apad[avo]`);
|
|
2069
|
+
voBus = "[avo]";
|
|
2070
|
+
}
|
|
2071
|
+
let audioOut = null;
|
|
2072
|
+
if (options.bgmPath) {
|
|
2073
|
+
args.push("-stream_loop", "-1", "-i", options.bgmPath);
|
|
2074
|
+
const bgmIdx = nextInputIdx++;
|
|
2075
|
+
const bgmVol = Math.max(0, options.bgmVolume ?? .16);
|
|
2076
|
+
filters.push(`[${bgmIdx}:a]aresample=44100,aformat=sample_fmts=fltp:channel_layouts=stereo,volume=${bgmVol.toFixed(3)}[abgm]`);
|
|
2077
|
+
if (voBus) {
|
|
2078
|
+
if (options.ducking !== false) filters.push(`${voBus}asplit=2[avomain][avosc]`, `[abgm][avosc]sidechaincompress=threshold=0.03:ratio=6:attack=25:release=320[abgmduck]`, `[avomain][abgmduck]amix=inputs=2:duration=first:dropout_transition=0:normalize=0[aout]`);
|
|
2079
|
+
else filters.push(`${voBus}[abgm]amix=inputs=2:duration=first:dropout_transition=0:normalize=0[aout]`);
|
|
2080
|
+
audioOut = "[aout]";
|
|
2081
|
+
} else audioOut = "[abgm]";
|
|
2082
|
+
} else if (voBus) audioOut = voBus;
|
|
2083
|
+
args.push("-filter_complex", filters.join(";"), "-map", "[vout]");
|
|
2084
|
+
if (audioOut) args.push("-map", audioOut);
|
|
2085
|
+
if (options.totalDurationSec !== void 0 && options.totalDurationSec > 0) args.push("-t", options.totalDurationSec.toFixed(3));
|
|
2086
|
+
args.push("-c:v", vCodec);
|
|
2087
|
+
if (isVp9) args.push("-b:v", "0", "-crf", String(options.crf ?? 28), "-deadline", "good", "-cpu-used", "4", "-pix_fmt", "yuv420p");
|
|
2088
|
+
else {
|
|
2089
|
+
if (options.preset !== "") args.push("-preset", options.preset ?? "veryfast");
|
|
2090
|
+
args.push("-crf", String(options.crf ?? 19), "-pix_fmt", "yuv420p");
|
|
2091
|
+
}
|
|
2092
|
+
if (audioOut) args.push("-c:a", isWebm ? "libopus" : "aac", "-b:a", options.audioBitrate ?? "192k", "-shortest");
|
|
2093
|
+
if (isWebm || isVp9) {
|
|
2094
|
+
if (isWebm) args.push("-f", "webm");
|
|
2095
|
+
args.push(options.outputPath);
|
|
2096
|
+
} else args.push("-movflags", "+faststart", options.outputPath);
|
|
2097
|
+
return args;
|
|
2098
|
+
}
|
|
2099
|
+
/**
|
|
2100
|
+
* Execute a single-pass `ffmpeg` layer composite combining external video cuts, transparent `@holtjs/stage`
|
|
2101
|
+
* Alpha Overlays (`yuva420p` WebM / `qtrle` MOV / PNG), sample-accurate voiceover segments, and auto-ducked BGM.
|
|
2102
|
+
*/
|
|
2103
|
+
async function composeVideoLayers(options) {
|
|
2104
|
+
const cp = await dynamicImportHeadless("node:child_process");
|
|
2105
|
+
const fs = await dynamicImportHeadless("node:fs");
|
|
2106
|
+
const os = await dynamicImportHeadless("node:os");
|
|
2107
|
+
const path = await dynamicImportHeadless("node:path");
|
|
2108
|
+
let ffmpegBin = options.ffmpegPath ?? "ffmpeg";
|
|
2109
|
+
if (!options.ffmpegPath) {
|
|
2110
|
+
const caps = probeFfmpegCapabilities(cp, ffmpegBin);
|
|
2111
|
+
if (caps && !caps.found) {
|
|
2112
|
+
const pwBin = discoverPlaywrightFfmpeg(fs, os, path);
|
|
2113
|
+
if (pwBin) ffmpegBin = pwBin;
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
const ffArgs = buildFfmpegCompositeArgs(options);
|
|
2117
|
+
const w = Math.max(2, Math.round((options.width ?? 1280) / 2) * 2);
|
|
2118
|
+
const h = Math.max(2, Math.round((options.height ?? 720) / 2) * 2);
|
|
2119
|
+
const fps = Math.max(1, Math.round(options.fps ?? 60));
|
|
2120
|
+
await new Promise((resolve, reject) => {
|
|
2121
|
+
const proc = cp.spawn(ffmpegBin, ffArgs, { stdio: [
|
|
2122
|
+
"ignore",
|
|
2123
|
+
"ignore",
|
|
2124
|
+
"pipe"
|
|
2125
|
+
] });
|
|
2126
|
+
let stderr = "";
|
|
2127
|
+
proc.stderr.on("data", (chunk) => {
|
|
2128
|
+
stderr += chunk.toString();
|
|
2129
|
+
});
|
|
2130
|
+
proc.on("error", reject);
|
|
2131
|
+
proc.on("close", (code) => {
|
|
2132
|
+
if (code === 0) resolve();
|
|
2133
|
+
else reject(/* @__PURE__ */ new Error(`composeVideoLayers: ffmpeg exited with code ${String(code)}:\n${stderr}`));
|
|
2134
|
+
});
|
|
2135
|
+
});
|
|
2136
|
+
return {
|
|
2137
|
+
outputPath: options.outputPath,
|
|
2138
|
+
width: w,
|
|
2139
|
+
height: h,
|
|
2140
|
+
fps,
|
|
2141
|
+
cutsCount: options.cuts.length,
|
|
2142
|
+
overlaysCount: (options.overlays ?? []).length,
|
|
2143
|
+
ffmpegArgs: ffArgs
|
|
2144
|
+
};
|
|
2145
|
+
}
|
|
2146
|
+
export { buildFfmpegCompositeArgs, buildFfmpegRawVideoArgs, composeVideoLayers, createAudioTimeline, createHeadlessStage, createHeadlessStageAsync, encodeVideoWithFfmpeg, openDawnWebGpu, openHeadlessStage, openWgpuNativeFfi, renderStoryboard, requestHeadlessWebGpu, runHeadlessRollouts, unpremultiplyRgbaInPlace };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $n as
|
|
1
|
+
import { $n as PanelOpenSide, $t as InputConfig, A as RecordedInputEntry, An as Container, B as TimelineDragOptions, Bn as DrawStreamBulkView, C as CameraPanOptions, Cn as RendererStats, D as InputTargetSpec, Dn as BindEquipmentOptions, E as InputRecorderPlugin, En as AnchorPose2D, F as RollbackStats, Fn as DirectionalPlayOptions, G as createInputTimeline, Gn as Graphics, Gt as SceneDigestOptions, H as createCameraDirector, Hn as DrawStreamOptions, Ht as SceneDigestActiveFocus, I as StageInputEvent, In as DisplayList, Jn as InstancedColumns, Jt as SceneDigestSurfaceEntry, K as createRollbackSession, Kn as ImageObject, Kt as SceneDigestOverlayStats, L as StageKernel, Ln as DisplayObject, M as RollbackSession, Mn as CustomPassCallback, N as RollbackSessionOptions, Nn as CustomPassObject, O as InputTimelineOptions, On as BlitterObject, P as RollbackStateCodec, Pn as CustomPassOptions, Qn as PanelObject, Qt as sanitizeTrackToken, R as StagePlugin, Rn as DisplayObjectType, S as CameraFollowCueOptions, Sn as RendererGlOptions, T as InputProvider, Tn as StageRenderTarget, U as createInputRecorder, Un as DrawStreamSpriteOptions, Ut as SceneDigestEngineSandbox, V as TimelineKeyOptions, Vn as DrawStreamObject, Vt as SceneDigest, W as createInputReplay, Wn as EquipmentBinding, Wt as SceneDigestNode, Xn as MsdfIconObject, Xt as SceneDigestSurfaces, Yn as MsdfIconConfig, Yt as SceneDigestSurfaceSource, Zn as NineSliceObject, Zt as buildSceneDigest, _ as ActionMap, _n as openDawnWebGpu, _r as HiDpiScaleLike, a as GameLoop, an as RendererWebGpuOptions, ar as ShapeBatchObject, b as CameraDirectorPlugin, bn as Renderer2D, c as LoaderPlugin, cn as WebGpuCanvasContextLike, cr as SpriteObject, d as SceneCtor, dn as unpremultiplyRgbaInPlace, dr as TextObject, en as InputPlugin, er as PanelStyleConfig, f as SceneInput, fn as HeadlessWebGpuBackend, fr as TextStyleConfig, g as ViewportFitResult, gn as OpenWgpuNativeFfiOptions, gr as HiDpiConfigureOptions, h as StageRenderer, hn as OpenDawnWebGpuOptions, hr as CameraFollowOptions, i as GameConfig$1, in as RendererWebGpu, ir as ShapeBatchColumns, j as RollbackResult, jn as ContainerFiltersShim, k as InputTimelinePlugin, kn as Bob$1, l as ScaleManager, ln as WebGpuDeviceLike, lr as SpritePlayOptions, m as SceneManager, mn as HeadlessWebGpuOptions, mr as Camera, n as EngineClockSnapshot, nn as Pointer, nr as RectangleObject, o as GameObjectFactory, on as RequestWebGpuOptions, or as ShapeBatchStyleDefaults, p as SceneLifecycleStats, pn as HeadlessWebGpuHandle, pr as TileSpriteObject, qn as InstancedBatchObject, qt as SceneDigestSandbox, r as Game, rn as PointerSample, rr as SceneHostLike, s as JsonCache, sn as WebGpuBootstrapResult, sr as SpriteAnimEventListener, t as EngineClock, tn as KeyboardPlugin, tr as RectClipMask, u as Scene, un as requestWebGpuDevice, ur as SyncAttachmentOptions, v as CameraCutOptions, vn as openWgpuNativeFfi, w as CameraSpotlightOptions, wn as Stage2DCustomImageHandler, x as CameraDirectorTarget, xn as RendererGl, y as CameraDirectorOptions, yn as requestHeadlessWebGpu, z as TimelineClickOptions, zn as DisplaySemantics } from "./game-BrYrde7y.js";
|
|
2
2
|
import { A as FilterModeValue, B as WEBGL, C as AUTO, D as CANVAS, E as BlendModes, F as Scale, G as packColorAbgr, H as WHITE_RGB, I as ScaleMode, K as parseColor, L as Scenes, M as Matrix2D, N as Rect2D, O as EventEmitter, P as RgbaColor, R as TintMode, S as TextureSource, T as BlendMode, U as WorldView2D, V as WEBGPU, W as createMatrix2D, _ as SpriteSheetConfig, a as AtlasClipRule, b as TextureImageSource, c as GenerateFrameNamesConfig, d as AtlasJsonLike, f as CanvasTexture, g as GlTextureHost, h as FrameExtraMeta, i as AtlasAutoAnimOptions, j as HEX_MASK, k as FilterMode, l as GenerateFrameNumbersConfig, m as FrameAnchorTuple, n as AnimationFrameInput, o as CompiledAnimationFrame, p as Frame, q as rgbToCss, r as AnimationManager, s as DirectionalAnimGroup, t as AnimationConfig, u as StageAnimation, v as Texture, w as BLACK_RGB, x as TextureManager, y as TextureImageOptions, z as TintModes } from "./anims-BOvaKn6w.js";
|
|
3
3
|
import { LocomotionFeel, LocomotionFeelInput, LocomotionFeelOptions, LocomotionFeelSample } from "./particles.js";
|
|
4
4
|
import { FlattenedFlexNode, FlattenedFlexTree, FlexAlign, FlexContainerSpec, FlexDir, FlexIconSpec, FlexItemRect, FlexItemSpec, FlexJustify, FlexNodeSpec, FlexPadding, FlexPanelStyle, FlexResult, FlexTextSpec, MountFlexUiOptions, MountedFlexUi, WrapContainerSpec, WrapItemRect, WrapItemSpec, WrapJustify, WrapResult, computeFlexLayout, computeWrapLayout, flattenFlexTree, mountFlexUi, resolvePadding } from "./flex.js";
|
|
@@ -333,4 +333,4 @@ export declare const Stage: {
|
|
|
333
333
|
};
|
|
334
334
|
};
|
|
335
335
|
};
|
|
336
|
-
export { AUTO, ActionMap, type AnchorPose2D, type AnimationConfig, type AnimationFrameInput, AnimationManager, type AtlasAutoAnimOptions, type AtlasClipRule, type AtlasJsonLike, BLACK_RGB, type BindEquipmentOptions, type BlendMode, BlendModes, BlitterObject, type Bob$1 as Bob, CANVAS, Camera, type CameraFollowOptions, CanvasTexture, type CompiledAnimationFrame, Container, type ContainerFiltersShim, type CoroutineGenerator, type CustomPassCallback, CustomPassObject, type CustomPassOptions, type DirectionalAnimGroup, type DirectionalPlayOptions, DisplayList, DisplayObject, type DisplayObjectType, type DisplaySemantics, type DisposableOwner, type DrawStreamBulkView, DrawStreamObject, type DrawStreamOptions, type DrawStreamSpriteOptions, type EasingFn, type EasingName, Easings, EngineClock, type EngineClockSnapshot, type EquipmentBinding, EventEmitter, FilterMode, type FilterModeValue, type FlattenedFlexNode, type FlattenedFlexTree, type FlexAlign, type FlexContainerSpec, type FlexDir, type FlexIconSpec, type FlexItemRect, type FlexItemSpec, type FlexJustify, type FlexNodeSpec, type FlexPadding, type FlexPanelStyle, type FlexResult, type FlexTextSpec, Frame, type FrameAnchorTuple, type FrameExtraMeta, Game, type GameConfig$1 as GameConfig, GameLoop, GameObjectFactory, type GenerateFrameNamesConfig, type GenerateFrameNumbersConfig, type GlTextureHost, Graphics, HEX_MASK, type HeadlessWebGpuBackend, type HeadlessWebGpuHandle, type HeadlessWebGpuOptions, type HiDpiConfigureOptions, type HiDpiScaleLike, ImageObject, type InputConfig, InputPlugin, type InputProvider, type InputRecorderPlugin, type InputTargetSpec, type InputTimelineOptions, type InputTimelinePlugin, InstancedBatchObject, type InstancedColumns, type JoystickDpad, type JoystickDpadOptions, type JoystickState, type JoystickVector, type JoystickViewport, type JoystickZone, type JoystickZonePredicate, type JoystickZoneRect, JsonCache, KeyboardPlugin, LoaderPlugin, LocomotionFeel, type LocomotionFeelInput, type LocomotionFeelOptions, type LocomotionFeelSample, type Matrix2D, type MountFlexUiOptions, type MountedFlexUi, type MsdfIconConfig, MsdfIconObject, NineSliceObject, type OpenDawnWebGpuOptions, type OpenWgpuNativeFfiOptions, PanelObject, type PanelOpenSide, type PanelStyleConfig, Pointer, type PointerSample, type RecordedInputEntry, type Rect2D, type RectClipMask, RectangleObject, Renderer2D, RendererGl, type RendererGlOptions, type RendererStats, RendererWebGpu, type RendererWebGpuOptions, type RequestWebGpuOptions, type RgbaColor, type RollbackResult, RollbackSession, type RollbackSessionOptions, type RollbackStateCodec, type RollbackStats, SURFACE_BAND, Scale, ScaleManager, type ScaleMode, Scene, type SceneCtor, type SceneDigest, type SceneDigestActiveFocus, type SceneDigestEngineSandbox, type SceneDigestNode, type SceneDigestOptions, type SceneDigestOverlayStats, type SceneDigestSandbox, type SceneDigestSurfaceEntry, type SceneDigestSurfaceSource, type SceneDigestSurfaces, type SceneHostLike, type SceneInput, type SceneLifecycleStats, SceneManager, Scenes, type ScriptContext, type ScriptHandle, type ScriptOptions, ScriptScheduler, type ScriptStats, type ShapeBatchColumns, ShapeBatchObject, type ShapeBatchStyleDefaults, type SpringHandle, type SpringOptions, type SpriteAnimEventListener, SpriteObject, type SpritePlayOptions, type SpriteSheetConfig, Stage as default, type Stage2DCustomImageHandler, type StageAnimation, type StageInputEvent, StageKernel, type StagePlugin, type StageRenderTarget, type StageRenderer, type SurfaceBand, type SurfaceBandName, type SurfaceBarrier, type SurfaceCancelContext, type SurfaceCancelDispatchResult, type SurfaceCancelResult, type SurfaceDomEntry, type SurfaceFocusContext, type SurfaceFocusDispatchResult, type SurfaceFocusResult, type SurfaceKeyContext, type SurfaceKeyDispatchResult, type SurfaceKeyResult, type SurfaceNodeInfo, type SurfaceNodeInput, type SurfaceScope, type SurfaceTree, type SyncAttachmentOptions, TextObject, type TextStyleConfig, Texture, type TextureImageOptions, type TextureImageSource, TextureManager, TextureSource, TileSpriteObject, type TimelineClickOptions, type TimelineDragOptions, type TimelineKeyOptions, type TintMode, TintModes, type TweenHandle, TweenManager, type TweenOptions, type TweenStats, type ViewportFitResult, VirtualJoystick, type VirtualJoystickMode, type VirtualJoystickOptions, type VirtualJoystickStyle, WEBGL, WEBGPU, WHITE_RGB, type WebGpuBootstrapResult, type WebGpuCanvasContextLike, type WebGpuDeviceLike, type WorldView2D, type WrapContainerSpec, type WrapItemRect, type WrapItemSpec, type WrapJustify, type WrapResult, buildSceneDigest, clampJoystickOrigin, computeFlexLayout, computeJoystickVector, computeSurfaceDomZ, computeWrapLayout, createInputRecorder, createInputReplay, createInputTimeline, createMatrix2D, createRollbackSession, createSurfaceTree, flattenFlexTree, isInJoystickZone, mountFlexUi, openDawnWebGpu, openWgpuNativeFfi, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, requestHeadlessWebGpu, requestWebGpuDevice, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ };
|
|
336
|
+
export { AUTO, ActionMap, type AnchorPose2D, type AnimationConfig, type AnimationFrameInput, AnimationManager, type AtlasAutoAnimOptions, type AtlasClipRule, type AtlasJsonLike, BLACK_RGB, type BindEquipmentOptions, type BlendMode, BlendModes, BlitterObject, type Bob$1 as Bob, CANVAS, Camera, type CameraCutOptions, type CameraDirectorOptions, type CameraDirectorPlugin, type CameraDirectorTarget, type CameraFollowCueOptions, type CameraFollowOptions, type CameraPanOptions, type CameraSpotlightOptions, CanvasTexture, type CompiledAnimationFrame, Container, type ContainerFiltersShim, type CoroutineGenerator, type CustomPassCallback, CustomPassObject, type CustomPassOptions, type DirectionalAnimGroup, type DirectionalPlayOptions, DisplayList, DisplayObject, type DisplayObjectType, type DisplaySemantics, type DisposableOwner, type DrawStreamBulkView, DrawStreamObject, type DrawStreamOptions, type DrawStreamSpriteOptions, type EasingFn, type EasingName, Easings, EngineClock, type EngineClockSnapshot, type EquipmentBinding, EventEmitter, FilterMode, type FilterModeValue, type FlattenedFlexNode, type FlattenedFlexTree, type FlexAlign, type FlexContainerSpec, type FlexDir, type FlexIconSpec, type FlexItemRect, type FlexItemSpec, type FlexJustify, type FlexNodeSpec, type FlexPadding, type FlexPanelStyle, type FlexResult, type FlexTextSpec, Frame, type FrameAnchorTuple, type FrameExtraMeta, Game, type GameConfig$1 as GameConfig, GameLoop, GameObjectFactory, type GenerateFrameNamesConfig, type GenerateFrameNumbersConfig, type GlTextureHost, Graphics, HEX_MASK, type HeadlessWebGpuBackend, type HeadlessWebGpuHandle, type HeadlessWebGpuOptions, type HiDpiConfigureOptions, type HiDpiScaleLike, ImageObject, type InputConfig, InputPlugin, type InputProvider, type InputRecorderPlugin, type InputTargetSpec, type InputTimelineOptions, type InputTimelinePlugin, InstancedBatchObject, type InstancedColumns, type JoystickDpad, type JoystickDpadOptions, type JoystickState, type JoystickVector, type JoystickViewport, type JoystickZone, type JoystickZonePredicate, type JoystickZoneRect, JsonCache, KeyboardPlugin, LoaderPlugin, LocomotionFeel, type LocomotionFeelInput, type LocomotionFeelOptions, type LocomotionFeelSample, type Matrix2D, type MountFlexUiOptions, type MountedFlexUi, type MsdfIconConfig, MsdfIconObject, NineSliceObject, type OpenDawnWebGpuOptions, type OpenWgpuNativeFfiOptions, PanelObject, type PanelOpenSide, type PanelStyleConfig, Pointer, type PointerSample, type RecordedInputEntry, type Rect2D, type RectClipMask, RectangleObject, Renderer2D, RendererGl, type RendererGlOptions, type RendererStats, RendererWebGpu, type RendererWebGpuOptions, type RequestWebGpuOptions, type RgbaColor, type RollbackResult, RollbackSession, type RollbackSessionOptions, type RollbackStateCodec, type RollbackStats, SURFACE_BAND, Scale, ScaleManager, type ScaleMode, Scene, type SceneCtor, type SceneDigest, type SceneDigestActiveFocus, type SceneDigestEngineSandbox, type SceneDigestNode, type SceneDigestOptions, type SceneDigestOverlayStats, type SceneDigestSandbox, type SceneDigestSurfaceEntry, type SceneDigestSurfaceSource, type SceneDigestSurfaces, type SceneHostLike, type SceneInput, type SceneLifecycleStats, SceneManager, Scenes, type ScriptContext, type ScriptHandle, type ScriptOptions, ScriptScheduler, type ScriptStats, type ShapeBatchColumns, ShapeBatchObject, type ShapeBatchStyleDefaults, type SpringHandle, type SpringOptions, type SpriteAnimEventListener, SpriteObject, type SpritePlayOptions, type SpriteSheetConfig, Stage as default, type Stage2DCustomImageHandler, type StageAnimation, type StageInputEvent, StageKernel, type StagePlugin, type StageRenderTarget, type StageRenderer, type SurfaceBand, type SurfaceBandName, type SurfaceBarrier, type SurfaceCancelContext, type SurfaceCancelDispatchResult, type SurfaceCancelResult, type SurfaceDomEntry, type SurfaceFocusContext, type SurfaceFocusDispatchResult, type SurfaceFocusResult, type SurfaceKeyContext, type SurfaceKeyDispatchResult, type SurfaceKeyResult, type SurfaceNodeInfo, type SurfaceNodeInput, type SurfaceScope, type SurfaceTree, type SyncAttachmentOptions, TextObject, type TextStyleConfig, Texture, type TextureImageOptions, type TextureImageSource, TextureManager, TextureSource, TileSpriteObject, type TimelineClickOptions, type TimelineDragOptions, type TimelineKeyOptions, type TintMode, TintModes, type TweenHandle, TweenManager, type TweenOptions, type TweenStats, type ViewportFitResult, VirtualJoystick, type VirtualJoystickMode, type VirtualJoystickOptions, type VirtualJoystickStyle, WEBGL, WEBGPU, WHITE_RGB, type WebGpuBootstrapResult, type WebGpuCanvasContextLike, type WebGpuDeviceLike, type WorldView2D, type WrapContainerSpec, type WrapItemRect, type WrapItemSpec, type WrapJustify, type WrapResult, buildSceneDigest, clampJoystickOrigin, computeFlexLayout, computeJoystickVector, computeSurfaceDomZ, computeWrapLayout, createCameraDirector, createInputRecorder, createInputReplay, createInputTimeline, createMatrix2D, createRollbackSession, createSurfaceTree, flattenFlexTree, isInJoystickZone, mountFlexUi, openDawnWebGpu, openWgpuNativeFfi, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, requestHeadlessWebGpu, requestWebGpuDevice, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ, unpremultiplyRgbaInPlace };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { _ as rgbToCss, a as EventEmitter, c as Scale, d as WEBGL, f as WEBGPU, g as parseColor, h as packColorAbgr, i as CANVAS, l as Scenes, m as createMatrix2D, n as BLACK_RGB, o as FilterMode, p as WHITE_RGB, r as BlendModes, s as HEX_MASK, t as AUTO, u as TintModes } from "./types-CXsCvp1p.js";
|
|
2
|
-
import { _ as CanvasTexture, a as JsonCache, b as TextureManager, c as Scene, d as KeyboardPlugin, f as Pointer, g as SdfPanelBatcher, h as MsdfIconBatcher, i as GameObjectFactory, l as SceneManager, m as PixelAaBatcher, n as Game, o as LoaderPlugin, p as RendererGl, r as GameLoop, s as ScaleManager, t as EngineClock, u as InputPlugin, v as Frame, x as TextureSource, y as Texture } from "./game-
|
|
2
|
+
import { _ as CanvasTexture, a as JsonCache, b as TextureManager, c as Scene, d as KeyboardPlugin, f as Pointer, g as SdfPanelBatcher, h as MsdfIconBatcher, i as GameObjectFactory, l as SceneManager, m as PixelAaBatcher, n as Game, o as LoaderPlugin, p as RendererGl, r as GameLoop, s as ScaleManager, t as EngineClock, u as InputPlugin, v as Frame, x as TextureSource, y as Texture } from "./game-ChUlbQwx.js";
|
|
3
3
|
import { AnimationManager } from "./anims.js";
|
|
4
|
-
import { a as
|
|
4
|
+
import { a as openWgpuNativeFfi, c as Camera, i as openDawnWebGpu, n as requestWebGpuDevice, o as requestHeadlessWebGpu, r as unpremultiplyRgbaInPlace, s as Renderer2D, t as RendererWebGpu } from "./renderer-webgpu-B4AvHUEt.js";
|
|
5
5
|
import { _ as TileSpriteObject, a as DisplayObject, 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";
|
|
6
|
-
import { ActionMap, RollbackSession, StageKernel, createInputRecorder, createInputReplay, createInputTimeline, createRollbackSession } from "./kernel.js";
|
|
6
|
+
import { ActionMap, RollbackSession, StageKernel, createCameraDirector, createInputRecorder, createInputReplay, createInputTimeline, createRollbackSession } from "./kernel.js";
|
|
7
7
|
import { LocomotionFeel } from "./particles.js";
|
|
8
8
|
import { buildSceneDigest, sanitizeTrackToken } from "./trace.js";
|
|
9
9
|
import { computeFlexLayout, computeWrapLayout, flattenFlexTree, mountFlexUi, resolvePadding } from "./flex.js";
|
|
@@ -52,4 +52,4 @@ const Stage2D = {
|
|
|
52
52
|
Display: { Canvas: { CanvasPool: { enableSmoothing() {} } } }
|
|
53
53
|
};
|
|
54
54
|
const Stage = Stage2D;
|
|
55
|
-
export { AUTO, ActionMap, AnimationManager, BLACK_RGB, BlendModes, BlitterObject, CANVAS, Camera, CanvasTexture, Container, CustomPassObject, DisplayList, DisplayObject, DrawStreamObject, Easings, EngineClock, EventEmitter, FilterMode, Frame, Game, GameLoop, GameObjectFactory, Graphics, HEX_MASK, ImageObject, InputPlugin, InstancedBatchObject, JsonCache, KeyboardPlugin, LoaderPlugin, LocomotionFeel, MsdfIconBatcher, MsdfIconObject, NineSliceObject, PanelObject, PixelAaBatcher, Pointer, RectangleObject, Renderer2D, RendererGl, RendererWebGpu, RollbackSession, SURFACE_BAND, Scale, ScaleManager, Scene, SceneManager, Scenes, ScriptScheduler, SdfPanelBatcher, ShapeBatchObject, SpriteObject, Stage, Stage as default, Stage2D, StageKernel, TextObject, Texture, TextureManager, TextureSource, TileSpriteObject, TintModes, TweenManager, VirtualJoystick, WEBGL, WEBGPU, WHITE_RGB, buildSceneDigest, clampJoystickOrigin, computeFlexLayout, computeJoystickVector, computeSurfaceDomZ, computeWrapLayout, createInputRecorder, createInputReplay, createInputTimeline, createMatrix2D, createRollbackSession, createSurfaceTree, flattenFlexTree, isInJoystickZone, mountFlexUi, openDawnWebGpu, openWgpuNativeFfi, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, requestHeadlessWebGpu, requestWebGpuDevice, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ };
|
|
55
|
+
export { AUTO, ActionMap, AnimationManager, BLACK_RGB, BlendModes, BlitterObject, CANVAS, Camera, CanvasTexture, Container, CustomPassObject, DisplayList, DisplayObject, DrawStreamObject, Easings, EngineClock, EventEmitter, FilterMode, Frame, Game, GameLoop, GameObjectFactory, Graphics, HEX_MASK, ImageObject, InputPlugin, InstancedBatchObject, JsonCache, KeyboardPlugin, LoaderPlugin, LocomotionFeel, MsdfIconBatcher, MsdfIconObject, NineSliceObject, PanelObject, PixelAaBatcher, Pointer, RectangleObject, Renderer2D, RendererGl, RendererWebGpu, RollbackSession, SURFACE_BAND, Scale, ScaleManager, Scene, SceneManager, Scenes, ScriptScheduler, SdfPanelBatcher, ShapeBatchObject, SpriteObject, Stage, Stage as default, Stage2D, StageKernel, TextObject, Texture, TextureManager, TextureSource, TileSpriteObject, TintModes, TweenManager, VirtualJoystick, WEBGL, WEBGPU, WHITE_RGB, buildSceneDigest, clampJoystickOrigin, computeFlexLayout, computeJoystickVector, computeSurfaceDomZ, computeWrapLayout, createCameraDirector, createInputRecorder, createInputReplay, createInputTimeline, createMatrix2D, createRollbackSession, createSurfaceTree, flattenFlexTree, isInJoystickZone, mountFlexUi, openDawnWebGpu, openWgpuNativeFfi, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, requestHeadlessWebGpu, requestWebGpuDevice, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ, unpremultiplyRgbaInPlace };
|
package/dist/joystick.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { An as Container, Qn as PanelObject, nn as Pointer, u as Scene } from "./game-BrYrde7y.js";
|
|
2
2
|
export type VirtualJoystickMode = 'floating' | 'fixed';
|
|
3
3
|
export interface JoystickVector {
|
|
4
4
|
/** Normalized X axis in [-1, 1] after deadzone remapping. */
|
package/dist/kernel.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { a as ScriptOptions, i as ScriptHandle, o as ScriptScheduler, r as ScriptContext, s as ScriptStats, t as CoroutineGenerator } from "./coroutine-DLgJumtD.js";
|
|
2
|
-
import { A as
|
|
3
|
-
export { ActionMap, type CoroutineGenerator, InputProvider, InputRecorderPlugin, InputTargetSpec, InputTimelineOptions, InputTimelinePlugin, RecordedInputEntry, RollbackResult, RollbackSession, RollbackSessionOptions, RollbackStateCodec, RollbackStats, type ScriptContext, type ScriptHandle, type ScriptOptions, ScriptScheduler, type ScriptStats, StageInputEvent, StageKernel, StagePlugin, TimelineClickOptions, TimelineDragOptions, TimelineKeyOptions, createInputRecorder, createInputReplay, createInputTimeline, createRollbackSession };
|
|
2
|
+
import { A as RecordedInputEntry, B as TimelineDragOptions, C as CameraPanOptions, D as InputTargetSpec, E as InputRecorderPlugin, F as RollbackStats, G as createInputTimeline, H as createCameraDirector, I as StageInputEvent, K as createRollbackSession, L as StageKernel, M as RollbackSession, N as RollbackSessionOptions, O as InputTimelineOptions, P as RollbackStateCodec, R as StagePlugin, S as CameraFollowCueOptions, T as InputProvider, U as createInputRecorder, V as TimelineKeyOptions, W as createInputReplay, _ as ActionMap, b as CameraDirectorPlugin, j as RollbackResult, k as InputTimelinePlugin, v as CameraCutOptions, w as CameraSpotlightOptions, x as CameraDirectorTarget, y as CameraDirectorOptions, z as TimelineClickOptions } from "./game-BrYrde7y.js";
|
|
3
|
+
export { ActionMap, CameraCutOptions, CameraDirectorOptions, CameraDirectorPlugin, CameraDirectorTarget, CameraFollowCueOptions, CameraPanOptions, CameraSpotlightOptions, type CoroutineGenerator, InputProvider, InputRecorderPlugin, InputTargetSpec, InputTimelineOptions, InputTimelinePlugin, RecordedInputEntry, RollbackResult, RollbackSession, RollbackSessionOptions, RollbackStateCodec, RollbackStats, type ScriptContext, type ScriptHandle, type ScriptOptions, ScriptScheduler, type ScriptStats, StageInputEvent, StageKernel, StagePlugin, TimelineClickOptions, TimelineDragOptions, TimelineKeyOptions, createCameraDirector, createInputRecorder, createInputReplay, createInputTimeline, createRollbackSession };
|
package/dist/kernel.js
CHANGED
|
@@ -819,4 +819,306 @@ var RollbackSession = class RollbackSession {
|
|
|
819
819
|
function createRollbackSession(options) {
|
|
820
820
|
return new RollbackSession(options);
|
|
821
821
|
}
|
|
822
|
-
|
|
822
|
+
/**
|
|
823
|
+
* In-engine virtual camera choreography & spotlight framing plugin (`StagePlugin`) for product demos,
|
|
824
|
+
* scientific visualizations, and game cutscenes. Resolves targets either by world coordinates `{ x, y }`
|
|
825
|
+
* or live `trackId` across scene display nodes and `UiRoot` elements.
|
|
826
|
+
*/
|
|
827
|
+
function createCameraDirector(options = {}) {
|
|
828
|
+
const id = options.id ?? "stage.camera-director";
|
|
829
|
+
let hostKernel = null;
|
|
830
|
+
const cuts = [];
|
|
831
|
+
const pans = [];
|
|
832
|
+
let followState = null;
|
|
833
|
+
let spotState = null;
|
|
834
|
+
let spotGfx = null;
|
|
835
|
+
let spotScene = null;
|
|
836
|
+
const resolveRect = (scene, spec) => {
|
|
837
|
+
const cam = scene.cameras.main;
|
|
838
|
+
const z = cam.zoom || 1;
|
|
839
|
+
if (typeof spec !== "string") {
|
|
840
|
+
const w = spec.w ?? 48;
|
|
841
|
+
const h = spec.h ?? 48;
|
|
842
|
+
const pt = cam.worldToScreen(spec.x, spec.y);
|
|
843
|
+
return {
|
|
844
|
+
wx: spec.x,
|
|
845
|
+
wy: spec.y,
|
|
846
|
+
sx: pt.x - w * z * .5,
|
|
847
|
+
sy: pt.y - h * z * .5,
|
|
848
|
+
sw: w * z,
|
|
849
|
+
sh: h * z
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
let foundNode = null;
|
|
853
|
+
let foundWx = 0;
|
|
854
|
+
let foundWy = 0;
|
|
855
|
+
const walk = (list, px, py) => {
|
|
856
|
+
for (let i = 0; i < list.length; i++) {
|
|
857
|
+
const o = list[i];
|
|
858
|
+
if (!o || !o.active) continue;
|
|
859
|
+
const wx = px + (o.x || 0);
|
|
860
|
+
const wy = py + (o.y || 0);
|
|
861
|
+
if (o.trackId === spec) {
|
|
862
|
+
foundNode = o;
|
|
863
|
+
foundWx = wx;
|
|
864
|
+
foundWy = wy;
|
|
865
|
+
return true;
|
|
866
|
+
}
|
|
867
|
+
if (o.type === "Container" && Array.isArray(o.list)) {
|
|
868
|
+
if (walk(o.list, wx, wy)) return true;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
return false;
|
|
872
|
+
};
|
|
873
|
+
if (walk(scene.children.list, 0, 0) && foundNode) {
|
|
874
|
+
const dw = Math.max(8, Math.abs(foundNode.displayWidth || foundNode.width || 32));
|
|
875
|
+
const dh = Math.max(8, Math.abs(foundNode.displayHeight || foundNode.height || 32));
|
|
876
|
+
const ox = (foundNode.displayOriginX ?? 0) * Math.abs(foundNode.scaleX ?? 1);
|
|
877
|
+
const oy = (foundNode.displayOriginY ?? 0) * Math.abs(foundNode.scaleY ?? 1);
|
|
878
|
+
const left = foundWx - ox;
|
|
879
|
+
const top = foundWy - oy;
|
|
880
|
+
const cx = left + dw * .5;
|
|
881
|
+
const cy = top + dh * .5;
|
|
882
|
+
const sfx = foundNode.scrollFactorX ?? 1;
|
|
883
|
+
const sfy = foundNode.scrollFactorY ?? 1;
|
|
884
|
+
if (sfx === 0 && sfy === 0) {
|
|
885
|
+
const worldPt = cam.screenToWorld(cx, cy);
|
|
886
|
+
return {
|
|
887
|
+
wx: worldPt.x,
|
|
888
|
+
wy: worldPt.y,
|
|
889
|
+
sx: left,
|
|
890
|
+
sy: top,
|
|
891
|
+
sw: dw,
|
|
892
|
+
sh: dh
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
const scrTl = cam.worldToScreen(left, top);
|
|
896
|
+
return {
|
|
897
|
+
wx: cx,
|
|
898
|
+
wy: cy,
|
|
899
|
+
sx: scrTl.x,
|
|
900
|
+
sy: scrTl.y,
|
|
901
|
+
sw: dw * z,
|
|
902
|
+
sh: dh * z
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
const dg = buildSceneDigest(scene, options.digestOptions);
|
|
906
|
+
for (let i = 0; i < dg.nodes.length; i++) {
|
|
907
|
+
const n = dg.nodes[i];
|
|
908
|
+
if (n.trackId === spec) {
|
|
909
|
+
const [bx, by, bw, bh] = n.bounds;
|
|
910
|
+
const cx = bx + bw * .5;
|
|
911
|
+
const cy = by + bh * .5;
|
|
912
|
+
const tl = cam.worldToScreen(bx, by);
|
|
913
|
+
return {
|
|
914
|
+
wx: cx,
|
|
915
|
+
wy: cy,
|
|
916
|
+
sx: tl.x,
|
|
917
|
+
sy: tl.y,
|
|
918
|
+
sw: Math.max(8, bw * z),
|
|
919
|
+
sh: Math.max(8, bh * z)
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
return null;
|
|
924
|
+
};
|
|
925
|
+
const applyInstantCut = (scene, target, zoom) => {
|
|
926
|
+
const cam = scene.cameras.main;
|
|
927
|
+
if (zoom !== void 0 && zoom > 0) cam.setZoom(zoom);
|
|
928
|
+
const rect = resolveRect(scene, target);
|
|
929
|
+
if (rect) cam.centerOn(rect.wx, rect.wy);
|
|
930
|
+
};
|
|
931
|
+
const director = {
|
|
932
|
+
id,
|
|
933
|
+
setup(kernel) {
|
|
934
|
+
hostKernel = kernel;
|
|
935
|
+
return () => {
|
|
936
|
+
hostKernel = null;
|
|
937
|
+
};
|
|
938
|
+
},
|
|
939
|
+
update(scene, _timeMs, deltaMs) {
|
|
940
|
+
const simTimeMs = scene.game.clock.simTimeMs;
|
|
941
|
+
const cam = scene.cameras.main;
|
|
942
|
+
for (let i = 0; i < cuts.length; i++) {
|
|
943
|
+
const c = cuts[i];
|
|
944
|
+
if (!c.fired && simTimeMs >= c.atMs) {
|
|
945
|
+
c.fired = true;
|
|
946
|
+
followState = null;
|
|
947
|
+
applyInstantCut(scene, c.target, c.zoom);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
for (let i = 0; i < pans.length; i++) {
|
|
951
|
+
const p = pans[i];
|
|
952
|
+
if (p.finished) continue;
|
|
953
|
+
const startAt = p.startMs ?? simTimeMs;
|
|
954
|
+
if (p.startMs === null) p.startMs = startAt;
|
|
955
|
+
if (simTimeMs < startAt) continue;
|
|
956
|
+
if (!p.started) {
|
|
957
|
+
p.started = true;
|
|
958
|
+
followState = null;
|
|
959
|
+
cam.syncMetrics();
|
|
960
|
+
p.fromX = cam.worldView.x + cam.worldView.width * .5;
|
|
961
|
+
p.fromY = cam.worldView.y + cam.worldView.height * .5;
|
|
962
|
+
p.fromZoom = cam.zoom || 1;
|
|
963
|
+
}
|
|
964
|
+
const rect = resolveRect(scene, p.target);
|
|
965
|
+
const toX = rect ? rect.wx : p.fromX;
|
|
966
|
+
const toY = rect ? rect.wy : p.fromY;
|
|
967
|
+
const toZ = p.toZoom !== void 0 && p.toZoom > 0 ? p.toZoom : p.fromZoom;
|
|
968
|
+
const rawT = p.durationMs <= 0 ? 1 : Math.min(1, (simTimeMs - startAt) / p.durationMs);
|
|
969
|
+
const e = p.easing(rawT);
|
|
970
|
+
cam.setZoom(p.fromZoom + (toZ - p.fromZoom) * e);
|
|
971
|
+
cam.centerOn(p.fromX + (toX - p.fromX) * e, p.fromY + (toY - p.fromY) * e);
|
|
972
|
+
if (rawT >= 1) p.finished = true;
|
|
973
|
+
}
|
|
974
|
+
if (followState) {
|
|
975
|
+
const rect = resolveRect(scene, followState.target);
|
|
976
|
+
if (rect) {
|
|
977
|
+
if (followState.zoom !== void 0 && followState.zoom > 0) {
|
|
978
|
+
const zAlpha = 1 - Math.pow(1 - followState.lerp, Math.max(1, deltaMs / 16.6667));
|
|
979
|
+
cam.setZoom(cam.zoom + (followState.zoom - cam.zoom) * zAlpha);
|
|
980
|
+
}
|
|
981
|
+
cam.syncMetrics();
|
|
982
|
+
const curX = cam.worldView.x + cam.worldView.width * .5;
|
|
983
|
+
const curY = cam.worldView.y + cam.worldView.height * .5;
|
|
984
|
+
const alpha = 1 - Math.pow(1 - followState.lerp, Math.max(1, deltaMs / 16.6667));
|
|
985
|
+
cam.centerOn(curX + (rect.wx - curX) * alpha, curY + (rect.wy - curY) * alpha);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
const activeSpot = spotState && (spotState.startMs === null || simTimeMs >= spotState.startMs) && (spotState.endMs === null || simTimeMs < spotState.endMs) ? spotState : null;
|
|
989
|
+
if (!activeSpot) {
|
|
990
|
+
if (spotGfx && spotGfx.active) {
|
|
991
|
+
spotGfx.clear();
|
|
992
|
+
spotGfx.setVisible(false);
|
|
993
|
+
}
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
const rect = resolveRect(scene, activeSpot.target);
|
|
997
|
+
if (!rect) return;
|
|
998
|
+
if (!spotGfx || spotScene !== scene || !spotGfx.active) {
|
|
999
|
+
spotScene = scene;
|
|
1000
|
+
spotGfx = scene.add.graphics();
|
|
1001
|
+
spotGfx.setDepth(999999e3);
|
|
1002
|
+
spotGfx.setScrollFactor(0, 0);
|
|
1003
|
+
spotGfx.trackId = "stage.camera-spotlight";
|
|
1004
|
+
spotGfx.role = "presentation";
|
|
1005
|
+
}
|
|
1006
|
+
spotGfx.setVisible(true);
|
|
1007
|
+
spotGfx.clear();
|
|
1008
|
+
const vw = cam.width;
|
|
1009
|
+
const vh = cam.height;
|
|
1010
|
+
const pad = activeSpot.padding;
|
|
1011
|
+
const hx = Math.max(0, Math.round(rect.sx - pad));
|
|
1012
|
+
const hy = Math.max(0, Math.round(rect.sy - pad));
|
|
1013
|
+
const hr = Math.min(vw, Math.round(rect.sx + rect.sw + pad));
|
|
1014
|
+
const hb = Math.min(vh, Math.round(rect.sy + rect.sh + pad));
|
|
1015
|
+
const hw = Math.max(0, hr - hx);
|
|
1016
|
+
const hh = Math.max(0, hb - hy);
|
|
1017
|
+
spotGfx.fillStyle(activeSpot.dimColor, activeSpot.dimAlpha);
|
|
1018
|
+
if (hy > 0) spotGfx.fillRect(0, 0, vw, hy);
|
|
1019
|
+
if (hb < vh) spotGfx.fillRect(0, hb, vw, vh - hb);
|
|
1020
|
+
if (hx > 0 && hh > 0) spotGfx.fillRect(0, hy, hx, hh);
|
|
1021
|
+
if (hr < vw && hh > 0) spotGfx.fillRect(hr, hy, vw - hr, hh);
|
|
1022
|
+
if (activeSpot.borderWidth > 0 && hw > 0 && hh > 0) {
|
|
1023
|
+
spotGfx.lineStyle(activeSpot.borderWidth, activeSpot.borderColor, .95);
|
|
1024
|
+
spotGfx.strokeRect(hx, hy, hw, hh);
|
|
1025
|
+
}
|
|
1026
|
+
},
|
|
1027
|
+
digest() {
|
|
1028
|
+
const cam = (hostKernel?.game.scene.scenes[0])?.cameras.main;
|
|
1029
|
+
return {
|
|
1030
|
+
zoom: cam ? +cam.zoom.toFixed(3) : 1,
|
|
1031
|
+
scrollX: cam ? Math.round(cam.scrollX) : 0,
|
|
1032
|
+
scrollY: cam ? Math.round(cam.scrollY) : 0,
|
|
1033
|
+
following: Boolean(followState),
|
|
1034
|
+
spotlight: Boolean(spotState)
|
|
1035
|
+
};
|
|
1036
|
+
},
|
|
1037
|
+
dispose() {
|
|
1038
|
+
spotGfx?.destroy();
|
|
1039
|
+
spotGfx = null;
|
|
1040
|
+
spotScene = null;
|
|
1041
|
+
hostKernel = null;
|
|
1042
|
+
},
|
|
1043
|
+
cutTo(target, cutOpts = {}) {
|
|
1044
|
+
if (cutOpts.atMs !== void 0) cuts.push({
|
|
1045
|
+
target,
|
|
1046
|
+
atMs: Math.max(0, cutOpts.atMs),
|
|
1047
|
+
zoom: cutOpts.zoom,
|
|
1048
|
+
fired: false
|
|
1049
|
+
});
|
|
1050
|
+
else {
|
|
1051
|
+
followState = null;
|
|
1052
|
+
const sc = hostKernel?.game.scene.scenes[0];
|
|
1053
|
+
if (sc) applyInstantCut(sc, target, cutOpts.zoom);
|
|
1054
|
+
}
|
|
1055
|
+
return director;
|
|
1056
|
+
},
|
|
1057
|
+
panTo(target, panOpts = {}) {
|
|
1058
|
+
pans.push({
|
|
1059
|
+
target,
|
|
1060
|
+
startMs: panOpts.atMs !== void 0 ? Math.max(0, panOpts.atMs) : null,
|
|
1061
|
+
durationMs: Math.max(0, panOpts.durationMs ?? 450),
|
|
1062
|
+
toZoom: panOpts.zoom,
|
|
1063
|
+
easing: panOpts.easing ?? Easings.inOutCubic,
|
|
1064
|
+
started: false,
|
|
1065
|
+
finished: false,
|
|
1066
|
+
fromX: 0,
|
|
1067
|
+
fromY: 0,
|
|
1068
|
+
fromZoom: 1
|
|
1069
|
+
});
|
|
1070
|
+
return director;
|
|
1071
|
+
},
|
|
1072
|
+
follow(target, followOpts = {}) {
|
|
1073
|
+
followState = {
|
|
1074
|
+
target,
|
|
1075
|
+
lerp: Math.max(.01, Math.min(1, followOpts.lerp ?? .18)),
|
|
1076
|
+
zoom: followOpts.zoom
|
|
1077
|
+
};
|
|
1078
|
+
return director;
|
|
1079
|
+
},
|
|
1080
|
+
stopFollow() {
|
|
1081
|
+
followState = null;
|
|
1082
|
+
return director;
|
|
1083
|
+
},
|
|
1084
|
+
spotlight(target, spotOpts = {}) {
|
|
1085
|
+
const startMs = spotOpts.atMs !== void 0 ? Math.max(0, spotOpts.atMs) : null;
|
|
1086
|
+
const dur = spotOpts.durationMs && spotOpts.durationMs > 0 ? spotOpts.durationMs : null;
|
|
1087
|
+
const curNow = hostKernel?.game.clock.simTimeMs ?? 0;
|
|
1088
|
+
spotState = {
|
|
1089
|
+
target,
|
|
1090
|
+
padding: Math.max(0, spotOpts.padding ?? 14),
|
|
1091
|
+
dimColor: spotOpts.dimColor ?? 527122,
|
|
1092
|
+
dimAlpha: Math.max(0, Math.min(1, spotOpts.dimAlpha ?? .68)),
|
|
1093
|
+
borderColor: spotOpts.borderColor ?? 0xb6ef48,
|
|
1094
|
+
borderWidth: Math.max(0, spotOpts.borderWidth ?? 2.5),
|
|
1095
|
+
startMs,
|
|
1096
|
+
endMs: dur !== null ? (startMs ?? curNow) + dur : null
|
|
1097
|
+
};
|
|
1098
|
+
return director;
|
|
1099
|
+
},
|
|
1100
|
+
clearSpotlight() {
|
|
1101
|
+
spotState = null;
|
|
1102
|
+
if (spotGfx && spotGfx.active) {
|
|
1103
|
+
spotGfx.clear();
|
|
1104
|
+
spotGfx.setVisible(false);
|
|
1105
|
+
}
|
|
1106
|
+
return director;
|
|
1107
|
+
},
|
|
1108
|
+
reset() {
|
|
1109
|
+
cuts.length = 0;
|
|
1110
|
+
pans.length = 0;
|
|
1111
|
+
followState = null;
|
|
1112
|
+
director.clearSpotlight();
|
|
1113
|
+
const sc = hostKernel?.game.scene.scenes[0];
|
|
1114
|
+
if (sc) {
|
|
1115
|
+
const cam = sc.cameras.main;
|
|
1116
|
+
cam.setZoom(1);
|
|
1117
|
+
cam.setScroll(0, 0);
|
|
1118
|
+
}
|
|
1119
|
+
return director;
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
return director;
|
|
1123
|
+
}
|
|
1124
|
+
export { ActionMap, RollbackSession, ScriptScheduler, StageKernel, createCameraDirector, createInputRecorder, createInputReplay, createInputTimeline, createRollbackSession };
|
package/dist/lighting.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { An as Container, Kn as ImageObject, Ln as DisplayObject, Nn as CustomPassObject, Tn as StageRenderTarget, rr as SceneHostLike } from "./game-BrYrde7y.js";
|
|
2
2
|
export type DayPhase = 'day' | 'dusk' | 'night';
|
|
3
3
|
export interface DayNightConfig {
|
|
4
4
|
dayLengthMs?: number;
|
package/dist/projection.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { An as Container, Ln as DisplayObject, rr as SceneHostLike } from "./game-BrYrde7y.js";
|
|
2
2
|
export interface Camera25DConfig {
|
|
3
3
|
viewportWidth: number;
|
|
4
4
|
viewportHeight: number;
|
|
@@ -3200,6 +3200,37 @@ async function requestWebGpuDevice(canvas, options = {}) {
|
|
|
3200
3200
|
return null;
|
|
3201
3201
|
}
|
|
3202
3202
|
}
|
|
3203
|
+
const UNPREMUL_RECIP_LUT = /* @__PURE__ */ (() => {
|
|
3204
|
+
const lut = /* @__PURE__ */ new Uint32Array(256);
|
|
3205
|
+
for (let a = 1; a < 256; a++) lut[a] = Math.round(0xff0000 / a);
|
|
3206
|
+
return lut;
|
|
3207
|
+
})();
|
|
3208
|
+
/**
|
|
3209
|
+
* Convert premultiplied-alpha `RGBA8888` pixels (`rgb = straight * a / 255`) into W3C straight-alpha `RGBA8888`
|
|
3210
|
+
* in place using a 16.16 fixed-point reciprocal LUT, preventing `alpha^2` dark-halo fringing when exporting
|
|
3211
|
+
* transparent WebGPU / WebGL2 frames to PNG, `yuva420p` WebM, or `ffmpeg` `overlay` pipelines.
|
|
3212
|
+
*/
|
|
3213
|
+
function unpremultiplyRgbaInPlace(rgba) {
|
|
3214
|
+
const len = rgba.length & -4;
|
|
3215
|
+
for (let i = 0; i < len; i += 4) {
|
|
3216
|
+
const a = rgba[i + 3];
|
|
3217
|
+
if (a === 255) continue;
|
|
3218
|
+
if (a === 0) {
|
|
3219
|
+
rgba[i] = 0;
|
|
3220
|
+
rgba[i + 1] = 0;
|
|
3221
|
+
rgba[i + 2] = 0;
|
|
3222
|
+
continue;
|
|
3223
|
+
}
|
|
3224
|
+
const inv = UNPREMUL_RECIP_LUT[a];
|
|
3225
|
+
const r = rgba[i] * inv + 32768 >>> 16;
|
|
3226
|
+
const g = rgba[i + 1] * inv + 32768 >>> 16;
|
|
3227
|
+
const b = rgba[i + 2] * inv + 32768 >>> 16;
|
|
3228
|
+
rgba[i] = r > 255 ? 255 : r;
|
|
3229
|
+
rgba[i + 1] = g > 255 ? 255 : g;
|
|
3230
|
+
rgba[i + 2] = b > 255 ? 255 : b;
|
|
3231
|
+
}
|
|
3232
|
+
return rgba;
|
|
3233
|
+
}
|
|
3203
3234
|
const INITIAL_VERTS = 65536;
|
|
3204
3235
|
const INITIAL_INDICES = 98304;
|
|
3205
3236
|
const VERT_FLOATS = 6;
|
|
@@ -3457,8 +3488,10 @@ var RendererWebGpu = class extends EventEmitter {
|
|
|
3457
3488
|
device;
|
|
3458
3489
|
gpuContext;
|
|
3459
3490
|
format;
|
|
3491
|
+
transparent;
|
|
3460
3492
|
width;
|
|
3461
3493
|
height;
|
|
3494
|
+
lastPassTransparent = false;
|
|
3462
3495
|
offscreenTex = null;
|
|
3463
3496
|
offscreenView = null;
|
|
3464
3497
|
offscreenW = 0;
|
|
@@ -3538,6 +3571,8 @@ var RendererWebGpu = class extends EventEmitter {
|
|
|
3538
3571
|
const ctx = opts.context !== void 0 ? opts.context : canvas?.getContext?.("webgpu") ?? null;
|
|
3539
3572
|
const format = opts.format ?? (ctx ? "bgra8unorm" : "rgba8unorm");
|
|
3540
3573
|
this.format = format;
|
|
3574
|
+
this.transparent = Boolean(opts.transparent);
|
|
3575
|
+
this.lastPassTransparent = this.transparent;
|
|
3541
3576
|
this.gpuContext = ctx;
|
|
3542
3577
|
if (ctx) ctx.configure({
|
|
3543
3578
|
device: this.device,
|
|
@@ -4694,7 +4729,9 @@ var RendererWebGpu = class extends EventEmitter {
|
|
|
4694
4729
|
}
|
|
4695
4730
|
if (this.sdfCount > 0) this.device.queue.writeBuffer(this.sdfInstVbo, 0, this.sdfF32.subarray(0, this.sdfCount * SDF_FLOATS));
|
|
4696
4731
|
const bg = camera.backgroundColor;
|
|
4697
|
-
const
|
|
4732
|
+
const isTrans = Boolean(this.transparent || camera.transparent);
|
|
4733
|
+
if (recordMainStats) this.lastPassTransparent = isTrans;
|
|
4734
|
+
const clearColor = isTrans ? {
|
|
4698
4735
|
r: 0,
|
|
4699
4736
|
g: 0,
|
|
4700
4737
|
b: 0,
|
|
@@ -4834,15 +4871,18 @@ var RendererWebGpu = class extends EventEmitter {
|
|
|
4834
4871
|
readPixelsSync(out) {
|
|
4835
4872
|
if (typeof this.device._readBufferSync !== "function") throw new Error("RendererWebGpu.readPixelsSync: current GPUDevice only supports async mapAsync(); use await stage.toRgbaAsync() or stage.recordFrames() / stage.encodeVideo()");
|
|
4836
4873
|
const { buf, w, h, bytesPerRow, byteLen } = this.encodeCopyToStaging();
|
|
4874
|
+
let res;
|
|
4837
4875
|
if (bytesPerRow === w * 4 && this.format !== "bgra8unorm") {
|
|
4838
4876
|
const totalOut = w * h * 4;
|
|
4839
4877
|
const dst = out && out.byteLength >= totalOut ? out : new Uint8Array(totalOut);
|
|
4840
4878
|
this.device._readBufferSync(buf, dst, totalOut);
|
|
4841
|
-
|
|
4879
|
+
res = dst;
|
|
4880
|
+
} else {
|
|
4881
|
+
const raw = new Uint8Array(byteLen);
|
|
4882
|
+
this.device._readBufferSync(buf, raw, byteLen);
|
|
4883
|
+
res = this.unpackStagingBytes(raw, w, h, bytesPerRow, out);
|
|
4842
4884
|
}
|
|
4843
|
-
|
|
4844
|
-
this.device._readBufferSync(buf, raw, byteLen);
|
|
4845
|
-
return this.unpackStagingBytes(raw, w, h, bytesPerRow, out);
|
|
4885
|
+
return this.lastPassTransparent ? unpremultiplyRgbaInPlace(res) : res;
|
|
4846
4886
|
}
|
|
4847
4887
|
/**
|
|
4848
4888
|
* Asynchronously read rendered W3C `RGBA8888` pixels across ALL WebGPU backends
|
|
@@ -4854,7 +4894,8 @@ var RendererWebGpu = class extends EventEmitter {
|
|
|
4854
4894
|
await buf.mapAsync(GPUMapMode_READ, 0, byteLen);
|
|
4855
4895
|
try {
|
|
4856
4896
|
const mapped = new Uint8Array(buf.getMappedRange(0, byteLen));
|
|
4857
|
-
|
|
4897
|
+
const res = this.unpackStagingBytes(mapped, w, h, bytesPerRow, out);
|
|
4898
|
+
return this.lastPassTransparent ? unpremultiplyRgbaInPlace(res) : res;
|
|
4858
4899
|
} finally {
|
|
4859
4900
|
buf.unmap();
|
|
4860
4901
|
}
|
|
@@ -4978,4 +5019,4 @@ var RendererWebGpu = class extends EventEmitter {
|
|
|
4978
5019
|
} catch {}
|
|
4979
5020
|
}
|
|
4980
5021
|
};
|
|
4981
|
-
export {
|
|
5022
|
+
export { openWgpuNativeFfi as a, Camera as c, openDawnWebGpu as i, requestWebGpuDevice as n, requestHeadlessWebGpu as o, unpremultiplyRgbaInPlace as r, Renderer2D as s, RendererWebGpu as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { type HeadlessWebGpuBackend, type HeadlessWebGpuHandle, type HeadlessWebGpuOptions, type OpenDawnWebGpuOptions, type OpenWgpuNativeFfiOptions, RendererWebGpu, RendererWebGpuOptions, RequestWebGpuOptions, WebGpuBootstrapResult, WebGpuCanvasContextLike, WebGpuDeviceLike, openDawnWebGpu, openWgpuNativeFfi, requestHeadlessWebGpu, requestWebGpuDevice };
|
|
1
|
+
import { _n as openDawnWebGpu, an as RendererWebGpuOptions, cn as WebGpuCanvasContextLike, dn as unpremultiplyRgbaInPlace, fn as HeadlessWebGpuBackend, gn as OpenWgpuNativeFfiOptions, hn as OpenDawnWebGpuOptions, in as RendererWebGpu, ln as WebGpuDeviceLike, mn as HeadlessWebGpuOptions, on as RequestWebGpuOptions, pn as HeadlessWebGpuHandle, sn as WebGpuBootstrapResult, un as requestWebGpuDevice, vn as openWgpuNativeFfi, yn as requestHeadlessWebGpu } from "./game-BrYrde7y.js";
|
|
2
|
+
export { type HeadlessWebGpuBackend, type HeadlessWebGpuHandle, type HeadlessWebGpuOptions, type OpenDawnWebGpuOptions, type OpenWgpuNativeFfiOptions, RendererWebGpu, RendererWebGpuOptions, RequestWebGpuOptions, WebGpuBootstrapResult, WebGpuCanvasContextLike, WebGpuDeviceLike, openDawnWebGpu, openWgpuNativeFfi, requestHeadlessWebGpu, requestWebGpuDevice, unpremultiplyRgbaInPlace };
|
package/dist/renderer-webgpu.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as RendererWebGpu,
|
|
1
|
+
export { t as RendererWebGpu, i as openDawnWebGpu, a as openWgpuNativeFfi, o as requestHeadlessWebGpu, n as requestWebGpuDevice, r as unpremultiplyRgbaInPlace } from "./renderer-webgpu-B4AvHUEt.js";
|
package/dist/rig2d.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { T as BlendMode } from "./anims-BOvaKn6w.js";
|
|
2
|
-
import {
|
|
2
|
+
import { An as Container, Gn as Graphics, Kn as ImageObject, rr as SceneHostLike } from "./game-BrYrde7y.js";
|
|
3
3
|
export type RigCurveKind = 'linear' | 'step' | 'smoothstep' | 'outBack';
|
|
4
4
|
export interface RigBoneDef {
|
|
5
5
|
name: string;
|
package/dist/tilemap.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { At as
|
|
1
|
+
import { At as computeDualGridMask, Bt as valueNoise2D, Ct as MountChunkedTilemapOptions, Dt as TileChunk, Et as TileCellFlags, Ft as mountChunkedTilemap, It as packChunkKey, Lt as positiveMod, Mt as fbm2D, Nt as floorDiv, Ot as bakeDualGridTileset, Pt as hash2D, Rt as unpackChunkX, St as IslandBiomeConfig, Tt as SurvivalBiomes, _t as BakedDualGridAtlas, bt as ChunkedTilemapOptions, gt as BakeDualGridTilesetOptions, jt as createIslandBiomeGenerator, kt as computeBlob47Index, vt as ChunkGeneratorFn, wt as MountedChunkedTilemap, xt as DualGridLayerSpec, yt as ChunkedTilemap, zt as unpackChunkY } from "./game-BrYrde7y.js";
|
|
2
2
|
export { BakeDualGridTilesetOptions, BakedDualGridAtlas, ChunkGeneratorFn, ChunkedTilemap, ChunkedTilemapOptions, DualGridLayerSpec, IslandBiomeConfig, MountChunkedTilemapOptions, MountedChunkedTilemap, SurvivalBiomes, TileCellFlags, TileChunk, bakeDualGridTileset, computeBlob47Index, computeDualGridMask, createIslandBiomeGenerator, fbm2D, floorDiv, hash2D, mountChunkedTilemap, packChunkKey, positiveMod, unpackChunkX, unpackChunkY, valueNoise2D };
|
package/dist/trace.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Gt as SceneDigestOptions, Ht as SceneDigestActiveFocus, Jt as SceneDigestSurfaceEntry, Kt as SceneDigestOverlayStats, Qt as sanitizeTrackToken, Ut as SceneDigestEngineSandbox, Vt as SceneDigest, Wt as SceneDigestNode, Xt as SceneDigestSurfaces, Yt as SceneDigestSurfaceSource, Zt as buildSceneDigest, qt as SceneDigestSandbox } from "./game-BrYrde7y.js";
|
|
2
2
|
export { SceneDigest, SceneDigestActiveFocus, SceneDigestEngineSandbox, SceneDigestNode, SceneDigestOptions, SceneDigestOverlayStats, SceneDigestSandbox, SceneDigestSurfaceEntry, SceneDigestSurfaceSource, SceneDigestSurfaces, buildSceneDigest, sanitizeTrackToken };
|
package/dist/world.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as RecipeDef, J as FrozenWorldCatalog, Q as ItemStack, X as ItemDef, Y as InventoryContainer, Z as ItemRegistry, at as WorkstationSnapshot, ct as WorldDeltaSnapshot, dt as captureWorldDelta, et as RecipeRegistry, ft as createWorldCatalogRuntime, ht as encodeWorldDeltaBytes, it as WorkstationScheduler, lt as WorldEntityRecord, mt as defineWorldCatalog, nt as WorkstationInstance, ot as WorldCatalogRuntime, pt as decodeWorldDeltaBytes, q as CatalogReloadDiff, rt as WorkstationJob, st as WorldCatalogSpec, tt as TileCellDelta, ut as applyWorldDelta } from "./game-BrYrde7y.js";
|
|
2
2
|
export { CatalogReloadDiff, FrozenWorldCatalog, InventoryContainer, ItemDef, ItemRegistry, ItemStack, RecipeDef, RecipeRegistry, TileCellDelta, WorkstationInstance, WorkstationJob, WorkstationScheduler, WorkstationSnapshot, WorldCatalogRuntime, WorldCatalogSpec, WorldDeltaSnapshot, WorldEntityRecord, applyWorldDelta, captureWorldDelta, createWorldCatalogRuntime, decodeWorldDeltaBytes, defineWorldCatalog, encodeWorldDeltaBytes };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holtjs/stage",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Zero-dependency TypeScript
|
|
3
|
+
"version": "0.17.0",
|
|
4
|
+
"description": "Zero-dependency TypeScript 2D & 2.5D game and motion-compositing engine for WebGPU/WebGL2/Canvas2D, Bun, and Node.js with GPU SDF UI, deterministic coroutines, alpha-overlay export, and FFmpeg video compositing.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Botiverse, Inc.",
|
|
7
7
|
"homepage": "https://github.com/botiverse-play/stage#readme",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@holtjs/stage` Subpath API Quick Reference
|
|
2
2
|
|
|
3
|
-
All symbols verified against `src/*.ts` (`@holtjs/stage@0.
|
|
3
|
+
All symbols verified against `src/*.ts` (`@holtjs/stage@0.17.0`, 22 subpaths).
|
|
4
4
|
|
|
5
5
|
## `@holtjs/stage` (~71.3 kB gz · Core Engine Barrel)
|
|
6
6
|
- **Bootstrap & Lifecycle**: `Stage` / `Stage2D` (namespaces), `AUTO`, `WEBGPU`, `WEBGL`, `CANVAS`, `Scale` (`NONE`, `FIT`, `RESIZE`), `Scenes`, `Game` (`.stepSimOnly()`, `.kernel`, `.anims`), `Scene` (`.update()` simulation + `.preRender()` presentation, `.anims`), `SceneManager`, `ScaleManager` (`.fitToContainer()`), `GameLoop`, `EngineClock`, `LoaderPlugin` (`.atlas()`), `JsonCache`, `GameObjectFactory` (`scene.add.sprite`, `shapeBatch`, `instancedBatch`, `customPass`, `panel`, `blitter`, etc.), `AnimationManager` (`.create()`, `.createFromAtlas()`, `.generateFrameNames()`, `.generateFrameNumbers()`)
|
|
@@ -23,15 +23,16 @@ All symbols verified against `src/*.ts` (`@holtjs/stage@0.16.0`, 22 subpaths).
|
|
|
23
23
|
- `StageKernel` (`game.kernel`): `.use(plugin)`, `.remove(id)`, `.get(id)`, `.addInputProvider(p)`, `.actions`, `.digest()`
|
|
24
24
|
- `ActionMap`: `.bind(action, codes)`, `.unbind(action)`, `.isDown(action)`, `.justPressed(action)`, `.justReleased(action)`, `.axis(negAction, posAction)`
|
|
25
25
|
- `createInputTimeline(opts?)`: `.moveTo()`, `.click(trackIdOrPt, atMs, opts?)`, `.drag()`, `.pressKey()`, `.typeText()` (with optional rendered virtual cursor & click ripples via `showCursor: true`)
|
|
26
|
-
- `createInputRecorder(id?)`, `createInputReplay(entries, id?)`, `RollbackSession` (`.fromSoaWorld()`, `.advance()`, `.applyAuthoritativeInput()`, `.rewindTo()`, `.checksumAt()`), `createRollbackSession(opts)`
|
|
27
|
-
- Types: `StagePlugin`, `InputProvider`, `StageInputEvent`, `InputTargetSpec`, `TimelineClickOptions`, `TimelineDragOptions`, `TimelineKeyOptions`, `InputTimelineOptions`, `InputTimelinePlugin`, `InputRecorderPlugin`, `RecordedInputEntry`, `RollbackStateCodec`, `RollbackSessionOptions`, `RollbackResult`, `RollbackStats`
|
|
26
|
+
- `createInputRecorder(id?)`, `createInputReplay(entries, id?)`, `createCameraDirector(opts?)` (`.cutTo()`, `.panTo()`, `.follow()`, `.spotlight()`, `.clearSpotlight()`), `RollbackSession` (`.fromSoaWorld()`, `.advance()`, `.applyAuthoritativeInput()`, `.rewindTo()`, `.checksumAt()`), `createRollbackSession(opts)`
|
|
27
|
+
- Types: `StagePlugin`, `InputProvider`, `StageInputEvent`, `InputTargetSpec`, `TimelineClickOptions`, `TimelineDragOptions`, `TimelineKeyOptions`, `InputTimelineOptions`, `InputTimelinePlugin`, `InputRecorderPlugin`, `RecordedInputEntry`, `CameraDirectorPlugin`, `CameraDirectorTarget`, `CameraPanOptions`, `CameraSpotlightOptions`, `RollbackStateCodec`, `RollbackSessionOptions`, `RollbackResult`, `RollbackStats`
|
|
28
28
|
|
|
29
|
-
## `@holtjs/stage/headless` (~
|
|
30
|
-
- `createHeadlessStageAsync(opts)` (`openHeadlessStage`), `createHeadlessStage(opts)`: `.step()`, `.stepToMs()`, `.stepToFrame()`, `.fastForward(frames)`, `.pointerDown/Move/Up()`, `.keyDown/Up()`, `.toRgba()`, `.toRgbaAsync()`, `.toPng()`, `.toPngAsync()`, `.encodeVideo(opts)
|
|
29
|
+
## `@holtjs/stage/headless` (~44 kB gz · Headless WebGPU, Alpha Overlays, FFmpeg Compositor & Batch Rollouts)
|
|
30
|
+
- `createHeadlessStageAsync(opts)` (`openHeadlessStage`), `createHeadlessStage(opts)`: `.step()`, `.stepToMs()`, `.stepToFrame()`, `.fastForward(frames)`, `.pointerDown/Move/Up()`, `.keyDown/Up()`, `.toRgba()`, `.toRgbaAsync()`, `.toPng()`, `.toPngAsync()`, `.encodeVideo(opts)` (`alpha?: boolean`), `.digest()`, `.recordFrames({ ..., reuseFrameBuffer? })`
|
|
31
|
+
- `composeVideoLayers(opts)`, `buildFfmpegCompositeArgs(opts)`, `unpremultiplyRgbaInPlace(rgba)`
|
|
31
32
|
- `runHeadlessRollouts(opts)` -> `HeadlessRolloutReport` (`summary` with `min / max / mean / p50 / p95 / sum`, `ticksPerSecond`, `results`)
|
|
32
33
|
- `renderStoryboard(stage, opts)` -> `{ png, width, height, digests }`
|
|
33
34
|
- `createAudioTimeline(opts?)`: `.addAtMs()`, `.addAtFrame()`, `.toStereoPcm16()`, `.toWav()`
|
|
34
|
-
- Types: `HeadlessCanvasLike`, `CreateHeadlessCanvas`, `HeadlessStageOptions`, `AsyncHeadlessStageOptions`, `HeadlessRecordedFrame`, `RecordFramesOptions`, `HeadlessStage`, `StoryboardOptions`, `StoryboardResult`, `AudioCueOptions`, `AudioTimelineOptions`, `AudioTimeline`, `EncodeVideoWithFfmpegOptions`, `EncodeVideoResult`, `HeadlessRolloutOptions`, `HeadlessRolloutReport`, `MetricSummaryStats`
|
|
35
|
+
- Types: `HeadlessCanvasLike`, `CreateHeadlessCanvas`, `HeadlessStageOptions`, `AsyncHeadlessStageOptions`, `HeadlessRecordedFrame`, `RecordFramesOptions`, `HeadlessStage`, `StoryboardOptions`, `StoryboardResult`, `AudioCueOptions`, `AudioTimelineOptions`, `AudioTimeline`, `EncodeVideoWithFfmpegOptions`, `EncodeVideoResult`, `ComposeVideoLayersOptions`, `ComposeVideoLayersResult`, `CompositeVideoCut`, `CompositeOverlayLayer`, `CompositeVoiceoverSegment`, `HeadlessRolloutOptions`, `HeadlessRolloutReport`, `MetricSummaryStats`
|
|
35
36
|
|
|
36
37
|
## `@holtjs/stage/rig2d` (~5.7 kB gz · zero DOM)
|
|
37
38
|
- Skeleton & Mixer: `defineRig2DSkeleton(def)`, `Rig2DInstance` (`.play(clip, opts?)`, `.playOverlay(clip, { maskBones?, loop? })`, `.clearOverlay()`, `.setAttachment(slot, attachment)`, `.applySkin(skinNameOrMap)`, `.setSlotTint()`, `.setBoneManualOffset()`, `.onEvent(fn)`, `.step(deltaMs)`, `.getBoneWorldTransform(bone, out?)`)
|