@moku-labs/game 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +5 -4
  2. package/dist/assets.d.mts +1 -1
  3. package/dist/{capture-fpd83Mi5.mjs → capture-BX5Gfoty.mjs} +1 -384
  4. package/dist/{commands-mzE9PX0H.d.mts → commands-C1kIfOG5.d.mts} +6 -4
  5. package/dist/control.d.mts +4 -3
  6. package/dist/control.mjs +2 -2
  7. package/dist/{define-BbgXv4cy.d.mts → define-BPpZcpxW.d.mts} +4 -3
  8. package/dist/headless-CvamCUcR.mjs +186 -0
  9. package/dist/headless-q98SwADR.d.mts +181 -0
  10. package/dist/index.d.mts +23 -22
  11. package/dist/index.mjs +15 -6
  12. package/dist/{input-CK4nxBO1.mjs → input-z_35Jwfn.mjs} +2 -2
  13. package/dist/inspect.d.mts +8 -6
  14. package/dist/inspect.mjs +2 -2
  15. package/dist/jsx-dev-runtime.d.mts +1 -1
  16. package/dist/jsx-runtime.d.mts +1 -1
  17. package/dist/project.d.mts +28 -28
  18. package/dist/project.mjs +7 -7
  19. package/dist/registry-DlpRCibU.mjs +384 -0
  20. package/dist/{run-Bcyg32M5.mjs → run-CUPSFM85.mjs} +4 -187
  21. package/dist/{runtime-HTlmRb81.d.mts → runtime-CvDZZg1S.d.mts} +1 -1
  22. package/dist/{sources-DVWJ8nfr.mjs → sources-BBUd15vQ.mjs} +1 -1
  23. package/dist/testing.d.mts +3 -328
  24. package/dist/testing.mjs +2 -2142
  25. package/dist/{types-BMEn0tSC.d.mts → types-BWzCSRM2.d.mts} +12 -2974
  26. package/dist/{types-CYYKjvLn.d.mts → types-CDSKa0vl.d.mts} +5 -182
  27. package/dist/{types-ClF8say0.d.mts → types-DF5kkW-C.d.mts} +5 -4
  28. package/dist/{types-BaUUcIaN.d.mts → types-DgdMLZnV.d.mts} +8 -7
  29. package/dist/{types-CXyipKhE.d.mts → types-DlgsfOmW.d.mts} +10 -9
  30. package/dist/types-ERb2Y9U5.d.mts +2967 -0
  31. package/dist/visual.d.mts +331 -0
  32. package/dist/visual.mjs +2142 -0
  33. package/llms.txt +6 -5
  34. package/package.json +7 -8
@@ -1,184 +1,7 @@
1
- import { At as JournalEntry, Kt as Json, Lt as Answer, Rt as Api, in as RngState, jt as RouteStep, kt as FlowState, tn as Snapshot, ut as Api$1 } from "./types-BMEn0tSC.mjs";
1
+ import { R as Json, q as Snapshot } from "./types-ERb2Y9U5.mjs";
2
+ import { t as HeadlessApp } from "./headless-q98SwADR.mjs";
2
3
  import { Log } from "@moku-labs/common/browser";
3
4
 
