@moku-labs/native 0.3.12 → 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.mjs CHANGED
@@ -794,7 +794,8 @@ function generateCapabilities(input) {
794
794
  //#region src/plugins/project/generators/cargo.ts
795
795
  /**
796
796
  * @file project plugin generator — Cargo.toml with registry-pinned crate dependencies, the
797
- * path dependency of every generated local crate, and the size profile of a release build.
797
+ * path dependency of every generated local crate, the iOS debug `devtools` feature, and the
798
+ * size profile of a release build.
798
799
  */
799
800
  /**
800
801
  * The `tauri` crate floor. The `back` capability calls `exit()` and grants
@@ -809,7 +810,7 @@ const TAURI_VERSION_FLOOR = "2.12";
809
810
  */
810
811
  const IOS_ONLY_DEPENDENCIES = [`[target.'cfg(target_os = "ios")'.dependencies]`, "objc2 = \"0.6\""];
811
812
  /**
812
- * The release profile, for every target and both build profiles: the debug build is a
813
+ * The release profile, for every target and every build profile: the debug build is a
813
814
  * release build too, so what a phone measures is what the store ships. It trades compile
814
815
  * time for a smaller library, and `panic = "abort"` drops the unwinding tables.
815
816
  */
@@ -822,6 +823,12 @@ const RELEASE_PROFILE = [
822
823
  "strip = true"
823
824
  ];
824
825
  /**
826
+ * The `tauri` feature an iOS debug build adds. The debug build is a release build, and a
827
+ * release build compiles the inspector only with it: the window's `devtools` flag alone does
828
+ * nothing there.
829
+ */
830
+ const IOS_DEBUG_FEATURE = "devtools";
831
+ /**
825
832
  * Derives a valid Cargo package name from the app's display name — lowercased,
826
833
  * non-alphanumeric runs collapsed to a single hyphen, and guaranteed to start with a
827
834
  * letter (Cargo package names must match `[a-z][a-z0-9_-]*`).
@@ -878,9 +885,9 @@ function dependencyLine(capability) {
878
885
  * every cargo feature the composed capabilities ask for (tray's `tray-icon`; without it
879
886
  * the tray API is not compiled in at all), plus one dependency line per resolved
880
887
  * capability that ships a crate: pinned for a published one, by path for the generated
881
- * shell crate. Feature-only and permission-only rows contribute no dependency line. The
882
- * `[profile.release]` table follows, and the iOS-only `objc2` table closes the file on
883
- * every target.
888
+ * shell crate. Feature-only and permission-only rows contribute no dependency line. An iOS
889
+ * debug build adds `devtools` to those features. The `[profile.release]` table follows, and
890
+ * the iOS-only `objc2` table closes the file on every target.
884
891
  *
885
892
  * @param input - Frozen global config + capabilities resolved for the target.
886
893
  * @returns A single-artifact array for `src-tauri/Cargo.toml`.
@@ -888,7 +895,9 @@ function dependencyLine(capability) {
888
895
  function generateCargo(input) {
889
896
  const packageName = sanitizePackageName(input.global.app.name);
890
897
  const pinnedDeps = input.capabilities.map((capability) => dependencyLine(capability)).filter((line) => line !== void 0).toSorted();
891
- const features = [...new Set(input.capabilities.flatMap((capability) => capability.cargoFeatures))].toSorted().map((feature) => `"${feature}"`).join(", ");
898
+ const iosDebug = input.target === "ios" && input.profile === "debug";
899
+ const requested = input.capabilities.flatMap((capability) => capability.cargoFeatures);
900
+ const features = [.../* @__PURE__ */ new Set([...requested, ...iosDebug ? [IOS_DEBUG_FEATURE] : []])].toSorted().map((feature) => `"${feature}"`).join(", ");
892
901
  return [{
893
902
  path: "src-tauri/Cargo.toml",
894
903
  content: [
@@ -1676,7 +1685,7 @@ class MokuShellPlugin(private val activity: Activity) : Plugin(activity) {
1676
1685
  `;
1677
1686
  /**
1678
1687
  * Renders `MokuShellProfile.kt`: the one per-profile file of the module. The debug profile
1679
- * turns on WebView debugging and `share`; the store profile turns both off.
1688
+ * turns on WebView debugging and `share`; the store and dev profiles turn both off.
1680
1689
  *
1681
1690
  * @param profile - The build profile the crate is generated for.
1682
1691
  * @returns The Kotlin source.
@@ -1919,8 +1928,8 @@ const CONTRACT_BODY = String.raw` var MAX_SHARE_BYTES = 32 * 1024 * 1024;
1919
1928
  }, noop);`;
1920
1929
  /**
1921
1930
  * Builds the page contract script for one app and profile. The build profile and id are
1922
- * baked in at generate time: the store profile reads `"release"` on the page, and the id is
1923
- * `"<app.version>+<app.buildNumber ?? 0>"`, with `"-debug"` in the debug profile. A second
1931
+ * baked in at generate time: the store and dev profiles read `"release"` on the page, and the
1932
+ * id is `"<app.version>+<app.buildNumber ?? 0>"`, with `"-debug"` in the debug profile. A second
1924
1933
  * run of the script in the same frame is a no-op.
1925
1934
  *
1926
1935
  * @param input - The generator input (target, app version and build number).
@@ -2100,11 +2109,14 @@ function escapeXml(text) {
2100
2109
  }
2101
2110
  //#endregion
2102
2111
  //#region src/plugins/project/generators/sidecar.ts
2103
- /**
2104
- * @file project plugin generator — Info.ios.plist sidecar (src-tauri root, outside gen/).
2105
- */
2106
2112
  /** One indentation step of the generated plist. */
2107
2113
  const PLIST_INDENT = " ";
2114
+ /** The key of the sentence iOS shows when it asks to reach the local network. */
2115
+ const LOCAL_NETWORK_USAGE_KEY = "NSLocalNetworkUsageDescription";
2116
+ /** The key of App Transport Security, which refuses `ws://` to the editor by default. */
2117
+ const APP_TRANSPORT_SECURITY_KEY = "NSAppTransportSecurity";
2118
+ /** The sentence iOS shows when an iOS debug build first reaches for the editor. */
2119
+ const LOCAL_NETWORK_USAGE = "This debug build talks to the editor on your local network.";
2108
2120
  /**
2109
2121
  * Tells a plist `<array>` from a `<dict>`: `Array.isArray` alone does not narrow a readonly
2110
2122
  * array.
@@ -2164,11 +2176,35 @@ function renderPlistValue(value, indent) {
2164
2176
  ];
2165
2177
  }
2166
2178
  /**
2179
+ * Lists what the debug profile needs to reach the editor from an iPhone: the local-network
2180
+ * sentence, and App Transport Security opened for the local network alone. Every other
2181
+ * profile adds nothing, and the iOS patch pass takes both keys out of a kept tree again
2182
+ * (`mobile/ios-plist.ts`).
2183
+ *
2184
+ * @param profile - The build profile being generated for.
2185
+ * @returns The two entries in the debug profile, otherwise none.
2186
+ * @example
2187
+ * ```ts
2188
+ * debugPlist("store"); // []
2189
+ * ```
2190
+ */
2191
+ function debugPlist(profile) {
2192
+ if (profile !== "debug") return [];
2193
+ return [{
2194
+ key: LOCAL_NETWORK_USAGE_KEY,
2195
+ value: LOCAL_NETWORK_USAGE
2196
+ }, {
2197
+ key: APP_TRANSPORT_SECURITY_KEY,
2198
+ value: { NSAllowsLocalNetworking: true }
2199
+ }];
2200
+ }
2201
+ /**
2167
2202
  * Generates the `Info.ios.plist` SIDECAR at the src-tauri root, which Tauri merges into the
2168
2203
  * app's Info.plist on every iOS build. Its entries are every resolved capability's
2169
- * `sidecarPlist`, then `ios.infoPlist`, then the orientation lock (`app.orientation`); on a
2170
- * duplicate key the later entry wins, so the app's keys beat a capability and orientation
2171
- * beats both.
2204
+ * `sidecarPlist`, then `ios.infoPlist`, then the debug profile's two keys, then the orientation
2205
+ * lock (`app.orientation`); on a duplicate key the later entry wins, so the app's keys beat a
2206
+ * capability, the debug keys beat a game's own in that profile only, and orientation beats
2207
+ * them all.
2172
2208
  *
2173
2209
  * On iOS the file is ALWAYS written, as an empty `<dict>` when nothing contributes a key:
2174
2210
  * the writer never deletes a file, and a portrait lock left in a stale sidecar would keep
@@ -2194,6 +2230,7 @@ function generateSidecar(input) {
2194
2230
  key,
2195
2231
  value
2196
2232
  })),
2233
+ ...debugPlist(input.profile),
2197
2234
  ...orientationPlist(input.global.app.orientation)
2198
2235
  ];
2199
2236
  for (const entry of contributed) entries.set(entry.key, entry.value);
@@ -2214,8 +2251,9 @@ function generateSidecar(input) {
2214
2251
  //#endregion
2215
2252
  //#region src/plugins/project/generators/tauri-conf.ts
2216
2253
  /**
2217
- * @file project plugin generator — tauri.conf.json (identity, build wiring, bundle
2218
- * metadata, Apple signing, the Android versionCode, plugin blocks).
2254
+ * @file project plugin generator — tauri.conf.json (identity, build wiring, the main
2255
+ * window with its iOS debug inspector, bundle metadata, Apple signing, the Android
2256
+ * versionCode, plugin blocks).
2219
2257
  */
2220
2258
  /**
2221
2259
  * The icon set `tauri icon` writes into `src-tauri/icons`. Tauri reads `bundle.icon` at
@@ -2350,9 +2388,11 @@ function buildPlugins(capabilities) {
2350
2388
  }
2351
2389
  /**
2352
2390
  * Generates `src-tauri/tauri.conf.json` — app identity, the web build/dev wiring, with
2353
- * `removeUnusedCommands` in the store profile only (a debug page may call what a store
2354
- * page does not), the main window (its title, plus `app.backgroundColor` when set), the
2355
- * bundle/signing metadata, and a `plugins.<name>` block per CONFIGURED capability (see
2391
+ * `removeUnusedCommands` in the store profile only (a debug or dev page may call what a
2392
+ * store page does not), the main window (its title, plus `app.backgroundColor` when set, and
2393
+ * `devtools` in an iOS debug build, so Safari Web Inspector can attach: the debug build is a
2394
+ * release build, where Tauri closes the inspector), the bundle/signing metadata, and a
2395
+ * `plugins.<name>` block per CONFIGURED capability (see
2356
2396
  * {@link buildPlugins}; this is where deep-link's scheme rides — per D-011/D-012 the whole
2357
2397
  * v1 mobile-permission story is conf-only). Both path-shaped fields are rebased onto
2358
2398
  * `src-tauri`, which is where Tauri resolves them from, and the before-commands carry an
@@ -2370,6 +2410,7 @@ function buildPlugins(capabilities) {
2370
2410
  function generateTauriConf(input) {
2371
2411
  const { global, capabilities } = input;
2372
2412
  const webRoot = path.resolve(global.web.cwd ?? ".");
2413
+ const inspectable = input.target === "ios" && input.profile === "debug";
2373
2414
  const conf = {
2374
2415
  productName: global.app.name,
2375
2416
  identifier: global.app.identifier,
@@ -2389,7 +2430,8 @@ function generateTauriConf(input) {
2389
2430
  },
2390
2431
  app: { windows: [{
2391
2432
  title: global.app.name,
2392
- ...compact([["backgroundColor", global.app.backgroundColor]])
2433
+ ...compact([["backgroundColor", global.app.backgroundColor]]),
2434
+ ...inspectable ? { devtools: true } : {}
2393
2435
  }] },
2394
2436
  bundle: buildBundle(input),
2395
2437
  plugins: buildPlugins(capabilities)
@@ -2698,9 +2740,9 @@ async function writeIfChanged(filePath, content, projectDirectory) {
2698
2740
  * the iOS project patches) reads the same list from here, so none can drift into a file the
2699
2741
  * others do not know about — and none ever descends into `gen/apple/build` or
2700
2742
  * `gen/android/build`, which belong to the toolchain. The privacy manifest's place in the
2701
- * tree is here too. The Android status bar patch finds its MainActivity.kt here, the profile
2702
- * patches their `strings.xml` and network security config, and the icon inset its adaptive
2703
- * icon directory.
2743
+ * tree is here too, and so is the app's `Info.plist`. The Android status bar patch finds its
2744
+ * MainActivity.kt here, the profile patches their `strings.xml` and network security config,
2745
+ * and the icon inset its adaptive icon directory.
2704
2746
  */
2705
2747
  /** Source extensions that can carry the Android runner command. */
2706
2748
  const ANDROID_SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
@@ -2732,6 +2774,10 @@ const SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set([
2732
2774
  ]);
2733
2775
  /** The file name Apple reads a privacy manifest from, at the top of the app bundle. */
2734
2776
  const IOS_PRIVACY_MANIFEST_FILE = "PrivacyInfo.xcprivacy";
2777
+ /** How the directory of the app's own files ends in `gen/apple`: `<slug>_iOS`. */
2778
+ const IOS_APP_DIRECTORY_SUFFIX = "_iOS";
2779
+ /** The file name of the app's property list, in that directory. */
2780
+ const IOS_INFO_PLIST_FILE = "Info.plist";
2735
2781
  /**
2736
2782
  * Lists the generated iOS files a patch pass may rewrite: `project.yml` plus the
2737
2783
  * `project.pbxproj` of every generated Xcode project. `gen/apple/build` is never listed —
@@ -2756,6 +2802,22 @@ async function iosPatchFiles(genDirectory) {
2756
2802
  return files;
2757
2803
  }
2758
2804
  /**
2805
+ * Lists the `Info.plist` of the generated iOS app, the file `tauri ios build` merges the
2806
+ * sidecar into: in the `gen/apple` directory that ends in `_iOS`. A tree where tauri has not
2807
+ * written it yet lists nothing.
2808
+ *
2809
+ * @param genDirectory - The `src-tauri/gen/apple` directory.
2810
+ * @returns The existing files, possibly none.
2811
+ * @example
2812
+ * ```ts
2813
+ * await iosInfoPlistFiles("/repo/.moku/tauri/src-tauri/gen/apple");
2814
+ * // ["/repo/.moku/tauri/src-tauri/gen/apple/my-game_iOS/Info.plist"]
2815
+ * ```
2816
+ */
2817
+ async function iosInfoPlistFiles(genDirectory) {
2818
+ return (await readdir(genDirectory, { withFileTypes: true })).filter((entry) => entry.isDirectory() && entry.name.endsWith(IOS_APP_DIRECTORY_SUFFIX)).map((entry) => path.join(genDirectory, entry.name, IOS_INFO_PLIST_FILE)).filter((file) => existsSync(file));
2819
+ }
2820
+ /**
2759
2821
  * Returns where the iOS patch pass keeps the privacy manifest: the top of `gen/apple`, the
2760
2822
  * directory `project.yml` and the pbxproj's root group resolve a relative path from.
2761
2823
  *
@@ -3741,6 +3803,118 @@ async function patchPrivacyManifest(projectDirectory, genDirectory, manifest) {
3741
3803
  };
3742
3804
  }
3743
3805
  //#endregion
3806
+ //#region src/plugins/project/mobile/ios-plist.ts
3807
+ /**
3808
+ * @file project plugin — the iOS `Info.plist` patch: takes the debug keys out of a kept tree.
3809
+ *
3810
+ * `tauri ios build` merges `Info.ios.plist` INTO `gen/apple/<slug>_iOS/Info.plist` for good
3811
+ * (measured with tauri-cli 2.11.4), so a key dropped from the sidecar stays in that file: a
3812
+ * store build of a tree that once built in debug would ship the loosened App Transport
3813
+ * Security. Outside the debug profile this pass removes both debug keys; the sidecar merge
3814
+ * after it restores whatever the game itself asked for.
3815
+ *
3816
+ * The transform is a pure text function over the shape the plist crate writes: line endings
3817
+ * and every neighbouring line survive byte for byte, and a file without the keys comes back
3818
+ * untouched. That crate escapes every value and writes no comment, so a `<` is always a tag.
3819
+ */
3820
+ /** The keys only a debug build may carry, the ones `generators/sidecar.ts` adds there. */
3821
+ const DEBUG_KEYS = [LOCAL_NETWORK_USAGE_KEY, APP_TRANSPORT_SECURITY_KEY];
3822
+ /** Every element tag of a plist. Group 1 marks a closing tag, group 2 a self-closed one. */
3823
+ const TAG_PATTERN = /<(\/?)[a-z][^<>]*?(\/?)>/gi;
3824
+ /**
3825
+ * Finds where the plist value that starts after `from` ends, walking its depth: a `<dict>`
3826
+ * may hold more of them, and a `<dict/>` opens nothing.
3827
+ *
3828
+ * @param text - The file content.
3829
+ * @param from - The index right after the value's `<key>` element.
3830
+ * @returns The index after the value, or undefined when no value follows.
3831
+ * @example
3832
+ * ```ts
3833
+ * valueEnd("<key>K</key><dict><dict/></dict>", 12); // 32
3834
+ * ```
3835
+ */
3836
+ function valueEnd(text, from) {
3837
+ let depth = 0;
3838
+ for (const match of text.slice(from).matchAll(TAG_PATTERN)) {
3839
+ const [tag, closing, selfClosed] = match;
3840
+ if (depth === 0 && tag === "<key>") return void 0;
3841
+ if (closing) depth -= 1;
3842
+ else if (!selfClosed) depth += 1;
3843
+ if (depth === 0) return from + match.index + tag.length;
3844
+ if (depth < 0) return void 0;
3845
+ }
3846
+ }
3847
+ /**
3848
+ * Cuts a range out of a text: the whole lines when the range is alone on them, so no blank
3849
+ * line stays behind and the file keeps its line endings, otherwise the range only.
3850
+ *
3851
+ * @param text - The file content.
3852
+ * @param start - The index of the range's first character.
3853
+ * @param end - The index after its last character.
3854
+ * @returns The text without the range.
3855
+ * @example
3856
+ * ```ts
3857
+ * cutRange("a\n\tb\nc\n", 3, 4); // "a\nc\n"
3858
+ * ```
3859
+ */
3860
+ function cutRange(text, start, end) {
3861
+ const lineStart = text.lastIndexOf("\n", start) + 1;
3862
+ const lineBreak = text.indexOf("\n", end);
3863
+ const lineEnd = lineBreak === -1 ? text.length : lineBreak + 1;
3864
+ return text.slice(lineStart, start).trim() === "" && text.slice(end, lineEnd).trim() === "" ? text.slice(0, lineStart) + text.slice(lineEnd) : text.slice(0, start) + text.slice(end);
3865
+ }
3866
+ /**
3867
+ * Removes keys and their values from the text of an XML property list. A value is whatever
3868
+ * element follows the `<key>`, however deep it nests. Content without the keys comes back
3869
+ * byte-identical, so the writer leaves the file alone.
3870
+ *
3871
+ * @param existing - The current `Info.plist` content.
3872
+ * @param keys - The keys to remove.
3873
+ * @returns The content without those keys.
3874
+ * @throws {Error} `[native]` when a key has no value after it: the file is broken, and a store
3875
+ * build must not go on with the key still in it.
3876
+ * @example
3877
+ * ```ts
3878
+ * removePlistKeys("<dict>\n\t<key>A</key>\n\t<dict/>\n\t<key>B</key>\n\t<true/>\n</dict>\n", ["A"]);
3879
+ * // "<dict>\n\t<key>B</key>\n\t<true/>\n</dict>\n"
3880
+ * ```
3881
+ */
3882
+ function removePlistKeys(existing, keys) {
3883
+ let text = existing;
3884
+ for (const key of keys) {
3885
+ const element = `<key>${key}</key>`;
3886
+ for (let start = text.indexOf(element); start !== -1; start = text.indexOf(element)) {
3887
+ const end = valueEnd(text, start + element.length);
3888
+ if (end === void 0) throw missingAnchorError(`the value of ${key}`, IOS_INFO_PLIST_FILE);
3889
+ text = cutRange(text, start, end);
3890
+ }
3891
+ }
3892
+ return text;
3893
+ }
3894
+ /**
3895
+ * Takes the debug keys out of the `Info.plist` of a kept iOS tree. Idempotent: a second pass
3896
+ * reports the file unchanged. A tree where tauri has not written the file reports nothing.
3897
+ *
3898
+ * @param projectDirectory - The Tauri project root.
3899
+ * @param genDirectory - The `src-tauri/gen/apple` directory.
3900
+ * @returns The paths patched vs. left unchanged.
3901
+ * @throws {Error} `[native]` when a debug key has no value after it.
3902
+ * @example
3903
+ * ```ts
3904
+ * await patchIosInfoPlist(projectDir, path.join(projectDir, "src-tauri/gen/apple"));
3905
+ * // { patched: [".../gen/apple/my-game_iOS/Info.plist"], unchanged: [] }
3906
+ * ```
3907
+ */
3908
+ async function patchIosInfoPlist(projectDirectory, genDirectory) {
3909
+ const patched = [];
3910
+ const unchanged = [];
3911
+ for (const file of await iosInfoPlistFiles(genDirectory)) (await writeIfChanged(file, removePlistKeys(await readFile(file, "utf8"), DEBUG_KEYS), projectDirectory) === "written" ? patched : unchanged).push(file);
3912
+ return {
3913
+ patched,
3914
+ unchanged
3915
+ };
3916
+ }
3917
+ //#endregion
3744
3918
  //#region src/plugins/project/mobile/manifest.ts
3745
3919
  /**
3746
3920
  * @file project plugin — the Android manifest patch. Tauri has no config key for what the
@@ -5598,8 +5772,9 @@ async function patchAndroidWindowBackground(projectDirectory, genDirectory, back
5598
5772
  * the orientation lock), `system-bars.ts` (the Android status bar icon style from
5599
5773
  * `app.backgroundColor`), `window-background.ts` (the Android window and icon-splash
5600
5774
  * background from the same colour), `runner.ts` (the Xcode / Android-Studio runner command),
5601
- * `xcode-settings.ts` (the iOS entitlements-modification setting that makes a REBUILD work)
5602
- * and `ios-project.ts` (the iOS deployment target and privacy manifest).
5775
+ * `xcode-settings.ts` (the iOS entitlements-modification setting that makes a REBUILD work),
5776
+ * `ios-project.ts` (the iOS deployment target and privacy manifest) and `ios-plist.ts` (the
5777
+ * debug keys a debug build left in the iOS `Info.plist`).
5603
5778
  */
5604
5779
  /** The profile of a pass whose caller names none: the store profile, warnings dropped. */
5605
5780
  const STORE_PROFILE = { profile: "store" };
@@ -5624,8 +5799,9 @@ function mergePatchResults(...results) {
5624
5799
  }
5625
5800
  /**
5626
5801
  * The iOS half of {@link patchMobile}: the Xcode entitlements-modification setting, the
5627
- * deployment target, the privacy manifest, then the runner command when the caller supplies
5628
- * a runner. A tree that was never initialised is left alone and reports nothing.
5802
+ * deployment target, the privacy manifest, outside the debug profile the removal of the debug
5803
+ * `Info.plist` keys, then the runner command when the caller supplies a runner. A tree that
5804
+ * was never initialised is left alone and reports nothing.
5629
5805
  *
5630
5806
  * @param options - What to patch.
5631
5807
  * @param options.projectDirectory - The Tauri project root.
@@ -5634,9 +5810,10 @@ function mergePatchResults(...results) {
5634
5810
  * @param options.minimumVersion - The iOS deployment target to write.
5635
5811
  * @param options.privacyManifest - `ios.privacyManifest`; unset removes one a previous pass
5636
5812
  * added.
5813
+ * @param options.profile - The build profile of this pass.
5637
5814
  * @returns The paths patched vs. left unchanged, merged over every patch.
5638
5815
  * @throws {Error} When the privacy manifest source is missing (before anything is written),
5639
- * or a project file lacks a line a patch needs.
5816
+ * a project file lacks a line a patch needs, or a debug key in `Info.plist` has no value.
5640
5817
  */
5641
5818
  async function patchIos(options) {
5642
5819
  const { projectDirectory, genDirectory, runner } = options;
@@ -5650,6 +5827,7 @@ async function patchIos(options) {
5650
5827
  await patchDeploymentTarget(projectDirectory, genDirectory, options.minimumVersion),
5651
5828
  await patchPrivacyManifest(projectDirectory, genDirectory, manifest)
5652
5829
  ];
5830
+ if (options.profile !== "debug") iosResults.push(await patchIosInfoPlist(projectDirectory, genDirectory));
5653
5831
  if (!runner) return mergePatchResults(...iosResults);
5654
5832
  const runnerResult = await patchRunner(projectDirectory, genDirectory, {
5655
5833
  target: "ios",
@@ -5708,20 +5886,23 @@ async function patchAndroid(options) {
5708
5886
  * byte, wherever the signing block sits. iOS gets the Xcode
5709
5887
  * entitlements-modification setting (without it the SECOND build of the same tree fails),
5710
5888
  * the deployment target and the privacy manifest (a kept tree never runs xcodegen again, so
5711
- * both land in `project.yml` AND `project.pbxproj`), then the runner command. The runner
5712
- * rewrite runs only when the caller supplies a `runner`. iOS takes no manifest entries, no
5713
- * background colour and no profile: its orientation lock and signing travel through the
5714
- * generated `Info.ios.plist` sidecar and tauri.conf.json, and its status bar adapts to the
5715
- * page on its own.
5889
+ * both land in `project.yml` AND `project.pbxproj`), outside the debug profile the removal of
5890
+ * the debug keys a debug build merged into `Info.plist`, then the runner command. The runner
5891
+ * rewrite runs only when the caller supplies a `runner`. iOS takes no manifest entries and no
5892
+ * background colour: its orientation lock and signing travel through the generated
5893
+ * `Info.ios.plist` sidecar and tauri.conf.json, and its status bar adapts to the page on its
5894
+ * own. Its profile is `opts.profile`, because `profile` below reads store for iOS.
5716
5895
  *
5717
5896
  * @param projectDirectory - The Tauri project root.
5718
- * @param opts - The mobile platform, and optionally the absolute Node/tauri.js runner pair.
5897
+ * @param opts - The mobile platform, optionally the absolute Node/tauri.js runner pair, and
5898
+ * the build profile, which iOS reads here; the store profile when omitted.
5719
5899
  * @param signing - The full signing config (`.android` on Android, the iOS minimum in
5720
5900
  * `.apple` on iOS).
5721
5901
  * @param manifest - Android manifest entries for the main activity (ignored on iOS).
5722
5902
  * @param backgroundColor - `app.backgroundColor`; the Android status bar icons, window
5723
5903
  * background and icon-splash background follow it (ignored on iOS).
5724
- * @param profile - The Android build profile; the store profile when omitted.
5904
+ * @param profile - The Android build profile, `dev` included as store; the store profile
5905
+ * when omitted (ignored on iOS).
5725
5906
  * @param privacyManifest - `ios.privacyManifest`, an absolute path; unset removes one a
5726
5907
  * previous pass added (ignored on Android).
5727
5908
  * @returns The paths patched vs. left unchanged, one merged report over every patch.
@@ -5730,8 +5911,8 @@ async function patchAndroid(options) {
5730
5911
  * written), manifest entries meet a missing manifest or an unclear main activity, a
5731
5912
  * background colour meets a tree without exactly one MainActivity.kt to style or without
5732
5913
  * the app theme to set the window background in; or when the iOS privacy manifest source
5733
- * is missing (before anything is written), or `project.yml` or `project.pbxproj` lacks a
5734
- * line a patch needs.
5914
+ * is missing (before anything is written), `project.yml` or `project.pbxproj` lacks a line
5915
+ * a patch needs, or a debug key in `Info.plist` has no value.
5735
5916
  */
5736
5917
  async function patchMobile(projectDirectory, opts, signing, manifest = [], backgroundColor, profile = STORE_PROFILE, privacyManifest) {
5737
5918
  const genDirectory = genDirectoryPath(projectDirectory, opts.target);
@@ -5740,7 +5921,8 @@ async function patchMobile(projectDirectory, opts, signing, manifest = [], backg
5740
5921
  genDirectory,
5741
5922
  runner: opts.runner,
5742
5923
  minimumVersion: signing.apple?.iosMinimumSystemVersion ?? "15.0",
5743
- privacyManifest
5924
+ privacyManifest,
5925
+ profile: opts.profile ?? "store"
5744
5926
  });
5745
5927
  return patchAndroid({
5746
5928
  projectDirectory,
@@ -6336,7 +6518,8 @@ function createProjectApi(ctx) {
6336
6518
  /**
6337
6519
  * Builds the Android profile one patch pass applies. The debug profile resolves the debug
6338
6520
  * keystore from `ctx.env` here (`HOME` ?? `USERPROFILE`), so the patch itself never reads
6339
- * the environment.
6521
+ * the environment. Every other case applies as store: the `dev` profile, and iOS, which reads
6522
+ * `opts.profile` itself.
6340
6523
  *
6341
6524
  * @param opts - See {@link Api.patchMobile}.
6342
6525
  * @returns The Android profile with its app name, keystore and log.
@@ -6356,7 +6539,7 @@ function createProjectApi(ctx) {
6356
6539
  /**
6357
6540
  * Implements {@link Api.patchMobile}: hands Android its build profile, its manifest
6358
6541
  * entries and `app.backgroundColor` (the status bar icons and the window background
6359
- * follow it), hands iOS `ios.privacyManifest`, then logs.
6542
+ * follow it), hands iOS `ios.privacyManifest` and its profile through `opts`, then logs.
6360
6543
  *
6361
6544
  * @param opts - See {@link Api.patchMobile}.
6362
6545
  * @returns See {@link Api.patchMobile}.
@@ -6367,7 +6550,7 @@ function createProjectApi(ctx) {
6367
6550
  const result = await patchMobile(ctx.global.projectDir, opts, ctx.global.signing, manifest, ctx.global.app.backgroundColor, profile, ctx.global.ios?.privacyManifest);
6368
6551
  ctx.log.info("project:patchMobile", {
6369
6552
  target: opts.target,
6370
- profile: profile.profile,
6553
+ profile: opts.profile ?? "store",
6371
6554
  patched: result.patched.length
6372
6555
  });
6373
6556
  return result;
@@ -8155,18 +8338,22 @@ const tauriPlugin = createPlugin$1("tauri", {
8155
8338
  //#endregion
8156
8339
  //#region src/plugins/build/phase.ts
8157
8340
  /**
8158
- * Picks the profile a build flavour asks for: `debug` set means the debug profile,
8159
- * anything else the store one.
8341
+ * Picks the profile a build flavour asks for: `debug` set means the debug profile, `dev` set
8342
+ * the dev one, anything else the store one. Both set name no profile and are refused here,
8343
+ * so every caller reads the refusal before its first phase.
8160
8344
  *
8161
8345
  * @param flavor - The build flavour of the run.
8162
- * @returns `"debug"` or `"store"`.
8346
+ * @returns `"debug"`, `"dev"` or `"store"`.
8347
+ * @throws {TypeError} `[native] debug and dev cannot be combined.` when both are set.
8163
8348
  * @example
8164
8349
  * ```ts
8165
- * profileOf({ debug: true }); // "debug"
8350
+ * profileOf({ dev: true }); // "dev"
8166
8351
  * ```
8167
8352
  */
8168
8353
  function profileOf(flavor) {
8169
- return flavor.debug === true ? "debug" : "store";
8354
+ if (flavor.debug === true && flavor.dev === true) throw new TypeError("[native] debug and dev cannot be combined.\n Build one profile: debug for the local app, dev for the store-signed test app.");
8355
+ if (flavor.debug === true) return "debug";
8356
+ return flavor.dev === true ? "dev" : "store";
8170
8357
  }
8171
8358
  /**
8172
8359
  * Emits one `native:phase` event, omitting `durationMs`/`detail` when absent rather than
@@ -8231,7 +8418,7 @@ function bundleRoot(projectDirectory, layout) {
8231
8418
  return path.join(projectDirectory, layout.root);
8232
8419
  }
8233
8420
  /**
8234
- * Names a build's delivery directory under `outDir`: the target for a store build,
8421
+ * Names a build's delivery directory under `outDir`: the target for a store or dev build,
8235
8422
  * `<target>-debug` for a debug one — so a debug installer never overwrites the store one.
8236
8423
  *
8237
8424
  * @param target - The packaging target being collected.
@@ -8463,8 +8650,9 @@ function storeAgentRefusal(dist, file) {
8463
8650
  /**
8464
8651
  * The checks at the end of compile/bundle, before anything is collected: on android the
8465
8652
  * shell link (the project plugin decides whether the profile composes the shell), then the
8466
- * page — a store build whose page carries the editor agent is refused. They run after the
8467
- * full compile because tauri runs the web build inside `tauri build`.
8653
+ * page — a store build whose page carries the editor agent is refused; a debug or dev build
8654
+ * may carry it. They run after the full compile because tauri runs the web build inside
8655
+ * `tauri build`.
8468
8656
  *
8469
8657
  * @param ctx - The build pipeline's domain context.
8470
8658
  * @param deps - The resolved project/tauri APIs.
@@ -8800,23 +8988,24 @@ function incompleteMobileTreeError(target, missing) {
8800
8988
  return /* @__PURE__ */ new Error(`[native] ${target} project tree is incomplete.\n Missing ${missing.join(", ")} — run \`native doctor\` to diagnose, or \`native clean --target ${target}\` to reset before rebuilding.`);
8801
8989
  }
8802
8990
  /**
8803
- * Refuses the debug profile for every target but android (Decision D2) — before any phase
8804
- * runs, and for ALL the targets of a run at once, so nothing is half-built.
8991
+ * Refuses the debug profile for every target but android and ios (Decision D2, widened to
8992
+ * iOS by F133) — before any phase runs, and for ALL the targets of a run at once, so nothing
8993
+ * is half-built.
8805
8994
  *
8806
8995
  * @param targets - Every target the run will build.
8807
8996
  * @param flavor - The build flavour of the run.
8808
- * @throws {Error} `[native] --debug builds Android only for now (asked for <target>).` for
8809
- * the first target that is not android, when `debug` is set.
8997
+ * @throws {Error} `[native] --debug builds Android and iOS only for now (asked for <target>).`
8998
+ * for the first target that is neither, when `debug` is set.
8810
8999
  * @example
8811
9000
  * ```ts
8812
- * assertDebugTargets(["android", "ios"], { debug: true }); // throws: asked for ios
9001
+ * assertDebugTargets(["android", "macos"], { debug: true }); // throws: asked for macos
8813
9002
  * ```
8814
9003
  */
8815
9004
  function assertDebugTargets(targets, flavor) {
8816
9005
  if (flavor.debug !== true) return;
8817
- const refused = targets.find((target) => target !== "android");
9006
+ const refused = targets.find((target) => !isMobileTarget(target));
8818
9007
  if (refused === void 0) return;
8819
- throw new Error(`[native] --debug builds Android only for now (asked for ${refused}).\n Build the debug profile for android, or drop debug to build ${refused}.`);
9008
+ throw new Error(`[native] --debug builds Android and iOS only for now (asked for ${refused}).\n Build the debug profile for android or ios, or drop debug to build ${refused}.`);
8820
9009
  }
8821
9010
  /**
8822
9011
  * Runs the `scaffold` phase: ensures `projectDir` exists. Nothing else — the mobile
@@ -8945,19 +9134,20 @@ async function runPrepare(ctx, deps, target, profile = "store") {
8945
9134
  * Runs the full `scaffold → codegen → icons → compile → bundle → collect` pipeline for
8946
9135
  * ONE target — sequential phases, each timed and reported via `native:phase`, stopping at
8947
9136
  * the first failing phase. Emits `native:complete` on success, with the run's profile. A
8948
- * debug run on any target but android is refused before the first phase.
9137
+ * debug run on any target but android and ios, and a run asking for `debug` and `dev`
9138
+ * together, are refused before the first phase.
8949
9139
  *
8950
9140
  * @param ctx - The build pipeline's domain context.
8951
9141
  * @param deps - The resolved project/tauri APIs.
8952
- * @param opts - The target plus the platform build flags (`simulator`, `aab`, `debug`).
9142
+ * @param opts - The target plus the platform build flags (`simulator`, `aab`, `debug`, `dev`).
8953
9143
  * @returns The completed pipeline's result, with all six phase timings and the profile.
8954
9144
  * @throws {Error} Whatever the failing phase throws (already reported via native:phase), or
8955
- * the debug-target refusal (before any phase event).
9145
+ * the debug-target or `debug` + `dev` refusal (before any phase event).
8956
9146
  */
8957
9147
  async function runPipeline(ctx, deps, opts) {
8958
9148
  const { target } = opts;
8959
- assertDebugTargets([target], opts);
8960
9149
  const profile = profileOf(opts);
9150
+ assertDebugTargets([target], opts);
8961
9151
  const startedAt = performance.now();
8962
9152
  const phases = [...await runPrepare(ctx, deps, target, profile)];
8963
9153
  const { compileDurationMs, bundleDurationMs } = await runCompileAndBundle(ctx, deps, opts);
@@ -8972,6 +9162,7 @@ async function runPipeline(ctx, deps, opts) {
8972
9162
  simulator: opts.simulator,
8973
9163
  aab: opts.aab,
8974
9164
  debug: opts.debug,
9165
+ dev: opts.dev,
8975
9166
  resolvePath: deps.project.resolveDerivedPath
8976
9167
  }));
8977
9168
  phases.push({
@@ -9044,13 +9235,15 @@ function createBuildApi(ctx, deps) {
9044
9235
  */
9045
9236
  async runAll(opts = {}) {
9046
9237
  const targets = opts.targets ?? ctx.global.targets;
9238
+ profileOf(opts);
9047
9239
  assertDebugTargets(targets, opts);
9048
9240
  const results = [];
9049
9241
  for (const target of targets) results.push(await runPipeline(ctx, deps, {
9050
9242
  target,
9051
9243
  simulator: opts.simulator,
9052
9244
  aab: opts.aab,
9053
- debug: opts.debug
9245
+ debug: opts.debug,
9246
+ dev: opts.dev
9054
9247
  }));
9055
9248
  return results;
9056
9249
  }
@@ -10951,13 +11144,14 @@ function createCliApi(ctx, deps) {
10951
11144
  * @returns See {@link Api.build}.
10952
11145
  */
10953
11146
  async build(opts = {}) {
10954
- const { simulator, aab, debug } = opts;
11147
+ const { simulator, aab, debug, dev } = opts;
10955
11148
  try {
10956
11149
  if (opts.all) {
10957
11150
  await build.runAll({
10958
11151
  simulator,
10959
11152
  aab,
10960
- debug
11153
+ debug,
11154
+ dev
10961
11155
  });
10962
11156
  return;
10963
11157
  }
@@ -10965,7 +11159,8 @@ function createCliApi(ctx, deps) {
10965
11159
  target: opts.target ?? hostTarget(),
10966
11160
  simulator,
10967
11161
  aab,
10968
- debug
11162
+ debug,
11163
+ dev
10969
11164
  });
10970
11165
  } catch (error) {
10971
11166
  renderBuildFailure(ui, error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moku-labs/native",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "description": "Node-only native packager framework for Moku — generates a gitignored Tauri project, codegens capabilities/Info.plist/AndroidManifest from composed system plugins, and runs tauri build.",
5
5
  "license": "MIT",
6
6
  "type": "module",