@moku-labs/native 0.3.11 → 0.3.13

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,26 +35,41 @@ 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
43
- * await native.build.run({ target: "android", debug: true });
45
+ * await app.build.run({ target: "android", debug: true });
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`,
@@ -114,6 +129,19 @@ type CapabilityConfigMap = {
114
129
  * ```
115
130
  */
116
131
  type Orientation = "portrait" | "landscape" | "any";
132
+ /**
133
+ * One Info.plist value: a `<string>`, a `<true/>`/`<false/>`, an `<array>` or a `<dict>`,
134
+ * nested as deep as the key needs.
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * const encryption: PlistValue = false; // ITSAppUsesNonExemptEncryption
139
+ * const transport: PlistValue = { NSAllowsLocalNetworking: true }; // NSAppTransportSecurity
140
+ * ```
141
+ */
142
+ type PlistValue = string | boolean | readonly PlistValue[] | {
143
+ readonly [key: string]: PlistValue;
144
+ };
117
145
  /** How `tauri ios build` exports the signed archive (`--export-method`). */
118
146
  type AppleExportMethod = "app-store-connect" | "release-testing" | "debugging";
119
147
  /**
@@ -154,8 +182,8 @@ type Config = {
154
182
  * App identity, store metadata and presentation — project.onInit validates
155
183
  * name/identifier are non-empty (reverse-DNS identifier). `icon` is a 1024x1024 PNG
156
184
  * relative to cwd (a placeholder is generated when unset); `category` maps to
157
- * `bundle.category`; `buildNumber` maps to the iOS/macOS `bundleVersion`;
158
- * `orientation` locks the mobile screen at build time; `backgroundColor` paints the
185
+ * `bundle.category`; `buildNumber` maps to the iOS/macOS `bundleVersion` and, a whole
186
+ * number from 1 to 2 100 000 000, to the Android `versionCode`; `orientation` locks the mobile screen at build time; `backgroundColor` paints the
159
187
  * native window behind the page.
160
188
  */
