@holtjs/stage 0.11.0 → 0.12.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 +13 -0
- package/dist/{game-COsuqGzC.d.ts → game-CT_WCPjJ.d.ts} +95 -3
- package/dist/{game-2dS3Qsrn.js → game-DZoRjZNH.js} +1 -1
- package/dist/headless.d.ts +14 -3
- package/dist/headless.js +64 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/joystick.d.ts +1 -1
- package/dist/kernel.d.ts +1 -1
- package/dist/lighting.d.ts +1 -1
- package/dist/projection.d.ts +1 -1
- package/dist/{renderer-webgpu-CHJxmCvR.js → renderer-webgpu-B8vktrUk.js} +1710 -22
- 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 +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,19 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.12.0] - 2026-12-04
|
|
10
|
+
|
|
11
|
+
### Added & Fixed
|
|
12
|
+
- **Isomorphic Zero-Dependency Headless WebGPU + Native C FFI Bridge (`requestHeadlessWebGpu`, `openWgpuNativeFfi`, `openDawnWebGpu`, `@holtjs/stage/webgpu` & `@holtjs/stage/headless`)**:
|
|
13
|
+
- Added `src/webgpu-headless.ts` with zero static runtime-specific imports (safe across Browser, Vite, Node.js, Bun, and Deno with zero forced npm dependencies):
|
|
14
|
+
1. **Bun `bun:ffi` + `wgpu-native` (`libwgpu_native.so`/`.dylib`/`.dll`)**: Direct `dlopen` + cached in-memory TinyCC struct-by-value C bridge (`wgpu-bun-ffi`) with single-call synchronous staging readback (`wgpuBufferGetConstMappedRange`).
|
|
15
|
+
2. **Node.js `koffi` + `wgpu-native` (`libwgpu_native.so`/`.dylib`/`.dll`)**: Prebuilt zero-compiler N-API C FFI (`wgpu-node-koffi`) sharing 100% of the 64-bit `webgpu.h` C ABI descriptor packers (`3,686,400 / 3,686,400` byte-identical RGBA parity with `bun:ffi` at 720p).
|
|
16
|
+
3. **Node.js & Bun Google Dawn (`webgpu` N-API)**: Full async `mapAsync` Headless WebGPU support (`dawn`) with `Instance`/`Adapter` lifetime pinning, plus Deno / Browser `navigator.gpu` (`navigator`).
|
|
17
|
+
- **Offscreen `RendererWebGpu` & Sync/Async `HeadlessStage` GPU Video Pipeline (`src/renderer-webgpu.ts`, `src/headless.ts`)**:
|
|
18
|
+
- `RendererWebGpu` now runs headlessly with `context: null`, rendering into an auto-resized offscreen `GPUTexture` with `256`-byte row-aligned staging readback (`readPixelsSync` & `readPixelsAsync`), BGRA/RGBA unpacking, premultiplied `queue.writeTexture` canvas/atlas uploads, `Frame.empty` skipping, and `4`-byte aligned `Uint16Array` index uploads.
|
|
19
|
+
- Wired `gpuDevice` and `gpuFormat` into `createHeadlessStage(...)`, adding `toRgbaAsync()`, `toRgbaIntoAsync()`, and `toPngAsync()` alongside synchronous `toRgba()` / `toPng()` / `renderStoryboard()` (for `wgpu-native` FFI) and streaming WebGPU frames directly into `stage.encodeVideo(...)` (`ffmpeg -f rawvideo -pix_fmt rgba`).
|
|
20
|
+
- Fixed WGSL fragment uniformity in `WGSL_BATCH_SRC` (`textureSample` hoisted before `in.mode` branching) for strict Google Dawn / Chrome Tint compliance.
|
|
21
|
+
|
|
9
22
|
## [0.11.0] - 2026-12-04
|
|
10
23
|
|
|
11
24
|
### Added
|
|
@@ -1259,10 +1259,76 @@ declare class Renderer2D extends EventEmitter {
|
|
|
1259
1259
|
render(displayList: DisplayList, camera: Camera): void;
|
|
1260
1260
|
destroy(): void;
|
|
1261
1261
|
}
|
|
1262
|
+
type HeadlessWebGpuBackend = 'wgpu-bun-ffi' | 'wgpu-node-koffi' | 'dawn' | 'navigator';
|
|
1263
|
+
interface HeadlessWebGpuHandle {
|
|
1264
|
+
readonly backend: HeadlessWebGpuBackend;
|
|
1265
|
+
readonly device: WebGpuDeviceLike;
|
|
1266
|
+
readonly format: 'rgba8unorm' | 'bgra8unorm';
|
|
1267
|
+
/** `true` when `stage.toRgba()` / `renderer.readPixelsSync()` works synchronously without `await` (`wgpu-native` FFI). */
|
|
1268
|
+
readonly supportsSyncReadback: boolean;
|
|
1269
|
+
/** Release native `GPUDevice` / `WGPUInstance` resources. */
|
|
1270
|
+
destroy(): void;
|
|
1271
|
+
}
|
|
1272
|
+
interface OpenWgpuNativeFfiOptions {
|
|
1273
|
+
/**
|
|
1274
|
+
* Path to `libwgpu_native.so` (Linux), `libwgpu_native.dylib` (macOS), or `wgpu_native.dll` (Windows).
|
|
1275
|
+
* Defaults to `process.env.STAGE_WGPU_LIB` or `process.env.WGPU_NATIVE_LIB`, then standard system/local paths.
|
|
1276
|
+
*/
|
|
1277
|
+
readonly libPath?: string;
|
|
1278
|
+
/** FFI engine selection (`'auto'` uses built-in `'bun:ffi'` on Bun and `'koffi'` on Node.js). */
|
|
1279
|
+
readonly runtime?: 'auto' | 'bun' | 'koffi';
|
|
1280
|
+
/** Optional pre-loaded `koffi` module instance on Node.js. */
|
|
1281
|
+
readonly koffiModule?: any;
|
|
1282
|
+
/** Adapter power profile (default `'high-performance'`). */
|
|
1283
|
+
readonly powerPreference?: 'low-power' | 'high-performance';
|
|
1284
|
+
}
|
|
1285
|
+
interface OpenDawnWebGpuOptions {
|
|
1286
|
+
/** Optional pre-loaded `'webgpu'` (Google Dawn N-API) module. */
|
|
1287
|
+
readonly dawnModule?: any;
|
|
1288
|
+
/** Optional Dawn instance flags passed to `dawn.create([...])` (default `[]`). */
|
|
1289
|
+
readonly dawnFlags?: readonly string[];
|
|
1290
|
+
/** Adapter power profile (default `'high-performance'`). */
|
|
1291
|
+
readonly powerPreference?: 'low-power' | 'high-performance';
|
|
1292
|
+
}
|
|
1293
|
+
interface HeadlessWebGpuOptions extends OpenWgpuNativeFfiOptions, OpenDawnWebGpuOptions {
|
|
1294
|
+
/** Backend discovery strategy (`'auto'` tries `wgpu-native` FFI -> Google Dawn `'webgpu'` -> `navigator.gpu`). */
|
|
1295
|
+
readonly backend?: 'auto' | 'ffi' | 'dawn' | 'navigator';
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Open a synchronous native Headless WebGPU `GPUDevice` via `wgpu-native` (`libwgpu_native.so`/`.dylib`/`.dll`)
|
|
1299
|
+
* using Bun's built-in `bun:ffi` or Node.js's prebuilt `koffi` C FFI.
|
|
1300
|
+
* Returns `null` cleanly if `libwgpu_native` or the FFI driver is unavailable.
|
|
1301
|
+
*/
|
|
1302
|
+
declare function openWgpuNativeFfi(options?: OpenWgpuNativeFfiOptions): Promise<HeadlessWebGpuHandle | null>;
|
|
1303
|
+
/**
|
|
1304
|
+
* Open a native Headless WebGPU `GPUDevice` via Google Dawn's prebuilt N-API `'webgpu'` package
|
|
1305
|
+
* (works identically in both Node.js and Bun!).
|
|
1306
|
+
* Returns `null` cleanly if `'webgpu'` is not installed or no Vulkan/Metal/D3D12 adapter is available.
|
|
1307
|
+
*/
|
|
1308
|
+
declare function openDawnWebGpu(options?: OpenDawnWebGpuOptions): Promise<HeadlessWebGpuHandle | null>;
|
|
1309
|
+
/**
|
|
1310
|
+
* Acquire an isomorphic Headless WebGPU device across Bun (`bun:ffi` + `wgpu-native` or Dawn `webgpu`),
|
|
1311
|
+
* Node.js (`koffi` + `wgpu-native` or Dawn `webgpu`), and Deno / Browser (`navigator.gpu`).
|
|
1312
|
+
* Never throws when native drivers are absent — returns `null` so callers can cleanly fall back to Canvas2D.
|
|
1313
|
+
*/
|
|
1314
|
+
declare function requestHeadlessWebGpu(options?: HeadlessWebGpuOptions): Promise<HeadlessWebGpuHandle | null>;
|
|
1262
1315
|
interface WebGpuDeviceLike {
|
|
1263
1316
|
readonly queue: {
|
|
1264
1317
|
writeBuffer(buffer: any, bufferOffset: number, data: BufferSource, dataOffset?: number, size?: number): void;
|
|
1265
|
-
copyExternalImageToTexture(source: any, destination: any, copySize: any): void;
|
|
1318
|
+
copyExternalImageToTexture?(source: any, destination: any, copySize: any): void;
|
|
1319
|
+
writeTexture?(destination: {
|
|
1320
|
+
texture: any;
|
|
1321
|
+
mipLevel?: number;
|
|
1322
|
+
origin?: [number, number, number];
|
|
1323
|
+
}, data: BufferSource, dataLayout: {
|
|
1324
|
+
offset?: number;
|
|
1325
|
+
bytesPerRow: number;
|
|
1326
|
+
rowsPerImage?: number;
|
|
1327
|
+
}, size: [number, number, number] | {
|
|
1328
|
+
width: number;
|
|
1329
|
+
height: number;
|
|
1330
|
+
depthOrArrayLayers?: number;
|
|
1331
|
+
}): void;
|
|
1266
1332
|
submit(commandBuffers: any[]): void;
|
|
1267
1333
|
};
|
|
1268
1334
|
createShaderModule(descriptor: {
|
|
@@ -1280,6 +1346,8 @@ interface WebGpuDeviceLike {
|
|
|
1280
1346
|
createRenderPipeline(descriptor: any): any;
|
|
1281
1347
|
createBindGroup(descriptor: any): any;
|
|
1282
1348
|
createCommandEncoder(descriptor?: any): any;
|
|
1349
|
+
/** Optional synchronous staging-buffer read hook provided by `wgpu-native` C FFI (`bun:ffi` / `koffi`). */
|
|
1350
|
+
_readBufferSync?(buffer: any, dst: Uint8Array, byteLength: number): boolean;
|
|
1283
1351
|
destroy?(): void;
|
|
1284
1352
|
}
|
|
1285
1353
|
interface WebGpuCanvasContextLike {
|
|
@@ -1322,10 +1390,20 @@ declare class RendererWebGpu extends EventEmitter {
|
|
|
1322
1390
|
readonly maxTextures = 16;
|
|
1323
1391
|
readonly canvas: HTMLCanvasElement;
|
|
1324
1392
|
readonly device: WebGpuDeviceLike;
|
|
1325
|
-
readonly gpuContext: WebGpuCanvasContextLike;
|
|
1393
|
+
readonly gpuContext: WebGpuCanvasContextLike | null;
|
|
1326
1394
|
readonly format: string;
|
|
1327
1395
|
width: number;
|
|
1328
1396
|
height: number;
|
|
1397
|
+
private offscreenTex;
|
|
1398
|
+
private offscreenView;
|
|
1399
|
+
private offscreenW;
|
|
1400
|
+
private offscreenH;
|
|
1401
|
+
private readbackBuf;
|
|
1402
|
+
private readbackCap;
|
|
1403
|
+
private readbackBytesPerRow;
|
|
1404
|
+
private uploadStaging;
|
|
1405
|
+
private uploadScratchCanvas;
|
|
1406
|
+
private uploadScratchCtx;
|
|
1329
1407
|
private readonly globalsBuf;
|
|
1330
1408
|
private readonly vbo;
|
|
1331
1409
|
private readonly ibo;
|
|
@@ -1365,6 +1443,8 @@ declare class RendererWebGpu extends EventEmitter {
|
|
|
1365
1443
|
private makeBatchBindGroup;
|
|
1366
1444
|
stats(): RendererStats;
|
|
1367
1445
|
resize(width: number, height: number): void;
|
|
1446
|
+
private ensureOffscreenTarget;
|
|
1447
|
+
private extractAndUploadTexture;
|
|
1368
1448
|
private ensureGpuTexture;
|
|
1369
1449
|
private ensureSourceBindGroup;
|
|
1370
1450
|
private currentScissor;
|
|
@@ -1379,6 +1459,18 @@ declare class RendererWebGpu extends EventEmitter {
|
|
|
1379
1459
|
private renderGraphics;
|
|
1380
1460
|
private renderNode;
|
|
1381
1461
|
render(displayList: DisplayList, camera: Camera): void;
|
|
1462
|
+
private encodeCopyToStaging;
|
|
1463
|
+
private unpackStagingBytes;
|
|
1464
|
+
/**
|
|
1465
|
+
* Synchronously read rendered W3C `RGBA8888` pixels when backed by a synchronous native WebGPU device
|
|
1466
|
+
* (`wgpu-native` C FFI via `bun:ffi` or Node `koffi`).
|
|
1467
|
+
*/
|
|
1468
|
+
readPixelsSync(out?: Uint8Array): Uint8Array;
|
|
1469
|
+
/**
|
|
1470
|
+
* Asynchronously read rendered W3C `RGBA8888` pixels across ALL WebGPU backends
|
|
1471
|
+
* (`wgpu-native` FFI, Google Dawn `webgpu`, Deno `navigator.gpu`, and Browser WebGPU).
|
|
1472
|
+
*/
|
|
1473
|
+
readPixelsAsync(out?: Uint8Array): Promise<Uint8Array>;
|
|
1382
1474
|
/** Create an offscreen render target backed by a registered Stage `Texture` (`key`) for WebGPU passes (e.g. `Lighting2DSystem`). */
|
|
1383
1475
|
createRenderTarget(key: string, width: number, height: number, textures: TextureManager, filterMode?: 0 | 1): StageRenderTarget;
|
|
1384
1476
|
/** Render a `DisplayList` (or callback) into an offscreen `StageRenderTarget` and mark its texture dirty for WebGPU upload (`camera` defaults to `target.camera`). */
|
|
@@ -2507,4 +2599,4 @@ declare class Game {
|
|
|
2507
2599
|
step(time: number, delta: number): void;
|
|
2508
2600
|
destroy(removeCanvas?: boolean): void;
|
|
2509
2601
|
}
|
|
2510
|
-
export { decodeWorldDeltaBytes as $,
|
|
2602
|
+
export { decodeWorldDeltaBytes as $, HiDpiConfigureOptions as $n, OpenWgpuNativeFfiOptions as $t, createInputRecorder as A, InstancedBatchObject as An, SceneDigestOverlayStats as At, RecipeRegistry as B, SceneHostLike as Bn, Pointer as Bt, RecordedInputEntry as C, DrawStreamBulkView as Cn, unpackChunkY as Ct, TimelineClickOptions as D, EquipmentBinding as Dn, SceneDigestEngineSandbox as Dt, StagePlugin as E, DrawStreamSpriteOptions as En, SceneDigestActiveFocus as Et, InventoryContainer as F, PanelObject as Fn, buildSceneDigest as Ft, WorkstationSnapshot as G, SpriteObject as Gn, WebGpuBootstrapResult as Gt, WorkstationInstance as H, ShapeBatchObject as Hn, RendererWebGpu as Ht, ItemDef as I, PanelOpenSide as In, sanitizeTrackToken as It, WorldDeltaSnapshot as J, TextObject as Jn, requestWebGpuDevice as Jt, WorldCatalogRuntime as K, SpritePlayOptions as Kn, WebGpuCanvasContextLike as Kt, ItemRegistry as L, PanelStyleConfig as Ln, InputConfig as Lt, createInputTimeline as M, MsdfIconConfig as Mn, SceneDigestSurfaceEntry as Mt, CatalogReloadDiff as N, MsdfIconObject as Nn, SceneDigestSurfaceSource as Nt, TimelineDragOptions as O, Graphics as On, SceneDigestNode as Ot, FrozenWorldCatalog as P, NineSliceObject as Pn, SceneDigestSurfaces as Pt, createWorldCatalogRuntime as Q, CameraFollowOptions as Qn, OpenDawnWebGpuOptions as Qt, ItemStack as R, RectClipMask as Rn, InputPlugin as Rt, InputTimelinePlugin as S, DisplaySemantics as Sn, unpackChunkX as St, StageKernel as T, DrawStreamOptions as Tn, SceneDigest as Tt, WorkstationJob as U, ShapeBatchStyleDefaults as Un, RendererWebGpuOptions as Ut, TileCellDelta as V, ShapeBatchColumns as Vn, PointerSample as Vt, WorkstationScheduler as W, SpriteAnimEventListener as Wn, RequestWebGpuOptions as Wt, applyWorldDelta as X, TileSpriteObject as Xn, HeadlessWebGpuHandle as Xt, WorldEntityRecord as Y, TextStyleConfig as Yn, HeadlessWebGpuBackend as Yt, captureWorldDelta as Z, Camera as Zn, HeadlessWebGpuOptions as Zt, ActionMap as _, CustomPassOptions as _n, floorDiv as _t, GameLoop as a, RendererGlOptions as an, ChunkedTilemapOptions as at, InputTargetSpec as b, DisplayObject as bn, packChunkKey as bt, LoaderPlugin as c, StageRenderTarget as cn, MountedChunkedTilemap as ct, SceneCtor as d, BlitterObject as dn, TileChunk as dt, openDawnWebGpu as en, HiDpiScaleLike as er, defineWorldCatalog as et, SceneInput as f, Bob as fn, bakeDualGridTileset as ft, ViewportFitResult as g, CustomPassObject as gn, fbm2D as gt, StageRenderer as h, CustomPassCallback as hn, createIslandBiomeGenerator as ht, GameConfig as i, RendererGl as in, ChunkedTilemap as it, createInputReplay as j, InstancedColumns as jn, SceneDigestSandbox as jt, TimelineKeyOptions as k, ImageObject as kn, SceneDigestOptions as kt, ScaleManager as l, AnchorPose2D as ln, SurvivalBiomes as lt, SceneManager as m, ContainerFiltersShim as mn, computeDualGridMask as mt, EngineClockSnapshot as n, requestHeadlessWebGpu as nn, BakedDualGridAtlas as nt, GameObjectFactory as o, RendererStats as on, DualGridLayerSpec as ot, SceneLifecycleStats as p, Container as pn, computeBlob47Index as pt, WorldCatalogSpec as q, SyncAttachmentOptions as qn, WebGpuDeviceLike as qt, Game as r, Renderer2D as rn, ChunkGeneratorFn as rt, JsonCache as s, Stage2DCustomImageHandler as sn, IslandBiomeConfig as st, EngineClock as t, openWgpuNativeFfi as tn, encodeWorldDeltaBytes as tt, Scene as u, BindEquipmentOptions as un, TileCellFlags as ut, InputProvider as v, DirectionalPlayOptions as vn, hash2D as vt, StageInputEvent as w, DrawStreamObject as wn, valueNoise2D as wt, InputTimelineOptions as x, DisplayObjectType as xn, positiveMod as xt, InputRecorderPlugin as y, DisplayList as yn, mountChunkedTilemap as yt, RecipeDef as z, RectangleObject as zn, KeyboardPlugin 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 { o as Renderer2D, s as Camera, t as RendererWebGpu } from "./renderer-webgpu-B8vktrUk.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-CuyQc8oE.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 { E as StagePlugin, Tt as SceneDigest, f as SceneInput, kt as SceneDigestOptions, n as EngineClockSnapshot, r as Game, u as Scene } from "./game-
|
|
1
|
+
import { $t as OpenWgpuNativeFfiOptions, E as StagePlugin, Qt as OpenDawnWebGpuOptions, Tt as SceneDigest, Xt as HeadlessWebGpuHandle, Yt as HeadlessWebGpuBackend, Zt as HeadlessWebGpuOptions, en as openDawnWebGpu, f as SceneInput, kt as SceneDigestOptions, n as EngineClockSnapshot, nn as requestHeadlessWebGpu, qt as WebGpuDeviceLike, r as Game, tn as openWgpuNativeFfi, u as Scene } from "./game-CT_WCPjJ.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;
|
|
@@ -26,6 +26,10 @@ export interface HeadlessStageOptions {
|
|
|
26
26
|
readonly pixelArt?: boolean;
|
|
27
27
|
/** Optional custom WebGL/WebGL2 context when testing GPU shaders headlessly; defaults to `CANVAS` (`Renderer2D`). */
|
|
28
28
|
readonly glContext?: WebGL2RenderingContext | WebGLRenderingContext | null;
|
|
29
|
+
/** Optional native Headless WebGPU `GPUDevice` (from `await requestHeadlessWebGpu()` via `bun:ffi` / `koffi` `wgpu-native` or Dawn `webgpu`). */
|
|
30
|
+
readonly gpuDevice?: WebGpuDeviceLike | null;
|
|
31
|
+
/** Optional WebGPU offscreen render format when `gpuDevice` is passed (default `'rgba8unorm'`). */
|
|
32
|
+
readonly gpuFormat?: string;
|
|
29
33
|
/** Optional `StagePlugin[]` (e.g. `createInputTimeline`, `createInputRecorder`) mounted at boot. */
|
|
30
34
|
readonly plugins?: StagePlugin[];
|
|
31
35
|
/** Scene instance or constructor to boot synchronously at frame 0. */
|
|
@@ -83,12 +87,18 @@ export interface HeadlessStage {
|
|
|
83
87
|
keyDown(code: string, key?: string): void;
|
|
84
88
|
/** Synthesize a deterministic key-up event. */
|
|
85
89
|
keyUp(code: string, key?: string): void;
|
|
86
|
-
/** Read raw W3C RGBA8888 pixels (`width * height * 4` bytes). */
|
|
90
|
+
/** Read raw W3C RGBA8888 pixels (`width * height * 4` bytes; synchronous on Canvas2D, WebGL, and `wgpu-native` FFI). */
|
|
87
91
|
toRgba(): Uint8Array;
|
|
88
92
|
/** Copy raw W3C RGBA8888 pixels into an existing `Uint8Array` (avoids per-frame buffer allocation in tight video loops). */
|
|
89
93
|
toRgbaInto(out: Uint8Array): Uint8Array;
|
|
94
|
+
/** Asynchronously read raw W3C RGBA8888 pixels across ALL renderers (including async Dawn `'webgpu'` and `navigator.gpu`). */
|
|
95
|
+
toRgbaAsync(): Promise<Uint8Array>;
|
|
96
|
+
/** Asynchronously copy raw W3C RGBA8888 pixels into an existing `Uint8Array` across ALL renderers. */
|
|
97
|
+
toRgbaIntoAsync(out: Uint8Array): Promise<Uint8Array>;
|
|
90
98
|
/** Encode current frame to PNG bytes (requires `canvas.toBuffer('image/png')` such as `@napi-rs/canvas`). */
|
|
91
99
|
toPng(): Uint8Array;
|
|
100
|
+
/** Asynchronously encode current frame to PNG bytes across ALL renderers (including async Dawn `'webgpu'`). */
|
|
101
|
+
toPngAsync(): Promise<Uint8Array>;
|
|
92
102
|
/** Capture a zero-PII structured `SceneDigest` for the active scene at the current frame. */
|
|
93
103
|
digest(options?: SceneDigestOptions): SceneDigest;
|
|
94
104
|
/** Step and stream raw RGBA frames (e.g. into `ffmpeg`) at deterministic `fps`. */
|
|
@@ -230,4 +240,5 @@ export declare function buildFfmpegRawVideoArgs(options: FfmpegRawVideoArgsOptio
|
|
|
230
240
|
* Step a `HeadlessStage` in Node.js or Bun and stream raw `RGBA8888` frames (`-f rawvideo -pix_fmt rgba`)
|
|
231
241
|
* directly into `ffmpeg` stdin with backpressure handling and optional stereo `.wav` audio muxing.
|
|
232
242
|
*/
|
|
233
|
-
export declare function encodeVideoWithFfmpeg(stage: HeadlessStage, options: EncodeVideoWithFfmpegOptions): Promise<EncodeVideoResult>;
|
|
243
|
+
export declare function encodeVideoWithFfmpeg(stage: HeadlessStage, options: EncodeVideoWithFfmpegOptions): Promise<EncodeVideoResult>;
|
|
244
|
+
export { type HeadlessWebGpuBackend, type HeadlessWebGpuHandle, type HeadlessWebGpuOptions, type OpenDawnWebGpuOptions, type OpenWgpuNativeFfiOptions, openDawnWebGpu, openWgpuNativeFfi, requestHeadlessWebGpu };
|
package/dist/headless.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "./types-CXsCvp1p.js";
|
|
2
|
-
import { n as Game } from "./game-
|
|
2
|
+
import { n as Game } from "./game-DZoRjZNH.js";
|
|
3
|
+
import { a as requestHeadlessWebGpu, i as openWgpuNativeFfi, r as openDawnWebGpu } from "./renderer-webgpu-B8vktrUk.js";
|
|
3
4
|
import { buildSceneDigest } from "./trace.js";
|
|
4
5
|
// src/headless.ts
|
|
5
6
|
function createVirtualDomHost(createCanvas, width, height) {
|
|
@@ -74,9 +75,12 @@ function createHeadlessStage(options) {
|
|
|
74
75
|
if (options.Path2D && typeof globalThis.Path2D !== "function") globalThis.Path2D = options.Path2D;
|
|
75
76
|
const { rootCanvas } = createVirtualDomHost(options.createCanvas, width, height);
|
|
76
77
|
const game = new Game({
|
|
77
|
-
type: options.glContext ? 2 : 1,
|
|
78
|
+
type: options.gpuDevice ? 3 : options.glContext ? 2 : 1,
|
|
78
79
|
canvas: rootCanvas,
|
|
79
80
|
context: options.glContext ?? void 0,
|
|
81
|
+
gpuDevice: options.gpuDevice ?? void 0,
|
|
82
|
+
gpuContext: null,
|
|
83
|
+
gpuFormat: options.gpuFormat ?? "rgba8unorm",
|
|
80
84
|
width,
|
|
81
85
|
height,
|
|
82
86
|
backgroundColor: options.backgroundColor ?? "#12161f",
|
|
@@ -122,11 +126,23 @@ function createHeadlessStage(options) {
|
|
|
122
126
|
}
|
|
123
127
|
return game.clock.snapshot();
|
|
124
128
|
};
|
|
129
|
+
const syncGpuPixelsToRootCanvas = (rgba) => {
|
|
130
|
+
const cw = rootCanvas.width || width;
|
|
131
|
+
const ch = rootCanvas.height || height;
|
|
132
|
+
const ctx = rootCanvas.getContext("2d");
|
|
133
|
+
if (!ctx) return;
|
|
134
|
+
if (typeof ctx.createImageData === "function" && typeof ctx.putImageData === "function") {
|
|
135
|
+
const imgData = ctx.createImageData(cw, ch);
|
|
136
|
+
imgData.data.set(rgba.subarray(0, cw * ch * 4));
|
|
137
|
+
ctx.putImageData(imgData, 0, 0);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
125
140
|
const toRgbaInto = (out) => {
|
|
126
141
|
const cw = rootCanvas.width || width;
|
|
127
142
|
const ch = rootCanvas.height || height;
|
|
128
143
|
const byteLen = cw * ch * 4;
|
|
129
144
|
const dst = out && out.byteLength >= byteLen ? out : new Uint8Array(byteLen);
|
|
145
|
+
if (game.renderer.type === 3) return game.renderer.readPixelsSync(dst);
|
|
130
146
|
if (game.renderer.type === 2 && game.renderer.gl) {
|
|
131
147
|
const gl = game.renderer.gl;
|
|
132
148
|
gl.readPixels(0, 0, cw, ch, gl.RGBA, gl.UNSIGNED_BYTE, dst);
|
|
@@ -141,6 +157,7 @@ function createHeadlessStage(options) {
|
|
|
141
157
|
const toRgba = () => {
|
|
142
158
|
const cw = rootCanvas.width || width;
|
|
143
159
|
const ch = rootCanvas.height || height;
|
|
160
|
+
if (game.renderer.type === 3) return game.renderer.readPixelsSync();
|
|
144
161
|
if (game.renderer.type === 2 && game.renderer.gl) {
|
|
145
162
|
const gl = game.renderer.gl;
|
|
146
163
|
const out = new Uint8Array(cw * ch * 4);
|
|
@@ -152,13 +169,34 @@ function createHeadlessStage(options) {
|
|
|
152
169
|
const img = ctx.getImageData(0, 0, cw, ch);
|
|
153
170
|
return new Uint8Array(img.data.buffer, img.data.byteOffset, img.data.byteLength);
|
|
154
171
|
};
|
|
172
|
+
const toRgbaIntoAsync = async (out) => {
|
|
173
|
+
if (game.renderer.type === 3) {
|
|
174
|
+
const byteLen = (rootCanvas.width || width) * (rootCanvas.height || height) * 4;
|
|
175
|
+
const dst = out && out.byteLength >= byteLen ? out : new Uint8Array(byteLen);
|
|
176
|
+
return game.renderer.readPixelsAsync(dst);
|
|
177
|
+
}
|
|
178
|
+
return toRgbaInto(out);
|
|
179
|
+
};
|
|
180
|
+
const toRgbaAsync = async () => {
|
|
181
|
+
if (game.renderer.type === 3) return game.renderer.readPixelsAsync();
|
|
182
|
+
return toRgba();
|
|
183
|
+
};
|
|
155
184
|
const toPng = () => {
|
|
185
|
+
if (game.renderer.type !== 1) syncGpuPixelsToRootCanvas(toRgba());
|
|
156
186
|
if (typeof rootCanvas.toBuffer === "function") {
|
|
157
187
|
const buf = rootCanvas.toBuffer("image/png");
|
|
158
188
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
159
189
|
}
|
|
160
190
|
throw new Error("HeadlessStage.toPng: canvas does not implement toBuffer(\"image/png\"); pass createCanvas from @napi-rs/canvas");
|
|
161
191
|
};
|
|
192
|
+
const toPngAsync = async () => {
|
|
193
|
+
if (game.renderer.type !== 1) syncGpuPixelsToRootCanvas(await toRgbaAsync());
|
|
194
|
+
if (typeof rootCanvas.toBuffer === "function") {
|
|
195
|
+
const buf = rootCanvas.toBuffer("image/png");
|
|
196
|
+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
197
|
+
}
|
|
198
|
+
throw new Error("HeadlessStage.toPngAsync: canvas does not implement toBuffer(\"image/png\"); pass createCanvas from @napi-rs/canvas");
|
|
199
|
+
};
|
|
162
200
|
const digest = (digestOpts) => buildSceneDigest(primaryScene, digestOpts);
|
|
163
201
|
const recordFrames = async (recOpts) => {
|
|
164
202
|
const totalFrames = recOpts.frames !== void 0 ? Math.max(1, Math.floor(recOpts.frames)) : Math.max(1, Math.round((recOpts.durationMs ?? 1e3) / 1e3 * fps));
|
|
@@ -170,12 +208,21 @@ function createHeadlessStage(options) {
|
|
|
170
208
|
game.step(simCursorMs, dt);
|
|
171
209
|
}
|
|
172
210
|
const snapDigest = digestEvery > 0 && i % digestEvery === 0 ? digest(recOpts.digestOptions) : void 0;
|
|
173
|
-
|
|
211
|
+
let frameRgba;
|
|
212
|
+
if (game.renderer.type === 3) {
|
|
213
|
+
if (sharedRgba) {
|
|
214
|
+
sharedRgba = await toRgbaIntoAsync(sharedRgba);
|
|
215
|
+
frameRgba = sharedRgba;
|
|
216
|
+
} else frameRgba = await toRgbaAsync();
|
|
217
|
+
} else if (sharedRgba) {
|
|
218
|
+
sharedRgba = toRgbaInto(sharedRgba);
|
|
219
|
+
frameRgba = sharedRgba;
|
|
220
|
+
} else frameRgba = toRgba();
|
|
174
221
|
await recOpts.onFrame({
|
|
175
222
|
index: i,
|
|
176
223
|
frameSeq: game.clock.frameSeq,
|
|
177
224
|
simTimeMs: Math.round(simCursorMs),
|
|
178
|
-
rgba:
|
|
225
|
+
rgba: frameRgba,
|
|
179
226
|
digest: snapDigest
|
|
180
227
|
});
|
|
181
228
|
}
|
|
@@ -227,7 +274,10 @@ function createHeadlessStage(options) {
|
|
|
227
274
|
}),
|
|
228
275
|
toRgba,
|
|
229
276
|
toRgbaInto,
|
|
277
|
+
toRgbaAsync,
|
|
278
|
+
toRgbaIntoAsync,
|
|
230
279
|
toPng,
|
|
280
|
+
toPngAsync,
|
|
231
281
|
digest,
|
|
232
282
|
recordFrames,
|
|
233
283
|
encodeVideo: (encOpts) => encodeVideoWithFfmpeg(self, encOpts),
|
|
@@ -265,6 +315,15 @@ function renderStoryboard(stage, options) {
|
|
|
265
315
|
const row = Math.floor(i / cols);
|
|
266
316
|
const tx = gap + col * (tileW + gap);
|
|
267
317
|
const ty = gap + row * (tileH + gap);
|
|
318
|
+
if (stage.game.renderer.type !== 1) {
|
|
319
|
+
const c2d = stage.canvas.getContext("2d");
|
|
320
|
+
if (c2d && typeof c2d.createImageData === "function" && typeof c2d.putImageData === "function") {
|
|
321
|
+
const rgba = stage.toRgba();
|
|
322
|
+
const imgData = c2d.createImageData(stage.width, stage.height);
|
|
323
|
+
imgData.data.set(rgba.subarray(0, stage.width * stage.height * 4));
|
|
324
|
+
c2d.putImageData(imgData, 0, 0);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
268
327
|
ctx.drawImage(stage.canvas, 0, 0, stage.width, stage.height, tx, ty, tileW, tileH);
|
|
269
328
|
ctx.strokeStyle = "rgba(255, 255, 255, 0.14)";
|
|
270
329
|
ctx.lineWidth = 1;
|
|
@@ -571,4 +630,4 @@ async function encodeVideoWithFfmpeg(stage, options) {
|
|
|
571
630
|
} catch {}
|
|
572
631
|
}
|
|
573
632
|
}
|
|
574
|
-
export { buildFfmpegRawVideoArgs, createAudioTimeline, createHeadlessStage, encodeVideoWithFfmpeg, renderStoryboard };
|
|
633
|
+
export { buildFfmpegRawVideoArgs, createAudioTimeline, createHeadlessStage, encodeVideoWithFfmpeg, openDawnWebGpu, openWgpuNativeFfi, renderStoryboard, requestHeadlessWebGpu };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as
|
|
1
|
+
import { $n as HiDpiConfigureOptions, $t as OpenWgpuNativeFfiOptions, A as createInputRecorder, An as InstancedBatchObject, At as SceneDigestOverlayStats, Bn as SceneHostLike, Bt as Pointer, C as RecordedInputEntry, Cn as DrawStreamBulkView, D as TimelineClickOptions, Dn as EquipmentBinding, Dt as SceneDigestEngineSandbox, E as StagePlugin, En as DrawStreamSpriteOptions, Et as SceneDigestActiveFocus, Fn as PanelObject, Ft as buildSceneDigest, Gn as SpriteObject, Gt as WebGpuBootstrapResult, Hn as ShapeBatchObject, Ht as RendererWebGpu, In as PanelOpenSide, It as sanitizeTrackToken, Jn as TextObject, Jt as requestWebGpuDevice, Kn as SpritePlayOptions, Kt as WebGpuCanvasContextLike, Ln as PanelStyleConfig, Lt as InputConfig, M as createInputTimeline, Mn as MsdfIconConfig, Mt as SceneDigestSurfaceEntry, Nn as MsdfIconObject, Nt as SceneDigestSurfaceSource, O as TimelineDragOptions, On as Graphics, Ot as SceneDigestNode, Pn as NineSliceObject, Pt as SceneDigestSurfaces, Qn as CameraFollowOptions, Qt as OpenDawnWebGpuOptions, Rn as RectClipMask, Rt as InputPlugin, S as InputTimelinePlugin, Sn as DisplaySemantics, T as StageKernel, Tn as DrawStreamOptions, Tt as SceneDigest, Un as ShapeBatchStyleDefaults, Ut as RendererWebGpuOptions, Vn as ShapeBatchColumns, Vt as PointerSample, Wn as SpriteAnimEventListener, Wt as RequestWebGpuOptions, Xn as TileSpriteObject, Xt as HeadlessWebGpuHandle, Yn as TextStyleConfig, Yt as HeadlessWebGpuBackend, Zn as Camera, Zt as HeadlessWebGpuOptions, _ as ActionMap, _n as CustomPassOptions, a as GameLoop, an as RendererGlOptions, b as InputTargetSpec, bn as DisplayObject, c as LoaderPlugin, cn as StageRenderTarget, d as SceneCtor, dn as BlitterObject, en as openDawnWebGpu, er as HiDpiScaleLike, f as SceneInput, fn as Bob$1, g as ViewportFitResult, gn as CustomPassObject, h as StageRenderer, hn as CustomPassCallback, i as GameConfig$1, in as RendererGl, j as createInputReplay, jn as InstancedColumns, jt as SceneDigestSandbox, k as TimelineKeyOptions, kn as ImageObject, kt as SceneDigestOptions, l as ScaleManager, ln as AnchorPose2D, m as SceneManager, mn as ContainerFiltersShim, n as EngineClockSnapshot, nn as requestHeadlessWebGpu, o as GameObjectFactory, on as RendererStats, p as SceneLifecycleStats, pn as Container, qn as SyncAttachmentOptions, qt as WebGpuDeviceLike, r as Game, rn as Renderer2D, s as JsonCache, sn as Stage2DCustomImageHandler, t as EngineClock, tn as openWgpuNativeFfi, u as Scene, un as BindEquipmentOptions, v as InputProvider, vn as DirectionalPlayOptions, w as StageInputEvent, wn as DrawStreamObject, x as InputTimelineOptions, xn as DisplayObjectType, y as InputRecorderPlugin, yn as DisplayList, zn as RectangleObject, zt as KeyboardPlugin } from "./game-CT_WCPjJ.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-BYBzSNXO.js";
|
|
3
3
|
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";
|
|
4
4
|
import { a as SpringHandle, c as TweenManager, i as Easings, l as TweenOptions, n as EasingFn, o as SpringOptions, r as EasingName, s as TweenHandle, t as DisposableOwner, u as TweenStats } from "./tween-BiF1FUvc.js";
|
|
@@ -332,4 +332,4 @@ export declare const Stage: {
|
|
|
332
332
|
};
|
|
333
333
|
};
|
|
334
334
|
};
|
|
335
|
-
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 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, type Matrix2D, type MountFlexUiOptions, type MountedFlexUi, type MsdfIconConfig, MsdfIconObject, NineSliceObject, 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, 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, createSurfaceTree, flattenFlexTree, isInJoystickZone, mountFlexUi, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, requestWebGpuDevice, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ };
|
|
335
|
+
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, 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, 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, createSurfaceTree, flattenFlexTree, isInJoystickZone, mountFlexUi, openDawnWebGpu, openWgpuNativeFfi, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, requestHeadlessWebGpu, requestWebGpuDevice, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-DZoRjZNH.js";
|
|
3
3
|
import { AnimationManager } from "./anims.js";
|
|
4
|
-
import { i as
|
|
4
|
+
import { a as requestHeadlessWebGpu, i as openWgpuNativeFfi, n as requestWebGpuDevice, o as Renderer2D, r as openDawnWebGpu, s as Camera, t as RendererWebGpu } from "./renderer-webgpu-B8vktrUk.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-CuyQc8oE.js";
|
|
6
6
|
import { ActionMap, StageKernel, createInputRecorder, createInputReplay, createInputTimeline } from "./kernel.js";
|
|
7
7
|
import { buildSceneDigest, sanitizeTrackToken } from "./trace.js";
|
|
@@ -51,4 +51,4 @@ const Stage2D = {
|
|
|
51
51
|
Display: { Canvas: { CanvasPool: { enableSmoothing() {} } } }
|
|
52
52
|
};
|
|
53
53
|
const Stage = Stage2D;
|
|
54
|
-
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, MsdfIconBatcher, MsdfIconObject, NineSliceObject, PanelObject, PixelAaBatcher, Pointer, RectangleObject, Renderer2D, RendererGl, RendererWebGpu, 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, createSurfaceTree, flattenFlexTree, isInJoystickZone, mountFlexUi, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, requestWebGpuDevice, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ };
|
|
54
|
+
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, MsdfIconBatcher, MsdfIconObject, NineSliceObject, PanelObject, PixelAaBatcher, Pointer, RectangleObject, Renderer2D, RendererGl, RendererWebGpu, 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, createSurfaceTree, flattenFlexTree, isInJoystickZone, mountFlexUi, openDawnWebGpu, openWgpuNativeFfi, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, requestHeadlessWebGpu, requestWebGpuDevice, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ };
|
package/dist/joystick.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bt as Pointer,
|
|
1
|
+
import { Bt as Pointer, Fn as PanelObject, pn as Container, u as Scene } from "./game-CT_WCPjJ.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 createInputRecorder, C as RecordedInputEntry, D as TimelineClickOptions, E as StagePlugin, M as createInputTimeline, O as TimelineDragOptions, S as InputTimelinePlugin, T as StageKernel, _ as ActionMap, b as InputTargetSpec, j as createInputReplay, k as TimelineKeyOptions, v as InputProvider, w as StageInputEvent, x as InputTimelineOptions, y as InputRecorderPlugin } from "./game-
|
|
2
|
+
import { A as createInputRecorder, C as RecordedInputEntry, D as TimelineClickOptions, E as StagePlugin, M as createInputTimeline, O as TimelineDragOptions, S as InputTimelinePlugin, T as StageKernel, _ as ActionMap, b as InputTargetSpec, j as createInputReplay, k as TimelineKeyOptions, v as InputProvider, w as StageInputEvent, x as InputTimelineOptions, y as InputRecorderPlugin } from "./game-CT_WCPjJ.js";
|
|
3
3
|
export { ActionMap, type CoroutineGenerator, InputProvider, InputRecorderPlugin, InputTargetSpec, InputTimelineOptions, InputTimelinePlugin, RecordedInputEntry, type ScriptContext, type ScriptHandle, type ScriptOptions, ScriptScheduler, type ScriptStats, StageInputEvent, StageKernel, StagePlugin, TimelineClickOptions, TimelineDragOptions, TimelineKeyOptions, createInputRecorder, createInputReplay, createInputTimeline };
|
package/dist/lighting.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bn as SceneHostLike, bn as DisplayObject, gn as CustomPassObject, kn as ImageObject, pn as Container } from "./game-CT_WCPjJ.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 { Bn as SceneHostLike, bn as DisplayObject, pn as Container } from "./game-CT_WCPjJ.js";
|
|
2
2
|
export interface Camera25DConfig {
|
|
3
3
|
viewportWidth: number;
|
|
4
4
|
viewportHeight: number;
|