@moku-labs/game 0.15.129 → 0.15.131

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 (32) hide show
  1. package/dist/app/page.d.mts +1 -1
  2. package/dist/app/page.mjs +1 -1
  3. package/dist/app/system.d.mts +3 -3
  4. package/dist/app.d.mts +3 -3
  5. package/dist/app.mjs +1 -1
  6. package/dist/assets.d.mts +1 -1
  7. package/dist/{commands-jELzVfPE.d.mts → commands-CzYKkdEO.d.mts} +5 -5
  8. package/dist/control.d.mts +4 -4
  9. package/dist/{define-CZ20Hsdi.d.mts → define-DR2SWS9E.d.mts} +2 -2
  10. package/dist/{headless-C0pK21sO.d.mts → headless-ffgavU3Y.d.mts} +1 -1
  11. package/dist/{index-C7v9DY3u.d.mts → index-C_Ej5JkQ.d.mts} +40 -4
  12. package/dist/index.d.mts +4 -4
  13. package/dist/index.mjs +1 -1
  14. package/dist/inspect.d.mts +9 -6
  15. package/dist/inspect.mjs +1 -1
  16. package/dist/jsx-dev-runtime.d.mts +1 -1
  17. package/dist/jsx-runtime.d.mts +1 -1
  18. package/dist/{runtime-CcNv443E.d.mts → runtime-wGL7TbEs.d.mts} +1 -1
  19. package/dist/{sources-CuG-Vma9.mjs → sources-D9Fk3Z4d.mjs} +45 -4
  20. package/dist/{src-Qxb4bwE4.mjs → src-BM3N5FXk.mjs} +430 -121
  21. package/dist/testing.d.mts +4 -4
  22. package/dist/testing.mjs +1 -1
  23. package/dist/{types-lV0kgldJ.d.mts → types-Bl-YjAnU.d.mts} +49 -9
  24. package/dist/{types-DvKiF3cX.d.mts → types-CYjnhoB9.d.mts} +2 -2
  25. package/dist/{types-BzBlqS6J.d.mts → types-DCtlPrmc.d.mts} +4 -4
  26. package/dist/{types-D_OXtHWf.d.mts → types-DNmg5EAM.d.mts} +37 -2
  27. package/dist/{types-ZH5oxtNb.d.mts → types-DU-RYYj0.d.mts} +126 -7
  28. package/dist/{visual-CmuxTTYx.d.mts → visual-CLR_C--i.d.mts} +6 -6
  29. package/dist/visual.d.mts +1 -1
  30. package/dist/visual.mjs +1 -1
  31. package/llms.txt +2 -2
  32. package/package.json +1 -1
@@ -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-lV0kgldJ.mjs";
2
- import { t as createApp } from "./index-C7v9DY3u.mjs";
3
- import { b as memory, x as saveOf, y as WithGameState } from "./types-BzBlqS6J.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-C0pK21sO.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-Bl-YjAnU.mjs";
2
+ import { t as createApp } from "./index-C_Ej5JkQ.mjs";
3
+ import { b as memory, x as saveOf, y as WithGameState } from "./types-DCtlPrmc.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-ffgavU3Y.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-Qxb4bwE4.mjs";
1
+ import { dn as refuseStart, gn as type, pn as exit, t as createApp, w as flattenFeatures } from "./src-BM3N5FXk.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-BuXptVI_.mjs";
@@ -2062,6 +2062,8 @@ type ModelCommitted = Events$5["model:committed"];
2062
2062
  * skipped: ["Display"],
2063
2063
  * motions: ["Transform"]
2064
2064
  * };
2065
+ * // The same item, when its enter motion was defined with the id "board.item" (its enter track is labelled "board.item.enter"):
2066
+ * const entering: Explained = { ...sliding, motionIds: ["board.item.enter"] };
2065
2067
  * ```
2066
2068
  */
2067
2069
  type Explained = {
@@ -2071,6 +2073,11 @@ type Explained = {
2071
2073
  components: Record<string, Json>; /** The names of the components that are not JSON, as `EntitySnapshot.skipped`. */
2072
2074
  skipped: string[]; /** `projection.motionsOf`: the components a running track drives, in start order. */
2073
2075
  motions: readonly string[];
2076
+ /**
2077
+ * `projection.motionIdsOf`: the labels of the running tracks, in start order. Absent when none
2078
+ * runs or no track carries a label, so a game without `defineMotion` ids answers as before.
2079
+ */
2080
+ motionIds?: readonly string[];
2074
2081
  };
2075
2082
  /**
2076
2083
  * Both halves of the `ecs` module: what a game calls and what `projection` gets injected.
@@ -3508,12 +3515,13 @@ type TrackSegment = {
3508
3515
  * keyframe walk: the segments run one after another over `ms` on one clock, and `to` is where the
3509
3516
  * last one ends. `repeat` runs the walk again from its first segment when it ends: a number
3510
3517
  * counts the extra runs, `"forever"` never ends. `reduced: "keep"` plays the track as written under
3511
- * reduced motion. The world passes it to the driver unchanged; without a driver the target is
3512
- * written once.
3518
+ * reduced motion. `label` names the track for inspection. The world passes it to the driver
3519
+ * unchanged; without a driver the target is written once.
3513
3520
  *
3514
3521
  * @example
3515
3522
  * ```ts
3516
3523
  * const options: TweenOptions = { ms: 350, ease: "out", delayMs: 40 };
3524
+ * const named: TweenOptions = { ms: 350, label: "hud.card.enter" };
3517
3525
  * const fade: TweenOptions = { ms: 250, reduced: "keep" }; // still fades under reduced motion
3518
3526
  * const walk: TweenOptions = { ms: 1000, segments: [{ at: 0.42, to: { y: 974 } }, { at: 1, to: { y: 960 } }] };
3519
3527
  * const sway: TweenOptions = { ms: 2400, additive: true, repeat: "forever", segments: [{ at: 0.5, to: { rotation: 0.05 } }, { at: 1, to: { rotation: 0 } }] };
@@ -3526,24 +3534,27 @@ type TweenOptions = {
3526
3534
  additive?: boolean;
3527
3535
  segments?: readonly TrackSegment[];
3528
3536
  repeat?: number | "forever";
3529
- reduced?: ReducedMotion;
3537
+ reduced?: ReducedMotion; /** A name for the track, shown by inspection (`motionIdsOf`, `game.explain`). `defineMotion` sets it from its `id`. */
3538
+ label?: string;
3530
3539
  };