161
189
  app: {
@@ -191,6 +219,16 @@ type Config = {
191
219
  * ```
192
220
  */
193
221
  adaptiveIconInset?: number;
222
+ /**
223
+ * iOS: the app turns the idle timer off at launch, so the screen does not dim while it
224
+ * runs. Android keeps it on from the page. Unset leaves the idle timer on.
225
+ *
226
+ * @example
227
+ * ```ts
228
+ * createApp({ config: { app: { name: "Demo", identifier: "com.acme.demo", keepScreenOn: true } } });
229
+ * ```
230
+ */
231
+ keepScreenOn?: boolean;
194
232
  }; /** Web build/dev wiring codegenned into tauri.conf.json. cwd for monorepo layouts. */
195
233
  web: {
196
234
  build: string;
@@ -207,6 +245,21 @@ type Config = {
207
245
  projectDir: string; /** Installer delivery root. */
208
246
  outDir: string; /** Signing env-var references. */
209
247
  signing: SigningConfig;
248
+ /**
249
+ * What an iOS app adds to its bundle. `infoPlist` merges into `Info.plist`, where
250
+ * `app.orientation` wins a shared key; `privacyManifest` is the absolute path of the file
251
+ * the bundle carries as `PrivacyInfo.xcprivacy`. Unset, a manifest an earlier build left
252
+ * in the generated tree is removed.
253
+ *
254
+ * @example
255
+ * ```ts
256
+ * createApp({ config: { ios: { infoPlist: { ITSAppUsesNonExemptEncryption: false } } } });
257
+ * ```
258
+ */
259
+ ios?: {
260
+ infoPlist?: Readonly<Record<string, PlistValue>>;
261
+ privacyManifest?: string;
262
+ };
210
263
  };
211
264
  /** native:phase payload — one flat event, target as a field (context decision). */
212
265
  type NativePhaseEvent = {
@@ -270,8 +323,9 @@ type CompletenessResult = {
270
323
  };
271
324
  /**
272
325
  * Result of the idempotent mobile patch pass: Android release signing and the main
273
- * activity's manifest attributes, the iOS Xcode build settings, and the runner command
274
- * on both platforms. A file several patches touched is listed once.
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.
275
329
  */
276
330
  type PatchResult = {
277
331
  readonly patched: readonly string[];
@@ -289,8 +343,9 @@ type PatchMobileOptions = {
289
343
  /**
290
344
  * The build profile one Android patch pass applies, with what that profile needs: the
291
345
  * debug profile names the app `"<name> (debug)"` and signs with the debug keystore the
292
- * caller resolved from `ctx.env`. `log` receives the warning about a network security
293
- * 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.
294
349
  *
295
350
  * @example
296
351
  * ```ts
@@ -387,21 +442,10 @@ type DeepLinkConf = {
387
442
  * the app at startup.
388
443
  */
389
444
  type TauriConfFragment = Record<string, never> | DeepLinkConf;
390
- /**
391
- * One Info.plist value: a `<string>`, a `<true/>`/`<false/>`, or an `<array>` of strings.
392
- *
393
- * @example
394
- * ```ts
395
- * const fullScreen: PlistValue = true; // <true/>
396
- * const portrait: PlistValue = ["UIInterfaceOrientationPortrait"];
397
- * // <array><string>UIInterfaceOrientationPortrait</string></array>
398
- * ```
399
- */
400
- type PlistValue = string | boolean | readonly string[];
401
445
  /**
402
446
  * An Info.ios.plist sidecar entry (src-tauri root, outside gen/), which Tauri merges into
403
447
  * the app's Info.plist on every iOS build. No registry row carries one today; the
404
- * orientation lock does.
448
+ * orientation lock, `ios.infoPlist` and the iOS debug profile do.
405
449
  */
406
450
  type PlistEntry = {
407
451
  key: string;
@@ -452,8 +496,11 @@ type Api$4 = {
452
496
  * write-if-changed writer. When the `shell` capability is composed for the target (named
453
497
  * in `config.system`, or implied by the debug profile on android), the
454
498
  * `tauri-plugin-moku-shell` crate is generated under `plugins/moku-shell/` too, with the
455
- * profile baked into its page script. Without the shell, the output is the same for both
456
- * profiles.
499
+ * profile baked into its page script. Without the shell, the profile changes one key: the
500
+ * store profile sets `build.removeUnusedCommands` in `tauri.conf.json`, and the debug and
501
+ * dev profiles do not. An iOS build in the debug profile also opens to Safari Web Inspector
502
+ * (`devtools` on the main window and in the `tauri` features) and to the editor on the local
503
+ * network (`NSLocalNetworkUsageDescription` and `NSAppTransportSecurity` in `Info.ios.plist`).
457
504
  *
458
505
  * @param opts - The generate options.
459
506
  * @param opts.target - The packaging target to generate for.
@@ -513,13 +560,19 @@ type Api$4 = {
513
560
  /**
514
561
  * Runs the idempotent mobile post-init patch pass. Android gets its build-profile
515
562
  * patches (debug: the `.debug` id suffix, the `"<name> (debug)"` label, a cleartext
516
- * network security config; store: all three reverted to the bytes before), its release
517
- * signing (the debug keystore under `HOME` ?? `USERPROFILE` in the debug profile), the
563
+ * network security config; store and dev: all three reverted to the bytes before), its
564
+ * release signing (the debug keystore under `HOME` ?? `USERPROFILE` in the debug profile), the
518
565
  * main activity's manifest attributes (the orientation lock among them) and the status
519
566
  * bar style in MainActivity.kt (light icons on a dark `app.backgroundColor`, dark icons
520
- * on a light one); iOS gets the Xcode entitlements-modification setting; both get the
521
- * Xcode/Android-Studio runner-command rewrite when a `runner` is supplied. The build
567
+ * on a light one); iOS gets the Xcode entitlements-modification setting, the deployment
568
+ * target (`signing.apple.iosMinimumSystemVersion`, or its default) and the privacy manifest
569
+ * (`ios.privacyManifest`; unset removes one an earlier pass added), each in `project.yml`
570
+ * and `project.pbxproj`, because a kept tree never runs xcodegen again, and outside the
571
+ * debug profile it loses the debug keys an earlier debug build merged into
572
+ * `<slug>_iOS/Info.plist`; both get the Xcode/Android-Studio runner-command rewrite when a
573
+ * `runner` is supplied. The build
522
574
  * plugin calls it after the mobile init pass, with the runner from `tauri.getRunner()`.
575
+ * A `gen/apple` tree that was never initialised reports nothing.
523
576
  *
524
577
  * @param opts - The patch options.
525
578
  * @param opts.target - The mobile platform to patch.
@@ -527,7 +580,9 @@ type Api$4 = {
527
580
  * @param opts.profile - The build profile; `"store"` when omitted.
528
581
  * @returns The paths patched vs. left unchanged.
529
582
  * @throws {Error} `[native]` in the debug profile when the debug keystore is missing,
530
- * with the `keytool` command that creates it.
583
+ * with the `keytool` command that creates it; when `ios.privacyManifest` names no file,
584
+ * before anything is written; when `project.yml` or `project.pbxproj` lacks a line a
585
+ * patch needs; when a debug key in `Info.plist` has no value.
531
586
  * @example
532
587
  * ```ts
533
588
  * // app.orientation is "portrait", app.backgroundColor is "#10161d", app.identifier is
@@ -941,7 +996,7 @@ type Api$3 = {
941
996
  * @param opts.onOutput - Called with each scrubbed output line.
942
997
  * @param opts.env - Extra environment for the tauri CLI, merged over the inherited one, so
943
998
  * the web build tauri runs (`beforeBuildCommand`) can read it. Never changes the argv: the
944
- * debug profile is still a release build (no `--debug`).
999
+ * debug and dev profiles are still release builds (no `--debug`).
945
1000
  * @returns The completed run's result.
946
1001
  * @throws {Error} A classified `TauriError` on a non-zero exit.
947
1002
  * @example
@@ -1044,19 +1099,34 @@ type PhaseTiming = {
1044
1099
  };
1045
1100
  /** Result of one target's full pipeline pass — `phases` always carries all six entries. */
1046
1101
  type BuildResult = {
1047
- target: Target; /** `<outDir>/<target>` for a store build, `<outDir>/<target>-debug` for a debug one. */
1102
+ target: Target; /** `<outDir>/<target>` for a store or dev build, `<outDir>/<target>-debug` for a debug one. */
1048
1103
  outPath: string;
1049
1104
  artifacts: readonly string[];
1050
1105
  durationMs: number;
1051
1106
  phases: readonly PhaseTiming[]; /** The profile the artifacts were built in — the same value `native:complete` carries. */
1052
1107
  profile: BuildProfile;
1053
1108
  };
1054
- /** Options for a prepare pass: the target, and `debug` for the debug profile (Android only). */
1109
+ /**
1110
+ * Options for a prepare pass: the target, and `debug` for the debug profile (Android, iOS).
1111
+ * It takes no `dev` on purpose: a dev build is only ever a full `run`.
1112
+ *
1113
+ * @example
1114
+ * ```ts
1115
+ * const opts: PrepareOptions = { target: "ios", debug: true };
1116
+ * ```
1117
+ */
1055
1118
  type PrepareOptions = {
1056
1119
  target: Target;
1057
1120
  debug?: boolean | undefined;
1058
1121
  };
1059
- /** Options for one target's pipeline pass. Platform-specific flags are ignored elsewhere. */
1122
+ /**
1123
+ * Options for one target's pipeline pass. Platform-specific flags are ignored elsewhere.
1124
+ *
1125
+ * @example
1126
+ * ```ts
1127
+ * const opts: RunOptions = { target: "android", aab: true, dev: true };
1128
+ * ```
1129
+ */
1060
1130
  type RunOptions = BuildFlavor & {
1061
1131
  target: Target;
1062
1132
  };
@@ -1088,13 +1158,13 @@ type Api$2 = {
1088
1158
  *
1089
1159
  * @param opts - The target to prepare, and `debug` for the debug profile.
1090
1160
  * @returns Nothing; the tree under `projectDir` is ready for the build verb.
1091
- * @throws {Error} `[native] --debug builds Android only for now (asked for <target>).` when
1092
- * `debug` is set for any target but android — before any phase runs.
1161
+ * @throws {Error} `[native] --debug builds Android and iOS only for now (asked for <target>).`
1162
+ * when `debug` is set for any target but android and ios — before any phase runs.
1093
1163
  * @example
1094
1164
  * ```ts
1095
1165
  * // A consumer prepares the debug tree of the phone build to open it in Android Studio: the
1096
1166
  * // shell crate is generated and the debug patches are applied, nothing is compiled.
1097
- * await ctx.require(buildPlugin).prepare({ target: "android", debug: true });
1167
+ * await app.build.prepare({ target: "android", debug: true });
1098
1168
  * ```
1099
1169
  */
1100
1170
  prepare(opts: PrepareOptions): Promise<void>;
@@ -1103,32 +1173,43 @@ type Api$2 = {
1103
1173
  * target, emitting `native:phase` per phase and `native:complete` on success. A store build
1104
1174
  * whose page carries the editor agent is refused after the compile, before anything is
1105
1175
  * collected; a debug build is delivered into `<outDir>/<target>-debug`, beside the store one.
1176
+ * A dev build is the store build with the agent allowed: same signing, same delivery.
1106
1177
  *
1107
- * @param opts - The target plus the platform flags (`simulator`, `aab`, `debug`).
1178
+ * @param opts - The target plus the platform flags (`simulator`, `aab`, `debug`, `dev`).
1108
1179
  * @returns The completed pipeline's result.
1109
- * @throws {Error} The first failing phase's error; `[native] --debug builds Android only …`
1110
- * for `debug` on another target, before any phase.
1180
+ * @throws {Error} The first failing phase's error; before any phase,
1181
+ * `[native] --debug builds Android and iOS only …` for `debug` on another target and
1182
+ * `[native] debug and dev cannot be combined.` for both flags together.
1111
1183
  * @example
1112
1184
  * ```ts
1113
1185
  * // A debug build for the phone, installed beside the store app.
1114
1186
  * const result = await app.build.run({ target: "android", debug: true });
1115
1187
  * // result.outPath === "dist-native/android-debug", result.profile === "debug"
1188
+ *
1189
+ * // The bundle a tester gets from the Play track, its page carrying the editor agent.
1190
+ * const test = await app.build.run({ target: "android", aab: true, dev: true });
1191
+ * // test.outPath === "dist-native/android", test.profile === "dev"
1116
1192
  * ```
1117
1193
  */
1118
1194
  run(opts: RunOptions): Promise<BuildResult>;
1119
1195
  /**
1120
1196
  * Runs the pipeline sequentially for every target in `opts.targets` (default: the configured
1121
1197
  * `targets`), stopping at the first failing target. With `debug`, every target is checked up
1122
- * front and the whole run is refused when one is not android — nothing is half-built.
1198
+ * front and the whole run is refused when one is neither android nor ios; `debug` and `dev`
1199
+ * together are refused up front too — nothing is half-built.
1123
1200
  *
1124
1201
  * @param opts - The targets plus the platform flags threaded into every run.
1125
1202
  * @returns Every completed target's result, in target order.
1126
- * @throws {Error} Whatever the first failing target's pipeline throws.
1203
+ * @throws {Error} The up-front refusals, or whatever the first failing target's pipeline throws.
1127
1204
  * @example
1128
1205
  * ```ts
1129
1206
  * // targets: ["android"] in the app config
1130
1207
  * const [phone] = await app.build.runAll({ debug: true });
1131
1208
  * // phone.profile === "debug", phone.outPath === "dist-native/android-debug"
1209
+ *
1210
+ * // The test app of both phones in one pass, each in the dev profile.
1211
+ * const results = await app.build.runAll({ targets: ["android", "ios"], dev: true });
1212
+ * // results.map(result => result.profile) is ["dev", "dev"]
1132
1213
  * ```
1133
1214
  */
1134
1215
  runAll(opts?: RunAllOptions): Promise<readonly BuildResult[]>;
@@ -1255,25 +1336,29 @@ type Api = {
1255
1336
  * `{ all: true }` (which ignores any given `target`). The flavor flags pass straight
1256
1337
  * through to `build.run`/`build.runAll`. Progress renders live through the plugin's
1257
1338
  * `native:phase`/`native:complete` hooks — a debug delivery is marked
1258
- * `debug build → <outPath>` in the completion panel. A failure (the store refusal of an
1259
- * editor-agent page included) renders the scrubbed stderr tail before the `[native]`
1260
- * error line, then rethrows unchanged.
1339
+ * `debug build → <outPath>` in the completion panel, a dev delivery reads like a store one.
1340
+ * A failure (the store refusal of an editor-agent page included) renders the scrubbed stderr
1341
+ * tail before the `[native]` error line, then rethrows unchanged.
1261
1342
  *
1262
1343
  * @param opts - Build options.
1263
1344
  * @param opts.target - The packaging target (default: the resolved host target).
1264
1345
  * @param opts.all - Build every configured target instead of one (ignores `target`).
1265
1346
  * @param opts.simulator - iOS: build for the host's simulator arch instead of a device archive.
1266
1347
  * @param opts.aab - Android: emit a store bundle (`.aab`) instead of an `.apk`.
1267
- * @param opts.debug - Build the debug profile (Android only), delivered to `<outDir>/<target>-debug`.
1348
+ * @param opts.debug - Build the debug profile (Android, iOS), delivered to `<outDir>/<target>-debug`.
1349
+ * @param opts.dev - Build the dev profile: the store build a tester installs, agent allowed.
1268
1350
  * @returns Resolves once the build (or all builds) complete.
1269
1351
  * @throws {Error} Whatever the pipeline throws — after rendering the failure.
1270
- * `[native] --debug builds Android only …` when `debug` is set with a non-android target,
1271
- * (or `all: true` with a non-android target).
1352
+ * `[native] --debug builds Android and iOS only …` when `debug` is set with another target
1353
+ * (or `all: true` with another target); `[native] debug and dev cannot be combined.` for
1354
+ * both flags together.
1272
1355
  * @example
1273
1356
  * ```ts
1274
1357
  * // A debug build for the phone, installed beside the store app; the completion panel
1275
1358
  * // reads "debug build → dist-native/android-debug".
1276
1359
  * await app.cli.build({ target: "android", debug: true });
1360
+ * // The bundle a tester gets from the Play track, in dist-native/android.
1361
+ * await app.cli.build({ target: "android", aab: true, dev: true });
1277
1362
  * // Every configured target, store profile.
1278
1363
  * await app.cli.build({ all: true });
1279
1364
  * ```
@@ -1418,8 +1503,9 @@ declare const doctorPlugin: import("@moku-labs/core").PluginInstance<"doctor", C
1418
1503
  * Complex tier — capability registry + generators/ (the `tauri-plugin-moku-shell` crate
1419
1504
  * among them) + write-if-changed writer + the mobile/ sub-domain (completeness gate, build
1420
1505
  * profile patches, Android signing block, Android manifest attributes, adaptive icon inset,
1421
- * shell link check, Xcode settings, runner-command rewrite) + the build-time orientation
1422
- * lock + the page agent scan + the guarded clean.
1506
+ * shell link check, Xcode settings, iOS deployment target and privacy manifest,
1507
+ * runner-command rewrite) + the build-time orientation lock + the page agent scan + the
1508
+ * guarded clean.
1423
1509
  *
1424
1510
  * @see README.md
1425
1511
  * @example
@@ -1484,4 +1570,4 @@ declare const createApp: <const ExtraPlugins extends readonly import("@moku-labs
1484
1570
  */
1485
1571
  declare const createPlugin: import("@moku-labs/core").BoundCreatePluginFunction<Config, Events, import("@moku-labs/core").CoreApisFromTuple<[import("@moku-labs/core").CorePluginInstance<"log", import("@moku-labs/common").LogConfig, import("@moku-labs/common").LogState, import("@moku-labs/common").LogApi>, import("@moku-labs/core").CorePluginInstance<"env", import("@moku-labs/common").EnvConfig, import("@moku-labs/common").EnvState, import("@moku-labs/common").EnvApi>]>>;
1486
1572
  //#endregion
1487
- export { type AppleExportMethod, type AppleSigning, type types_d_exports as Build, type BuildFlavor, type BuildProfile, type CapabilityConfigMap, type types_d_exports$1 as Cli, type Config, type types_d_exports$2 as Doctor, type Events, type MobileTarget, type NativeCompleteEvent, type NativePhase, type NativePhaseEvent, type Orientation, PHASE_ORDER, type types_d_exports$3 as Project, type SigningConfig, TARGETS, type Target, type types_d_exports$4 as Tauri, TauriError, type TauriRunner, buildPlugin, cliPlugin, createApp, createPlugin, doctorPlugin, hostTargets, projectPlugin, tauriPlugin };
1573
+ export { type AppleExportMethod, type AppleSigning, type types_d_exports as Build, type BuildFlavor, type BuildProfile, type CapabilityConfigMap, type types_d_exports$1 as Cli, type Config, type types_d_exports$2 as Doctor, type Events, type MobileTarget, type NativeCompleteEvent, type NativePhase, type NativePhaseEvent, type Orientation, PHASE_ORDER, type PlistValue, type types_d_exports$3 as Project, type SigningConfig, TARGETS, type Target, type types_d_exports$4 as Tauri, TauriError, type TauriRunner, buildPlugin, cliPlugin, createApp, createPlugin, doctorPlugin, hostTargets, projectPlugin, tauriPlugin };