@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/README.md +50 -13
- package/dist/index.cjs +365 -66
- package/dist/index.d.cts +126 -37
- package/dist/index.d.mts +126 -37
- package/dist/index.mjs +366 -67
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -821,7 +821,8 @@ function generateCapabilities(input) {
|
|
|
821
821
|
//#region src/plugins/project/generators/cargo.ts
|
|
822
822
|
/**
|
|
823
823
|
* @file project plugin generator — Cargo.toml with registry-pinned crate dependencies, the
|
|
824
|
-
* path dependency of every generated local crate,
|
|
824
|
+
* path dependency of every generated local crate, the iOS debug `devtools` feature, and the
|
|
825
|
+
* size profile of a release build.
|
|
825
826
|
*/
|
|
826
827
|
/**
|
|
827
828
|
* The `tauri` crate floor. The `back` capability calls `exit()` and grants
|
|
@@ -836,7 +837,7 @@ const TAURI_VERSION_FLOOR = "2.12";
|
|
|
836
837
|
*/
|
|
837
838
|
const IOS_ONLY_DEPENDENCIES = [`[target.'cfg(target_os = "ios")'.dependencies]`, "objc2 = \"0.6\""];
|
|
838
839
|
/**
|
|
839
|
-
* The release profile, for every target and
|
|
840
|
+
* The release profile, for every target and every build profile: the debug build is a
|
|
840
841
|
* release build too, so what a phone measures is what the store ships. It trades compile
|
|
841
842
|
* time for a smaller library, and `panic = "abort"` drops the unwinding tables.
|
|
842
843
|
*/
|
|
@@ -849,6 +850,12 @@ const RELEASE_PROFILE = [
|
|
|
849
850
|
"strip = true"
|
|
850
851
|
];
|
|
851
852
|
/**
|
|
853
|
+
* The `tauri` feature an iOS debug build adds. The debug build is a release build, and a
|
|
854
|
+
* release build compiles the inspector only with it: the window's `devtools` flag alone does
|
|
855
|
+
* nothing there.
|
|
856
|
+
*/
|
|
857
|
+
const IOS_DEBUG_FEATURE = "devtools";
|
|
858
|
+
/**
|
|
852
859
|
* Derives a valid Cargo package name from the app's display name — lowercased,
|
|
853
860
|
* non-alphanumeric runs collapsed to a single hyphen, and guaranteed to start with a
|
|
854
861
|
* letter (Cargo package names must match `[a-z][a-z0-9_-]*`).
|
|
@@ -905,9 +912,9 @@ function dependencyLine(capability) {
|
|
|
905
912
|
* every cargo feature the composed capabilities ask for (tray's `tray-icon`; without it
|
|
906
913
|
* the tray API is not compiled in at all), plus one dependency line per resolved
|
|
907
914
|
* capability that ships a crate: pinned for a published one, by path for the generated
|
|
908
|
-
* shell crate. Feature-only and permission-only rows contribute no dependency line.
|
|
909
|
-
* `[profile.release]` table follows, and
|
|
910
|
-
* every target.
|
|
915
|
+
* shell crate. Feature-only and permission-only rows contribute no dependency line. An iOS
|
|
916
|
+
* debug build adds `devtools` to those features. The `[profile.release]` table follows, and
|
|
917
|
+
* the iOS-only `objc2` table closes the file on every target.
|
|
911
918
|
*
|
|
912
919
|
* @param input - Frozen global config + capabilities resolved for the target.
|
|
913
920
|
* @returns A single-artifact array for `src-tauri/Cargo.toml`.
|
|
@@ -915,7 +922,9 @@ function dependencyLine(capability) {
|
|
|
915
922
|
function generateCargo(input) {
|
|
916
923
|
const packageName = sanitizePackageName(input.global.app.name);
|
|
917
924
|
const pinnedDeps = input.capabilities.map((capability) => dependencyLine(capability)).filter((line) => line !== void 0).toSorted();
|
|
918
|
-
const
|
|
925
|
+
const iosDebug = input.target === "ios" && input.profile === "debug";
|
|
926
|
+
const requested = input.capabilities.flatMap((capability) => capability.cargoFeatures);
|
|
927
|
+
const features = [.../* @__PURE__ */ new Set([...requested, ...iosDebug ? [IOS_DEBUG_FEATURE] : []])].toSorted().map((feature) => `"${feature}"`).join(", ");
|
|
919
928
|
return [{
|
|
920
929
|
path: "src-tauri/Cargo.toml",
|
|
921
930
|
content: [
|
|
@@ -1703,7 +1712,7 @@ class MokuShellPlugin(private val activity: Activity) : Plugin(activity) {
|
|
|
1703
1712
|
`;
|
|
1704
1713
|
/**
|
|
1705
1714
|
* Renders `MokuShellProfile.kt`: the one per-profile file of the module. The debug profile
|
|
1706
|
-
* turns on WebView debugging and `share`; the store
|
|
1715
|
+
* turns on WebView debugging and `share`; the store and dev profiles turn both off.
|
|
1707
1716
|
*
|
|
1708
1717
|
* @param profile - The build profile the crate is generated for.
|
|
1709
1718
|
* @returns The Kotlin source.
|
|
@@ -1946,8 +1955,8 @@ const CONTRACT_BODY = String.raw` var MAX_SHARE_BYTES = 32 * 1024 * 1024;
|
|
|
1946
1955
|
}, noop);`;
|
|
1947
1956
|
/**
|
|
1948
1957
|
* Builds the page contract script for one app and profile. The build profile and id are
|
|
1949
|
-
* baked in at generate time: the store
|
|
1950
|
-
* `"<app.version>+<app.buildNumber ?? 0>"`, with `"-debug"` in the debug profile. A second
|
|
1958
|
+
* baked in at generate time: the store and dev profiles read `"release"` on the page, and the
|
|
1959
|
+
* id is `"<app.version>+<app.buildNumber ?? 0>"`, with `"-debug"` in the debug profile. A second
|
|
1951
1960
|
* run of the script in the same frame is a no-op.
|
|
1952
1961
|
*
|
|
1953
1962
|
* @param input - The generator input (target, app version and build number).
|
|
@@ -2127,11 +2136,14 @@ function escapeXml(text) {
|
|
|
2127
2136
|
}
|
|
2128
2137
|
//#endregion
|
|
2129
2138
|
//#region src/plugins/project/generators/sidecar.ts
|
|
2130
|
-
/**
|
|
2131
|
-
* @file project plugin generator — Info.ios.plist sidecar (src-tauri root, outside gen/).
|
|
2132
|
-
*/
|
|
2133
2139
|
/** One indentation step of the generated plist. */
|
|
2134
2140
|
const PLIST_INDENT = " ";
|
|
2141
|
+
/** The key of the sentence iOS shows when it asks to reach the local network. */
|
|
2142
|
+
const LOCAL_NETWORK_USAGE_KEY = "NSLocalNetworkUsageDescription";
|
|
2143
|
+
/** The key of App Transport Security, which refuses `ws://` to the editor by default. */
|
|
2144
|
+
const APP_TRANSPORT_SECURITY_KEY = "NSAppTransportSecurity";
|
|
2145
|
+
/** The sentence iOS shows when an iOS debug build first reaches for the editor. */
|
|
2146
|
+
const LOCAL_NETWORK_USAGE = "This debug build talks to the editor on your local network.";
|
|
2135
2147
|
/**
|
|
2136
2148
|
* Tells a plist `<array>` from a `<dict>`: `Array.isArray` alone does not narrow a readonly
|
|
2137
2149
|
* array.
|
|
@@ -2191,11 +2203,35 @@ function renderPlistValue(value, indent) {
|
|
|
2191
2203
|
];
|
|
2192
2204
|
}
|
|
2193
2205
|
/**
|
|
2206
|
+
* Lists what the debug profile needs to reach the editor from an iPhone: the local-network
|
|
2207
|
+
* sentence, and App Transport Security opened for the local network alone. Every other
|
|
2208
|
+
* profile adds nothing, and the iOS patch pass takes both keys out of a kept tree again
|
|
2209
|
+
* (`mobile/ios-plist.ts`).
|
|
2210
|
+
*
|
|
2211
|
+
* @param profile - The build profile being generated for.
|
|
2212
|
+
* @returns The two entries in the debug profile, otherwise none.
|
|
2213
|
+
* @example
|
|
2214
|
+
* ```ts
|
|
2215
|
+
* debugPlist("store"); // []
|
|
2216
|
+
* ```
|
|
2217
|
+
*/
|
|
2218
|
+
function debugPlist(profile) {
|
|
2219
|
+
if (profile !== "debug") return [];
|
|
2220
|
+
return [{
|
|
2221
|
+
key: LOCAL_NETWORK_USAGE_KEY,
|
|
2222
|
+
value: LOCAL_NETWORK_USAGE
|
|
2223
|
+
}, {
|
|
2224
|
+
key: APP_TRANSPORT_SECURITY_KEY,
|
|
2225
|
+
value: { NSAllowsLocalNetworking: true }
|
|
2226
|
+
}];
|
|
2227
|
+
}
|
|
2228
|
+
/**
|
|
2194
2229
|
* Generates the `Info.ios.plist` SIDECAR at the src-tauri root, which Tauri merges into the
|
|
2195
2230
|
* app's Info.plist on every iOS build. Its entries are every resolved capability's
|
|
2196
|
-
* `sidecarPlist`, then `ios.infoPlist`, then the
|
|
2197
|
-
* duplicate key the later entry wins, so the app's keys beat a
|
|
2198
|
-
* beats
|
|
2231
|
+
* `sidecarPlist`, then `ios.infoPlist`, then the debug profile's two keys, then the orientation
|
|
2232
|
+
* lock (`app.orientation`); on a duplicate key the later entry wins, so the app's keys beat a
|
|
2233
|
+
* capability, the debug keys beat a game's own in that profile only, and orientation beats
|
|
2234
|
+
* them all.
|
|
2199
2235
|
*
|
|
2200
2236
|
* On iOS the file is ALWAYS written, as an empty `<dict>` when nothing contributes a key:
|
|
2201
2237
|
* the writer never deletes a file, and a portrait lock left in a stale sidecar would keep
|
|
@@ -2221,6 +2257,7 @@ function generateSidecar(input) {
|
|
|
2221
2257
|
key,
|
|
2222
2258
|
value
|
|
2223
2259
|
})),
|
|
2260
|
+
...debugPlist(input.profile),
|
|
2224
2261
|
...orientationPlist(input.global.app.orientation)
|
|
2225
2262
|
];
|
|
2226
2263
|
for (const entry of contributed) entries.set(entry.key, entry.value);
|
|
@@ -2241,8 +2278,9 @@ function generateSidecar(input) {
|
|
|
2241
2278
|
//#endregion
|
|
2242
2279
|
//#region src/plugins/project/generators/tauri-conf.ts
|
|
2243
2280
|
/**
|
|
2244
|
-
* @file project plugin generator — tauri.conf.json (identity, build wiring,
|
|
2245
|
-
* metadata, Apple signing, the Android
|
|
2281
|
+
* @file project plugin generator — tauri.conf.json (identity, build wiring, the main
|
|
2282
|
+
* window with its iOS debug inspector, bundle metadata, Apple signing, the Android
|
|
2283
|
+
* versionCode, plugin blocks).
|
|
2246
2284
|
*/
|
|
2247
2285
|
/**
|
|
2248
2286
|
* The icon set `tauri icon` writes into `src-tauri/icons`. Tauri reads `bundle.icon` at
|
|
@@ -2377,9 +2415,11 @@ function buildPlugins(capabilities) {
|
|
|
2377
2415
|
}
|
|
2378
2416
|
/**
|
|
2379
2417
|
* Generates `src-tauri/tauri.conf.json` — app identity, the web build/dev wiring, with
|
|
2380
|
-
* `removeUnusedCommands` in the store profile only (a debug page may call what a
|
|
2381
|
-
* page does not), the main window (its title, plus `app.backgroundColor` when set
|
|
2382
|
-
*
|
|
2418
|
+
* `removeUnusedCommands` in the store profile only (a debug or dev page may call what a
|
|
2419
|
+
* store page does not), the main window (its title, plus `app.backgroundColor` when set, and
|
|
2420
|
+
* `devtools` in an iOS debug build, so Safari Web Inspector can attach: the debug build is a
|
|
2421
|
+
* release build, where Tauri closes the inspector), the bundle/signing metadata, and a
|
|
2422
|
+
* `plugins.<name>` block per CONFIGURED capability (see
|
|
2383
2423
|
* {@link buildPlugins}; this is where deep-link's scheme rides — per D-011/D-012 the whole
|
|
2384
2424
|
* v1 mobile-permission story is conf-only). Both path-shaped fields are rebased onto
|
|
2385
2425
|
* `src-tauri`, which is where Tauri resolves them from, and the before-commands carry an
|
|
@@ -2397,6 +2437,7 @@ function buildPlugins(capabilities) {
|
|
|
2397
2437
|
function generateTauriConf(input) {
|
|
2398
2438
|
const { global, capabilities } = input;
|
|
2399
2439
|
const webRoot = node_path.default.resolve(global.web.cwd ?? ".");
|
|
2440
|
+
const inspectable = input.target === "ios" && input.profile === "debug";
|
|
2400
2441
|
const conf = {
|
|
2401
2442
|
productName: global.app.name,
|
|
2402
2443
|
identifier: global.app.identifier,
|
|
@@ -2416,7 +2457,8 @@ function generateTauriConf(input) {
|
|
|
2416
2457
|
},
|
|
2417
2458
|
app: { windows: [{
|
|
2418
2459
|
title: global.app.name,
|
|
2419
|
-
...compact([["backgroundColor", global.app.backgroundColor]])
|
|
2460
|
+
...compact([["backgroundColor", global.app.backgroundColor]]),
|
|
2461
|
+
...inspectable ? { devtools: true } : {}
|
|
2420
2462
|
}] },
|
|
2421
2463
|
bundle: buildBundle(input),
|
|
2422
2464
|
plugins: buildPlugins(capabilities)
|
|
@@ -2725,9 +2767,9 @@ async function writeIfChanged(filePath, content, projectDirectory) {
|
|
|
2725
2767
|
* the iOS project patches) reads the same list from here, so none can drift into a file the
|
|
2726
2768
|
* others do not know about — and none ever descends into `gen/apple/build` or
|
|
2727
2769
|
* `gen/android/build`, which belong to the toolchain. The privacy manifest's place in the
|
|
2728
|
-
* tree is here too. The Android status bar patch finds its
|
|
2729
|
-
* patches their `strings.xml` and network security config,
|
|
2730
|
-
* icon directory.
|
|
2770
|
+
* tree is here too, and so is the app's `Info.plist`. The Android status bar patch finds its
|
|
2771
|
+
* MainActivity.kt here, the profile patches their `strings.xml` and network security config,
|
|
2772
|
+
* and the icon inset its adaptive icon directory.
|
|
2731
2773
|
*/
|
|
2732
2774
|
/** Source extensions that can carry the Android runner command. */
|
|
2733
2775
|
const ANDROID_SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
@@ -2759,6 +2801,10 @@ const SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
|
2759
2801
|
]);
|
|
2760
2802
|
/** The file name Apple reads a privacy manifest from, at the top of the app bundle. */
|
|
2761
2803
|
const IOS_PRIVACY_MANIFEST_FILE = "PrivacyInfo.xcprivacy";
|
|
2804
|
+
/** How the directory of the app's own files ends in `gen/apple`: `<slug>_iOS`. */
|
|
2805
|
+
const IOS_APP_DIRECTORY_SUFFIX = "_iOS";
|
|
2806
|
+
/** The file name of the app's property list, in that directory. */
|
|
2807
|
+
const IOS_INFO_PLIST_FILE = "Info.plist";
|
|
2762
2808
|
/**
|
|
2763
2809
|
* Lists the generated iOS files a patch pass may rewrite: `project.yml` plus the
|
|
2764
2810
|
* `project.pbxproj` of every generated Xcode project. `gen/apple/build` is never listed —
|
|
@@ -2783,6 +2829,22 @@ async function iosPatchFiles(genDirectory) {
|
|
|
2783
2829
|
return files;
|
|
2784
2830
|
}
|
|
2785
2831
|
/**
|
|
2832
|
+
* Lists the `Info.plist` of the generated iOS app, the file `tauri ios build` merges the
|
|
2833
|
+
* sidecar into: in the `gen/apple` directory that ends in `_iOS`. A tree where tauri has not
|
|
2834
|
+
* written it yet lists nothing.
|
|
2835
|
+
*
|
|
2836
|
+
* @param genDirectory - The `src-tauri/gen/apple` directory.
|
|
2837
|
+
* @returns The existing files, possibly none.
|
|
2838
|
+
* @example
|
|
2839
|
+
* ```ts
|
|
2840
|
+
* await iosInfoPlistFiles("/repo/.moku/tauri/src-tauri/gen/apple");
|
|
2841
|
+
* // ["/repo/.moku/tauri/src-tauri/gen/apple/my-game_iOS/Info.plist"]
|
|
2842
|
+
* ```
|
|
2843
|
+
*/
|
|
2844
|
+
async function iosInfoPlistFiles(genDirectory) {
|
|
2845
|
+
return (await (0, node_fs_promises.readdir)(genDirectory, { withFileTypes: true })).filter((entry) => entry.isDirectory() && entry.name.endsWith(IOS_APP_DIRECTORY_SUFFIX)).map((entry) => node_path.default.join(genDirectory, entry.name, IOS_INFO_PLIST_FILE)).filter((file) => (0, node_fs.existsSync)(file));
|
|
2846
|
+
}
|
|
2847
|
+
/**
|
|
2786
2848
|
* Returns where the iOS patch pass keeps the privacy manifest: the top of `gen/apple`, the
|
|
2787
2849
|
* directory `project.yml` and the pbxproj's root group resolve a relative path from.
|
|
2788
2850
|
*
|
|
@@ -2986,6 +3048,90 @@ async function patchAndroidIcon(options) {
|
|
|
2986
3048
|
};
|
|
2987
3049
|
}
|
|
2988
3050
|
//#endregion
|
|
3051
|
+
//#region src/plugins/project/mobile/identity.ts
|
|
3052
|
+
/**
|
|
3053
|
+
* @file project plugin — the app id a `gen/android` tree was initialised for, and setting a
|
|
3054
|
+
* tree aside when that id is not the configured one. `tauri android init` bakes the id into
|
|
3055
|
+
* the namespace, the `applicationId` and the Kotlin package path; a kept tree never runs
|
|
3056
|
+
* init again, so a changed `app.identifier` would otherwise build against the old package.
|
|
3057
|
+
*/
|
|
3058
|
+
/** The key of the `applicationId = "<id>"` line; the debug suffix is a separate line. */
|
|
3059
|
+
const APPLICATION_ID_KEY = "applicationId";
|
|
3060
|
+
/**
|
|
3061
|
+
* Reads the `applicationId` a `gen/android` tree was initialised for. Only a quoted literal
|
|
3062
|
+
* is recognised, the form `tauri android init` writes; an expression reads as no id.
|
|
3063
|
+
*
|
|
3064
|
+
* @param genDirectory - The absolute `src-tauri/gen/android` directory.
|
|
3065
|
+
* @returns The id, or undefined when `app/build.gradle.kts` is absent or names no literal id.
|
|
3066
|
+
* @example
|
|
3067
|
+
* ```ts
|
|
3068
|
+
* readAndroidApplicationId("/repo/.moku/tauri/src-tauri/gen/android"); // "com.acme.demo"
|
|
3069
|
+
* ```
|
|
3070
|
+
*/
|
|
3071
|
+
function readAndroidApplicationId(genDirectory) {
|
|
3072
|
+
const gradlePath = node_path.default.join(genDirectory, "app", "build.gradle.kts");
|
|
3073
|
+
if (!(0, node_fs.existsSync)(gradlePath)) return void 0;
|
|
3074
|
+
for (const line of (0, node_fs.readFileSync)(gradlePath, "utf8").split("\n")) {
|
|
3075
|
+
const [key, value] = line.split("=", 2).map((part) => part.trim());
|
|
3076
|
+
if (key === APPLICATION_ID_KEY && value?.startsWith("\"")) return value.split("\"")[1];
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
/**
|
|
3080
|
+
* Compares two Android ids the way Tauri writes them: a `-` may come out as `_`.
|
|
3081
|
+
*
|
|
3082
|
+
* @param left - One id.
|
|
3083
|
+
* @param right - The other id.
|
|
3084
|
+
* @returns Whether both name the same app.
|
|
3085
|
+
*/
|
|
3086
|
+
function sameAndroidId(left, right) {
|
|
3087
|
+
return left.replaceAll("-", "_") === right.replaceAll("-", "_");
|
|
3088
|
+
}
|
|
3089
|
+
/**
|
|
3090
|
+
* Picks the first free `<genDirectory>.old-<id>` path, then `-2`, `-3`, … so an earlier
|
|
3091
|
+
* set-aside tree is never overwritten.
|
|
3092
|
+
*
|
|
3093
|
+
* @param genDirectory - The tree being set aside.
|
|
3094
|
+
* @param found - The id it was initialised for.
|
|
3095
|
+
* @returns A path that does not exist yet.
|
|
3096
|
+
*/
|
|
3097
|
+
function freeAsidePath(genDirectory, found) {
|
|
3098
|
+
const base = `${genDirectory}.old-${found}`;
|
|
3099
|
+
let candidate = base;
|
|
3100
|
+
let n = 1;
|
|
3101
|
+
while ((0, node_fs.existsSync)(candidate)) {
|
|
3102
|
+
n += 1;
|
|
3103
|
+
candidate = `${base}-${n}`;
|
|
3104
|
+
}
|
|
3105
|
+
return candidate;
|
|
3106
|
+
}
|
|
3107
|
+
/**
|
|
3108
|
+
* Moves a `gen/android` tree aside when it was initialised for another app id, so the next
|
|
3109
|
+
* `tauri android init` writes a fresh one. The tree is renamed, never deleted: it may hold a
|
|
3110
|
+
* keystore or hand edits. A tree whose id cannot be read is left to the completeness gate.
|
|
3111
|
+
*
|
|
3112
|
+
* @param options - The check options.
|
|
3113
|
+
* @param options.genDirectory - The absolute `src-tauri/gen/android` directory.
|
|
3114
|
+
* @param options.identifier - The configured `app.identifier`.
|
|
3115
|
+
* @returns What was found and where it went, or undefined when the tree was kept.
|
|
3116
|
+
* @example
|
|
3117
|
+
* ```ts
|
|
3118
|
+
* await setAsideStaleAndroidTree({ genDirectory, identifier: "studio.kitto.memorymissing" });
|
|
3119
|
+
* // { found: "com.mokulabs.memorymissing", expected: "studio.kitto.memorymissing",
|
|
3120
|
+
* // movedTo: ".../gen/android.old-com.mokulabs.memorymissing" }
|
|
3121
|
+
* ```
|
|
3122
|
+
*/
|
|
3123
|
+
async function setAsideStaleAndroidTree(options) {
|
|
3124
|
+
const found = readAndroidApplicationId(options.genDirectory);
|
|
3125
|
+
if (found === void 0 || sameAndroidId(found, options.identifier)) return void 0;
|
|
3126
|
+
const movedTo = freeAsidePath(options.genDirectory, found);
|
|
3127
|
+
await (0, node_fs_promises.rename)(options.genDirectory, movedTo);
|
|
3128
|
+
return {
|
|
3129
|
+
found,
|
|
3130
|
+
expected: options.identifier,
|
|
3131
|
+
movedTo
|
|
3132
|
+
};
|
|
3133
|
+
}
|
|
3134
|
+
//#endregion
|
|
2989
3135
|
//#region src/plugins/project/mobile/xcode-settings.ts
|
|
2990
3136
|
/**
|
|
2991
3137
|
* @file project plugin — the Xcode build-settings patch that makes an iOS REBUILD work.
|
|
@@ -3768,6 +3914,118 @@ async function patchPrivacyManifest(projectDirectory, genDirectory, manifest) {
|
|
|
3768
3914
|
};
|
|
3769
3915
|
}
|
|
3770
3916
|
//#endregion
|
|
3917
|
+
//#region src/plugins/project/mobile/ios-plist.ts
|
|
3918
|
+
/**
|
|
3919
|
+
* @file project plugin — the iOS `Info.plist` patch: takes the debug keys out of a kept tree.
|
|
3920
|
+
*
|
|
3921
|
+
* `tauri ios build` merges `Info.ios.plist` INTO `gen/apple/<slug>_iOS/Info.plist` for good
|
|
3922
|
+
* (measured with tauri-cli 2.11.4), so a key dropped from the sidecar stays in that file: a
|
|
3923
|
+
* store build of a tree that once built in debug would ship the loosened App Transport
|
|
3924
|
+
* Security. Outside the debug profile this pass removes both debug keys; the sidecar merge
|
|
3925
|
+
* after it restores whatever the game itself asked for.
|
|
3926
|
+
*
|
|
3927
|
+
* The transform is a pure text function over the shape the plist crate writes: line endings
|
|
3928
|
+
* and every neighbouring line survive byte for byte, and a file without the keys comes back
|
|
3929
|
+
* untouched. That crate escapes every value and writes no comment, so a `<` is always a tag.
|
|
3930
|
+
*/
|
|
3931
|
+
/** The keys only a debug build may carry, the ones `generators/sidecar.ts` adds there. */
|
|
3932
|
+
const DEBUG_KEYS = [LOCAL_NETWORK_USAGE_KEY, APP_TRANSPORT_SECURITY_KEY];
|
|
3933
|
+
/** Every element tag of a plist. Group 1 marks a closing tag, group 2 a self-closed one. */
|
|
3934
|
+
const TAG_PATTERN = /<(\/?)[a-z][^<>]*?(\/?)>/gi;
|
|
3935
|
+
/**
|
|
3936
|
+
* Finds where the plist value that starts after `from` ends, walking its depth: a `<dict>`
|
|
3937
|
+
* may hold more of them, and a `<dict/>` opens nothing.
|
|
3938
|
+
*
|
|
3939
|
+
* @param text - The file content.
|
|
3940
|
+
* @param from - The index right after the value's `<key>` element.
|
|
3941
|
+
* @returns The index after the value, or undefined when no value follows.
|
|
3942
|
+
* @example
|
|
3943
|
+
* ```ts
|
|
3944
|
+
* valueEnd("<key>K</key><dict><dict/></dict>", 12); // 32
|
|
3945
|
+
* ```
|
|
3946
|
+
*/
|
|
3947
|
+
function valueEnd(text, from) {
|
|
3948
|
+
let depth = 0;
|
|
3949
|
+
for (const match of text.slice(from).matchAll(TAG_PATTERN)) {
|
|
3950
|
+
const [tag, closing, selfClosed] = match;
|
|
3951
|
+
if (depth === 0 && tag === "<key>") return void 0;
|
|
3952
|
+
if (closing) depth -= 1;
|
|
3953
|
+
else if (!selfClosed) depth += 1;
|
|
3954
|
+
if (depth === 0) return from + match.index + tag.length;
|
|
3955
|
+
if (depth < 0) return void 0;
|
|
3956
|
+
}
|
|
3957
|
+
}
|
|
3958
|
+
/**
|
|
3959
|
+
* Cuts a range out of a text: the whole lines when the range is alone on them, so no blank
|
|
3960
|
+
* line stays behind and the file keeps its line endings, otherwise the range only.
|
|
3961
|
+
*
|
|
3962
|
+
* @param text - The file content.
|
|
3963
|
+
* @param start - The index of the range's first character.
|
|
3964
|
+
* @param end - The index after its last character.
|
|
3965
|
+
* @returns The text without the range.
|
|
3966
|
+
* @example
|
|
3967
|
+
* ```ts
|
|
3968
|
+
* cutRange("a\n\tb\nc\n", 3, 4); // "a\nc\n"
|
|
3969
|
+
* ```
|
|
3970
|
+
*/
|
|
3971
|
+
function cutRange(text, start, end) {
|
|
3972
|
+
const lineStart = text.lastIndexOf("\n", start) + 1;
|
|
3973
|
+
const lineBreak = text.indexOf("\n", end);
|
|
3974
|
+
const lineEnd = lineBreak === -1 ? text.length : lineBreak + 1;
|
|
3975
|
+
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);
|
|
3976
|
+
}
|
|
3977
|
+
/**
|
|
3978
|
+
* Removes keys and their values from the text of an XML property list. A value is whatever
|
|
3979
|
+
* element follows the `<key>`, however deep it nests. Content without the keys comes back
|
|
3980
|
+
* byte-identical, so the writer leaves the file alone.
|
|
3981
|
+
*
|
|
3982
|
+
* @param existing - The current `Info.plist` content.
|
|
3983
|
+
* @param keys - The keys to remove.
|
|
3984
|
+
* @returns The content without those keys.
|
|
3985
|
+
* @throws {Error} `[native]` when a key has no value after it: the file is broken, and a store
|
|
3986
|
+
* build must not go on with the key still in it.
|
|
3987
|
+
* @example
|
|
3988
|
+
* ```ts
|
|
3989
|
+
* removePlistKeys("<dict>\n\t<key>A</key>\n\t<dict/>\n\t<key>B</key>\n\t<true/>\n</dict>\n", ["A"]);
|
|
3990
|
+
* // "<dict>\n\t<key>B</key>\n\t<true/>\n</dict>\n"
|
|
3991
|
+
* ```
|
|
3992
|
+
*/
|
|
3993
|
+
function removePlistKeys(existing, keys) {
|
|
3994
|
+
let text = existing;
|
|
3995
|
+
for (const key of keys) {
|
|
3996
|
+
const element = `<key>${key}</key>`;
|
|
3997
|
+
for (let start = text.indexOf(element); start !== -1; start = text.indexOf(element)) {
|
|
3998
|
+
const end = valueEnd(text, start + element.length);
|
|
3999
|
+
if (end === void 0) throw missingAnchorError(`the value of ${key}`, IOS_INFO_PLIST_FILE);
|
|
4000
|
+
text = cutRange(text, start, end);
|
|
4001
|
+
}
|
|
4002
|
+
}
|
|
4003
|
+
return text;
|
|
4004
|
+
}
|
|
4005
|
+
/**
|
|
4006
|
+
* Takes the debug keys out of the `Info.plist` of a kept iOS tree. Idempotent: a second pass
|
|
4007
|
+
* reports the file unchanged. A tree where tauri has not written the file reports nothing.
|
|
4008
|
+
*
|
|
4009
|
+
* @param projectDirectory - The Tauri project root.
|
|
4010
|
+
* @param genDirectory - The `src-tauri/gen/apple` directory.
|
|
4011
|
+
* @returns The paths patched vs. left unchanged.
|
|
4012
|
+
* @throws {Error} `[native]` when a debug key has no value after it.
|
|
4013
|
+
* @example
|
|
4014
|
+
* ```ts
|
|
4015
|
+
* await patchIosInfoPlist(projectDir, path.join(projectDir, "src-tauri/gen/apple"));
|
|
4016
|
+
* // { patched: [".../gen/apple/my-game_iOS/Info.plist"], unchanged: [] }
|
|
4017
|
+
* ```
|
|
4018
|
+
*/
|
|
4019
|
+
async function patchIosInfoPlist(projectDirectory, genDirectory) {
|
|
4020
|
+
const patched = [];
|
|
4021
|
+
const unchanged = [];
|
|
4022
|
+
for (const file of await iosInfoPlistFiles(genDirectory)) (await writeIfChanged(file, removePlistKeys(await (0, node_fs_promises.readFile)(file, "utf8"), DEBUG_KEYS), projectDirectory) === "written" ? patched : unchanged).push(file);
|
|
4023
|
+
return {
|
|
4024
|
+
patched,
|
|
4025
|
+
unchanged
|
|
4026
|
+
};
|
|
4027
|
+
}
|
|
4028
|
+
//#endregion
|
|
3771
4029
|
//#region src/plugins/project/mobile/manifest.ts
|
|
3772
4030
|
/**
|
|
3773
4031
|
* @file project plugin — the Android manifest patch. Tauri has no config key for what the
|
|
@@ -5625,8 +5883,9 @@ async function patchAndroidWindowBackground(projectDirectory, genDirectory, back
|
|
|
5625
5883
|
* the orientation lock), `system-bars.ts` (the Android status bar icon style from
|
|
5626
5884
|
* `app.backgroundColor`), `window-background.ts` (the Android window and icon-splash
|
|
5627
5885
|
* background from the same colour), `runner.ts` (the Xcode / Android-Studio runner command),
|
|
5628
|
-
* `xcode-settings.ts` (the iOS entitlements-modification setting that makes a REBUILD work)
|
|
5629
|
-
*
|
|
5886
|
+
* `xcode-settings.ts` (the iOS entitlements-modification setting that makes a REBUILD work),
|
|
5887
|
+
* `ios-project.ts` (the iOS deployment target and privacy manifest) and `ios-plist.ts` (the
|
|
5888
|
+
* debug keys a debug build left in the iOS `Info.plist`).
|
|
5630
5889
|
*/
|
|
5631
5890
|
/** The profile of a pass whose caller names none: the store profile, warnings dropped. */
|
|
5632
5891
|
const STORE_PROFILE = { profile: "store" };
|
|
@@ -5651,8 +5910,9 @@ function mergePatchResults(...results) {
|
|
|
5651
5910
|
}
|
|
5652
5911
|
/**
|
|
5653
5912
|
* The iOS half of {@link patchMobile}: the Xcode entitlements-modification setting, the
|
|
5654
|
-
* deployment target, the privacy manifest,
|
|
5655
|
-
*
|
|
5913
|
+
* deployment target, the privacy manifest, outside the debug profile the removal of the debug
|
|
5914
|
+
* `Info.plist` keys, then the runner command when the caller supplies a runner. A tree that
|
|
5915
|
+
* was never initialised is left alone and reports nothing.
|
|
5656
5916
|
*
|
|
5657
5917
|
* @param options - What to patch.
|
|
5658
5918
|
* @param options.projectDirectory - The Tauri project root.
|
|
@@ -5661,9 +5921,10 @@ function mergePatchResults(...results) {
|
|
|
5661
5921
|
* @param options.minimumVersion - The iOS deployment target to write.
|
|
5662
5922
|
* @param options.privacyManifest - `ios.privacyManifest`; unset removes one a previous pass
|
|
5663
5923
|
* added.
|
|
5924
|
+
* @param options.profile - The build profile of this pass.
|
|
5664
5925
|
* @returns The paths patched vs. left unchanged, merged over every patch.
|
|
5665
5926
|
* @throws {Error} When the privacy manifest source is missing (before anything is written),
|
|
5666
|
-
*
|
|
5927
|
+
* a project file lacks a line a patch needs, or a debug key in `Info.plist` has no value.
|
|
5667
5928
|
*/
|
|
5668
5929
|
async function patchIos(options) {
|
|
5669
5930
|
const { projectDirectory, genDirectory, runner } = options;
|
|
@@ -5677,6 +5938,7 @@ async function patchIos(options) {
|
|
|
5677
5938
|
await patchDeploymentTarget(projectDirectory, genDirectory, options.minimumVersion),
|
|
5678
5939
|
await patchPrivacyManifest(projectDirectory, genDirectory, manifest)
|
|
5679
5940
|
];
|
|
5941
|
+
if (options.profile !== "debug") iosResults.push(await patchIosInfoPlist(projectDirectory, genDirectory));
|
|
5680
5942
|
if (!runner) return mergePatchResults(...iosResults);
|
|
5681
5943
|
const runnerResult = await patchRunner(projectDirectory, genDirectory, {
|
|
5682
5944
|
target: "ios",
|
|
@@ -5735,20 +5997,23 @@ async function patchAndroid(options) {
|
|
|
5735
5997
|
* byte, wherever the signing block sits. iOS gets the Xcode
|
|
5736
5998
|
* entitlements-modification setting (without it the SECOND build of the same tree fails),
|
|
5737
5999
|
* the deployment target and the privacy manifest (a kept tree never runs xcodegen again, so
|
|
5738
|
-
* both land in `project.yml` AND `project.pbxproj`),
|
|
5739
|
-
*
|
|
5740
|
-
*
|
|
5741
|
-
*
|
|
5742
|
-
* page on its
|
|
6000
|
+
* both land in `project.yml` AND `project.pbxproj`), outside the debug profile the removal of
|
|
6001
|
+
* the debug keys a debug build merged into `Info.plist`, then the runner command. The runner
|
|
6002
|
+
* rewrite runs only when the caller supplies a `runner`. iOS takes no manifest entries and no
|
|
6003
|
+
* background colour: its orientation lock and signing travel through the generated
|
|
6004
|
+
* `Info.ios.plist` sidecar and tauri.conf.json, and its status bar adapts to the page on its
|
|
6005
|
+
* own. Its profile is `opts.profile`, because `profile` below reads store for iOS.
|
|
5743
6006
|
*
|
|
5744
6007
|
* @param projectDirectory - The Tauri project root.
|
|
5745
|
-
* @param opts - The mobile platform,
|
|
6008
|
+
* @param opts - The mobile platform, optionally the absolute Node/tauri.js runner pair, and
|
|
6009
|
+
* the build profile, which iOS reads here; the store profile when omitted.
|
|
5746
6010
|
* @param signing - The full signing config (`.android` on Android, the iOS minimum in
|
|
5747
6011
|
* `.apple` on iOS).
|
|
5748
6012
|
* @param manifest - Android manifest entries for the main activity (ignored on iOS).
|
|
5749
6013
|
* @param backgroundColor - `app.backgroundColor`; the Android status bar icons, window
|
|
5750
6014
|
* background and icon-splash background follow it (ignored on iOS).
|
|
5751
|
-
* @param profile - The Android build profile; the store profile
|
|
6015
|
+
* @param profile - The Android build profile, `dev` included as store; the store profile
|
|
6016
|
+
* when omitted (ignored on iOS).
|
|
5752
6017
|
* @param privacyManifest - `ios.privacyManifest`, an absolute path; unset removes one a
|
|
5753
6018
|
* previous pass added (ignored on Android).
|
|
5754
6019
|
* @returns The paths patched vs. left unchanged, one merged report over every patch.
|
|
@@ -5757,8 +6022,8 @@ async function patchAndroid(options) {
|
|
|
5757
6022
|
* written), manifest entries meet a missing manifest or an unclear main activity, a
|
|
5758
6023
|
* background colour meets a tree without exactly one MainActivity.kt to style or without
|
|
5759
6024
|
* the app theme to set the window background in; or when the iOS privacy manifest source
|
|
5760
|
-
* is missing (before anything is written),
|
|
5761
|
-
*
|
|
6025
|
+
* is missing (before anything is written), `project.yml` or `project.pbxproj` lacks a line
|
|
6026
|
+
* a patch needs, or a debug key in `Info.plist` has no value.
|
|
5762
6027
|
*/
|
|
5763
6028
|
async function patchMobile(projectDirectory, opts, signing, manifest = [], backgroundColor, profile = STORE_PROFILE, privacyManifest) {
|
|
5764
6029
|
const genDirectory = genDirectoryPath(projectDirectory, opts.target);
|
|
@@ -5767,7 +6032,8 @@ async function patchMobile(projectDirectory, opts, signing, manifest = [], backg
|
|
|
5767
6032
|
genDirectory,
|
|
5768
6033
|
runner: opts.runner,
|
|
5769
6034
|
minimumVersion: signing.apple?.iosMinimumSystemVersion ?? "15.0",
|
|
5770
|
-
privacyManifest
|
|
6035
|
+
privacyManifest,
|
|
6036
|
+
profile: opts.profile ?? "store"
|
|
5771
6037
|
});
|
|
5772
6038
|
return patchAndroid({
|
|
5773
6039
|
projectDirectory,
|
|
@@ -6361,9 +6627,27 @@ function createProjectApi(ctx) {
|
|
|
6361
6627
|
*/
|
|
6362
6628
|
const checkCompleteness = (opts) => completeness(ctx.global.projectDir, opts.target);
|
|
6363
6629
|
/**
|
|
6630
|
+
* Implements {@link Api.setAsideStaleTree}: Android only, one plain warn line when a tree
|
|
6631
|
+
* was moved.
|
|
6632
|
+
*
|
|
6633
|
+
* @param opts - See {@link Api.setAsideStaleTree}.
|
|
6634
|
+
* @param opts.target - The mobile platform whose tree to check.
|
|
6635
|
+
* @returns See {@link Api.setAsideStaleTree}.
|
|
6636
|
+
*/
|
|
6637
|
+
const runSetAsideStaleTree = async (opts) => {
|
|
6638
|
+
if (opts.target !== "android") return void 0;
|
|
6639
|
+
const aside = await setAsideStaleAndroidTree({
|
|
6640
|
+
genDirectory: genDirectoryPath(ctx.global.projectDir, opts.target),
|
|
6641
|
+
identifier: ctx.global.app.identifier
|
|
6642
|
+
});
|
|
6643
|
+
if (aside !== void 0) ctx.log.warn(`gen/android was made for ${aside.found}, not ${aside.expected}: moved it to ${node_path.default.basename(aside.movedTo)} and generating it again`);
|
|
6644
|
+
return aside;
|
|
6645
|
+
};
|
|
6646
|
+
/**
|
|
6364
6647
|
* Builds the Android profile one patch pass applies. The debug profile resolves the debug
|
|
6365
6648
|
* keystore from `ctx.env` here (`HOME` ?? `USERPROFILE`), so the patch itself never reads
|
|
6366
|
-
* the environment.
|
|
6649
|
+
* the environment. Every other case applies as store: the `dev` profile, and iOS, which reads
|
|
6650
|
+
* `opts.profile` itself.
|
|
6367
6651
|
*
|
|
6368
6652
|
* @param opts - See {@link Api.patchMobile}.
|
|
6369
6653
|
* @returns The Android profile with its app name, keystore and log.
|
|
@@ -6383,7 +6667,7 @@ function createProjectApi(ctx) {
|
|
|
6383
6667
|
/**
|
|
6384
6668
|
* Implements {@link Api.patchMobile}: hands Android its build profile, its manifest
|
|
6385
6669
|
* entries and `app.backgroundColor` (the status bar icons and the window background
|
|
6386
|
-
* follow it), hands iOS `ios.privacyManifest`, then logs.
|
|
6670
|
+
* follow it), hands iOS `ios.privacyManifest` and its profile through `opts`, then logs.
|
|
6387
6671
|
*
|
|
6388
6672
|
* @param opts - See {@link Api.patchMobile}.
|
|
6389
6673
|
* @returns See {@link Api.patchMobile}.
|
|
@@ -6394,7 +6678,7 @@ function createProjectApi(ctx) {
|
|
|
6394
6678
|
const result = await patchMobile(ctx.global.projectDir, opts, ctx.global.signing, manifest, ctx.global.app.backgroundColor, profile, ctx.global.ios?.privacyManifest);
|
|
6395
6679
|
ctx.log.info("project:patchMobile", {
|
|
6396
6680
|
target: opts.target,
|
|
6397
|
-
profile:
|
|
6681
|
+
profile: opts.profile ?? "store",
|
|
6398
6682
|
patched: result.patched.length
|
|
6399
6683
|
});
|
|
6400
6684
|
return result;
|
|
@@ -6506,6 +6790,7 @@ function createProjectApi(ctx) {
|
|
|
6506
6790
|
generate: generateArtifacts,
|
|
6507
6791
|
getBundleLayout,
|
|
6508
6792
|
getCompleteness: checkCompleteness,
|
|
6793
|
+
setAsideStaleTree: runSetAsideStaleTree,
|
|
6509
6794
|
patchMobile: runPatchMobile,
|
|
6510
6795
|
patchMobileIcons: runPatchMobileIcons,
|
|
6511
6796
|
detectPageAgent: runDetectPageAgent,
|
|
@@ -8182,18 +8467,22 @@ const tauriPlugin = createPlugin$1("tauri", {
|
|
|
8182
8467
|
//#endregion
|
|
8183
8468
|
//#region src/plugins/build/phase.ts
|
|
8184
8469
|
/**
|
|
8185
|
-
* Picks the profile a build flavour asks for: `debug` set means the debug profile,
|
|
8186
|
-
* anything else the store one.
|
|
8470
|
+
* Picks the profile a build flavour asks for: `debug` set means the debug profile, `dev` set
|
|
8471
|
+
* the dev one, anything else the store one. Both set name no profile and are refused here,
|
|
8472
|
+
* so every caller reads the refusal before its first phase.
|
|
8187
8473
|
*
|
|
8188
8474
|
* @param flavor - The build flavour of the run.
|
|
8189
|
-
* @returns `"debug"` or `"store"`.
|
|
8475
|
+
* @returns `"debug"`, `"dev"` or `"store"`.
|
|
8476
|
+
* @throws {TypeError} `[native] debug and dev cannot be combined.` when both are set.
|
|
8190
8477
|
* @example
|
|
8191
8478
|
* ```ts
|
|
8192
|
-
* profileOf({
|
|
8479
|
+
* profileOf({ dev: true }); // "dev"
|
|
8193
8480
|
* ```
|
|
8194
8481
|
*/
|
|
8195
8482
|
function profileOf(flavor) {
|
|
8196
|
-
|
|
8483
|
+
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.");
|
|
8484
|
+
if (flavor.debug === true) return "debug";
|
|
8485
|
+
return flavor.dev === true ? "dev" : "store";
|
|
8197
8486
|
}
|
|
8198
8487
|
/**
|
|
8199
8488
|
* Emits one `native:phase` event, omitting `durationMs`/`detail` when absent rather than
|
|
@@ -8258,7 +8547,7 @@ function bundleRoot(projectDirectory, layout) {
|
|
|
8258
8547
|
return node_path.default.join(projectDirectory, layout.root);
|
|
8259
8548
|
}
|
|
8260
8549
|
/**
|
|
8261
|
-
* Names a build's delivery directory under `outDir`: the target for a store build,
|
|
8550
|
+
* Names a build's delivery directory under `outDir`: the target for a store or dev build,
|
|
8262
8551
|
* `<target>-debug` for a debug one — so a debug installer never overwrites the store one.
|
|
8263
8552
|
*
|
|
8264
8553
|
* @param target - The packaging target being collected.
|
|
@@ -8490,8 +8779,9 @@ function storeAgentRefusal(dist, file) {
|
|
|
8490
8779
|
/**
|
|
8491
8780
|
* The checks at the end of compile/bundle, before anything is collected: on android the
|
|
8492
8781
|
* shell link (the project plugin decides whether the profile composes the shell), then the
|
|
8493
|
-
* page — a store build whose page carries the editor agent is refused
|
|
8494
|
-
* full compile because tauri runs the web build inside
|
|
8782
|
+
* page — a store build whose page carries the editor agent is refused; a debug or dev build
|
|
8783
|
+
* may carry it. They run after the full compile because tauri runs the web build inside
|
|
8784
|
+
* `tauri build`.
|
|
8495
8785
|
*
|
|
8496
8786
|
* @param ctx - The build pipeline's domain context.
|
|
8497
8787
|
* @param deps - The resolved project/tauri APIs.
|
|
@@ -8827,23 +9117,24 @@ function incompleteMobileTreeError(target, missing) {
|
|
|
8827
9117
|
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.`);
|
|
8828
9118
|
}
|
|
8829
9119
|
/**
|
|
8830
|
-
* Refuses the debug profile for every target but android (Decision D2
|
|
8831
|
-
* runs, and for ALL the targets of a run at once, so nothing
|
|
9120
|
+
* Refuses the debug profile for every target but android and ios (Decision D2, widened to
|
|
9121
|
+
* iOS by F133) — before any phase runs, and for ALL the targets of a run at once, so nothing
|
|
9122
|
+
* is half-built.
|
|
8832
9123
|
*
|
|
8833
9124
|
* @param targets - Every target the run will build.
|
|
8834
9125
|
* @param flavor - The build flavour of the run.
|
|
8835
|
-
* @throws {Error} `[native] --debug builds Android only for now (asked for <target>).`
|
|
8836
|
-
* the first target that is
|
|
9126
|
+
* @throws {Error} `[native] --debug builds Android and iOS only for now (asked for <target>).`
|
|
9127
|
+
* for the first target that is neither, when `debug` is set.
|
|
8837
9128
|
* @example
|
|
8838
9129
|
* ```ts
|
|
8839
|
-
* assertDebugTargets(["android", "
|
|
9130
|
+
* assertDebugTargets(["android", "macos"], { debug: true }); // throws: asked for macos
|
|
8840
9131
|
* ```
|
|
8841
9132
|
*/
|
|
8842
9133
|
function assertDebugTargets(targets, flavor) {
|
|
8843
9134
|
if (flavor.debug !== true) return;
|
|
8844
|
-
const refused = targets.find((target) => target
|
|
9135
|
+
const refused = targets.find((target) => !isMobileTarget(target));
|
|
8845
9136
|
if (refused === void 0) return;
|
|
8846
|
-
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}.`);
|
|
9137
|
+
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}.`);
|
|
8847
9138
|
}
|
|
8848
9139
|
/**
|
|
8849
9140
|
* Runs the `scaffold` phase: ensures `projectDir` exists. Nothing else — the mobile
|
|
@@ -8858,7 +9149,8 @@ async function runScaffold(ctx) {
|
|
|
8858
9149
|
}
|
|
8859
9150
|
/**
|
|
8860
9151
|
* Runs the `codegen` phase — `project.generate()` first (mobile init needs the generated
|
|
8861
|
-
* `tauri.conf.json`), then for a mobile target:
|
|
9152
|
+
* `tauri.conf.json`), then for a mobile target: a tree initialised for another app id is
|
|
9153
|
+
* set aside (`project.setAsideStaleTree()`), `tauri.mobileInit()` when the `gen/` tree
|
|
8862
9154
|
* is absent, the completeness gate (a partial tree fails fast, never silently
|
|
8863
9155
|
* re-initialized), and the idempotent `project.patchMobile()` pass carrying
|
|
8864
9156
|
* `tauri.getRunner()` — Tauri's own generated build phase calls a `node tauri` command
|
|
@@ -8877,6 +9169,7 @@ async function runCodegen(ctx, deps, target, profile = "store") {
|
|
|
8877
9169
|
profile
|
|
8878
9170
|
});
|
|
8879
9171
|
if (!isMobileTarget(target)) return { mobileInitRan: false };
|
|
9172
|
+
await deps.project.setAsideStaleTree({ target });
|
|
8880
9173
|
let status = deps.project.getCompleteness({ target });
|
|
8881
9174
|
let mobileInitRan = false;
|
|
8882
9175
|
if (status.status === "not-initialized") {
|
|
@@ -8972,19 +9265,20 @@ async function runPrepare(ctx, deps, target, profile = "store") {
|
|
|
8972
9265
|
* Runs the full `scaffold → codegen → icons → compile → bundle → collect` pipeline for
|
|
8973
9266
|
* ONE target — sequential phases, each timed and reported via `native:phase`, stopping at
|
|
8974
9267
|
* the first failing phase. Emits `native:complete` on success, with the run's profile. A
|
|
8975
|
-
* debug run on any target but android
|
|
9268
|
+
* debug run on any target but android and ios, and a run asking for `debug` and `dev`
|
|
9269
|
+
* together, are refused before the first phase.
|
|
8976
9270
|
*
|
|
8977
9271
|
* @param ctx - The build pipeline's domain context.
|
|
8978
9272
|
* @param deps - The resolved project/tauri APIs.
|
|
8979
|
-
* @param opts - The target plus the platform build flags (`simulator`, `aab`, `debug`).
|
|
9273
|
+
* @param opts - The target plus the platform build flags (`simulator`, `aab`, `debug`, `dev`).
|
|
8980
9274
|
* @returns The completed pipeline's result, with all six phase timings and the profile.
|
|
8981
9275
|
* @throws {Error} Whatever the failing phase throws (already reported via native:phase), or
|
|
8982
|
-
* the debug-target refusal (before any phase event).
|
|
9276
|
+
* the debug-target or `debug` + `dev` refusal (before any phase event).
|
|
8983
9277
|
*/
|
|
8984
9278
|
async function runPipeline(ctx, deps, opts) {
|
|
8985
9279
|
const { target } = opts;
|
|
8986
|
-
assertDebugTargets([target], opts);
|
|
8987
9280
|
const profile = profileOf(opts);
|
|
9281
|
+
assertDebugTargets([target], opts);
|
|
8988
9282
|
const startedAt = performance.now();
|
|
8989
9283
|
const phases = [...await runPrepare(ctx, deps, target, profile)];
|
|
8990
9284
|
const { compileDurationMs, bundleDurationMs } = await runCompileAndBundle(ctx, deps, opts);
|
|
@@ -8999,6 +9293,7 @@ async function runPipeline(ctx, deps, opts) {
|
|
|
8999
9293
|
simulator: opts.simulator,
|
|
9000
9294
|
aab: opts.aab,
|
|
9001
9295
|
debug: opts.debug,
|
|
9296
|
+
dev: opts.dev,
|
|
9002
9297
|
resolvePath: deps.project.resolveDerivedPath
|
|
9003
9298
|
}));
|
|
9004
9299
|
phases.push({
|
|
@@ -9071,13 +9366,15 @@ function createBuildApi(ctx, deps) {
|
|
|
9071
9366
|
*/
|
|
9072
9367
|
async runAll(opts = {}) {
|
|
9073
9368
|
const targets = opts.targets ?? ctx.global.targets;
|
|
9369
|
+
profileOf(opts);
|
|
9074
9370
|
assertDebugTargets(targets, opts);
|
|
9075
9371
|
const results = [];
|
|
9076
9372
|
for (const target of targets) results.push(await runPipeline(ctx, deps, {
|
|
9077
9373
|
target,
|
|
9078
9374
|
simulator: opts.simulator,
|
|
9079
9375
|
aab: opts.aab,
|
|
9080
|
-
debug: opts.debug
|
|
9376
|
+
debug: opts.debug,
|
|
9377
|
+
dev: opts.dev
|
|
9081
9378
|
}));
|
|
9082
9379
|
return results;
|
|
9083
9380
|
}
|
|
@@ -10978,13 +11275,14 @@ function createCliApi(ctx, deps) {
|
|
|
10978
11275
|
* @returns See {@link Api.build}.
|
|
10979
11276
|
*/
|
|
10980
11277
|
async build(opts = {}) {
|
|
10981
|
-
const { simulator, aab, debug } = opts;
|
|
11278
|
+
const { simulator, aab, debug, dev } = opts;
|
|
10982
11279
|
try {
|
|
10983
11280
|
if (opts.all) {
|
|
10984
11281
|
await build.runAll({
|
|
10985
11282
|
simulator,
|
|
10986
11283
|
aab,
|
|
10987
|
-
debug
|
|
11284
|
+
debug,
|
|
11285
|
+
dev
|
|
10988
11286
|
});
|
|
10989
11287
|
return;
|
|
10990
11288
|
}
|
|
@@ -10992,7 +11290,8 @@ function createCliApi(ctx, deps) {
|
|
|
10992
11290
|
target: opts.target ?? hostTarget(),
|
|
10993
11291
|
simulator,
|
|
10994
11292
|
aab,
|
|
10995
|
-
debug
|
|
11293
|
+
debug,
|
|
11294
|
+
dev
|
|
10996
11295
|
});
|
|
10997
11296
|
} catch (error) {
|
|
10998
11297
|
renderBuildFailure(ui, error);
|