4
- //#region src/plugins/flow/headless.d.ts
5
- /**
6
- * The part of an app the headless helpers use. Structural on purpose: any app created with the
7
- * default plugins fits.
8
- *
9
- * @example
10
- * ```ts
11
- * const app: HeadlessApp = createApp({ pluginConfigs: { flow: { mainFlow } } });
12
- * ```
13
- */
14
- type HeadlessApp = {
15
- start(): Promise<void>;
16
- stop(): Promise<void>;
17
- time: Api;
18
- flow: Api$1;
19
- };
20
- /**
21
- * A game played without a screen: answers go through the gate, effects resolve instantly.
22
- *
23
- * @example
24
- * ```ts
25
- * // A test of the dice game: two rolls, no screen, no waiting.
26
- * const game = await createHeadless(app);
27
- * const state = await game.walk([{ at: "home", intent: "roll" }, { at: "home", intent: "roll" }]);
28
- *
29
- * state.path; // "home"
30
- * await game.stop();
31
- * ```
32
- */
33
- type HeadlessGame = {
34
- /**
35
- * Walks a route through the running loop.
36
- *
37
- * @param route - The player's answers and substituted sub-flow results, in order.
38
- * @returns The state the walk ended in.
39
- * @throws {Error} When a step is never reached, or the loop failed fatally.
40
- * @example
41
- * ```ts
42
- * // Open the board and tap the generator twice. Every node's logic runs for real.
43
- * const tap = { at: "board/awaitIntent", intent: "tap", payload: { generatorId: "sawmill" } };
44
- * const state = await game.walk([{ at: "home", intent: "play" }, tap, tap]);
45
- *
46
- * state.path; // "board/awaitIntent"
47
- * ```
48
- */
49
- walk(route: readonly RouteStep[]): Promise<FlowState>;
50
- /**
51
- * Gives one answer to the gate, the way a tap does.
52
- *
53
- * @param answer - Intent and optional payload.
54
- * @returns Whether the gate took it.
55
- * @example
56
- * ```ts
57
- * // One tap without a route. The test then waits for the loop by itself.
58
- * game.answer({ intent: "play" }); // true: "home" rests and lists "play"
59
- * ```
60
- */
61
- answer(answer: Answer): boolean;
62
- /**
63
- * Reads where the graph stands.
64
- *
65
- * @returns Whether it runs, the path, the stack, what it waits for and the mode.
66
- * @example
67
- * ```ts
68
- * // Right after createHeadless: the graph rests at its first rest node.
69
- * game.state().path; // "home"
70
- * game.state().pending; // { gate: ["play"] }
71
- * ```
72
- */
73
- state(): FlowState;
74
- /**
75
- * Reads the edges taken since the last checkpoint.
76
- *
77
- * @returns A copy of the journal.
78
- * @example
79
- * ```ts
80
- * // After a merge onto an empty cell: the last edge says why the move was refused.
81
- * const last = game.history().at(-1);
82
- * // last?.path: "board/merge", last?.outcome: "rejected", last?.payload: { reason: "empty" }
83
- * ```
84
- */
85
- history(): readonly JournalEntry[];
86
- /**
87
- * Stops the app, then re-throws a fatal error of the loop.
88
- *
89
- * @throws {Error} When the loop failed fatally.
90
- * @example
91
- * ```ts
92
- * // The last line of a headless test. A fatal error of the loop fails the test here.
93
- * await game.stop();
94
- * ```
95
- */
96
- stop(): Promise<void>;
97
- };
98
- /**
99
- * A reproducible run: a starting state, an optional checkpoint and the route played from it.
100
- *
101
- * @example
102
- * ```ts
103
- * const repro: Repro = { player: { coins: 0 }, checkpoint: "home", route: [{ at: "home", intent: "play" }] };
104
- * ```
105
- */
106
- type Repro = {
107
- player: Json;
108
- session?: Json;
109
- rng?: RngState;
110
- checkpoint?: string;
111
- route: RouteStep[];
112
- };
113
- /**
114
- * What a repro run ends with: the path where the loop rests and the committed state.
115
- *
116
- * @example
117
- * ```ts
118
- * const result: ReproResult = { path: ["home"], player: { coins: 3 }, session: { visits: 1 } };
119
- * ```
120
- */
121
- type ReproResult = {
122
- path: string[];
123
- player: Json;
124
- session: Json;
125
- };
126
- /**
127
- * Starts an app headless: sets flow mode `"fast"`, awaits `app.start()`, starts `flow.run()`
128
- * unless the app's own `onStart` already did, and waits until the loop rests for the first time.
129
- * `game.state().path` therefore names the first rest node of the graph as soon as the call
130
- * resolves. A fatal error of the loop rejects this call, and a later one is re-thrown by `walk`
131
- * and by `stop`, so a headless test never loses it.
132
- *
133
- * @param app - An app that is not started yet.
134
- * @returns The game: walk it, answer it, read it, stop it.
135
- * @throws {Error} When the loop failed fatally before it reached its first rest node.
136
- * @example
137
- * ```ts
138
- * // A test starts the merge game without a screen. The call resolves at the first rest node.
139
- * const game = await createHeadless(app);
140
- *
141
- * game.state().path; // "home": the transit node "boot" was played out
142
- * game.state().mode; // "fast"
143
- * await game.stop();
144
- * ```
145
- */
146
- declare function createHeadless(app: HeadlessApp): Promise<HeadlessGame>;
147
- /**
148
- * Plays a repro: starts the app headless, restores the bookmark built from its state and
149
- * checkpoint, then walks its route. The app keeps running, so the caller can read more than the
150
- * result and stops it itself.
151
- *
152
- * @param app - An app that is not started yet.
153
- * @param repro - Starting state, optional checkpoint and the route.
154
- * @returns The path the run ended at, and the committed state.
155
- * @example
156
- * ```ts
157
- * // A bug report on the dice game: "reset keeps my coins". Replay it from the "home" checkpoint.
158
- * const reset = { at: "home", intent: "reset" };
159
- * const result = await runRepro(app, { player: { coins: 7 }, checkpoint: "home", route: [reset] });
160
- *
161
- * result.player; // { coins: 0 }; result.path is ["home"]
162
- * await app.stop(); // the app keeps running after the run
163
- * ```
164
- */
165
- declare function runRepro(app: HeadlessApp, repro: Repro): Promise<ReproResult>;
166
- /**
167
- * Steps the frame loop by hand: `count` calls of `app.time.step(deltaMs)`. A headless game has no
168
- * frame source, so this is the only thing that moves the frame phases.
169
- *
170
- * @param app - A started app.
171
- * @param count - Number of frames.
172
- * @param deltaMs - Milliseconds per frame.
173
- * @example
174
- * ```ts
175
- * // A headless game has no frame source: the test moves the six frame phases by hand.
176
- * stepFrames(app, 2, 16);
177
- * app.time.snapshot(); // frame: 2, delta: 16, elapsed: 32
178
- * ```
179
- */
180
- declare function stepFrames(app: HeadlessApp, count: number, deltaMs: number): void;
181
- //#endregion
182
5
  //#region src/plugins/flow/doors/types.d.ts
