@moku-labs/game 0.15.92 → 0.15.93
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 +1 -0
- 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 +1 -1
- package/dist/cli.mjs +317 -45
- package/dist/{config-BYx_7HL1.mjs → config-DVqciSkP.mjs} +23 -1
- package/dist/testing.d.mts +1 -1
- package/dist/{types-B2Dh7oWu.d.mts → types-CNNxfAsF.d.mts} +25 -2
- package/llms.txt +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -167,6 +167,7 @@ The engine bin `moku-game` serves, builds and packs a game folder. A game writes
|
|
|
167
167
|
| `moku-game native build <target> [--simulator] [--debug[=full] [--editor host:port]]` | Builds the native app: `ios`, `macos`, `android`; `--debug` builds an Android or iOS debug app beside the store app |
|
|
168
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 |
|
|
169
169
|
| `moku-game native build <target> --store --dev --build-number <n>` | The test app of `native.dev`: store-signed, under its own `.dev` id, with the overlay and no editor link, in `dist-native-dev` |
|
|
170
|
+
| `moku-game native build ios --store [--dev] --build-number <n> --upload` | The iOS store build, then the upload of its `.ipa` to App Store Connect with the App Store Connect key of `native.signing.apple`, or of `APPLE_API_KEY`, `APPLE_API_ISSUER`, `APPLE_API_KEY_PATH`; TestFlight shows it after Apple processes it |
|
|
170
171
|
| `moku-game native dev <target>` | Runs the native shell on the dev server |
|
|
171
172
|
| `moku-game native doctor`, `native clean` | Checks or removes the native project; `clean` also the test and iOS debug projects |
|
|
172
173
|
| `moku-game keys [--check]` | Writes `generated/assets.ts`, the strings and `generated/manifest.json` |
|
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-kL64Svgl.mjs";
|
|
6
|
-
import { n as resolveConfig } from "../config-
|
|
6
|
+
import { n as resolveConfig } from "../config-DVqciSkP.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 { Kr as PlayerStateProvider } from "../types-D1lRinVJ.mjs";
|
|
2
2
|
import { ht as PlatformProvider } from "../index-vPc22SoP.mjs";
|
|
3
|
-
import { _ as SystemName, g as SystemModules, v as SystemShellFactory } from "../types-
|
|
3
|
+
import { _ as SystemName, g as SystemModules, v as SystemShellFactory } from "../types-CNNxfAsF.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 { Vr as Json } from "./types-D1lRinVJ.mjs";
|
|
2
2
|
import { q as StringTable } from "./types-BMUuyOcm.mjs";
|
|
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-
|
|
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-CNNxfAsF.mjs";
|
|
4
4
|
import { AnyPluginInstance } from "@moku-labs/core";
|
|
5
5
|
|
|
6
6
|
//#region src/app/define.d.ts
|
package/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as resolveConfig } from "./config-
|
|
1
|
+
import { n as resolveConfig } from "./config-DVqciSkP.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";
|
|
@@ -2156,6 +2156,8 @@ const DEBUG_PROJECT = ".moku/tauri-debug";
|
|
|
2156
2156
|
const STORE_OUT = "dist-native";
|
|
2157
2157
|
/** Where the test apps land: native delivers one to `<outDir>/<target>`, as it does a store app. */
|
|
2158
2158
|
const DEV_OUT = "dist-native-dev";
|
|
2159
|
+
/** The line of an `--upload` that finds no App Store Connect key, in `config.ts` or the env. */
|
|
2160
|
+
const NO_UPLOAD_KEY = "--upload needs an App Store Connect key. Add apiKeyId, apiIssuer and apiKeyPath to native.signing.apple, or set APPLE_API_KEY, APPLE_API_ISSUER and APPLE_API_KEY_PATH.";
|
|
2159
2161
|
/**
|
|
2160
2162
|
* The native section of a resolved config.
|
|
2161
2163
|
*
|
|
@@ -2168,8 +2170,8 @@ function nativeSectionOf(settings) {
|
|
|
2168
2170
|
return settings.native;
|
|
2169
2171
|
}
|
|
2170
2172
|
/**
|
|
2171
|
-
* Makes a keystore path absolute, since Gradle reads a relative one under
|
|
2172
|
-
* starts at the home folder, anything else at the game folder.
|
|
2173
|
+
* Makes a keystore or `.p8` path absolute, since Gradle reads a relative one under
|
|
2174
|
+
* `gen/android/app`: `~/` starts at the home folder, anything else at the game folder.
|
|
2173
2175
|
*
|
|
2174
2176
|
* @param keystore - The path `config.ts` gives.
|
|
2175
2177
|
* @param cwd - The game folder.
|
|
@@ -2184,6 +2186,122 @@ function resolveKeystore(keystore, cwd, home) {
|
|
|
2184
2186
|
return keystore.startsWith("~/") ? path.join(home, keystore.slice(2)) : path.resolve(cwd, keystore);
|
|
2185
2187
|
}
|
|
2186
2188
|
/**
|
|
2189
|
+
* The App Store Connect key of `config.ts`, its `.p8` path made absolute as a keystore's is.
|
|
2190
|
+
*
|
|
2191
|
+
* @param native - `native` of the resolved config.
|
|
2192
|
+
* @param where - The game folder and the home folder.
|
|
2193
|
+
* @returns The key, or `undefined` when `native.signing.apple` names none.
|
|
2194
|
+
* @example
|
|
2195
|
+
* ```ts
|
|
2196
|
+
* appleKeyOf({ name: "T", identifier: "com.acme.t", signing: { apple: { teamId: "ABCDE12345", apiKeyId: "ABC123DEF4", apiIssuer: "i-1", apiKeyPath: "keys/k.p8" } } }, { cwd: "/g", home: "/home/a" }); // { keyId: "ABC123DEF4", issuer: "i-1", keyPath: "/g/keys/k.p8" }
|
|
2197
|
+
* ```
|
|
2198
|
+
*/
|
|
2199
|
+
function appleKeyOf(native, where) {
|
|
2200
|
+
const { apiKeyId, apiIssuer, apiKeyPath } = native?.signing?.apple ?? {};
|
|
2201
|
+
if (!(apiKeyId !== void 0 && apiIssuer !== void 0 && apiKeyPath !== void 0)) return void 0;
|
|
2202
|
+
return {
|
|
2203
|
+
keyId: apiKeyId,
|
|
2204
|
+
issuer: apiIssuer,
|
|
2205
|
+
keyPath: resolveKeystore(apiKeyPath, where.cwd, where.home)
|
|
2206
|
+
};
|
|
2207
|
+
}
|
|
2208
|
+
/**
|
|
2209
|
+
* The App Store Connect key of the env: the three variables Tauri reads, each set and not empty.
|
|
2210
|
+
*
|
|
2211
|
+
* @param env - The environment.
|
|
2212
|
+
* @returns The key, its path as the env gives it, or `undefined` without all three.
|
|
2213
|
+
* @example
|
|
2214
|
+
* ```ts
|
|
2215
|
+
* envAppleKeyOf({ APPLE_API_KEY: "ABC123DEF4", APPLE_API_ISSUER: "i-1" }); // undefined
|
|
2216
|
+
* ```
|
|
2217
|
+
*/
|
|
2218
|
+
function envAppleKeyOf(env) {
|
|
2219
|
+
const keyId = env.APPLE_API_KEY ?? "";
|
|
2220
|
+
const issuer = env.APPLE_API_ISSUER ?? "";
|
|
2221
|
+
const keyPath = env.APPLE_API_KEY_PATH ?? "";
|
|
2222
|
+
return keyId === "" || issuer === "" || keyPath === "" ? void 0 : {
|
|
2223
|
+
keyId,
|
|
2224
|
+
issuer,
|
|
2225
|
+
keyPath
|
|
2226
|
+
};
|
|
2227
|
+
}
|
|
2228
|
+
/**
|
|
2229
|
+
* The App Store Connect key an upload sends: the one of `config.ts`, else the three env vars.
|
|
2230
|
+
*
|
|
2231
|
+
* @param native - `native` of the resolved config.
|
|
2232
|
+
* @param where - The game folder and the home folder.
|
|
2233
|
+
* @param env - The environment.
|
|
2234
|
+
* @returns The key, or `undefined` when there is none.
|
|
2235
|
+
* @example
|
|
2236
|
+
* ```ts
|
|
2237
|
+
* uploadKeyOf({ name: "T", identifier: "com.acme.t" }, { cwd: "/g", home: "/home/a" }, { APPLE_API_KEY: "ABC123DEF4", APPLE_API_ISSUER: "i-1", APPLE_API_KEY_PATH: "/k/AuthKey.p8" }); // { keyId: "ABC123DEF4", issuer: "i-1", keyPath: "/k/AuthKey.p8" }
|
|
2238
|
+
* ```
|
|
2239
|
+
*/
|
|
2240
|
+
function uploadKeyOf(native, where, env) {
|
|
2241
|
+
return appleKeyOf(native, where) ?? envAppleKeyOf(env);
|
|
2242
|
+
}
|
|
2243
|
+
/**
|
|
2244
|
+
* The env vars of an App Store Connect key, by the names Tauri reads.
|
|
2245
|
+
*
|
|
2246
|
+
* @param key - The key.
|
|
2247
|
+
* @returns The three variables.
|
|
2248
|
+
* @example
|
|
2249
|
+
* ```ts
|
|
2250
|
+
* appleKeyVariablesOf({ keyId: "ABC123DEF4", issuer: "i-1", keyPath: "/k.p8" }).APPLE_API_KEY_PATH; // "/k.p8"
|
|
2251
|
+
* ```
|
|
2252
|
+
*/
|
|
2253
|
+
function appleKeyVariablesOf(key) {
|
|
2254
|
+
return {
|
|
2255
|
+
APPLE_API_KEY: key.keyId,
|
|
2256
|
+
APPLE_API_ISSUER: key.issuer,
|
|
2257
|
+
APPLE_API_KEY_PATH: key.keyPath
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
/**
|
|
2261
|
+
* The command that uploads an `.ipa` to App Store Connect with a team key: `xcrun altool`, the
|
|
2262
|
+
* path as one word, spaces and all.
|
|
2263
|
+
*
|
|
2264
|
+
* @param ipa - The `.ipa` file, absolute.
|
|
2265
|
+
* @param key - The App Store Connect key.
|
|
2266
|
+
* @returns The argv.
|
|
2267
|
+
* @example
|
|
2268
|
+
* ```ts
|
|
2269
|
+
* uploadArgvOf("/g/dist-native/ios/T.ipa", { keyId: "ABC123DEF4", issuer: "i-1", keyPath: "/k.p8" }); // ["xcrun", "altool", "--upload-app", "-f", "/g/dist-native/ios/T.ipa", "-t", "ios", "--api-key", "ABC123DEF4", "--api-issuer", "i-1", "--p8-file-path", "/k.p8"]
|
|
2270
|
+
* ```
|
|
2271
|
+
*/
|
|
2272
|
+
function uploadArgvOf(ipa, key) {
|
|
2273
|
+
return [
|
|
2274
|
+
"xcrun",
|
|
2275
|
+
"altool",
|
|
2276
|
+
"--upload-app",
|
|
2277
|
+
"-f",
|
|
2278
|
+
ipa,
|
|
2279
|
+
"-t",
|
|
2280
|
+
"ios",
|
|
2281
|
+
"--api-key",
|
|
2282
|
+
key.keyId,
|
|
2283
|
+
"--api-issuer",
|
|
2284
|
+
key.issuer,
|
|
2285
|
+
"--p8-file-path",
|
|
2286
|
+
key.keyPath
|
|
2287
|
+
];
|
|
2288
|
+
}
|
|
2289
|
+
/**
|
|
2290
|
+
* The folder native leaves the `.ipa` of an iOS store build in: under `dist-native`, or under
|
|
2291
|
+
* `dist-native-dev` for the test app.
|
|
2292
|
+
*
|
|
2293
|
+
* @param cwd - The game folder.
|
|
2294
|
+
* @param store - The store block, for its `dev` mark.
|
|
2295
|
+
* @returns The folder, absolute.
|
|
2296
|
+
* @example
|
|
2297
|
+
* ```ts
|
|
2298
|
+
* uploadFolderOf("/g", { dev: true }); // "/g/dist-native-dev/ios"
|
|
2299
|
+
* ```
|
|
2300
|
+
*/
|
|
2301
|
+
function uploadFolderOf(cwd, store) {
|
|
2302
|
+
return path.join(cwd, store.dev === true ? DEV_OUT : STORE_OUT, "ios");
|
|
2303
|
+
}
|
|
2304
|
+
/**
|
|
2187
2305
|
* The password variables of an Android signing block that are unset or empty, by name only. The
|
|
2188
2306
|
* key password falls back to the keystore's.
|
|
2189
2307
|
*
|
|
@@ -2214,14 +2332,32 @@ function androidProblems(native, input) {
|
|
|
2214
2332
|
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.`)];
|
|
2215
2333
|
}
|
|
2216
2334
|
/**
|
|
2217
|
-
* The
|
|
2218
|
-
*
|
|
2335
|
+
* The problems of the App Store Connect key of an iOS store build: a `.p8` of `config.ts` that is
|
|
2336
|
+
* not a file, and for `--upload` no key at all or an env key whose file is not there. A line names
|
|
2337
|
+
* the resolved path of `config.ts` or the variable, never the value of a variable.
|
|
2219
2338
|
*
|
|
2220
2339
|
* @param native - The native section.
|
|
2221
|
-
* @
|
|
2340
|
+
* @param input - The store build.
|
|
2341
|
+
* @returns One line, or none for a key that can go.
|
|
2342
|
+
*/
|
|
2343
|
+
function appleKeyProblems(native, input) {
|
|
2344
|
+
const key = appleKeyOf(native, input);
|
|
2345
|
+
if (key !== void 0) return input.store.exists(key.keyPath) ? [] : [`The App Store Connect key ${key.keyPath} is not a file. Fix native.signing.apple.apiKeyPath.`];
|
|
2346
|
+
if (input.store.upload !== true) return [];
|
|
2347
|
+
const envKey = envAppleKeyOf(input.store.env);
|
|
2348
|
+
if (envKey === void 0) return [NO_UPLOAD_KEY];
|
|
2349
|
+
return input.store.exists(envKey.keyPath) ? [] : ["The file of APPLE_API_KEY_PATH is not a file."];
|
|
2350
|
+
}
|
|
2351
|
+
/**
|
|
2352
|
+
* The problems of the iOS row of a store build: the Apple signing block, and the App Store Connect
|
|
2353
|
+
* key, which `config.ts` names or the env holds for Tauri.
|
|
2354
|
+
*
|
|
2355
|
+
* @param native - The native section.
|
|
2356
|
+
* @param input - The store build.
|
|
2357
|
+
* @returns One line per problem.
|
|
2222
2358
|
*/
|
|
2223
|
-
function appleProblems(native) {
|
|
2224
|
-
return native.signing?.apple === void 0 ? ["No native.signing.apple in config.ts. Add teamId."] : [];
|
|
2359
|
+
function appleProblems(native, input) {
|
|
2360
|
+
return [...native.signing?.apple === void 0 ? ["No native.signing.apple in config.ts. Add teamId."] : [], ...appleKeyProblems(native, input)];
|
|
2225
2361
|
}
|
|
2226
2362
|
/**
|
|
2227
2363
|
* The problem of a `package.json` version a store build cannot ship.
|
|
@@ -2300,7 +2436,7 @@ function identifierProblems(identifier) {
|
|
|
2300
2436
|
function storeProblems(input) {
|
|
2301
2437
|
const native = nativeSectionOf(input.settings);
|
|
2302
2438
|
return [
|
|
2303
|
-
...input.target === "android" ? androidProblems(native, input) : appleProblems(native),
|
|
2439
|
+
...input.target === "android" ? androidProblems(native, input) : appleProblems(native, input),
|
|
2304
2440
|
...versionProblems(input.version),
|
|
2305
2441
|
...input.store.dev === true ? devIdentifierProblems(native.dev) : identifierProblems(native.identifier)
|
|
2306
2442
|
];
|
|
@@ -2615,9 +2751,70 @@ async function runApp(native, config, verb, target, options) {
|
|
|
2615
2751
|
}
|
|
2616
2752
|
}
|
|
2617
2753
|
/**
|
|
2754
|
+
* Runs one verb over the native config, and for `clean` once more per test project, one after the
|
|
2755
|
+
* other.
|
|
2756
|
+
*
|
|
2757
|
+
* @param native - The `@moku-labs/native` module.
|
|
2758
|
+
* @param config - The native config.
|
|
2759
|
+
* @param verb - The native verb.
|
|
2760
|
+
* @param target - The checked target.
|
|
2761
|
+
* @param options - The verb options.
|
|
2762
|
+
* @returns True when the verb succeeded on every folder.
|
|
2763
|
+
*/
|
|
2764
|
+
async function runApps(native, config, verb, target, options) {
|
|
2765
|
+
let passed = await runApp(native, config, verb, target, options);
|
|
2766
|
+
for (const project of options.testProjects ?? []) {
|
|
2767
|
+
const cleaned = await runApp(native, {
|
|
2768
|
+
...config,
|
|
2769
|
+
projectDir: project
|
|
2770
|
+
}, verb, target, options);
|
|
2771
|
+
passed &&= cleaned;
|
|
2772
|
+
}
|
|
2773
|
+
return passed;
|
|
2774
|
+
}
|
|
2775
|
+
/**
|
|
2776
|
+
* The env an iOS `build` or `dev` signs with when `config.ts` names the App Store Connect key.
|
|
2777
|
+
*
|
|
2778
|
+
* @param native - The native section.
|
|
2779
|
+
* @param where - The game folder and the home folder.
|
|
2780
|
+
* @param verb - The native verb.
|
|
2781
|
+
* @param target - The checked target.
|
|
2782
|
+
* @returns The three variables, or `undefined` for another verb or target, or without the key.
|
|
2783
|
+
*/
|
|
2784
|
+
function keyVariablesOf(native, where, verb, target) {
|
|
2785
|
+
if (!(target === "ios" && (verb === "build" || verb === "dev"))) return void 0;
|
|
2786
|
+
const key = appleKeyOf(native, where);
|
|
2787
|
+
return key === void 0 ? void 0 : appleKeyVariablesOf(key);
|
|
2788
|
+
}
|
|
2789
|
+
/**
|
|
2790
|
+
* Runs with the given variables in the env of this process, which native's Tauri spawn passes on,
|
|
2791
|
+
* and puts back every earlier value, or its absence, when the run ends, also when it throws.
|
|
2792
|
+
*
|
|
2793
|
+
* @param values - The variables, or `undefined` to leave the env untouched.
|
|
2794
|
+
* @param run - The run.
|
|
2795
|
+
* @returns What the run answers.
|
|
2796
|
+
*/
|
|
2797
|
+
async function withProcessVariables(values, run) {
|
|
2798
|
+
if (values === void 0) return run();
|
|
2799
|
+
const before = Object.keys(values).map((name) => [name, process.env[name]]);
|
|
2800
|
+
Object.assign(process.env, values);
|
|
2801
|
+
try {
|
|
2802
|
+
return await run();
|
|
2803
|
+
} finally {
|
|
2804
|
+
for (const [name, value] of before) {
|
|
2805
|
+
if (value === void 0) {
|
|
2806
|
+
Reflect.deleteProperty(process.env, name);
|
|
2807
|
+
continue;
|
|
2808
|
+
}
|
|
2809
|
+
process.env[name] = value;
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
/**
|
|
2618
2814
|
* Runs one native verb through `@moku-labs/native` over the game's config: once, or for `clean`
|
|
2619
|
-
* once per project folder, one after the other.
|
|
2620
|
-
*
|
|
2815
|
+
* once per project folder, one after the other. An iOS `build` or `dev` with the App Store Connect
|
|
2816
|
+
* key in `config.ts` runs with the key in the env Tauri reads, the earlier env put back after.
|
|
2817
|
+
* Native's cli prints the progress and the failure itself.
|
|
2621
2818
|
*
|
|
2622
2819
|
* @param verb - The native verb: build, dev, doctor or clean.
|
|
2623
2820
|
* @param settings - The resolved `config.ts` of the game.
|
|
@@ -2629,22 +2826,14 @@ async function runApp(native, config, verb, target, options) {
|
|
|
2629
2826
|
* anything loads, `@moku-labs/native` is not installed, or the target is unknown or missing.
|
|
2630
2827
|
*/
|
|
2631
2828
|
async function runNative(verb, settings, where, options) {
|
|
2632
|
-
nativeSectionOf(settings);
|
|
2829
|
+
const section = nativeSectionOf(settings);
|
|
2633
2830
|
refuseStoreProblems(settings, where, options);
|
|
2634
2831
|
const native = await import("@moku-labs/native").catch((error) => {
|
|
2635
2832
|
throw new Error("[game] moku-game native needs @moku-labs/native.\n Install it: bun add -d @moku-labs/native@^0.3.13.", { cause: error });
|
|
2636
2833
|
});
|
|
2637
2834
|
const target = targetOf(native.TARGETS, verb, options.target);
|
|
2638
2835
|
const config = nativeConfigOf(settings, where, target, extrasOf(options));
|
|
2639
|
-
|
|
2640
|
-
for (const project of options.testProjects ?? []) {
|
|
2641
|
-
const cleaned = await runApp(native, {
|
|
2642
|
-
...config,
|
|
2643
|
-
projectDir: project
|
|
2644
|
-
}, verb, target, options);
|
|
2645
|
-
passed &&= cleaned;
|
|
2646
|
-
}
|
|
2647
|
-
return passed;
|
|
2836
|
+
return withProcessVariables(keyVariablesOf(section, where, verb, target), () => runApps(native, config, verb, target, options));
|
|
2648
2837
|
}
|
|
2649
2838
|
//#endregion
|
|
2650
2839
|
//#region src/app/visual.ts
|
|
@@ -2827,8 +3016,8 @@ async function runVisual(command, deps) {
|
|
|
2827
3016
|
* `parseArgs`, then one of `dev`, `build`, `native <verb>`, `keys`, `pack`, `visual` or `help`.
|
|
2828
3017
|
* Every seam of the process (the console, the environment, spawning, signals, the watcher, the
|
|
2829
3018
|
* keys watch, the asset scanner, native, Bun's resolver, the visual test runner, the home folder,
|
|
2830
|
-
* the file check, the game's version) comes in as `deps`, so a test runs a
|
|
2831
|
-
* returns the exit code and never exits itself. A plain function, on no API.
|
|
3019
|
+
* the file check, the folder listing, the game's version) comes in as `deps`, so a test runs a
|
|
3020
|
+
* command with stubs. It returns the exit code and never exits itself. A plain function, on no API.
|
|
2832
3021
|
*/
|
|
2833
3022
|
/** The flags every command takes. */
|
|
2834
3023
|
const GLOBAL_OPTIONS = [
|
|
@@ -2874,7 +3063,8 @@ const ALL_OPTIONS = {
|
|
|
2874
3063
|
editor: { type: "string" },
|
|
2875
3064
|
store: { type: "boolean" },
|
|
2876
3065
|
dev: { type: "boolean" },
|
|
2877
|
-
"build-number": { type: "string" }
|
|
3066
|
+
"build-number": { type: "string" },
|
|
3067
|
+
upload: { type: "boolean" }
|
|
2878
3068
|
};
|
|
2879
3069
|
/** The flags of `visual` that `parseVisualArgv` reads, in the runner's words. */
|
|
2880
3070
|
const VISUAL_FLAGS = /^(?:update|only|no-pixels|pixels|dir|webgl|no-verify-frames)$/;
|
|
@@ -2892,7 +3082,8 @@ const COMMAND_OPTIONS = {
|
|
|
2892
3082
|
"editor",
|
|
2893
3083
|
"store",
|
|
2894
3084
|
"dev",
|
|
2895
|
-
"build-number"
|
|
3085
|
+
"build-number",
|
|
3086
|
+
"upload"
|
|
2896
3087
|
],
|
|
2897
3088
|
keys: ["check"],
|
|
2898
3089
|
pack: ["no-cache"],
|
|
@@ -2940,6 +3131,7 @@ const USAGE = [
|
|
|
2940
3131
|
" native build <target> [--simulator] [--debug [--editor host:port]] build the native app (ios, macos, android)",
|
|
2941
3132
|
" native build <target> --store --build-number <n> a store build: an .aab on android, an .ipa on ios",
|
|
2942
3133
|
" native build <target> --store --dev --build-number <n> a store-signed test app from native.dev",
|
|
3134
|
+
" native build ios --store --build-number <n> --upload a store build, then the upload to App Store Connect",
|
|
2943
3135
|
" native dev <target> run the native shell on the dev server",
|
|
2944
3136
|
" native doctor | native clean check or remove the native project",
|
|
2945
3137
|
" keys [--check] write generated/assets.ts and generated/manifest.json",
|
|
@@ -3178,8 +3370,10 @@ function nativeVerbOf(word) {
|
|
|
3178
3370
|
*
|
|
3179
3371
|
* @param parsed - The command line.
|
|
3180
3372
|
* @param deps - The process seams.
|
|
3181
|
-
* @returns `0` when the verb succeeded, `1` when native reported a
|
|
3182
|
-
*
|
|
3373
|
+
* @returns `0` when the verb, and an `--upload` after it, succeeded, `1` when native reported a
|
|
3374
|
+
* failure.
|
|
3375
|
+
* @throws {Error} When the verb is missing or unknown, native refuses the config or target, or the
|
|
3376
|
+
* upload fails.
|
|
3183
3377
|
*/
|
|
3184
3378
|
async function runNativeVerb(parsed, deps) {
|
|
3185
3379
|
const [word, target] = parsed.rest;
|
|
@@ -3208,7 +3402,54 @@ async function runNativeVerb(parsed, deps) {
|
|
|
3208
3402
|
options.store = storeBlockOf(store, settings, deps);
|
|
3209
3403
|
warnIosStore(settings, target, deps.ui);
|
|
3210
3404
|
} else if (isPlainAndroidBuild) leaveKeyOut(settings, options, deps);
|
|
3211
|
-
|
|
3405
|
+
if (!await deps.native(verb, settings, where, options)) return 1;
|
|
3406
|
+
return options.store?.upload === true ? uploadIpa(settings, where, options.store, deps) : 0;
|
|
3407
|
+
}
|
|
3408
|
+
/**
|
|
3409
|
+
* Picks the newest `.ipa` of a folder by the time it was written.
|
|
3410
|
+
*
|
|
3411
|
+
* @param folder - The folder native leaves the `.ipa` in.
|
|
3412
|
+
* @param deps - The seams of the process.
|
|
3413
|
+
* @returns The file, absolute, or `undefined` when the folder has none.
|
|
3414
|
+
*/
|
|
3415
|
+
function newestIpaOf(folder, deps) {
|
|
3416
|
+
let newest;
|
|
3417
|
+
for (const file of deps.listFiles(folder)) {
|
|
3418
|
+
const isNewer = newest === void 0 || file.mtimeMs > newest.mtimeMs;
|
|
3419
|
+
if (file.name.endsWith(".ipa") && isNewer) newest = file;
|
|
3420
|
+
}
|
|
3421
|
+
return newest === void 0 ? void 0 : path.join(folder, newest.name);
|
|
3422
|
+
}
|
|
3423
|
+
/**
|
|
3424
|
+
* Uploads the newest `.ipa` of a green iOS store build to App Store Connect with `xcrun altool`
|
|
3425
|
+
* and the team key, the one of `config.ts` or the env's. The lines name the `.ipa`, never an id
|
|
3426
|
+
* or the key path.
|
|
3427
|
+
*
|
|
3428
|
+
* @param settings - The resolved `config.ts` of the game.
|
|
3429
|
+
* @param where - The game folder and the home folder.
|
|
3430
|
+
* @param store - The store block of the build.
|
|
3431
|
+
* @param deps - The seams of the process.
|
|
3432
|
+
* @returns `0` once altool uploaded.
|
|
3433
|
+
* @throws {Error} When there is no key or no `.ipa`, or altool exits with another code than 0.
|
|
3434
|
+
*/
|
|
3435
|
+
async function uploadIpa(settings, where, store, deps) {
|
|
3436
|
+
const key = uploadKeyOf(settings.native, where, deps.env);
|
|
3437
|
+
if (key === void 0) throw new Error("[game] native: --upload needs an App Store Connect key.");
|
|
3438
|
+
const folder = uploadFolderOf(where.cwd, store);
|
|
3439
|
+
const ipa = newestIpaOf(folder, deps);
|
|
3440
|
+
if (ipa === void 0) throw new Error(`[game] native: no .ipa in ${folder} to upload.`);
|
|
3441
|
+
deps.ui.info(`native: uploading ${ipa} to App Store Connect.`);
|
|
3442
|
+
const code = await deps.spawn(uploadArgvOf(ipa, key), {
|
|
3443
|
+
env: deps.env,
|
|
3444
|
+
stdio: [
|
|
3445
|
+
"inherit",
|
|
3446
|
+
"inherit",
|
|
3447
|
+
"inherit"
|
|
3448
|
+
]
|
|
3449
|
+
}).exited;
|
|
3450
|
+
if (code !== 0) throw new Error(`[game] native: the upload failed (altool exit ${code}).`);
|
|
3451
|
+
deps.ui.info("native: uploaded. TestFlight shows the build after Apple processes it.");
|
|
3452
|
+
return 0;
|
|
3212
3453
|
}
|
|
3213
3454
|
/**
|
|
3214
3455
|
* The store block of a verb: the number, the test app's mark, and the seams of the store checks.
|
|
@@ -3224,6 +3465,7 @@ function storeBlockOf(store, settings, deps) {
|
|
|
3224
3465
|
return {
|
|
3225
3466
|
buildNumber: store.buildNumber,
|
|
3226
3467
|
...store.dev === true ? { dev: true } : {},
|
|
3468
|
+
...store.upload === true ? { upload: true } : {},
|
|
3227
3469
|
env: deps.env,
|
|
3228
3470
|
exists: deps.exists
|
|
3229
3471
|
};
|
|
@@ -3316,23 +3558,37 @@ function buildNumberOf(value) {
|
|
|
3316
3558
|
throw new Error(`[game] native: --build-number takes an integer from 1 to ${MAX_BUILD_NUMBER}, got "${value}".`);
|
|
3317
3559
|
}
|
|
3318
3560
|
/**
|
|
3319
|
-
*
|
|
3320
|
-
*
|
|
3321
|
-
*
|
|
3561
|
+
* Refuses the flags that go with `--store` on a command line without it.
|
|
3562
|
+
*
|
|
3563
|
+
* @param parsed - The command line.
|
|
3564
|
+
* @throws {Error} When `--dev`, `--upload` or `--build-number` is given, naming the first of them.
|
|
3565
|
+
*/
|
|
3566
|
+
function refuseWithoutStore(parsed) {
|
|
3567
|
+
const { dev, upload, "build-number": number } = parsed.values;
|
|
3568
|
+
if (dev === true) throw new Error("[game] native: --dev goes with --store.");
|
|
3569
|
+
if (upload === true) throw new Error("[game] native: --upload goes with --store.");
|
|
3570
|
+
if (number !== void 0) throw new Error("[game] native: --build-number goes with --store.");
|
|
3571
|
+
}
|
|
3572
|
+
/**
|
|
3573
|
+
* Reads `--store`, `--build-number`, `--dev` and `--upload` of `moku-game native`, before any
|
|
3574
|
+
* config is read: they go with `native build ios` and `native build android` only, one number for
|
|
3575
|
+
* both stores, `--dev` turns the store build into the test app, and `--upload` sends an iOS one to
|
|
3576
|
+
* App Store Connect.
|
|
3322
3577
|
*
|
|
3323
3578
|
* @param parsed - The command line.
|
|
3324
3579
|
* @param verb - The native verb.
|
|
3325
3580
|
* @param target - The target the command line names, unchecked.
|
|
3326
|
-
* @returns The store flag, the number and `
|
|
3581
|
+
* @returns The store flag, the number, `dev` and `upload`, or nothing without them.
|
|
3327
3582
|
* @throws {Error} When the first two go without each other or with another verb or target, when
|
|
3328
|
-
* `--dev` goes without `--store`, when `--
|
|
3329
|
-
* the number is refused.
|
|
3583
|
+
* `--dev` or `--upload` goes without `--store`, when `--upload` goes with another target than
|
|
3584
|
+
* ios, when `--debug`, `--editor` or `--simulator` comes along, or when the number is refused.
|
|
3330
3585
|
*/
|
|
3331
3586
|
function nativeStoreOf(parsed, verb, target) {
|
|
3332
|
-
const { store, dev, "build-number": number } = parsed.values;
|
|
3333
|
-
if (store !== true
|
|
3334
|
-
|
|
3335
|
-
|
|
3587
|
+
const { store, dev, upload, "build-number": number } = parsed.values;
|
|
3588
|
+
if (store !== true) {
|
|
3589
|
+
refuseWithoutStore(parsed);
|
|
3590
|
+
return {};
|
|
3591
|
+
}
|
|
3336
3592
|
if (verb !== "build") throw new Error("[game] native: --store goes with native build only.");
|
|
3337
3593
|
const clash = [
|
|
3338
3594
|
"debug",
|
|
@@ -3343,13 +3599,12 @@ function nativeStoreOf(parsed, verb, target) {
|
|
|
3343
3599
|
if (target !== "ios" && target !== "android") throw new Error(`[game] native: --store builds ios or android, got ${target ?? "no target"}.`);
|
|
3344
3600
|
if (number === void 0) throw new Error("[game] native: --store needs --build-number, the number of this upload.");
|
|
3345
3601
|
const buildNumber = buildNumberOf(number);
|
|
3346
|
-
|
|
3602
|
+
if (upload === true && target !== "ios") throw new Error("[game] native: --upload goes with ios.");
|
|
3603
|
+
return {
|
|
3347
3604
|
store: true,
|
|
3348
3605
|
buildNumber,
|
|
3349
|
-
dev: true
|
|
3350
|
-
|
|
3351
|
-
store: true,
|
|
3352
|
-
buildNumber
|
|
3606
|
+
...dev === true ? { dev: true } : {},
|
|
3607
|
+
...upload === true ? { upload: true } : {}
|
|
3353
3608
|
};
|
|
3354
3609
|
}
|
|
3355
3610
|
/**
|
|
@@ -3831,6 +4086,22 @@ function watchFolder(folder, listener) {
|
|
|
3831
4086
|
return watcher;
|
|
3832
4087
|
}
|
|
3833
4088
|
/**
|
|
4089
|
+
* Lists the files of a folder with the time each was last written; folders in it are left out.
|
|
4090
|
+
*
|
|
4091
|
+
* @param folder - The folder.
|
|
4092
|
+
* @returns The files, none for a folder that is not there.
|
|
4093
|
+
*/
|
|
4094
|
+
function listFiles(folder) {
|
|
4095
|
+
if (!existsSync(folder)) return [];
|
|
4096
|
+
return readdirSync(folder).flatMap((name) => {
|
|
4097
|
+
const stats = statSync(path.join(folder, name));
|
|
4098
|
+
return stats.isFile() ? [{
|
|
4099
|
+
name,
|
|
4100
|
+
mtimeMs: stats.mtimeMs
|
|
4101
|
+
}] : [];
|
|
4102
|
+
});
|
|
4103
|
+
}
|
|
4104
|
+
/**
|
|
3834
4105
|
* Bun's resolver: the file a specifier gives from a folder.
|
|
3835
4106
|
*
|
|
3836
4107
|
* @param specifier - The specifier.
|
|
@@ -3874,8 +4145,8 @@ function keysSeams(ui) {
|
|
|
3874
4145
|
* The real process behind the command line: the branded console, the environment the bin
|
|
3875
4146
|
* started with, Bun's spawn and resolver, the signals, `fs.watch`, the keys watch, the asset
|
|
3876
4147
|
* scanner with the string tools, native, the visual test runner, loaded only by
|
|
3877
|
-
* `moku-game visual`, and what a native build reads: the home folder, the file check
|
|
3878
|
-
* version of the game's `package.json`.
|
|
4148
|
+
* `moku-game visual`, and what a native build reads: the home folder, the file check, the folder
|
|
4149
|
+
* listing of `--upload` and the version of the game's `package.json`.
|
|
3879
4150
|
*
|
|
3880
4151
|
* @returns The seams of this process.
|
|
3881
4152
|
*/
|
|
@@ -3906,6 +4177,7 @@ function processDeps() {
|
|
|
3906
4177
|
now: () => Date.now(),
|
|
3907
4178
|
home: homedir(),
|
|
3908
4179
|
exists: existsSync,
|
|
4180
|
+
listFiles,
|
|
3909
4181
|
readPackageVersion: packageVersionOf
|
|
3910
4182
|
};
|
|
3911
4183
|
}
|
|
@@ -9,6 +9,12 @@ const ANDROID_SIGNING_FIELDS = [
|
|
|
9
9
|
"keystorePasswordEnv",
|
|
10
10
|
"keyAlias"
|
|
11
11
|
];
|
|
12
|
+
/** The fields of the App Store Connect key, all three or none, in the order a message names them. */
|
|
13
|
+
const APPLE_KEY_FIELDS = [
|
|
14
|
+
"apiKeyId",
|
|
15
|
+
"apiIssuer",
|
|
16
|
+
"apiKeyPath"
|
|
17
|
+
];
|
|
12
18
|
/** The last part of a test app's identifier. */
|
|
13
19
|
const TEST_APP_SUFFIX = ".dev";
|
|
14
20
|
/** An iOS version as native takes it: `26.0` or `26.0.1`. */
|
|
@@ -97,16 +103,32 @@ function badPlistValue(value, at) {
|
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
105
|
/**
|
|
106
|
+
* Throws for an App Store Connect key named in part: one or two of its fields, or an empty one.
|
|
107
|
+
*
|
|
108
|
+
* @param apple - `native.signing.apple` of the config.
|
|
109
|
+
* @throws {Error} Naming the fields that are there and, in field order, the ones that are not.
|
|
110
|
+
*/
|
|
111
|
+
function checkAppleKey(apple) {
|
|
112
|
+
const written = APPLE_KEY_FIELDS.filter((field) => apple?.[field] !== void 0);
|
|
113
|
+
const named = APPLE_KEY_FIELDS.filter((field) => isFilled(apple?.[field]));
|
|
114
|
+
if (written.length === 0 || named.length === APPLE_KEY_FIELDS.length) return;
|
|
115
|
+
const missing = APPLE_KEY_FIELDS.filter((field) => !named.includes(field));
|
|
116
|
+
const has = named.length === 0 ? "" : `${named.join(", ")} but `;
|
|
117
|
+
throw new Error(`[game] config.native.signing.apple has ${has}no ${missing.join(", ")}.\n Name all three of the App Store Connect key, or none.`);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
100
120
|
* Throws for a half-filled `native.signing`.
|
|
101
121
|
*
|
|
102
122
|
* @param signing - `native.signing` of the config.
|
|
103
|
-
* @throws {Error} When `android` misses one of its required strings, or `apple` has no `teamId
|
|
123
|
+
* @throws {Error} When `android` misses one of its required strings, or `apple` has no `teamId` or
|
|
124
|
+
* a part of the App Store Connect key only.
|
|
104
125
|
*/
|
|
105
126
|
function checkSigning(signing) {
|
|
106
127
|
const android = signing?.android;
|
|
107
128
|
const missing = ANDROID_SIGNING_FIELDS.find((field) => !isFilled(android?.[field]));
|
|
108
129
|
if (android !== void 0 && missing !== void 0) throw new Error(`[game] config.native.signing.android has no ${missing}.\n Name keystorePath, keystorePasswordEnv and keyAlias.`);
|
|
109
130
|
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.");
|
|
131
|
+
checkAppleKey(signing?.apple);
|
|
110
132
|
}
|
|
111
133
|
/**
|
|
112
134
|
* Throws for a value of `native.ios` that would fail deep in a build.
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { An as FeaturePlugin, Fr as FakeClock, Hn as Descriptor, Kn as Hint, Mn as AnyFlow, Nr as ClockSource, Rn as NodeTable, Vr as Json, qn as NodeFx } from "./types-D1lRinVJ.mjs";
|
|
2
2
|
import { t as createApp } from "./index-vPc22SoP.mjs";
|
|
3
|
-
import { b as memory, x as saveOf, y as WithGameState } from "./types-
|
|
3
|
+
import { b as memory, x as saveOf, y as WithGameState } from "./types-CNNxfAsF.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-Dasz6dgy.mjs";
|
|
5
5
|
import { AnyPluginInstance } from "@moku-labs/core";
|
|
6
6
|
|
|
@@ -155,9 +155,32 @@ type GameConfig = {
|
|
|
155
155
|
keystorePasswordEnv: string; /** The name of the env var with the key password. The keystore's one by default. */
|
|
156
156
|
keyPasswordEnv?: string; /** The alias of the key in the keystore. */
|
|
157
157
|
keyAlias: string;
|
|
158
|
-
};
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* The Apple team, and the App Store Connect team key an iOS build signs with from the
|
|
161
|
+
* command line, where `xcodebuild` sees no Xcode account. The key is named by its two ids and
|
|
162
|
+
* the path of its `.p8` file, all three or none, never the key itself. Without them a build
|
|
163
|
+
* reads `APPLE_API_KEY`, `APPLE_API_ISSUER` and `APPLE_API_KEY_PATH` from the env as Tauri
|
|
164
|
+
* does. `--store` refuses iOS without the block, `--upload` without a key.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* // config.ts of A Memory Missing: `tauri ios build` signs with the team key, and
|
|
169
|
+
* // `moku-game native build ios --store --build-number 12 --upload` sends the .ipa to TestFlight.
|
|
170
|
+
* signing: {
|
|
171
|
+
* apple: { teamId: "ABCDE12345", apiKeyId: "ABC123DEF4", apiIssuer: "69a6de7e-1234-47e3-e053-5b8c7c11a4d1", apiKeyPath: "~/keys/AuthKey_ABC123DEF4.p8" }
|
|
172
|
+
* } // on a Mac with the home /Users/anya, tauri runs with APPLE_API_KEY "ABC123DEF4" and APPLE_API_KEY_PATH "/Users/anya/keys/AuthKey_ABC123DEF4.p8"
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
159
175
|
apple?: {
|
|
160
|
-
/** The Apple Developer team id. */teamId: string;
|
|
176
|
+
/** The Apple Developer team id. */teamId: string; /** The key id of the App Store Connect key, such as `"ABC123DEF4"`. With the two others. */
|
|
177
|
+
apiKeyId?: string; /** The issuer id of the team in App Store Connect, a UUID. With the two others. */
|
|
178
|
+
apiIssuer?: string;
|
|
179
|
+
/**
|
|
180
|
+
* The `.p8` file of the key: absolute, `~/...` from the home folder, or relative to the game
|
|
181
|
+
* folder. Keep it outside the repo. With the two others.
|
|
182
|
+
*/
|
|
183
|
+
apiKeyPath?: string;
|
|
161
184
|
};
|
|
162
185
|
}; /** What an iOS app adds to its bundle. None by default. */
|
|
163
186
|
ios?: {
|
package/llms.txt
CHANGED
|
@@ -303,7 +303,7 @@ app.model.store.snapshot().session; // { rolls: 2 }
|
|
|
303
303
|
await run.stop();
|
|
304
304
|
```
|
|
305
305
|
|
|
306
|
-
`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 }
|
|
306
|
+
`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, apiKeyId?, apiIssuer?, apiKeyPath? }`: an iOS build signs from the command line with an App Store Connect team key, since an Xcode account sign-in is not seen by `xcodebuild` there, which fails with "No Accounts" and no provisioning profiles; the key is `apiKeyId` (the key id), `apiIssuer` (the issuer id) and `apiKeyPath` (the `.p8` file: absolute, `~/...` or relative to the game, kept outside the repo, never the key itself), all three or none (`[game] config.native.signing.apple has apiKeyId but no apiIssuer, apiKeyPath.`); `native build` and `native dev` on iOS put them into the env Tauri reads, `APPLE_API_KEY`, `APPLE_API_ISSUER` and `APPLE_API_KEY_PATH` (absolute), and put the earlier env back after; without them the three env vars a person sets reach Tauri as before, and a config key wins over them; `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.`
|
|
307
307
|
|
|
308
308
|
```ts
|
|
309
309
|
// config.ts of a game in a native shell
|
|
@@ -344,7 +344,7 @@ Commands of the bin `moku-game` (bun). Every command takes `--root <dir>` (defau
|
|
|
344
344
|
- `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://`.
|
|
345
345
|
- `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.
|
|
346
346
|
- `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`.
|
|
347
|
-
- `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
|
+
- `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 `.p8` of `signing.apple.apiKeyPath` that is not a file is a problem line with the resolved path. `--upload` (`native build ios --store [--dev] --build-number <n> --upload`) sends the build to App Store Connect, for TestFlight: refused before `config.ts` is read without `--store` (`[game] native: --upload goes with --store.`) and on another target (`[game] native: --upload goes with ios.`); it needs a key, the one of `config.ts`, else the three env vars, and the store checks name a missing key, and for the env key a `.p8` that is not a file by the variable's name only. After a green build it runs `xcrun altool --upload-app -f <ipa> -t ios --api-key <id> --api-issuer <issuer> --p8-file-path <.p8>` on the newest `.ipa` of `dist-native/ios` (`dist-native-dev/ios` with `--dev`), printing `native: uploading <ipa> to App Store Connect.` and `native: uploaded. TestFlight shows the build after Apple processes it.`, never an id or the key path; no `.ipa` (`[game] native: no .ipa in <folder> to upload.`) or an altool exit other than 0 (`[game] native: the upload failed (altool exit <code>).`) exits 1, and a failed build uploads nothing. 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.
|
|
348
348
|
- `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`.
|
|
349
349
|
- `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.
|
|
350
350
|
- `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.93",
|
|
4
4
|
"description": "2D puzzle game engine on TypeScript and PixiJS, built on @moku-labs/core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -159,10 +159,10 @@
|
|
|
159
159
|
"@arethetypeswrong/core": "0.18.3",
|
|
160
160
|
"@biomejs/biome": "2.4.16",
|
|
161
161
|
"@formatjs/icu-messageformat-parser": "3.5.20",
|
|
162
|
-
"@moku-labs/ci": "1.5.
|
|
163
|
-
"@moku-labs/common": "0.3.
|
|
162
|
+
"@moku-labs/ci": "1.5.8",
|
|
163
|
+
"@moku-labs/common": "0.3.11",
|
|
164
164
|
"@moku-labs/core": "1.7.6",
|
|
165
|
-
"@moku-labs/native": "0.3.
|
|
165
|
+
"@moku-labs/native": "0.3.15",
|
|
166
166
|
"@moku-labs/system": "0.3.7",
|
|
167
167
|
"@types/bun": "1.4.2",
|
|
168
168
|
"@vitest/coverage-istanbul": "4.0.18",
|