3531
3540
  /**
3532
3541
  * Options of `ViewHandle.toRest`. Defaults: the plugin's `settleMs` and ease `"out"`. `delayMs`
3533
3542
  * lets a hook wait, for example for a flight to land, before the view comes home. `reduced: "keep"`
3534
- * lets the way home run its length under reduced motion.
3543
+ * lets the way home run its length under reduced motion. `label` names the track for inspection.
3535
3544
  *
3536
3545
  * @example
3537
3546
  * ```ts
3538
3547
  * const options: RestOptions = { ms: 200, delayMs: 120 };
3539
3548
  * const fadeIn: RestOptions = { ms: 200, reduced: "keep" };
3549
+ * const named: RestOptions = { ms: 200, label: "hud.card.exit" };
3540
3550
  * ```
3541
3551
  */
3542
3552
  type RestOptions = {
3543
3553
  ms?: number;
3544
3554
  ease?: Ease;
3545
3555
  delayMs?: number;
3546
- reduced?: ReducedMotion;
3556
+ reduced?: ReducedMotion; /** A name for the track, shown by inspection (`motionIdsOf`, `game.explain`). `defineMotion` sets it from its `id`. */
3557
+ label?: string;
3547
3558
  };
3548
3559
  /**
3549
3560
  * What the driver is told about one track: how long it runs, how it eases, how long it waits,
@@ -3552,7 +3563,8 @@ type RestOptions = {
3552
3563
  * `to` is the last segment's target. A track with `repeat` starts its walk again when it ends
3553
3564
  * (a number counts the extra runs, `"forever"` never ends); the instant driver ignores it and
3554
3565
  * writes the end pose once. `reduced: "keep"` tells the driver the author kept the track under
3555
- * reduced motion; the instant driver ignores that too.
3566
+ * reduced motion; the instant driver ignores that too. `label` names the track for inspection:
3567
+ * the world keeps it with the track and `motionIdsOf` answers it while the track runs.
3556
3568
  *
3557
3569
  * @example
3558
3570
  * ```ts
@@ -3560,6 +3572,7 @@ type RestOptions = {
3560
3572
  * const kept: TrackOptions = { ms: 250, ease: "out", reduced: "keep" };
3561
3573
  * const walk: TrackOptions = { ms: 1000, segments: [{ at: 0.42, to: { y: 974 } }, { at: 1, to: { y: 960 } }] };
3562
3574
  * const twice: TrackOptions = { ms: 400, ease: "inOut", delayMs: 0, additive: true, repeat: 1 };
3575
+ * const named: TrackOptions = { ms: 250, label: "hud.card.enter" };
3563
3576
  * ```
3564
3577
  */
