@moku-labs/game 0.15.123 → 0.15.125

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.
@@ -1,7 +1,7 @@
1
- import { Bn as NodeTable, Ir as ClockSource, Jn as Hint, Mn as FeaturePlugin, Pn as AnyFlow, Rr as FakeClock, Wn as Descriptor, Wr as Json, Yn as NodeFx } from "./types-B6H9yr9N.mjs";
2
- import { t as createApp } from "./index-BZCgS_Mn.mjs";
3
- import { b as memory, x as saveOf, y as WithGameState } from "./types-DywIk6LN.mjs";
4
- import { a as createHeadless, i as ReproResult, n as HeadlessGame, o as runRepro, r as Repro, s as stepFrames, t as HeadlessApp } from "./headless-DOX90jck.mjs";
1
+ import { Bn as NodeTable, Ir as ClockSource, Jn as Hint, Mn as FeaturePlugin, Pn as AnyFlow, Rr as FakeClock, Wn as Descriptor, Wr as Json, Yn as NodeFx } from "./types-sfPTACpA.mjs";
2
+ import { t as createApp } from "./index-DmOlNphG.mjs";
3
+ import { b as memory, x as saveOf, y as WithGameState } from "./types-BZsooAhi.mjs";
4
+ import { a as createHeadless, i as ReproResult, n as HeadlessGame, o as runRepro, r as Repro, s as stepFrames, t as HeadlessApp } from "./headless-T-UG6gZ4.mjs";
5
5
  import { AnyPluginInstance } from "@moku-labs/core";
6
6
 
7
7
  //#region src/plugins/clock/fake.d.ts
package/dist/testing.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { dn as refuseStart, gn as type, pn as exit, t as createApp, w as flattenFeatures } from "./src-BqnQLXSV.mjs";
1
+ import { dn as refuseStart, gn as type, pn as exit, t as createApp, w as flattenFeatures } from "./src-Bfie_HWL.mjs";
2
2
  import { n as saveOf, t as memory } from "./memory-DeD9wis6.mjs";
3
3
  import { n as fakeClock } from "./fake-hnJcJeYf.mjs";
4
4
  import { i as stepFrames, r as runRepro, t as createHeadless } from "./headless-CCiUwvlp.mjs";
@@ -1,7 +1,7 @@
1
- import { $ as Config$2, Hr as Config, Ir as ClockSource, Mn as FeaturePlugin, Pn as AnyFlow, Rr as FakeClock, Un as TypeTag, Wr as Json, Xr as ProviderCall, Yr as PlayerStateProvider, Zr as SaveDoc, _t as Orientation, a as Config$3, d as Manifest, ei as SnapshotOf, gn as Config$1, it as PixiModule, n as AssetsIo } from "./types-B6H9yr9N.mjs";
2
- import { o as AudioContextLike, s as Config$4 } from "./types-C0eMpuaq.mjs";
3
- import { J as StringTable, U as I18nApi, Y as TextKey } from "./types-BDx3KRoA.mjs";
4
- import { Et as PlatformProvider, It as audioPlugin, Nt as effectsPlugin, i as screen, t as createApp, wt as platformPlugin } from "./index-BZCgS_Mn.mjs";
1
+ import { $ as Config$2, Hr as Config, Ir as ClockSource, Mn as FeaturePlugin, Pn as AnyFlow, Rr as FakeClock, Un as TypeTag, Wr as Json, Xr as ProviderCall, Yr as PlayerStateProvider, Zr as SaveDoc, _t as Orientation, a as Config$3, d as Manifest, ei as SnapshotOf, gn as Config$1, it as PixiModule, n as AssetsIo } from "./types-sfPTACpA.mjs";
2
+ import { o as AudioContextLike, s as Config$4 } from "./types-CJu46Hbe.mjs";
3
+ import { J as StringTable, U as I18nApi, Y as TextKey } from "./types-Dd2UJzHY.mjs";
4
+ import { Et as PlatformProvider, It as audioPlugin, Nt as effectsPlugin, i as screen, t as createApp, wt as platformPlugin } from "./index-DmOlNphG.mjs";
5
5
  import { AnyPluginInstance } from "@moku-labs/core";
