@moku-labs/game 0.15.148 → 0.15.150

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- import { Bn as NodeTable, Ir as ClockSource, Jn as Hint, Mn as FeaturePlugin, Pn as AnyFlow, Rr as FakeClock, Wn as Descriptor, Wr as Json, Yn as NodeFx } from "./types-C9L-dSRf.mjs";
2
- import { t as createApp } from "./index-sltlACR5.mjs";
3
- import { b as memory, x as saveOf, y as WithGameState } from "./types-Bxecqli6.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-ABpROLSJ.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-VJcIdmHU.mjs";
2
+ import { t as createApp } from "./index-Dgwheaoi.mjs";
3
+ import { b as memory, x as saveOf, y as WithGameState } from "./types-C2-KGQGt.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-CO19o31k.mjs";
5
5
  import { AnyPluginInstance } from "@moku-labs/core";
6
6
 
7
7
  //#region src/plugins/clock/fake.d.ts
@@ -89,11 +89,12 @@ type FakeFx = {
89
89
  * Builds the `fx` of a node context for a unit test that calls `node.run(context)` itself, with no
90
90
  * app and no runner. It records every call and plays no effect: `await fx(descriptor)` goes to
91
91
  * `awaited` and resolves with `options.answer(descriptor)`, `fx.start(descriptor)` goes to
92
- * `started`, `fx.emit(hint)` goes to `emitted`. `fx.start` refuses a descriptor with `answers`
93
- * and a `guide` with the error the game throws. An `answer` that fails rejects the awaited
94
- * effect, and resolves `undefined` for a `cosmetic` descriptor, as in the game. There is no
95
- * handler, no log, no fast mode and no abort signal here: for those, walk the graph with
96
- * `createHeadless`.
92
+ * `started`, `fx.emit(hint)` goes to `emitted`. `fx.cancel(promise)` resolves an awaited effect
93
+ * that has not settled `undefined` and returns `true`, and returns `false` for any other promise.
94
+ * `fx.start` refuses a descriptor with `answers` and a `guide` with the error the game throws. An
95
+ * `answer` that fails rejects the awaited effect, and resolves `undefined` for a `cosmetic`
96
+ * descriptor, as in the game. There is no handler, no log, no fast mode and no abort signal here:
97
+ * for those, walk the graph with `createHeadless`.
97
98
  *
98
99
  * @param options - The answer of an awaited effect, and the node path for the refusal message.
99
100
  * @returns The `fx` and the lists `awaited`, `started` and `emitted`.
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-BcZrBZKH.mjs";
1
+ import { dn as refuseStart, gn as type, pn as exit, t as createApp, w as flattenFeatures } from "./src-DQdOkAKn.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-yi2XmYWC.mjs";
@@ -9,11 +9,12 @@ const defaultPath = "test";
9
9
  * Builds the `fx` of a node context for a unit test that calls `node.run(context)` itself, with no
10
10
  * app and no runner. It records every call and plays no effect: `await fx(descriptor)` goes to
11
11
  * `awaited` and resolves with `options.answer(descriptor)`, `fx.start(descriptor)` goes to
12
- * `started`, `fx.emit(hint)` goes to `emitted`. `fx.start` refuses a descriptor with `answers`
13
- * and a `guide` with the error the game throws. An `answer` that fails rejects the awaited
14
- * effect, and resolves `undefined` for a `cosmetic` descriptor, as in the game. There is no
15
- * handler, no log, no fast mode and no abort signal here: for those, walk the graph with
16
- * `createHeadless`.
12
+ * `started`, `fx.emit(hint)` goes to `emitted`. `fx.cancel(promise)` resolves an awaited effect
13
+ * that has not settled `undefined` and returns `true`, and returns `false` for any other promise.
14
+ * `fx.start` refuses a descriptor with `answers` and a `guide` with the error the game throws. An
15
+ * `answer` that fails rejects the awaited effect, and resolves `undefined` for a `cosmetic`
16
+ * descriptor, as in the game. There is no handler, no log, no fast mode and no abort signal here:
17
+ * for those, walk the graph with `createHeadless`.
17
18
  *
18
19
  * @param options - The answer of an awaited effect, and the node path for the refusal message.
19
20
  * @returns The `fx` and the lists `awaited`, `started` and `emitted`.
@@ -44,22 +45,56 @@ function fakeFx(options = {}) {
44
45
  const awaited = [];
45
46
  const started = [];
46
47
  const emitted = [];
48
+ const open = /* @__PURE__ */ new Map();
47
49
  /**
48
- * Records one awaited effect and answers it. Both happen at the call. An `answer` that throws
49
- * or rejects is a handler that fails: the effect rejects, never the call. A `cosmetic`
50
- * descriptor swallows that failure and resolves `undefined`, as the gateway of the game does.
50
+ * Asks `options.answer` for one awaited effect. An `answer` that throws or rejects is a handler
51
+ * that fails: the effect rejects, never the call. A `cosmetic` descriptor swallows that failure
52
+ * and resolves `undefined`, as the gateway of the game does.
51
53
  *
52
54
  * @param descriptor - The descriptor the body awaits.
53
55
  * @returns A promise of what `options.answer` gives for it.
54
56
  */
55
- const run = async (descriptor) => {
56
- awaited.push(descriptor);
57
+ const answerOf = async (descriptor) => {
57
58
  try {
58
59
  return await options.answer?.(descriptor);
59
60
  } catch (error) {
60
61
  if (descriptor.cosmetic !== true) throw error;
61
62
  }
62
63
  };
64
+ /**
65
+ * Records one awaited effect and answers it. Both happen at the call. The effect stays open
66
+ * until it settles, or until `cancel` resolves it `undefined`.
67
+ *
68
+ * @param descriptor - The descriptor the body awaits.
69
+ * @returns A promise of what `options.answer` gives for it.
70
+ */
71
+ const run = (descriptor) => {
72
+ awaited.push(descriptor);
73
+ const answered = answerOf(descriptor);
74
+ const early = { end: () => void 0 };
75
+ const effect = new Promise((resolve, reject) => {
76
+ early.end = () => {
77
+ resolve(void 0);
78
+ };
79
+ answered.then(resolve, reject);
80
+ });
81
+ open.set(effect, early.end);
82
+ answered.then(() => open.delete(effect), () => open.delete(effect));
83
+ return effect;
84
+ };
85
+ /**
86
+ * Ends one open effect the fake returned: it resolves `undefined`.
87
+ *
88
+ * @param effect - A promise `run` returned.
89
+ * @returns True when the effect was open and is ended now.
90
+ */
91
+ const cancel = (effect) => {
92
+ const end = open.get(effect);
93
+ if (end === void 0) return false;
94
+ open.delete(effect);
95
+ end();
96
+ return true;
97
+ };
63
98
  const fx = Object.assign(run, {
64
99
  /**
65
100
  * Records one hint. Nothing releases it: the test has no edge to commit.
@@ -78,7 +113,8 @@ function fakeFx(options = {}) {
78
113
  start: (descriptor) => {
79
114
  refuseStart(descriptor, path);
80
115
  started.push(descriptor);
81
- }
116
+ },
117
+ cancel
82
118
  });
83
119
  return Object.freeze({
84
120
  fx,
@@ -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-C9L-dSRf.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-VJcIdmHU.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";
@@ -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-C9L-dSRf.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-CbbpjAo1.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-VJcIdmHU.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-BaarAgv8.mjs";
3
3
  import { Log } from "@moku-labs/common/browser";
4
4
  import { PluginCtx } from "@moku-labs/core";
5
5
 
@@ -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-C9L-dSRf.mjs";
2
- import { o as AudioContextLike, s as Config$4 } from "./types-BZuWxDNn.mjs";
3
- import { J as StringTable, U as I18nApi, Y as TextKey } from "./types-CbbpjAo1.mjs";
4
- import { Et as PlatformProvider, It as audioPlugin, Nt as effectsPlugin, i as screen, t as createApp, wt as platformPlugin } from "./index-sltlACR5.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-VJcIdmHU.mjs";
2
+ import { o as AudioContextLike, s as Config$4 } from "./types-BpmdVJso.mjs";
3
+ import { J as StringTable, U as I18nApi, Y as TextKey } from "./types-BaarAgv8.mjs";
4
+ import { Et as PlatformProvider, It as audioPlugin, Nt as effectsPlugin, i as screen, t as createApp, wt as platformPlugin } from "./index-Dgwheaoi.mjs";
5
5
  import { AnyPluginInstance } from "@moku-labs/core";
6
6
 
7
7
  //#region src/plugins/model/store/providers/memory.d.ts
@@ -1,5 +1,5 @@
1
- import { $r as Snapshot, Wr as Json } from "./types-C9L-dSRf.mjs";
2
- import { t as HeadlessApp } from "./headless-ABpROLSJ.mjs";
1
+ import { $r as Snapshot, Wr as Json } from "./types-VJcIdmHU.mjs";
2
+ import { t as HeadlessApp } from "./headless-CO19o31k.mjs";
3
3
  import { Log } from "@moku-labs/common/browser";
4
4
 
5
5
  //#region src/plugins/flow/doors/types.d.ts
@@ -3930,17 +3930,22 @@ type ProjectionSpec<Item, LayerName extends string, LiftName extends string, Pla
3930
3930
  readonly initialOnly?: InitialOnly<Values, Item>;
3931
3931
  /**
3932
3932
  * The item a closed window of this projection is kept built for, so it opens in the frame after the tap. While
3933
- * `from` does not show its key (`key(item)`, or the name of the projection without `key`), the engine builds its
3934
- * view aside in the idle time of frames, one step a frame, and holds it hidden: never drawn, never hit, `entityOf`
3935
- * does not answer for it. After a commit it reads `warm` again: the same content changes nothing, the same key
3936
- * writes the difference into the held view, another key builds it again. When `from` shows that key the held view
3937
- * is shown at once: the same entity, only what differs from the warm item is written (no `change` hook), and the
3938
- * `enter` and `loop` hooks play as for a new view. A close plays the exit as before; the view is then built again
3939
- * in idle frames. Only on a drawing renderer and a live world (a pause or a fast walk drops the view in work, to be
3940
- * built again after it), and not in the frames of a motion that owns its fields (a loop and a motion that repeats
3941
- * forever do not count); a `warm` or a `view` that throws is logged as `world:projection-failed` and nothing is held
3942
- * until the next commit. The cost is the memory of the held view.
3943
- * Left out, nothing is warmed.
3933
+ * `from` does not show its key (`key(item)`, or the name of the projection without `key`), or shows it with another
3934
+ * content, the engine builds its view aside in the idle time of frames, one step a frame, and holds it hidden: never
3935
+ * drawn, never hit, `entityOf` does not answer for it. After a commit it reads `warm` again: the same content
3936
+ * changes nothing, the same key writes the difference into the held view, another key builds it again. When `from`
3937
+ * shows that key the held view is shown at once: the same entity, only what differs from the warm item is written
3938
+ * (no `change` hook), and the `enter` and `loop` hooks play as for a new view. A close plays the exit as before; the
3939
+ * view is then built again in idle frames. Only on a drawing renderer and a live world (a pause or a fast walk drops
3940
+ * the view in work, to be built again after it), and not in the frames of a motion that owns its fields (a loop and
3941
+ * a motion that repeats forever do not count); a `warm` or a `view` that throws is logged as
3942
+ * `world:projection-failed` and nothing is held until the next commit. The cost is the memory of the held view.
3943
+ *
3944
+ * A gated window (F202) keeps one key from its dim into its open: `from` shows the dim item first, then the open
3945
+ * one. A `warm` that answers the open item while the dim shows has it built under the dim, also through the press
3946
+ * motion of the tapped button; the commit of the open item swaps the views in one frame (the dim view leaves with
3947
+ * the cause `"discard"` and no exit, the held one is shown as above), and a `ready` of the open waits for the build.
3948
+ * A commit of the dim's content as a new object swaps nothing. Left out, nothing is warmed.
3944
3949
  *
3945
3950
  * @param player - The `player` root of the committed state.
3946
3951
  * @param session - The `session` root of the committed state.
@@ -4231,6 +4236,17 @@ type ProjectionState = {
4231
4236
  */
4232
4237
  warmHeld: Set<Entity>; /** The record whose held view is being built now; absent when none is, never written as `undefined`. */
4233
4238
  warmActive?: WarmRecord;
4239
+ /**
4240
+ * The keys an element of a held view registered while a live element of its projection holds the same key, by
4241
+ * projection, then key (F202: the open view of a gated window built under its dim). The live element keeps the key
4242
+ * in `keys` until the show of the record, which moves these over; a drop of the record forgets them.
4243
+ */
4244
+ heldKeys: Map<string, Map<string, Entity>>;
4245
+ /**
4246
+ * The entity `adopt` was last handed while no build and no warm record was in work: an element ui made for a root
4247
+ * held warm, read by the `registerKey` that follows its spawn. `-1` for none.
4248
+ */
4249
+ warmLoose: Entity;
4234
4250
  /**
4235
4251
  * The warm step may find work: a record went cold, or a commit came since the step last found none. A frame at rest
4236
4252
  * reads it and `warmActive` and returns.
@@ -4285,6 +4301,22 @@ type WarmRecord = {
4285
4301
  * Kept when `warm`, `from` or `view` threw, so a throw is logged once per commit and not every frame.
4286
4302
  */
4287
4303
  seen?: Snapshot;
4304
+ /**
4305
+ * The record holds the next view of a key `from` shows live with another content (F202: the open view of a gated
4306
+ * window, built under its dim): it is stepped and polled also while a motion that owns its fields runs.
4307
+ */
4308
+ next: boolean;
4309
+ /**
4310
+ * The step read the record under a motion that owns its fields and passed it over: it is stepped from `pending`,
4311
+ * without a second read, in the first step with no such motion.
4312
+ */
4313
+ waiting: boolean; /** The read a waiting record is stepped from; absent for a read that gave no item. */
4314
+ pending?: WarmRead;
4315
+ };
4316
+ /** What the warm step read for a record: the item and its key. */
4317
+ type WarmRead = {
4318
+ item: unknown;
4319
+ key: string;
4288
4320
  };
4289
4321
  /**
4290
4322
  * The build of the next scene aside (spec 31): its projections mounted into a table of their own, so a name never has
@@ -4743,10 +4775,13 @@ type ProjectionApi = {
4743
4775
  * Gives an entity a projection and key of its own, so `entityOf` and `keyOf` answer for it next
4744
4776
  * to the live views. That is how an element becomes a target for `anim`, `input` and `guide`.
4745
4777
  * A key whose entity is gone is dropped in the next live frame, also when the remover was never
4746
- * called. An element registered while the projection's warm window is held and the projection
4747
- * shows no live view belongs to the held root (a row its list ranged in after it was built): it
4748
- * is held with the window, `isBuilding` answers true and `entityOf` nothing until the open. A
4749
- * projection that shows other keys live while it warms one is not covered: its elements answer.
4778
+ * called. An element registered while the projection's warm window holds a view not shown belongs
4779
+ * to the held root (a row its list ranged in after it was built) when the projection shows no
4780
+ * live view, or when `adopt` was handed it since its spawn (ui adopts every element of a held
4781
+ * root): it is held with the window, `isBuilding` answers true and `entityOf` nothing until the
4782
+ * open. An element of a live view of the projection answers. While a live element holds the same
4783
+ * key, the held element waits: `entityOf` answers the live one until the held view is shown in
4784
+ * its place, then the held one (F202, the open view of a gated window built under its dim).
4750
4785
  *
4751
4786
  * @param projection - Name the element is addressed under.
4752
4787
  * @param key - Key the element is addressed under.
@@ -4765,6 +4800,11 @@ type ProjectionApi = {
4765
4800
  * // A row the shop's list ranges in while the shop is closed and held warm.
4766
4801
  * world.projection.registerKey("shop.sheet", "w15", row);
4767
4802
  * world.projection.entityOf("shop.sheet", "w15"); // undefined until the shop opens
4803
+ *
4804
+ * // The vitrine dims; its open view, built under the dim, has a scrim keyed as the dim's.
4805
+ * world.projection.adopt(openScrim);
4806
+ * world.projection.registerKey("vitrine", "scrim", openScrim);
4807
+ * world.projection.entityOf("vitrine", "scrim"); // dimScrim, until the open swaps the views
4768
4808
  * ```
4769
4809
  */
4770
4810
  registerKey(projection: string, key: string, entity: Entity): () => void;
@@ -4914,7 +4954,7 @@ type ProjectionApi = {
4914
4954
  /**
4915
4955
  * Whether an entity is built aside or held warm: a view the running build spawned, the view a warm window holds
4916
4956
  * hidden (`warm` of a projection), an entity `adopt` marked for either, or an element registered with `registerKey`
4917
- * for a closed warm window. Such an entity is not drawn, not hit and not found until it is shown. A view is flagged before the `onAdded` hooks of its components, so a hook can ask.
4957
+ * for the root a warm window holds. Such an entity is not drawn, not hit and not found until it is shown. A view is flagged before the `onAdded` hooks of its components, so a hook can ask.
4918
4958
  * Two set lookups; false after the commit of the build and once `from` shows the warm view. Allocates nothing.
4919
4959
  *
4920
4960
  * @param entity - The entity to ask about.
@@ -4953,8 +4993,9 @@ type ProjectionApi = {
4953
4993
  /**
4954
4994
  * Marks an entity another plugin spawned for a root built aside or held warm, so `isBuilding` answers for the whole
4955
4995
  * tree and a discard despawns it with the rest. It joins the running scene build, else the warm window being built
4956
- * now; does nothing when neither runs. The commit of the build, and the open of the window, clear the mark with
4957
- * every other.
4996
+ * now. When neither runs it marks nothing, but a `registerKey` of the same entity that follows holds it with the
4997
+ * window its projection holds (a row of a held root's list, ranged in after the window was built). The commit of
4998
+ * the build, and the open of the window, clear the mark with every other.
4958
4999
  *
4959
5000
  * @param entity - The entity to mark.
4960
5001
  * @example
@@ -5330,9 +5371,10 @@ type GuideOptions = {
5330
5371
  text?: string;
5331
5372
  };
5332
5373
  /**
5333
- * Handler of one effect kind, registered by a plugin above `flow`. `signal` is the node's abort
5334
- * signal, except for a descriptor with `answers` and for `guide`: those get a signal of their own,
5335
- * aborted when the answer arrives or the narrow is lifted, so the handler unmounts what it showed.
5374
+ * Handler of one effect kind, registered by a plugin above `flow`. `signal` is a signal that ends
5375
+ * with the node, or earlier on `fx.cancel` and, for a popup, at the body's return. A descriptor
5376
+ * with `answers` and a `guide` get a signal of their own, aborted as well when the answer arrives
5377
+ * or the narrow is lifted, so the handler unmounts what it showed.
5336
5378
  *
5337
5379
  * @example
5338
5380
  * ```ts
@@ -5446,7 +5488,9 @@ type FxApi = {
5446
5488
  /**
5447
5489
  * The `fx` of a node context, and of the context of `recover`. Three ways to reach what is not
5448
5490
  * logic: `await fx(descriptor)` runs an effect and waits for it, `fx.start(descriptor)` starts one
5449
- * now and does not wait, `fx.emit(hint)` keeps a cosmetic hint until the edge has committed. The
5491
+ * now and does not wait, `fx.emit(hint)` keeps a cosmetic hint until the edge has committed.
5492
+ * `fx.cancel(promise)` ends an awaited effect early, and the body's return closes the popups it
5493
+ * left open. The
5450
5494
  * awaited value is typed by the descriptor: what its helper or its `defineEffect` declared,
5451
5495
  * `unknown` for a descriptor written by hand.
5452
5496
  *
@@ -5498,6 +5542,35 @@ type NodeFx = (<Result>(descriptor: Descriptor<Result>) => Promise<Result>) & {
5498
5542
  * ```
5499
5543
  */
5500
5544
  start(descriptor: Descriptor): void;
5545
+ /**
5546
+ * Ends one awaited effect of this node early, without leaving the node. Its handler's signal is
5547
+ * aborted, so a popup unmounts; for a descriptor with `answers` the gate closes as well. The
5548
+ * promise then resolves `undefined`, also where the descriptor's result type has no `undefined`
5549
+ * in it: a body that cancels an effect does not read its value. The body's return closes the
5550
+ * popups it left open anyway; `cancel` is for an effect that has to go while the node goes on.
5551
+ *
5552
+ * @param effect - A promise this node's `fx(...)` returned.
5553
+ * @returns `true` when the effect was open and is ended now. `false` for an effect that settled
5554
+ * or was cancelled already, one of another node, a `guide`, any other promise, and for every
5555
+ * call after the node's abort: then nothing happens.
5556
+ * @example
5557
+ * ```ts
5558
+ * // The "wait" node: the popup Loading (outcome "back") stands while the board bundle loads.
5559
+ * run: async ({ fx, out }) => {
5560
+ * const shown = fx(popup(Loading, {}));
5561
+ * const back = shown.then(() => "back" as const);
5562
+ * const there = await Promise.race([back, fx(load("board")).then(() => "loaded" as const)]);
5563
+ *
5564
+ * if (there === "back") return out.back();
5565
+ *
5566
+ * fx.cancel(shown); // true: Loading unmounts, its gate closes, `shown` resolves undefined
5567
+ * await fx(popup(Tip, {})); // the next popup opens the gate for its own answers
5568
+ *
5569
+ * return out.ready();
5570
+ * }
5571
+ * ```
5572
+ */
5573
+ cancel(effect: Promise<unknown>): boolean;
5501
5574
  };
5502
5575
  /**
5503
5576
  * How an effect a game declares behaves; see `defineEffect`. `fast: "run"` runs its handler in a
@@ -5515,7 +5588,8 @@ type EffectOptions = {
5515
5588
  };
5516
5589
  /**
5517
5590
  * The handler of one declared effect: the typed payload in, the result out. The context is the
5518
- * gateway's: the node's abort signal and the mode of the walk.
5591
+ * gateway's: a signal that ends with the node, or earlier on `fx.cancel` and, for a popup, at the
5592
+ * body's return, and the mode of the walk.
5519
5593
  *
5520
5594
  * @example
5521
5595
  * ```ts
@@ -14725,7 +14799,7 @@ type State = {
14725
14799
  warned: Set<string>;
14726
14800
  /**
14727
14801
  * `onEnter`, the `load` and `ready` handlers, the texture provider, the start and the end of an exit in `world`,
14728
- * and the system `assets.leave` of phase `sync`.
14802
+ * and the systems `assets.leave` and `assets.ready` of phase `sync`.
14729
14803
  */
14730
14804
  removers: Array<() => void>; /** The `files` map of the stamp the dev hot swap applied last. `undefined` until the first swap. */
14731
14805
  stamps: Readonly<Record<string, string>> | undefined; /** The running dev hot swap. The next one waits for it, so two swaps never overlap. */
@@ -14755,6 +14829,15 @@ type State = {
14755
14829
  */
14756
14830
  readyFailed: Set<string>; /** One running or finished warm per bundle, joined by a second `warm`; dropped when the bundle unloads (F60). */
14757
14831
  warmed: Map<string, WarmEntry>;
14832
+ /**
14833
+ * Where a `ready` stands on a warm view in work (F202, the open view of a gated window built under its dim):
14834
+ * `"none"`, `"warm"` while a `ready` answered `false` waits for the build to post, or `"waived"` after the cap
14835
+ * posted with the build still in work, so a re-ask goes on, until the build ends. The system `assets.ready` reads it
14836
+ * each frame.
14837
+ */
14838
+ readyWait: "none" | "warm" | "waived"; /** The game clock (`Time.elapsed`) of the first frame the `"warm"` wait was seen, the start of its cap; -1 before. */
14839
+ readySince: number; /** The number of the ask (`readyAsk`) whose post the `"warm"` wait holds; its post goes through `settleAsk` (F204). */
14840
+ readyWarmAsk: number;
14758
14841
  };
14759
14842
  /**
14760
14843
  * What `usage()` reports about one loaded bundle.
@@ -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-C9L-dSRf.mjs";
2
- import { W as AnimApi, r as UiApi } from "./types-BZuWxDNn.mjs";
3
- import { R as InputApi } from "./types-CbbpjAo1.mjs";
4
- import { r as Repro } from "./headless-ABpROLSJ.mjs";
5
- import { i as ControlApp, o as InputOf } from "./types-D9J6jJ6g.mjs";
6
- import { t as commands } from "./commands-DCBhp5aM.mjs";
1
+ import { Ar as Api$1, Fr as Api$4, Q as Api, Vr as Api$2, ii as Api$3 } from "./types-VJcIdmHU.mjs";
2
+ import { W as AnimApi, r as UiApi } from "./types-BpmdVJso.mjs";
3
+ import { R as InputApi } from "./types-BaarAgv8.mjs";
4
+ import { r as Repro } from "./headless-CO19o31k.mjs";
5
+ import { i as ControlApp, o as InputOf } from "./types-CbSTnp8T.mjs";
6
+ import { t as commands } from "./commands-DXSaq2AP.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-BmR3GBMY.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-Dw4QXpgC.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/llms.txt CHANGED
@@ -44,6 +44,7 @@ Root exports:
44
44
  - A pure wait ends in two ways. A gate answer whose `intent` is an outcome name: the answer payload becomes the outcome payload. Or a world event whose `type` is listed in the node's `inbox`: the event payload becomes the outcome payload.
45
45
  - Transition: rest node to rest node. It is a transaction. On an error the runner discards, rolls back to the last rest point, retries `retries` times, then enters `safeNode`. A failure inside `safeNode` rejects `run()`.
46
46
  - Three ways to run an effect in a node. `await fx(descriptor)`: the node waits for it. `fx.start(descriptor)`: it starts now and the node goes on; write it in place of `void fx(...)`. A failure of a started effect is the log entry `flow:fx-start-failed` and never fails the node. A `cosmetic` descriptor (`sfx`, `play`, `haptic`, `music`) that fails, awaited or started, is the warn entry `flow:fx-cosmetic-failed` with `{ kind, message }` and resolves `undefined`; a descriptor with `answers` and a `guide` are refused, they have to be awaited. `fx.emit(hint(...))`: released after the commit of the edge, dropped in fast mode.
47
+ - A body's return closes the popups it left open. A body may show a popup without awaiting it (`const shown = fx(popup(Loading, {}))`, raced against a load) and return an outcome: when it returns, with an outcome or a failure, each popup still open is closed in the order it was shown, its handler's signal aborted (the popup unmounts) and the gate shut, so the next rest opens its own gate. The same holds for `recover`. Other awaited effects nobody waited for run on. A body the inbox, a restore or a stop already left closes nothing when it returns late. `fx.cancel(promise)` ends one awaited effect early while the node stays: for an open effect of this node it aborts the handler's signal, shuts the gate when the descriptor has `answers`, resolves the promise `undefined` (whatever the descriptor's type says) and returns `true`; for a settled or cancelled effect, a `guide`, another node's effect, any other promise, or after the node's abort it does nothing and returns `false`. Pass the promise `fx(...)` returned, not one built from it with `.then`. So `fx.cancel(shown); await fx(popup(Tip, {}))` opens the next popup in the same node.
47
48
  - `await fx(descriptor)` is typed by the descriptor (`Flow.Descriptor<Result>`): `schedule`, `guide`, `music`, `sfx`, `haptic`, `play` resolve `void`; `load` resolves `Assets.LoadResult | undefined` (`undefined` without `assets`, as in `game.headless()`); `ready` resolves `boolean | undefined` (`true` when every bundle is loaded and on the GPU, `undefined` without `assets`, so compare `=== false`); `popup(Component, props)` resolves `Flow.Answered<outcome names>`, `{ intent, payload?, at }` with `at` the `clock.now()` moment the answer arrived (live and in a fast walk alike), so comparing it with an intent the component does not declare is a compile error; a descriptor written by hand resolves `unknown`. A game declares its own: `const envRead = defineEffect<{ notice: boolean }, EnvRead>("view-env.read", { fast: "run" })`, then `await fx(envRead({ notice: true }))` is `EnvRead` and `envRead.handle(ctx.require(flowPlugin).fx, payload => ...)` registers the one handler (returns the remover). Only `{ fast: "run" }` without `cosmetic` resolves `Result`; any other declaration resolves `Result | undefined`. `NodeFx` is generic: a hand-written fake is typed `as NodeFx`, or use `fakeFx`.
48
49
  - Every failure is written into the log by the engine: an `error` entry `flow:error` with `{ path, rolledBackTo, retry, error: { message, stack } }`. Read it with `app.log.trace()`. A game needs no plugin for it.
49
50
  - `recover` on a rest node: `recover: async ({ player, session, rng, fx, signal, now }) => { ... }`. It runs only when the runner gave up on a transition and enters this node as `safeNode`, before the node is entered. The rollback left the state of the failed rest point; `recover` writes the drafts so the safe node can draw itself. What it wrote commits as one edge with `outcome: "recover"` and becomes the rest point. A `recover` that throws rejects `run()`. A retry does not run it. So the safe node stays a pure wait: no `run` body, no extra outcome, no self edge.
@@ -138,7 +139,7 @@ type NodeContext = {
138
139
  player: Player; // draft of the saved player tree, mutate it
139
140
  session: Session; // draft of the session tree, never saved
140
141
  rng: RngView; // rng.stream(id) gives a deterministic stream
141
- fx: NodeFx; // await fx(descriptor), fx.start(descriptor), fx.emit(hint(...))
142
+ fx: NodeFx; // await fx(descriptor), fx.start(descriptor), fx.emit(hint(...)), fx.cancel(promise)
142
143
  out: Out; // one method per declared outcome
143
144
  signal: AbortSignal; // aborted on stop, restore and inbox delivery
144
145
  now: number; // clock.now() read once at node entry
@@ -565,14 +566,15 @@ The graph. Modules `runner`, `gate`, `inbox`, `fx`, `features`. Runner methods s
565
566
  - 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
567
  - 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
568
  - 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
- - `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
+ - `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; in live mode it also answers `false` while a warm view is in work (`world.projection.left()` finite) and posts once that build ended, at most 400 ms (game clock) after the bundles settled (F202). 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
570
  - `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.
570
571
  - `Now` is the engine resource of the frame's moment: `world` writes `clock.now()` into it at start and first thing in every frame, headless too, so every system of a frame reads one moment: `const { now } = res(Now)`; a fake clock makes it exact. A system that shows time writes its component only when its picture changes. `snapshot().resources` holds `Now: { now }`. Reserved resource names: `Now`, `Pointer`, `AnimPlayer`, `UiCounters`; a game resource of one of them throws `[game] world: the resource name "Now" is the engine's (the frame's moment).`
571
572
  - When a system runs: before each run the world checks it. A system with a `query` is skipped while a term of its query has no entity (the smallest store among the terms is empty): no walk, no `mut()` mark, no timing. A system without a query always runs. `system({ ..., scenes: ["board"] })` runs only while one of those scenes is mounted or leaving: `scenes` calls `app.world.ecs.setScene(id)` at every switch, and the scene before leaves until nothing carries `Exiting` (the elements of its JSX views played their exit; the next scene's entities already stand then, so a `scenes` system writes only its own scene's entities). A dev build throws at start for a name in `scenes` no feature declares: `[game] System "board.idle" runs on the scene "bord", which no feature declares.` `ctx.resumed` is true on the first run after a skip (a cache or a remembered cue starts over then). The same for every system, the engine's included; 0 B a frame. A run with no rows does not happen any more: work a system did besides its rows (a hover, a drop or a press that ends, a resource reset, something that outlives its entities) goes to a system with `query: []` and `scenes`, reading its rows with `world.query()`. From 0.15.3: delete `systemsRun` from every feature (the type refuses it), rewrite the systems that work outside their rows, add `scenes` only to a system whose entities stand on every screen; `ecs.hold` and `ecs.isActive` are gone (a test asks `app.scenes.current()` or whether the system ran). World README, "When a system runs".
572
573
  - Motion hooks are told why they play: `enter(view, item, hint, cause)` and `exit(view, item, hint, cause)` get `World.MotionCause`, `"mount"` (the view comes or goes with its screen: a mount, an unmount, a load, a restore, a paused or fast world) or `"change"` (a commit). A world projection plays them only for `"change"`; `ui` plays them for both. `app.world.projection.causeOf(entity)` answers how a view came or how it is leaving, also in a removal hook of its despawn, until the next frame.
573
574
  - `app.world.projection.replace(spec)` swaps the spec of a registered projection; a mounted one runs its new `view` on the next frame. An unknown name throws. The caller is the dev hot swap.
574
575
  - `projection({ …, initialOnly: [[Shape, ["sweep"]]] })`: `view` gives those fields once, at the birth of a view; after that they belong to another writer (a system drawing a timer arc from `Now`), and no changed item, motion, end-of-motion check (`world:view-corrected`), rollback, `settle`, restore or load writes or compares them, as with `mute()` for every view's whole life. Field names are checked per component; a pair with no field throws at register. Absent, every field is the projection's.
575
- - `projection({ …, warm: (player, session) => item })`: a warm window, since 0.15.47. `warm` returns one item of the type `from` gives, the window as it opens (its closed or default state); while `from` does not show that key, the world builds its view in idle frames (by root and by part, under two thirds of the frame interval, only in a live world on a drawing renderer, never while an owned motion runs) and keeps it hidden: not drawn, not hit, `entityOf` answers nothing. When `from` shows the key, the open only shows the held view in the next frame: an item equal to the warm one writes nothing, another one writes only the difference; `enter` and `loop` play as for a new view. Example, a settings sheet: `projection({ name: "settings.sheet", layer: "ui", from: (player, session) => session.sheet?.kind === "settings" ? [settingsModel(player, session, tables)] : [], key: sheet => sheet.id, view: settingsView, warm: (player, session) => settingsModel(player, { ...session, sheet: { kind: "settings", page: "main" } }, tables) })`. Cost: the memory of the held view (A Memory Missing's album: about +2 MB of JS heap, textures unchanged); after each close the view goes cold and is built again in idle frames (the album: 41–58 frames of work, about a second, at 6× CPU); a commit that changes the warm item rebuilds it, so it suits windows whose item rarely changes (settings, a shop). A `warm` or a `view` that throws logs `world:projection-failed` and the window opens as before. World README, "Warm windows".
576
+ - `projection({ …, warm: (player, session) => item })`: a warm window, since 0.15.47. `warm` returns one item of the type `from` gives, the window as it opens (its closed or default state); while `from` does not show that key, or shows it with another content (a gated window's dim, below), the world builds its view in idle frames (by root and by part, under two thirds of the frame interval, only in a live world on a drawing renderer, never while an owned motion runs but for a gated window's dim) and keeps it hidden: not drawn, not hit, `entityOf` answers nothing. When `from` shows the key, the open only shows the held view in the next frame: an item equal to the warm one writes nothing, another one writes only the difference; `enter` and `loop` play as for a new view. Example, a settings sheet: `projection({ name: "settings.sheet", layer: "ui", from: (player, session) => session.sheet?.kind === "settings" ? [settingsModel(player, session, tables)] : [], key: sheet => sheet.id, view: settingsView, warm: (player, session) => settingsModel(player, { ...session, sheet: { kind: "settings", page: "main" } }, tables) })`. Cost: the memory of the held view (A Memory Missing's album: about +2 MB of JS heap, textures unchanged); after each close the view goes cold and is built again in idle frames (the album: 41–58 frames of work, about a second, at 6× CPU); a commit that changes the warm item rebuilds it, so it suits windows whose item rarely changes (settings, a shop). A `warm` or a `view` that throws logs `world:projection-failed` and the window opens as before. World README, "Warm windows".
577
+ - A gated window (F202) keeps one key from its dim into its open (`from` shows the dim item, then the open one, while `ready` loads its pictures). Give it a `warm` that answers the open item while the dim shows (and nothing otherwise): the open view is built aside under the dim, also through the press tween of the tapped button (other warm windows wait for that motion to end), and the commit of the open item swaps the views in one frame: the dim view leaves at once (cause `"discard"`, no exit), the held one is shown with its `enter`, only the difference to the warm item written. A commit of the dim's content as a new object swaps nothing. While the dim shows, `entityOf` answers the dim's elements for keys both views have (the root, the scrim) and the open's after the swap. `ready` waits for the build too: it answers `false` while `world.projection.left()` is finite and posts once the build ended, at most 400 ms (game clock) after its bundles settled. World README, "A gated window".
576
578
  - `from(player, session, sw)`: the third argument is the switch another plugin last handed the projection with `projection.feed(name, sw)`, a `SceneSwitch` `{ from, to, progress }` (the scene left, the scene entered, `progress` 0 to 1), `undefined` for a projection never fed; a `from` with two parameters reads the state alone, as before. A loader reads it: `from: (_player, _session, sw: SceneSwitch | undefined) => ({ to: sw?.to ?? "", progress: sw?.progress ?? 0 })`. World README, "Feeding a projection".
577
579
  - `app.input.lock.window(rect | null | undefined)`: the input lock `ui` sets for a guide (`Input.LockWindow` = `{ x, y, w, h }` in reference units, kept by reference and written in place); a press outside reaches no view and answers `flow.gate.state().blocked` or nothing, a drop or trace sample outside finds nothing; `null` locks everything, `undefined` lifts it. The doors `tap`, `press`, `drag`, `swipe`, `trace` are never locked.
578
580
  - `input`: one followed pointer. A finger that has not started a gesture (pressed, inside the tap slop, no long press, no trace) gives way to the next finger that goes down, wherever it rests, and its press is cancelled; a finger that started a gesture keeps it. `Pointer.id` is the followed `pointerId` (`-1` at rest): a system that measures the finger's travel starts over when it changes.
@@ -763,7 +765,7 @@ The scanner keys it `ui.font-body`, which is the `text` config default `fonts.bo
763
765
 
764
766
  ## Testing entry
765
767
 
766
- Exports of `@moku-labs/game/testing`: `createHeadless`, `runRepro`, `stepFrames`, `fakeClock`, `memory`, `saveOf`, `isolate`, `stub`, `fakeFx`. `fakeFx(options?)` is the `fx` of a node context for a unit test that calls `node.run?.({ ...context, fx: fake.fx })`: it returns `{ fx, awaited, started, emitted }`, `options.answer(descriptor)` gives what an awaited effect resolves with, and `fx.start` refuses `answers` and a `guide` as the game does. The visual tests `defineVisualTest`, `runVisualTests`, `parseVisualArgv` come from `@moku-labs/game/visual`, node and bun only (see `docs/testing.md` in the engine repository).
768
+ Exports of `@moku-labs/game/testing`: `createHeadless`, `runRepro`, `stepFrames`, `fakeClock`, `memory`, `saveOf`, `isolate`, `stub`, `fakeFx`. `fakeFx(options?)` is the `fx` of a node context for a unit test that calls `node.run?.({ ...context, fx: fake.fx })`: it returns `{ fx, awaited, started, emitted }`, `options.answer(descriptor)` gives what an awaited effect resolves with, `fx.cancel(promise)` resolves an effect it returned that has not settled `undefined` and returns `true` (`false` for any other promise), and `fx.start` refuses `answers` and a `guide` as the game does. The visual tests `defineVisualTest`, `runVisualTests`, `parseVisualArgv` come from `@moku-labs/game/visual`, node and bun only (see `docs/testing.md` in the engine repository).
767
769
 
768
770
  - `createHeadless(app): Promise<HeadlessGame>`. Pass an app that is not started. It sets mode `"fast"`, awaits `app.start()`, starts `flow.run()` unless the app's `onStart` already did, and resolves when the loop rests for the first time: `game.state().path` already names the first rest node. A fatal error of `run()` rejects the call.
769
771
  - `HeadlessGame`: `walk(route): Promise<FlowState>`, `answer(answer): boolean`, `state()`, `history()`, `stop()`. `walk` and `stop` throw a fatal error of the loop again when the headless runner owns `run()`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moku-labs/game",
3
- "version": "0.15.148",
3
+ "version": "0.15.150",
4
4
  "description": "2D puzzle game engine on TypeScript and PixiJS, built on @moku-labs/core.",
5
5
  "type": "module",
6
6
  "sideEffects": [