@moku-labs/game 0.15.100 → 0.15.102

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.
Files changed (37) hide show
  1. package/dist/app/page.d.mts +4 -3
  2. package/dist/app/page.mjs +73 -4
  3. package/dist/app/system.d.mts +3 -3
  4. package/dist/app.d.mts +3 -3
  5. package/dist/app.mjs +2 -2
  6. package/dist/assets.d.mts +1 -1
  7. package/dist/cli.mjs +1 -1
  8. package/dist/{commands-Da3AUaKC.d.mts → commands-C2JXDkUV.d.mts} +19 -10
  9. package/dist/control.d.mts +10 -6
  10. package/dist/control.mjs +2 -2
  11. package/dist/{define-hPbGjPAY.d.mts → define-DNF9A0ce.d.mts} +2 -2
  12. package/dist/{headless-Co3SEFi5.d.mts → headless-CEG1oR5D.d.mts} +1 -1
  13. package/dist/{index-D5w2xQz0.d.mts → index-DtbI1op8.d.mts} +3 -3
  14. package/dist/index.d.mts +4 -4
  15. package/dist/index.mjs +1 -1
  16. package/dist/inspect.d.mts +6 -6
  17. package/dist/inspect.mjs +2 -2
  18. package/dist/jsx-dev-runtime.d.mts +1 -1
  19. package/dist/jsx-runtime.d.mts +1 -1
  20. package/dist/{memory-CWlqhS7l.mjs → memory-DeD9wis6.mjs} +28 -3
  21. package/dist/{run-B5if0jxE.mjs → run-pCQlIaNP.mjs} +46 -3
  22. package/dist/{runtime-B69fIYx_.d.mts → runtime-CcHPrVBm.d.mts} +1 -1
  23. package/dist/{session-D0AYRm5T.mjs → session-ClUqpGId.mjs} +138 -2
  24. package/dist/{sources-Cqqz-0-b.mjs → sources-BJyIJf_X.mjs} +1 -1
  25. package/dist/{src-tL_KNZE7.mjs → src-CilP057R.mjs} +96 -40
  26. package/dist/testing.d.mts +4 -4
  27. package/dist/testing.mjs +2 -2
  28. package/dist/{types-L3E-YS4N.d.mts → types-C1B7-x7p.d.mts} +1 -1
  29. package/dist/{types-BE6tcAFX.d.mts → types-C612npUH.d.mts} +2 -2
  30. package/dist/{types-BVrpb6HD.d.mts → types-Cdzw3as5.d.mts} +2 -2
  31. package/dist/{types-qCcSw8YI.d.mts → types-Ce5W0gZe.d.mts} +51 -10
  32. package/dist/{types-D0lN1gFj.d.mts → types-IJXSUFJa.d.mts} +4 -4
  33. package/dist/{visual-B10_HmCZ.d.mts → visual-BoSpJLWP.d.mts} +6 -6
  34. package/dist/visual.d.mts +1 -1
  35. package/dist/visual.mjs +2 -2
  36. package/llms.txt +4 -4
  37. package/package.json +1 -1
