@moku-labs/native 0.3.12 → 0.3.14

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/dist/index.d.cts CHANGED
@@ -34,8 +34,10 @@ type BuildFlavor = {
34
34
  aab?: boolean | undefined;
35
35
  /**
36
36
  * Build the debug profile instead of the store one: a still-optimized build that installs
37
- * next to the store app (`.debug` id, "(debug)" name), is signed with the debug keystore,
38
- * forwards the page console and allows cleartext. Unset means the store profile.
37
+ * next to the store app. On Android native gives it the `.debug` id and "(debug)" name, signs
38
+ * it with the debug keystore, forwards the page console and allows cleartext. On iOS the
39
+ * config names the app, and native adds the local-network keys and the Web Inspector. Unset
40
+ * means the store profile.
39
41
  *
40
42
  * @example
41
43
  * ```ts
@@ -43,17 +45,30 @@ type BuildFlavor = {
43
45
  * ```
44
46
  */
45
47
  debug?: boolean | undefined;
48
+ /**
49
+ * Build the dev profile instead of the store one: the store build a tester installs, with
50
+ * the same signing, `.aab`, `exportMethod` and delivery, whose page may carry the editor
51
+ * agent. The app config names the separate app (id, name, icon, `projectDir`, `outDir`);
52
+ * native renames nothing. Combining it with `debug` is an error.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * await app.build.run({ target: "android", aab: true, dev: true });
57
+ * ```
58
+ */
59
+ dev?: boolean | undefined;
46
60
  };
47
61
  /**
48
62
  * Which profile a build is made in. `"store"` is the shippable build; `"debug"` is the
49
- * on-device test build of {@link BuildFlavor.debug}. The page sees `"store"` as `"release"`.
63
+ * on-device test build of {@link BuildFlavor.debug}; `"dev"` is the store-signed test build
64
+ * of {@link BuildFlavor.dev}. The page sees `"store"` and `"dev"` as `"release"`.
50
65
  *
51
66
  * @example
52
67
  * ```ts
53
- * const profile: BuildProfile = flavor.debug ? "debug" : "store";
68
+ * const profile: BuildProfile = flavor.dev ? "dev" : "store";
54
69
  * ```
55
70
  */
56
- type BuildProfile = "store" | "debug";
71
+ type BuildProfile = "store" | "debug" | "dev";
57
72
  /**
58
73
  * Resolves the packaging targets a host can build with no extra opt-in — the default
59
74
  * `config.targets`. Exactly one desktop target per host (`darwin` → `macos`,
@@ -282,7 +297,7 @@ type BundleLayout = {
282
297
  readonly genDirectory: string | undefined;
283
298
  };
284
299
  declare namespace types_d_exports$3 {
285
- export { AndroidProfile, Api$4 as Api, CleanResult, CompletenessResult, DebugKeystore, DeepLinkConf, GenerateResult, ManifestEntry, PageAgentResult, PatchMobileOptions, PatchResult, PlistEntry, PlistValue, ProjectContext, RegistryRow, ResolvedCapability, TauriConfFragment };
300
+ export { AndroidProfile, Api$4 as Api, CleanResult, CompletenessResult, DebugKeystore, DeepLinkConf, GenerateResult, ManifestEntry, PageAgentResult, PatchMobileOptions, PatchResult, PlistEntry, PlistValue, ProjectContext, RegistryRow, ResolvedCapability, StaleTree, TauriConfFragment };
286
301
  }
287
302
  /**
288
303
  * What one `generate` pass did to each artifact, as paths under `projectDir`: written
@@ -307,9 +322,9 @@ type CompletenessResult = {
307
322
  };
308
323
  /**
309
324
  * Result of the idempotent mobile patch pass: Android release signing and the main
310
- * activity's manifest attributes, the iOS Xcode build settings, deployment target and
311
- * privacy manifest, and the runner command on both platforms. A file several patches
312
- * touched is listed once; a file a patch removed is listed as patched.
325
+ * activity's manifest attributes, the iOS Xcode build settings, deployment target, privacy
326
+ * manifest and `Info.plist`, and the runner command on both platforms. A file several
327
+ * patches touched is listed once; a file a patch removed is listed as patched.
313
328
  */