183
6
  /**
184
7
  * The kinds an input field can take. `json` is any JSON value the command checks itself.
@@ -276,7 +99,7 @@ type Effect = "read" | "route" | "cosmetic" | "cheat" | "raw";
276
99
  * ```ts
277
100
  * // A game's .dev module: the coins a panel shows, re-read on every commit.
278
101
  * const coins = defineSource({
279
- * id: "timber.coins",
102
+ * id: "mini.coins",
280
103
  * title: "Coins",
281
104
  * input: {},
282
105
  * changes: "commit",
@@ -300,7 +123,7 @@ type Source<S extends InputSchema, O, App = HeadlessApp> = {
300
123
  * ```ts
301
124
  * // A game's .dev module: jump to a level through the graph, the session stays clean.
302
125
  * const jumpToLevel = defineCommand({
303
- * id: "timber.jumpToLevel",
126
+ * id: "mini.jumpToLevel",
304
127
  * title: "Go to level",
305
128
  * input: { level: "number" },
306
129
  * effect: "route",
@@ -389,4 +212,4 @@ type ControlApp = HeadlessApp & {
389
212
  readonly log: Log.LogApi;
390
213
  };
391
214
  //#endregion
392
- export { stepFrames as _, InputOf as a, Source as c, HeadlessApp as d, HeadlessGame as f, runRepro as g, createHeadless as h, InputArguments as i, WatchApp as l, ReproResult as m, Command as n, InputSchema as o, Repro as p, ControlApp as r, Ran as s, CheatEntry as t, WatchInput as u };
215
+ export { InputOf as a, Source as c, InputArguments as i, WatchApp as l, Command as n, InputSchema as o, ControlApp as r, Ran as s, CheatEntry as t, WatchInput as u };
@@ -1,5 +1,6 @@
1
- import { D as Point, E as FilterSlot, L as ComponentHandle, V as Entity, _ as PixiModule, _n as Events$1, g as PixiFilter, k as Api$1, m as Api$2, o as Events, t as Api$3, ut as Api, v as PixiSprite, vn as Require, y as PixiTexture, z as ComponentType } from "./types-BMEn0tSC.mjs";
2
- import { b as AnimApi } from "./types-CXyipKhE.mjs";
1
+ import { lt as Events, t as Api, ut as Require } from "./types-ERb2Y9U5.mjs";
2
+ import { D as Point, E as FilterSlot, L as ComponentHandle, V as Entity, _ as PixiModule, g as PixiFilter, k as Api$1, m as Api$2, o as Events$1, t as Api$3, v as PixiSprite, y as PixiTexture, z as ComponentType } from "./types-BWzCSRM2.mjs";
3
+ import { b as AnimApi } from "./types-DlgsfOmW.mjs";
3
4
  import { Log } from "@moku-labs/common/browser";
4
5
  import { PluginCtx } from "@moku-labs/core";
5
6
 
@@ -643,10 +644,10 @@ type EffectsCtx = KernelSlice & {
643
644
  /**
644
645
  * Payload of the `assets:bundle-unloaded` hook: `keys` names every texture that is gone.
645
646
  */
