@moku-labs/game 0.7.1 → 0.9.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 (40) hide show
  1. package/README.md +12 -8
  2. package/dist/assets.d.mts +97 -33
  3. package/dist/assets.mjs +350 -110
  4. package/dist/{commands-mzE9PX0H.d.mts → commands-DuwCxK5t.d.mts} +5 -4
  5. package/dist/control.d.mts +4 -3
  6. package/dist/control.mjs +2 -2
  7. package/dist/{define-BbgXv4cy.d.mts → define-B6pHpdBi.d.mts} +4 -3
  8. package/dist/headless-BsNdJs9W.mjs +186 -0
  9. package/dist/headless-SCQXJxQf.d.mts +181 -0
  10. package/dist/hot.d.mts +4 -2
  11. package/dist/hot.mjs +8 -6
  12. package/dist/index-BO9kZzY3.d.mts +1611 -0
  13. package/dist/index.d.mts +6 -1596
  14. package/dist/index.mjs +4 -34334
  15. package/dist/{input-CK4nxBO1.mjs → input-z_35Jwfn.mjs} +2 -2
  16. package/dist/inspect.d.mts +7 -6
  17. package/dist/inspect.mjs +2 -2
  18. package/dist/jsx-dev-runtime.d.mts +1 -1
  19. package/dist/jsx-runtime.d.mts +1 -1
  20. package/dist/lint.d.mts +55 -4
  21. package/dist/lint.mjs +993 -40
  22. package/dist/project.d.mts +57 -41
  23. package/dist/project.mjs +994 -505
  24. package/dist/{run-Bcyg32M5.mjs → run-CofJEdYx.mjs} +4 -187
  25. package/dist/{runtime-HTlmRb81.d.mts → runtime-CdNJ0UBm.d.mts} +1 -1
  26. package/dist/{sources-DVWJ8nfr.mjs → sources-DNnzyCYf.mjs} +2 -2
  27. package/dist/src-536arXjV.mjs +34644 -0
  28. package/dist/testing.d.mts +85 -283
  29. package/dist/testing.mjs +158 -2109
  30. package/dist/{types-BMEn0tSC.d.mts → types-B0v5VVa3.d.mts} +10 -9
  31. package/dist/{types-ClF8say0.d.mts → types-CQueODzo.d.mts} +2 -2
  32. package/dist/{types-CYYKjvLn.d.mts → types-DUMoYPYe.d.mts} +5 -182
  33. package/dist/{types-CXyipKhE.d.mts → types-VZVWwqCg.d.mts} +42 -4
  34. package/dist/{types-BaUUcIaN.d.mts → types-xXfyk56Q.d.mts} +1 -1
  35. package/dist/{visual-DUvvPPCt.mjs → visual-dMW8iqAE.mjs} +8 -4
  36. package/dist/visual.d.mts +330 -0
  37. package/dist/visual.mjs +2142 -0
  38. package/llms.txt +59 -21
  39. package/package.json +7 -8
  40. package/dist/memory-CvgdnsQO.mjs +0 -259
@@ -1,7 +1,8 @@
1
- import { C as Captured, Et as Bookmark, T as DebugSwitches, Vt as Time, an as Api, k as Api$2, kt as FlowState, m as Api$1 } from "./types-BMEn0tSC.mjs";
2
- import { d as HeadlessApp, n as Command, r as ControlApp } from "./types-CYYKjvLn.mjs";
3
- import { H as InputApi } from "./types-BaUUcIaN.mjs";
4
- import { b as AnimApi, p as ScenesApi, t as AudioApi, v as UiApi } from "./types-CXyipKhE.mjs";
1
+ import { At as FlowState, C as Captured, Dt as Bookmark, T as DebugSwitches, Ut as Time, k as Api$2, m as Api$1, sn as Api } from "./types-B0v5VVa3.mjs";
2
+ import { t as HeadlessApp } from "./headless-SCQXJxQf.mjs";
3
+ import { n as Command, r as ControlApp } from "./types-DUMoYPYe.mjs";
4
+ import { H as InputApi } from "./types-xXfyk56Q.mjs";
5
+ import { b as AnimApi, p as ScenesApi, t as AudioApi, v as UiApi } from "./types-VZVWwqCg.mjs";
5
6
 
6
7
  //#region src/plugins/flow/doors/commands.d.ts
