@moku-labs/game 0.15.85 → 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.
Files changed (38) hide show
  1. package/README.md +4 -3
  2. package/dist/app/page.d.mts +1 -1
  3. package/dist/app/page.mjs +2 -2
  4. package/dist/app/system.d.mts +3 -3
  5. package/dist/app.d.mts +3 -3
  6. package/dist/app.mjs +1 -1
  7. package/dist/assets.d.mts +1 -1
  8. package/dist/cli.mjs +351 -83
  9. package/dist/{commands-DKjkHK5b.d.mts → commands-DxUF13zr.d.mts} +5 -5
  10. package/dist/{config-Cn1VZ-tx.mjs → config-BYx_7HL1.mjs} +24 -5
  11. package/dist/control.d.mts +12 -8
  12. package/dist/control.mjs +2 -2
  13. package/dist/{define-DcB9KOfh.d.mts → define-CMl6NcM4.d.mts} +27 -5
  14. package/dist/{headless-B8JIqsZk.d.mts → headless-DtDdn5gg.d.mts} +1 -1
  15. package/dist/{index-DTHVVLFB.d.mts → index-Bn0pFiae.d.mts} +3 -3
  16. package/dist/index.d.mts +4 -4
  17. package/dist/index.mjs +1 -1
  18. package/dist/inspect.d.mts +6 -6
  19. package/dist/inspect.mjs +2 -2
  20. package/dist/jsx-dev-runtime.d.mts +1 -1
  21. package/dist/jsx-runtime.d.mts +1 -1
  22. package/dist/{run-3QhrffgM.mjs → run-B5if0jxE.mjs} +1 -1
  23. package/dist/{runtime-B3CsJr_p.d.mts → runtime-DOvgFNLH.d.mts} +1 -1
  24. package/dist/{session-DuZfGZWk.mjs → session-D0AYRm5T.mjs} +39 -3
  25. package/dist/{sources-Djd8MjP9.mjs → sources-CyltHb9o.mjs} +1 -1
  26. package/dist/{src-D1J2QlGK.mjs → src-BFa-zMmW.mjs} +1132 -89
  27. package/dist/testing.d.mts +4 -4
  28. package/dist/testing.mjs +1 -1
  29. package/dist/{types-DsRV-ph1.d.mts → types-BpipkaVe.d.mts} +41 -11
  30. package/dist/{types-DJCC9CAp.d.mts → types-C5gLBKbm.d.mts} +16 -6
  31. package/dist/{types-DfHytzox.d.mts → types-CbVXXqPs.d.mts} +130 -16
  32. package/dist/{types-CPWi_CLI.d.mts → types-OBpR0u05.d.mts} +1 -1
  33. package/dist/{types-DhECCgeT.d.mts → types-OKAnpylW.d.mts} +15 -5
  34. package/dist/{visual-B76IxxTL.d.mts → visual-CMnWgCkh.d.mts} +6 -6
  35. package/dist/visual.d.mts +1 -1
  36. package/dist/visual.mjs +2 -2
  37. package/llms.txt +6 -6
  38. package/package.json +3 -3
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.12`) 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`); other verbs and targets refuse `--debug`. `[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. 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.85",
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.12",
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.12",
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",