646
- type BundleUnloaded = Events["assets:bundle-unloaded"];
647
+ type BundleUnloaded = Events$1["assets:bundle-unloaded"];
647
648
  /**
648
649
  * Payload of the global `ui:hot-swap` hook: the saved file and its new exports.
649
650
  */
650
- type HotSwap = Events$1["ui:hot-swap"];
651
+ type HotSwap = Events["ui:hot-swap"];
651
652
  //#endregion
652
653
  export { NoiseValue as _, types_d_exports as a, EmitterValue as c, ColorMatrixValue as d, DisplacementValue as f, GlowValue as g, FilterValueOf as h, State as i, AlphaValue as l, FilterSpec as m, EffectsApi as n, EmitterConfig as o, FilterComponent as p, EffectsStats as r, EmitterDefinition as s, Config as t, BlurValue as u, OutlineValue as v, UniformDeclaration as y };
@@ -1,4 +1,5 @@
1
- import { B as ComponentValue, D as Point$2, F as AnyComponentType, I as AnyComponentValue, It as Hint, Kt as Json, O as ViewportSize, P as AnyComponent, Pt as Descriptor, Rt as Api, V as Entity, Z as ChangeHook, at as ProjectionMotion, dn as Api$5, it as NumericFields, k as Api$2, lt as ViewHandle, m as Api$3, nt as Motion, o as Events$1, rt as MotionHandle, t as Api$4, ut as Api$1, vn as Require, z as ComponentType } from "./types-BMEn0tSC.mjs";
1
+ import { A as Api, E as Descriptor, O as Hint, R as Json, rt as Api$2, t as Api$1, ut as Require } from "./types-ERb2Y9U5.mjs";
2
+ import { B as ComponentValue, D as Point$2, F as AnyComponentType, I as AnyComponentValue, O as ViewportSize, P as AnyComponent, V as Entity, Z as ChangeHook, at as ProjectionMotion, it as NumericFields, k as Api$3, lt as ViewHandle, m as Api$4, nt as Motion, o as Events$1, rt as MotionHandle, t as Api$5, z as ComponentType } from "./types-BWzCSRM2.mjs";
2
3
  import { Log } from "@moku-labs/common/browser";
3
4
  import { PluginCtx } from "@moku-labs/core";
4
5
 
