@holtjs/stage 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/headless.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import "./types-CXsCvp1p.js";
2
- import { n as Game } from "./game-2dS3Qsrn.js";
2
+ import { n as Game } from "./game-CziLa7dv.js";
3
+ import { a as requestHeadlessWebGpu, i as openWgpuNativeFfi, r as openDawnWebGpu } from "./renderer-webgpu-LDnrpYa0.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
- if (sharedRgba) sharedRgba = toRgbaInto(sharedRgba);
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: sharedRgba ?? toRgba(),
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,5 +1,5 @@
1
- import { $t as Stage2DCustomImageHandler, A as createInputRecorder, An as RectClipMask, At as SceneDigestOverlayStats, Bn as TextObject, Bt as Pointer, C as RecordedInputEntry, Cn as InstancedColumns, D as TimelineClickOptions, Dn as PanelObject, Dt as SceneDigestEngineSandbox, E as StagePlugin, En as NineSliceObject, Et as SceneDigestActiveFocus, Fn as ShapeBatchStyleDefaults, Ft as buildSceneDigest, Gn as HiDpiConfigureOptions, Gt as WebGpuBootstrapResult, Hn as TileSpriteObject, Ht as RendererWebGpu, In as SpriteAnimEventListener, It as sanitizeTrackToken, Jt as requestWebGpuDevice, Kn as HiDpiScaleLike, Kt as WebGpuCanvasContextLike, Ln as SpriteObject, Lt as InputConfig, M as createInputTimeline, Mn as SceneHostLike, Mt as SceneDigestSurfaceEntry, Nn as ShapeBatchColumns, Nt as SceneDigestSurfaceSource, O as TimelineDragOptions, On as PanelOpenSide, Ot as SceneDigestNode, Pn as ShapeBatchObject, Pt as SceneDigestSurfaces, Qt as RendererStats, Rn as SpritePlayOptions, Rt as InputPlugin, S as InputTimelinePlugin, Sn as InstancedBatchObject, T as StageKernel, Tn as MsdfIconObject, Tt as SceneDigest, Un as Camera, Ut as RendererWebGpuOptions, Vn as TextStyleConfig, Vt as PointerSample, Wn as CameraFollowOptions, Wt as RequestWebGpuOptions, Xt as RendererGl, Yt as Renderer2D, Zt as RendererGlOptions, _ as ActionMap, _n as DrawStreamOptions, a as GameLoop, an as Container, b as InputTargetSpec, bn as Graphics, c as LoaderPlugin, cn as CustomPassObject, d as SceneCtor, dn as DisplayList, en as StageRenderTarget, f as SceneInput, fn as DisplayObject, g as ViewportFitResult, gn as DrawStreamObject, h as StageRenderer, hn as DrawStreamBulkView, i as GameConfig$1, in as Bob$1, j as createInputReplay, jn as RectangleObject, jt as SceneDigestSandbox, k as TimelineKeyOptions, kn as PanelStyleConfig, kt as SceneDigestOptions, l as ScaleManager, ln as CustomPassOptions, m as SceneManager, mn as DisplaySemantics, n as EngineClockSnapshot, nn as BindEquipmentOptions, o as GameObjectFactory, on as ContainerFiltersShim, p as SceneLifecycleStats, pn as DisplayObjectType, qt as WebGpuDeviceLike, r as Game, rn as BlitterObject, s as JsonCache, sn as CustomPassCallback, t as EngineClock, tn as AnchorPose2D, u as Scene, un as DirectionalPlayOptions, v as InputProvider, vn as DrawStreamSpriteOptions, w as StageInputEvent, wn as MsdfIconConfig, x as InputTimelineOptions, xn as ImageObject, y as InputRecorderPlugin, yn as EquipmentBinding, zn as SyncAttachmentOptions, zt as KeyboardPlugin } from "./game-COsuqGzC.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-BYBzSNXO.js";
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-C8bz7tay.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-n8aqhzxu.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";
@@ -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,8 +1,8 @@
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-2dS3Qsrn.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-CziLa7dv.js";
3
3
  import { AnimationManager } from "./anims.js";
4
- import { i as Camera, n as requestWebGpuDevice, r as Renderer2D, t as RendererWebGpu } from "./renderer-webgpu-CHJxmCvR.js";
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";
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-LDnrpYa0.js";
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";
8
8
  import { computeFlexLayout, computeWrapLayout, flattenFlexTree, mountFlexUi, resolvePadding } from "./flex.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 };
@@ -1,4 +1,4 @@
1
- import { Bt as Pointer, Dn as PanelObject, an as Container, u as Scene } from "./game-COsuqGzC.js";
1
+ import { Bt as Pointer, Fn as PanelObject, pn as Container, u as Scene } from "./game-C8bz7tay.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-COsuqGzC.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-C8bz7tay.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 };
@@ -1,4 +1,4 @@
1
- import { Mn as SceneHostLike, an as Container, cn as CustomPassObject, fn as DisplayObject, xn as ImageObject } from "./game-COsuqGzC.js";
1
+ import { Bn as SceneHostLike, bn as DisplayObject, gn as CustomPassObject, kn as ImageObject, pn as Container } from "./game-C8bz7tay.js";
2
2
  export type DayPhase = 'day' | 'dusk' | 'night';
3
3
  export interface DayNightConfig {
4
4
  dayLengthMs?: number;
package/dist/lighting.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { m as createMatrix2D, o as FilterMode, r as BlendModes } from "./types-CXsCvp1p.js";
2
- import { l as InstancedBatchObject } from "./display-CuyQc8oE.js";
2
+ import { l as InstancedBatchObject } from "./display-CVjvA8ZO.js";
3
3
  // src/lighting.ts
4
4
  function lerpChannel(a, b, t) {
5
5
  return Math.round(a + (b - a) * t) & 255;
@@ -984,7 +984,10 @@ function createSceneNormalLitPass(scene, opts) {
984
984
  if (!scene.textures.exists(normKey)) return;
985
985
  const normTex = scene.textures.get(normKey);
986
986
  const diffGl = glRenderer.ensureGlTexture(fr.source);
987
- const normGl = glRenderer.ensureGlTexture(normTex.source[0]);
987
+ const normFrame = normTex.has(fr.name) ? normTex.get(fr.name) : null;
988
+ const normSrc = normFrame ? normFrame.source : normTex.source[fr.sourceIndex] ?? normTex.source[0];
989
+ if (!normSrc) return;
990
+ const normGl = glRenderer.ensureGlTexture(normSrc);
988
991
  if (!diffGl || !normGl) return;
989
992
  if (diffGl !== curDiffGl || normGl !== curNormGl) {
990
993
  flushBatch();
@@ -1,4 +1,4 @@
1
- import { Mn as SceneHostLike, an as Container, fn as DisplayObject } from "./game-COsuqGzC.js";
1
+ import { Bn as SceneHostLike, bn as DisplayObject, pn as Container } from "./game-C8bz7tay.js";
2
2
  export interface Camera25DConfig {
3
3
  viewportWidth: number;
4
4
  viewportHeight: number;