@holtjs/stage 0.13.0 → 0.14.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/{anims-n8aqhzxu.d.ts → anims-BOvaKn6w.d.ts} +7 -1
- package/dist/anims.d.ts +1 -1
- package/dist/ecs.d.ts +3 -3
- package/dist/ecs.js +2 -2
- package/dist/{game-CziLa7dv.js → game-BF1ZbJRC.js} +22 -8
- package/dist/{game-C8bz7tay.d.ts → game-rKghsNlA.d.ts} +31 -15
- package/dist/headless.d.ts +33 -3
- package/dist/headless.js +201 -9
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/joystick.d.ts +1 -1
- package/dist/kernel.d.ts +1 -1
- package/dist/lighting.d.ts +1 -1
- package/dist/lighting.js +23 -18
- package/dist/projection.d.ts +1 -1
- package/dist/{renderer-webgpu-LDnrpYa0.js → renderer-webgpu-CnIevdNP.js} +459 -168
- package/dist/renderer-webgpu.d.ts +1 -1
- package/dist/renderer-webgpu.js +1 -1
- package/dist/rig2d.d.ts +2 -2
- 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,17 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.14.0] - 2026-12-05
|
|
10
|
+
|
|
11
|
+
### Added, Optimized & Fixed
|
|
12
|
+
- **Turnkey `createHeadlessStageAsync` / `openHeadlessStage` & Zero-Canvas WebGPU Mode (`@holtjs/stage/headless`, `src/headless.ts`)**:
|
|
13
|
+
- Added one-step `await createHeadlessStageAsync({ renderer: 'auto' | 'webgpu' | 'canvas', ... })` (aliased as `openHeadlessStage`) across **Bun**, **Node.js**, and **Deno**: automatically acquires native Headless WebGPU (`wgpu-native` FFI -> Google Dawn `'webgpu'` -> `navigator.gpu`), auto-discovers `@napi-rs/canvas` when installed, owns and destroys the `GPUDevice` inside `stage.destroy()`, exposes `stage.backend`, and throws an explicit setup error when `renderer: 'webgpu'` has no GPU backend.
|
|
14
|
+
- Made `createCanvas` optional on `createHeadlessStage` when `gpuDevice` or `glContext` is supplied, adding a zero-dependency pure-TypeScript RGBA8888 PNG fallback encoder (`toPng()` / `toPngAsync()`) and `RawRgbaTextureSource` (`{ width, height, data }`) support across `TextureManager`, `Lighting2DSystem`, `RendererWebGpu`, and `RendererGl`.
|
|
15
|
+
- **Unbounded `Uint32Array` Batching, Screen-Space Frustum Culling & Native GPU `StageRenderTarget` in `RendererWebGpu` (`src/renderer-webgpu.ts`)**:
|
|
16
|
+
- Switched `RendererWebGpu` batch index buffers from fixed `65,536`-vertex `Uint16Array` (`'uint16'`) to dynamically growing `Uint32Array` (`'uint32'`) + auto-growing `vbo` / `ibo` / `sdfInstVbo`, eliminating vertex-count truncation on large survival worlds (e.g. Nightfall 96×96 Dual-Grid island + night lighting + HUD).
|
|
17
|
+
- Added screen-space frustum culling in `pushQuad`, `pushTri`, and `pushSdfInstance` (`stats().culled`), plus `NineSlice` 9-patch quad emission, `TileSprite` repeat samplers, and `TextObject` crop UVs.
|
|
18
|
+
- Upgraded `RendererWebGpu.createRenderTarget` and `renderToTarget` to execute native offscreen WebGPU render passes (`rgba8unorm` target pipeline cache + re-entrant `executePass`) with zero per-frame CPU Canvas2D rasterization or `writeTexture` re-uploads.
|
|
19
|
+
|
|
9
20
|
## [0.13.0] - 2026-12-05
|
|
10
21
|
|
|
11
22
|
### Added & Fixed
|
|
@@ -91,7 +91,13 @@ declare class EventEmitter {
|
|
|
91
91
|
emit(event: string, ...args: any[]): boolean;
|
|
92
92
|
removeAllListeners(event?: string): this;
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
/** Zero-DOM raw RGBA8888 pixel buffer accepted by `TextureManager.addImage` / `addAtlas` across WebGPU, WebGL, and Headless hosts. */
|
|
95
|
+
interface RawRgbaTextureSource {
|
|
96
|
+
readonly width: number;
|
|
97
|
+
readonly height: number;
|
|
98
|
+
readonly data?: Uint8Array | Uint8ClampedArray;
|
|
99
|
+
}
|
|
100
|
+
type TextureImageSource = HTMLImageElement | HTMLCanvasElement | ImageBitmap | RawRgbaTextureSource;
|
|
95
101
|
interface SpriteSheetConfig {
|
|
96
102
|
frameWidth: number;
|
|
97
103
|
frameHeight: number;
|
package/dist/anims.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as AtlasClipRule, c as GenerateFrameNamesConfig, i as AtlasAutoAnimOptions, l as GenerateFrameNumbersConfig, n as AnimationFrameInput, o as CompiledAnimationFrame, r as AnimationManager, s as DirectionalAnimGroup, t as AnimationConfig, u as StageAnimation } from "./anims-
|
|
1
|
+
import { a as AtlasClipRule, c as GenerateFrameNamesConfig, i as AtlasAutoAnimOptions, l as GenerateFrameNumbersConfig, n as AnimationFrameInput, o as CompiledAnimationFrame, r as AnimationManager, s as DirectionalAnimGroup, t as AnimationConfig, u as StageAnimation } from "./anims-BOvaKn6w.js";
|
|
2
2
|
export { AnimationConfig, AnimationFrameInput, AnimationManager, AtlasAutoAnimOptions, AtlasClipRule, CompiledAnimationFrame, DirectionalAnimGroup, GenerateFrameNamesConfig, GenerateFrameNumbersConfig, StageAnimation };
|
package/dist/ecs.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export interface EventTable<S extends ComponentSchema = ComponentSchema> {
|
|
|
50
50
|
/** Reset `count = 0` in O(1) without freeing underlying TypedArray buffers. */
|
|
51
51
|
clear(): void;
|
|
52
52
|
}
|
|
53
|
-
/** Declarative
|
|
53
|
+
/** Declarative relational query descriptor (`world.select(...)` / `world.query({...})`). */
|
|
54
54
|
export interface RelationalQuerySpec<R extends readonly ComponentDef<any, any>[] = readonly [], W extends readonly ComponentDef<any, any>[] = readonly []> {
|
|
55
55
|
readonly read?: R;
|
|
56
56
|
readonly write?: W;
|
|
@@ -203,8 +203,8 @@ export declare class SoaWorld {
|
|
|
203
203
|
/** Clear all per-frame `EventTable`s in O(numEventTables) at the end of a simulation tick (zero GC). */
|
|
204
204
|
clearEvents(): void;
|
|
205
205
|
/**
|
|
206
|
-
* Compile a declarative
|
|
207
|
-
*Note: column references stay live even when `SoaWorld` grows capacity!
|
|
206
|
+
* Compile a declarative relational query (`read`, `write`, `with`, `without`).
|
|
207
|
+
* Note: column references stay live even when `SoaWorld` grows capacity!
|
|
208
208
|
*/
|
|
209
209
|
select<const R extends readonly ComponentDef<any, any>[] = readonly [], const W extends readonly ComponentDef<any, any>[] = readonly []>(spec: RelationalQuerySpec<R, W>): RelationalQuery<R, W>;
|
|
210
210
|
/**
|
package/dist/ecs.js
CHANGED
|
@@ -386,8 +386,8 @@ var SoaWorld = class {
|
|
|
386
386
|
for (let i = 0; i < this.eventTableList.length; i++) this.eventTableList[i].clear();
|
|
387
387
|
}
|
|
388
388
|
/**
|
|
389
|
-
* Compile a declarative
|
|
390
|
-
*Note: column references stay live even when `SoaWorld` grows capacity!
|
|
389
|
+
* Compile a declarative relational query (`read`, `write`, `with`, `without`).
|
|
390
|
+
* Note: column references stay live even when `SoaWorld` grows capacity!
|
|
391
391
|
*/
|
|
392
392
|
select(spec) {
|
|
393
393
|
const readDefs = spec.read ?? [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as rgbToCss, a as EventEmitter, c as Scale, h as packColorAbgr, l as Scenes, m as createMatrix2D, o as FilterMode, p as WHITE_RGB, r as BlendModes, u as TintModes } from "./types-CXsCvp1p.js";
|
|
2
2
|
import { AnimationManager } from "./anims.js";
|
|
3
|
-
import { o as Renderer2D, s as Camera, t as RendererWebGpu } from "./renderer-webgpu-
|
|
3
|
+
import { o as Renderer2D, s as Camera, t as RendererWebGpu } from "./renderer-webgpu-CnIevdNP.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";
|
|
@@ -345,16 +345,25 @@ var TextureManager = class {
|
|
|
345
345
|
const defCanvas = this.doc.createElement("canvas");
|
|
346
346
|
defCanvas.width = 1;
|
|
347
347
|
defCanvas.height = 1;
|
|
348
|
-
this.addCanvas("__DEFAULT", defCanvas);
|
|
348
|
+
if (defCanvas.getContext?.("2d", { willReadFrequently: true }) ?? null) this.addCanvas("__DEFAULT", defCanvas);
|
|
349
|
+
else this.addImage("__DEFAULT", {
|
|
350
|
+
width: 1,
|
|
351
|
+
height: 1,
|
|
352
|
+
data: /* @__PURE__ */ new Uint8Array(4)
|
|
353
|
+
});
|
|
349
354
|
const whiteCanvas = this.doc.createElement("canvas");
|
|
350
355
|
whiteCanvas.width = 2;
|
|
351
356
|
whiteCanvas.height = 2;
|
|
352
|
-
const wg = whiteCanvas.getContext("2d", { willReadFrequently: true });
|
|
357
|
+
const wg = whiteCanvas.getContext?.("2d", { willReadFrequently: true }) ?? null;
|
|
353
358
|
if (wg) {
|
|
354
359
|
wg.fillStyle = rgbToCss(WHITE_RGB, 1);
|
|
355
360
|
wg.fillRect(0, 0, 2, 2);
|
|
356
|
-
|
|
357
|
-
this.
|
|
361
|
+
this.addCanvas("__WHITE", whiteCanvas);
|
|
362
|
+
} else this.addImage("__WHITE", {
|
|
363
|
+
width: 2,
|
|
364
|
+
height: 2,
|
|
365
|
+
data: (/* @__PURE__ */ new Uint8Array(16)).fill(255)
|
|
366
|
+
});
|
|
358
367
|
}
|
|
359
368
|
exists(key) {
|
|
360
369
|
return Object.prototype.hasOwnProperty.call(this.list, key);
|
|
@@ -2778,15 +2787,20 @@ var RendererGl = class extends EventEmitter {
|
|
|
2778
2787
|
src.glRepeat = canRepeat;
|
|
2779
2788
|
src.glPremultiplyAlpha = src.premultiplyAlpha;
|
|
2780
2789
|
this.bindTextureAt(0, this.dummyTex);
|
|
2781
|
-
} else if (!isNew && src.glWidth === src.width && src.glHeight === src.height && src.glRepeat === canRepeat && src.glPremultiplyAlpha === src.premultiplyAlpha)
|
|
2782
|
-
|
|
2790
|
+
} else if (!isNew && src.glWidth === src.width && src.glHeight === src.height && src.glRepeat === canRepeat && src.glPremultiplyAlpha === src.premultiplyAlpha) {
|
|
2791
|
+
const rawBuf = src.image?.data;
|
|
2792
|
+
if (rawBuf instanceof Uint8Array || rawBuf instanceof Uint8ClampedArray) gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, src.width, src.height, gl.RGBA, gl.UNSIGNED_BYTE, rawBuf);
|
|
2793
|
+
else gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, src.image);
|
|
2794
|
+
} else {
|
|
2783
2795
|
const wrap = canRepeat ? gl.REPEAT : gl.CLAMP_TO_EDGE;
|
|
2784
2796
|
const filt = src.filterMode === FilterMode.NEAREST ? gl.NEAREST : gl.LINEAR;
|
|
2785
2797
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrap);
|
|
2786
2798
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrap);
|
|
2787
2799
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filt);
|
|
2788
2800
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filt);
|
|
2789
|
-
|
|
2801
|
+
const rawBuf = src.image?.data;
|
|
2802
|
+
if (rawBuf instanceof Uint8Array || rawBuf instanceof Uint8ClampedArray) gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, src.width, src.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, rawBuf);
|
|
2803
|
+
else gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, src.image);
|
|
2790
2804
|
src.glWidth = src.width;
|
|
2791
2805
|
src.glHeight = src.height;
|
|
2792
2806
|
src.glRepeat = canRepeat;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as ScaleMode, M as Matrix2D, N as Rect2D, O as EventEmitter, P as RgbaColor, R as TintMode, S as TextureSource, T as BlendMode, U as WorldView2D, _ as SpriteSheetConfig, d as AtlasJsonLike, g as GlTextureHost, p as Frame, r as AnimationManager, u as StageAnimation, v as Texture, x as TextureManager, y as TextureImageOptions } from "./anims-
|
|
1
|
+
import { I as ScaleMode, M as Matrix2D, N as Rect2D, O as EventEmitter, P as RgbaColor, R as TintMode, S as TextureSource, T as BlendMode, U as WorldView2D, _ as SpriteSheetConfig, d as AtlasJsonLike, g as GlTextureHost, p as Frame, r as AnimationManager, u as StageAnimation, v as Texture, x as TextureManager, y as TextureImageOptions } from "./anims-BOvaKn6w.js";
|
|
2
2
|
import { c as TweenManager, u as TweenStats } from "./tween-BiF1FUvc.js";
|
|
3
3
|
import { a as ScriptOptions, i as ScriptHandle, o as ScriptScheduler, r as ScriptContext, s as ScriptStats, t as CoroutineGenerator } from "./coroutine-DLgJumtD.js";
|
|
4
4
|
interface CameraFollowOptions {
|
|
@@ -1407,41 +1407,56 @@ declare class RendererWebGpu extends EventEmitter {
|
|
|
1407
1407
|
private uploadScratchCanvas;
|
|
1408
1408
|
private uploadScratchCtx;
|
|
1409
1409
|
private readonly globalsBuf;
|
|
1410
|
-
private
|
|
1411
|
-
private
|
|
1410
|
+
private vbo;
|
|
1411
|
+
private ibo;
|
|
1412
1412
|
private readonly sdfCornerVbo;
|
|
1413
|
-
private
|
|
1413
|
+
private sdfInstVbo;
|
|
1414
1414
|
private readonly sdfQuadIbo;
|
|
1415
1415
|
private readonly samplerLinear;
|
|
1416
1416
|
private readonly samplerNearest;
|
|
1417
|
+
private readonly samplerLinearRepeat;
|
|
1418
|
+
private readonly samplerNearestRepeat;
|
|
1417
1419
|
private readonly batchBgl;
|
|
1418
1420
|
private readonly sdfBgl;
|
|
1419
1421
|
private readonly sdfBindGroup;
|
|
1422
|
+
private readonly batchMod;
|
|
1423
|
+
private readonly batchLayout;
|
|
1424
|
+
private readonly sdfMod;
|
|
1425
|
+
private readonly sdfLayout;
|
|
1420
1426
|
private readonly batchPipelines;
|
|
1421
1427
|
private readonly sdfPipelines;
|
|
1422
1428
|
private readonly texCache;
|
|
1423
1429
|
private dummyEntry;
|
|
1424
|
-
private
|
|
1425
|
-
private
|
|
1426
|
-
private
|
|
1427
|
-
private
|
|
1428
|
-
private
|
|
1429
|
-
private
|
|
1430
|
-
private
|
|
1430
|
+
private vertCap;
|
|
1431
|
+
private indexCap;
|
|
1432
|
+
private vertRaw;
|
|
1433
|
+
private f32;
|
|
1434
|
+
private u32;
|
|
1435
|
+
private indices;
|
|
1436
|
+
private sdfCap;
|
|
1437
|
+
private sdfRaw;
|
|
1438
|
+
private sdfF32;
|
|
1439
|
+
private sdfU32;
|
|
1431
1440
|
private vertCount;
|
|
1432
1441
|
private indexCount;
|
|
1433
1442
|
private cmdStartIndex;
|
|
1434
1443
|
private sdfCount;
|
|
1435
1444
|
private sdfCmdStart;
|
|
1445
|
+
private curTargetW;
|
|
1446
|
+
private curTargetH;
|
|
1436
1447
|
private curBlend;
|
|
1437
1448
|
private curBindGroup;
|
|
1438
|
-
private
|
|
1439
|
-
private
|
|
1449
|
+
private cmds;
|
|
1450
|
+
private scissorStack;
|
|
1440
1451
|
private readonly matPool;
|
|
1441
1452
|
private readonly sfMat;
|
|
1442
1453
|
private readonly maskWorldMat;
|
|
1443
1454
|
private lastStats;
|
|
1444
1455
|
constructor(canvas: HTMLCanvasElement, width: number, height: number, opts: RendererWebGpuOptions);
|
|
1456
|
+
private getBatchPipeline;
|
|
1457
|
+
private getSdfPipeline;
|
|
1458
|
+
private ensureBatchCapacity;
|
|
1459
|
+
private ensureSdfCapacity;
|
|
1445
1460
|
private makeBatchBindGroup;
|
|
1446
1461
|
stats(): RendererStats;
|
|
1447
1462
|
resize(width: number, height: number): void;
|
|
@@ -1460,6 +1475,7 @@ declare class RendererWebGpu extends EventEmitter {
|
|
|
1460
1475
|
private renderPanel;
|
|
1461
1476
|
private renderGraphics;
|
|
1462
1477
|
private renderNode;
|
|
1478
|
+
private executePass;
|
|
1463
1479
|
render(displayList: DisplayList, camera: Camera): void;
|
|
1464
1480
|
private encodeCopyToStaging;
|
|
1465
1481
|
private unpackStagingBytes;
|
|
@@ -1473,9 +1489,9 @@ declare class RendererWebGpu extends EventEmitter {
|
|
|
1473
1489
|
* (`wgpu-native` FFI, Google Dawn `webgpu`, Deno `navigator.gpu`, and Browser WebGPU).
|
|
1474
1490
|
*/
|
|
1475
1491
|
readPixelsAsync(out?: Uint8Array): Promise<Uint8Array>;
|
|
1476
|
-
/** Create an offscreen render target backed by a registered Stage `Texture` (`key`) for WebGPU passes (e.g. `Lighting2DSystem`). */
|
|
1492
|
+
/** Create an offscreen GPU render target backed by a registered Stage `Texture` (`key`) for WebGPU passes (e.g. `Lighting2DSystem`). */
|
|
1477
1493
|
createRenderTarget(key: string, width: number, height: number, textures: TextureManager, filterMode?: 0 | 1): StageRenderTarget;
|
|
1478
|
-
/** Render a `DisplayList`
|
|
1494
|
+
/** Render a `DisplayList` natively on the GPU into an offscreen `StageRenderTarget` (zero CPU Canvas2D copy!). */
|
|
1479
1495
|
renderToTarget(target: StageRenderTarget, content: DisplayList | ((renderer: Renderer2D, camera: Camera) => void), camera?: Camera): void;
|
|
1480
1496
|
destroy(): void;
|
|
1481
1497
|
}
|
package/dist/headless.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-rKghsNlA.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;
|
|
@@ -7,9 +7,13 @@ export interface HeadlessCanvasLike {
|
|
|
7
7
|
toBuffer?(mimeType: 'image/png'): Uint8Array;
|
|
8
8
|
}
|
|
9
9
|
export type CreateHeadlessCanvas = (width: number, height: number) => HeadlessCanvasLike;
|
|
10
|
+
export type HeadlessStageBackend = HeadlessWebGpuBackend | 'webgpu' | 'webgl' | 'canvas2d';
|
|
10
11
|
export interface HeadlessStageOptions {
|
|
11
|
-
/**
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Canvas factory such as `createCanvas` from `@napi-rs/canvas`.
|
|
14
|
+
* Required for `CANVAS` rendering or `TextObject` rasterization; optional when `gpuDevice` or `glContext` is supplied.
|
|
15
|
+
*/
|
|
16
|
+
readonly createCanvas?: CreateHeadlessCanvas;
|
|
13
17
|
/** Optional `Path2D` constructor (e.g. from `@napi-rs/canvas`) so `MsdfIconObject` paths render in Node. */
|
|
14
18
|
readonly Path2D?: typeof Path2D;
|
|
15
19
|
/** Viewport width in pixels (default `1280`). */
|
|
@@ -30,11 +34,26 @@ export interface HeadlessStageOptions {
|
|
|
30
34
|
readonly gpuDevice?: WebGpuDeviceLike | null;
|
|
31
35
|
/** Optional WebGPU offscreen render format when `gpuDevice` is passed (default `'rgba8unorm'`). */
|
|
32
36
|
readonly gpuFormat?: string;
|
|
37
|
+
/** Optional explicit backend label recorded on `stage.backend`. */
|
|
38
|
+
readonly backend?: HeadlessStageBackend;
|
|
39
|
+
/** Optional cleanup hook invoked when `stage.destroy()` runs. */
|
|
40
|
+
readonly onDestroy?: () => void;
|
|
33
41
|
/** Optional `StagePlugin[]` (e.g. `createInputTimeline`, `createInputRecorder`) mounted at boot. */
|
|
34
42
|
readonly plugins?: StagePlugin[];
|
|
35
43
|
/** Scene instance or constructor to boot synchronously at frame 0. */
|
|
36
44
|
readonly scene: SceneInput;
|
|
37
45
|
}
|
|
46
|
+
export interface AsyncHeadlessStageOptions extends Omit<HeadlessStageOptions, 'gpuDevice' | 'gpuFormat' | 'backend'> {
|
|
47
|
+
/**
|
|
48
|
+
* Renderer selection (`default = 'auto'`):
|
|
49
|
+
* - `'auto'`: acquires native Headless WebGPU (`wgpu-native` FFI -> Dawn `webgpu` -> `navigator.gpu`) when available, falling back cleanly to Canvas2D.
|
|
50
|
+
* - `'webgpu'`: requires native Headless WebGPU and throws an actionable setup error if no GPU driver is available.
|
|
51
|
+
* - `'canvas'`: forces deterministic CPU Canvas2D rendering.
|
|
52
|
+
*/
|
|
53
|
+
readonly renderer?: 'auto' | 'webgpu' | 'canvas';
|
|
54
|
+
/** Optional native WebGPU discovery options (`libPath`, `backend`, `powerPreference`, `dawnFlags`). */
|
|
55
|
+
readonly webgpu?: HeadlessWebGpuOptions;
|
|
56
|
+
}
|
|
38
57
|
export interface HeadlessRecordedFrame {
|
|
39
58
|
/** Zero-based recorded frame index (`0 .. frames - 1`). */
|
|
40
59
|
readonly index: number;
|
|
@@ -65,6 +84,8 @@ export interface HeadlessStage {
|
|
|
65
84
|
readonly game: Game;
|
|
66
85
|
readonly scene: Scene;
|
|
67
86
|
readonly canvas: HeadlessCanvasLike;
|
|
87
|
+
/** Active headless rendering backend (`'wgpu-bun-ffi' | 'wgpu-node-koffi' | 'dawn' | 'navigator' | 'webgpu' | 'webgl' | 'canvas2d'`). */
|
|
88
|
+
readonly backend: HeadlessStageBackend;
|
|
68
89
|
readonly width: number;
|
|
69
90
|
readonly height: number;
|
|
70
91
|
readonly fps: number;
|
|
@@ -113,6 +134,15 @@ export interface HeadlessStage {
|
|
|
113
134
|
* (such as `@napi-rs/canvas` in Node) for AI-agent drawing, CI visual assertions, and 60 FPS video rendering.
|
|
114
135
|
*/
|
|
115
136
|
export declare function createHeadlessStage(options: HeadlessStageOptions): HeadlessStage;
|
|
137
|
+
/**
|
|
138
|
+
* Turnkey async headless Stage initializer across **Bun**, **Node.js**, and **Deno**:
|
|
139
|
+
* - Automatically discovers native Headless WebGPU (`wgpu-native` FFI -> Dawn `webgpu` -> `navigator.gpu`) when `renderer` is `'auto'` (default) or `'webgpu'`
|
|
140
|
+
* - Automatically discovers `@napi-rs/canvas` (`createCanvas` & `Path2D`) if installed when `createCanvas` is omitted (and runs pure-GPU scenes with zero npm dependencies!)
|
|
141
|
+
* - Manages `GPUDevice` cleanup automatically inside `stage.destroy()` and exposes the active backend via `stage.backend`
|
|
142
|
+
*/
|
|
143
|
+
export declare function createHeadlessStageAsync(options: AsyncHeadlessStageOptions): Promise<HeadlessStage>;
|
|
144
|
+
/** Alias for `createHeadlessStageAsync` (`await openHeadlessStage({ renderer: 'webgpu', scene })`). */
|
|
145
|
+
export declare const openHeadlessStage: typeof createHeadlessStageAsync;
|
|
116
146
|
export interface StoryboardOptions {
|
|
117
147
|
/** Ascending frame numbers to capture (e.g. `[0, 30, 60, 90, 120, 150]`). */
|
|
118
148
|
readonly frames: readonly number[];
|
package/dist/headless.js
CHANGED
|
@@ -1,8 +1,127 @@
|
|
|
1
1
|
import "./types-CXsCvp1p.js";
|
|
2
|
-
import { n as Game } from "./game-
|
|
3
|
-
import { a as requestHeadlessWebGpu, i as openWgpuNativeFfi, r as openDawnWebGpu } from "./renderer-webgpu-
|
|
2
|
+
import { n as Game } from "./game-BF1ZbJRC.js";
|
|
3
|
+
import { a as requestHeadlessWebGpu, i as openWgpuNativeFfi, r as openDawnWebGpu } from "./renderer-webgpu-CnIevdNP.js";
|
|
4
4
|
import { buildSceneDigest } from "./trace.js";
|
|
5
5
|
// src/headless.ts
|
|
6
|
+
let pngCrcTable = null;
|
|
7
|
+
function getPngCrcTable() {
|
|
8
|
+
if (pngCrcTable) return pngCrcTable;
|
|
9
|
+
const table = /* @__PURE__ */ new Uint32Array(256);
|
|
10
|
+
for (let n = 0; n < 256; n++) {
|
|
11
|
+
let c = n;
|
|
12
|
+
for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ c >>> 1 : c >>> 1;
|
|
13
|
+
table[n] = c >>> 0;
|
|
14
|
+
}
|
|
15
|
+
pngCrcTable = table;
|
|
16
|
+
return table;
|
|
17
|
+
}
|
|
18
|
+
function pngCrc32(buf, start, len) {
|
|
19
|
+
const table = getPngCrcTable();
|
|
20
|
+
let c = 0xffffffff;
|
|
21
|
+
for (let i = 0; i < len; i++) c = table[(c ^ buf[start + i]) & 255] ^ c >>> 8;
|
|
22
|
+
return (c ^ 0xffffffff) >>> 0;
|
|
23
|
+
}
|
|
24
|
+
/** Zero-dependency pure-TS RGBA8888 -> PNG encoder (used when running pure WebGPU/WebGL without `@napi-rs/canvas`). */
|
|
25
|
+
function encodeRgbaToPngFallback(rgba, width, height) {
|
|
26
|
+
const rowStride = width * 4;
|
|
27
|
+
const rawLen = height * (1 + rowStride);
|
|
28
|
+
const raw = new Uint8Array(rawLen);
|
|
29
|
+
let s1 = 1;
|
|
30
|
+
let s2 = 0;
|
|
31
|
+
let dstOff = 0;
|
|
32
|
+
for (let y = 0; y < height; y++) {
|
|
33
|
+
raw[dstOff++] = 0;
|
|
34
|
+
s2 = (s2 + s1) % 65521;
|
|
35
|
+
const srcRow = y * rowStride;
|
|
36
|
+
for (let x = 0; x < rowStride; x++) {
|
|
37
|
+
const b = rgba[srcRow + x];
|
|
38
|
+
raw[dstOff++] = b;
|
|
39
|
+
s1 = (s1 + b) % 65521;
|
|
40
|
+
s2 = (s2 + s1) % 65521;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const adler = (s2 << 16 | s1) >>> 0;
|
|
44
|
+
const numBlocks = Math.max(1, Math.ceil(rawLen / 65535));
|
|
45
|
+
const idatDataLen = 2 + rawLen + numBlocks * 5 + 4;
|
|
46
|
+
const out = new Uint8Array(57 + idatDataLen);
|
|
47
|
+
const dv = new DataView(out.buffer);
|
|
48
|
+
out.set([
|
|
49
|
+
137,
|
|
50
|
+
80,
|
|
51
|
+
78,
|
|
52
|
+
71,
|
|
53
|
+
13,
|
|
54
|
+
10,
|
|
55
|
+
26,
|
|
56
|
+
10
|
|
57
|
+
], 0);
|
|
58
|
+
dv.setUint32(8, 13, false);
|
|
59
|
+
out.set([
|
|
60
|
+
73,
|
|
61
|
+
72,
|
|
62
|
+
68,
|
|
63
|
+
82
|
|
64
|
+
], 12);
|
|
65
|
+
dv.setUint32(16, width, false);
|
|
66
|
+
dv.setUint32(20, height, false);
|
|
67
|
+
out[24] = 8;
|
|
68
|
+
out[25] = 6;
|
|
69
|
+
out[26] = 0;
|
|
70
|
+
out[27] = 0;
|
|
71
|
+
out[28] = 0;
|
|
72
|
+
dv.setUint32(29, pngCrc32(out, 12, 17), false);
|
|
73
|
+
dv.setUint32(33, idatDataLen, false);
|
|
74
|
+
out.set([
|
|
75
|
+
73,
|
|
76
|
+
68,
|
|
77
|
+
65,
|
|
78
|
+
84
|
|
79
|
+
], 37);
|
|
80
|
+
let p = 41;
|
|
81
|
+
out[p++] = 120;
|
|
82
|
+
out[p++] = 1;
|
|
83
|
+
let rem = rawLen;
|
|
84
|
+
let rOff = 0;
|
|
85
|
+
while (rem > 0 || rOff === 0) {
|
|
86
|
+
const chunk = Math.min(65535, rem);
|
|
87
|
+
const isFinal = rem - chunk <= 0 ? 1 : 0;
|
|
88
|
+
out[p++] = isFinal;
|
|
89
|
+
out[p++] = chunk & 255;
|
|
90
|
+
out[p++] = chunk >>> 8 & 255;
|
|
91
|
+
const nlen = ~chunk & 65535;
|
|
92
|
+
out[p++] = nlen & 255;
|
|
93
|
+
out[p++] = nlen >>> 8 & 255;
|
|
94
|
+
if (chunk > 0) {
|
|
95
|
+
out.set(raw.subarray(rOff, rOff + chunk), p);
|
|
96
|
+
p += chunk;
|
|
97
|
+
rOff += chunk;
|
|
98
|
+
rem -= chunk;
|
|
99
|
+
}
|
|
100
|
+
if (isFinal) break;
|
|
101
|
+
}
|
|
102
|
+
dv.setUint32(p, adler, false);
|
|
103
|
+
p += 4;
|
|
104
|
+
dv.setUint32(p, pngCrc32(out, 37, 4 + idatDataLen), false);
|
|
105
|
+
p += 4;
|
|
106
|
+
dv.setUint32(p, 0, false);
|
|
107
|
+
out.set([
|
|
108
|
+
73,
|
|
109
|
+
69,
|
|
110
|
+
78,
|
|
111
|
+
68
|
|
112
|
+
], p + 4);
|
|
113
|
+
dv.setUint32(p + 8, pngCrc32(out, p + 4, 4), false);
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
116
|
+
function createGpuStubCanvas(width, height) {
|
|
117
|
+
return {
|
|
118
|
+
width,
|
|
119
|
+
height,
|
|
120
|
+
getContext() {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
6
125
|
function createVirtualDomHost(createCanvas, width, height) {
|
|
7
126
|
const winStub = {
|
|
8
127
|
innerWidth: width,
|
|
@@ -72,8 +191,9 @@ function createHeadlessStage(options) {
|
|
|
72
191
|
const height = Math.max(1, Math.round(options.height ?? 720));
|
|
73
192
|
const fps = Math.max(1, Math.min(240, options.fps ?? 60));
|
|
74
193
|
const dt = 1e3 / fps;
|
|
194
|
+
if (!options.createCanvas && !options.gpuDevice && !options.glContext) throw new Error("createHeadlessStage: pass createCanvas (e.g. from @napi-rs/canvas) for Canvas2D, or use await createHeadlessStageAsync({ renderer: \"webgpu\" | \"auto\", ... })");
|
|
75
195
|
if (options.Path2D && typeof globalThis.Path2D !== "function") globalThis.Path2D = options.Path2D;
|
|
76
|
-
const { rootCanvas } = createVirtualDomHost(options.createCanvas, width, height);
|
|
196
|
+
const { rootCanvas } = createVirtualDomHost(options.createCanvas ?? createGpuStubCanvas, width, height);
|
|
77
197
|
const game = new Game({
|
|
78
198
|
type: options.gpuDevice ? 3 : options.glContext ? 2 : 1,
|
|
79
199
|
canvas: rootCanvas,
|
|
@@ -182,20 +302,28 @@ function createHeadlessStage(options) {
|
|
|
182
302
|
return toRgba();
|
|
183
303
|
};
|
|
184
304
|
const toPng = () => {
|
|
185
|
-
|
|
305
|
+
const cw = rootCanvas.width || width;
|
|
306
|
+
const ch = rootCanvas.height || height;
|
|
307
|
+
const rgba = game.renderer.type !== 1 ? toRgba() : null;
|
|
308
|
+
if (rgba) syncGpuPixelsToRootCanvas(rgba);
|
|
186
309
|
if (typeof rootCanvas.toBuffer === "function") {
|
|
187
310
|
const buf = rootCanvas.toBuffer("image/png");
|
|
188
311
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
189
312
|
}
|
|
190
|
-
|
|
313
|
+
if (rgba) return encodeRgbaToPngFallback(rgba, cw, ch);
|
|
314
|
+
return encodeRgbaToPngFallback(toRgba(), cw, ch);
|
|
191
315
|
};
|
|
192
316
|
const toPngAsync = async () => {
|
|
193
|
-
|
|
317
|
+
const cw = rootCanvas.width || width;
|
|
318
|
+
const ch = rootCanvas.height || height;
|
|
319
|
+
const rgba = game.renderer.type !== 1 ? await toRgbaAsync() : null;
|
|
320
|
+
if (rgba) syncGpuPixelsToRootCanvas(rgba);
|
|
194
321
|
if (typeof rootCanvas.toBuffer === "function") {
|
|
195
322
|
const buf = rootCanvas.toBuffer("image/png");
|
|
196
323
|
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
197
324
|
}
|
|
198
|
-
|
|
325
|
+
if (rgba) return encodeRgbaToPngFallback(rgba, cw, ch);
|
|
326
|
+
return encodeRgbaToPngFallback(await toRgbaAsync(), cw, ch);
|
|
199
327
|
};
|
|
200
328
|
const digest = (digestOpts) => buildSceneDigest(primaryScene, digestOpts);
|
|
201
329
|
const recordFrames = async (recOpts) => {
|
|
@@ -232,6 +360,7 @@ function createHeadlessStage(options) {
|
|
|
232
360
|
game,
|
|
233
361
|
scene: primaryScene,
|
|
234
362
|
canvas: rootCanvas,
|
|
363
|
+
backend: options.backend ?? (game.renderer.type === 3 ? "webgpu" : game.renderer.type === 2 ? "webgl" : "canvas2d"),
|
|
235
364
|
width,
|
|
236
365
|
height,
|
|
237
366
|
fps,
|
|
@@ -281,10 +410,73 @@ function createHeadlessStage(options) {
|
|
|
281
410
|
digest,
|
|
282
411
|
recordFrames,
|
|
283
412
|
encodeVideo: (encOpts) => encodeVideoWithFfmpeg(self, encOpts),
|
|
284
|
-
destroy: () =>
|
|
413
|
+
destroy: () => {
|
|
414
|
+
game.destroy(false);
|
|
415
|
+
options.onDestroy?.();
|
|
416
|
+
}
|
|
285
417
|
};
|
|
286
418
|
return self;
|
|
287
419
|
}
|
|
420
|
+
const dynamicImportHeadless = (specifier) => import(
|
|
421
|
+
/* @vite-ignore */
|
|
422
|
+
specifier
|
|
423
|
+
);
|
|
424
|
+
async function tryAutoDiscoverCanvasFactory() {
|
|
425
|
+
try {
|
|
426
|
+
const mod = await dynamicImportHeadless("@napi-rs/canvas");
|
|
427
|
+
if (mod && typeof mod.createCanvas === "function") return {
|
|
428
|
+
createCanvas: mod.createCanvas,
|
|
429
|
+
Path2D: mod.Path2D
|
|
430
|
+
};
|
|
431
|
+
} catch {}
|
|
432
|
+
const proc = globalThis.process;
|
|
433
|
+
if (!proc || typeof proc.cwd !== "function") return {};
|
|
434
|
+
try {
|
|
435
|
+
const [modNs, pathNs] = await Promise.all([dynamicImportHeadless("node:module"), dynamicImportHeadless("node:path")]);
|
|
436
|
+
const mod = modNs.createRequire(pathNs.join(proc.cwd(), "__stage_canvas_resolve__.cjs"))("@napi-rs/canvas");
|
|
437
|
+
if (mod && typeof mod.createCanvas === "function") return {
|
|
438
|
+
createCanvas: mod.createCanvas,
|
|
439
|
+
Path2D: mod.Path2D
|
|
440
|
+
};
|
|
441
|
+
} catch {}
|
|
442
|
+
return {};
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Turnkey async headless Stage initializer across **Bun**, **Node.js**, and **Deno**:
|
|
446
|
+
* - Automatically discovers native Headless WebGPU (`wgpu-native` FFI -> Dawn `webgpu` -> `navigator.gpu`) when `renderer` is `'auto'` (default) or `'webgpu'`
|
|
447
|
+
* - Automatically discovers `@napi-rs/canvas` (`createCanvas` & `Path2D`) if installed when `createCanvas` is omitted (and runs pure-GPU scenes with zero npm dependencies!)
|
|
448
|
+
* - Manages `GPUDevice` cleanup automatically inside `stage.destroy()` and exposes the active backend via `stage.backend`
|
|
449
|
+
*/
|
|
450
|
+
async function createHeadlessStageAsync(options) {
|
|
451
|
+
const mode = options.renderer ?? "auto";
|
|
452
|
+
let createCanvas = options.createCanvas;
|
|
453
|
+
let path2DCtor = options.Path2D;
|
|
454
|
+
if (!createCanvas) {
|
|
455
|
+
const discovered = await tryAutoDiscoverCanvasFactory();
|
|
456
|
+
createCanvas = discovered.createCanvas;
|
|
457
|
+
if (!path2DCtor && discovered.Path2D) path2DCtor = discovered.Path2D;
|
|
458
|
+
}
|
|
459
|
+
let gpu = null;
|
|
460
|
+
if (mode === "webgpu" || mode === "auto") {
|
|
461
|
+
gpu = await requestHeadlessWebGpu(options.webgpu);
|
|
462
|
+
if (!gpu && mode === "webgpu") throw new Error("createHeadlessStageAsync: WebGPU requested (renderer: \"webgpu\") but no native WebGPU backend was found. Set STAGE_WGPU_LIB=/path/to/libwgpu_native.{so,dylib,dll}, install the \"webgpu\" (Dawn) package, run on Deno with --unstable-webgpu, or pass renderer: \"auto\" to allow Canvas2D fallback.");
|
|
463
|
+
}
|
|
464
|
+
if (!gpu && !options.glContext && !createCanvas) throw new Error("createHeadlessStageAsync: neither a Headless WebGPU backend nor @napi-rs/canvas was found; install @napi-rs/canvas or configure WebGPU.");
|
|
465
|
+
return createHeadlessStage({
|
|
466
|
+
...options,
|
|
467
|
+
createCanvas,
|
|
468
|
+
Path2D: path2DCtor,
|
|
469
|
+
gpuDevice: gpu?.device ?? null,
|
|
470
|
+
gpuFormat: gpu?.format,
|
|
471
|
+
backend: gpu ? gpu.backend : options.glContext ? "webgl" : "canvas2d",
|
|
472
|
+
onDestroy: () => {
|
|
473
|
+
options.onDestroy?.();
|
|
474
|
+
gpu?.destroy();
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
/** Alias for `createHeadlessStageAsync` (`await openHeadlessStage({ renderer: 'webgpu', scene })`). */
|
|
479
|
+
const openHeadlessStage = createHeadlessStageAsync;
|
|
288
480
|
/**
|
|
289
481
|
* Step a `HeadlessStage` across target keyframes and composite a single multi-panel
|
|
290
482
|
* storyboard contact sheet + paired `SceneDigest` array so AI agents can visually and
|
|
@@ -630,4 +822,4 @@ async function encodeVideoWithFfmpeg(stage, options) {
|
|
|
630
822
|
} catch {}
|
|
631
823
|
}
|
|
632
824
|
}
|
|
633
|
-
export { buildFfmpegRawVideoArgs, createAudioTimeline, createHeadlessStage, encodeVideoWithFfmpeg, openDawnWebGpu, openWgpuNativeFfi, renderStoryboard, requestHeadlessWebGpu };
|
|
825
|
+
export { buildFfmpegRawVideoArgs, createAudioTimeline, createHeadlessStage, createHeadlessStageAsync, encodeVideoWithFfmpeg, openDawnWebGpu, openHeadlessStage, openWgpuNativeFfi, renderStoryboard, requestHeadlessWebGpu };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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-
|
|
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-rKghsNlA.js";
|
|
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 { 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";
|
|
5
5
|
import { a as ScriptOptions, i as ScriptHandle, o as ScriptScheduler, r as ScriptContext, s as ScriptStats, t as CoroutineGenerator } from "./coroutine-DLgJumtD.js";
|
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-BF1ZbJRC.js";
|
|
3
3
|
import { AnimationManager } from "./anims.js";
|
|
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-
|
|
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-CnIevdNP.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
6
|
import { ActionMap, StageKernel, createInputRecorder, createInputReplay, createInputTimeline } from "./kernel.js";
|
|
7
7
|
import { buildSceneDigest, sanitizeTrackToken } from "./trace.js";
|
package/dist/joystick.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bt as Pointer, Fn as PanelObject, pn as Container, u as Scene } from "./game-
|
|
1
|
+
import { Bt as Pointer, Fn as PanelObject, pn as Container, u as Scene } from "./game-rKghsNlA.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-rKghsNlA.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 { Bn as SceneHostLike, bn as DisplayObject, gn as CustomPassObject, kn as ImageObject, pn as Container } from "./game-
|
|
1
|
+
import { Bn as SceneHostLike, bn as DisplayObject, gn as CustomPassObject, kn as ImageObject, pn as Container } from "./game-rKghsNlA.js";
|
|
2
2
|
export type DayPhase = 'day' | 'dusk' | 'night';
|
|
3
3
|
export interface DayNightConfig {
|
|
4
4
|
dayLengthMs?: number;
|