@@ -634,8 +635,8 @@ type InputApi = {
634
635
  type Deps$1 = {
635
636
  time: Api;
636
637
  flow: Api$1;
637
- world: Api$2;
638
- renderer: Api$3;
638
+ world: Api$3;
639
+ renderer: Api$4;
639
640
  };
640
641
  /**
641
642
  * What the kernel context offers before the deps are attached.
@@ -1510,11 +1511,11 @@ type TextApi = {
1510
1511
  type Deps = {
1511
1512
  time: Api;
1512
1513
  flow: Api$1;
1513
- world: Api$2;
1514
- renderer: Api$3;
1515
- assets: Api$4;
1514
+ world: Api$3;
1515
+ renderer: Api$4;
1516
+ assets: Api$5;
1516
1517
  i18n: I18nApi;
1517
- clock: Api$5;
1518
+ clock: Api$2;
1518
1519
  };
1519
1520
  /**
1520
1521
  * What the kernel context offers before the deps are attached.
@@ -1,5 +1,6 @@
1
- import { $ as Ease, Gt as Events$3, I as AnyComponentValue, K as Owner, Kt as Json, L as ComponentHandle, Nt as TypeTag, P as AnyComponent, Pt as Descriptor, Rt as Api, Ut as Api$5, V as Entity, _n as Events$2, ct as TrackSegment, et as LayerSort, it as NumericFields, k as Api$2, m as Api$3, o as Events$5, rt as MotionHandle, sn as Events$4, st as TrackOptions, t as Api$4, tt as LayerSpec, ut as Api$1, vn as Require, z as ComponentType } from "./types-BMEn0tSC.mjs";
2
- import { D as TextApi, H as InputApi, I as I18nApi, c as UiNode, i as Finding, n as ElementChange, o as JsxState, r as ElementMotion, v as StylesState } from "./types-BaUUcIaN.mjs";
1
+ import { $ as Events$4, A as Api, E as Descriptor, F as Api$2, L as Events$3, R as Json, T as TypeTag, lt as Events$2, t as Api$1, ut as Require } from "./types-ERb2Y9U5.mjs";
2
+ import { $ as Ease, I as AnyComponentValue, K as Owner, L as ComponentHandle, P as AnyComponent, V as Entity, ct as TrackSegment, et as LayerSort, it as NumericFields, k as Api$3, m as Api$4, o as Events$5, rt as MotionHandle, st as TrackOptions, t as Api$5, tt as LayerSpec, z as ComponentType } from "./types-BWzCSRM2.mjs";
3
+ import { D as TextApi, H as InputApi, I as I18nApi, c as UiNode, i as Finding, n as ElementChange, o as JsxState, r as ElementMotion, v as StylesState } from "./types-DgdMLZnV.mjs";
3
4
  import { Log } from "@moku-labs/common/browser";
4
5
  import { PluginCtx } from "@moku-labs/core";
5
6
  import { Node, Yoga } from "yoga-layout/load";
@@ -1065,7 +1066,7 @@ type AnimApi = {
1065
1066
  type Deps$3 = {
1066
1067
  time: Api;
1067
1068
  flow: Api$1;
1068
- world: Api$2;
1069
+ world: Api$3;
1069
1070
  };
1070
1071
  /**
1071
1072
  * What the kernel context offers before the deps are attached.
@@ -1211,8 +1212,8 @@ type Deps$2 = {
1211
1212
  anim: AnimApi;
1212
1213
  time: Api;
1213
1214
  flow: Api$1;
1214
- world: Api$2;
1215
- renderer: Api$3;
1215
+ world: Api$3;
1216
+ renderer: Api$4;
1216
1217
  input: InputApi;
1217
1218
  i18n: I18nApi;
1218
1219
  text: TextApi;
@@ -1568,8 +1569,8 @@ type ScenesApi = {
1568
1569
  */
1569
1570
  type Deps$1 = {
1570
1571
  flow: Api$1;
1571
- world: Api$2;
1572
- assets: Api$4;
1572
+ world: Api$3;
1573
+ assets: Api$5;
1573
1574
  time: Api;
1574
1575
  };
1575
1576
  /**
@@ -1944,8 +1945,8 @@ type AudioApi = {
1944
1945
  */
1945
1946
  type Deps = {
1946
1947
  flow: Api$1;
1947
- assets: Api$4;
1948
- model: Api$5;
1948
+ assets: Api$5;
1949
+ model: Api$2;
1949
1950
  time: Api;
1950
1951
  };
1951
1952
  /**