@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/README.md +62 -13
- package/dist/index.cjs +2620 -1678
- package/dist/index.d.cts +138 -52
- package/dist/index.d.mts +138 -52
- package/dist/index.mjs +2620 -1678
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
<br/>
|
|
16
16
|
|
|
17
|
-
[Quick start](#quick-start) · [Two apps, one contract](#two-apps-one-contract) · [Plugins](#plugins) · [Configuration](#configuration) · [Signing and store builds](#signing-and-store-builds) · [Debug builds](#debug-builds-
|
|
17
|
+
[Quick start](#quick-start) · [Two apps, one contract](#two-apps-one-contract) · [Plugins](#plugins) · [Configuration](#configuration) · [Signing and store builds](#signing-and-store-builds) · [Debug builds](#debug-builds) · [Dev profile](#dev-profile) · [iOS simulator](#ios-simulator) · [Events](#events) · [Docs](#docs)
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
@@ -175,10 +175,11 @@ The substantive surface is **global** `Config` — every plugin reads it via `ct
|
|
|
175
175
|
| `app.version` | `string?` | unset → `"0.1.0"` | Marketing version. |
|
|
176
176
|
| `app.icon` | `string?` | unset | 1024×1024 PNG, relative to cwd. Unset → a placeholder PNG is generated. |
|
|
177
177
|
| `app.category` | `string?` | unset | Store category → `bundle.category`. |
|
|
178
|
-
| `app.buildNumber` | `string?` | unset | Store build number → `bundle.{iOS,macOS}.bundleVersion
|
|
178
|
+
| `app.buildNumber` | `string?` | unset | Store build number → `bundle.{iOS,macOS}.bundleVersion`, and on an android build `bundle.android.versionCode`, as a number. Android refuses anything but a whole number from 1 to 2100000000, at generate; `"1.0.3"` stays legal elsewhere. |
|
|
179
179
|
| `app.orientation` | `"portrait" \| "landscape" \| "any"` | unset (= `"any"`) | Build-time mobile orientation lock → `UISupportedInterfaceOrientations` (+ `~ipad`, `UIRequiresFullScreen`) in `Info.ios.plist`, `android:screenOrientation` on the Android main activity. No runtime lock. |
|
|
180
180
|
| `app.backgroundColor` | `string?` | unset | Hex window colour (`"#10161d"`, `"#10161dff"`) → `app.windows[0].backgroundColor`. Shows during launch and behind any gap the page does not cover. On Android it also paints the activity window and the Android 12+ icon splash, so no dark frame shows between the icon splash and the page's first paint; the status bar icons follow it: light on a dark colour, dark on a light one. |
|
|
181
181
|
| `app.adaptiveIconInset` | `number?` | unset | Android adaptive icon inset, percent per side of the 108 dp canvas (`0 < n ≤ 30`, validated at composition). Wraps the launcher foreground in an `<inset>` so full-bleed art survives the mask; `19.44` keeps it inside the 66 dp safe zone. Re-applied after `tauri icon` on every Android build; unset leaves the icon untouched. |
|
|
182
|
+
| `app.keepScreenOn` | `boolean?` | unset | iOS: the app turns the idle timer off at launch, because iOS refuses `navigator.wakeLock` until the first tap. Android keeps the screen on from the page. |
|
|
182
183
|
| `web.build` | `string` | `"bun run build"` | Runs before a build, in `web.cwd`. |
|
|
183
184
|
| `web.devCommand` | `string` | `"bun run dev"` | Runs before `dev`, in `web.cwd`. |
|
|
184
185
|
| `web.devUrl` | `string` | `"http://localhost:5173"` | Dev server URL — also the `DevHandle.url` and the readiness-poll target. |
|
|
@@ -189,9 +190,11 @@ The substantive surface is **global** `Config` — every plugin reads it via `ct
|
|
|
189
190
|
| `targets` | `readonly Target[]` | `hostTargets(process.platform)` | The host's own desktop target (`darwin`→`macos`, `win32`→`windows`, `linux`→`linux`). **Mobile is opt-in**: name `ios`/`android` explicitly. |
|
|
190
191
|
| `projectDir` | `string` | `".moku/tauri"` | Generated Tauri project root (contains `src-tauri/`). Gitignored build output. |
|
|
191
192
|
| `outDir` | `string` | `"dist-native"` | Installer delivery root — `collect` copies finished artifacts to `outDir/<target>/`. |
|
|
192
|
-
| `signing.apple` | `AppleSigning?` | unset | `teamId`, `signingIdentity`, `providerShortName`, `entitlements`, `appStore`, `exportMethod`, `macosMinimumSystemVersion`, `iosMinimumSystemVersion` (default `"15.0"`: Tauri's own 14.0 is refused by Xcode 27) — see [Signing and store builds](#signing-and-store-builds). |
|
|
193
|
+
| `signing.apple` | `AppleSigning?` | unset | `teamId`, `signingIdentity`, `providerShortName`, `entitlements`, `appStore`, `exportMethod`, `macosMinimumSystemVersion`, `iosMinimumSystemVersion` (default `"15.0"`: Tauri's own 14.0 is refused by Xcode 27; a kept iOS tree follows it) — see [Signing and store builds](#signing-and-store-builds). |
|
|
193
194
|
| `signing.android` | `{ keystorePath?, keystorePasswordEnv?, keyPasswordEnv?, keyAlias? }` | unset | Env-var **names**, never secrets. `keyPasswordEnv` falls back to `keystorePasswordEnv`. |
|
|
194
195
|
| `signing.windows` | `{ certificateThumbprint? }` | unset | Windows signing certificate thumbprint. |
|
|
196
|
+
| `ios.infoPlist` | `Readonly<Record<string, PlistValue>>?` | unset | Keys merged into `Info.plist` through `Info.ios.plist`, nested dictionaries and arrays included. They beat a capability; `app.orientation` beats them. |
|
|
197
|
+
| `ios.privacyManifest` | `string?` | unset | Absolute path of the file the bundle carries as `PrivacyInfo.xcprivacy`. Unset, a manifest an earlier build left in the generated tree is removed. |
|
|
195
198
|
|
|
196
199
|
Per-plugin knobs, overridable via `createApp({ pluginConfigs })`:
|
|
197
200
|
|
|
@@ -266,16 +269,23 @@ What each piece does:
|
|
|
266
269
|
> [!NOTE]
|
|
267
270
|
> **Unsigned dev builds and iOS simulator builds need none of this.** `doctor`'s signing check is warn-only for exactly that reason — a missing credential never fails a build, and never flips `report.ok`.
|
|
268
271
|
|
|
269
|
-
|
|
272
|
+
What the generated project adds for a store:
|
|
273
|
+
|
|
274
|
+
- **A smaller library.** Every `Cargo.toml` carries a `[profile.release]` table (`codegen-units = 1`, `lto = true`, `opt-level = "s"`, `panic = "abort"`, `strip = true`), on every target and in every build profile. It costs compile time.
|
|
275
|
+
- **No unused commands.** A store build sets `build.removeUnusedCommands: true` in `tauri.conf.json`. A debug or dev build leaves it out.
|
|
276
|
+
- **An Android `versionCode`.** An android build with `app.buildNumber` writes it to `bundle.android.versionCode`, as a number.
|
|
277
|
+
- **`Info.plist` keys and a privacy manifest.** `ios.infoPlist` and `ios.privacyManifest`, see [Configuration](#configuration).
|
|
278
|
+
|
|
279
|
+
## Debug builds
|
|
270
280
|
|
|
271
281
|
```ts
|
|
272
282
|
await native.cli.build({ target: "android", debug: true });
|
|
273
283
|
// debug build → dist-native/android-debug/
|
|
274
284
|
```
|
|
275
285
|
|
|
276
|
-
`debug: true` (on `cli.build`, `build.run`, `build.runAll` and `build.prepare`) builds the **debug profile**: an on-device test build that is still a *release* build type — Rust and Gradle optimized, so what you measure on the phone is what the store app does
|
|
286
|
+
`debug: true` (on `cli.build`, `build.run`, `build.runAll` and `build.prepare`) builds the **debug profile**: an on-device test build that is still a *release* build type — Rust and Gradle optimized, so what you measure on the phone is what the store app does. On Android it is marked so it can never be mistaken for the store app, and installed **beside** it rather than over it:
|
|
277
287
|
|
|
278
|
-
| | Debug profile | Store profile (default) |
|
|
288
|
+
| Android | Debug profile | Store profile (default) |
|
|
279
289
|
|---|---|---|
|
|
280
290
|
| Application id | `<app.identifier>.debug` (`applicationIdSuffix`) | `app.identifier` |
|
|
281
291
|
| Launcher name | `<app.name> (debug)` | `app.name` |
|
|
@@ -285,16 +295,26 @@ await native.cli.build({ target: "android", debug: true });
|
|
|
285
295
|
| Page | `__MOKU_NATIVE__.build.profile === "debug"`, `console.*` also forwarded to logcat under the tag `moku-page`, WebView debugging on, `share` present | `build.profile === "release"`, none of these |
|
|
286
296
|
| Delivered to | `<outDir>/android-debug/` | `<outDir>/android/` |
|
|
287
297
|
|
|
288
|
-
Every debug patch is idempotent, and the next store build reverts each one to the bytes the tree had before. The run's profile also reaches your web build: the tauri CLI is spawned with `MOKU_NATIVE_PROFILE` (`"store"` or `"
|
|
298
|
+
Every debug patch is idempotent, and the next store or dev build reverts each one to the bytes the tree had before. The run's profile also reaches your web build: the tauri CLI is spawned with `MOKU_NATIVE_PROFILE` (`"store"`, `"debug"` or `"dev"`) in its environment, and tauri runs `web.build` inside `tauri build`. `BuildResult.profile` and `native:complete`'s `profile` carry the same value, and `cli` marks the delivery as `debug build → <outPath>`.
|
|
299
|
+
|
|
300
|
+
**iOS works too**, and there native renames nothing. The debug profile opens the page to the local network and to Safari, and that is all it adds:
|
|
301
|
+
|
|
302
|
+
| iOS | What the debug profile adds |
|
|
303
|
+
|---|---|
|
|
304
|
+
| `NSLocalNetworkUsageDescription` | The local-network prompt, in `Info.ios.plist`, after your `ios.infoPlist` keys. |
|
|
305
|
+
| `NSAppTransportSecurity` | `{ NSAllowsLocalNetworking: true }`, so `ws://` reaches a machine on the LAN. It replaces your own `NSAppTransportSecurity`, in this profile only. |
|
|
306
|
+
| Web Inspector | `devtools: true` on the main window and the `devtools` feature on the `tauri` crate. iOS stays a release build, so it takes both. |
|
|
289
307
|
|
|
290
|
-
|
|
308
|
+
The separate app comes from the config: the engine passes the id, the name and its own `projectDir`, so `gen/apple` is never regenerated for a new id. The next store or dev build of a kept tree takes both keys out of the generated `Info.plist` again, and whatever your `ios.infoPlist` asks for merges back in. `teamId`, `iosMinimumSystemVersion`, `exportMethod` and `simulator` work as in the store profile, and the build lands in `<outDir>/ios-debug/`. So far this is **verified on a simulator only**.
|
|
309
|
+
|
|
310
|
+
**Android and iOS only for now.** `debug` on any other target throws before the first phase; `runAll` (and `cli.build({ all: true, debug: true })`) checks every target up front and refuses the whole run if one is neither:
|
|
291
311
|
|
|
292
312
|
```
|
|
293
|
-
[native] --debug builds Android only for now (asked for
|
|
294
|
-
Build the debug profile for android, or drop debug to build
|
|
313
|
+
[native] --debug builds Android and iOS only for now (asked for macos).
|
|
314
|
+
Build the debug profile for android or ios, or drop debug to build macos.
|
|
295
315
|
```
|
|
296
316
|
|
|
297
|
-
**A store build refuses a page that carries the editor agent.** After the compile, `project.detectPageAgent()` scans every `.js` file under `web.dist` for the editor agent's markers; a store build whose page still carries it fails before `collect`, so no store artifact with the agent reaches `outDir`. A debug build with the agent passes:
|
|
317
|
+
**A store build refuses a page that carries the editor agent.** After the compile, `project.detectPageAgent()` scans every `.js` file under `web.dist` for the editor agent's markers; a store build whose page still carries it fails before `collect`, so no store artifact with the agent reaches `outDir`. A debug or dev build with the agent passes:
|
|
298
318
|
|
|
299
319
|
```
|
|
300
320
|
[native] store build refused: the page carries the editor agent (<dist>/<file>).
|
|
@@ -303,6 +323,33 @@ Every debug patch is idempotent, and the next store build reverts each one to th
|
|
|
303
323
|
|
|
304
324
|
`native doctor` covers the Android side with two checks: `android-platform` (fail) — the SDK platform the build compiles against (`compileSdk`) is installed, fix-it `sdkmanager "platforms;android-N"` — and `android-debug-signing` (warn) — the debug keystore exists, with the `keytool` command that creates it as the fix-it. A debug build with no debug keystore fails in `codegen` with that same command.
|
|
305
325
|
|
|
326
|
+
## Dev profile
|
|
327
|
+
|
|
328
|
+
```ts
|
|
329
|
+
await native.cli.build({ target: "android", aab: true, dev: true });
|
|
330
|
+
// installers land in dist-native/android/
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
`dev: true` (on `cli.build`, `build.run` and `build.runAll`) builds the **dev profile**: the store build a tester installs from TestFlight or a Play track, whose page may carry the editor agent. Native renames nothing. The app config names the test app — `app.identifier`, `app.name`, `app.icon`, `projectDir`, `outDir` — and everything else is the store build:
|
|
334
|
+
|
|
335
|
+
| | Dev profile | Store profile (default) |
|
|
336
|
+
|---|---|---|
|
|
337
|
+
| Page with the editor agent | allowed | refused after the compile |
|
|
338
|
+
| `MOKU_NATIVE_PROFILE` | `"dev"` | `"store"` |
|
|
339
|
+
| `build.removeUnusedCommands` | left out: a dev page may call what a store page does not | `true` |
|
|
340
|
+
| Signing | `signing.android`, `signing.apple` | the same |
|
|
341
|
+
| Application id, name | as configured: no `.debug`, no `(debug)` | the same |
|
|
342
|
+
| Network | cleartext closed | the same |
|
|
343
|
+
| Page | `__MOKU_NATIVE__.build.profile === "release"`, no WebView debugging, no `share` | the same |
|
|
344
|
+
| Delivered to | `<outDir>/<target>/` | the same |
|
|
345
|
+
|
|
346
|
+
`BuildResult.profile` and `native:complete`'s `profile` say `"dev"`, and `cli` shows the delivery like a store one. A run picks one profile, and the pair is refused before the first phase, whatever the target:
|
|
347
|
+
|
|
348
|
+
```
|
|
349
|
+
[native] debug and dev cannot be combined.
|
|
350
|
+
Build one profile: debug for the local app, dev for the store-signed test app.
|
|
351
|
+
```
|
|
352
|
+
|
|
306
353
|
## iOS simulator
|
|
307
354
|
|
|
308
355
|
```ts
|
|
@@ -330,6 +377,8 @@ The first iOS build also runs `tauri ios init` once, then rewrites the build pha
|
|
|
330
377
|
|
|
331
378
|
Android needs neither: Gradle manages its own `build` tree.
|
|
332
379
|
|
|
380
|
+
**A kept tree follows the config.** `tauri ios build` never runs xcodegen on a kept tree, so a change to `project.yml` alone reaches no build, and `MinimumOSVersion` would stay on the value of the first `tauri ios init`. Every `patchMobile` therefore writes `iosMinimumSystemVersion` into `deploymentTarget.iOS` in `project.yml` and every `IPHONEOS_DEPLOYMENT_TARGET` in `project.pbxproj`, and keeps `ios.privacyManifest` in both files, as `gen/apple/PrivacyInfo.xcprivacy` in the Resources phase. Unset, the manifest and its entries go again, down to the original bytes. A file without the line a patch needs is a `[native]` error, and a missing manifest source is refused before anything is written.
|
|
381
|
+
|
|
333
382
|
## When a build fails
|
|
334
383
|
|
|
335
384
|
A non-zero `@tauri-apps/cli` exit throws a `TauriError` carrying `kind`, `exitCode` and a scrubbed `stderrTail` (the last cause lines first, then the raw tail — `cli` prints it above the error line). In a terminal it is a branded box and each tail line is cut to the terminal's width minus the box chrome; with no terminal — CI, or `native build > build.log` — there is no box and nothing is cut, so a piped log keeps the full toolchain diagnostic on plain, unpadded lines. Classification runs over the *cause* lines of both streams only, most specific first, so one incidental `CodeSign` line in a 50k-line xcodebuild log cannot decide the taxonomy:
|
|
@@ -363,7 +412,7 @@ Two **global framework events** are declared in `src/config.ts` — emitted by `
|
|
|
363
412
|
outPath: string; // dist-native/<target>/ — dist-native/<target>-debug/ for a debug build
|
|
364
413
|
artifacts: readonly string[];
|
|
365
414
|
durationMs: number;
|
|
366
|
-
profile: BuildProfile; // "store" | "debug" — cli marks a debug delivery
|
|
415
|
+
profile: BuildProfile; // "store" | "debug" | "dev" — cli marks a debug delivery
|
|
367
416
|
};
|
|
368
417
|
```
|
|
369
418
|
|
|
@@ -378,7 +427,7 @@ One **per-plugin event** is declared by `doctor` (hookable via a `depends: [doct
|
|
|
378
427
|
|
|
379
428
|
## Breaking changes in this release
|
|
380
429
|
|
|
381
|
-
The Android shell, the debug profile, `app.adaptiveIconInset` and the two new doctor checks are additive — nothing in the table below comes from them.
|
|
430
|
+
The Android shell, the debug profile, `app.adaptiveIconInset` and the two new doctor checks are additive — nothing in the table below comes from them. So are the `dev` profile, `debug` on iOS, `ios`, `app.keepScreenOn` and the store-build changes, with one earlier stop: a non-numeric `app.buildNumber` on an android build is now refused at generate, where Tauri would have failed on it anyway. `Project.PlistValue` widens to the recursive `PlistValue`, which the package root exports too.
|
|
382
431
|
|
|
383
432
|
| What breaks | Migration |
|
|
384
433
|
|---|---|
|