314
329
  type PatchResult = {
315
330
  readonly patched: readonly string[];
@@ -327,8 +342,9 @@ type PatchMobileOptions = {
327
342
  /**
328
343
  * The build profile one Android patch pass applies, with what that profile needs: the
329
344
  * debug profile names the app `"<name> (debug)"` and signs with the debug keystore the
330
- * caller resolved from `ctx.env`. `log` receives the warning about a network security
331
- * config this plugin did not write.
345
+ * caller resolved from `ctx.env`. The `dev` build profile applies as `store`: it is the
346
+ * store build a tester installs, signed with the game's key. `log` receives the warning about
347
+ * a network security config this plugin did not write.
332
348
  *
333
349
  * @example
334
350
  * ```ts
@@ -364,6 +380,23 @@ type PageAgentResult = {
364
380
  type CleanResult = {
365
381
  removed: readonly string[];
366
382
  };
383
+ /**
384
+ * A mobile `gen/` tree set aside because it was initialised for another app id.
385
+ *
386
+ * @example
387
+ * ```ts
388
+ * const aside: StaleTree = {
389
+ * found: "com.mokulabs.memorymissing",
390
+ * expected: "studio.kitto.memorymissing",
391
+ * movedTo: "/repo/.moku/tauri/src-tauri/gen/android.old-com.mokulabs.memorymissing"
392
+ * };
393
+ * ```
394
+ */
395
+ type StaleTree = {
396
+ /** The id the tree was initialised for. */readonly found: string; /** The configured `app.identifier`. */
397
+ readonly expected: string; /** The absolute path the tree was renamed to. */
398
+ readonly movedTo: string;
399
+ };
367
400
  /**
368
401
  * The Android SDK debug keystore the debug profile signs with, and the shell command that
369
402
  * creates it. `path` is undefined when the environment names no home directory.
@@ -428,7 +461,7 @@ type TauriConfFragment = Record<string, never> | DeepLinkConf;
428
461
  /**
429
462
  * An Info.ios.plist sidecar entry (src-tauri root, outside gen/), which Tauri merges into
430
463
  * the app's Info.plist on every iOS build. No registry row carries one today; the
431
- * orientation lock and `ios.infoPlist` do.
464
+ * orientation lock, `ios.infoPlist` and the iOS debug profile do.
432
465
  */
433
466
  type PlistEntry = {
434
467
  key: string;
@@ -480,7 +513,10 @@ type Api$4 = {
480
513
  * in `config.system`, or implied by the debug profile on android), the
481
514
  * `tauri-plugin-moku-shell` crate is generated under `plugins/moku-shell/` too, with the
482
515
  * profile baked into its page script. Without the shell, the profile changes one key: the
483
- * store profile sets `build.removeUnusedCommands` in `tauri.conf.json`.
516
+ * store profile sets `build.removeUnusedCommands` in `tauri.conf.json`, and the debug and
517
+ * dev profiles do not. An iOS build in the debug profile also opens to Safari Web Inspector
518
+ * (`devtools` on the main window and in the `tauri` features) and to the editor on the local
519
+ * network (`NSLocalNetworkUsageDescription` and `NSAppTransportSecurity` in `Info.ios.plist`).
484
520
  *
485
521
  * @param opts - The generate options.
486
522
  * @param opts.target - The packaging target to generate for.
@@ -537,18 +573,41 @@ type Api$4 = {
537
573
  getCompleteness(opts: {
538
574
  target: Target;
539
575
  }): CompletenessResult;
576
+ /**
577
+ * Sets a `gen/android` tree aside when it was initialised for another app id than
578
+ * `app.identifier`: renames it to `gen/android.old-<old id>` (never deletes it, it may hold
579
+ * a keystore or hand edits) and logs one line, so the build's mobile init writes a fresh
580
+ * tree. The build plugin calls it before the completeness read. iOS, a missing tree and a
581
+ * tree whose id cannot be read get undefined.
582
+ *
583
+ * @param opts - The check options.
584
+ * @param opts.target - The mobile platform whose tree to check.
585
+ * @returns What was set aside, or undefined when the tree was kept.
586
+ * @example
587
+ * ```ts
588
+ * // app.identifier changed from com.mokulabs.memorymissing to studio.kitto.memorymissing.
589
+ * await app.project.setAsideStaleTree({ target: "android" });
590
+ * // { found: "com.mokulabs.memorymissing", expected: "studio.kitto.memorymissing",
591
+ * // movedTo: "/repo/.moku/tauri/src-tauri/gen/android.old-com.mokulabs.memorymissing" }
592
+ * ```
593
+ */
594
+ setAsideStaleTree(opts: {
595
+ target: MobileTarget;
596
+ }): Promise<StaleTree | undefined>;
540
597
  /**
541
598
  * Runs the idempotent mobile post-init patch pass. Android gets its build-profile
542
599
  * patches (debug: the `.debug` id suffix, the `"<name> (debug)"` label, a cleartext
543
- * network security config; store: all three reverted to the bytes before), its release
544
- * signing (the debug keystore under `HOME` ?? `USERPROFILE` in the debug profile), the
600
+ * network security config; store and dev: all three reverted to the bytes before), its
601
+ * release signing (the debug keystore under `HOME` ?? `USERPROFILE` in the debug profile), the
545
602
  * main activity's manifest attributes (the orientation lock among them) and the status
546
603
  * bar style in MainActivity.kt (light icons on a dark `app.backgroundColor`, dark icons
547
604
  * on a light one); iOS gets the Xcode entitlements-modification setting, the deployment
548
605
  * target (`signing.apple.iosMinimumSystemVersion`, or its default) and the privacy manifest
549
606
  * (`ios.privacyManifest`; unset removes one an earlier pass added), each in `project.yml`
550
- * and `project.pbxproj`, because a kept tree never runs xcodegen again; both get the
551
- * Xcode/Android-Studio runner-command rewrite when a `runner` is supplied. The build
607
+ * and `project.pbxproj`, because a kept tree never runs xcodegen again, and outside the
608
+ * debug profile it loses the debug keys an earlier debug build merged into
609
+ * `<slug>_iOS/Info.plist`; both get the Xcode/Android-Studio runner-command rewrite when a
610
+ * `runner` is supplied. The build
552
611
  * plugin calls it after the mobile init pass, with the runner from `tauri.getRunner()`.
553
612
  * A `gen/apple` tree that was never initialised reports nothing.
554
613
  *
@@ -560,7 +619,7 @@ type Api$4 = {
560
619
  * @throws {Error} `[native]` in the debug profile when the debug keystore is missing,
561
620
  * with the `keytool` command that creates it; when `ios.privacyManifest` names no file,
562
621
  * before anything is written; when `project.yml` or `project.pbxproj` lacks a line a
563
- * patch needs.
622
+ * patch needs; when a debug key in `Info.plist` has no value.
564
623
  * @example
565
624
  * ```ts
566
625
  * // app.orientation is "portrait", app.backgroundColor is "#10161d", app.identifier is
@@ -974,7 +1033,7 @@ type Api$3 = {
974
1033
  * @param opts.onOutput - Called with each scrubbed output line.
975
1034
  * @param opts.env - Extra environment for the tauri CLI, merged over the inherited one, so
976
1035
  * the web build tauri runs (`beforeBuildCommand`) can read it. Never changes the argv: the
977
- * debug profile is still a release build (no `--debug`).
1036
+ * debug and dev profiles are still release builds (no `--debug`).
978
1037
  * @returns The completed run's result.
979
1038
  * @throws {Error} A classified `TauriError` on a non-zero exit.
980
1039
  * @example
@@ -1077,19 +1136,34 @@ type PhaseTiming = {
1077
1136
  };
1078
1137
  /** Result of one target's full pipeline pass — `phases` always carries all six entries. */
1079
1138
  type BuildResult = {
1080
- target: Target; /** `<outDir>/<target>` for a store build, `<outDir>/<target>-debug` for a debug one. */
1139
+ target: Target; /** `<outDir>/<target>` for a store or dev build, `<outDir>/<target>-debug` for a debug one. */
1081
1140
  outPath: string;
1082
1141
  artifacts: readonly string[];
1083
1142
  durationMs: number;
1084
1143
  phases: readonly PhaseTiming[]; /** The profile the artifacts were built in — the same value `native:complete` carries. */
1085
1144
  profile: BuildProfile;
1086
1145
  };
1087
- /** Options for a prepare pass: the target, and `debug` for the debug profile (Android only). */
1146
+ /**
1147
+ * Options for a prepare pass: the target, and `debug` for the debug profile (Android, iOS).
1148
+ * It takes no `dev` on purpose: a dev build is only ever a full `run`.
1149
+ *
1150
+ * @example
1151
+ * ```ts
1152
+ * const opts: PrepareOptions = { target: "ios", debug: true };
1153
+ * ```
1154
+ */
1088
1155
  type PrepareOptions = {
1089
1156
  target: Target;
1090
1157
  debug?: boolean | undefined;
1091
1158
  };
1092
- /** Options for one target's pipeline pass. Platform-specific flags are ignored elsewhere. */
1159
+ /**
1160
+ * Options for one target's pipeline pass. Platform-specific flags are ignored elsewhere.
1161
+ *
1162
+ * @example
1163
+ * ```ts
1164
+ * const opts: RunOptions = { target: "android", aab: true, dev: true };
1165
+ * ```
1166
+ */
1093
1167
  type RunOptions = BuildFlavor & {
1094
1168
  target: Target;
1095
1169
  };
@@ -1109,7 +1183,7 @@ type PathResolver = (target: string) => string;
1109
1183
  * cross-plugin surface build depends on (D-007) is readable in one place.
1110
1184
  */
1111
1185
  type BuildDeps = {
1112
- readonly project: Pick<Api$4, "generate" | "getBundleLayout" | "getCompleteness" | "patchMobile" | "clearMobileBuildOutput" | "ensureIconSource" | "resolveDerivedPath" | "patchMobileIcons" | "detectPageAgent" | "checkShellLinked">;
1186
+ readonly project: Pick<Api$4, "generate" | "getBundleLayout" | "getCompleteness" | "setAsideStaleTree" | "patchMobile" | "clearMobileBuildOutput" | "ensureIconSource" | "resolveDerivedPath" | "patchMobileIcons" | "detectPageAgent" | "checkShellLinked">;
1113
1187
  readonly tauri: Pick<Api$3, "build" | "mobileInit" | "icon" | "getRunner">;
1114
1188
  };
1115
1189
  /** Public API of the build plugin — the per-target pipeline orchestrator. */
@@ -1121,13 +1195,13 @@ type Api$2 = {
1121
1195
  *
1122
1196
  * @param opts - The target to prepare, and `debug` for the debug profile.
1123
1197
  * @returns Nothing; the tree under `projectDir` is ready for the build verb.
1124
- * @throws {Error} `[native] --debug builds Android only for now (asked for <target>).` when
1125
- * `debug` is set for any target but android — before any phase runs.
1198
+ * @throws {Error} `[native] --debug builds Android and iOS only for now (asked for <target>).`
1199
+ * when `debug` is set for any target but android and ios — before any phase runs.
1126
1200
  * @example
1127
1201
  * ```ts
1128
1202
  * // A consumer prepares the debug tree of the phone build to open it in Android Studio: the
1129
1203
  * // shell crate is generated and the debug patches are applied, nothing is compiled.
1130
- * await ctx.require(buildPlugin).prepare({ target: "android", debug: true });
1204
+ * await app.build.prepare({ target: "android", debug: true });
1131
1205
  * ```
1132
1206
  */
1133
1207
  prepare(opts: PrepareOptions): Promise<void>;
@@ -1136,32 +1210,43 @@ type Api$2 = {
1136
1210
  * target, emitting `native:phase` per phase and `native:complete` on success. A store build
1137
1211
  * whose page carries the editor agent is refused after the compile, before anything is
1138
1212
  * collected; a debug build is delivered into `<outDir>/<target>-debug`, beside the store one.
1213
+ * A dev build is the store build with the agent allowed: same signing, same delivery.
1139
1214
  *
1140
- * @param opts - The target plus the platform flags (`simulator`, `aab`, `debug`).
1215
+ * @param opts - The target plus the platform flags (`simulator`, `aab`, `debug`, `dev`).
1141
1216
  * @returns The completed pipeline's result.
1142
- * @throws {Error} The first failing phase's error; `[native] --debug builds Android only …`
1143
- * for `debug` on another target, before any phase.
1217
+ * @throws {Error} The first failing phase's error; before any phase,
1218
+ * `[native] --debug builds Android and iOS only …` for `debug` on another target and
1219
+ * `[native] debug and dev cannot be combined.` for both flags together.
1144
1220
  * @example
1145
1221
  * ```ts
1146
1222
  * // A debug build for the phone, installed beside the store app.
1147
1223
  * const result = await app.build.run({ target: "android", debug: true });
1148
1224
  * // result.outPath === "dist-native/android-debug", result.profile === "debug"
1225
+ *
1226
+ * // The bundle a tester gets from the Play track, its page carrying the editor agent.
1227
+ * const test = await app.build.run({ target: "android", aab: true, dev: true });
1228
+ * // test.outPath === "dist-native/android", test.profile === "dev"
1149
1229
  * ```
1150
1230
  */
1151
1231
  run(opts: RunOptions): Promise<BuildResult>;
1152
1232
  /**
1153
1233
  * Runs the pipeline sequentially for every target in `opts.targets` (default: the configured
1154
1234
  * `targets`), stopping at the first failing target. With `debug`, every target is checked up
1155
- * front and the whole run is refused when one is not android — nothing is half-built.
1235
+ * front and the whole run is refused when one is neither android nor ios; `debug` and `dev`
1236
+ * together are refused up front too — nothing is half-built.
1156
1237
  *
1157
1238
  * @param opts - The targets plus the platform flags threaded into every run.
1158
1239
  * @returns Every completed target's result, in target order.
1159
- * @throws {Error} Whatever the first failing target's pipeline throws.
1240
+ * @throws {Error} The up-front refusals, or whatever the first failing target's pipeline throws.
1160
1241
  * @example
1161
1242
  * ```ts
1162
1243
  * // targets: ["android"] in the app config
1163
1244
  * const [phone] = await app.build.runAll({ debug: true });
1164
1245
  * // phone.profile === "debug", phone.outPath === "dist-native/android-debug"
1246
+ *
1247
+ * // The test app of both phones in one pass, each in the dev profile.
1248
+ * const results = await app.build.runAll({ targets: ["android", "ios"], dev: true });
1249
+ * // results.map(result => result.profile) is ["dev", "dev"]
1165
1250
  * ```
1166
1251
  */
1167
1252
  runAll(opts?: RunAllOptions): Promise<readonly BuildResult[]>;
@@ -1288,25 +1373,29 @@ type Api = {
1288
1373
  * `{ all: true }` (which ignores any given `target`). The flavor flags pass straight
1289
1374
  * through to `build.run`/`build.runAll`. Progress renders live through the plugin's
1290
1375
  * `native:phase`/`native:complete` hooks — a debug delivery is marked
1291
- * `debug build → <outPath>` in the completion panel. A failure (the store refusal of an
1292
- * editor-agent page included) renders the scrubbed stderr tail before the `[native]`
1293
- * error line, then rethrows unchanged.
1376
+ * `debug build → <outPath>` in the completion panel, a dev delivery reads like a store one.
1377
+ * A failure (the store refusal of an editor-agent page included) renders the scrubbed stderr
1378
+ * tail before the `[native]` error line, then rethrows unchanged.
1294
1379
  *
1295
1380
  * @param opts - Build options.
1296
1381
  * @param opts.target - The packaging target (default: the resolved host target).
1297
1382
  * @param opts.all - Build every configured target instead of one (ignores `target`).
1298
1383
  * @param opts.simulator - iOS: build for the host's simulator arch instead of a device archive.
1299
1384
  * @param opts.aab - Android: emit a store bundle (`.aab`) instead of an `.apk`.
1300
- * @param opts.debug - Build the debug profile (Android only), delivered to `<outDir>/<target>-debug`.
1385
+ * @param opts.debug - Build the debug profile (Android, iOS), delivered to `<outDir>/<target>-debug`.
1386
+ * @param opts.dev - Build the dev profile: the store build a tester installs, agent allowed.
1301
1387
  * @returns Resolves once the build (or all builds) complete.
1302
1388
  * @throws {Error} Whatever the pipeline throws — after rendering the failure.
1303
- * `[native] --debug builds Android only …` when `debug` is set with a non-android target,
1304
- * (or `all: true` with a non-android target).
1389
+ * `[native] --debug builds Android and iOS only …` when `debug` is set with another target
1390
+ * (or `all: true` with another target); `[native] debug and dev cannot be combined.` for
1391
+ * both flags together.
1305
1392
  * @example
1306
1393
  * ```ts
1307
1394
  * // A debug build for the phone, installed beside the store app; the completion panel
1308
1395
  * // reads "debug build → dist-native/android-debug".
1309
1396
  * await app.cli.build({ target: "android", debug: true });
1397
+ * // The bundle a tester gets from the Play track, in dist-native/android.
1398
+ * await app.cli.build({ target: "android", aab: true, dev: true });
1310
1399
  * // Every configured target, store profile.
1311
1400
  * await app.cli.build({ all: true });
1312
1401
  * ```