@moku-labs/game 0.15.86 → 0.15.87
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.
- package/README.md +4 -3
- package/dist/app/page.d.mts +1 -1
- package/dist/app/page.mjs +2 -2
- package/dist/app/system.d.mts +1 -1
- package/dist/app.d.mts +1 -1
- package/dist/cli.mjs +351 -83
- package/dist/{commands-CeBF2nRY.d.mts → commands-DxUF13zr.d.mts} +1 -1
- package/dist/{config-Cn1VZ-tx.mjs → config-BYx_7HL1.mjs} +24 -5
- package/dist/control.d.mts +11 -7
- package/dist/control.mjs +2 -2
- package/dist/{define-N-2nQNK_.d.mts → define-CMl6NcM4.d.mts} +26 -4
- package/dist/inspect.d.mts +2 -2
- package/dist/inspect.mjs +2 -2
- package/dist/{run-3QhrffgM.mjs → run-B5if0jxE.mjs} +1 -1
- package/dist/{session-DuZfGZWk.mjs → session-D0AYRm5T.mjs} +39 -3
- package/dist/{sources-Djd8MjP9.mjs → sources-CyltHb9o.mjs} +1 -1
- package/dist/testing.d.mts +1 -1
- package/dist/{types-DNWWlVky.d.mts → types-BpipkaVe.d.mts} +39 -9
- package/dist/{types-CyPbo757.d.mts → types-OKAnpylW.d.mts} +11 -1
- package/dist/{visual-Di8ecxYD.d.mts → visual-CMnWgCkh.d.mts} +2 -2
- package/dist/visual.d.mts +1 -1
- package/dist/visual.mjs +2 -2
- package/llms.txt +6 -6
- package/package.json +3 -3
|
@@ -2,7 +2,7 @@ import { An as Bookmark, D as DebugSwitches, Nn as FlowState, Qr as Api, Yr as S
|
|
|
2
2
|
import { P as AnimApi, a as AudioApi, h as EffectsApi, r as UiApi } from "./types-C5gLBKbm.mjs";
|
|
3
3
|
import { N as InputApi } from "./types-OBpR0u05.mjs";
|
|
4
4
|
import { t as HeadlessApp } from "./headless-DtDdn5gg.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { i as ControlApp, r as Command } from "./types-BpipkaVe.mjs";
|
|
6
6
|
|
|
7
7
|
//#region src/plugins/flow/doors/commands.d.ts
|
|
8
8
|
/**
|
|
@@ -9,6 +9,8 @@ const ANDROID_SIGNING_FIELDS = [
|
|
|
9
9
|
"keystorePasswordEnv",
|
|
10
10
|
"keyAlias"
|
|
11
11
|
];
|
|
12
|
+
/** The last part of a test app's identifier. */
|
|
13
|
+
const TEST_APP_SUFFIX = ".dev";
|
|
12
14
|
/** An iOS version as native takes it: `26.0` or `26.0.1`. */
|
|
13
15
|
const IOS_VERSION = /^\d+\.\d+(\.\d+)?$/;
|
|
14
16
|
/**
|
|
@@ -124,13 +126,29 @@ function checkIos(ios) {
|
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
128
|
/**
|
|
129
|
+
* Throws for a `native.dev` that cannot name a test app.
|
|
130
|
+
*
|
|
131
|
+
* @param native - `native` of the config.
|
|
132
|
+
* @throws {Error} When the block has no `identifier`, or one that does not end in `.dev` or is
|
|
133
|
+
* `native.identifier` itself, or when `name` or `icon` is an empty string.
|
|
134
|
+
*/
|
|
135
|
+
function checkTestApp(native) {
|
|
136
|
+
const dev = native?.dev;
|
|
137
|
+
if (dev === void 0) return;
|
|
138
|
+
if (!isFilled(dev.identifier)) throw new Error("[game] config.native.dev has no identifier.\n Name one that ends in .dev.");
|
|
139
|
+
if (!dev.identifier.endsWith(".dev")) throw new Error(`[game] config.native.dev.identifier is "${dev.identifier}".\n Use one that ends in .dev.`);
|
|
140
|
+
if (dev.identifier === native?.identifier) throw new Error(`[game] config.native.dev.identifier is "${dev.identifier}", the same as native.identifier.\n The test app needs an id of its own.`);
|
|
141
|
+
if (dev.name === "") throw new Error("[game] config.native.dev.name is empty.\n Name the test app, or leave the field out.");
|
|
142
|
+
if (dev.icon === "") throw new Error("[game] config.native.dev.icon is empty.\n Name a 1024 px PNG, or leave the field out.");
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
127
145
|
* Throws for the first value of a config that TypeScript would have refused.
|
|
128
146
|
*
|
|
129
147
|
* @param config - The default export of `config.ts`.
|
|
130
148
|
* @throws {Error} When `save` is not a save kind, a `system` name is not wired, the title is empty,
|
|
131
149
|
* `debug.overlay` is not a start mode, `page.boot` has no image, `page.boot.fadeMs` is not a finite number of 0
|
|
132
|
-
* or more, `native.signing` is half filled, `native.ios.minimumVersion` is no iOS version,
|
|
133
|
-
* `native.ios.infoPlist` is no plist value.
|
|
150
|
+
* or more, `native.signing` is half filled, `native.ios.minimumVersion` is no iOS version, a value of
|
|
151
|
+
* `native.ios.infoPlist` is no plist value, or `native.dev` cannot name a test app.
|
|
134
152
|
*/
|
|
135
153
|
function checkConfig(config) {
|
|
136
154
|
if (config.save !== void 0 && !saveKinds().has(config.save)) throw new Error(`[game] config.save is "${config.save}".\n Use "memory", "local" or "store".`);
|
|
@@ -146,6 +164,7 @@ function checkConfig(config) {
|
|
|
146
164
|
if (fadeMs !== void 0 && !(Number.isFinite(fadeMs) && fadeMs >= 0)) throw new Error(`[game] config.page.boot.fadeMs is ${String(fadeMs)}.\n Use a number of milliseconds, 0 or more.`);
|
|
147
165
|
checkSigning(config.native?.signing);
|
|
148
166
|
checkIos(config.native?.ios);
|
|
167
|
+
checkTestApp(config.native);
|
|
149
168
|
}
|
|
150
169
|
/**
|
|
151
170
|
* Fills the defaults of `page.boot`: the width `"40vmin"`, the fade 300 ms.
|
|
@@ -174,8 +193,8 @@ function resolveBoot(boot) {
|
|
|
174
193
|
* @returns The config with every field set.
|
|
175
194
|
* @throws {Error} When `save` is not a save kind, a `system` name is not wired, the title is empty,
|
|
176
195
|
* `debug.overlay` is not a start mode, `page.boot` has no image, `page.boot.fadeMs` is not a finite number of 0
|
|
177
|
-
* or more, `native.signing` is half filled, `native.ios.minimumVersion` is no iOS version,
|
|
178
|
-
* `native.ios.infoPlist` is no plist value.
|
|
196
|
+
* or more, `native.signing` is half filled, `native.ios.minimumVersion` is no iOS version, a value of
|
|
197
|
+
* `native.ios.infoPlist` is no plist value, or `native.dev` cannot name a test app.
|
|
179
198
|
* @example
|
|
180
199
|
* ```ts
|
|
181
200
|
* resolveConfig({ page: { title: "T" } }).save; // "memory"
|
|
@@ -201,4 +220,4 @@ function resolveConfig(config) {
|
|
|
201
220
|
};
|
|
202
221
|
}
|
|
203
222
|
//#endregion
|
|
204
|
-
export { resolveConfig as t };
|
|
223
|
+
export { resolveConfig as n, TEST_APP_SUFFIX as t };
|
package/dist/control.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as HeadlessApp } from "./headless-DtDdn5gg.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { t as commands } from "./commands-
|
|
4
|
-
import { t as defineCommand } from "./define-
|
|
2
|
+
import { a as InputArguments, c as Ran, n as ChoiceInput, r as Command, s as InputSchema, u as ToggleInput } from "./types-BpipkaVe.mjs";
|
|
3
|
+
import { t as commands } from "./commands-DxUF13zr.mjs";
|
|
4
|
+
import { t as defineCommand } from "./define-CMl6NcM4.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/plugins/flow/doors/dev.d.ts
|
|
7
7
|
/**
|
|
@@ -76,19 +76,23 @@ declare global {
|
|
|
76
76
|
var __MOKU_GAME_ENGINE__: string | undefined;
|
|
77
77
|
/**
|
|
78
78
|
* Where the page agent of a debug build finds the editor: `host:port`, written by `--editor` (default
|
|
79
|
-
* `"127.0.0.1:47600"`).
|
|
80
|
-
*
|
|
79
|
+
* `"127.0.0.1:47600"`). Exactly `"off"` on the page of a test app (`native build --store --dev`): the agent opens no
|
|
80
|
+
* socket and the overlay works alone, a contract with `@moku-labs/editor` 0.10.19 and later. Any other string is an
|
|
81
|
+
* address. Undefined on the dev page, whose agent talks to the server that served it, and on a release build.
|
|
81
82
|
*
|
|
82
83
|
* @example
|
|
83
84
|
* ```ts
|
|
84
85
|
* // moku-game build --debug --editor 192.168.1.20:47600
|
|
85
86
|
* globalThis.__MOKU_GAME_EDITOR__; // "192.168.1.20:47600"
|
|
87
|
+
* // moku-game native build android --store --dev --build-number 13
|
|
88
|
+
* globalThis.__MOKU_GAME_EDITOR__; // "off"
|
|
86
89
|
* ```
|
|
87
90
|
*/
|
|
88
91
|
var __MOKU_GAME_EDITOR__: string | undefined;
|
|
89
92
|
/**
|
|
90
93
|
* The app id of a debug build, so the editor pairs a device stream with its project: `native.identifier` of
|
|
91
|
-
* `config.ts`, with `.debug` in the native debug app (`MOKU_NATIVE_PROFILE=debug`), which installs under that id
|
|
94
|
+
* `config.ts`, with `.debug` in the native debug app (`MOKU_NATIVE_PROFILE=debug`), which installs under that id, and
|
|
95
|
+
* `native.dev.identifier` in a test app (`MOKU_NATIVE_PROFILE=dev`).
|
|
92
96
|
* Undefined on a debug build of a game with no native section, on the dev page and on a release build.
|
|
93
97
|
*
|
|
94
98
|
* @example
|
|
@@ -197,4 +201,4 @@ declare function controlReadOnly(id: string): ControlReadOnlyError;
|
|
|
197
201
|
*/
|
|
198
202
|
declare function run<S extends InputSchema, O, App extends HeadlessApp>(app: App, command: Command<S, O, App>, ...input: InputArguments<S>): Promise<Ran<O>>;
|
|
199
203
|
//#endregion
|
|
200
|
-
export { type Command, type ControlReadOnlyError, type ControlRefusedError, type Ran, commands, controlReadOnly, controlRefused, defineCommand, run };
|
|
204
|
+
export { type ChoiceInput, type Command, type ControlReadOnlyError, type ControlRefusedError, type Ran, type ToggleInput, commands, controlReadOnly, controlRefused, defineCommand, run };
|
package/dist/control.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { n as controlRefused, t as controlReadOnly } from "./dev-BNndV-hU.mjs";
|
|
2
|
-
import { s as defineCommand } from "./session-
|
|
3
|
-
import { n as commands, t as run } from "./run-
|
|
2
|
+
import { s as defineCommand } from "./session-D0AYRm5T.mjs";
|
|
3
|
+
import { n as commands, t as run } from "./run-B5if0jxE.mjs";
|
|
4
4
|
export { commands, controlReadOnly, controlRefused, defineCommand, run };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as HeadlessApp } from "./headless-DtDdn5gg.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { l as Source, r as Command, s as InputSchema } from "./types-BpipkaVe.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins/flow/doors/define.d.ts
|
|
5
5
|
/**
|
|
@@ -30,12 +30,14 @@ declare function defineSource<S extends InputSchema, O, App = HeadlessApp>(sourc
|
|
|
30
30
|
* control form for the others (see docs/doors.md), so a production build drops it. A game's
|
|
31
31
|
* `.dev` command with only the `__MOKU_GAME_DEV__` guard runs in dev and is refused on a debug
|
|
32
32
|
* page. `overlay` shows it in the editor's overlay: `"toggle"` with the input `{ on: "boolean" }`
|
|
33
|
-
* and a `value(app)` the switch is drawn from, `
|
|
34
|
-
* any other combination is
|
|
33
|
+
* and a `value(app)` the switch is drawn from, or with `choices` and a `choice(app)` too and
|
|
34
|
+
* `choice` in the input, `"button"` with no required input and no value; any other combination is
|
|
35
|
+
* a type error.
|
|
35
36
|
*
|
|
36
37
|
* @param command - The descriptor.
|
|
37
38
|
* @returns The same descriptor, frozen.
|
|
38
|
-
* @throws {Error} When the id is not a dotted name such as `"game.answer"
|
|
39
|
+
* @throws {Error} When the id is not a dotted name such as `"game.answer"`, or `choices` holds a
|
|
40
|
+
* word twice.
|
|
39
41
|
* @example
|
|
40
42
|
* ```ts
|
|
41
43
|
* // A game's .dev module: open the shop from anywhere, through the graph.
|
|
@@ -74,6 +76,26 @@ declare function defineSource<S extends InputSchema, O, App = HeadlessApp>(sourc
|
|
|
74
76
|
* });
|
|
75
77
|
* // The overlay draws a switch "Glow", on; a tap runs it with { on: false } and the next frame draws no glow.
|
|
76
78
|
* ```
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* // features/purchases/simulate.dev.ts — a tester on a phone picks how a purchase ends.
|
|
82
|
+
* export const simulate = defineCommand({
|
|
83
|
+
* id: "purchases.simulate",
|
|
84
|
+
* title: "Simulated purchases",
|
|
85
|
+
* input: { on: "boolean", choice: "string" },
|
|
86
|
+
* effect: "cheat",
|
|
87
|
+
* overlay: "toggle",
|
|
88
|
+
* choices: ["success", "failure", "delay"],
|
|
89
|
+
* value: (app: { readonly purchases: PurchasesApi }) => app.purchases.overridden(),
|
|
90
|
+
* choice: () => readSetting().mode, // the game's own .dev module remembers the pick
|
|
91
|
+
* run: (app, { on, choice }) => {
|
|
92
|
+
* // The control guard, then:
|
|
93
|
+
* writeSetting({ mode: choice });
|
|
94
|
+
* app.purchases.simulate(on ? choice : undefined);
|
|
95
|
+
* }
|
|
96
|
+
* });
|
|
97
|
+
* // The overlay draws a switch with the row success, failure, delay; a tap on failure runs { on: true, choice: "failure" }.
|
|
98
|
+
* ```
|
|
77
99
|
*/
|
|
78
100
|
declare function defineCommand<S extends InputSchema, O, App = HeadlessApp>(command: Command<S, O, App>): Command<S, O, App>;
|
|
79
101
|
//#endregion
|
package/dist/inspect.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ import { Er as Explained, Fr as Api, Mn as FlowGraph, Pn as JournalEntry, Z as A
|
|
|
2
2
|
import { a as AudioApi, g as EffectsStats, h as EffectsApi, r as UiApi, u as SoundEntry } from "./types-C5gLBKbm.mjs";
|
|
3
3
|
import { c as UiNode } from "./types-OBpR0u05.mjs";
|
|
4
4
|
import { t as HeadlessApp } from "./headless-DtDdn5gg.mjs";
|
|
5
|
-
import { a as
|
|
6
|
-
import { n as defineSource } from "./define-
|
|
5
|
+
import { a as InputArguments, d as WatchApp, f as WatchInput, l as Source, o as InputOf, s as InputSchema, t as CheatEntry } from "./types-BpipkaVe.mjs";
|
|
6
|
+
import { n as defineSource } from "./define-CMl6NcM4.mjs";
|
|
7
7
|
|
|
8
8
|
//#region src/plugins/flow/doors/read.d.ts
|
|
9
9
|
/**
|
package/dist/inspect.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as defineSource } from "./session-
|
|
2
|
-
import { n as read, r as watch, t as sources } from "./sources-
|
|
1
|
+
import { c as defineSource } from "./session-D0AYRm5T.mjs";
|
|
2
|
+
import { n as read, r as watch, t as sources } from "./sources-CyltHb9o.mjs";
|
|
3
3
|
import "./inspect-la_KkjCS.mjs";
|
|
4
4
|
export { defineSource, read, sources, watch };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as sheetAlone, p as graphHash } from "./capture-BtS6_oWr.mjs";
|
|
2
2
|
import { a as isDev, i as isControl, n as controlRefused, o as notInstalled, r as isAgent, t as controlReadOnly } from "./dev-BNndV-hU.mjs";
|
|
3
3
|
import { n as reproBookmark } from "./headless-CCiUwvlp.mjs";
|
|
4
|
-
import { a as readTarget, i as isProjectionTarget, l as inputSchema, n as isTainted, o as inputOrEmpty, r as recordCheat, s as defineCommand } from "./session-
|
|
4
|
+
import { a as readTarget, i as isProjectionTarget, l as inputSchema, n as isTainted, o as inputOrEmpty, r as recordCheat, s as defineCommand } from "./session-D0AYRm5T.mjs";
|
|
5
5
|
//#region src/plugins/anim/control.ts
|
|
6
6
|
/**
|
|
7
7
|
* @file anim plugin — the anim command of the `/control` door: switch reduced motion. Dev and
|
|
@@ -13,6 +13,19 @@ function checkId(kind, id) {
|
|
|
13
13
|
throw new Error(`[game] The ${kind} id "${id}" is not a dotted name.\n Name it like "game.position": camelCase words joined by dots.`);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
+
* Refuses a choice listed twice: the overlay would draw two rows of one name, and a tap on the
|
|
17
|
+
* second would run the first's.
|
|
18
|
+
*
|
|
19
|
+
* @param id - The id of the command, for the message.
|
|
20
|
+
* @param choices - The choices of the command, when it has some.
|
|
21
|
+
* @throws {Error} Naming the first choice that comes twice.
|
|
22
|
+
*/
|
|
23
|
+
function checkChoices(id, choices) {
|
|
24
|
+
const twice = choices?.find((choice, index) => choices.indexOf(choice) !== index);
|
|
25
|
+
if (twice === void 0) return;
|
|
26
|
+
throw new Error(`[game] The command ${id} lists the choice "${twice}" twice.\n Name each choice once.`);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
16
29
|
* Builds the input schema of a door without an object literal (F77). A literal such as
|
|
17
30
|
* `{ x: "number", y: "number" }` shares V8's hidden shape with the game's points and stores
|
|
18
31
|
* strings where they store numbers: V8 turns the fields of that shape tagged, and every fractional
|
|
@@ -63,12 +76,14 @@ function defineSource(source) {
|
|
|
63
76
|
* control form for the others (see docs/doors.md), so a production build drops it. A game's
|
|
64
77
|
* `.dev` command with only the `__MOKU_GAME_DEV__` guard runs in dev and is refused on a debug
|
|
65
78
|
* page. `overlay` shows it in the editor's overlay: `"toggle"` with the input `{ on: "boolean" }`
|
|
66
|
-
* and a `value(app)` the switch is drawn from, `
|
|
67
|
-
* any other combination is
|
|
79
|
+
* and a `value(app)` the switch is drawn from, or with `choices` and a `choice(app)` too and
|
|
80
|
+
* `choice` in the input, `"button"` with no required input and no value; any other combination is
|
|
81
|
+
* a type error.
|
|
68
82
|
*
|
|
69
83
|
* @param command - The descriptor.
|
|
70
84
|
* @returns The same descriptor, frozen.
|
|
71
|
-
* @throws {Error} When the id is not a dotted name such as `"game.answer"
|
|
85
|
+
* @throws {Error} When the id is not a dotted name such as `"game.answer"`, or `choices` holds a
|
|
86
|
+
* word twice.
|
|
72
87
|
* @example
|
|
73
88
|
* ```ts
|
|
74
89
|
* // A game's .dev module: open the shop from anywhere, through the graph.
|
|
@@ -107,9 +122,30 @@ function defineSource(source) {
|
|
|
107
122
|
* });
|
|
108
123
|
* // The overlay draws a switch "Glow", on; a tap runs it with { on: false } and the next frame draws no glow.
|
|
109
124
|
* ```
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* // features/purchases/simulate.dev.ts — a tester on a phone picks how a purchase ends.
|
|
128
|
+
* export const simulate = defineCommand({
|
|
129
|
+
* id: "purchases.simulate",
|
|
130
|
+
* title: "Simulated purchases",
|
|
131
|
+
* input: { on: "boolean", choice: "string" },
|
|
132
|
+
* effect: "cheat",
|
|
133
|
+
* overlay: "toggle",
|
|
134
|
+
* choices: ["success", "failure", "delay"],
|
|
135
|
+
* value: (app: { readonly purchases: PurchasesApi }) => app.purchases.overridden(),
|
|
136
|
+
* choice: () => readSetting().mode, // the game's own .dev module remembers the pick
|
|
137
|
+
* run: (app, { on, choice }) => {
|
|
138
|
+
* // The control guard, then:
|
|
139
|
+
* writeSetting({ mode: choice });
|
|
140
|
+
* app.purchases.simulate(on ? choice : undefined);
|
|
141
|
+
* }
|
|
142
|
+
* });
|
|
143
|
+
* // The overlay draws a switch with the row success, failure, delay; a tap on failure runs { on: true, choice: "failure" }.
|
|
144
|
+
* ```
|
|
110
145
|
*/
|
|
111
146
|
function defineCommand(command) {
|
|
112
147
|
checkId("command", command.id);
|
|
148
|
+
checkChoices(command.id, command.choices);
|
|
113
149
|
Object.freeze(command.input);
|
|
114
150
|
return Object.freeze(command);
|
|
115
151
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $ as Layer, F as parentOf, H as NineSlice, K as Shape, d as Box, r as drawnRect, z as rootPoseOf } from "./visual-B7TxMv1J.mjs";
|
|
2
2
|
import { o as notInstalled } from "./dev-BNndV-hU.mjs";
|
|
3
|
-
import { a as readTarget, c as defineSource, l as inputSchema, n as isTainted, o as inputOrEmpty, t as cheatsOf } from "./session-
|
|
3
|
+
import { a as readTarget, c as defineSource, l as inputSchema, n as isTainted, o as inputOrEmpty, t as cheatsOf } from "./session-D0AYRm5T.mjs";
|
|
4
4
|
//#region src/plugins/flow/doors/read.ts
|
|
5
5
|
/**
|
|
6
6
|
* @file flow/doors — `read` and `watch`, the `/inspect` side. Neither changes the game.
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ar as ClockSource, Dn as FeaturePlugin, Fn as NodeTable, Mr as FakeClock, Rr as Json, Un as Hint, Wn as NodeFx, kn as AnyFlow, zn as Descriptor } from "./types-CbVXXqPs.mjs";
|
|
2
2
|
import { t as createApp } from "./index-Bn0pFiae.mjs";
|
|
3
|
-
import { b as memory, x as saveOf, y as WithGameState } from "./types-
|
|
3
|
+
import { b as memory, x as saveOf, y as WithGameState } from "./types-OKAnpylW.mjs";
|
|
4
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-DtDdn5gg.mjs";
|
|
5
5
|
import { AnyPluginInstance } from "@moku-labs/core";
|
|
6
6
|
|
|
@@ -127,26 +127,56 @@ type Source<S extends InputSchema, O, App = HeadlessApp> = {
|
|
|
127
127
|
type ToggleInput = {
|
|
128
128
|
readonly on: "boolean";
|
|
129
129
|
};
|
|
130
|
+
/**
|
|
131
|
+
* The input schema of an overlay toggle with `choices`: the state the switch asks for and the pick
|
|
132
|
+
* of the row under it. `choice` is `"string"` or `"string?"`: the editor's registry refuses any other
|
|
133
|
+
* kind at start.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* // A tester on a phone picks how a purchase ends: the overlay runs { on: true, choice: "failure" }.
|
|
138
|
+
* const input: ChoiceInput = { on: "boolean", choice: "string" };
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
type ChoiceInput = {
|
|
142
|
+
readonly on: "boolean";
|
|
143
|
+
readonly choice: "string" | "string?";
|
|
144
|
+
};
|
|
130
145
|
/** The schema a toggle accepts: exactly `{ on: "boolean" }`; any schema while `S` is the wide one. */
|
|
131
146
|
type ToggleSchema<S extends InputSchema> = string extends keyof S ? S : [Exclude<keyof S, "on">] extends [never] ? S extends ToggleInput ? S : never : never;
|
|
147
|
+
/** The schema a toggle with `choices` accepts: exactly `ChoiceInput`; any schema while `S` is the wide one. */
|
|
148
|
+
type ChoiceSchema<S extends InputSchema> = string extends keyof S ? S : [Exclude<keyof S, keyof ChoiceInput>] extends [never] ? S extends ChoiceInput ? S : never : never;
|
|
132
149
|
/** The schema a button accepts: no required field; any schema while `S` is the wide one. */
|
|
133
150
|
type ButtonSchema<S extends InputSchema> = string extends keyof S ? S : [RequiredKeys<S>] extends [never] ? S : never;
|
|
134
151
|
/**
|
|
135
|
-
* The overlay part of a command, one of
|
|
136
|
-
*
|
|
137
|
-
* `value`. Any other combination
|
|
152
|
+
* The overlay part of a command, one of four shapes: none, a toggle with its input
|
|
153
|
+
* `{ on: "boolean" }` and its `value`, a toggle with `choices`, whose input adds `choice` and which
|
|
154
|
+
* has a `choice(app)` too, or a button with no required input and no `value`. Any other combination
|
|
155
|
+
* does not compile.
|
|
138
156
|
*/
|
|
139
157
|
type CommandOverlay<S extends InputSchema, App> = {
|
|
140
158
|
/** Not shown in the overlay. */readonly overlay?: never; /** Only a toggle has a value. */
|
|
141
|
-
readonly value?: never;
|
|
159
|
+
readonly value?: never; /** Only a toggle with a row of choices has them. */
|
|
160
|
+
readonly choices?: never; /** Only a toggle with a row of choices reads one. */
|
|
161
|
+
readonly choice?: never;
|
|
142
162
|
} | {
|
|
143
163
|
/** A switch of the overlay, run with `{ on: !value(app) }`. */readonly overlay: "toggle";
|
|
144
164
|
readonly input: ToggleSchema<S>; /** The current value of the switch, read by the overlay to draw it. */
|
|
145
|
-
readonly value: (app: App) => boolean;
|
|
165
|
+
readonly value: (app: App) => boolean; /** Only a toggle with a row of choices has them. */
|
|
166
|
+
readonly choices?: never; /** Only a toggle with a row of choices reads one. */
|
|
167
|
+
readonly choice?: never;
|
|
168
|
+
} | {
|
|
169
|
+
/** A switch of the overlay with a row of choices, run with `{ on, choice }`. */readonly overlay: "toggle";
|
|
170
|
+
readonly input: ChoiceSchema<S>; /** The current value of the switch, read by the overlay to draw it. */
|
|
171
|
+
readonly value: (app: App) => boolean; /** The row under the switch, one word each, none twice. */
|
|
172
|
+
readonly choices: readonly [string, ...string[]]; /** The choice the row marks. The game keeps it, in its own `.dev` module. */
|
|
173
|
+
readonly choice: (app: App) => string;
|
|
146
174
|
} | {
|
|
147
175
|
/** A button of the overlay, run with `{}`. */readonly overlay: "button";
|
|
148
176
|
readonly input: ButtonSchema<S>; /** Only a toggle has a value. */
|
|
149
|
-
readonly value?: never;
|
|
177
|
+
readonly value?: never; /** Only a toggle with a row of choices has them. */
|
|
178
|
+
readonly choices?: never; /** Only a toggle with a row of choices reads one. */
|
|
179
|
+
readonly choice?: never;
|
|
150
180
|
};
|
|
151
181
|
/**
|
|
152
182
|
* An action on a running game, on the dev page and on a debug page: an id, a title, the input it
|
|
@@ -154,8 +184,8 @@ type CommandOverlay<S extends InputSchema, App> = {
|
|
|
154
184
|
* form for `read` and `cosmetic`, the control form for the others (see docs/doors.md), so a
|
|
155
185
|
* production build drops it. A game's `.dev` command with only the `__MOKU_GAME_DEV__` guard runs
|
|
156
186
|
* in dev and is refused on a debug page. With `overlay` the editor's overlay shows it: a toggle
|
|
157
|
-
* takes the input `{ on: "boolean" }` and a `value(app)`,
|
|
158
|
-
* value; the types refuse every other shape.
|
|
187
|
+
* takes the input `{ on: "boolean" }` and a `value(app)`, with `choices` also `choice` in the input
|
|
188
|
+
* and a `choice(app)`, a button no required input and no value; the types refuse every other shape.
|
|
159
189
|
*
|
|
160
190
|
* @example
|
|
161
191
|
* ```ts
|
|
@@ -250,4 +280,4 @@ type ControlApp = HeadlessApp & {
|
|
|
250
280
|
readonly log: Log.LogApi;
|
|
251
281
|
};
|
|
252
282
|
//#endregion
|
|
253
|
-
export {
|
|
283
|
+
export { InputArguments as a, Ran as c, WatchApp as d, WatchInput as f, ControlApp as i, Source as l, ChoiceInput as n, InputOf as o, Command as r, InputSchema as s, CheatEntry as t, ToggleInput as u };
|
|
@@ -103,7 +103,8 @@ type PlistValue = string | boolean | readonly PlistValue[] | {
|
|
|
103
103
|
* android: { keystorePath: "~/keys/upload.jks", keystorePasswordEnv: "TIMBER_KEYSTORE_PASSWORD", keyAlias: "upload" },
|
|
104
104
|
* apple: { teamId: "ABCDE12345" }
|
|
105
105
|
* },
|
|
106
|
-
* ios: { infoPlist: { ITSAppUsesNonExemptEncryption: false }, privacyManifest: "ios/PrivacyInfo.xcprivacy" }
|
|
106
|
+
* ios: { infoPlist: { ITSAppUsesNonExemptEncryption: false }, privacyManifest: "ios/PrivacyInfo.xcprivacy" },
|
|
107
|
+
* dev: { identifier: "com.mokulabs.timber.dev", icon: "assets/icon-dev.png" } // name: "Лесной городок DEV"
|
|
107
108
|
* },
|
|
108
109
|
* system: ["lifecycle", "back", "haptics", "keepAwake"],
|
|
109
110
|
* save: "memory",
|
|
@@ -164,6 +165,15 @@ type GameConfig = {
|
|
|
164
165
|
infoPlist?: Readonly<Record<string, PlistValue>>; /** The privacy manifest, relative to the game folder. The bundle holds it as `PrivacyInfo.xcprivacy`. */
|
|
165
166
|
privacyManifest?: string;
|
|
166
167
|
};
|
|
168
|
+
/**
|
|
169
|
+
* The test app of `--store --dev`: signed as the store app, with the overlay and no link to the
|
|
170
|
+
* editor, beside the players' app on a phone. Left out, `--dev` is refused.
|
|
171
|
+
*/
|
|
172
|
+
dev?: {
|
|
173
|
+
/** Its bundle identifier, ending in `.dev`, never `identifier` itself. Required in the block. */identifier: string; /** The app name under the icon. `"<name> DEV"` by default. */
|
|
174
|
+
name?: string; /** Its own 1024 px PNG, relative to the game folder. The game's `icon` by default. */
|
|
175
|
+
icon?: string;
|
|
176
|
+
};
|
|
167
177
|
}; /** The system plugins the shell wires. Default `[]`, a web page with no shell. */
|
|
168
178
|
system?: readonly SystemName[]; /** Where the save lives. Default `"memory"`. */
|
|
169
179
|
save?: SaveKind; /** The asset build. Default: no layers. */
|
|
@@ -2,8 +2,8 @@ import { Fr as Api$2, Qr as Api$3, Z as Api, kr as Api$4, wr as Api$1 } from "./
|
|
|
2
2
|
import { P as AnimApi, r as UiApi } from "./types-C5gLBKbm.mjs";
|
|
3
3
|
import { N as InputApi } from "./types-OBpR0u05.mjs";
|
|
4
4
|
import { r as Repro } from "./headless-DtDdn5gg.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { t as commands } from "./commands-
|
|
5
|
+
import { i as ControlApp, o as InputOf } from "./types-BpipkaVe.mjs";
|
|
6
|
+
import { t as commands } from "./commands-DxUF13zr.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-
|
|
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-CMnWgCkh.mjs";
|
|
2
2
|
export { type CheckpointResult, type VisualApp, type VisualOptions, type VisualPage, type VisualRenderer, type VisualReport, type VisualSetup, type VisualStart, type VisualStep, type VisualTest, type VisualTestResult, type VisualTolerance, defineVisualTest, parseVisualArgv, runVisualTests };
|
package/dist/visual.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as VISUAL_CLOCK } from "./fake-hnJcJeYf.mjs";
|
|
2
|
-
import { n as read, t as sources } from "./sources-
|
|
3
|
-
import { n as commands, t as run } from "./run-
|
|
2
|
+
import { n as read, t as sources } from "./sources-CyltHb9o.mjs";
|
|
3
|
+
import { n as commands, t as run } from "./run-B5if0jxE.mjs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { createBrandConsole } from "@moku-labs/common/cli";
|
|
6
6
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
package/llms.txt
CHANGED
|
@@ -302,7 +302,7 @@ app.model.store.snapshot().session; // { rolls: 2 }
|
|
|
302
302
|
await run.stop();
|
|
303
303
|
```
|
|
304
304
|
|
|
305
|
-
`config.ts` keys and defaults: `page.title` (required, never empty), `page.lang` (`"en"`), `page.background` (`"#000000"`: the page behind the canvas, the `theme-color` meta and the native window; the canvas clear colour stays `pluginConfigs.renderer.background`), `page.orientation` (`"portrait"`, or `"landscape"`, `"any"`: the native build locks it), `page.icons: { favicon?, appleTouch? }` (files relative to the game, `<link>` tags), `page.head` (raw tags, verbatim), `page.boot: { image, width?, fadeMs? }` (absent by default; an `<img id="moku-boot">` centred over the canvas from the first paint until the first scene drew, then faded over `fadeMs`, `300`, and removed; `image` a file relative to the game, `width` `"40vmin"`), `native: { name, identifier, icon?, targets?, signing?, ios? }` (absent: no native build; `signing.android: { keystorePath, keystorePasswordEnv, keyPasswordEnv?, keyAlias }`, the path absolute, `~/...` or relative to the game, the passwords by env var name only; `signing.apple: { teamId }`; `ios: { minimumVersion?, infoPlist?, privacyManifest? }`, the minimum `"26.0"` by default, `infoPlist` of `PlistValue`: strings, booleans, arrays, dictionaries, a number or `null` refused; the manifest relative to the game), `system` (`[]`; names `lifecycle`, `back`, `haptics`, `keepAwake`, `store`), `save` (`"memory"`, or `"local"`, `"store"`), `assets.layers` (`{}`; `{ shared: "ui" }` becomes `--layer shared=ui`), `debug.overlay` (`"closed"`, or `"pill"`, `"open"`: how the editor's overlay shows when a debug page starts; the page calls `app.debug.overlay.open({ mode })` right after the agents started; only a page with the agent reads it). A refused value throws, for example `[game] config.save is "disk".` or `[game] config.system names "tray", which the game shell does not wire.`
|
|
305
|
+
`config.ts` keys and defaults: `page.title` (required, never empty), `page.lang` (`"en"`), `page.background` (`"#000000"`: the page behind the canvas, the `theme-color` meta and the native window; the canvas clear colour stays `pluginConfigs.renderer.background`), `page.orientation` (`"portrait"`, or `"landscape"`, `"any"`: the native build locks it), `page.icons: { favicon?, appleTouch? }` (files relative to the game, `<link>` tags), `page.head` (raw tags, verbatim), `page.boot: { image, width?, fadeMs? }` (absent by default; an `<img id="moku-boot">` centred over the canvas from the first paint until the first scene drew, then faded over `fadeMs`, `300`, and removed; `image` a file relative to the game, `width` `"40vmin"`), `native: { name, identifier, icon?, targets?, signing?, ios?, dev? }` (absent: no native build; `signing.android: { keystorePath, keystorePasswordEnv, keyPasswordEnv?, keyAlias }`, the path absolute, `~/...` or relative to the game, the passwords by env var name only; `signing.apple: { teamId }`; `ios: { minimumVersion?, infoPlist?, privacyManifest? }`, the minimum `"26.0"` by default, `infoPlist` of `PlistValue`: strings, booleans, arrays, dictionaries, a number or `null` refused; the manifest relative to the game; `dev: { identifier, name?, icon? }`, the test app of `--store --dev`, the identifier ending in `.dev` and not `native.identifier`, `name` `"<name> DEV"` and `icon` `native.icon` by default), `system` (`[]`; names `lifecycle`, `back`, `haptics`, `keepAwake`, `store`), `save` (`"memory"`, or `"local"`, `"store"`), `assets.layers` (`{}`; `{ shared: "ui" }` becomes `--layer shared=ui`), `debug.overlay` (`"closed"`, or `"pill"`, `"open"`: how the editor's overlay shows when a debug page starts; the page calls `app.debug.overlay.open({ mode })` right after the agents started; only a page with the agent reads it). A refused value throws, for example `[game] config.save is "disk".` or `[game] config.system names "tray", which the game shell does not wire.`
|
|
306
306
|
|
|
307
307
|
```ts
|
|
308
308
|
// config.ts of a game in a native shell
|
|
@@ -341,9 +341,9 @@ await startPage(game, config, {
|
|
|
341
341
|
Commands of the bin `moku-game` (bun). Every command takes `--root <dir>` (default `.`), `--preload <path>` and `--serve-plugin <path>` (both repeat), before or after the command word. Exit 0 on success, else 1 with a `[game] …` line.
|
|
342
342
|
- `moku-game dev [--port 3000] [--packed]`: writes `.moku/index.html`, `script.ts` (the `moku:script` startup mark), `dev.ts` (sets `__MOKU_GAME_BUILD__` `"dev"`, the engine id `__MOKU_GAME_ENGINE__`, `__MOKU_GAME_CONTROL__`, `__MOKU_GAME_AGENT__` and last `__MOKU_GAME_DEV__`), `main.ts`, `assets-stamp.ts`, `bunfig.toml` (the hot plugin first, `__MOKU_GAME_DEV__`, `__MOKU_GAME_AGENT__` and `__MOKU_GAME_CONTROL__` defined `true`), runs Bun again under that bunfig in the game folder and serves `/`. It prints `› engine <id>` (and the patch file when there is one), then `› <folder>: dev server, raw assets. Ctrl+C stops it.` and then the bound URL alone on its own line, `http://localhost:3000/`. `--port 0` takes a free port. `--packed` serves `dist/assets`. A new or removed file in `tests/scenarios/` rewrites `main.ts`. On the raw files it keeps `generated/` fresh: it runs the scan of `keys` once before the page is written, and a save of an asset file (`.png`, `.webp`, `.fnt`, `.mp3`, `.m4a`) or of a `strings/<locale>.json` runs it again 100 ms after the last file event and prints `› keys: <path>` or `› keys: <path> and <n> more`; a folder that becomes or stops being a sub-feature (it gains or loses its door, `assets/`, `assets.ts` or `strings/`) scans too, `› keys: features/episodes/ep03/`; a changed or new string hot swaps through `generated/strings.<locale>.ts`, an asset file saved with new bytes swaps in the running page and a new or removed one reloads it, both through `.moku/assets-stamp.ts`, which `main.ts` imports (see "Hot swap"), and files answer `Cache-Control: no-store`. A failed scan is one warning `[game] keys: <message>` and the server runs on. A changed layer in `config.ts` needs a restart; `--packed` watches nothing. A taken port: `[game] dev: port 3000 is in use.` with `Pass --port 0 for a free port.` It watches the installed engine: 300 ms after a new version or dist it warns `[game] dev: the engine changed (<old id> -> <new id>), restarting the dev server.`, stops the child with SIGTERM, writes the page again with the new id and starts a new child (a fixed port keeps its URL, `--port 0` prints a new one); a patch file that changed while the engine did not is one warning that asks for `bun install`.
|
|
343
343
|
- `moku-game build [--out dist/web]`: packs the assets, bundles the page minified with `__MOKU_GAME_DEV__`, `__MOKU_GAME_AGENT__` and `__MOKU_GAME_CONTROL__` defined `false` (no scenario, no agent, no `.dev` module, no `/control`, no engine id), every link `./`, and copies the pack beside it with `manifest.json` next to `index.html`. Every page marks `moku:script` first and `moku:main` first after its imports. A release page whose `.js` carries `"/__editor/hello"` or `"[moku-editor]"` (the editor's agent) fails with `[game] build: the release page carries the editor agent (…)` and its output folder is removed. Runs from any http sub-path and from Tauri, not from `file://`.
|
|
344
|
-
- `moku-game build --debug[=read] [--editor host:port]`: a debug page, never shipped: the release page plus `@moku-labs/editor/agent/page` (resolved from the game, else `[game] build --debug needs @moku-labs/editor in the game.`) and the game's `.dev` modules, started after the app; DEV `false`, AGENT `true`, CONTROL `true` (`--debug`: every command, cheats too; `--debug=full` is an alias that prints one line) or `false` (`--debug=read`, the rare read-only page: read and cosmetic commands); `__MOKU_GAME_BUILD__` `debug-<UTC stamp>` for both, `__MOKU_GAME_ENGINE__` the engine id (`<version>+<dist hash>[.patch.<hash>]`, `+src` from sources), `__MOKU_GAME_EDITOR__` the `--editor` address (default `127.0.0.1:47600`); the title reads `<title> Debug`; no hot swap, no frame recorder, no audio journal, no scenario. It prints one warning naming the profile, the build id, the engine and the editor. `MOKU_NATIVE_PROFILE=store` with `--debug` is refused.
|
|
345
|
-
- `moku-game native build <target> [--simulator] [--debug[=full] [--editor host:port]]`, `native dev <target>`, `native doctor [<target>]`, `native clean [<target>]`: one verb of `@moku-labs/native` (a dev dependency, `^0.3.
|
|
346
|
-
- `moku-game native build <ios|android> --store --build-number <n>`: a store build, an `.aab` on Android (`aab: true` to native), an `.ipa` with `exportMethod: "app-store-connect"` on iOS. `app.version` from `package.json`, `app.buildNumber` from the flag, an integer from 1 to 2100000000, one number for both stores. Refused before `config.ts` is read: outside `native build`, with `--debug`, `--editor` or `--simulator`, on another target, without a valid number; `--build-number` without `--store`. Then every problem at once, before anything compiles, in one `[game] native --store: …` error, a line per problem: no signing block for the target, on Android a keystore that is not a file or an unset password variable (its name only, never a value), a `package.json` version that is not `x.y.z`, an identifier that ends in `.soak`, `.debug`, `.dev`, `.test` or `.staging`. On iOS it warns, and goes on, without `ios.privacyManifest` or `ITSAppUsesNonExemptEncryption` in `ios.infoPlist`. A build without `--store` runs no store check: `native build ios` is a device build. Every build takes a valid `package.json` version (else native's `0.1.0`), `app.keepScreenOn` from `keepAwake` in `system`, and on iOS the minimum `26.0`; a debug app leaves `signing.android` out and keeps the SDK key.
|
|
344
|
+
- `moku-game build --debug[=read] [--editor host:port]`: a debug page, never shipped: the release page plus `@moku-labs/editor/agent/page` (resolved from the game, else `[game] build --debug needs @moku-labs/editor in the game.`) and the game's `.dev` modules, started after the app; DEV `false`, AGENT `true`, CONTROL `true` (`--debug`: every command, cheats too; `--debug=full` is an alias that prints one line) or `false` (`--debug=read`, the rare read-only page: read and cosmetic commands); `__MOKU_GAME_BUILD__` `debug-<UTC stamp>` for both, `__MOKU_GAME_ENGINE__` the engine id (`<version>+<dist hash>[.patch.<hash>]`, `+src` from sources), `__MOKU_GAME_EDITOR__` the `--editor` address (default `127.0.0.1:47600`); the title reads `<title> Debug`; no hot swap, no frame recorder, no audio journal, no scenario. It prints one warning naming the profile, the build id, the engine and the editor. `MOKU_NATIVE_PROFILE=store` with `--debug` is refused. `MOKU_NATIVE_PROFILE=dev`, a test app's web build: a run without `--debug` is refused (`[game] build: MOKU_NATIVE_PROFILE is dev: a dev page carries the overlay.`); `--debug` builds `__MOKU_GAME_EDITOR__` exactly `"off"`, so the agent opens no socket, with CONTROL `true` and `__MOKU_GAME_APP__` `native.dev.identifier`; `--editor`, `--debug=read` and an `@moku-labs/editor` below 0.10.19, or of a version that cannot be read, are refused.
|
|
345
|
+
- `moku-game native build <target> [--simulator] [--debug[=full] [--editor host:port]]`, `native dev <target>`, `native doctor [<target>]`, `native clean [<target>]`: one verb of `@moku-labs/native` (a dev dependency, `^0.3.13`) over `config.ts`. App name, identifier and icon from `native`, orientation and background colour from `page`; the web build is `moku-game build`, the dev server `moku-game dev --port 5173`; system rows for `back`, `haptics`, `store`; the Tauri project in `.moku/tauri`, the apps in `dist-native`; an Android app composes native's `shell` system first. `native build android --debug` builds a debug app (`debug: true` to native, which installs it beside the store app; the web build is `moku-game build --debug` with the same profile and `--editor`). `native build ios --debug [--simulator]` is the same app on iOS: the engine names it `<name> (debug)` and `<identifier>.debug`, in `.moku/tauri-debug`, native delivers to `dist-native/ios-debug`. Other verbs and targets refuse `--debug`. `native clean` also cleans `.moku/tauri-dev` and `.moku/tauri-debug` when they exist, one native clean per folder; `doctor` stays on `.moku/tauri`. `[game] config.ts has no native section.` without `native`.
|
|
346
|
+
- `moku-game native build <ios|android> --store --build-number <n>`: a store build, an `.aab` on Android (`aab: true` to native), an `.ipa` with `exportMethod: "app-store-connect"` on iOS. `app.version` from `package.json`, `app.buildNumber` from the flag, an integer from 1 to 2100000000, one number for both stores. Refused before `config.ts` is read: outside `native build`, with `--debug`, `--editor` or `--simulator`, on another target, without a valid number; `--build-number` without `--store`. Then every problem at once, before anything compiles, in one `[game] native --store: …` error, a line per problem: no signing block for the target, on Android a keystore that is not a file or an unset password variable (its name only, never a value), a `package.json` version that is not `x.y.z`, an identifier that ends in `.soak`, `.debug`, `.dev`, `.test` or `.staging`. On iOS it warns, and goes on, without `ios.privacyManifest` or `ITSAppUsesNonExemptEncryption` in `ios.infoPlist`. A build without `--store` runs no store check: `native build ios` is a device build. `--store --dev` builds the test app of `native.dev`: every store check, the identifier row reading `native.dev.identifier`; `dev: true` to native (`aab` on Android as before), the same signing, the web build `moku-game build --debug`, the project `.moku/tauri-dev`, a full Rust build of its own, the apps in `dist-native-dev`; the save stays under `native.identifier`. `--dev` without `--store` is refused before `config.ts` is read, with no `native.dev` right after, and `--store --debug` stays refused. Every build takes a valid `package.json` version (else native's `0.1.0`), `app.keepScreenOn` from `keepAwake` in `system`, and on iOS the minimum `26.0`; a debug app leaves `signing.android` out and keeps the SDK key.
|
|
347
347
|
- `moku-game keys [--check]`: `generated/assets.ts`, the compiled strings (`strings.ts`, `strings.<locale>.ts` for the top-level features and the layers, and `strings.<feature>.<locale>.ts` for every sub-feature with string files) and the dev manifest `generated/manifest.json` (a sub-feature's bundle carries its `dir` and `parent`); `dev` runs the same scan at start and on save and serves the manifest on `/manifest.json`, `visual` stops without it. `moku-game pack [--no-cache]`: `dist/assets`. Both pass the layers of `config.ts`.
|
|
348
348
|
- `moku-game visual [--update] [--only <name>] [--no-pixels | --pixels] [--webgl] [--dir <path>] [--tests <file>] [--url <url>]`: runs `runVisualTests` with the default export of `tests/visual/index.ts`, `{ app, tests }` (`app` is a `VisualSetup` `{ app, page? }`: `export default { app: { app: fixtureApp }, tests }`), against `tests/visual/baselines/`. The flags go through `parseVisualArgv`. The pixel leg runs on a Mac only unless `--pixels`/`--no-pixels`; without `--url` the command writes its own page into `.moku/visual/` (the page of `dev` and of the editor in `.moku/` stays), runs Bun again under `.moku/visual/bunfig.toml` as `dev` does (hot plugin, `--serve-plugin`, `--preload`), and the child serves the page on a free port, then stops it. No `manifest.json`: `[game] visual: no manifest.json in "<game>".` Exit 0 when the report is ok, else 1. `[game] visual: <file> must export default { app, tests }.` for a missing module or another shape, a bare app factory too.
|
|
349
349
|
- `preparePage(root, { agents?, preload?, servePlugins? })` of `@moku-labs/game/cli` writes the dev page of `moku-game dev` and resolves `{ html, bunfig, engine }` (both paths absolute; `engine` the `EngineFingerprint` whose `id` the page shows in `globalThis.__MOKU_GAME_ENGINE__`), for a server the caller starts: `bun --config=<bunfig>`. With agents the page also imports the game's `**/*.dev.ts` and hands them to the agents. It also writes the first, empty `.moku/assets-stamp.ts` when the game has none. The editor calls it: `await preparePage("games/timber", { agents: ["@moku-labs/editor/agent/page"] })`.
|
|
@@ -699,10 +699,10 @@ A plugin that owns a resource stores it in its state and frees it in `onStop: ({
|
|
|
699
699
|
Two subpaths, neither on the root (V4). An editor, MCP tools and e2e scripts reach a running game through them; `docs/doors.md` in the engine repository has the full catalogue.
|
|
700
700
|
|
|
701
701
|
- `@moku-labs/game/inspect`: `read(app, source, input?)` reads once; `watch(app, source, input, fn)` reads on the `signals` phase when the source changes and returns the stop function; `defineSource`; the frozen catalogue `sources`; the types `Source`, `InputSchema`, `InputOf`. Every source only reads, so the door is safe in a production build. Keys of `sources`: `graph`, `position`, `history`, `tainted`, `cheats`, `model`, `entities`, `projections`, `ui`, `locate`, `render`, `sounds`, `audioMuted`, `effects`, `filters`, `assets`, `log`, `explain`, `diff`, `schema`, `at`; their ids are `game.<key>`. `filters` answers `{ kinds, off }` of `effects.diagnostics`. `locate` takes `{ key }` (a ui element) or `{ target }` (a view by projection key) and answers its box in CSS px, the numbers Playwright clicks. `at` takes `{ x, y }` in CSS px and lists the views under that point, topmost first. `explain` takes `{ entity }` and answers that entity in full, `undefined` for a stale id. `diff` takes `{ from, to }` frames and answers what changed per entity; it throws in a production build and for a frame outside the last 120. `schema` lists every component and tag type the world met, with the JSON kind of each field. `audioMuted` answers whether the master bus is muted. `sounds` throws `[game] The source game.sounds needs audioPlugin.`, `audioMuted` throws `[game] The source game.audioMuted needs audioPlugin.` and `effects` and `filters` throw `[game] The source game.effects needs effectsPlugin.` (`game.filters` for `filters`) when that plugin is not installed; the editor lists such a source as not installed.
|
|
702
|
-
- `@moku-labs/game/control`: `run(app, command, input?)` resolves `{ value, state }`, `state` being `{ path, frame, tainted }`; `defineCommand`; `controlRefused`; `controlReadOnly`; the frozen catalogue `commands`; the types `Command`, `Ran`, `ControlReadOnlyError`. Keys of `commands`: `answer`, `tap`, `drag`, `key`, `fill`, `scroll`, `walk`, `bookmark`, `restore`, `saveExport`, `saveImport`, `step`, `pause`, `resume`, `capture`, `debug`, `reducedMotion`, `timeScale`, `frameRate`, `mute`, `trace`, `filter`. `capture` resolves `{ png }`, and `{ png, legend }` with `legend: true`; `undefined` while the renderer is inert. `timeScale` takes `{ scale }`; 0 freezes game time while the frames keep running. `frameRate` takes `{ fps? }`, calls `time.setRate(fps ?? "auto")` and answers `time.rate()`. `mute` takes `{ muted }`, mutes the master bus and answers the flag. Without `audioPlugin` it throws `[game] The command game.mute needs audioPlugin.` `trace` takes `{ path }`, a list of views by projection key, and answers whether the gate took the answer. `scroll` takes `{ key, to }`, calls `ui.scroll(key, to)` and answers what it answers; a visual test writes it as the step `{ scroll: { key, to } }`. `filter` takes `{ kind, on }`, switches the filter kind through `effects.diagnostics` (cosmetic) and answers the off kinds; an unknown kind throws `[game] No filter kind "fx.nope".` naming the known ones; without `effectsPlugin` it throws `[game] The command game.filter needs effectsPlugin.`
|
|
702
|
+
- `@moku-labs/game/control`: `run(app, command, input?)` resolves `{ value, state }`, `state` being `{ path, frame, tainted }`; `defineCommand`; `controlRefused`; `controlReadOnly`; the frozen catalogue `commands`; the types `Command`, `ChoiceInput`, `Ran`, `ControlReadOnlyError`. Keys of `commands`: `answer`, `tap`, `drag`, `key`, `fill`, `scroll`, `walk`, `bookmark`, `restore`, `saveExport`, `saveImport`, `step`, `pause`, `resume`, `capture`, `debug`, `reducedMotion`, `timeScale`, `frameRate`, `mute`, `trace`, `filter`. `capture` resolves `{ png }`, and `{ png, legend }` with `legend: true`; `undefined` while the renderer is inert. `timeScale` takes `{ scale }`; 0 freezes game time while the frames keep running. `frameRate` takes `{ fps? }`, calls `time.setRate(fps ?? "auto")` and answers `time.rate()`. `mute` takes `{ muted }`, mutes the master bus and answers the flag. Without `audioPlugin` it throws `[game] The command game.mute needs audioPlugin.` `trace` takes `{ path }`, a list of views by projection key, and answers whether the gate took the answer. `scroll` takes `{ key, to }`, calls `ui.scroll(key, to)` and answers what it answers; a visual test writes it as the step `{ scroll: { key, to } }`. `filter` takes `{ kind, on }`, switches the filter kind through `effects.diagnostics` (cosmetic) and answers the off kinds; an unknown kind throws `[game] No filter kind "fx.nope".` naming the known ones; without `effectsPlugin` it throws `[game] The command game.filter needs effectsPlugin.`
|
|
703
703
|
- Commands run in dev builds and debug builds. `__MOKU_GAME_DEV__ === true` (the dev page, a test's `vi.stubGlobal("__MOKU_GAME_DEV__", true)`) or `__MOKU_GAME_CONTROL__ === true` (`--debug`) runs every command; `__MOKU_GAME_AGENT__ === true` alone (`--debug=read`) runs the `read` and `cosmetic` ones and `run` refuses the others with `controlReadOnly(id)`, an error with `reason: "read-only"`: `[game] The command game.tap changes the game: this debug build runs read and cosmetic commands only.`; no flag: `run` throws `[game] Control commands run in dev builds only.` `moku-game build` defines the three flags `false`; a game without the shell uses a bundler `define` and should add `__MOKU_GAME_AGENT__: "false"` and `__MOKU_GAME_CONTROL__: "false"`. `saveExport` answers the committed `{ player, session, rng }` (read); `saveImport` takes `{ save }` of `saveExport`, restores it at the main flow's start and flushes the store (raw: not on a `--debug=read` page).
|
|
704
704
|
- A command's effect is `read`, `route`, `cosmetic`, `cheat` or `raw`. A `cheat` or `raw` command taints the session and is journaled; read it with `sources.tainted` and `sources.cheats`. Of the base commands `restore` and `saveImport` are `raw`; `capture` with `diff` writes the state too, so a `--debug=read` page refuses it. `bookmark` answers `flow.bookmark()` plus `scene`, the mounted scene; `restore` calls `scenes.expect(scene)` before `flow.restore`, so a bookmark at a popup restores the scene under it, also on a page that shows another scene. A bookmark taken while an effect that takes answers waits names the waiting transit node (`info/show` in the mini game) and carries `rest`; `restore` of it answers once that node's gate is open, with `pending.gate` in its value, and the popup shows on the next frame.
|
|
705
|
-
- A game's own: `defineSource({ id, title, input, changes, read })` with `changes` `"frame"`, `"commit"` or `"edge"`, and `defineCommand({ id, title, input, effect, run, overlay?, value? })`: `overlay: "toggle"` (input exactly `{ on: "boolean" }` and `value: app => boolean`, the switch's state) or `overlay: "button"` (no required input, no value) lists the command in the editor's overlay, which shows only such commands; any other combination is a type error. The id is camelCase words joined by dots, at least two: `dice.rolls`. An input schema maps field names to `"string"`, `"number"`, `"boolean"` or `"json"`; a trailing `?` makes one optional. A command body starts with `if (typeof __MOKU_GAME_DEV__ === "undefined" || !__MOKU_GAME_DEV__) throw controlRefused();`: it runs in dev and is refused on a debug page. A `.dev` command meant for a debug page writes the agent form for a read or cosmetic effect, `if ((typeof __MOKU_GAME_DEV__ === "undefined" || !__MOKU_GAME_DEV__) && (typeof __MOKU_GAME_AGENT__ === "undefined" || !__MOKU_GAME_AGENT__)) throw controlRefused();`, and the control form (`__MOKU_GAME_CONTROL__` in place of `__MOKU_GAME_AGENT__`) for the others. Keep them in `.dev` modules that only the dev page, a debug page and the tests import: the editor's dev page (`preparePage` with agents) and `moku-game build --debug` import every `**/*.dev.ts`, `moku-game build` none.
|
|
705
|
+
- A game's own: `defineSource({ id, title, input, changes, read })` with `changes` `"frame"`, `"commit"` or `"edge"`, and `defineCommand({ id, title, input, effect, run, overlay?, value?, choices?, choice? })`: `overlay: "toggle"` (input exactly `{ on: "boolean" }` and `value: app => boolean`, the switch's state; with `choices: readonly [string, ...string[]]`, each word once or `defineCommand` throws, the input is exactly `{ on: "boolean", choice: "string" | "string?" }` and `choice: app => string` answers the marked one, run with `{ on, choice }`) or `overlay: "button"` (no required input, no value) lists the command in the editor's overlay, which shows only such commands; any other combination is a type error. The id is camelCase words joined by dots, at least two: `dice.rolls`. An input schema maps field names to `"string"`, `"number"`, `"boolean"` or `"json"`; a trailing `?` makes one optional. A command body starts with `if (typeof __MOKU_GAME_DEV__ === "undefined" || !__MOKU_GAME_DEV__) throw controlRefused();`: it runs in dev and is refused on a debug page. A `.dev` command meant for a debug page writes the agent form for a read or cosmetic effect, `if ((typeof __MOKU_GAME_DEV__ === "undefined" || !__MOKU_GAME_DEV__) && (typeof __MOKU_GAME_AGENT__ === "undefined" || !__MOKU_GAME_AGENT__)) throw controlRefused();`, and the control form (`__MOKU_GAME_CONTROL__` in place of `__MOKU_GAME_AGENT__`) for the others. Keep them in `.dev` modules that only the dev page, a debug page and the tests import: the editor's dev page (`preparePage` with agents) and `moku-game build --debug` import every `**/*.dev.ts`, `moku-game build` none.
|
|
706
706
|
|
|
707
707
|
## Project index
|
|
708
708
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moku-labs/game",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.87",
|
|
4
4
|
"description": "2D puzzle game engine on TypeScript and PixiJS, built on @moku-labs/core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
"peerDependencies": {
|
|
128
128
|
"@moku-labs/common": "^0.3.4",
|
|
129
129
|
"@moku-labs/core": "^1.7.1",
|
|
130
|
-
"@moku-labs/native": "^0.3.
|
|
130
|
+
"@moku-labs/native": "^0.3.13",
|
|
131
131
|
"@moku-labs/system": "^0.3.1",
|
|
132
132
|
"pixi.js": "^8.22.0",
|
|
133
133
|
"playwright-core": ">=1.50.0",
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"@moku-labs/ci": "1.5.7",
|
|
163
163
|
"@moku-labs/common": "0.3.10",
|
|
164
164
|
"@moku-labs/core": "1.7.6",
|
|
165
|
-
"@moku-labs/native": "0.3.
|
|
165
|
+
"@moku-labs/native": "0.3.13",
|
|
166
166
|
"@moku-labs/system": "0.3.7",
|
|
167
167
|
"@types/bun": "1.4.2",
|
|
168
168
|
"@vitest/coverage-istanbul": "4.0.18",
|