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