@@ -1686,10 +1686,12 @@ type ClockSource = {
1686
1686
  */
1687
1687
  now(): number;
1688
1688
  /**
1689
- * Schedules one callback. The plugin keeps at most one timer alive.
1689
+ * Schedules one callback. The plugin keeps at most one timer alive, and never asks for more
1690
+ * than 2^31−1 ms (24.8 days), the most a platform timer keeps: a farther moment is armed again
1691
+ * when this timer fires.
1690
1692
  *
1691
1693
  * @param callback - Function to run when the delay has passed.
1692
- * @param delayMs - Delay in milliseconds, never negative.
1694
+ * @param delayMs - Delay in milliseconds, from 0 to 2^31−1.
1693
1695
  * @returns A handle of any shape; the plugin only hands it back to `clearTimer`.
1694
1696
  */
1695
1697
  setTimer(callback: () => void, delayMs: number): unknown;
@@ -1766,7 +1768,8 @@ type Config$5 = {
1766
1768
  */
1767
1769
  type State$5 = {
1768
1770
  source: ClockSource;
1769
- last: number;
1771
+ last: number; /** Milliseconds `advance` moved the clock forward, added to every reading of the source. */
1772
+ shift: number;
1770
1773
  dueAt: number | undefined;
1771
1774
  handle: unknown;
1772
1775
  listeners: Array<(input: Elapsed) => void>;
@@ -1801,7 +1804,8 @@ type Api$4 = {
1801
1804
  now(): number;
1802
1805
  /**
1803
1806
  * Replaces the single pending due moment. A moment in the past is not delivered synchronously:
1804
- * it fires on the next macrotask of the source.
1807
+ * it fires on the next macrotask of the source. A moment further than 2^31−1 ms (24.8 days) waits
1808
+ * on one timer of that length at a time, armed again until the moment comes.
1805
1809
  *
1806
1810
  * @param moment - Moment in epoch milliseconds, or `undefined` to cancel.
1807
1811
  * @example
@@ -1840,6 +1844,26 @@ type Api$4 = {
1840
1844
  * ```
1841
1845
  */
1842
1846
  poke(): void;
1847
+ /**
1848
+ * Moves the clock forward, as if `ms` passed at once: every later `now()` is `ms` further, and a
1849
+ * pending moment that is due now is delivered at once, before the call returns; one still ahead
1850
+ * waits for the rest. The door `game.clock` calls it, so a visual test or the editor reaches a
1851
+ * moment the rules scheduled without waiting for it. Only forward.
1852
+ *
1853
+ * @param ms - Milliseconds forward, a finite number above 0.
1854
+ * @returns The trusted moment after the move.
1855
+ * @throws {RangeError} `[game] clock.advance moves the clock forward, not by 0 ms.` for 0, a
1856
+ * negative or a number that is not finite.
1857
+ * @example
1858
+ * ```ts
1859
+ * // A board tick is due in 60 s; the visual test moves the clock and the tick arrives.
1860
+ * app.clock.now(); // 1000000000
1861
+ * app.clock.scheduleAt(1_000_060_000);
1862
+ * app.clock.advance(60_000); // 1000060000: onElapsed listeners got { now: 1000060000 }
1863
+ * app.clock.dueAt(); // undefined
1864
+ * ```
1865
+ */
1866
+ advance(ms: number): number;
1843
1867
  /**
1844
1868
  * Reads the pending due moment, for inspection and tests.
1845
1869
  *
@@ -2072,6 +2096,7 @@ type QueryPlan = {
2072
2096
  */
2073
2097
  declare class SystemWalk implements Iterator<readonly unknown[], undefined> {
2074
2098
  private readonly ctx;
2099
+ private readonly hidesAside;
2075
2100
  /** The step handed back for every row: always the one row array. */
2076
2101
  private readonly step;
2077
2102
  /** The one row: the entity, then one stored value per name, sized at registration. */
@@ -2092,13 +2117,17 @@ declare class SystemWalk implements Iterator<readonly unknown[], undefined> {
2092
2117
  private started;
2093
2118
  /** The first store's size at the first step: a dev build compares it; -1 when not watched. */
2094
2119
  private size;
2120
+ /** The entities of the running aside build this run passes over, read at the first step; `undefined` for none. */
2121
+ private aside;
2095
2122
  /**
2096
2123
  * Prepares the walk of one system.
2097
2124
  *
2098
2125
  * @param ctx - Domain context of the world plugin.
2099
2126
  * @param plan - The system's resolved query.
2127
+ * @param hidesAside - True for a feature's system: it passes over the entities of a scene built aside until the
2128
+ * commit (F155).
2100
2129
  */
2101
- constructor(ctx: WorldCtx, plan: QueryPlan);
2130
+ constructor(ctx: WorldCtx, plan: QueryPlan, hidesAside?: boolean);
2102
2131
  /**
2103
2132
  * The walk is its own iterator, so the runner hands it to `run` as the rows. A second loop over
2104
2133
  * it in the same run finds it walked.
@@ -2113,7 +2142,7 @@ declare class SystemWalk implements Iterator<readonly unknown[], undefined> {
2113
2142
  */
2114
2143
  reset(): SystemWalk;
2115
2144
  /**
2116
- * Keeps one key of the first store when the entity carries every other name.
2145
+ * Keeps one key of the first store when the entity carries every other name and is not built aside.
2117
2146
  *
2118
2147
  * @param entity - The key.
2119
2148
  */
@@ -2127,8 +2156,8 @@ declare class SystemWalk implements Iterator<readonly unknown[], undefined> {
2127
2156
  next(): IteratorResult<readonly unknown[], undefined>;
2128
2157
  /**
2129
2158
  * Reads the stores of this run and collects the entities that carry every name, in the first
2130
- * store's order. Structural changes are queued until the phase ends, so the matches stay true
2131
- * while the rows are consumed.
2159
+ * store's order; a feature's system passes over the entities of a scene built aside. Structural
2160
+ * changes are queued until the phase ends, so the matches stay true while the rows are consumed.
2132
2161
  */
2133
2162
  private start;
2134
2163
  /**
@@ -2579,7 +2608,8 @@ type SystemEntry = {
2579
2608
  */
2580
2609
  readonly stores: Array<ComponentStore | undefined>; /** The scenes it runs on, read once at registration; `undefined` for every scene. */
2581
2610
  readonly scenes: readonly string[] | undefined; /** Its last chance to run was skipped: the next run is told so with `resumed`. */
2582
- skipped: boolean;
2611
+ skipped: boolean; /** A feature brought it: its rows pass over the entities of a scene built aside (F155). */
2612
+ readonly hidesAside?: boolean;
2583
2613
  /**
2584
2614
  * The walk of the declared query, made at registration; `undefined` for an empty query, which
2585
2615
  * the runner never walks. An entry built without one gets it on its first run.
@@ -3320,6 +3350,15 @@ type EcsApi = {
3320
3350
  * ecs methods the plugin root calls: frame phases, the owner listener, the clears. Not public.
3321
3351
  */
3322
3352
  type EcsInternal = {
3353
+ /**
3354
+ * Registers a system a feature brought: as `system`, and the rows of its declared `query` pass
3355
+ * over the entities of a scene built aside until the commit (F155). `world.query()`, `get` and
3356
+ * `has` inside its `run` still read them.
3357
+ *
3358
+ * @param definition - The system.
3359
+ * @returns The remover.
3360
+ */
3361
+ featureSystem(definition: AnySystem): () => void;
3323
3362
  /**
3324
3363
  * Registers a listener for `despawnOwnedBy`, so `projection` can drop the views of an owner
3325
3364
  * that left.
@@ -13452,11 +13491,13 @@ type Leaving = {
13452
13491
  outMs: number;
13453
13492
  /**
13454
13493
  * The floor on the swap (F130), for a loader that is on with `holdMs` above 0: the clock moment the swap may happen at,
13455
- * and the frame counter at the look's start. Absent: no floor. `state.leaving` is always the running switch's look
13494
+ * the game time it may happen at (F156: the stepped frames of a visual test move it where the clock stands), and the
13495
+ * frame counter at the look's start. Absent: no floor. `state.leaving` is always the running switch's look
13456
13496
  * (`dropLeftOver` and `leaveFor` keep it so), which is why the build reads it there.
13457
13497
  */
13458
13498
  hold?: {
13459
13499
  until: number;
13500
+ elapsedUntil: number;
13460
13501
  frame: number;
13461
13502
  };
13462
13503
  /**
@@ -1,7 +1,7 @@
1
- import { An as FeaturePlugin, Br as Config, Hr as Json, Ir as FakeClock, Jr as ProviderCall, Mn as AnyFlow, Pr as ClockSource, Q as Config$2, Qr as SnapshotOf, Vn as TypeTag, Yr as SaveDoc, a as Config$3, d as Manifest, ht as Orientation, mn as Config$1, n as AssetsIo, nt as PixiModule, qr as PlayerStateProvider } from "./types-qCcSw8YI.mjs";
2
- import { o as AudioContextLike, s as Config$4 } from "./types-BVrpb6HD.mjs";
3
- import { H as I18nApi, J as TextKey, q as StringTable } from "./types-L3E-YS4N.mjs";
4
- import { Ct as platformPlugin, Ft as audioPlugin, Mt as effectsPlugin, Tt as PlatformProvider, i as screen, t as createApp } from "./index-D5w2xQz0.mjs";
1
+ import { An as FeaturePlugin, Br as Config, Hr as Json, Ir as FakeClock, Jr as ProviderCall, Mn as AnyFlow, Pr as ClockSource, Q as Config$2, Qr as SnapshotOf, Vn as TypeTag, Yr as SaveDoc, a as Config$3, d as Manifest, ht as Orientation, mn as Config$1, n as AssetsIo, nt as PixiModule, qr as PlayerStateProvider } from "./types-Ce5W0gZe.mjs";
2
+ import { o as AudioContextLike, s as Config$4 } from "./types-Cdzw3as5.mjs";
3
+ import { H as I18nApi, J as TextKey, q as StringTable } from "./types-C1B7-x7p.mjs";
4
+ import { Ct as platformPlugin, Ft as audioPlugin, Mt as effectsPlugin, Tt as PlatformProvider, i as screen, t as createApp } from "./index-DtbI1op8.mjs";
5
5
  import { AnyPluginInstance } from "@moku-labs/core";
6
6
 
7
7
  //#region src/plugins/model/store/providers/memory.d.ts
@@ -1,9 +1,9 @@
1
- import { Nr as Api$4, Or as Api$1, Z as Api, ni as Api$3, zr as Api$2 } from "./types-qCcSw8YI.mjs";
2
- import { U as AnimApi, r as UiApi } from "./types-BVrpb6HD.mjs";
3
- import { L as InputApi } from "./types-L3E-YS4N.mjs";
4
- import { r as Repro } from "./headless-Co3SEFi5.mjs";
5
- import { i as ControlApp, o as InputOf } from "./types-BE6tcAFX.mjs";
6
- import { t as commands } from "./commands-Da3AUaKC.mjs";
1
+ import { Nr as Api$4, Or as Api$1, Z as Api, ni as Api$3, zr as Api$2 } from "./types-Ce5W0gZe.mjs";
2
+ import { U as AnimApi, r as UiApi } from "./types-Cdzw3as5.mjs";
3
+ import { L as InputApi } from "./types-C1B7-x7p.mjs";
4
+ import { r as Repro } from "./headless-CEG1oR5D.mjs";
5
+ import { i as ControlApp, o as InputOf } from "./types-C612npUH.mjs";
6
+ import { t as commands } from "./commands-C2JXDkUV.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-B10_HmCZ.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-BoSpJLWP.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/dist/visual.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as VISUAL_CLOCK } from "./fake-hnJcJeYf.mjs";
2
- import { n as read, t as sources } from "./sources-Cqqz-0-b.mjs";
3
- import { n as commands, t as run } from "./run-B5if0jxE.mjs";
2
+ import { n as read, t as sources } from "./sources-BJyIJf_X.mjs";
3
+ import { n as commands, t as run } from "./run-pCQlIaNP.mjs";
4
4
  import path from "node:path";
5
5
  import { createBrandConsole } from "@moku-labs/common/cli";
6
6
  import { mkdir, readFile, writeFile } from "node:fs/promises";
package/llms.txt CHANGED
@@ -12,7 +12,7 @@ Facts: Bun only. ESM only. `"sideEffects"` lists the root entry `./dist/index.mj
12
12
  - `@moku-labs/game/app/system` (the browser, the native shell): `systemShellOf`, `fromSystem`, `storeSave`, `createSystemApp`, the type `SystemModules`, over the optional peer `@moku-labs/system`. The one entry that names it, in types only: the page hands it the loaders.
13
13
  - `@moku-labs/game/cli` (node and bun only): `runCli`, the bin `moku-game`, `preparePage`, the editor's dev page, `watchKeys`, the watch that keeps `generated/` fresh next to it, and `watchEngine`, the watch that tells when the installed engine changed.
14
14
  - `@moku-labs/game/testing`: headless play, repro runs, isolated feature tests (`isolate`, `stub`), fake clock, the `fx` of a node for a unit test (`fakeFx`), in-memory save provider. No `node:` import.
15
- - `@moku-labs/game/visual` (node and bun only): the visual tests `defineVisualTest`, `runVisualTests`, `parseVisualArgv`. The bin runs them: `moku-game visual`. A step is a `/control` command or `{ checkpoint: name, finish?: boolean }`: a checkpoint lands every motion before its snapshot, `finish: false` keeps them running (same frames in both legs). Both legs run on one clock: the pixel leg's dev page runs on a fake clock at the headless app's `clock.now()` (`startMoment`), standing still like the headless one.
15
+ - `@moku-labs/game/visual` (node and bun only): the visual tests `defineVisualTest`, `runVisualTests`, `parseVisualArgv`. The bin runs them: `moku-game visual`. A step is a `/control` command or `{ checkpoint: name, finish?: boolean }`: a checkpoint lands every motion before its snapshot, `finish: false` keeps them running (same frames in both legs). Both legs run on one clock: the pixel leg's dev page runs on a fake clock at the headless app's `clock.now()` (`startMoment`), standing still like the headless one. Frames move game time, not that clock: the step `{ clock: { advanceMs } }` moves it (`clock.advance`), so a moment armed with `schedule` comes due (F157). A floor on a scene swap (`loader.holdMs`) also passes in game time, so an `answer` that switches the scene settles in the pixel leg (F156).
16
16
  - `@moku-labs/game/assets` (node and bun only): the asset key scanner, the production packer and the string compiler. The package bin `moku-game-assets` runs it.
17
17
  - `@moku-labs/game/inspect`: the read door of the editor, safe in a production build. See "Doors for the editor".
18
18
  - `@moku-labs/game/control`: the write door of the editor, dev builds only. See "Doors for the editor".
@@ -558,12 +558,12 @@ The graph. Modules `runner`, `gate`, `inbox`, `fx`, `features`. Runner methods s
558
558
  ### Screen plugins (V2, built)
559
559
 
560
560
  `world`, `renderer`, `input`, `assets`, `scenes`. Each has a README at `src/plugins/<name>/README.md`; the root README lists their APIs, events and config. Rendering: WebGPU preferred, with Pixi's WebGL fallback.
561
- - `app.scenes`: `current()` the mounted scene id, `expect(id)` the scene the next node without its own `scene` mounts, a rest node or a transit node in live mode (the restore door calls it; an unknown id throws). An `over` node takes it the same way, also over another mounted scene. A live switch, before it builds the scene, warms the bundles the scene names (`assets.warm`): their textures go to the GPU `renderer.uploads` a drawn frame while the old scene is still up, so the first frame of the new scene uploads none of them; textures already there are not waited for, and a fast walk or a headless app never waits. A bundle the scene does not name (a `core` bundle of portraits the board shows) is not warmed: name it in the scene's `bundles` or call `app.assets.warm`. Then, with a drawing renderer, the next scene is built aside: its ui elements are made by root and by part, laid out once and applied in parts, and the renderer makes its Pixi views, over the next frames off the stage in a budget per frame, config `scenes.buildMs: number | "auto"` (default `"auto"`, two thirds of the frame interval: 11.1 ms at 60 Hz, 5.56 ms at 120 Hz; `0` throws), and it is swapped in one frame. Until the swap `current()` answers the old scene, nothing of the new one is drawn, hit or found by `ui.find`, its `enter` motions wait and the gate stays closed, so the first tap lands on a complete scene; `scenes:changed` is emitted at the swap. A fast walk, a world that is not live and a headless app mount in one block as before. Over the scene being left, a live switch shows the look of `scenes.leave` (a veil, and a loader once the switch is not done `afterMs` after its start); the veil goes up at the node's `"begin"` stage, before `assets` downloads the coming scene at `"load"`, so a cold first visit reacts in the next frame.
561
+ - `app.scenes`: `current()` the mounted scene id, `expect(id)` the scene the next node without its own `scene` mounts, a rest node or a transit node in live mode (the restore door calls it; an unknown id throws). An `over` node takes it the same way, also over another mounted scene. A live switch, before it builds the scene, warms the bundles the scene names (`assets.warm`): their textures go to the GPU `renderer.uploads` a drawn frame while the old scene is still up, so the first frame of the new scene uploads none of them; textures already there are not waited for, and a fast walk or a headless app never waits. A bundle the scene does not name (a `core` bundle of portraits the board shows) is not warmed: name it in the scene's `bundles` or call `app.assets.warm`. Then, with a drawing renderer, the next scene is built aside: its ui elements are made by root and by part, laid out once and applied in parts, and the renderer makes its Pixi views, over the next frames off the stage in a budget per frame, config `scenes.buildMs: number | "auto"` (default `"auto"`, two thirds of the frame interval: 11.1 ms at 60 Hz, 5.56 ms at 120 Hz; `0` throws), and it is swapped in one frame. Until the swap `current()` answers the old scene, nothing of the new one is drawn, hit or found by `ui.find`, the rows of a feature's system pass over its entities (a system without `scenes` sees the new scene whole from the commit frame, F155), its `enter` motions wait and the gate stays closed, so the first tap lands on a complete scene; `scenes:changed` is emitted at the swap. A fast walk, a world that is not live and a headless app mount in one block as before. Over the scene being left, a live switch shows the look of `scenes.leave` (a veil, and a loader once the switch is not done `afterMs` after its start); the veil goes up at the node's `"begin"` stage, before `assets` downloads the coming scene at `"load"`, so a cold first visit reacts in the next frame.
562
562
  - `Shape({ kind, w, h, fill, fillAlpha, alpha, radius, stroke, strokeWidth, dash, clip, sweep?, cap? })` (`kind: "rect"`; `sweep` and `cap` are optional, `1` and `"round"` when left out; only an arc reads them; a rectangle or a triangle ignores them, also when an earlier arc left them on the `Shape`): a rounded rectangle, `kind: "triangle"` (fills its box pointing right) or `kind: "arc"`: a stroke on the circle inscribed in the box (`min(w, h) − strokeWidth` across, centred) from 12 o'clock clockwise over `sweep` (0..1, clamped; 0 draws nothing, 1 a closed ring), ended by `cap` (`"round" | "butt"`); an arc draws no fill and ignores `radius` and `dash`. The path is built again only when a field changes: a still arc costs nothing a frame. `Shape({ kind: "arc", w: 28, h: 28, stroke: 0xc8a15a, strokeWidth: 2.2, sweep: 0.42 })` is a slot timer's ring with 42 % left.
563
563
  - Overlays: `Overlay({ dim, dimColor, cover, hud, fade, hold })` on the root of an overlay (in `components`) keeps everything drawn before it as one picture, retaken in the frame anything in it changes, and with `cover: "opaque"` draws none of it once landed at alpha 1; `hold: true` (default `false`) holds the endless loops under it while it stands, as under a cover or a blurred picture (their phase follows time), so a dimmed sheet over a sharp scene draws no frame at rest; the engine draws the dim (`dim × level`, right under the root); the level follows the root's own enter and exit motion, `fade` (250 ms) only when it has none; level and landing are read through `app.renderer.sync.debug.overlays()`. A `backdrop: true` filter inside the kept range runs no pass while the picture stands (its look is in the picture) and is drawn again in the frame the overlay is gone. Types: `OverlayValue` (the component's value) and `HudPartValue` (a part of the HUD an overlay keeps shown or lets fade).
564
564
  - HUD: a scene layer `{ above: "overlays" }` is the HUD layer, drawn above every overlay and never in a picture; a scene with a HUD layer and no `ui` gets `ui` right under it. Its roots never take the keyboard: Escape and the Back press reach the top sheet under it. `HudPart({ key })` tags a HUD view; an overlay's `hud` (`"all"`, `"none"` or keys) names the parts that stay shown, the others fade with its level and take no tap. `hud: "under"` draws the whole HUD layer under the overlay's own dim instead, dimmed with the rest (one Pixi `RenderLayer` right before the dim; the HUD and the veil each drawn once): `Overlay({ dim: 0.82, dimColor: 0x1e161a, hud: "under" })`. While held the HUD takes no tap; the topmost such overlay holds it, and a sheet without `"under"` over it shows the HUD above again until it goes; with `dim: 0` it is `"all"`. Keys are typed by `defineGame<{ …, hud: "energy" | "gems" }>()`.
565
565
  - Endless loops of views under an opaque or blurred overlay write nothing (`renderer.sync.loopsHeld(entity)`, the seam anim asks before an endless loop writes); their phase follows time.
566
- - Scene switch look: from the start of a live switch (before its bundles and textures are awaited) the renderer draws a veil over the scene being left, above every layer, and, when the switch is not done `afterMs` after its start, a loader above it until the swap; then the veil fades out over the new scene. Config `scenes.leave` (default `{ cover: { color: 0x000000, alpha: 0.45, inMs: 50, outMs: 150 }, loader: { afterMs: 400 } }`) and a scene's `leave` (`defineScene("ward", { ..., leave: false })`) are merged field by field (the scene being left decides; `false` turns a part or the whole off); the loader is the engine's white ring, `loader: { texture: "ui.loader.ring" }` a game texture turning, or `loader: { projection: "loading" }` a projection in a layer of its own the scene declares (no other projection of the scene may draw there), kept built and hidden while the scene stands and shown once the loader is due; `scenes` feeds that loader the switch (`projection.feed`), so its `from(player, session, sw)` reads a `SceneSwitch`: `{ from: "ward", to: "ward", progress: 0 }` while the ward stands, then `{ from: "ward", to: "board", progress }`, the share of the board's bundles loaded (from `assets:bundle-progress`; a bundle loaded at the start or once the scene stage has its loads counts whole), 0 to 1 in steps of 0.01, the last exactly 1; `loader: { holdMs: 260 }` (default 0) is a floor on the swap: the next scene builds at once and the old one stays until 260 ms after the switch start and one drawn frame of the look, so a switch slower than it gets nothing added; an abort or a throw drops both at once; fast walks, a world that is not live, headless apps and the first scene show nothing and hold nothing. The scene being entered sets the veil's colour and alpha: `defineScene("night", { ..., enter: { cover: { color: 0x0b1020, alpha: 0.7 } } })` wins over what the scene being left resolved, field by field; `inMs`/`outMs` stay the left scene's and a veil turned off stays off. Types `SceneLeave`, `SceneCover`, `SceneLoader`, `SceneEnter` (`Scenes`).
566
+ - Scene switch look: from the start of a live switch (before its bundles and textures are awaited) the renderer draws a veil over the scene being left, above every layer, and, when the switch is not done `afterMs` after its start, a loader above it until the swap; then the veil fades out over the new scene. Config `scenes.leave` (default `{ cover: { color: 0x000000, alpha: 0.45, inMs: 50, outMs: 150 }, loader: { afterMs: 400 } }`) and a scene's `leave` (`defineScene("ward", { ..., leave: false })`) are merged field by field (the scene being left decides; `false` turns a part or the whole off); the loader is the engine's white ring, `loader: { texture: "ui.loader.ring" }` a game texture turning, or `loader: { projection: "loading" }` a projection in a layer of its own the scene declares (no other projection of the scene may draw there), kept built and hidden while the scene stands and shown once the loader is due; `scenes` feeds that loader the switch (`projection.feed`), so its `from(player, session, sw)` reads a `SceneSwitch`: `{ from: "ward", to: "ward", progress: 0 }` while the ward stands, then `{ from: "ward", to: "board", progress }`, the share of the board's bundles loaded (from `assets:bundle-progress`; a bundle loaded at the start or once the scene stage has its loads counts whole), 0 to 1 in steps of 0.01, the last exactly 1; `loader: { holdMs: 260 }` (default 0) is a floor on the swap: the next scene builds at once and the old one stays until 260 ms after the switch start (on the clock or in game time, whichever passes first, so a visual test's stepped frames pass it while its fake clock stands, F156) and one drawn frame of the look, so a switch slower than it gets nothing added; an abort or a throw drops both at once; fast walks, a world that is not live, headless apps and the first scene show nothing and hold nothing. The scene being entered sets the veil's colour and alpha: `defineScene("night", { ..., enter: { cover: { color: 0x0b1020, alpha: 0.7 } } })` wins over what the scene being left resolved, field by field; `inMs`/`outMs` stay the left scene's and a veil turned off stays off. Types `SceneLeave`, `SceneCover`, `SceneLoader`, `SceneEnter` (`Scenes`).
567
567
  - A scene names bundles on top of its `bundle` from the committed state: `defineScene("ward", { bundle: "episodes-kit", bundles: ({ session }) => [session.episode], layers: {}, projections: [wardRoom] })`. `bundles` is read each time a node enters the scene, and every way in (a live entry, a restore, the `safeNode` recovery) waits for all of them before the scene is mounted and the node's gate opens. The keys are `BundleKey`s of `generated/assets.ts`.
568
568
  - `app.assets`: `load(bundle)`, `warm(bundle)` (loads it if needed, then puts its textures and atlas pages on the GPU through `renderer.sync.textures.upload`, `renderer.uploads` a drawn frame; joins a running or finished warm; an unload forgets it; resolves also when the renderer could not upload; headless at once), `unload(bundle)`, `isLoaded(bundle)`, `has(bundle)` (the manifest carries it, loaded or not), `texture(key)`, `font(key)`, `audio(key)`, `usage()`. Per bundle in a feature's `assets.ts`: `defineBundles({ ep01: { tier: "feature", release: "leave", mipmaps: ["items/**"] } })`. `release: "leave"` also unloads the bundle, with reason `"leave"`, at the next rest once nothing holds it: not pinned by the node entered, not named by the mounted scene, no node of its feature on the stack; a bundle the outgoing scene named leaves one rest later. The default `"budget"` leaves only under the texture budget. `mipmaps` (`true` or globs relative to `assets/`) uploads the textures with their full chain; such a texture stays loose in a pack. A sub-feature with resources gets its own bundles, named like its folder, with `dir` and `parent` in the manifest; a code-only one has none. The effect `ready(bundle | bundles)` (root export, also from `defineGame`) lets a node rest on a load and stay answerable: its handler (fast mode too) answers `true` headless, throws for an unknown bundle, answers `true` when every bundle is loaded and warmed or its last warm failed (`ctx.log.warn("assets:ready-failed", { bundle, error })`, cleared by a later successful load), otherwise starts `warm` for what is missing, answers `false` and posts `{ type: "ready" }` into `flow.inbox` once all of it settled. Recipe: a rest node `inbox: ["elapsed", "ready"]` with outcomes `ready` and `back`, and a transit node `if ((await fx(ready(list))) === false) return out.wait();`. `companions.add({ load(bundle), unload(bundle) })` adds what loads and unloads with every bundle; `i18n` adds the strings of a sub-feature that way, only when `assets` is composed. Events `assets:bundle-loaded`, `assets:bundle-progress`, `assets:bundle-unloaded` (`reason: "budget" | "request" | "leave"`), `assets:replaced` (dev). Config: `manifest`, `textureBudgetMb: 192`, `preloadDepth: 2`, `baseUrl`, `io`.
569
569
  - `resource(name, defaults)` clones plain JSON defaults into every world. `resource(name, () => value)` calls the factory once per world on first read, so the value may hold a `Map` or a function: `const Looks = resource("boardLooks", () => ({ shown: new Map<World.Entity, { look: string }>() }))`. A system keeps its own state there; `snapshot()` leaves a value that is not JSON out.
@@ -703,7 +703,7 @@ A plugin that owns a resource stores it in its state and frees it in `onStop: ({
703
703
  Two subpaths, neither on the root (V4). An editor, MCP tools and e2e scripts reach a running game through them; `docs/doors.md` in the engine repository has the full catalogue.
704
704
 
705
705
  - `@moku-labs/game/inspect`: `read(app, source, input?)` reads once; `watch(app, source, input, fn)` reads on the `signals` phase when the source changes and returns the stop function; `defineSource`; the frozen catalogue `sources`; the types `Source`, `InputSchema`, `InputOf`. Every source only reads, so the door is safe in a production build. Keys of `sources`: `graph`, `position`, `history`, `tainted`, `cheats`, `model`, `entities`, `projections`, `ui`, `locate`, `render`, `sounds`, `audioMuted`, `effects`, `filters`, `assets`, `log`, `explain`, `diff`, `schema`, `at`; their ids are `game.<key>`. `filters` answers `{ kinds, off }` of `effects.diagnostics`. `locate` takes `{ key }` (a ui element) or `{ target }` (a view by projection key) and answers its box in CSS px, the numbers Playwright clicks. `at` takes `{ x, y }` in CSS px and lists the views under that point, topmost first. `explain` takes `{ entity }` and answers that entity in full, `undefined` for a stale id. `diff` takes `{ from, to }` frames and answers what changed per entity; it throws in a production build and for a frame outside the last 120. `schema` lists every component and tag type the world met, with the JSON kind of each field. `audioMuted` answers whether the master bus is muted. `sounds` throws `[game] The source game.sounds needs audioPlugin.`, `audioMuted` throws `[game] The source game.audioMuted needs audioPlugin.` and `effects` and `filters` throw `[game] The source game.effects needs effectsPlugin.` (`game.filters` for `filters`) when that plugin is not installed; the editor lists such a source as not installed.
706
- - `@moku-labs/game/control`: `run(app, command, input?)` resolves `{ value, state }`, `state` being `{ path, frame, tainted }`; `defineCommand`; `controlRefused`; `controlReadOnly`; the frozen catalogue `commands`; the types `Command`, `ChoiceInput`, `Ran`, `ControlReadOnlyError`. Keys of `commands`: `answer`, `tap`, `drag`, `key`, `fill`, `scroll`, `walk`, `bookmark`, `restore`, `saveExport`, `saveImport`, `step`, `pause`, `resume`, `capture`, `debug`, `reducedMotion`, `timeScale`, `frameRate`, `mute`, `trace`, `filter`. `capture` resolves `{ png }`, and `{ png, legend }` with `legend: true`; `undefined` while the renderer is inert. `timeScale` takes `{ scale }`; 0 freezes game time while the frames keep running. `frameRate` takes `{ fps? }`, calls `time.setRate(fps ?? "auto")` and answers `time.rate()`. `mute` takes `{ muted }`, mutes the master bus and answers the flag. Without `audioPlugin` it throws `[game] The command game.mute needs audioPlugin.` `trace` takes `{ path }`, a list of views by projection key, and answers whether the gate took the answer. `scroll` takes `{ key, to }`, calls `ui.scroll(key, to)` and answers what it answers; a visual test writes it as the step `{ scroll: { key, to } }`. `filter` takes `{ kind, on }`, switches the filter kind through `effects.diagnostics` (cosmetic) and answers the off kinds; an unknown kind throws `[game] No filter kind "fx.nope".` naming the known ones; without `effectsPlugin` it throws `[game] The command game.filter needs effectsPlugin.`
706
+ - `@moku-labs/game/control`: `run(app, command, input?)` resolves `{ value, state }`, `state` being `{ path, frame, tainted }`; `defineCommand`; `controlRefused`; `controlReadOnly`; the frozen catalogue `commands`; the types `Command`, `ChoiceInput`, `Ran`, `ControlReadOnlyError`. Keys of `commands`: `answer`, `tap`, `drag`, `key`, `fill`, `scroll`, `walk`, `bookmark`, `restore`, `saveExport`, `saveImport`, `step`, `clock`, `pause`, `resume`, `capture`, `debug`, `reducedMotion`, `timeScale`, `frameRate`, `mute`, `trace`, `filter`. `run` checks the input against the command's schema first (F154): an unknown field, a required field left out and a value of another kind (a `number` must be finite) throw `[game] The command game.scroll got the field "dy", which it does not take.` with the fields it takes, and nothing runs. `clock` takes `{ advanceMs }` (cheat), calls `clock.advance(advanceMs)` and answers `{ now }`: a moment armed with `clock.scheduleAt` that is due arrives as `elapsed`; a visual test writes it as the step `{ clock: { advanceMs: 60_000 } }` to reach a clock-armed rest node (F157). `capture` resolves `{ png }`, and `{ png, legend }` with `legend: true`; `undefined` while the renderer is inert. `timeScale` takes `{ scale }`; 0 freezes game time while the frames keep running. `frameRate` takes `{ fps? }`, calls `time.setRate(fps ?? "auto")` and answers `time.rate()`. `mute` takes `{ muted }`, mutes the master bus and answers the flag. Without `audioPlugin` it throws `[game] The command game.mute needs audioPlugin.` `trace` takes `{ path }`, a list of views by projection key, and answers whether the gate took the answer. `scroll` takes `{ key, to }`, calls `ui.scroll(key, to)` and answers what it answers; a visual test writes it as the step `{ scroll: { key, to } }`. `filter` takes `{ kind, on }`, switches the filter kind through `effects.diagnostics` (cosmetic) and answers the off kinds; an unknown kind throws `[game] No filter kind "fx.nope".` naming the known ones; without `effectsPlugin` it throws `[game] The command game.filter needs effectsPlugin.`
707
707
  - Commands run in dev builds and debug builds. `__MOKU_GAME_DEV__ === true` (the dev page, a test's `vi.stubGlobal("__MOKU_GAME_DEV__", true)`) or `__MOKU_GAME_CONTROL__ === true` (`--debug`) runs every command; `__MOKU_GAME_AGENT__ === true` alone (`--debug=read`) runs the `read` and `cosmetic` ones and `run` refuses the others with `controlReadOnly(id)`, an error with `reason: "read-only"`: `[game] The command game.tap changes the game: this debug build runs read and cosmetic commands only.`; no flag: `run` throws `[game] Control commands run in dev builds only.` `moku-game build` defines the three flags `false`; a game without the shell uses a bundler `define` and should add `__MOKU_GAME_AGENT__: "false"` and `__MOKU_GAME_CONTROL__: "false"`. `saveExport` answers the committed `{ player, session, rng }` (read); `saveImport` takes `{ save }` of `saveExport`, restores it at the main flow's start and flushes the store (raw: not on a `--debug=read` page).
708
708
  - A command's effect is `read`, `route`, `cosmetic`, `cheat` or `raw`. A `cheat` or `raw` command taints the session and is journaled; read it with `sources.tainted` and `sources.cheats`. Of the base commands `restore` and `saveImport` are `raw`; `capture` with `diff` writes the state too, so a `--debug=read` page refuses it. `bookmark` answers `flow.bookmark()` plus `scene`, the mounted scene; `restore` calls `scenes.expect(scene)` before `flow.restore`, so a bookmark at a popup restores the scene under it, also on a page that shows another scene. A bookmark taken while an effect that takes answers waits names the waiting transit node (`info/show` in the mini game) and carries `rest`; `restore` of it answers once that node's gate is open, with `pending.gate` in its value, and the popup shows on the next frame.
709
709
  - A game's own: `defineSource({ id, title, input, changes, read })` with `changes` `"frame"`, `"commit"` or `"edge"`, and `defineCommand({ id, title, input, effect, run, overlay?, value?, choices?, choice? })`: `overlay: "toggle"` (input exactly `{ on: "boolean" }` and `value: app => boolean`, the switch's state; with `choices: readonly [string, ...string[]]`, each word once or `defineCommand` throws, the input is exactly `{ on: "boolean", choice: "string" | "string?" }` and `choice: app => string` answers the marked one, run with `{ on, choice }`) or `overlay: "button"` (no required input, no value) lists the command in the editor's overlay, which shows only such commands; any other combination is a type error. The id is camelCase words joined by dots, at least two: `dice.rolls`. An input schema maps field names to `"string"`, `"number"`, `"boolean"` or `"json"`; a trailing `?` makes one optional. A command body starts with `if (typeof __MOKU_GAME_DEV__ === "undefined" || !__MOKU_GAME_DEV__) throw controlRefused();`: it runs in dev and is refused on a debug page. A `.dev` command meant for a debug page writes the agent form for a read or cosmetic effect, `if ((typeof __MOKU_GAME_DEV__ === "undefined" || !__MOKU_GAME_DEV__) && (typeof __MOKU_GAME_AGENT__ === "undefined" || !__MOKU_GAME_AGENT__)) throw controlRefused();`, and the control form (`__MOKU_GAME_CONTROL__` in place of `__MOKU_GAME_AGENT__`) for the others. Keep them in `.dev` modules that only the dev page, a debug page and the tests import: the editor's dev page (`preparePage` with agents) and `moku-game build --debug` import every `**/*.dev.ts`, `moku-game build` none.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moku-labs/game",
3
- "version": "0.15.100",
3
+ "version": "0.15.102",
4
4
  "description": "2D puzzle game engine on TypeScript and PixiJS, built on @moku-labs/core.",
5
5
  "type": "module",
6
6
  "sideEffects": [