@moku-labs/native 0.3.8 → 0.3.10

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 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) · [iOS simulator](#ios-simulator) · [Events](#events) · [Docs](#docs)
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-android) · [iOS simulator](#ios-simulator) · [Events](#events) · [Docs](#docs)
18
18
 
19
19
  ---
20
20
 
@@ -98,7 +98,29 @@ Each `build.run({ target })` walks the phase pipeline `scaffold → codegen →
98
98
 
99
99
  ### The composition is the contract
100
100
 
101
- `config.system` is a name-only array — `ReadonlyArray<{ name: string }>` — and that one list drives the whole packaging surface. The `project` plugin resolves each name against its capability registry (`store`, `notification`, `clipboard-manager`, `tray`, `deep-link`, `back`, `haptics`) into a `ResolvedCapability`: npm package + crate ranges, Rust init line, capability permissions, per-platform applicability, and conf fragments. Unknown names fail at composition time, not at build time. The mobile permission surface is conf-only by verified design — the official Tauri plugins self-merge their own manifest needs — so no permission XML is patched at all. The one XML the packager does write is presentation: the `app.orientation` lock, as `Info.ios.plist` keys and an attribute on the Android main activity.
101
+ `config.system` is a name-only array — `ReadonlyArray<{ name: string }>` — and that one list drives the whole packaging surface. The `project` plugin resolves each name against its capability registry (`store`, `notification`, `clipboard-manager`, `tray`, `deep-link`, `back`, `haptics`, `shell`) into a `ResolvedCapability`: npm package + crate ranges, Rust init line, capability permissions, per-platform applicability, and conf fragments. Unknown names fail at composition time, not at build time. The mobile permission surface is conf-only by verified design — the official Tauri plugins self-merge their own manifest needs — so no permission XML is patched at all. The one XML the packager does write is presentation: the `app.orientation` lock, as `Info.ios.plist` keys and an attribute on the Android main activity.
102
+
103
+ ### The shell: a page bridge on Android
104
+
105
+ `shell` is the one capability that is not an official Tauri plugin. Compose it like any other — `system: [{ name: "shell" }]` — and `project` generates a small local crate, `tauri-plugin-moku-shell` (under `<projectDir>/plugins/moku-shell/`, linked by path, permission `moku-shell:default`), whose init script installs a frozen `globalThis.__MOKU_NATIVE__` (contract `version: 1`) before the page's own scripts run:
106
+
107
+ | Member | What the page gets |
108
+ |---|---|
109
+ | `display.setFrameRate(fps \| null)` / `display.maxHz` | Picks the slowest display mode at or above `fps` at the current resolution (`null` restores the default); `maxHz` is the panel's top rate. |
110
+ | `thermal.read()` | Thermal status and ADPF headroom; a `moku-native:thermal` event on `window` on every status change. |
111
+ | `insets.current` | Safe-area insets in CSS px, mirrored to `--moku-device-safe-top/right/bottom/left` on `<html>` (a page's own `--moku-safe-*` wins over them), with a `moku-native:insets` event on `window`. |
112
+ | `device`, `ready` | Model, manufacturer and SDK level, filled in once `ready` resolves (it never rejects). |
113
+ | `build` | `{ profile: "release" \| "debug", id }` — baked in at generate time. |
114
+ | `share(file)` | Debug builds only: writes the bytes to the app cache and opens the share sheet. |
115
+
116
+ The shell is **Android only** for now — on iOS the row is filtered out like any platform-limited row, so a browser, iOS, or an app without the shell has no `__MOKU_NATIVE__` and the page keeps its fallback. `capabilities.shell` is its empty parameter object and composes nothing on its own. The full contract is in the [`project` README](./src/plugins/project/README.md#page-contract-v1).
117
+
118
+ The packaged page's origin depends on the platform, which matters for any server-side CORS allowlist:
119
+
120
+ | Platform | `location.origin` |
121
+ |---|---|
122
+ | Android, Windows | `http://tauri.localhost` |
123
+ | iOS, macOS, Linux | `tauri://localhost` |
102
124
 
103
125
  ## Two apps, one contract
104
126
 
@@ -134,7 +156,7 @@ Your project runs **two `createApp`s side by side**: the web/node app you alread
134
156
 
135
157
  | Plugin | Tier | Key API | Responsibility |
136
158
  |---|---|---|---|
137
- | [`project`](./src/plugins/project/README.md) | Complex | `generate` · `completeness` · `patchMobile` · `ensureIconSource` · `clean` · `resolve` | Capability registry + `.moku/tauri` generators + write-if-changed writer + mobile init-once-then-patch. Owns the generated tree as *files*; never spawns. |
159
+ | [`project`](./src/plugins/project/README.md) | Complex | `generate` · `getCompleteness` · `patchMobile` · `detectPageAgent` · `ensureIconSource` · `clean` · `resolve` | Capability registry + `.moku/tauri` generators (the `shell` crate among them) + write-if-changed writer + mobile init-once-then-patch, per build profile. Owns the generated tree as *files*; never spawns. |
138
160
  | [`tauri`](./src/plugins/tauri/README.md) | Standard | `icon` · `build` · `mobileInit` · `dev` · `version` · `runner` | The framework's **only** subprocess seam: `@tauri-apps/cli` argv builders, injectable spawn, process-group dev lifecycle, error taxonomy, secret scrubbing. |
139
161
  | [`build`](./src/plugins/build/README.md) | Standard | `prepare` · `run` · `runAll` | Sequential per-target phase pipeline; emits `native:phase`/`native:complete`; owns the `collect` phase (bundle-location table → `dist-native/<target>/`). |
140
162
  | [`doctor`](./src/plugins/doctor/README.md) | Complex | `run` | Per-target toolchain/completeness/version-skew diagnosis via a `checks/` registry, run in parallel — one broken check never sinks the report. |
@@ -156,17 +178,18 @@ The substantive surface is **global** `Config` — every plugin reads it via `ct
156
178
  | `app.buildNumber` | `string?` | unset | Store build number → `bundle.{iOS,macOS}.bundleVersion`. |
157
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. |
158
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. Android status bar icons follow it: light on a dark colour, dark on a light one. |
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. |
159
182
  | `web.build` | `string` | `"bun run build"` | Runs before a build, in `web.cwd`. |
160
183
  | `web.devCommand` | `string` | `"bun run dev"` | Runs before `dev`, in `web.cwd`. |
161
184
  | `web.devUrl` | `string` | `"http://localhost:5173"` | Dev server URL — also the `DevHandle.url` and the readiness-poll target. |
162
185
  | `web.dist` | `string` | `"dist"` | Web build output, resolved from `web.cwd` and rebased onto `src-tauri`. |
163
186
  | `web.cwd` | `string?` | unset → the process cwd | Root of the web package — monorepo layouts. Everything web-shaped resolves from here. |
164
187
  | `system` | `ReadonlyArray<{ name: string }>` | `[]` | The composed system plugins — the shared cross-team contract. Unknown names throw at init. |
165
- | `capabilities` | `Partial<CapabilityConfigMap>` | `{}` | Per-capability packaging parameters, keyed `store`, `notification`, `clipboard-manager`, `tray`, `deep-link`, `back`, `haptics`. `deep-link` requires `{ mode: "scheme", scheme: string }`; the others take none. |
188
+ | `capabilities` | `Partial<CapabilityConfigMap>` | `{}` | Per-capability packaging parameters, keyed `store`, `notification`, `clipboard-manager`, `tray`, `deep-link`, `back`, `haptics`, `shell`. `deep-link` requires `{ mode: "scheme", scheme: string }`; the others take none (`shell: {}` composes nothing alone — name it in `system`). |
166
189
  | `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. |
167
190
  | `projectDir` | `string` | `".moku/tauri"` | Generated Tauri project root (contains `src-tauri/`). Gitignored build output. |
168
191
  | `outDir` | `string` | `"dist-native"` | Installer delivery root — `collect` copies finished artifacts to `outDir/<target>/`. |
169
- | `signing.apple` | `AppleSigning?` | unset | `teamId`, `signingIdentity`, `providerShortName`, `entitlements`, `appStore`, `exportMethod`, `macosMinimumSystemVersion`, `iosMinimumSystemVersion` — see [Signing and store builds](#signing-and-store-builds). |
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). |
170
193
  | `signing.android` | `{ keystorePath?, keystorePasswordEnv?, keyPasswordEnv?, keyAlias? }` | unset | Env-var **names**, never secrets. `keyPasswordEnv` falls back to `keystorePasswordEnv`. |
171
194
  | `signing.windows` | `{ certificateThumbprint? }` | unset | Windows signing certificate thumbprint. |
172
195
 
@@ -243,6 +266,43 @@ What each piece does:
243
266
  > [!NOTE]
244
267
  > **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`.
245
268
 
269
+ ## Debug builds (Android)
270
+
271
+ ```ts
272
+ await native.cli.build({ target: "android", debug: true });
273
+ // debug build → dist-native/android-debug/
274
+ ```
275
+
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 — but marked so it can never be mistaken for one, and installed **beside** the store app rather than over it:
277
+
278
+ | | Debug profile | Store profile (default) |
279
+ |---|---|---|
280
+ | Application id | `<app.identifier>.debug` (`applicationIdSuffix`) | `app.identifier` |
281
+ | Launcher name | `<app.name> (debug)` | `app.name` |
282
+ | Signing | the SDK debug keystore, `~/.android/debug.keystore`, alias `androiddebugkey` | `signing.android` |
283
+ | Network | cleartext allowed (generated network security config) | platform default |
284
+ | `shell` | composed even when `system` does not name it | only when `system` names it |
285
+ | 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
+ | Delivered to | `<outDir>/android-debug/` | `<outDir>/android/` |
287
+
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 `"debug"`) 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>`.
289
+
290
+ **Android 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 not Android:
291
+
292
+ ```
293
+ [native] --debug builds Android only for now (asked for ios).
294
+ Build the debug profile for android, or drop debug to build ios.
295
+ ```
296
+
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:
298
+
299
+ ```
300
+ [native] store build refused: the page carries the editor agent (<dist>/<file>).
301
+ Build with debug: true.
302
+ ```
303
+
304
+ `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
+
246
306
  ## iOS simulator
247
307
 
248
308
  ```ts
@@ -300,9 +360,10 @@ Two **global framework events** are declared in `src/config.ts` — emitted by `
300
360
  };
301
361
  "native:complete": {
302
362
  target: Target;
303
- outPath: string; // dist-native/<target>/
363
+ outPath: string; // dist-native/<target>/ — dist-native/<target>-debug/ for a debug build
304
364
  artifacts: readonly string[];
305
365
  durationMs: number;
366
+ profile: BuildProfile; // "store" | "debug" — cli marks a debug delivery
306
367
  };
307
368
  ```
308
369
 
@@ -317,6 +378,8 @@ One **per-plugin event** is declared by `doctor` (hookable via a `depends: [doct
317
378
 
318
379
  ## Breaking changes in this release
319
380
 
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.
382
+
320
383
  | What breaks | Migration |
321
384
  |---|---|
322
385
  | `web.dev.command`, `web.dev.url` | Use the flat `web.devCommand`, `web.devUrl` (config is shallow-merged, so a nested `dev` object could never merge cleanly). |