@moku-labs/game 0.15.83 → 0.15.85
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 +2 -1
- package/dist/app/page.d.mts +1 -1
- package/dist/app/page.mjs +1 -1
- package/dist/app/system.d.mts +1 -1
- package/dist/app.d.mts +2 -2
- package/dist/app.mjs +1 -1
- package/dist/cli.mjs +519 -185
- package/dist/{config-HpC-p8Ow.mjs → config-Cn1VZ-tx.mjs} +77 -4
- package/dist/index.mjs +1 -1
- package/dist/{src-Dcft8otV.mjs → src-D1J2QlGK.mjs} +10 -3
- package/dist/testing.d.mts +1 -1
- package/dist/testing.mjs +1 -1
- package/dist/{types-D-5dwalj.d.mts → types-DhECCgeT.d.mts} +41 -3
- package/llms.txt +3 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -165,6 +165,7 @@ The engine bin `moku-game` serves, builds and packs a game folder. A game writes
|
|
|
165
165
|
| `moku-game dev [--port 3000] [--packed]` | Serves the game with hot reload. Prints the bound URL, also for `--port 0`. On the raw files it runs the scan of `keys` at start and on a save of an asset or a strings file. Restarts its server when the installed engine changes |
|
|
166
166
|
| `moku-game build [--out dist/web] [--debug[=full] [--editor host:port]]` | Packs the assets and builds the page; `--debug` adds the editor's page agent (read and cosmetic commands), `--debug=full` every command; `--editor` names where the agent finds the editor (default `127.0.0.1:47600`). A debug page is never shipped: a release page that carries the agent is refused |
|
|
167
167
|
| `moku-game native build <target> [--simulator] [--debug[=full] [--editor host:port]]` | Builds the native app: `ios`, `macos`, `android`; `--debug` builds an Android debug app beside the store app |
|
|
168
|
+
| `moku-game native build <target> --store --build-number <n>` | A store build: an `.aab` on `android`, an `.ipa` for App Store Connect on `ios`. The version comes from `package.json`, the signing from `native.signing`. Everything wrong is refused at once, before anything compiles |
|
|
168
169
|
| `moku-game native dev <target>` | Runs the native shell on the dev server |
|
|
169
170
|
| `moku-game native doctor`, `native clean` | Checks or removes the native project |
|
|
170
171
|
| `moku-game keys [--check]` | Writes `generated/assets.ts`, the strings and `generated/manifest.json` |
|
|
@@ -173,7 +174,7 @@ The engine bin `moku-game` serves, builds and packs a game folder. A game writes
|
|
|
173
174
|
|
|
174
175
|
Every command takes `--root <dir>`, `--preload <path>` and `--serve-plugin <path>`.
|
|
175
176
|
|
|
176
|
-
`config.ts` names the system plugins the page wires, `system: ["lifecycle", "back", "haptics", "keepAwake"]`, and the save, `save: "memory" | "local" | "store"`. A `system` list and the `"store"` save need the optional peer `@moku-labs/system`; `moku-game native` needs `@moku-labs/native`. The game imports neither. The whole shell is in [docs/shell.md](./docs/shell.md).
|
|
177
|
+
`config.ts` names the system plugins the page wires, `system: ["lifecycle", "back", "haptics", "keepAwake"]`, and the save, `save: "memory" | "local" | "store"`. A `system` list and the `"store"` save need the optional peer `@moku-labs/system`; `moku-game native` needs `@moku-labs/native`. The game imports neither. The `native` keys are `name`, `identifier`, `icon`, `targets`, `signing` (`android`, `apple`: env var names and identifiers, never a secret) and `ios` (`minimumVersion`, `"26.0"` by default, `infoPlist`, `privacyManifest`). The whole shell is in [docs/shell.md](./docs/shell.md).
|
|
177
178
|
|
|
178
179
|
## How it works
|
|
179
180
|
|
package/dist/app/page.d.mts
CHANGED
package/dist/app/page.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { t as applyTo } from "../drafts-BawpSaVp.mjs";
|
|
|
3
3
|
import { i as isControl } from "../dev-BNndV-hU.mjs";
|
|
4
4
|
import { n as fakeClock, t as VISUAL_CLOCK } from "../fake-hnJcJeYf.mjs";
|
|
5
5
|
import { n as read, r as watch, t as sources } from "../sources-Djd8MjP9.mjs";
|
|
6
|
-
import { t as resolveConfig } from "../config-
|
|
6
|
+
import { t as resolveConfig } from "../config-Cn1VZ-tx.mjs";
|
|
7
7
|
//#region src/app/boot.ts
|
|
8
8
|
/** How long after the fade the timer removes a picture whose transition never ended, ms. */
|
|
9
9
|
const FALLBACK_MS = 100;
|
package/dist/app/system.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Br as PlayerStateProvider } from "../types-DfHytzox.mjs";
|
|
2
2
|
import { ht as PlatformProvider } from "../index-DTHVVLFB.mjs";
|
|
3
|
-
import { _ as
|
|
3
|
+
import { _ as SystemName, g as SystemModules, v as SystemShellFactory } from "../types-DhECCgeT.mjs";
|
|
4
4
|
import { Back, Haptics, KeepAwake, Lifecycle, Store } from "@moku-labs/system";
|
|
5
5
|
|
|
6
6
|
//#region src/app/system.d.ts
|
package/dist/app.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fr as Json } from "./types-DfHytzox.mjs";
|
|
2
2
|
import { U as StringTable } from "./types-CPWi_CLI.mjs";
|
|
3
|
-
import { a as GameHandle, c as MemoryProvider, d as
|
|
3
|
+
import { _ as SystemName, a as GameHandle, c as MemoryProvider, d as PlistValue, f as SaveKind, i as GameDefinition, l as PageAgent, m as ScreenSeams, n as GameApp, o as GamePluginConfigs, p as Scenario, r as GameConfig, s as HeadlessSeams, y as WithGameState } from "./types-DhECCgeT.mjs";
|
|
4
4
|
import { AnyPluginInstance } from "@moku-labs/core";
|
|
5
5
|
|
|
6
6
|
//#region src/app/define.d.ts
|
|
@@ -42,4 +42,4 @@ declare const startMoment = 1000000;
|
|
|
42
42
|
*/
|
|
43
43
|
declare function defineGameApp<const Plugins extends readonly AnyPluginInstance[] = readonly [], const HeadlessPlugins extends readonly AnyPluginInstance[] = readonly [], Player extends Json = Json, Session extends Json = Json, Strings extends StringTable = StringTable>(definition: GameDefinition<Plugins, HeadlessPlugins, Player, Session, Strings>): GameApp<Plugins, HeadlessPlugins, Player, Session, Strings>;
|
|
44
44
|
//#endregion
|
|
45
|
-
export { type GameApp, type GameConfig, type GameDefinition, type GameHandle, type GamePluginConfigs, type HeadlessSeams, type MemoryProvider, type PageAgent, type SaveKind, type Scenario, type ScreenSeams, type SystemName, type WithGameState, defineGameApp, startMoment };
|
|
45
|
+
export { type GameApp, type GameConfig, type GameDefinition, type GameHandle, type GamePluginConfigs, type HeadlessSeams, type MemoryProvider, type PageAgent, type PlistValue, type SaveKind, type Scenario, type ScreenSeams, type SystemName, type WithGameState, defineGameApp, startMoment };
|
package/dist/app.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ft as audioPlugin, H as platformPlugin, i as screen, m as flattenFeatures, t as createApp, wt as effectsPlugin } from "./src-
|
|
1
|
+
import { Ft as audioPlugin, H as platformPlugin, i as screen, m as flattenFeatures, t as createApp, wt as effectsPlugin } from "./src-D1J2QlGK.mjs";
|
|
2
2
|
import { t as memory } from "./memory-CWlqhS7l.mjs";
|
|
3
3
|
import { n as fakeClock, r as isFakeClock } from "./fake-hnJcJeYf.mjs";
|
|
4
4
|
//#region src/app/define.ts
|
package/dist/cli.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { t as resolveConfig } from "./config-
|
|
1
|
+
import { t as resolveConfig } from "./config-Cn1VZ-tx.mjs";
|
|
2
2
|
import { t as findFeatureOwners } from "./features-DowEilZm.mjs";
|
|
3
3
|
import { r as watchTree, t as createBatcher, x as isSkippedFolder$1 } from "./watch-BSgptowj.mjs";
|
|
4
4
|
import { a as runCli$1, i as compileStrings, n as importStrings, t as exportStrings } from "./assets-BRTUagOC.mjs";
|
|
5
5
|
import { constants, copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, watch, writeFileSync } from "node:fs";
|
|
6
|
+
import { homedir } from "node:os";
|
|
6
7
|
import path from "node:path";
|
|
7
8
|
import { createBrandConsole } from "@moku-labs/common/cli";
|
|
8
9
|
import { parseArgs } from "node:util";
|
|
@@ -44,6 +45,16 @@ function packageOf(folder) {
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
48
|
+
* Reads the `version` of a folder's `package.json`.
|
|
49
|
+
*
|
|
50
|
+
* @param folder - The folder.
|
|
51
|
+
* @returns The version, or `undefined` for a missing or broken file, or one with no string there.
|
|
52
|
+
*/
|
|
53
|
+
function packageVersionOf(folder) {
|
|
54
|
+
const version = packageOf(folder)?.version;
|
|
55
|
+
return typeof version === "string" ? version : void 0;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
47
58
|
* Tells whether a path lies inside a folder, the folder itself left out.
|
|
48
59
|
*
|
|
49
60
|
* @param file - The path.
|
|
@@ -2020,6 +2031,408 @@ async function runBuild(run, deps) {
|
|
|
2020
2031
|
return 0;
|
|
2021
2032
|
}
|
|
2022
2033
|
//#endregion
|
|
2034
|
+
//#region src/app/native.ts
|
|
2035
|
+
/**
|
|
2036
|
+
* @file The native verbs of `moku-game`: a game's `config.ts` as the config of `@moku-labs/native`,
|
|
2037
|
+
* and one verb run over it. Node only, no package export: the bin bundles it. The only file of the
|
|
2038
|
+
* engine that imports `@moku-labs/native`, and only with `import()`, so a web-only game never
|
|
2039
|
+
* loads it.
|
|
2040
|
+
*/
|
|
2041
|
+
/** The port of the dev server Tauri's shell starts and loads. */
|
|
2042
|
+
const DEV_PORT = 5173;
|
|
2043
|
+
/** The iOS minimum of a game that names none. Native's own default is older. */
|
|
2044
|
+
const IOS_MINIMUM = "26.0";
|
|
2045
|
+
/** The version shape a store takes, and the only one the engine hands native: `1.2.3`. */
|
|
2046
|
+
const STORE_VERSION = /^\d+\.\d+\.\d+$/;
|
|
2047
|
+
/**
|
|
2048
|
+
* The native section of a resolved config.
|
|
2049
|
+
*
|
|
2050
|
+
* @param settings - The resolved `config.ts` of the game.
|
|
2051
|
+
* @returns The native section.
|
|
2052
|
+
* @throws {Error} When `config.ts` has no native section.
|
|
2053
|
+
*/
|
|
2054
|
+
function nativeSectionOf(settings) {
|
|
2055
|
+
if (settings.native === void 0) throw new Error("[game] config.ts has no native section.\n Add native: { name, identifier } to config.ts.");
|
|
2056
|
+
return settings.native;
|
|
2057
|
+
}
|
|
2058
|
+
/**
|
|
2059
|
+
* Makes a keystore path absolute, since Gradle reads a relative one under `gen/android/app`: `~/`
|
|
2060
|
+
* starts at the home folder, anything else at the game folder.
|
|
2061
|
+
*
|
|
2062
|
+
* @param keystore - The path `config.ts` gives.
|
|
2063
|
+
* @param cwd - The game folder.
|
|
2064
|
+
* @param home - The home folder.
|
|
2065
|
+
* @returns The absolute path.
|
|
2066
|
+
* @example
|
|
2067
|
+
* ```ts
|
|
2068
|
+
* resolveKeystore("~/keys/upload.jks", "/g", "/home/a"); // "/home/a/keys/upload.jks"
|
|
2069
|
+
* ```
|
|
2070
|
+
*/
|
|
2071
|
+
function resolveKeystore(keystore, cwd, home) {
|
|
2072
|
+
return keystore.startsWith("~/") ? path.join(home, keystore.slice(2)) : path.resolve(cwd, keystore);
|
|
2073
|
+
}
|
|
2074
|
+
/**
|
|
2075
|
+
* The password variables of an Android signing block that are unset or empty, by name only. The
|
|
2076
|
+
* key password falls back to the keystore's.
|
|
2077
|
+
*
|
|
2078
|
+
* @param android - `native.signing.android`, when the game has one.
|
|
2079
|
+
* @param env - The environment.
|
|
2080
|
+
* @returns The names of the variables.
|
|
2081
|
+
* @example
|
|
2082
|
+
* ```ts
|
|
2083
|
+
* missingPasswords({ keystorePath: "k.jks", keystorePasswordEnv: "KS", keyAlias: "a" }, { KS: "" }); // ["KS"]
|
|
2084
|
+
* ```
|
|
2085
|
+
*/
|
|
2086
|
+
function missingPasswords(android, env) {
|
|
2087
|
+
if (android === void 0) return [];
|
|
2088
|
+
return [.../* @__PURE__ */ new Set([android.keystorePasswordEnv, android.keyPasswordEnv ?? android.keystorePasswordEnv])].filter((name) => (env[name] ?? "") === "");
|
|
2089
|
+
}
|
|
2090
|
+
/**
|
|
2091
|
+
* The problems of the Android row of a store build: the signing block, the keystore file, and the
|
|
2092
|
+
* two password variables, by name only.
|
|
2093
|
+
*
|
|
2094
|
+
* @param native - The native section.
|
|
2095
|
+
* @param input - The store build.
|
|
2096
|
+
* @returns One line per problem.
|
|
2097
|
+
*/
|
|
2098
|
+
function androidProblems(native, input) {
|
|
2099
|
+
const android = native.signing?.android;
|
|
2100
|
+
if (android === void 0) return ["No native.signing.android in config.ts. Add keystorePath, keystorePasswordEnv and keyAlias."];
|
|
2101
|
+
const keystore = resolveKeystore(android.keystorePath, input.cwd, input.home);
|
|
2102
|
+
return [...input.store.exists(keystore) ? [] : [`The keystore ${keystore} is not a file.`], ...missingPasswords(android, input.store.env).map((name) => `The env var ${name} is not set. It holds a signing password.`)];
|
|
2103
|
+
}
|
|
2104
|
+
/**
|
|
2105
|
+
* The problem of the iOS row of a store build: the Apple signing block. Keys stay in the env, and
|
|
2106
|
+
* Tauri reads them.
|
|
2107
|
+
*
|
|
2108
|
+
* @param native - The native section.
|
|
2109
|
+
* @returns One line, or none with the block.
|
|
2110
|
+
*/
|
|
2111
|
+
function appleProblems(native) {
|
|
2112
|
+
return native.signing?.apple === void 0 ? ["No native.signing.apple in config.ts. Add teamId."] : [];
|
|
2113
|
+
}
|
|
2114
|
+
/**
|
|
2115
|
+
* The problem of a `package.json` version a store build cannot ship.
|
|
2116
|
+
*
|
|
2117
|
+
* @param version - The version, unchecked.
|
|
2118
|
+
* @returns One line, or none for an `x.y.z`.
|
|
2119
|
+
* @example
|
|
2120
|
+
* ```ts
|
|
2121
|
+
* versionProblems("1.2"); // ['package.json has version "1.2". Use x.y.z, such as 1.0.0.']
|
|
2122
|
+
* ```
|
|
2123
|
+
*/
|
|
2124
|
+
function versionProblems(version) {
|
|
2125
|
+
if (version === void 0) return ["package.json has no version. Add one, such as 1.0.0."];
|
|
2126
|
+
return STORE_VERSION.test(version) ? [] : [`package.json has version "${version}". Use x.y.z, such as 1.0.0.`];
|
|
2127
|
+
}
|
|
2128
|
+
/**
|
|
2129
|
+
* The last parts of an identifier that never goes to a store.
|
|
2130
|
+
*
|
|
2131
|
+
* @returns The set of words.
|
|
2132
|
+
* @example
|
|
2133
|
+
* ```ts
|
|
2134
|
+
* testSuffixes().has("soak"); // true
|
|
2135
|
+
* ```
|
|
2136
|
+
*/
|
|
2137
|
+
function testSuffixes() {
|
|
2138
|
+
return /* @__PURE__ */ new Set([
|
|
2139
|
+
"soak",
|
|
2140
|
+
"debug",
|
|
2141
|
+
"dev",
|
|
2142
|
+
"test",
|
|
2143
|
+
"staging"
|
|
2144
|
+
]);
|
|
2145
|
+
}
|
|
2146
|
+
/**
|
|
2147
|
+
* The problem of an identifier that names a test build.
|
|
2148
|
+
*
|
|
2149
|
+
* @param identifier - `native.identifier`.
|
|
2150
|
+
* @returns One line, or none for a real identifier.
|
|
2151
|
+
* @example
|
|
2152
|
+
* ```ts
|
|
2153
|
+
* identifierProblems("com.acme.t"); // []
|
|
2154
|
+
* ```
|
|
2155
|
+
*/
|
|
2156
|
+
function identifierProblems(identifier) {
|
|
2157
|
+
const last = identifier.slice(identifier.lastIndexOf(".") + 1);
|
|
2158
|
+
return testSuffixes().has(last) ? [`The identifier ${identifier} ends in .${last}. A store build ships the real identifier.`] : [];
|
|
2159
|
+
}
|
|
2160
|
+
/**
|
|
2161
|
+
* Everything that stops a store build, all at once, so one run shows every fix. A message names a
|
|
2162
|
+
* field, a path, a value of `package.json` or an env var, never the value of a variable.
|
|
2163
|
+
*
|
|
2164
|
+
* @param input - The store build.
|
|
2165
|
+
* @returns One line per problem, none for a build that can go.
|
|
2166
|
+
* @throws {Error} When `config.ts` has no native section.
|
|
2167
|
+
* @example
|
|
2168
|
+
* ```ts
|
|
2169
|
+
* const settings = resolveConfig({ page: { title: "T" }, native: { name: "T", identifier: "com.acme.t" } });
|
|
2170
|
+
* const store = { buildNumber: 12, env: {}, exists: () => true };
|
|
2171
|
+
* storeProblems({ settings, target: "ios", cwd: "/g", home: "/home/a", version: "1.2.3", store }); // ["No native.signing.apple in config.ts. Add teamId."]
|
|
2172
|
+
* ```
|
|
2173
|
+
*/
|
|
2174
|
+
function storeProblems(input) {
|
|
2175
|
+
const native = nativeSectionOf(input.settings);
|
|
2176
|
+
return [
|
|
2177
|
+
...input.target === "android" ? androidProblems(native, input) : appleProblems(native),
|
|
2178
|
+
...versionProblems(input.version),
|
|
2179
|
+
...identifierProblems(native.identifier)
|
|
2180
|
+
];
|
|
2181
|
+
}
|
|
2182
|
+
/**
|
|
2183
|
+
* The system rows native packages: one per system plugin that needs a Tauri capability. The
|
|
2184
|
+
* webview's own events and wake lock serve `lifecycle` and `keepAwake`, so they need no row. A
|
|
2185
|
+
* `"store"` save needs the store row even when `system` leaves it out.
|
|
2186
|
+
*
|
|
2187
|
+
* @param settings - The resolved `config.ts` of the game.
|
|
2188
|
+
* @returns The rows, in the order of `config.system`.
|
|
2189
|
+
*/
|
|
2190
|
+
function systemRowsOf(settings) {
|
|
2191
|
+
const names = settings.system.filter((name) => name !== "lifecycle" && name !== "keepAwake");
|
|
2192
|
+
if (settings.save === "store" && !names.includes("store")) names.push("store");
|
|
2193
|
+
return names.map((name) => ({ name }));
|
|
2194
|
+
}
|
|
2195
|
+
/**
|
|
2196
|
+
* The web build command native runs: `moku-game build`, with the debug profile and the editor
|
|
2197
|
+
* address of a debug app.
|
|
2198
|
+
*
|
|
2199
|
+
* @param where - The game folder and the command that runs `moku-game`.
|
|
2200
|
+
* @param debug - The debug profile, or `undefined` for a store app.
|
|
2201
|
+
* @returns The command.
|
|
2202
|
+
* @example
|
|
2203
|
+
* ```ts
|
|
2204
|
+
* webBuildOf({ cwd: "/g", command: '"bun" "/g/bin/moku-game.mjs"', home: "/home/a" }, { level: "full", editor: "192.168.1.20:47600" }); // '"bun" "/g/bin/moku-game.mjs" build --debug --editor 192.168.1.20:47600'
|
|
2205
|
+
* ```
|
|
2206
|
+
*/
|
|
2207
|
+
function webBuildOf(where, debug) {
|
|
2208
|
+
if (debug === void 0) return `${where.command} build`;
|
|
2209
|
+
const level = debug.level === "full" ? "--debug" : "--debug=read";
|
|
2210
|
+
const editor = debug.editor === void 0 ? "" : ` --editor ${debug.editor}`;
|
|
2211
|
+
return `${where.command} build ${level}${editor}`;
|
|
2212
|
+
}
|
|
2213
|
+
/**
|
|
2214
|
+
* The app block of the native config: the identity and the window, and what this run adds.
|
|
2215
|
+
*
|
|
2216
|
+
* @param settings - The resolved `config.ts` of the game.
|
|
2217
|
+
* @param native - The native section.
|
|
2218
|
+
* @param extras - The version and the build number of this run.
|
|
2219
|
+
* @returns The app block.
|
|
2220
|
+
*/
|
|
2221
|
+
function appOf(settings, native, extras) {
|
|
2222
|
+
return {
|
|
2223
|
+
name: native.name,
|
|
2224
|
+
identifier: native.identifier,
|
|
2225
|
+
orientation: settings.page.orientation,
|
|
2226
|
+
backgroundColor: settings.page.background,
|
|
2227
|
+
...native.icon === void 0 ? {} : { icon: native.icon },
|
|
2228
|
+
...extras.version === void 0 ? {} : { version: extras.version },
|
|
2229
|
+
...extras.buildNumber === void 0 ? {} : { buildNumber: String(extras.buildNumber) },
|
|
2230
|
+
...settings.system.includes("keepAwake") ? { keepScreenOn: true } : {}
|
|
2231
|
+
};
|
|
2232
|
+
}
|
|
2233
|
+
/**
|
|
2234
|
+
* The signing block of the native config. A debug build keeps native's SDK key, so it takes no
|
|
2235
|
+
* upload key, and neither does a plain build without its passwords, which Gradle would refuse only
|
|
2236
|
+
* after the compile; a store build on iOS exports for App Store Connect, and only that one does.
|
|
2237
|
+
*
|
|
2238
|
+
* @param native - The native section.
|
|
2239
|
+
* @param where - The game folder and the home folder.
|
|
2240
|
+
* @param target - The target of the verb.
|
|
2241
|
+
* @param extras - The debug profile and the build number of this run.
|
|
2242
|
+
* @returns The block, empty when there is nothing to pass.
|
|
2243
|
+
*/
|
|
2244
|
+
function signingOf(native, where, target, extras) {
|
|
2245
|
+
const android = native.signing?.android;
|
|
2246
|
+
const teamId = native.signing?.apple?.teamId;
|
|
2247
|
+
const isStoreIos = target === "ios" && extras.buildNumber !== void 0;
|
|
2248
|
+
const keyStaysOut = android === void 0 || extras.debug !== void 0 || extras.unsigned === true;
|
|
2249
|
+
const apple = {
|
|
2250
|
+
...teamId === void 0 ? {} : { teamId },
|
|
2251
|
+
...target === "ios" ? { iosMinimumSystemVersion: native.ios?.minimumVersion ?? IOS_MINIMUM } : {},
|
|
2252
|
+
...isStoreIos ? { exportMethod: "app-store-connect" } : {}
|
|
2253
|
+
};
|
|
2254
|
+
return {
|
|
2255
|
+
...keyStaysOut ? {} : { android: {
|
|
2256
|
+
...android,
|
|
2257
|
+
keystorePath: resolveKeystore(android.keystorePath, where.cwd, where.home)
|
|
2258
|
+
} },
|
|
2259
|
+
...Object.keys(apple).length === 0 ? {} : { apple }
|
|
2260
|
+
};
|
|
2261
|
+
}
|
|
2262
|
+
/**
|
|
2263
|
+
* The iOS block of the native config. Native takes the manifest as an absolute path only.
|
|
2264
|
+
*
|
|
2265
|
+
* @param native - The native section.
|
|
2266
|
+
* @param cwd - The game folder.
|
|
2267
|
+
* @returns The block, empty when the game adds nothing to the bundle.
|
|
2268
|
+
*/
|
|
2269
|
+
function iosBundleOf(native, cwd) {
|
|
2270
|
+
const infoPlist = native.ios?.infoPlist;
|
|
2271
|
+
const manifest = native.ios?.privacyManifest;
|
|
2272
|
+
return {
|
|
2273
|
+
...infoPlist === void 0 ? {} : { infoPlist },
|
|
2274
|
+
...manifest === void 0 ? {} : { privacyManifest: path.resolve(cwd, manifest) }
|
|
2275
|
+
};
|
|
2276
|
+
}
|
|
2277
|
+
/**
|
|
2278
|
+
* Maps a game's resolved `config.ts` to the config of `@moku-labs/native`: the app from `native`
|
|
2279
|
+
* and `page`, the web build through `moku-game`, the system rows, the targets, the signing, the
|
|
2280
|
+
* iOS bundle, and the Tauri project and output folders under the game. An Android app composes
|
|
2281
|
+
* native's `shell` system first, the one that sets `globalThis.__MOKU_NATIVE__`. A debug app
|
|
2282
|
+
* builds its web page with the same profile and `--editor`; its name and identifier stay the
|
|
2283
|
+
* game's. A build number means a store build.
|
|
2284
|
+
*
|
|
2285
|
+
* @param settings - The resolved `config.ts` of the game.
|
|
2286
|
+
* @param where - The game folder, the command that runs `moku-game` and the home folder.
|
|
2287
|
+
* @param target - The target of the verb, used when `config.ts` names no targets.
|
|
2288
|
+
* @param extras - What this run adds: the debug profile, the build number, the version.
|
|
2289
|
+
* @returns The config for `createApp({ config })` of `@moku-labs/native`.
|
|
2290
|
+
* @throws {Error} When `config.ts` has no native section.
|
|
2291
|
+
* @example
|
|
2292
|
+
* ```ts
|
|
2293
|
+
* const where = { cwd: "/g", command: '"/usr/local/bin/bun" "/g/node_modules/@moku-labs/game/bin/moku-game.mjs" "--root" "/g"', home: "/home/a" };
|
|
2294
|
+
* nativeConfigOf(resolveConfig({ page: { title: "T" }, native: { name: "T", identifier: "com.x.t" } }), where, "ios").web.dist; // "/g/dist/web"
|
|
2295
|
+
* ```
|
|
2296
|
+
*/
|
|
2297
|
+
function nativeConfigOf(settings, where, target, extras = {}) {
|
|
2298
|
+
const native = nativeSectionOf(settings);
|
|
2299
|
+
const rows = systemRowsOf(settings);
|
|
2300
|
+
const config = {
|
|
2301
|
+
app: appOf(settings, native, extras),
|
|
2302
|
+
web: {
|
|
2303
|
+
cwd: where.cwd,
|
|
2304
|
+
build: webBuildOf(where, extras.debug),
|
|
2305
|
+
devCommand: `${where.command} dev --port ${DEV_PORT}`,
|
|
2306
|
+
devUrl: `http://127.0.0.1:${DEV_PORT}`,
|
|
2307
|
+
dist: path.join(where.cwd, "dist/web")
|
|
2308
|
+
},
|
|
2309
|
+
system: target === "android" ? [{ name: "shell" }, ...rows.filter((row) => row.name !== "shell")] : rows,
|
|
2310
|
+
projectDir: path.join(where.cwd, ".moku/tauri"),
|
|
2311
|
+
outDir: path.join(where.cwd, "dist-native")
|
|
2312
|
+
};
|
|
2313
|
+
const targets = native.targets ?? (target === void 0 ? void 0 : [target]);
|
|
2314
|
+
const signing = signingOf(native, where, target, extras);
|
|
2315
|
+
const ios = iosBundleOf(native, where.cwd);
|
|
2316
|
+
if (targets !== void 0) config.targets = targets;
|
|
2317
|
+
if (Object.keys(signing).length > 0) config.signing = signing;
|
|
2318
|
+
if (Object.keys(ios).length > 0) config.ios = ios;
|
|
2319
|
+
return config;
|
|
2320
|
+
}
|
|
2321
|
+
/**
|
|
2322
|
+
* Checks the target of a verb against the targets native knows. `build` and `dev` need one.
|
|
2323
|
+
*
|
|
2324
|
+
* @param known - The `TARGETS` of `@moku-labs/native`.
|
|
2325
|
+
* @param verb - The native verb.
|
|
2326
|
+
* @param given - The target the command line names, unchecked.
|
|
2327
|
+
* @returns The target, or `undefined` for a `doctor` or `clean` over every target.
|
|
2328
|
+
* @throws {Error} When the target is unknown, or `build` or `dev` names none.
|
|
2329
|
+
*/
|
|
2330
|
+
function targetOf(known, verb, given) {
|
|
2331
|
+
const target = known.find((name) => name === given);
|
|
2332
|
+
if (given !== void 0 && target === void 0) throw new Error(`[game] No native target "${given}".\n Name one of ${known.join(", ")}.`);
|
|
2333
|
+
if (target === void 0 && verb === "build") throw new Error("[game] moku-game native build needs a target.\n Run: moku-game native build ios --simulator.");
|
|
2334
|
+
if (target === void 0 && verb === "dev") throw new Error("[game] moku-game native dev needs a target.\n Run: moku-game native dev ios.");
|
|
2335
|
+
return target;
|
|
2336
|
+
}
|
|
2337
|
+
/**
|
|
2338
|
+
* Runs one verb on the cli of a started native app.
|
|
2339
|
+
*
|
|
2340
|
+
* @param cli - The cli of the native app.
|
|
2341
|
+
* @param verb - The native verb.
|
|
2342
|
+
* @param target - The checked target.
|
|
2343
|
+
* @param options - The simulator flag, the debug profile of a debug app, and the store flag.
|
|
2344
|
+
* @returns The boolean of `doctor`, true for the other verbs once they finish.
|
|
2345
|
+
*/
|
|
2346
|
+
async function runVerb(cli, verb, target, options) {
|
|
2347
|
+
switch (verb) {
|
|
2348
|
+
case "build": {
|
|
2349
|
+
const build = {
|
|
2350
|
+
target,
|
|
2351
|
+
simulator: options.simulator,
|
|
2352
|
+
...options.debug === void 0 ? {} : { debug: true },
|
|
2353
|
+
...options.store !== void 0 && target === "android" ? { aab: true } : {}
|
|
2354
|
+
};
|
|
2355
|
+
await cli.build(build);
|
|
2356
|
+
return true;
|
|
2357
|
+
}
|
|
2358
|
+
case "dev":
|
|
2359
|
+
await cli.dev({ target });
|
|
2360
|
+
return true;
|
|
2361
|
+
case "doctor": return cli.doctor({ target });
|
|
2362
|
+
case "clean":
|
|
2363
|
+
await cli.clean({ target });
|
|
2364
|
+
return true;
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
/**
|
|
2368
|
+
* What this run adds to the native config. A version that is not `x.y.z` stays out, and native
|
|
2369
|
+
* falls back to its own; `--store` has refused one before this reads it.
|
|
2370
|
+
*
|
|
2371
|
+
* @param options - The verb options.
|
|
2372
|
+
* @returns The extras of `nativeConfigOf`.
|
|
2373
|
+
*/
|
|
2374
|
+
function extrasOf(options) {
|
|
2375
|
+
const { debug, editor, store, unsigned, version } = options;
|
|
2376
|
+
return {
|
|
2377
|
+
...debug === void 0 ? {} : { debug: {
|
|
2378
|
+
level: debug,
|
|
2379
|
+
editor
|
|
2380
|
+
} },
|
|
2381
|
+
...store === void 0 ? {} : { buildNumber: store.buildNumber },
|
|
2382
|
+
...unsigned === void 0 ? {} : { unsigned },
|
|
2383
|
+
...version !== void 0 && STORE_VERSION.test(version) ? { version } : {}
|
|
2384
|
+
};
|
|
2385
|
+
}
|
|
2386
|
+
/**
|
|
2387
|
+
* Throws every problem of a store build as one error. A plain build passes untouched.
|
|
2388
|
+
*
|
|
2389
|
+
* @param settings - The resolved `config.ts` of the game.
|
|
2390
|
+
* @param where - The game folder and the home folder.
|
|
2391
|
+
* @param options - The verb options.
|
|
2392
|
+
* @throws {Error} With a line per problem.
|
|
2393
|
+
*/
|
|
2394
|
+
function refuseStoreProblems(settings, where, options) {
|
|
2395
|
+
if (options.store === void 0) return;
|
|
2396
|
+
const problems = storeProblems({
|
|
2397
|
+
settings,
|
|
2398
|
+
target: options.target === "ios" ? "ios" : "android",
|
|
2399
|
+
cwd: where.cwd,
|
|
2400
|
+
home: where.home,
|
|
2401
|
+
version: options.version,
|
|
2402
|
+
store: options.store
|
|
2403
|
+
});
|
|
2404
|
+
if (problems.length > 0) throw new Error(`[game] native --store: fix these before a store build.\n ${problems.join("\n ")}`);
|
|
2405
|
+
}
|
|
2406
|
+
/**
|
|
2407
|
+
* Runs one native verb through `@moku-labs/native` over the game's config. Native's cli prints
|
|
2408
|
+
* the progress and the failure itself.
|
|
2409
|
+
*
|
|
2410
|
+
* @param verb - The native verb: build, dev, doctor or clean.
|
|
2411
|
+
* @param settings - The resolved `config.ts` of the game.
|
|
2412
|
+
* @param where - The game folder, the command that runs `moku-game` and the home folder.
|
|
2413
|
+
* @param options - The target, the simulator flag, the debug profile, the version, the store build.
|
|
2414
|
+
* @returns True when the verb succeeded, false when it failed.
|
|
2415
|
+
* @throws {Error} When `config.ts` has no native section, a store build has a problem, before
|
|
2416
|
+
* anything loads, `@moku-labs/native` is not installed, or the target is unknown or missing.
|
|
2417
|
+
*/
|
|
2418
|
+
async function runNative(verb, settings, where, options) {
|
|
2419
|
+
nativeSectionOf(settings);
|
|
2420
|
+
refuseStoreProblems(settings, where, options);
|
|
2421
|
+
const native = await import("@moku-labs/native").catch((error) => {
|
|
2422
|
+
throw new Error("[game] moku-game native needs @moku-labs/native.\n Install it: bun add -d @moku-labs/native@^0.3.12.", { cause: error });
|
|
2423
|
+
});
|
|
2424
|
+
const target = targetOf(native.TARGETS, verb, options.target);
|
|
2425
|
+
const app = native.createApp({ config: nativeConfigOf(settings, where, target, extrasOf(options)) });
|
|
2426
|
+
await app.start();
|
|
2427
|
+
try {
|
|
2428
|
+
return await runVerb(app.cli, verb, target, options);
|
|
2429
|
+
} catch {
|
|
2430
|
+
return false;
|
|
2431
|
+
} finally {
|
|
2432
|
+
await app.stop();
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
//#endregion
|
|
2023
2436
|
//#region src/app/visual.ts
|
|
2024
2437
|
/**
|
|
2025
2438
|
* @file `moku-game visual`: the visual tests of a game from the bin. It imports the tests module,
|
|
@@ -2199,9 +2612,9 @@ async function runVisual(command, deps) {
|
|
|
2199
2612
|
* @file The command line of `moku-game`: the arguments read per command with `node:util`
|
|
2200
2613
|
* `parseArgs`, then one of `dev`, `build`, `native <verb>`, `keys`, `pack`, `visual` or `help`.
|
|
2201
2614
|
* Every seam of the process (the console, the environment, spawning, signals, the watcher, the
|
|
2202
|
-
* keys watch, the asset scanner, native, Bun's resolver, the visual test runner
|
|
2203
|
-
* `deps`, so a test runs a command with stubs. It
|
|
2204
|
-
* plain function, on no API.
|
|
2615
|
+
* keys watch, the asset scanner, native, Bun's resolver, the visual test runner, the home folder,
|
|
2616
|
+
* the file check, the game's version) comes in as `deps`, so a test runs a command with stubs. It
|
|
2617
|
+
* returns the exit code and never exits itself. A plain function, on no API.
|
|
2205
2618
|
*/
|
|
2206
2619
|
/** The flags every command takes. */
|
|
2207
2620
|
const GLOBAL_OPTIONS = [
|
|
@@ -2244,7 +2657,9 @@ const ALL_OPTIONS = {
|
|
|
2244
2657
|
dir: { type: "string" },
|
|
2245
2658
|
webgl: { type: "boolean" },
|
|
2246
2659
|
debug: { type: "string" },
|
|
2247
|
-
editor: { type: "string" }
|
|
2660
|
+
editor: { type: "string" },
|
|
2661
|
+
store: { type: "boolean" },
|
|
2662
|
+
"build-number": { type: "string" }
|
|
2248
2663
|
};
|
|
2249
2664
|
/** The flags of `visual` that `parseVisualArgv` reads, in the runner's words. */
|
|
2250
2665
|
const VISUAL_FLAGS = /^(?:update|only|no-pixels|pixels|dir|webgl|no-verify-frames)$/;
|
|
@@ -2259,7 +2674,9 @@ const COMMAND_OPTIONS = {
|
|
|
2259
2674
|
native: [
|
|
2260
2675
|
"simulator",
|
|
2261
2676
|
"debug",
|
|
2262
|
-
"editor"
|
|
2677
|
+
"editor",
|
|
2678
|
+
"store",
|
|
2679
|
+
"build-number"
|
|
2263
2680
|
],
|
|
2264
2681
|
keys: ["check"],
|
|
2265
2682
|
pack: ["no-cache"],
|
|
@@ -2290,6 +2707,8 @@ const VISUAL_TESTS = path.join("tests", "visual", "index.ts");
|
|
|
2290
2707
|
const DEFAULT_PORT = "3000";
|
|
2291
2708
|
/** The highest port number. */
|
|
2292
2709
|
const MAX_PORT = 65535;
|
|
2710
|
+
/** The highest `--build-number`, the top of an Android `versionCode`. */
|
|
2711
|
+
const MAX_BUILD_NUMBER = 21e8;
|
|
2293
2712
|
/** A host of `--editor`: a name or an IPv4 address, or an IPv6 address in brackets. */
|
|
2294
2713
|
const EDITOR_HOST = /^(?:[\w.-]+|\[[\da-f:.]+\])$/i;
|
|
2295
2714
|
/** The value a bare `--debug` reads as: the full profile, with no alias note. */
|
|
@@ -2303,6 +2722,7 @@ const USAGE = [
|
|
|
2303
2722
|
" dev [--port 3000] [--packed] serve the game with hot reload",
|
|
2304
2723
|
" build [--out dist/web] [--debug [--editor host:port]] pack the assets and build the page; --debug adds the editor agent and control",
|
|
2305
2724
|
" native build <target> [--simulator] [--debug [--editor host:port]] build the native app (ios, macos, android)",
|
|
2725
|
+
" native build <target> --store --build-number <n> a store build: an .aab on android, an .ipa on ios",
|
|
2306
2726
|
" native dev <target> run the native shell on the dev server",
|
|
2307
2727
|
" native doctor | native clean check or remove the native project",
|
|
2308
2728
|
" keys [--check] write generated/assets.ts and generated/manifest.json",
|
|
@@ -2539,22 +2959,61 @@ async function runNativeVerb(parsed, deps) {
|
|
|
2539
2959
|
if (word === void 0) throw new Error("[game] native: name a verb: build, dev, doctor, clean.");
|
|
2540
2960
|
if (verb === void 0) throw new Error(`[game] native: no verb "${word}". Name one of build, dev, doctor, clean.`);
|
|
2541
2961
|
refuseExtra(parsed, 2);
|
|
2962
|
+
const store = nativeStoreOf(parsed, verb, target);
|
|
2542
2963
|
const debug = nativeDebugOf(parsed, verb, target);
|
|
2543
2964
|
noteFullAlias(parsed, deps.ui);
|
|
2544
2965
|
const settings = await loadSettings(parsed.root);
|
|
2966
|
+
const version = deps.readPackageVersion(parsed.root);
|
|
2545
2967
|
const where = {
|
|
2546
2968
|
cwd: parsed.root,
|
|
2547
|
-
command: selfCommand(parsed, deps)
|
|
2969
|
+
command: selfCommand(parsed, deps),
|
|
2970
|
+
home: deps.home
|
|
2548
2971
|
};
|
|
2549
2972
|
const options = {
|
|
2550
2973
|
...target === void 0 ? {} : { target },
|
|
2551
2974
|
...verb === "build" && parsed.values.simulator === true ? { simulator: true } : {},
|
|
2552
|
-
...debug
|
|
2975
|
+
...debug,
|
|
2976
|
+
...version === void 0 ? {} : { version }
|
|
2553
2977
|
};
|
|
2554
2978
|
if (debug.debug !== void 0 && target === "android") deps.ui.warn("native: a DEBUG app with the editor agent, installed beside the store app. Never ship it to a store.");
|
|
2979
|
+
if (store.store === true) {
|
|
2980
|
+
options.store = {
|
|
2981
|
+
buildNumber: store.buildNumber,
|
|
2982
|
+
env: deps.env,
|
|
2983
|
+
exists: deps.exists
|
|
2984
|
+
};
|
|
2985
|
+
warnIosStore(settings, target, deps.ui);
|
|
2986
|
+
} else if (verb === "build" && target === "android" && debug.debug === void 0) leaveKeyOut(settings, options, deps);
|
|
2555
2987
|
return await deps.native(verb, settings, where, options) ? 0 : 1;
|
|
2556
2988
|
}
|
|
2557
2989
|
/**
|
|
2990
|
+
* Keeps a plain Android build going without its passwords: Gradle would refuse the signing block
|
|
2991
|
+
* only after the compile, and a teammate with no key still builds. The result is an unsigned `.apk`.
|
|
2992
|
+
*
|
|
2993
|
+
* @param settings - The resolved `config.ts` of the game.
|
|
2994
|
+
* @param options - The verb options.
|
|
2995
|
+
* @param deps - The seams of the process.
|
|
2996
|
+
*/
|
|
2997
|
+
function leaveKeyOut(settings, options, deps) {
|
|
2998
|
+
const missing = missingPasswords(settings.native?.signing?.android, deps.env);
|
|
2999
|
+
if (missing.length === 0) return;
|
|
3000
|
+
options.unsigned = true;
|
|
3001
|
+
deps.ui.warn(`native: ${missing.join(", ")} not set, so this build is an unsigned .apk.`);
|
|
3002
|
+
}
|
|
3003
|
+
/**
|
|
3004
|
+
* Warns about what App Store Connect asks for on an iOS store build. Neither stops the build.
|
|
3005
|
+
*
|
|
3006
|
+
* @param settings - The resolved `config.ts` of the game.
|
|
3007
|
+
* @param target - The target the command line names.
|
|
3008
|
+
* @param ui - The console.
|
|
3009
|
+
*/
|
|
3010
|
+
function warnIosStore(settings, target, ui) {
|
|
3011
|
+
const native = settings.native;
|
|
3012
|
+
if (target !== "ios" || native === void 0) return;
|
|
3013
|
+
if (native.ios?.privacyManifest === void 0) ui.warn("native: --store on ios with no native.ios.privacyManifest. App Store Connect asks for one.");
|
|
3014
|
+
if (native.ios?.infoPlist?.ITSAppUsesNonExemptEncryption === void 0) ui.warn("native: --store on ios with no ITSAppUsesNonExemptEncryption in native.ios.infoPlist. App Store Connect asks on every upload without it.");
|
|
3015
|
+
}
|
|
3016
|
+
/**
|
|
2558
3017
|
* Reads `--debug` and `--editor` of `moku-game native`: they go with `native build android`
|
|
2559
3018
|
* only in this release.
|
|
2560
3019
|
*
|
|
@@ -2578,6 +3037,51 @@ function nativeDebugOf(parsed, verb, target) {
|
|
|
2578
3037
|
};
|
|
2579
3038
|
}
|
|
2580
3039
|
/**
|
|
3040
|
+
* Reads `--build-number`: a whole number from 1 to the top of an Android `versionCode`.
|
|
3041
|
+
*
|
|
3042
|
+
* @param value - The value of the flag.
|
|
3043
|
+
* @returns The number.
|
|
3044
|
+
* @throws {Error} When the value is anything else.
|
|
3045
|
+
* @example
|
|
3046
|
+
* ```ts
|
|
3047
|
+
* buildNumberOf("12"); // 12
|
|
3048
|
+
* ```
|
|
3049
|
+
*/
|
|
3050
|
+
function buildNumberOf(value) {
|
|
3051
|
+
const number = Number(value);
|
|
3052
|
+
if (/^\d+$/.test(value) && number >= 1 && number <= MAX_BUILD_NUMBER) return number;
|
|
3053
|
+
throw new Error(`[game] native: --build-number takes an integer from 1 to ${MAX_BUILD_NUMBER}, got "${value}".`);
|
|
3054
|
+
}
|
|
3055
|
+
/**
|
|
3056
|
+
* Reads `--store` and `--build-number` of `moku-game native`, before any config is read: they go
|
|
3057
|
+
* with `native build ios` and `native build android` only, one number for both stores.
|
|
3058
|
+
*
|
|
3059
|
+
* @param parsed - The command line.
|
|
3060
|
+
* @param verb - The native verb.
|
|
3061
|
+
* @param target - The target the command line names, unchecked.
|
|
3062
|
+
* @returns The store flag and the number, or nothing without them.
|
|
3063
|
+
* @throws {Error} When either goes without the other or with another verb or target, when `--debug`,
|
|
3064
|
+
* `--editor` or `--simulator` comes along, or when the number is refused.
|
|
3065
|
+
*/
|
|
3066
|
+
function nativeStoreOf(parsed, verb, target) {
|
|
3067
|
+
const { store, "build-number": number } = parsed.values;
|
|
3068
|
+
if (store !== true && number === void 0) return {};
|
|
3069
|
+
if (store !== true) throw new Error("[game] native: --build-number goes with --store.");
|
|
3070
|
+
if (verb !== "build") throw new Error("[game] native: --store goes with native build only.");
|
|
3071
|
+
const clash = [
|
|
3072
|
+
"debug",
|
|
3073
|
+
"editor",
|
|
3074
|
+
"simulator"
|
|
3075
|
+
].find((flag) => parsed.values[flag] !== void 0);
|
|
3076
|
+
if (clash !== void 0) throw new Error(`[game] native: --store does not go with --${clash}.`);
|
|
3077
|
+
if (target !== "ios" && target !== "android") throw new Error(`[game] native: --store builds ios or android, got ${target ?? "no target"}.`);
|
|
3078
|
+
if (number === void 0) throw new Error("[game] native: --store needs --build-number, the number of this upload.");
|
|
3079
|
+
return {
|
|
3080
|
+
store: true,
|
|
3081
|
+
buildNumber: buildNumberOf(number)
|
|
3082
|
+
};
|
|
3083
|
+
}
|
|
3084
|
+
/**
|
|
2581
3085
|
* Runs `moku-game keys` or `pack` through the asset scanner, with the layers of `config.ts`.
|
|
2582
3086
|
*
|
|
2583
3087
|
* @param parsed - The command line.
|
|
@@ -3035,180 +3539,6 @@ async function watchKeysAt(root, settings, seams, options = {}) {
|
|
|
3035
3539
|
return { close };
|
|
3036
3540
|
}
|
|
3037
3541
|
//#endregion
|
|
3038
|
-
//#region src/app/native.ts
|
|
3039
|
-
/**
|
|
3040
|
-
* @file The native verbs of `moku-game`: a game's `config.ts` as the config of `@moku-labs/native`,
|
|
3041
|
-
* and one verb run over it. Node only, no package export: the bin bundles it. The only file of the
|
|
3042
|
-
* engine that imports `@moku-labs/native`, and only with `import()`, so a web-only game never
|
|
3043
|
-
* loads it.
|
|
3044
|
-
*/
|
|
3045
|
-
/** The port of the dev server Tauri's shell starts and loads. */
|
|
3046
|
-
const DEV_PORT = 5173;
|
|
3047
|
-
/**
|
|
3048
|
-
* The native section of a resolved config.
|
|
3049
|
-
*
|
|
3050
|
-
* @param settings - The resolved `config.ts` of the game.
|
|
3051
|
-
* @returns The native section.
|
|
3052
|
-
* @throws {Error} When `config.ts` has no native section.
|
|
3053
|
-
*/
|
|
3054
|
-
function nativeSectionOf(settings) {
|
|
3055
|
-
if (settings.native === void 0) throw new Error("[game] config.ts has no native section.\n Add native: { name, identifier } to config.ts.");
|
|
3056
|
-
return settings.native;
|
|
3057
|
-
}
|
|
3058
|
-
/**
|
|
3059
|
-
* The system rows native packages: one per system plugin that needs a Tauri capability. The
|
|
3060
|
-
* webview's own events and wake lock serve `lifecycle` and `keepAwake`, so they need no row. A
|
|
3061
|
-
* `"store"` save needs the store row even when `system` leaves it out.
|
|
3062
|
-
*
|
|
3063
|
-
* @param settings - The resolved `config.ts` of the game.
|
|
3064
|
-
* @returns The rows, in the order of `config.system`.
|
|
3065
|
-
*/
|
|
3066
|
-
function systemRowsOf(settings) {
|
|
3067
|
-
const names = settings.system.filter((name) => name !== "lifecycle" && name !== "keepAwake");
|
|
3068
|
-
if (settings.save === "store" && !names.includes("store")) names.push("store");
|
|
3069
|
-
return names.map((name) => ({ name }));
|
|
3070
|
-
}
|
|
3071
|
-
/**
|
|
3072
|
-
* The web build command native runs: `moku-game build`, with the debug profile and the editor
|
|
3073
|
-
* address of a debug app.
|
|
3074
|
-
*
|
|
3075
|
-
* @param where - The game folder and the command that runs `moku-game`.
|
|
3076
|
-
* @param debug - The debug profile, or `undefined` for a store app.
|
|
3077
|
-
* @returns The command.
|
|
3078
|
-
* @example
|
|
3079
|
-
* ```ts
|
|
3080
|
-
* webBuildOf({ cwd: "/g", command: '"bun" "/g/bin/moku-game.mjs"' }, { level: "full", editor: "192.168.1.20:47600" }); // '"bun" "/g/bin/moku-game.mjs" build --debug --editor 192.168.1.20:47600'
|
|
3081
|
-
* ```
|
|
3082
|
-
*/
|
|
3083
|
-
function webBuildOf(where, debug) {
|
|
3084
|
-
if (debug === void 0) return `${where.command} build`;
|
|
3085
|
-
const level = debug.level === "full" ? "--debug" : "--debug=read";
|
|
3086
|
-
const editor = debug.editor === void 0 ? "" : ` --editor ${debug.editor}`;
|
|
3087
|
-
return `${where.command} build ${level}${editor}`;
|
|
3088
|
-
}
|
|
3089
|
-
/**
|
|
3090
|
-
* Maps a game's resolved `config.ts` to the config of `@moku-labs/native`: the app from `native`
|
|
3091
|
-
* and `page`, the web build through `moku-game`, the system rows, the targets, and the Tauri
|
|
3092
|
-
* project and output folders under the game. An Android app composes native's `shell` system
|
|
3093
|
-
* first, the one that sets `globalThis.__MOKU_NATIVE__`. A debug app builds its web page with the
|
|
3094
|
-
* same profile and `--editor`; its name and identifier stay the game's.
|
|
3095
|
-
*
|
|
3096
|
-
* @param settings - The resolved `config.ts` of the game.
|
|
3097
|
-
* @param where - The game folder and the command that runs `moku-game`.
|
|
3098
|
-
* @param target - The target of the verb, used when `config.ts` names no targets.
|
|
3099
|
-
* @param debug - The debug profile of a debug app; left out for a store app.
|
|
3100
|
-
* @returns The config for `createApp({ config })` of `@moku-labs/native`.
|
|
3101
|
-
* @throws {Error} When `config.ts` has no native section.
|
|
3102
|
-
* @example
|
|
3103
|
-
* ```ts
|
|
3104
|
-
* const where = { cwd: "/g", command: '"/usr/local/bin/bun" "/g/node_modules/@moku-labs/game/bin/moku-game.mjs" "--root" "/g"' };
|
|
3105
|
-
* nativeConfigOf(resolveConfig({ page: { title: "T" }, native: { name: "T", identifier: "com.x.t" } }), where, "ios").web.dist; // "/g/dist/web"
|
|
3106
|
-
* ```
|
|
3107
|
-
*/
|
|
3108
|
-
function nativeConfigOf(settings, where, target, debug) {
|
|
3109
|
-
const native = nativeSectionOf(settings);
|
|
3110
|
-
const rows = systemRowsOf(settings);
|
|
3111
|
-
const config = {
|
|
3112
|
-
app: {
|
|
3113
|
-
name: native.name,
|
|
3114
|
-
identifier: native.identifier,
|
|
3115
|
-
orientation: settings.page.orientation,
|
|
3116
|
-
backgroundColor: settings.page.background
|
|
3117
|
-
},
|
|
3118
|
-
web: {
|
|
3119
|
-
cwd: where.cwd,
|
|
3120
|
-
build: webBuildOf(where, debug),
|
|
3121
|
-
devCommand: `${where.command} dev --port ${DEV_PORT}`,
|
|
3122
|
-
devUrl: `http://127.0.0.1:${DEV_PORT}`,
|
|
3123
|
-
dist: path.join(where.cwd, "dist/web")
|
|
3124
|
-
},
|
|
3125
|
-
system: target === "android" ? [{ name: "shell" }, ...rows.filter((row) => row.name !== "shell")] : rows,
|
|
3126
|
-
projectDir: path.join(where.cwd, ".moku/tauri"),
|
|
3127
|
-
outDir: path.join(where.cwd, "dist-native")
|
|
3128
|
-
};
|
|
3129
|
-
const targets = native.targets ?? (target === void 0 ? void 0 : [target]);
|
|
3130
|
-
if (native.icon !== void 0) config.app.icon = native.icon;
|
|
3131
|
-
if (targets !== void 0) config.targets = targets;
|
|
3132
|
-
return config;
|
|
3133
|
-
}
|
|
3134
|
-
/**
|
|
3135
|
-
* Checks the target of a verb against the targets native knows. `build` and `dev` need one.
|
|
3136
|
-
*
|
|
3137
|
-
* @param known - The `TARGETS` of `@moku-labs/native`.
|
|
3138
|
-
* @param verb - The native verb.
|
|
3139
|
-
* @param given - The target the command line names, unchecked.
|
|
3140
|
-
* @returns The target, or `undefined` for a `doctor` or `clean` over every target.
|
|
3141
|
-
* @throws {Error} When the target is unknown, or `build` or `dev` names none.
|
|
3142
|
-
*/
|
|
3143
|
-
function targetOf(known, verb, given) {
|
|
3144
|
-
const target = known.find((name) => name === given);
|
|
3145
|
-
if (given !== void 0 && target === void 0) throw new Error(`[game] No native target "${given}".\n Name one of ${known.join(", ")}.`);
|
|
3146
|
-
if (target === void 0 && verb === "build") throw new Error("[game] moku-game native build needs a target.\n Run: moku-game native build ios --simulator.");
|
|
3147
|
-
if (target === void 0 && verb === "dev") throw new Error("[game] moku-game native dev needs a target.\n Run: moku-game native dev ios.");
|
|
3148
|
-
return target;
|
|
3149
|
-
}
|
|
3150
|
-
/**
|
|
3151
|
-
* Runs one verb on the cli of a started native app.
|
|
3152
|
-
*
|
|
3153
|
-
* @param cli - The cli of the native app.
|
|
3154
|
-
* @param verb - The native verb.
|
|
3155
|
-
* @param target - The checked target.
|
|
3156
|
-
* @param options - The simulator flag, and the debug profile of a debug app.
|
|
3157
|
-
* @returns The boolean of `doctor`, true for the other verbs once they finish.
|
|
3158
|
-
*/
|
|
3159
|
-
async function runVerb(cli, verb, target, options) {
|
|
3160
|
-
switch (verb) {
|
|
3161
|
-
case "build": {
|
|
3162
|
-
const build = {
|
|
3163
|
-
target,
|
|
3164
|
-
simulator: options.simulator,
|
|
3165
|
-
...options.debug === void 0 ? {} : { debug: true }
|
|
3166
|
-
};
|
|
3167
|
-
await cli.build(build);
|
|
3168
|
-
return true;
|
|
3169
|
-
}
|
|
3170
|
-
case "dev":
|
|
3171
|
-
await cli.dev({ target });
|
|
3172
|
-
return true;
|
|
3173
|
-
case "doctor": return cli.doctor({ target });
|
|
3174
|
-
case "clean":
|
|
3175
|
-
await cli.clean({ target });
|
|
3176
|
-
return true;
|
|
3177
|
-
}
|
|
3178
|
-
}
|
|
3179
|
-
/**
|
|
3180
|
-
* Runs one native verb through `@moku-labs/native` over the game's config. Native's cli prints
|
|
3181
|
-
* the progress and the failure itself.
|
|
3182
|
-
*
|
|
3183
|
-
* @param verb - The native verb: build, dev, doctor or clean.
|
|
3184
|
-
* @param settings - The resolved `config.ts` of the game.
|
|
3185
|
-
* @param where - The game folder and the command that runs `moku-game`.
|
|
3186
|
-
* @param options - The target, the simulator flag, and the debug profile of a debug app.
|
|
3187
|
-
* @returns True when the verb succeeded, false when it failed.
|
|
3188
|
-
* @throws {Error} When `config.ts` has no native section, `@moku-labs/native` is not installed, or
|
|
3189
|
-
* the target is unknown or missing.
|
|
3190
|
-
*/
|
|
3191
|
-
async function runNative(verb, settings, where, options) {
|
|
3192
|
-
nativeSectionOf(settings);
|
|
3193
|
-
const native = await import("@moku-labs/native").catch((error) => {
|
|
3194
|
-
throw new Error("[game] moku-game native needs @moku-labs/native.\n Install it: bun add -d @moku-labs/native@^0.3.9.", { cause: error });
|
|
3195
|
-
});
|
|
3196
|
-
const target = targetOf(native.TARGETS, verb, options.target);
|
|
3197
|
-
const debug = options.debug === void 0 ? void 0 : {
|
|
3198
|
-
level: options.debug,
|
|
3199
|
-
editor: options.editor
|
|
3200
|
-
};
|
|
3201
|
-
const app = native.createApp({ config: nativeConfigOf(settings, where, target, debug) });
|
|
3202
|
-
await app.start();
|
|
3203
|
-
try {
|
|
3204
|
-
return await runVerb(app.cli, verb, target, options);
|
|
3205
|
-
} catch {
|
|
3206
|
-
return false;
|
|
3207
|
-
} finally {
|
|
3208
|
-
await app.stop();
|
|
3209
|
-
}
|
|
3210
|
-
}
|
|
3211
|
-
//#endregion
|
|
3212
3542
|
//#region src/cli.ts
|
|
3213
3543
|
/**
|
|
3214
3544
|
* @file The `@moku-labs/game/cli` door, node and bun only: the `moku-game` bin and the editor's
|
|
@@ -3274,8 +3604,9 @@ function keysSeams(ui) {
|
|
|
3274
3604
|
/**
|
|
3275
3605
|
* The real process behind the command line: the branded console, the environment the bin
|
|
3276
3606
|
* started with, Bun's spawn and resolver, the signals, `fs.watch`, the keys watch, the asset
|
|
3277
|
-
* scanner with the string tools, native,
|
|
3278
|
-
* `moku-game visual
|
|
3607
|
+
* scanner with the string tools, native, the visual test runner, loaded only by
|
|
3608
|
+
* `moku-game visual`, and what a native build reads: the home folder, the file check and the
|
|
3609
|
+
* version of the game's `package.json`.
|
|
3279
3610
|
*
|
|
3280
3611
|
* @returns The seams of this process.
|
|
3281
3612
|
*/
|
|
@@ -3303,7 +3634,10 @@ function processDeps() {
|
|
|
3303
3634
|
resolve: bunResolve,
|
|
3304
3635
|
loadPage: (file) => import(file),
|
|
3305
3636
|
visual: () => import("./visual.mjs"),
|
|
3306
|
-
now: () => Date.now()
|
|
3637
|
+
now: () => Date.now(),
|
|
3638
|
+
home: homedir(),
|
|
3639
|
+
exists: existsSync,
|
|
3640
|
+
readPackageVersion: packageVersionOf
|
|
3307
3641
|
};
|
|
3308
3642
|
}
|
|
3309
3643
|
/**
|
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
const BOOT_WIDTH = "40vmin";
|
|
4
4
|
/** The fade of a boot picture whose config names none, ms. */
|
|
5
5
|
const BOOT_FADE_MS = 300;
|
|
6
|
+
/** The strings a `native.signing.android` cannot go without. */
|
|
7
|
+
const ANDROID_SIGNING_FIELDS = [
|
|
8
|
+
"keystorePath",
|
|
9
|
+
"keystorePasswordEnv",
|
|
10
|
+
"keyAlias"
|
|
11
|
+
];
|
|
12
|
+
/** An iOS version as native takes it: `26.0` or `26.0.1`. */
|
|
13
|
+
const IOS_VERSION = /^\d+\.\d+(\.\d+)?$/;
|
|
6
14
|
/**
|
|
7
15
|
* The save kinds a config may name.
|
|
8
16
|
*
|
|
@@ -55,12 +63,74 @@ function overlayStarts() {
|
|
|
55
63
|
]);
|
|
56
64
|
}
|
|
57
65
|
/**
|
|
66
|
+
* Tells whether a field of a config is a string with something in it.
|
|
67
|
+
*
|
|
68
|
+
* @param value - The field, unchecked.
|
|
69
|
+
* @returns False for a missing field, an empty string and any other type.
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* isFilled(""); // false
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
function isFilled(value) {
|
|
76
|
+
return typeof value === "string" && value !== "";
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Finds the first value under an `Info.plist` value that a plist cannot hold.
|
|
80
|
+
*
|
|
81
|
+
* @param value - The value, unchecked.
|
|
82
|
+
* @param at - Its dotted path.
|
|
83
|
+
* @returns The path of the bad value, or `undefined` when all of it is fine.
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* badPlistValue({ a: [true, 7] }, "Key"); // "Key.a.1"
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
function badPlistValue(value, at) {
|
|
90
|
+
if (typeof value === "string" || typeof value === "boolean") return void 0;
|
|
91
|
+
if (!(value instanceof Object)) return at;
|
|
92
|
+
for (const [key, child] of Object.entries(value)) {
|
|
93
|
+
const bad = badPlistValue(child, `${at}.${key}`);
|
|
94
|
+
if (bad !== void 0) return bad;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Throws for a half-filled `native.signing`.
|
|
99
|
+
*
|
|
100
|
+
* @param signing - `native.signing` of the config.
|
|
101
|
+
* @throws {Error} When `android` misses one of its required strings, or `apple` has no `teamId`.
|
|
102
|
+
*/
|
|
103
|
+
function checkSigning(signing) {
|
|
104
|
+
const android = signing?.android;
|
|
105
|
+
const missing = ANDROID_SIGNING_FIELDS.find((field) => !isFilled(android?.[field]));
|
|
106
|
+
if (android !== void 0 && missing !== void 0) throw new Error(`[game] config.native.signing.android has no ${missing}.\n Name keystorePath, keystorePasswordEnv and keyAlias.`);
|
|
107
|
+
if (signing?.apple !== void 0 && !isFilled(signing.apple.teamId)) throw new Error("[game] config.native.signing.apple has no teamId.\n Name the Apple Developer team id.");
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Throws for a value of `native.ios` that would fail deep in a build.
|
|
111
|
+
*
|
|
112
|
+
* @param ios - `native.ios` of the config.
|
|
113
|
+
* @throws {Error} When `minimumVersion` is no iOS version, or a value of `infoPlist`, at any depth,
|
|
114
|
+
* is no plist value.
|
|
115
|
+
*/
|
|
116
|
+
function checkIos(ios) {
|
|
117
|
+
const minimum = ios?.minimumVersion;
|
|
118
|
+
const isIosVersion = typeof minimum === "string" && IOS_VERSION.test(minimum);
|
|
119
|
+
if (minimum !== void 0 && !isIosVersion) throw new Error(`[game] config.native.ios.minimumVersion is ${JSON.stringify(minimum)}.\n Use a version such as "26.0" or "26.0.1".`);
|
|
120
|
+
for (const [key, value] of Object.entries(ios?.infoPlist ?? {})) {
|
|
121
|
+
const bad = badPlistValue(value, key);
|
|
122
|
+
if (bad === void 0) continue;
|
|
123
|
+
throw new Error(`[game] config.native.ios.infoPlist.${bad} is not a plist value.\n Use a string, a boolean, an array or an object.`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
58
127
|
* Throws for the first value of a config that TypeScript would have refused.
|
|
59
128
|
*
|
|
60
129
|
* @param config - The default export of `config.ts`.
|
|
61
130
|
* @throws {Error} When `save` is not a save kind, a `system` name is not wired, the title is empty,
|
|
62
|
-
* `debug.overlay` is not a start mode, `page.boot` has no image,
|
|
63
|
-
* or more.
|
|
131
|
+
* `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, or a value of
|
|
133
|
+
* `native.ios.infoPlist` is no plist value.
|
|
64
134
|
*/
|
|
65
135
|
function checkConfig(config) {
|
|
66
136
|
if (config.save !== void 0 && !saveKinds().has(config.save)) throw new Error(`[game] config.save is "${config.save}".\n Use "memory", "local" or "store".`);
|
|
@@ -74,6 +144,8 @@ function checkConfig(config) {
|
|
|
74
144
|
if (config.page.boot !== void 0 && (typeof image !== "string" || image === "")) throw new Error("[game] config.page.boot has no image.\n Name a picture file of the game in page.boot.image.");
|
|
75
145
|
const fadeMs = config.page.boot?.fadeMs;
|
|
76
146
|
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
|
+
checkSigning(config.native?.signing);
|
|
148
|
+
checkIos(config.native?.ios);
|
|
77
149
|
}
|
|
78
150
|
/**
|
|
79
151
|
* Fills the defaults of `page.boot`: the width `"40vmin"`, the fade 300 ms.
|
|
@@ -101,8 +173,9 @@ function resolveBoot(boot) {
|
|
|
101
173
|
* @param config - The default export of `config.ts`.
|
|
102
174
|
* @returns The config with every field set.
|
|
103
175
|
* @throws {Error} When `save` is not a save kind, a `system` name is not wired, the title is empty,
|
|
104
|
-
* `debug.overlay` is not a start mode, `page.boot` has no image,
|
|
105
|
-
* or more.
|
|
176
|
+
* `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, or a value of
|
|
178
|
+
* `native.ios.infoPlist` is no plist value.
|
|
106
179
|
* @example
|
|
107
180
|
* ```ts
|
|
108
181
|
* resolveConfig({ page: { title: "T" } }).save; // "memory"
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as sfx, $t as worldPlugin, A as types_exports$7, At as Glow, B as defineMotion, Bt as Animation, C as types_exports$14, Ct as messageDuration, D as types_exports$10, Dt as Blur, E as types_exports$11, Et as Alpha, F as types_exports$2, Ft as audioPlugin, G as external, Gt as MONITOR_SECTIONS, H as platformPlugin, Ht as rendererPlugin, I as types_exports$1, It as scenesPlugin, J as mark, Jt as PERF_LOG_VERSION, K as frames, Kt as PERF_CAUSES, L as types_exports, Lt as assetsPlugin, M as types_exports$5, Mt as Outline, N as types_exports$4, Nt as defineFilter, O as types_exports$9, Ot as ColorMatrix, P as types_exports$3, Pt as debugPlugin, Q as set, Qt as DEMAND_REASONS, R as uiPlugin, Rt as animPlugin, S as types_exports$15, St as messageArgument, T as types_exports$12, Tt as Emitter, U as HAPTIC_KINDS, Ut as PASS_KINDS, V as textPlugin, Vt as Frames, W as defineAnimation, Wt as frameAt, X as play, Xt as SHADER_WHATS, Y as parallel, Yt as PROBLEM_RULES, Z as sequence, Zt as CANVAS_RESTARTS, _ as defineBundles, _t as Tappable, a as cubicBezier, an as to, at as use, b as types_exports$17, bt as Traced, c as hint, cn as SaveUnreadableError, ct as Draggable, d as defineScene, dn as clockPlugin, dt as Hovered, en as flowPlugin, et as spawn, f as tr, ft as Pointer, g as music, gt as Swipeable, h as defineEmitter, ht as Pressed, i as screen, in as slot, it as tween, j as types_exports$6, jt as Noise, k as types_exports$8, kt as Displacement, l as schedule, ln as lifecyclePlugin, lt as DropTarget, m as flattenFeatures, mt as Pressable, n as createPlugin, nn as contribution, nt as stagger, o as defineEffect, on as type, ot as wait, p as defineFeature, pt as PointerOver, q as haptic, qt as PERF_GAP_BUCKETS, r as defineGame, rn as exit, rt as stopSfx, s as guide, sn as modelPlugin, st as inputPlugin, t as createApp, tt as spawned, u as projection, un as timePlugin, ut as Held, v as load, vt as Touchable, w as types_exports$13, wt as effectsPlugin, x as types_exports$16, xt as i18nPlugin, y as ready, yt as Traceable, z as resolve, zt as AnimPlayer } from "./src-
|
|
1
|
+
import { $ as sfx, $t as worldPlugin, A as types_exports$7, At as Glow, B as defineMotion, Bt as Animation, C as types_exports$14, Ct as messageDuration, D as types_exports$10, Dt as Blur, E as types_exports$11, Et as Alpha, F as types_exports$2, Ft as audioPlugin, G as external, Gt as MONITOR_SECTIONS, H as platformPlugin, Ht as rendererPlugin, I as types_exports$1, It as scenesPlugin, J as mark, Jt as PERF_LOG_VERSION, K as frames, Kt as PERF_CAUSES, L as types_exports, Lt as assetsPlugin, M as types_exports$5, Mt as Outline, N as types_exports$4, Nt as defineFilter, O as types_exports$9, Ot as ColorMatrix, P as types_exports$3, Pt as debugPlugin, Q as set, Qt as DEMAND_REASONS, R as uiPlugin, Rt as animPlugin, S as types_exports$15, St as messageArgument, T as types_exports$12, Tt as Emitter, U as HAPTIC_KINDS, Ut as PASS_KINDS, V as textPlugin, Vt as Frames, W as defineAnimation, Wt as frameAt, X as play, Xt as SHADER_WHATS, Y as parallel, Yt as PROBLEM_RULES, Z as sequence, Zt as CANVAS_RESTARTS, _ as defineBundles, _t as Tappable, a as cubicBezier, an as to, at as use, b as types_exports$17, bt as Traced, c as hint, cn as SaveUnreadableError, ct as Draggable, d as defineScene, dn as clockPlugin, dt as Hovered, en as flowPlugin, et as spawn, f as tr, ft as Pointer, g as music, gt as Swipeable, h as defineEmitter, ht as Pressed, i as screen, in as slot, it as tween, j as types_exports$6, jt as Noise, k as types_exports$8, kt as Displacement, l as schedule, ln as lifecyclePlugin, lt as DropTarget, m as flattenFeatures, mt as Pressable, n as createPlugin, nn as contribution, nt as stagger, o as defineEffect, on as type, ot as wait, p as defineFeature, pt as PointerOver, q as haptic, qt as PERF_GAP_BUCKETS, r as defineGame, rn as exit, rt as stopSfx, s as guide, sn as modelPlugin, st as inputPlugin, t as createApp, tt as spawned, u as projection, un as timePlugin, ut as Held, v as load, vt as Touchable, w as types_exports$13, wt as effectsPlugin, x as types_exports$16, xt as i18nPlugin, y as ready, yt as Traceable, z as resolve, zt as AnimPlayer } from "./src-D1J2QlGK.mjs";
|
|
2
2
|
import { $ as Layer, B as Display, C as defineStyle, E as bind, G as Parent, H as NineSlice, J as Transform, K as Shape, O as defineTextStyles, Q as Exiting, S as defineTokens, T as Text, U as Overlay, V as HudPart, Z as sprite, _ as ScrollState, at as resource, b as popup, ct as tag, d as Box, et as Now, h as LocalWrite, it as mut, k as label, nt as Tree, ot as system, p as DebugTrigger, q as Sprite, rt as component, tt as Order, w as Countdown } from "./visual-B7TxMv1J.mjs";
|
|
3
3
|
import { t as defineComponent } from "./component-DGg5DqKK.mjs";
|
|
4
4
|
export { Alpha, types_exports as Anim, AnimPlayer, Animation, types_exports$1 as Assets, types_exports$2 as Audio, Blur, Box, CANVAS_RESTARTS, types_exports$3 as Clock, ColorMatrix, Countdown, DEMAND_REASONS, types_exports$4 as Debug, DebugTrigger, Displacement, Display, Draggable, DropTarget, types_exports$5 as Effects, Emitter, Exiting, types_exports$6 as Flow, Frames, Glow, HAPTIC_KINDS, Held, Hovered, HudPart, types_exports$7 as I18n, types_exports$8 as Input, Layer, types_exports$9 as Lifecycle, LocalWrite, MONITOR_SECTIONS, types_exports$10 as Model, NineSlice, Noise, Now, Order, Outline, Overlay, PASS_KINDS, PERF_CAUSES, PERF_GAP_BUCKETS, PERF_LOG_VERSION, PROBLEM_RULES, Parent, types_exports$11 as Platform, Pointer, PointerOver, Pressable, Pressed, types_exports$12 as Renderer, SHADER_WHATS, SaveUnreadableError, types_exports$13 as Scenes, ScrollState, Shape, Sprite, Swipeable, Tappable, Text, types_exports$14 as TextTypes, types_exports$15 as Time, Touchable, Traceable, Traced, Transform, Tree, types_exports$16 as Ui, types_exports$17 as World, animPlugin, assetsPlugin, audioPlugin, bind, clockPlugin, component, contribution, createApp, createPlugin, cubicBezier, debugPlugin, defineAnimation, defineBundles, defineComponent, defineEffect, defineEmitter, defineFeature, defineFilter, defineGame, defineMotion, defineScene, defineStyle, defineTextStyles, defineTokens, effectsPlugin, exit, external, flattenFeatures, flowPlugin, frameAt, frames, guide, haptic, hint, i18nPlugin, inputPlugin, label, lifecyclePlugin, load, mark, messageArgument, messageDuration, modelPlugin, music, mut, parallel, platformPlugin, play, popup, projection, ready, rendererPlugin, resolve, resource, scenesPlugin, schedule, screen, sequence, set, sfx, slot, spawn, spawned, sprite, stagger, stopSfx, system, tag, textPlugin, timePlugin, to, tr, tween, type, uiPlugin, use, wait, worldPlugin };
|
|
@@ -17601,15 +17601,17 @@ function fitTexture(kctx, pixi, current, size, label) {
|
|
|
17601
17601
|
return texture;
|
|
17602
17602
|
}
|
|
17603
17603
|
/**
|
|
17604
|
-
* Takes a texture
|
|
17605
|
-
*
|
|
17604
|
+
* Takes a texture out of the pool (F119): the first one of the same CSS size and resolution, its bytes no longer the
|
|
17605
|
+
* pool's. The last one fills its place: the pool keeps no order. With none of that size the last one is resized to it
|
|
17606
|
+
* (F132): a view that keeps leaving at one size and coming back at another would otherwise pile up textures of a size
|
|
17607
|
+
* no take asks for, until the budget is full.
|
|
17606
17608
|
*
|
|
17607
17609
|
* @param kctx - The kept context.
|
|
17608
17610
|
* @param size - CSS px and texels per CSS px.
|
|
17609
17611
|
* @param size.width - CSS width.
|
|
17610
17612
|
* @param size.height - CSS height.
|
|
17611
17613
|
* @param size.resolution - Texels per CSS px.
|
|
17612
|
-
* @returns The texture, or `undefined` when
|
|
17614
|
+
* @returns The texture, or `undefined` when the pool is empty.
|
|
17613
17615
|
*/
|
|
17614
17616
|
function fromPool(kctx, size) {
|
|
17615
17617
|
const { pool } = kctx.state;
|
|
@@ -17624,6 +17626,11 @@ function fromPool(kctx, size) {
|
|
|
17624
17626
|
unpool(kctx, texture);
|
|
17625
17627
|
return texture;
|
|
17626
17628
|
}
|
|
17629
|
+
const other = pool.pop();
|
|
17630
|
+
if (other === void 0) return void 0;
|
|
17631
|
+
unpool(kctx, other);
|
|
17632
|
+
other.resize(size.width, size.height, size.resolution);
|
|
17633
|
+
return other;
|
|
17627
17634
|
}
|
|
17628
17635
|
/**
|
|
17629
17636
|
* Puts a texture of a record whose view left into the pool (F119), for the next take of its size: a scene that leaves
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Bn as Hint, Dr as ClockSource, En as AnyFlow, Fr as Json, In as Descriptor, Mn as NodeTable, Vn as NodeFx, kr as FakeClock, wn as FeaturePlugin } from "./types-DfHytzox.mjs";
|
|
2
2
|
import { t as createApp } from "./index-DTHVVLFB.mjs";
|
|
3
|
-
import { b as
|
|
3
|
+
import { b as memory, x as saveOf, y as WithGameState } from "./types-DhECCgeT.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-B8JIqsZk.mjs";
|
|
5
5
|
import { AnyPluginInstance } from "@moku-labs/core";
|
|
6
6
|
|
package/dist/testing.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as flattenFeatures, on as type, rn as exit, t as createApp, tn as refuseStart } from "./src-
|
|
1
|
+
import { m as flattenFeatures, on as type, rn as exit, t as createApp, tn as refuseStart } from "./src-D1J2QlGK.mjs";
|
|
2
2
|
import { n as saveOf, t as memory } from "./memory-CWlqhS7l.mjs";
|
|
3
3
|
import { n as fakeClock } from "./fake-hnJcJeYf.mjs";
|
|
4
4
|
import { i as stepFrames, r as runRepro, t as createHeadless } from "./headless-CCiUwvlp.mjs";
|
|
@@ -72,6 +72,19 @@ type SystemName = "lifecycle" | "back" | "haptics" | "keepAwake" | "store";
|
|
|
72
72
|
* ```
|
|
73
73
|
*/
|
|
74
74
|
type SaveKind = "memory" | "local" | "store";
|
|
75
|
+
/**
|
|
76
|
+
* One `Info.plist` value of `native.ios.infoPlist`: a string, a boolean, an array or a dictionary,
|
|
77
|
+
* nested as deep as the key needs. A number, `null` or `undefined` is refused when the config is read.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* // config.ts of a game that talks to the Mac on the local network.
|
|
82
|
+
* const transport: PlistValue = { NSAllowsLocalNetworking: true }; // <dict><key>NSAllowsLocalNetworking</key><true/></dict>
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
type PlistValue = string | boolean | readonly PlistValue[] | {
|
|
86
|
+
readonly [key: string]: PlistValue;
|
|
87
|
+
};
|
|
75
88
|
/**
|
|
76
89
|
* What `config.ts` of a game holds: plain data, no call. The page, the native build and the shell
|
|
77
90
|
* read it; the game logic never does.
|
|
@@ -82,7 +95,16 @@ type SaveKind = "memory" | "local" | "store";
|
|
|
82
95
|
* import type { GameConfig } from "@moku-labs/game/app";
|
|
83
96
|
* export default {
|
|
84
97
|
* page: { title: "Лесной городок", lang: "ru", background: "#10161d", orientation: "portrait", icons: { favicon: "assets/icon.png" }, boot: { image: "assets/boot.png" } },
|
|
85
|
-
* native: {
|
|
98
|
+
* native: {
|
|
99
|
+
* name: "Лесной городок",
|
|
100
|
+
* identifier: "com.mokulabs.timber",
|
|
101
|
+
* icon: "assets/icon.png",
|
|
102
|
+
* signing: {
|
|
103
|
+
* android: { keystorePath: "~/keys/upload.jks", keystorePasswordEnv: "TIMBER_KEYSTORE_PASSWORD", keyAlias: "upload" },
|
|
104
|
+
* apple: { teamId: "ABCDE12345" }
|
|
105
|
+
* },
|
|
106
|
+
* ios: { infoPlist: { ITSAppUsesNonExemptEncryption: false }, privacyManifest: "ios/PrivacyInfo.xcprivacy" }
|
|
107
|
+
* },
|
|
86
108
|
* system: ["lifecycle", "back", "haptics", "keepAwake"],
|
|
87
109
|
* save: "memory",
|
|
88
110
|
* assets: { layers: { shared: "ui" } }
|
|
@@ -125,7 +147,23 @@ type GameConfig = {
|
|
|
125
147
|
/** The app name under the icon. */name: string; /** The bundle identifier, reverse DNS. */
|
|
126
148
|
identifier: string; /** A 1024 px PNG, relative to the game folder. A placeholder by default. */
|
|
127
149
|
icon?: string; /** The native targets a build makes. The target of the command by default. */
|
|
128
|
-
targets?: readonly ("ios" | "android" | "macos")[];
|
|
150
|
+
targets?: readonly ("ios" | "android" | "macos")[]; /** How a store build signs. Names and identifiers only, never a secret. None by default. */
|
|
151
|
+
signing?: {
|
|
152
|
+
/** The upload key of a release build on Android. `--store` refuses Android without it. */android?: {
|
|
153
|
+
/** The keystore file: absolute, `~/...`, or relative to the game folder. */keystorePath: string; /** The name of the env var with the keystore password, never the password. */
|
|
154
|
+
keystorePasswordEnv: string; /** The name of the env var with the key password. The keystore's one by default. */
|
|
155
|
+
keyPasswordEnv?: string; /** The alias of the key in the keystore. */
|
|
156
|
+
keyAlias: string;
|
|
157
|
+
}; /** The Apple team. Keys stay in the env, Tauri reads them. `--store` refuses iOS without it. */
|
|
158
|
+
apple?: {
|
|
159
|
+
/** The Apple Developer team id. */teamId: string;
|
|
160
|
+
};
|
|
161
|
+
}; /** What an iOS app adds to its bundle. None by default. */
|
|
162
|
+
ios?: {
|
|
163
|
+
/** The lowest iOS the app runs on, `x.y` or `x.y.z`. Default `"26.0"`. */minimumVersion?: string; /** Keys merged into `Info.plist`. `page.orientation` wins a key it shares. */
|
|
164
|
+
infoPlist?: Readonly<Record<string, PlistValue>>; /** The privacy manifest, relative to the game folder. The bundle holds it as `PrivacyInfo.xcprivacy`. */
|
|
165
|
+
privacyManifest?: string;
|
|
166
|
+
};
|
|
129
167
|
}; /** The system plugins the shell wires. Default `[]`, a web page with no shell. */
|
|
130
168
|
system?: readonly SystemName[]; /** Where the save lives. Default `"memory"`. */
|
|
131
169
|
save?: SaveKind; /** The asset build. Default: no layers. */
|
|
@@ -742,4 +780,4 @@ type SystemShell = {
|
|
|
742
780
|
stop(): Promise<void>;
|
|
743
781
|
};
|
|
744
782
|
//#endregion
|
|
745
|
-
export {
|
|
783
|
+
export { SystemName as _, GameHandle as a, memory as b, MemoryProvider as c, PlistValue as d, SaveKind as f, SystemModules as g, StartedPage as h, GameDefinition as i, PageAgent as l, ScreenSeams as m, GameApp as n, GamePluginConfigs as o, Scenario as p, GameConfig as r, HeadlessSeams as s, AnyGameApp as t, PageOptions as u, SystemShellFactory as v, saveOf as x, WithGameState as y };
|
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? }` (absent: no native build), `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? }` (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.`
|
|
306
306
|
|
|
307
307
|
```ts
|
|
308
308
|
// config.ts of a game in a native shell
|
|
@@ -342,7 +342,8 @@ Commands of the bin `moku-game` (bun). Every command takes `--root <dir>` (defau
|
|
|
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
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.
|
|
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.
|
|
346
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`.
|
|
347
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.
|
|
348
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"] })`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moku-labs/game",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.85",
|
|
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.12",
|
|
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.12",
|
|
166
166
|
"@moku-labs/system": "0.3.7",
|
|
167
167
|
"@types/bun": "1.4.2",
|
|
168
168
|
"@vitest/coverage-istanbul": "4.0.18",
|