6
6
 
7
7
  //#region src/plugins/model/store/providers/memory.d.ts
@@ -1,5 +1,5 @@
1
- import { A as FilterSlotInputs, Ar as Api$3, M as SyncApi, Q as Api$4, Qn as AnchorTarget, Un as TypeTag, Ur as Events$3, Vr as Api$6, Wn as Descriptor, Wr as Json, ar as NumericFields, at as PixiSprite, b as Events$4, bi as Require, br as Entity, bt as FilterCache, cr as ReducedMotion, dr as TrackSegment, gr as ComponentHandle, hr as AnyComponentValue, ir as MotionHandle, it as PixiModule, j as FilterSlotQuad, k as FilterSlot, mn as Api$2, nt as PixiFilter, oi as Events$5, ot as PixiTexture, pr as AnyComponent, rt as PixiGpuProgram, s as Events$1, st as PixiUniformGroup, t as Api$5, tr as Ease, ui as Api$1, ur as TrackOptions, vr as ComponentType, vt as Point, yi as Events$2 } from "./types-B6H9yr9N.mjs";
2
- import { R as InputApi, T as TextApi, U as I18nApi, c as UiNode, i as Finding, l as LayoutState, n as ElementChange, o as JsxState, r as ElementMotion, tt as StylesState } from "./types-BDx3KRoA.mjs";
1
+ import { A as FilterSlotInputs, Ar as Api$3, M as SyncApi, Q as Api$4, Qn as AnchorTarget, Un as TypeTag, Ur as Events$3, Vr as Api$6, Wn as Descriptor, Wr as Json, ar as NumericFields, at as PixiSprite, b as Events$4, bi as Require, br as Entity, bt as FilterCache, cr as ReducedMotion, dr as TrackSegment, gr as ComponentHandle, hr as AnyComponentValue, ir as MotionHandle, it as PixiModule, j as FilterSlotQuad, k as FilterSlot, mn as Api$2, nt as PixiFilter, oi as Events$5, ot as PixiTexture, pr as AnyComponent, rt as PixiGpuProgram, s as Events$1, st as PixiUniformGroup, t as Api$5, tr as Ease, ui as Api$1, ur as TrackOptions, vr as ComponentType, vt as Point, yi as Events$2 } from "./types-sfPTACpA.mjs";
2
+ import { R as InputApi, T as TextApi, U as I18nApi, c as UiNode, i as Finding, l as LayoutState, n as ElementChange, o as JsxState, r as ElementMotion, tt as StylesState } from "./types-Dd2UJzHY.mjs";
3
3
  import { Log } from "@moku-labs/common/browser";
4
4
  import { PluginCtx } from "@moku-labs/core";
5
5
 
@@ -1,5 +1,5 @@
1
- import { $r as Snapshot, Wr as Json } from "./types-B6H9yr9N.mjs";
2
- import { t as HeadlessApp } from "./headless-DOX90jck.mjs";
1
+ import { $r as Snapshot, Wr as Json } from "./types-sfPTACpA.mjs";
2
+ import { t as HeadlessApp } from "./headless-T-UG6gZ4.mjs";
3
3
  import { Log } from "@moku-labs/common/browser";
4
4
 
5
5
  //#region src/plugins/flow/doors/types.d.ts