3565
3578
  type TrackOptions = {
@@ -3569,7 +3582,8 @@ type TrackOptions = {
3569
3582
  additive?: boolean;
3570
3583
  segments?: readonly TrackSegment[];
3571
3584
  repeat?: number | "forever";
3572
- reduced?: ReducedMotion;
3585
+ reduced?: ReducedMotion; /** A name for the track, shown by inspection (`motionIdsOf`, `game.explain`). `defineMotion` sets it from its `id`. */
3586
+ label?: string;
3573
3587
  };
3574
3588
  /**
3575
3589
  * The tween engine behind `ViewHandle.tween`, `toRest` and `all`. `anim` installs one with
@@ -3726,6 +3740,7 @@ type ChangeHooks<Item> = {
3726
3740
  * ```
3727
3741
  */
3728
3742
  type ProjectionMotion<Item> = {
3743
+ /** The id `defineMotion` was given; `anim` also labels the tracks of the motion with it. */readonly id?: string;
3729
3744
  enter?(view: ViewHandle<Item>, item: Item, hint?: Hint, cause?: MotionCause): Motion;
3730
3745
  loop?(view: ViewHandle<Item>): Motion;
3731
3746
  exit?(view: ViewHandle<Item>, item: Item, hint?: Hint, cause?: MotionCause): Motion;
@@ -4072,7 +4087,8 @@ type Track = {
4072
4087
  * Whether the track repeats forever (`repeat: "forever"`): it never ends, so the warm step does not wait for it to
4073
4088
  * end, as for a loop.
4074
4089
  */
4075
- forever: boolean;
4090
+ forever: boolean; /** The name `TrackOptions.label` gave the track, for inspection (`motionIdsOf`); `undefined` for an unlabelled one. */
4091
+ label: string | undefined;
4076
4092
  };
4077
4093
  /**
4078
4094
  * The rest pose of one entity, by component name: the last output of `view(item)` for a view, or
@@ -4600,6 +4616,23 @@ type ProjectionApi = {
4600
4616
  * ```
4601
4617
  */
4602
4618
  motionsOf(entity: Entity): readonly string[];
4619
+ /**
4620
+ * The labels of the running tracks on an entity, as inspection shows them: the `label` of every
4621
+ * track that still runs, in start order, each once. A track without a label adds none. An
4622
+ * entity no labelled motion drives answers `[]`. Every call hands out a new array.
4623
+ *
4624
+ * @param entity - The entity to ask about.
4625
+ * @returns The labels, or `[]`.
4626
+ * @example
4627
+ * ```ts
4628
+ * // A coin whose enter motion was defined with `defineMotion({ id: "hud.coin", transition: { ms: 400 }, ... })`
4629
+ * // is mid-flight, and its enter track is labelled "hud.coin.enter".
4630
+ * app.world.projection.motionIdsOf(coin); // ["hud.coin.enter"]
4631
+ * app.time.step(500);
4632
+ * app.world.projection.motionIdsOf(coin); // []
4633
+ * ```
4634
+ */
4635
+ motionIdsOf(entity: Entity): readonly string[];
4603
4636
  /**
4604
4637
  * The rest value of one component of an entity: what a view holds when nothing animates it, or
4605
4638
  * what `setRest` recorded for an element. Read-only and owner-free, so a plugin that owns no
@@ -14562,7 +14595,14 @@ type State = {
14562
14595
  * Bundles a view asked again for right after the budget unloaded them: never a budget victim again, until they leave
14563
14596
  * another way (`"request"`, `"leave"`), so an untracked consumer costs one evict/reload at most (F184).
14564
14597
  */
14565
- reloadHeld: Set<string>; /** Bundles the "asked again" warning named already: one line per bundle per session (F184). */
14598
+ reloadHeld: Set<string>;
14599
+ /**
14600
+ * Bundles a node rests on through the `ready` effect, to the live rests seen since: a `ready` answered `false` for
14601
+ * them, and none answered `true` since. Held from the budget and from the `"leave"` release, so the rest the node
14602
+ * waits on cannot take them before the node asks again (F190). A bundle no `ready` asked for again by its second
14603
+ * rest is let go: the node it was asked for was left another way (Back).
14604
+ */
14605
+ readyWaiting: Map<string, number>; /** Bundles the "asked again" warning named already: one line per bundle per session (F184). */
14566
14606
  thrashWarned: Set<string>; /** Scene id to its declaration, read from the `scenes` key of `flow.features`. */
14567
14607
  scenes: Map<string, SceneDefinition>; /** Flow id to the feature that owns it, read from the `flows` key of `flow.features`. */
14568
14608
  featureOfFlow: Map<string, string>;
@@ -1,5 +1,5 @@
1
- import { $r as Snapshot, Wr as Json } from "./types-lV0kgldJ.mjs";
2
- import { t as HeadlessApp } from "./headless-C0pK21sO.mjs";
1
+ import { $r as Snapshot, Wr as Json } from "./types-Bl-YjAnU.mjs";
2
+ import { t as HeadlessApp } from "./headless-ffgavU3Y.mjs";
3
3
  import { Log } from "@moku-labs/common/browser";
4
4
 
5
5
  //#region src/plugins/flow/doors/types.d.ts
@@ -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-lV0kgldJ.mjs";
2
- import { o as AudioContextLike, s as Config$4 } from "./types-ZH5oxtNb.mjs";
3
- import { J as StringTable, U as I18nApi, Y as TextKey } from "./types-D_OXtHWf.mjs";
4
- import { Et as PlatformProvider, It as audioPlugin, Nt as effectsPlugin, i as screen, t as createApp, wt as platformPlugin } from "./index-C7v9DY3u.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-Bl-YjAnU.mjs";
2
+ import { o as AudioContextLike, s as Config$4 } from "./types-DU-RYYj0.mjs";
3
+ import { J as StringTable, U as I18nApi, Y as TextKey } from "./types-DNmg5EAM.mjs";
4
+ import { Et as PlatformProvider, It as audioPlugin, Nt as effectsPlugin, i as screen, t as createApp, wt as platformPlugin } from "./index-C_Ej5JkQ.mjs";
5
5
  import { AnyPluginInstance } from "@moku-labs/core";
6
6
 
7
7
  //#region src/plugins/model/store/providers/memory.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-lV0kgldJ.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-Bl-YjAnU.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";
@@ -3717,7 +3717,8 @@ type Anchor = {
3717
3717
  * the scale it is drawn at. A `text` adds `content`: the words it draws. A `text` given a text
3718
3718
  * style key adds `textStyle`. An `input` adds `value`: the text being typed while it is edited,
3719
3719
  * else the local field it writes. A windowed `scroll` adds `window`: the rows that exist, which
3720
- * are the children of its content, and how many the list has.
3720
+ * are the children of its content, and how many the list has. An element whose `motion` carries an
3721
+ * id adds `motion`; a `scroll` adds `scroll`.
3721
3722
  *
3722
3723
  * @example
3723
3724
  * ```ts
@@ -3791,6 +3792,40 @@ type UiNode = {
3791
3792
  last: number;
3792
3793
  rows: number;
3793
3794
  };
3795
+ /**
3796
+ * The id of the element's `motion` prop, when it was built by `defineMotion({ id })`. Absent on
3797
+ * an element without a motion and on a motion without an id. A loop that an equal re-render
3798
+ * kept under another id still runs under its old `<id>.loop` label: this shows the new id.
3799
+ *
3800
+ * @example
3801
+ * ```ts
3802
+ * // Home: `<column key="card" motion={cardMotion} />`, `cardMotion = defineMotion({ id: "hud.card", ... })`.
3803
+ * const card = app.ui.tree().children.find(node => node.key === "card");
3804
+ * card?.motion; // "hud.card"
3805
+ * ```
3806
+ */
3807
+ motion?: string;
3808
+ /**
3809
+ * Where a scroll stands and how it rests: its axis, offset and max (as `ScrollState` has them),
3810
+ * whether it moves, and its snap stops as a release uses them: numbers only, each kept inside
3811
+ * 0 to `max` (`Infinity` reads as `max`), in prop order, `NaN` and non-numbers left out. `snap` is absent when the scroll names no stops. Absent on any
3812
+ * other tag; offset, max and `moving` are 0 and false until the first solve placed the scroll.
3813
+ *
3814
+ * @example
3815
+ * ```ts
3816
+ * // The board's order strip: `<scroll key="strip" axis="x" snap={[0, 318, 390]} offset={318} />`,
3817
+ * // a 306 u window over a 696 u track.
3818
+ * const strip = app.ui.tree().children.find(node => node.key === "strip");
3819
+ * strip?.scroll; // { axis: "x", offset: 318, max: 390, moving: false, snap: [0, 318, 390] }
3820
+ * ```
3821
+ */
3822
+ scroll?: {
3823
+ axis: "x" | "y";
3824
+ offset: number;
3825
+ max: number;
3826
+ moving: boolean;
3827
+ snap?: number[];
3828
+ };
3794
3829
  children: UiNode[];
3795
3830
  };
3796
3831
  /**
@@ -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-lV0kgldJ.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-D_OXtHWf.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-Bl-YjAnU.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-DNmg5EAM.mjs";
3
3
  import { Log } from "@moku-labs/common/browser";
4
4
  import { PluginCtx } from "@moku-labs/core";
5
5
 
@@ -844,7 +844,9 @@ type CursorCtx = {
844
844
  */
845
845
  type RunningTimeline = {
846
846
  readonly id: number;
847
- readonly animation: string;
847
+ readonly animation: string; /** The slot values exactly as `play` received them, by reference: `timelines()` shows them. */
848
+ readonly slots: SlotRecord; /** The frame count of anim (`State.frame`) when the timeline started. */
849
+ readonly startFrame: number;
848
850
  readonly cursor: Cursor;
849
851
  readonly marks: string[];
850
852
  readonly entities: readonly Entity[]; /** The entities its `{ projection, key }` targets named when it started, by target object. */
@@ -854,8 +856,20 @@ type RunningTimeline = {
854
856
  ended: boolean; /** The one cursor context of the timeline, made at its start and reused by every frame. */
855
857
  readonly cctx: CursorCtx;
856
858
  };
859
+ /**
860
+ * One slot of the ring of ended timelines. The sixteen records are made once with the state and
861
+ * written in place at every end, so an end allocates no record. Private: the API answers
862
+ * `EndedTimelineInfo` copies.
863
+ */
864
+ type EndedRecord = {
865
+ timeline: number;
866
+ animation: string;
867
+ startFrame: number;
868
+ endFrame: number;
869
+ reason: TimelineEndReason;
870
+ };
857
871
  declare namespace types_d_exports$3 {
858
- export { AnimApi, AnimCtx, AnimPlayerValue, AnimationDefinition, AnimationSpec, AnyAnimationDefinition, BuildTools, Config$3 as Config, Cursor, Deps$3 as Deps, ErasedFields, Events, ExternalPlayer, FrameLoop, FramesValue, FxStep, HapticDescriptor, HapticKind, KernelSlice$3 as KernelSlice, MarkListener, MotionKeyframe, PlayDescriptor, PlayHandle, Pose, RunningTimeline, SfxDescriptor, SlotRecord, SlotTags, SlotValue, SlotValues, State$3 as State, Step, StepMotion, StopSfxDescriptor, Target, TimelineRuntime, Track };
872
+ export { AnimApi, AnimCtx, AnimPlayerValue, AnimationDefinition, AnimationSpec, AnyAnimationDefinition, BuildTools, Config$3 as Config, Cursor, Deps$3 as Deps, EndedTimelineInfo, ErasedFields, Events, ExternalPlayer, FrameLoop, FramesValue, FxStep, HapticDescriptor, HapticKind, KernelSlice$3 as KernelSlice, MarkListener, MotionKeyframe, PlayDescriptor, PlayHandle, Pose, RunningTimeline, RunningTimelineInfo, SfxDescriptor, SlotRecord, SlotTags, SlotValue, SlotValues, State$3 as State, Step, StepMotion, StopSfxDescriptor, Target, TimelineEndReason, TimelineRuntime, TimelinesSnapshot, Track };
859
873
  }
860
874
  /**
861
875
  * What a step and a slot are pointed at: the projection key of a live view or of an element a
@@ -1044,11 +1058,87 @@ type Events = {
1044
1058
  /** A `mark` step was reached, or jumped by `finish()`. */"anim:mark": {
1045
1059
  animation: string;
1046
1060
  mark: string;
1047
- }; /** A timeline ended or was finished. Not emitted on `cancel()`. */
1061
+ }; /** A timeline started: it is in `timelines()` and `play` has not returned yet. */
1062
+ "anim:started": {
1063
+ animation: string;
1064
+ timeline: number;
1065
+ }; /** A timeline was cancelled with `handle.cancel()`. `anim:finished` does not follow. */
1066
+ "anim:cancelled": {
1067
+ animation: string;
1068
+ timeline: number;
1069
+ };
1070
+ /**
1071
+ * A timeline ended or was finished, with `reason: "ended"` when its tree ran through and
1072
+ * `"finished"` for `finish()`, `finishAll()` and the abort of the node that played it. Not
1073
+ * emitted on `cancel()`.
1074
+ */
1048
1075
  "anim:finished": {
1049
1076
  animation: string;
1077
+ timeline: number;
1078
+ reason: "ended" | "finished";
1050
1079
  };
1051
1080
  };
1081
+ /**
1082
+ * Why a timeline ended: it ran through its tree, it was finished early, or it was cancelled.
1083
+ *
1084
+ * @example
1085
+ * ```ts
1086
+ * // A timeline that played to its last step, then one a node's abort finished early.
1087
+ * const ran: TimelineEndReason = "ended";
1088
+ * const aborted: TimelineEndReason = "finished";
1089
+ * ```
1090
+ */
1091
+ type TimelineEndReason = "ended" | "finished" | "cancelled";
1092
+ /**
1093
+ * One running timeline as `timelines()` reports it.
1094
+ *
1095
+ * @example
1096
+ * ```ts
1097
+ * // The delivery of order card "a", one frame in, with nothing reached yet.
1098
+ * const info: RunningTimelineInfo = {
1099
+ * timeline: 4, animation: "orders.deliver", startFrame: 0,
1100
+ * slots: { card: { projection: "board.items", key: "a" } }, entities: [1_048_576], marks: []
1101
+ * };
1102
+ * ```
1103
+ */
1104
+ type RunningTimelineInfo = {
1105
+ /** The timeline number: the one `anim:started` and `anim:finished` carry. Ids are shared with tracks. */readonly timeline: number; /** The animation id. */
1106
+ readonly animation: string; /** The anim frame count when it started. */
1107
+ readonly startFrame: number; /** The targets as `play` received them: the very object, not a copy. Do not mutate it. */
1108
+ readonly slots: SlotRecord; /** The entities its targets resolved to at the start, each counted in `Animation`. A copy. */
1109
+ readonly entities: readonly Entity[]; /** The marks reached so far. A copy. */
1110
+ readonly marks: readonly string[];
1111
+ };
1112
+ /**
1113
+ * One ended timeline of the ring `timelines()` keeps.
1114
+ *
1115
+ * @example
1116
+ * ```ts
1117
+ * const info: EndedTimelineInfo = {
1118
+ * timeline: 4, animation: "orders.deliver", startFrame: 0, endFrame: 2, reason: "ended"
1119
+ * };
1120
+ * ```
1121
+ */
1122
+ type EndedTimelineInfo = {
1123
+ /** The timeline number it ran under. */readonly timeline: number; /** The animation id. */
1124
+ readonly animation: string; /** The anim frame count when it started. */
1125
+ readonly startFrame: number; /** The anim frame count when it ended. */
1126
+ readonly endFrame: number; /** How it ended. */
1127
+ readonly reason: TimelineEndReason;
1128
+ };
1129
+ /**
1130
+ * What `timelines()` and the `game.timelines` source answer: the timelines that run now, in start
1131
+ * order, and the last sixteen that ended, oldest first.
1132
+ *
1133
+ * @example
1134
+ * ```ts
1135
+ * const idle: TimelinesSnapshot = { running: [], ended: [] };
1136
+ * ```
1137
+ */
1138
+ type TimelinesSnapshot = {
1139
+ /** The running timelines, in start order. */readonly running: readonly RunningTimelineInfo[]; /** The last ended timelines, oldest first, at most 16. */
1140
+ readonly ended: readonly EndedTimelineInfo[];
1141
+ };
1052
1142
  /**
1053
1143
  * One key of a keyframe track in `defineMotion`: where on the track it sits (`at`, 0..1 of
1054
1144
  * `transition.ms`), the curve of the segment that ends on it (default `"inOut"`) and the pose.
@@ -1170,7 +1260,14 @@ type State$3 = {
1170
1260
  * The timelines in start order, as a dense list the frame step walks by index. An ended timeline
1171
1261
  * stays in it until the next frame step drops it.
1172
1262
  */
1173
- timelineList: RunningTimeline[]; /** The `animations` of every feature, read in `onStart`. */
1263
+ timelineList: RunningTimeline[];
1264
+ /**
1265
+ * The ring of the last 16 ended timelines. Its 16 records are made with the state and written
1266
+ * in place at every end, never replaced.
1267
+ */
1268
+ ended: EndedRecord[]; /** The ring slot the next end writes, 0..15. */
1269
+ endedNext: number; /** How many slots of the ring hold a real record, 0..16. */
1270
+ endedCount: number; /** The `animations` of every feature, read in `onStart`. */
1174
1271
  registry: Map<string, AnyAnimationDefinition>; /** `onMark` subscribers, in subscription order. */
1175
1272
  markListeners: Set<MarkListener>; /** Counter of the frame steps. A track born in the running step is not advanced by it. */
1176
1273
  frame: number; /** True while the track count is over `maxTracks`, so the warning is one per crossing. */
@@ -1267,6 +1364,28 @@ type AnimApi = {
1267
1364
  * ```
1268
1365
  */
1269
1366
  active(): number;
1367
+ /**
1368
+ * What plays now and what ended last: every running timeline with the targets it was played
1369
+ * with, and the last 16 that ended with the reason of each end. Every call builds new plain
1370
+ * objects and copies `entities` and `marks`; `slots` is the very object `play` received, so do
1371
+ * not mutate it. A reader pays for the copies, the frame step does not. Stopping the app empties
1372
+ * the ring.
1373
+ *
1374
+ * @returns The running timelines in start order and the ended ones, oldest first.
1375
+ * @example
1376
+ * ```ts
1377
+ * // A test asks what the delivery did, one frame in and at its end.
1378
+ * const deliverOrder = defineAnimation("orders.deliver", { slots: { card: type<Target>() },
1379
+ * build: ({ card }) => sequence(tween(card, Transform, { x: 100 }, { ms: 100 }), mark("done")) });
1380
+ * app.anim.play(deliverOrder, { card: { projection: "board.items", key: "a" } });
1381
+ * app.time.step(50);
1382
+ * app.anim.timelines().running[0]?.animation; // "orders.deliver"
1383
+ * app.time.step(50);
1384
+ * app.anim.timelines().running; // []
1385
+ * app.anim.timelines().ended[0]?.reason; // "ended"
1386
+ * ```
1387
+ */
1388
+ timelines(): TimelinesSnapshot;
1270
1389
  /**
1271
1390
  * Whether reduced motion is on. It starts at `Config.reducedMotion` and `setReducedMotion`
1272
1391
  * switches it.
@@ -3429,4 +3548,4 @@ type UiApi = {
3429
3548
  }> | undefined;
3430
3549
  };
3431
3550
  //#endregion
3432
- export { SfxDescriptor as $, EmitterDefinition as A, GlowValue as B, FoldValue as C, ShineValue as D, RevealRoundValue as E, DisplacementValue as F, AnimPlayerValue as G, OutlineValue as H, FilterArea as I, MotionKeyframe as J, Config$3 as K, FilterComponent as L, AlphaValue as M, BlurValue as N, VignetteValue as O, ColorMatrixValue as P, HapticKind as Q, FilterSpec as R, FlashValue as S, RevealLineValue as T, UniformDeclaration as U, NoiseValue as V, AnimApi as W, Target as X, State$3 as Y, types_d_exports$3 as Z, State$2 as _, use as _t, AudioApi as a, haptic as at, BloomValue as b, types_d_exports$4 as bt, MusicDescriptor as c, play as ct, State$1 as d, sfx as dt, Step as et, VolumesFor as f, spawn as ft, EffectsStats as g, tween as gt, EffectsApi as h, stopSfx as ht, types_d_exports as i, frames as it, EmitterValue as j, EmitterConfig as k, MusicOptions as l, sequence as lt, Config$2 as m, stagger as mt, State as n, defineAnimation as nt, AudioContextLike as o, mark as ot, types_d_exports$1 as p, spawned as pt, FramesValue as q, UiApi as r, external as rt, Config$1 as s, parallel as st, Config as t, HAPTIC_KINDS as tt, SoundEntry as u, set as ut, types_d_exports$2 as v, wait as vt, GradeValue as w, DissolveValue as x, AuraValue as y, OverlayApi as yt, FilterValueOf as z };
3551
+ export { HapticKind as $, EmitterDefinition as A, GlowValue as B, FoldValue as C, ShineValue as D, RevealRoundValue as E, DisplacementValue as F, AnimPlayerValue as G, OutlineValue as H, FilterArea as I, MotionKeyframe as J, Config$3 as K, FilterComponent as L, AlphaValue as M, BlurValue as N, VignetteValue as O, ColorMatrixValue as P, types_d_exports$3 as Q, FilterSpec as R, FlashValue as S, RevealLineValue as T, UniformDeclaration as U, NoiseValue as V, AnimApi as W, Target as X, State$3 as Y, TimelinesSnapshot as Z, State$2 as _, tween as _t, AudioApi as a, frames as at, BloomValue as b, OverlayApi as bt, MusicDescriptor as c, parallel as ct, State$1 as d, set as dt, SfxDescriptor as et, VolumesFor as f, sfx as ft, EffectsStats as g, stopSfx as gt, EffectsApi as h, stagger as ht, types_d_exports as i, external as it, EmitterValue as j, EmitterConfig as k, MusicOptions as l, play as lt, Config$2 as m, spawned as mt, State as n, HAPTIC_KINDS as nt, AudioContextLike as o, haptic as ot, types_d_exports$1 as p, spawn as pt, FramesValue as q, UiApi as r, defineAnimation as rt, Config$1 as s, mark as st, Config as t, Step as tt, SoundEntry as u, sequence as ut, types_d_exports$2 as v, use as vt, GradeValue as w, DissolveValue as x, types_d_exports$4 as xt, AuraValue as y, wait as yt, FilterValueOf as z };
@@ -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-lV0kgldJ.mjs";
2
- import { W as AnimApi, r as UiApi } from "./types-ZH5oxtNb.mjs";
3
- import { R as InputApi } from "./types-D_OXtHWf.mjs";
4
- import { r as Repro } from "./headless-C0pK21sO.mjs";
5
- import { i as ControlApp, o as InputOf } from "./types-DvKiF3cX.mjs";
6
- import { t as commands } from "./commands-jELzVfPE.mjs";
1
+ import { Ar as Api$1, Fr as Api$4, Q as Api, Vr as Api$2, ii as Api$3 } from "./types-Bl-YjAnU.mjs";
2
+ import { W as AnimApi, r as UiApi } from "./types-DU-RYYj0.mjs";
3
+ import { R as InputApi } from "./types-DNmg5EAM.mjs";
4
+ import { r as Repro } from "./headless-ffgavU3Y.mjs";
5
+ import { i as ControlApp, o as InputOf } from "./types-CYjnhoB9.mjs";
6
+ import { t as commands } from "./commands-CzYKkdEO.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-CmuxTTYx.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-CLR_C--i.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,5 +1,5 @@
1
1
  import { t as VISUAL_CLOCK } from "./fake-hnJcJeYf.mjs";
2
- import { n as read, t as sources } from "./sources-CuG-Vma9.mjs";
2
+ import { n as read, t as sources } from "./sources-D9Fk3Z4d.mjs";
3
3
  import { n as commands, t as run } from "./run-1i_SfbM4.mjs";
4
4
  import path from "node:path";
5
5
  import { createBrandConsole } from "@moku-labs/common/cli";
package/llms.txt CHANGED
@@ -600,7 +600,7 @@ A screen is a projection whose `view` returns JSX. The game's `tsconfig.json` se
600
600
  - `tr(key, params?)` returns a frozen `Message` `{ key, params }`; no locale is read at the call site. Strings live in `strings/<locale>.json` of any feature or sub-feature, as ICU MessageFormat 1 (`{n, plural, one {# order} other {# orders}}`, `select`, `selectordinal`, `number`, `date`, `time`; no skeletons, no `currency`). `bun run assets:keys` compiles them. The keys of the top-level features and the layers go into `generated/strings.<locale>.ts`, which one feature registers; a sub-feature's keys start with `<name>.` (`ep01.title`) and go into `generated/strings.<name>.<locale>.ts`, which the sub-feature registers lazily, `strings: { en: () => import("@generated/strings.ep01.en"), ru: () => import("@generated/strings.ep01.ru") }`. With `assets` composed those modules load and unload with the bundle named like the sub-feature: every way the bundle comes (a node entry, a scene's `bundles`, `load`, a restore, the `safeNode`) brings its strings, a locale switch brings them in the new locale, and while the bundle is not loaded a key of it gives `⟦key⟧` and `has(key)` is false. A compiled module calls the root helpers `messageArgument(value, intl)` (an element stays an element part, a list goes through `Intl.ListFormat`, a number through `Intl.NumberFormat`, else text) and `messageDuration(ms)` (`95_000` gives `{ minutes: 1, seconds: 35 }`). `app.i18n`: `locale()`, `setLocale(locale)` (async, emits `i18n:locale-changed`), `format(message, locale?)` returns `Part[]`, `plain(message)` returns a string, `has(key)`, `isKey(value)`, `locales()`, `replace(locale, messages)` (dev hot swap of a generated strings file). Config: `locale: "en"`, `fallback: "en"`, `locales: {}`.
601
601
  - Keys that come from data: `I18n.TextKey<Strings>` is the keys of the generated `Strings` without parameters (nothing new is generated). A data table types its keys `TextKey` or builds them with the kit's `key("board.hint.red")`; the kit's `tr` never takes a plain `string`. A key read back from a save is checked where the app is (an effect handler, app or page code, loading a save) with one `isKey(value)`: `defineGameApp({ ..., strings: type<Strings>() })` types the game's `app.i18n`, so a true `app.i18n.isKey(value)` narrows the value to `TextKey`; `ctx.require(i18nPlugin).isKey(value)` in a plugin narrows to `string`. `app.i18n.isKey(value)` answers true for a key of the loaded tables of the current locale or the fallback, and for the `<feature>.` prefix of a sub-feature whose strings are not loaded yet; a key that takes parameters answers true too.
602
602
  - Text: `Text` component, `label({ text, style, at, anchor? })` for board text in a projection view, `defineTextStyles({ "hud.digits": { font, size, fill, bold?, italic?, stroke?, strokeWidth?, letterSpacing?, align?, wrap? (a width, "none" or "box": wrap at the laid-out width of its ui element; lines break between words, after a hyphen inside a word and at a soft hyphen U+00AD, drawn as `-` only where the line breaks), digits?, lineHeight? (the line as a multiple of size above 0, such as 1.28; glyphs sit in the middle of the line; absent: the font's own line), balance? (true evens a wrapped block of 2–6 lines at the narrowest width that keeps its number of lines, like CSS `text-wrap: balance`; never wider than the wrap; one line, more than 6 or a word wider than the wrap stay greedy), boldStyle? (a `TextRunStyle` of `font`, `size`, `fill`, `letterSpacing`, `stroke`, `strokeWidth`, `shadow`: the look of the `<b>` runs of the style, laid over it; `font` wins over `bold`), textIndent? (the indent of the first line in reference px, ≥ 0, like CSS `text-indent`; a line after `\n` starts at the edge; counted in the width) } })` under the feature's `textStyles` key. Tags inside a string: `<b>`, `<i>`, `<color=#rrggbb>`, `<span style=KEY>` (the glyph look of the style `KEY`: font, size, fill, spacing, outline, shadow, line; unquoted key; an unknown key draws in the text's own look and warns once), `<icon=key>`, `\<`, `\n`. Every piece of a line stands on one baseline, and a larger piece makes its line taller. Built-in styles `body` and `digits` from config `fonts: { body: "ui.font-body", digits: "ui.font-digits" }`. `app.text.measure(content, style, width?)` gives the same numbers in a browser and in Bun. `app.text.replaceStyles(styles)` is the dev hot swap of a saved `defineTextStyles` value. A game's own number format: `defineTextFormats({ "pill.number": value => ({ content, style }) })` under the feature's `textFormats` key, named by the `bind` of `defineGame` (`GameTypes.textFormats`): `bind(Counter, "value", { format: "pill.number" })`. It takes the whole value, is pure over value and language, is not called while the whole value and the locale stand, and owns `Text.style`; a `Countdown` calls it every frame. `app.text.formatted(name, value)` answers `{ text, style }`, `undefined` for an unknown or built-in name and for a format that threw. A saved module exporting formats reloads the page.
603
- - Animation is data: `defineAnimation(id, { slots: { name: type<Anim.Target>() }, build: (slots, { at, reducedMotion }) => Step })`; `reducedMotion` is the reduced-motion switch read once when the play starts (absent reads as `false`; `use` carries it only with the outer tools), so `build` can return a designed variant whose tweens are marked `reduced: "keep"`. Steps: `sequence(...)`, `parallel(...)`, `stagger(items, ms, item => Step)`, `tween(target, Component, to, { ms, ease?, delayMs?, additive?, space?, reduced? })`, `set(target, Component, patch)`, `wait(ms)`, `mark(name)`, `frames(target, { keys, fps, loop? })`, `sfx(key, { bus? })`, `haptic(kind)`, `use(animation, slots, tools?)`, `spawn` (a temporary entity, flying coins, that the timeline despawns when it ends; see the anim README). `Frames({ keys, fps, loop, playing })` is a component that walks a sprite through its textures for the entity's whole life. A target is `{ projection, key }` or an entity. A timeline resolves each `{ projection, key }` target once, when it starts: every step writes the view that held the key then, also after a commit removed it and while its exit plays, until it despawns; a view spawned again under the same key is not followed, and a key nothing held at the start is looked up at its step. `reduced: "keep"` (on a `tween` step, `transition` and `loop` of `defineMotion`, `TweenOptions`, `RestOptions`) plays a track as written under reduced motion, a fade for one; the default `"cut"` lands it at once or holds a loop on its first key. A node plays it with `await fx(play(animation, slots))`; in fast mode it finishes at once. `defineMotion({ states, transition?, on: { enter?, exit?, change? }, when? })` builds the enter, exit and change hooks for a projection or the `motion` prop of a tag; `when: "change"` plays enter and exit only for a commit, so an element that comes or goes with its screen stands at rest and leaves without a motion (default `"always"`). Events `anim:mark` `{ animation, mark }` and `anim:finished` `{ animation }`. `app.anim.replace(definition)` is the dev hot swap: the next `play` builds the new tree. A system cannot `require` a plugin, so it plays through the resource `AnimPlayer`: `res(AnimPlayer).play(animation, slots)` returns the same handle as `app.anim.play`, and the registered animation of `animation.id` wins, so a hot swap reaches the system. Play on a change, never every frame; from phase `input` the tree moves in `animate` of the same frame. Before `anim` starts it throws `[game] AnimPlayer is not ready: anim has not started.` Config `maxTracks: 2000`.
603
+ - Animation is data: `defineAnimation(id, { slots: { name: type<Anim.Target>() }, build: (slots, { at, reducedMotion }) => Step })`; `reducedMotion` is the reduced-motion switch read once when the play starts (absent reads as `false`; `use` carries it only with the outer tools), so `build` can return a designed variant whose tweens are marked `reduced: "keep"`. Steps: `sequence(...)`, `parallel(...)`, `stagger(items, ms, item => Step)`, `tween(target, Component, to, { ms, ease?, delayMs?, additive?, space?, reduced? })`, `set(target, Component, patch)`, `wait(ms)`, `mark(name)`, `frames(target, { keys, fps, loop? })`, `sfx(key, { bus? })`, `haptic(kind)`, `use(animation, slots, tools?)`, `spawn` (a temporary entity, flying coins, that the timeline despawns when it ends; see the anim README). `Frames({ keys, fps, loop, playing })` is a component that walks a sprite through its textures for the entity's whole life. A target is `{ projection, key }` or an entity. A timeline resolves each `{ projection, key }` target once, when it starts: every step writes the view that held the key then, also after a commit removed it and while its exit plays, until it despawns; a view spawned again under the same key is not followed, and a key nothing held at the start is looked up at its step. `reduced: "keep"` (on a `tween` step, `transition` and `loop` of `defineMotion`, `TweenOptions`, `RestOptions`) plays a track as written under reduced motion, a fade for one; the default `"cut"` lands it at once or holds a loop on its first key. A node plays it with `await fx(play(animation, slots))`; in fast mode it finishes at once. `defineMotion({ states, transition?, on: { enter?, exit?, change? }, when? })` builds the enter, exit and change hooks for a projection or the `motion` prop of a tag; `when: "change"` plays enter and exit only for a commit, so an element that comes or goes with its screen stands at rest and leaves without a motion (default `"always"`). Events `anim:mark` `{ animation, mark }`, `anim:started` `{ animation, timeline }`, `anim:cancelled` `{ animation, timeline }` and `anim:finished` `{ animation, timeline, reason }` (`reason` is `"ended"` when the tree ran through, `"finished"` for `finish()`, `finishAll()` and the abort of the node that played it; the timeline number is shared with tracks, so it is not consecutive). `app.anim.timelines()` answers `{ running, ended }`: every running timeline with its `timeline`, `animation`, `startFrame`, `slots`, `entities` and `marks`, and the last 16 ended ones with `startFrame`, `endFrame` and `reason` (`"ended"`, `"finished"` or `"cancelled"`), oldest first; `game.timelines` is the same as an inspect source. `defineMotion({ id: "hud.card", … })` labels every track it starts `hud.card.enter`, `.exit`, `.loop` or `.change`, shown by `world.projection.motionIdsOf(entity)` and `game.explain` as `motionIds`; an equal loop built again under another id keeps its running track and its old label. `app.anim.replace(definition)` is the dev hot swap: the next `play` builds the new tree. A system cannot `require` a plugin, so it plays through the resource `AnimPlayer`: `res(AnimPlayer).play(animation, slots)` returns the same handle as `app.anim.play`, and the registered animation of `animation.id` wins, so a hot swap reaches the system. Play on a change, never every frame; from phase `input` the tree moves in `animate` of the same frame. Before `anim` starts it throws `[game] AnimPlayer is not ready: anim has not started.` Config `maxTracks: 2000`.
604
604
  - A `tween` step takes `segments` and `repeat` as `ViewHandle.tween` does: `tween(chest, Transform, { y: 0, scale: 0 }, { ms: 2400, additive: true, repeat: "forever", segments: [{ at: 0.08, ease: "out", to: { y: -14, scale: 0.06 } }, { at: 1, to: { y: 0, scale: 0 } }] })`. Segments walk over `ms` on one clock, `to` is where the last one ends, an additive walk names offsets; a number counts the extra runs. A definition error throws for empty segments, an `at` outside 0..1 or out of order, a last segment before 1, a bad repeat, and a `sequence` step after one that never ends. A forever step ends only by cancel or finish (a finish and a fast world land it on its start pose), does not play under reduced motion `"cut"`, writes nothing while its view is unseen, and lets the clock idle; a system plays it once through `AnimPlayer` and keeps the handle.
605
605
  - Audio is opt-in: `plugins: [...screen, audioPlugin]`. `fx(sfx("orders.complete"))` resolves when the sound started. `await fx(music("board.theme"))` cross-fades; `music(null)` fades out; a scene's `music` key switches the track on `scenes:changed`. Buses `master`, `music`, `sfx`. Volumes come from the committed player: config `volumes: player => (player as Player).settings.audio`, applied on every `model:committed`. `app.audio`: `setVolume(bus, value)`, `volume(bus)`, `mute(bus, on)`, `muted(bus)`, `unlocked()`, `journal()` (the last started sounds, empty unless config `journal` is above 0). Config: `buses: { master: 1, music: 0.6, sfx: 1 }`, `musicFadeMs: 600`, `volumes`, `context`, `journal: 0`, `music: "decode" | "stream"` default `"decode"` (gapless buffer; `"stream"` is an `<audio>` element, less memory, a gap at every loop), `session: "ambient" | "playback" | "auto"` default `"ambient"` (iOS only: ambient mixes with other apps and obeys the silent switch). The context is asked to run at start: where the shell lets audio play (a native webview with the gesture requirement off) `unlocked()` is true with no touch; a browser that wants a gesture unlocks on the first `pointerdown` or `touchend`. iOS: after a pause the touch unlock stays armed until the context really runs (WebKit holds `resume()` pending after a screenshot or Control Center); on a return from the background (WebKit with `navigator.audioSession`, a touch screen, `session` not `"playback"`) the plugin renews its context one second later or at the first touch: session `"auto"`, old context closed, `session` again, a new context from `config.context` (called again, so return a new context each call) at the same volumes, decoded buffers kept, the scene's music restarted, sounds in flight dropped. Without `audio` every `sfx` and `music` effect resolves `undefined` at once, so the same node runs in a game with no sound. Named sounds: `sfx(key, { bus?, id?, fadeMs? })` with an `id` plays through its own gain, and the next sound with the same `id` fades the old one out over `fadeMs`, else config `sfxFadeMs` (default `120`, real milliseconds); `fx.start(stopSfx(id, { fadeMs? }))` and `app.audio.stop(id, { fadeMs? })` fade it out and end it (`fadeMs: 0` cuts it); an `id` nothing plays under changes nothing, and a sound of that `id` still decoding never starts. Without `id` an `sfx` plays to its end as before.
606
606
  - `app.ui`: `tree()` the live screen as plain data (a text node carries `content`, the words it draws after `tr()` and `bind`; a text field carries `value`), `find(key)` the entity of a keyed element, `fill(key, value)` types into the text field with that `key`, `scroll(key, to)` puts the `scroll` with that `key` at `to` from its start at once, inside `0..max`, its fling or glide stopped (`false` and `ui:scroll-without-scroll` for no live `scroll`, `false` and `ui:scroll-before-solve` for a `scroll` its first solve has not placed yet), `rectOf(target)` where an `AnchorTarget` (or the shown ones of a list) is drawn, in screen reference units, the rect an `<anchor>` sits on, a target of no area shown at its point (`{ x, y, w: 0, h: 0 }`; an `<anchor>` on it stands there at size 0, takes no tap, its children lay out and hit as usual; an inward `pad` past half the target leaves it at size 0 on the centre), `undefined` when none is shown (an `image` whose style states a size, `width`/`height` or both edges of an absolute one, laid out at 0 draws nothing and counts as not shown; one whose style states no size keeps its alpha and draws as its `Sprite` says, ui never writing the size a game's system gives it), any build, a new object per call (`app.ui.rectOf({ projection: "board.strip", key: "seat0" })` → `{ x: 40, y: 1500, w: 116, h: 120 }`), `lint()` tap targets under `tapTargetPt` (default `44`), text that overflows in some locale, absolute elements without `reason`. Config: `tapTargetPt: 44`, `breakpoints: { tall: 2, wide: 1.5 }`. `ui` emits only the dev global event `ui:hot-swap`, see "Hot swap".
@@ -702,7 +702,7 @@ A plugin that owns a resource stores it in its state and frees it in `onStop: ({
702
702
 
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
- - `@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.
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`, `timelines`; 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. `timelines` answers `anim.timelines()` and throws `[game] The source game.timelines needs animPlugin.` without the plugin. `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
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). While `pause` holds (`devtools`), `clock.now()` stands: only `step` (each frame moves it by `deltaMs` with the frame time) and `clock` move it, so a frame-stepped trace is deterministic; after `resume` it goes on from where it stood, behind the device clock by the pause, the advances kept. Another pause reason, such as `background`, keeps the clock on the device (F169). `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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moku-labs/game",
3
- "version": "0.15.129",
3
+ "version": "0.15.131",
4
4
  "description": "2D puzzle game engine on TypeScript and PixiJS, built on @moku-labs/core.",
5
5
  "type": "module",
6
6
  "sideEffects": [