7
8
  /**
@@ -1,6 +1,7 @@
1
- import { d as HeadlessApp, i as InputArguments, n as Command, o as InputSchema, s as Ran } from "./types-CYYKjvLn.mjs";
2
- import { t as commands } from "./commands-mzE9PX0H.mjs";
3
- import { t as defineCommand } from "./define-BbgXv4cy.mjs";
1
+ import { t as HeadlessApp } from "./headless-SCQXJxQf.mjs";
2
+ import { i as InputArguments, n as Command, o as InputSchema, s as Ran } from "./types-DUMoYPYe.mjs";
3
+ import { t as commands } from "./commands-DuwCxK5t.mjs";
4
+ import { t as defineCommand } from "./define-B6pHpdBi.mjs";
4
5
 
5
6
  //#region src/plugins/flow/doors/dev.d.ts
6
7
  /**
package/dist/control.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  import { t as controlRefused } from "./dev-wKLgOw7c.mjs";
2
- import { n as commands, t as run } from "./run-Bcyg32M5.mjs";
3
- import { s as defineCommand } from "./input-CK4nxBO1.mjs";
2
+ import { s as defineCommand } from "./input-z_35Jwfn.mjs";
3
+ import { n as commands, t as run } from "./run-CofJEdYx.mjs";
4
4
  export { commands, controlRefused, defineCommand, run };
@@ -1,4 +1,5 @@
1
- import { c as Source, d as HeadlessApp, n as Command, o as InputSchema } from "./types-CYYKjvLn.mjs";
1
+ import { t as HeadlessApp } from "./headless-SCQXJxQf.mjs";
2
+ import { c as Source, n as Command, o as InputSchema } from "./types-DUMoYPYe.mjs";
2
3
 
3
4
  //#region src/plugins/flow/doors/define.d.ts
4
5
  /**
@@ -13,7 +14,7 @@ import { c as Source, d as HeadlessApp, n as Command, o as InputSchema } from ".
13
14
  * ```ts
14
15
  * // A game's .dev module: the orders on the board, re-read after every edge.
15
16
  * export const orders = defineSource({
16
- * id: "timber.orders",
17
+ * id: "mini.orders",
17
18
  * title: "Orders",
18
19
  * input: {},
19
20
  * changes: "edge",
@@ -34,7 +35,7 @@ declare function defineSource<S extends InputSchema, O, App = HeadlessApp>(sourc
34
35
  * ```ts
35
36
  * // A game's .dev module: open the shop from anywhere, through the graph.
36
37
  * export const openShop = defineCommand({
37
- * id: "timber.openShop",
38
+ * id: "mini.openShop",
38
39
  * title: "Open the shop",
39
40
  * input: {},
40
41
  * effect: "route",
@@ -0,0 +1,186 @@
1
+ import { u as graphHash } from "./capture-fpd83Mi5.mjs";
2
+ //#region src/plugins/flow/headless.ts
3
+ const noPayload = null;
4
+ /** Seed of a repro that pins no rng state, the seed `saveOf` writes. */
5
+ const defaultSeed = 1;
6
+ /**
7
+ * Turns whatever `run()` rejected with into an error that can be thrown again.
8
+ *
9
+ * @param value - The rejection value.
10
+ * @returns The value itself when it is an error, a wrapped one otherwise.
11
+ * @example
12
+ * ```ts
13
+ * asError("offline").message; // "[game] The headless run failed.\n offline."
14
+ * ```
15
+ */
16
+ function asError(value) {
17
+ if (value instanceof Error) return value;
18
+ return /* @__PURE__ */ new Error(`[game] The headless run failed.\n ${String(value)}.`);
19
+ }
20
+ /**
21
+ * Starts the one loop unless the app's own `onStart` already did, and keeps a fatal error until
22
+ * someone asks for it. `run()` rejects only on a fatal error, and nobody awaits it here.
23
+ *
24
+ * @param app - The started app.
25
+ * @returns The holder of the fatal error.
26
+ */
27
+ function startLoop(app) {
28
+ const fatal = { error: void 0 };
29
+ if (app.flow.state().running) return fatal;
30
+ app.flow.run().catch((error) => {
31
+ fatal.error = error;
32
+ });
33
+ return fatal;
34
+ }
35
+ /**
36
+ * Waits until the loop rests for the first time, or ends. An empty route walks nowhere: it only
37
+ * waits for the gate the loop opens at the node it enters, so a start that is a chain of transit
38
+ * nodes is played out before anything reads the game.
39
+ *
40
+ * @param app - The started app whose loop is running.
41
+ * @param fatal - Holder of the fatal error of `run()`.
42
+ * @returns Resolves once the loop rests at its first rest node.
43
+ * @throws {Error} When the loop failed fatally instead of reaching a rest node.
44
+ */
45
+ async function settleAtFirstRest(app, fatal) {
46
+ await app.flow.walk([]).catch((error) => {
47
+ throw asError(fatal.error ?? error);
48
+ });
49
+ if (fatal.error !== void 0) throw asError(fatal.error);
50
+ }
51
+ /**
52
+ * Starts an app headless: sets flow mode `"fast"`, awaits `app.start()`, starts `flow.run()`
53
+ * unless the app's own `onStart` already did, and waits until the loop rests for the first time.
54
+ * `game.state().path` therefore names the first rest node of the graph as soon as the call
55
+ * resolves. A fatal error of the loop rejects this call, and a later one is re-thrown by `walk`
56
+ * and by `stop`, so a headless test never loses it.
57
+ *
58
+ * @param app - An app that is not started yet.
59
+ * @returns The game: walk it, answer it, read it, stop it.
60
+ * @throws {Error} When the loop failed fatally before it reached its first rest node.
61
+ * @example
62
+ * ```ts
63
+ * // A test starts the merge game without a screen. The call resolves at the first rest node.
64
+ * const game = await createHeadless(app);
65
+ *
66
+ * game.state().path; // "home": the transit node "boot" was played out
67
+ * game.state().mode; // "fast"
68
+ * await game.stop();
69
+ * ```
70
+ */
71
+ async function createHeadless(app) {
72
+ app.flow.setMode("fast");
73
+ await app.start();
74
+ const fatal = startLoop(app);
75
+ await settleAtFirstRest(app, fatal);
76
+ return {
77
+ walk: async (route) => {
78
+ const state = await app.flow.walk(route).catch((error) => {
79
+ throw asError(fatal.error ?? error);
80
+ });
81
+ if (fatal.error !== void 0) throw asError(fatal.error);
82
+ return state;
83
+ },
84
+ answer: (answer) => app.flow.gate.answer(answer),
85
+ state: () => app.flow.state(),
86
+ history: () => app.flow.history(),
87
+ stop: async () => {
88
+ await app.stop();
89
+ if (fatal.error !== void 0) throw asError(fatal.error);
90
+ }
91
+ };
92
+ }
93
+ /**
94
+ * Reads the rest node a repro starts at: its checkpoint, or the start of the main flow.
95
+ *
96
+ * @param app - The started app.
97
+ * @param repro - Starting state, optional checkpoint and the route.
98
+ * @returns The path of the node the repro enters.
99
+ * @throws {Error} When the graph has no main flow to start from.
100
+ */
101
+ function reproPath(app, repro) {
102
+ if (repro.checkpoint !== void 0) return repro.checkpoint;
103
+ const graph = app.flow.describe();
104
+ const start = graph.flows[graph.main]?.start;
105
+ if (start === void 0) throw new Error(`[game] runRepro() found no flow "${graph.main}" to start from.\n Name the checkpoint the repro was taken at.`);
106
+ return start;
107
+ }
108
+ /**
109
+ * Builds the bookmark a repro is entered with: its state, its checkpoint and the hash of the
110
+ * graph that runs now, so a checkpoint is accepted and any other rest node is checked. The route
111
+ * is not part of it: the caller walks it after the restore.
112
+ *
113
+ * @param app - The started app.
114
+ * @param repro - Starting state, optional checkpoint and the route.
115
+ * @returns The bookmark to restore.
116
+ * @throws {Error} When the repro names no checkpoint and the graph has no main flow.
117
+ * @example
118
+ * ```ts
119
+ * // The game.restore command loads a bug report taken at the "home" checkpoint.
120
+ * const bookmark = reproBookmark(app, { player: { coins: 7 }, checkpoint: "home", route: [] });
121
+ * bookmark.path; // "home"
122
+ * bookmark.rng; // { seed: 1, streams: {} }: the repro pinned no rng
123
+ * await app.flow.restore(bookmark);
124
+ * ```
125
+ */
126
+ function reproBookmark(app, repro) {
127
+ return {
128
+ path: reproPath(app, repro),
129
+ input: noPayload,
130
+ player: repro.player,
131
+ session: repro.session ?? {},
132
+ rng: repro.rng ?? {
133
+ seed: defaultSeed,
134
+ streams: {}
135
+ },
136
+ graph: graphHash(app.flow.describe())
137
+ };
138
+ }
139
+ /**
140
+ * Plays a repro: starts the app headless, restores the bookmark built from its state and
141
+ * checkpoint, then walks its route. The app keeps running, so the caller can read more than the
142
+ * result and stops it itself.
143
+ *
144
+ * @param app - An app that is not started yet.
145
+ * @param repro - Starting state, optional checkpoint and the route.
146
+ * @returns The path the run ended at, and the committed state.
147
+ * @example
148
+ * ```ts
149
+ * // A bug report on the dice game: "reset keeps my coins". Replay it from the "home" checkpoint.
150
+ * const reset = { at: "home", intent: "reset" };
151
+ * const result = await runRepro(app, { player: { coins: 7 }, checkpoint: "home", route: [reset] });
152
+ *
153
+ * result.player; // { coins: 0 }; result.path is ["home"]
154
+ * await app.stop(); // the app keeps running after the run
155
+ * ```
156
+ */
157
+ async function runRepro(app, repro) {
158
+ const game = await createHeadless(app);
159
+ await app.flow.restore(reproBookmark(app, repro));
160
+ const state = await game.walk(repro.route);
161
+ const ended = app.flow.bookmark();
162
+ return {
163
+ path: state.stack.map((frame) => frame.node),
164
+ player: ended.player,
165
+ session: ended.session
166
+ };
167
+ }
168
+ /**
169
+ * Steps the frame loop by hand: `count` calls of `app.time.step(deltaMs)`. A headless game has no
170
+ * frame source, so this is the only thing that moves the frame phases.
171
+ *
172
+ * @param app - A started app.
173
+ * @param count - Number of frames.
174
+ * @param deltaMs - Milliseconds per frame.
175
+ * @example
176
+ * ```ts
177
+ * // A headless game has no frame source: the test moves the six frame phases by hand.
178
+ * stepFrames(app, 2, 16);
179
+ * app.time.snapshot(); // frame: 2, delta: 16, elapsed: 32
180
+ * ```
181
+ */
182
+ function stepFrames(app, count, deltaMs) {
183
+ for (let frame = 0; frame < count; frame += 1) app.time.step(deltaMs);
184
+ }
185
+ //#endregion
186
+ export { stepFrames as i, reproBookmark as n, runRepro as r, createHeadless as t };
@@ -0,0 +1,181 @@
1
+ import { At as FlowState, Bt as Api, Jt as Json, Nt as RouteStep, jt as JournalEntry, on as RngState, ut as Api$1, zt as Answer } from "./types-B0v5VVa3.mjs";
2
+
3
+ //#region src/plugins/flow/headless.d.ts
4
+ /**
5
+ * The part of an app the headless helpers use. Structural on purpose: any app created with the
6
+ * default plugins fits.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const app: HeadlessApp = createApp({ pluginConfigs: { flow: { mainFlow } } });
11
+ * ```
12
+ */
13
+ type HeadlessApp = {
14
+ start(): Promise<void>;
15
+ stop(): Promise<void>;
16
+ time: Api;
17
+ flow: Api$1;
18
+ };
19
+ /**
20
+ * A game played without a screen: answers go through the gate, effects resolve instantly.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * // A test of the dice game: two rolls, no screen, no waiting.
25
+ * const game = await createHeadless(app);
26
+ * const state = await game.walk([{ at: "home", intent: "roll" }, { at: "home", intent: "roll" }]);
27
+ *
28
+ * state.path; // "home"
29
+ * await game.stop();
30
+ * ```
31
+ */
32
+ type HeadlessGame = {
33
+ /**
34
+ * Walks a route through the running loop.
35
+ *
36
+ * @param route - The player's answers and substituted sub-flow results, in order.
37
+ * @returns The state the walk ended in.
38
+ * @throws {Error} When a step is never reached, or the loop failed fatally.
39
+ * @example
40
+ * ```ts
41
+ * // Open the board and tap the generator twice. Every node's logic runs for real.
42
+ * const tap = { at: "board/awaitIntent", intent: "tap", payload: { generatorId: "sawmill" } };
43
+ * const state = await game.walk([{ at: "home", intent: "play" }, tap, tap]);
44
+ *
45
+ * state.path; // "board/awaitIntent"
46
+ * ```
47
+ */
48
+ walk(route: readonly RouteStep[]): Promise<FlowState>;
49
+ /**
50
+ * Gives one answer to the gate, the way a tap does.
51
+ *
52
+ * @param answer - Intent and optional payload.
53
+ * @returns Whether the gate took it.
54
+ * @example
55
+ * ```ts
56
+ * // One tap without a route. The test then waits for the loop by itself.
57
+ * game.answer({ intent: "play" }); // true: "home" rests and lists "play"
58
+ * ```
59
+ */
60
+ answer(answer: Answer): boolean;
61
+ /**
62
+ * Reads where the graph stands.
63
+ *
64
+ * @returns Whether it runs, the path, the stack, what it waits for and the mode.
65
+ * @example
66
+ * ```ts
67
+ * // Right after createHeadless: the graph rests at its first rest node.
68
+ * game.state().path; // "home"
69
+ * game.state().pending; // { gate: ["play"] }
70
+ * ```
71
+ */
72
+ state(): FlowState;
73
+ /**
74
+ * Reads the edges taken since the last checkpoint.
75
+ *
76
+ * @returns A copy of the journal.
77
+ * @example
78
+ * ```ts
79
+ * // After a merge onto an empty cell: the last edge says why the move was refused.
80
+ * const last = game.history().at(-1);
81
+ * // last?.path: "board/merge", last?.outcome: "rejected", last?.payload: { reason: "empty" }
82
+ * ```
83
+ */
84
+ history(): readonly JournalEntry[];
85
+ /**
86
+ * Stops the app, then re-throws a fatal error of the loop.
87
+ *
88
+ * @throws {Error} When the loop failed fatally.
89
+ * @example
90
+ * ```ts
91
+ * // The last line of a headless test. A fatal error of the loop fails the test here.
92
+ * await game.stop();
93
+ * ```
94
+ */
95
+ stop(): Promise<void>;
96
+ };
97
+ /**
98
+ * A reproducible run: a starting state, an optional checkpoint and the route played from it.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * const repro: Repro = { player: { coins: 0 }, checkpoint: "home", route: [{ at: "home", intent: "play" }] };
103
+ * ```
104
+ */
105
+ type Repro = {
106
+ player: Json;
107
+ session?: Json;
108
+ rng?: RngState;
109
+ checkpoint?: string;
110
+ route: RouteStep[];
111
+ };
112
+ /**
113
+ * What a repro run ends with: the path where the loop rests and the committed state.
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * const result: ReproResult = { path: ["home"], player: { coins: 3 }, session: { visits: 1 } };
118
+ * ```
119
+ */
120
+ type ReproResult = {
121
+ path: string[];
122
+ player: Json;
123
+ session: Json;
124
+ };
125
+ /**
126
+ * Starts an app headless: sets flow mode `"fast"`, awaits `app.start()`, starts `flow.run()`
127
+ * unless the app's own `onStart` already did, and waits until the loop rests for the first time.
128
+ * `game.state().path` therefore names the first rest node of the graph as soon as the call
129
+ * resolves. A fatal error of the loop rejects this call, and a later one is re-thrown by `walk`
130
+ * and by `stop`, so a headless test never loses it.
131
+ *
132
+ * @param app - An app that is not started yet.
133
+ * @returns The game: walk it, answer it, read it, stop it.
134
+ * @throws {Error} When the loop failed fatally before it reached its first rest node.
135
+ * @example
136
+ * ```ts
137
+ * // A test starts the merge game without a screen. The call resolves at the first rest node.
138
+ * const game = await createHeadless(app);
139
+ *
140
+ * game.state().path; // "home": the transit node "boot" was played out
141
+ * game.state().mode; // "fast"
142
+ * await game.stop();
143
+ * ```
144
+ */
145
+ declare function createHeadless(app: HeadlessApp): Promise<HeadlessGame>;
146
+ /**
147
+ * Plays a repro: starts the app headless, restores the bookmark built from its state and
148
+ * checkpoint, then walks its route. The app keeps running, so the caller can read more than the
149
+ * result and stops it itself.
150
+ *
151
+ * @param app - An app that is not started yet.
152
+ * @param repro - Starting state, optional checkpoint and the route.
153
+ * @returns The path the run ended at, and the committed state.
154
+ * @example
155
+ * ```ts
156
+ * // A bug report on the dice game: "reset keeps my coins". Replay it from the "home" checkpoint.
157
+ * const reset = { at: "home", intent: "reset" };
158
+ * const result = await runRepro(app, { player: { coins: 7 }, checkpoint: "home", route: [reset] });
159
+ *
160
+ * result.player; // { coins: 0 }; result.path is ["home"]
161
+ * await app.stop(); // the app keeps running after the run
162
+ * ```
163
+ */
164
+ declare function runRepro(app: HeadlessApp, repro: Repro): Promise<ReproResult>;
165
+ /**
166
+ * Steps the frame loop by hand: `count` calls of `app.time.step(deltaMs)`. A headless game has no
167
+ * frame source, so this is the only thing that moves the frame phases.
168
+ *
169
+ * @param app - A started app.
170
+ * @param count - Number of frames.
171
+ * @param deltaMs - Milliseconds per frame.
172
+ * @example
173
+ * ```ts
174
+ * // A headless game has no frame source: the test moves the six frame phases by hand.
175
+ * stepFrames(app, 2, 16);
176
+ * app.time.snapshot(); // frame: 2, delta: 16, elapsed: 32
177
+ * ```
178
+ */
179
+ declare function stepFrames(app: HeadlessApp, count: number, deltaMs: number): void;
180
+ //#endregion
181
+ export { createHeadless as a, ReproResult as i, HeadlessGame as n, runRepro as o, Repro as r, stepFrames as s, HeadlessApp as t };
package/dist/hot.d.mts CHANGED
@@ -14,8 +14,10 @@
14
14
  type HotOptions = {
15
15
  /**
16
16
  * The files that get the footer. Default: `.tsx` files, `styles.ts`, `view.ts`,
17
- * `animations.ts`, `effects.ts` and `generated/strings.<locale>.ts`. Bun runs it as the load
18
- * filter on the absolute path, so it should not anchor at the start.
17
+ * `animations.ts`, `effects.ts`, any `.ts` directly in a `styles/`, `motion/`, `effects/` or
18
+ * `views/` folder, and in `world/projections/` or `world/layout/`, and
19
+ * `generated/strings.<locale>.ts`. Bun runs it as the load filter on the absolute path, so it
20
+ * should not anchor at the start.
19
21
  */
20
22
  include?: RegExp;
21
23
  /**
package/dist/hot.mjs CHANGED
@@ -7,16 +7,18 @@ import path from "node:path";
7
7
  * update and hands the new exports to the running game through `globalThis.__moku_hot`. The `ui`
8
8
  * plugin installs that handler in dev builds only. What swaps: styles, components, projections,
9
9
  * animations, text styles, emitters and generated strings. A view module is a `.tsx` file, a
10
- * `styles.ts`, a `view.ts`, an `animations.ts`, an `effects.ts` or a generated
11
- * `generated/strings.<locale>.ts`; a logic module never gets the footer, so its save reaches the
12
- * root and the page reloads and restores its state. The plugin lives in `[serve.static]` of
10
+ * `styles.ts`, a `view.ts`, an `animations.ts`, an `effects.ts`, any `.ts` directly in a
11
+ * `styles/`, `motion/`, `effects/` or `views/` folder, any `.ts` directly in `world/projections/`
12
+ * or `world/layout/`, or a generated `generated/strings.<locale>.ts`; a logic module never gets
13
+ * the footer (`world/components/` and `world/systems/` included: they are registered at start), so
14
+ * its save reaches the root and the page reloads and restores its state. The plugin lives in `[serve.static]` of
13
15
  * `bunfig.toml`, the dev server only: `Bun.build` of a production build never loads it.
14
16
  */
15
17
  /**
16
- * The default view modules: `.tsx` files, `styles.ts`, `view.ts`, `animations.ts`, `effects.ts`
17
- * and the generated strings of a locale.
18
+ * The default view modules: the view files by name or by kind folder. Two literals joined, so
19
+ * each stays readable.
18
20
  */
19
- const DEFAULT_INCLUDE = /(\.tsx|\/styles\.ts|\/view\.ts|\/animations\.ts|\/effects\.ts|\/generated\/strings\.[\w-]+\.ts)$/;
21
+ const DEFAULT_INCLUDE = new RegExp(`(${/\.tsx|\/styles\.ts|\/view\.ts|\/animations\.ts|\/effects\.ts|\/generated\/strings\.[\w-]+\.ts/.source}|${/\/(?:styles|motion|effects|views)\/[^/]+\.ts|\/world\/(?:projections|layout)\/[^/]+\.ts/.source})$`);
20
22
  /** The generated strings of one locale, the one file under `generated/` that swaps. */
21
23
  const STRINGS = /\/generated\/strings\.[\w-]+\.ts$/;
22
24
  /** The default folders and test files that never hot swap. The outer group only scopes the `$`. */