@@ -1,4 +1,4 @@
1
- import { $n as ChangeHook, Ar as Api$2, D as AxisPose, Fr as Api$5, Jn as Hint, Q as Api$3, Qn as AnchorTarget, Wn as Descriptor, Wr as Json, Y as TransformValue, Zn as Answered, ar as NumericFields, bi as Require, br as Entity, cr as ReducedMotion, fr as ViewHandle, hr as AnyComponentValue, ir as MotionHandle, it as PixiModule, kr as TagType, mn as Api$1, mr as AnyComponentType, nr as Motion, or as ProjectionMotion, pr as AnyComponent, rr as MotionCause, s as Events$1, t as Api$4, tr as Ease, tt as PixiContainer, ui as Api, vr as ComponentType, yt as ViewportSize } from "./types-B6H9yr9N.mjs";
1
+ import { $n as ChangeHook, Ar as Api$2, D as AxisPose, Fr as Api$5, Jn as Hint, Q as Api$3, Qn as AnchorTarget, Wn as Descriptor, Wr as Json, Y as TransformValue, Zn as Answered, ar as NumericFields, bi as Require, br as Entity, cr as ReducedMotion, fr as ViewHandle, hr as AnyComponentValue, ir as MotionHandle, it as PixiModule, kr as TagType, mn as Api$1, mr as AnyComponentType, nr as Motion, or as ProjectionMotion, pr as AnyComponent, rr as MotionCause, s as Events$1, t as Api$4, tr as Ease, tt as PixiContainer, ui as Api, vr as ComponentType, yt as ViewportSize } from "./types-sfPTACpA.mjs";
2
2
  import { Log } from "@moku-labs/common/browser";
3
3
  import { PluginCtx } from "@moku-labs/core";
4
4
  import { Node, Yoga } from "yoga-layout/load";
@@ -8519,7 +8519,9 @@ type HostState = {
8519
8519
  * Run after every successful restore, where `onReady` must not run twice: `rebuilt` is true when a new application
8520
8520
  * replaced the old one (WebGPU), false when a WebGL context came back on the same one.
8521
8521
  */
8522
- onRestore: Array<(rebuilt: boolean) => void>; /** Run before the lost application is destroyed, while its display objects are still alive. */
8522
+ onRestore: Array<(rebuilt: boolean) => void>; /** Asked at every loss whether the page leaves (F189): one that answers true stops the restore. */
8523
+ lossDeciders: Array<(info: LossInfo) => boolean>; /** True once a loss decided that the page reloads: nothing is restored any more. */
8524
+ leaving: boolean; /** Run before the lost application is destroyed, while its display objects are still alive. */
8523
8525
  onLoss: Array<() => void>;
8524
8526
  cleanups: Array<() => void>;
8525
8527
  unsupported: HTMLElement | undefined;
@@ -8684,6 +8686,15 @@ type TextureUsage = {
8684
8686
  targets: number; /** Bytes of the sources the engine keeps as pictures. */
8685
8687
  kept: number;
8686
8688
  };
8689
+ /**
8690
+ * What a `decideLoss` callback hears of a loss: the backend, what the browser said, and the bytes of every texture
8691
+ * source the lost application held (art, targets and kept pictures), measured before it went. Not public.
8692
+ */
8693
+ type LossInfo = {
8694
+ kind: "webgpu" | "webgl";
8695
+ reason: string;
8696
+ textureBytes: number;
8697
+ };
8687
8698
  /**
8688
8699
  * host methods injected into `viewport`, `sync` and `monitor`, and driven by the plugin root. Not
8689
8700
  * public.
@@ -8705,6 +8716,21 @@ type HostInternal = {
8705
8716
  * @param fn - Called after every successful restore, told whether the application is new.
8706
8717
  */
8707
8718
  onRestore(fn: (rebuilt: boolean) => void): void;
8719
+ /**
8720
+ * Subscribes to every loss of the device, after `renderer:device-lost` went out: the callback answers whether the
8721
+ * page leaves (it reloads), and then nothing is restored (F189).
8722
+ *
8723
+ * @param fn - Told what was lost and the texture bytes the lost application held; answers true when the page leaves.
8724
+ */
8725
+ decideLoss(fn: (info: LossInfo) => boolean): void;
8726
+ /**
8727
+ * Tells whether Pixi has a GPU texture for a source on the application that draws now: it uploaded the source, at a
8728
+ * draw or through `initSource`. Reads Pixi's per-renderer slot of the source; allocates nothing.
8729
+ *
8730
+ * @param source - The source.
8731
+ * @returns True when the source is on the GPU of the drawing renderer; false while nothing draws.
8732
+ */
8733
+ onGpu(source: PixiTextureSource): boolean;
8708
8734
  /**
8709
8735
  * Subscribes to the moment just before a lost application is destroyed. This is the last point
8710
8736
  * at which a display object the game owns can be saved out of the tree.
@@ -11646,7 +11672,7 @@ type SliceFrame = {
11646
11672
  * // `assets` decoded a file of a bundle: it uploads it, then the views of the key draw it.
11647
11673
  * const renderer = ctx.require(rendererPlugin);
11648
11674
  * const bitmap = await createImageBitmap(await (await fetch("/assets/board/cell.png")).blob());
11649
- * const texture = renderer.sync.textures.create(bitmap); // texture.width === bitmap.width
11675
+ * const texture = renderer.sync.textures.create(bitmap); // the renderer owns the bitmap now: never read it again
11650
11676
  * renderer.sync.textures.invalidate(["board.cell"]); // the next pass resolves "board.cell" again
11651
11677
  * ```
11652
11678
  */
@@ -11668,7 +11694,8 @@ type TexturesApi = {
11668
11694
  provide(fn: TextureProvider): () => void;
11669
11695
  /**
11670
11696
  * Makes a Pixi texture from a decoded image, so `assets` never imports Pixi. Once uploaded it stays on the GPU until
11671
- * `destroy`: Pixi's collector leaves it alone.
11697
+ * `destroy`: Pixi's collector leaves it alone. The renderer owns an `ImageBitmap` from here on: it closes it once
11698
+ * Pixi has the texture on the GPU (F189), so the caller never uses it again; `destroy` closes one not uploaded yet.
11672
11699
  *
11673
11700
  * @param image - The decoded image.
11674
11701
  * @param options - `nine` is left, top, right and bottom in pixels; it becomes the texture's
@@ -12720,6 +12747,18 @@ type SyncInternal = {
12720
12747
  * @returns True when it uploaded a source in this frame: the frame is then no sample of the adaptive rate.
12721
12748
  */
12722
12749
  uploadStep(): boolean;
12750
+ /**
12751
+ * Frees the decoded images Pixi has on the GPU now (F189), after the stage pass of a drawn frame: each bitmap is
12752
+ * closed and its source gets the 1x1 stand-in. One compare and no allocation while nothing waits.
12753
+ */
12754
+ releaseStep(): void;
12755
+ /**
12756
+ * How many textures hold the stand-in instead of their decoded image: after a lost device they can only come back
12757
+ * with a page reload (F189).
12758
+ *
12759
+ * @returns The count of freed textures still alive.
12760
+ */
12761
+ freedCount(): number;
12723
12762
  /**
12724
12763
  * Subscribes to the end of a warm-up run: the queue became empty (the monitor of an agent build writes the `warm`
12725
12764
  * event line). Emptied by `stopSync`.
@@ -12891,6 +12930,17 @@ type UploadState = {
12891
12930
  done: WeakSet<PixiTextureSource>; /** The one listener on `unload` of every source in `done`. */
12892
12931
  forget(source: PixiTextureSource): void;
12893
12932
  };
12933
+ /**
12934
+ * The decoded images of `textures.create` (F189): a source made from an `ImageBitmap` waits in `pending` until Pixi
12935
+ * has it on the GPU of the drawing renderer; then its bitmap is closed and a 1x1 stand-in takes its place, so no
12936
+ * upload ever reads a closed bitmap (WebGPU throws on one). A freed source cannot be uploaded again: after a lost
12937
+ * device the page reloads. Not public.
12938
+ */
12939
+ type ReleaseState = {
12940
+ /** The sources whose bitmap is still open, in the order they were made. */pending: PixiTextureSource[]; /** The sources that hold the stand-in, until they are destroyed. */
12941
+ freed: Set<PixiTextureSource>; /** The transparent 1x1 image every freed source holds; made at the first release. */
12942
+ standIn: OffscreenCanvas | undefined;
12943
+ };
12894
12944
  /**
12895
12945
  * What a nine-slice view's object offers `sync`, whichever class draws it: Pixi's `NineSliceSprite`, or the engine's
12896
12946
  * rim-only mesh of a `hollow` one (`hollow.ts`). The six numbers rebuild the panel when written, the tint and the
@@ -13157,7 +13207,8 @@ type SyncState = {
13157
13207
  */
13158
13208
  viewlessEntries: boolean; /** The pipeline warm-up (F4). */
13159
13209
  warm: WarmState; /** The texture upload queue (F60). */
13160
- upload: UploadState; /** The class of the rim-only nine-slice (F59), made at the first hollow view over the loaded Pixi module. */
13210
+ upload: UploadState; /** The decoded images waiting to be freed, and the stand-in the freed ones hold (F189). */
13211
+ release: ReleaseState; /** The class of the rim-only nine-slice (F59), made at the first hollow view over the loaded Pixi module. */
13161
13212
  hollowClass: HollowClass | undefined;
13162
13213
  /**
13163
13214
  * The kind of each Pixi filter a slot named, for the performance log of an agent build; a
@@ -1,9 +1,9 @@
1
- import { Ar as Api$1, Fr as Api$4, Q as Api, Vr as Api$2, ii as Api$3 } from "./types-B6H9yr9N.mjs";
2
- import { W as AnimApi, r as UiApi } from "./types-C0eMpuaq.mjs";
3
- import { R as InputApi } from "./types-BDx3KRoA.mjs";
4
- import { r as Repro } from "./headless-DOX90jck.mjs";
5
- import { i as ControlApp, o as InputOf } from "./types-BV0HvdUr.mjs";
6
- import { t as commands } from "./commands-DeBQ0y5y.mjs";
1
+ import { Ar as Api$1, Fr as Api$4, Q as Api, Vr as Api$2, ii as Api$3 } from "./types-sfPTACpA.mjs";
2
+ import { W as AnimApi, r as UiApi } from "./types-CJu46Hbe.mjs";
3
+ import { R as InputApi } from "./types-Dd2UJzHY.mjs";
4
+ import { r as Repro } from "./headless-T-UG6gZ4.mjs";
5
+ import { i as ControlApp, o as InputOf } from "./types-D8dMREkO.mjs";
6
+ import { t as commands } from "./commands-Dl7YWA7h.mjs";
7
7
 
8
8
  //#region src/visual/types.d.ts
9
9
  /** The base commands of the `/control` door, keyed by their short names. */
package/dist/visual.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as VisualApp, c as VisualRenderer, d as VisualStart, f as VisualStep, h as VisualTolerance, i as CheckpointResult, l as VisualReport, m as VisualTestResult, n as runVisualTests, o as VisualOptions, p as VisualTest, r as defineVisualTest, s as VisualPage, t as parseVisualArgv, u as VisualSetup } from "./visual-BfN0ONFr.mjs";
1
+ import { a as VisualApp, c as VisualRenderer, d as VisualStart, f as VisualStep, h as VisualTolerance, i as CheckpointResult, l as VisualReport, m as VisualTestResult, n as runVisualTests, o as VisualOptions, p as VisualTest, r as defineVisualTest, s as VisualPage, t as parseVisualArgv, u as VisualSetup } from "./visual-Bk1ph3gC.mjs";
2
2
  export { type CheckpointResult, type VisualApp, type VisualOptions, type VisualPage, type VisualRenderer, type VisualReport, type VisualSetup, type VisualStart, type VisualStep, type VisualTest, type VisualTestResult, type VisualTolerance, defineVisualTest, parseVisualArgv, runVisualTests };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moku-labs/game",
3
- "version": "0.15.123",
3
+ "version": "0.15.125",
4
4
  "description": "2D puzzle game engine on TypeScript and PixiJS, built on @moku-labs/core.",
5
5
  "type": "module",
6
6
  "sideEffects": [