[docs] TauriPlatforms: Four versions from one codebase on Tauri 2: CLAUDE.md, the roadmap's platform track, the analysis
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
# Four versions, one garden — the Tauri 2 shell
|
||||
|
||||
Status: built on `feature/tauri-platforms`, 2026-11-17. Decided by the author the same day: *"I need
|
||||
also android apk version, desktop version, ios version and pwa version … based on the tauri2
|
||||
framework."* CLAUDE.md §2 (*Four versions, one garden*), §3, §4, §8; ROADMAP *The platform track*.
|
||||
Review: [`feature-tauri-platforms.md`](../reviews/feature-tauri-platforms.md).
|
||||
|
||||
## 1. Why and what, in the player's terms
|
||||
|
||||
Until now Rosea Domi was a page you open from a link and may add to the home screen. Now the same
|
||||
garden also comes as an **app**: an Android app to install from a file (later from a store), a
|
||||
desktop app for Windows (macOS and Linux once built on those systems), and an iOS app once there is
|
||||
a Mac to build it on. The PWA stays as it is.
|
||||
|
||||
What the player meets is the same in all four: the same rose, the same words, the same sunset, the
|
||||
same *Keep her safe*. Nothing asks for an account, nothing goes online. Differences they may notice:
|
||||
|
||||
- The app opens straight into the garden, with its own icon, without a browser around it.
|
||||
- In the app there is never *A new version of the garden is ready*: a new version comes as a new app.
|
||||
- A rose in the PWA and a rose in the app on the same phone are **two roses**. To carry one across,
|
||||
*Keep her safe* saves her to a file and brings her back (on Android, see G-T4).
|
||||
|
||||
Why now and not in Phase 6: the shell needs no new feature, and an APK puts the Phase 1 spike on the
|
||||
author's phone without any hosting (G0.13 is still open).
|
||||
|
||||
## 2. Technical architecture
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph game["one Svelte 5 codebase"]
|
||||
schema["packages/schema"] --- engine["packages/engine"]
|
||||
engine --- ui["packages/ui"]
|
||||
storage["packages/storage<br/>(IndexedDB)"] --- engine
|
||||
content["packages/content"] --- schema
|
||||
identity["packages/identity"] --- schema
|
||||
app["apps/rosea<br/>App.svelte wiring"]
|
||||
ui --> app
|
||||
storage --> app
|
||||
content --> app
|
||||
identity --> app
|
||||
end
|
||||
app -->|"vite build<br/>(default mode)"| dist["apps/rosea/dist/<br/>base /Rosea/, service worker,<br/>manifest, <meta> CSP"]
|
||||
app -->|"vite build --mode tauri"| distt["apps/rosea/dist-tauri/<br/>base /, no worker, no manifest,<br/>no <meta> CSP"]
|
||||
dist --> pwa["PWA<br/>GitHub Pages"]
|
||||
distt --> shell["apps/rosea-tauri/src-tauri<br/>tauri.conf.json (CSP, name, version)<br/>lib.rs: a window, nothing else"]
|
||||
shell --> win["Windows<br/>WebView2 · NSIS"]
|
||||
shell --> android["Android<br/>System WebView · APK<br/>(privacy patch on gen/)"]
|
||||
shell --> ios["iOS<br/>WKWebView<br/>(macOS + Xcode only)"]
|
||||
shell --> mac["macOS / Linux<br/>WKWebView / WebKitGTK"]
|
||||
```
|
||||
|
||||
| # | Decision | Why |
|
||||
|:--|:--|:--|
|
||||
| D1 | **`apps/rosea-tauri/` with `src-tauri/` inside**, a workspace package `@rosea/tauri` holding the Tauri CLI and the scripts. Not Tauri's default `apps/rosea/src-tauri/`. | The Tauri 2 CLI finds `src-tauri/tauri.conf.json` below the folder it runs in, so this is its expected layout one level down. The PWA's package stays free of Rust and of the CLI; the shell is deletable; its only input is a built folder, the same seam the e2e suites test. |
|
||||
| D2 | **Two builds of one game.** `vite build --mode tauri` (`build:shell`) → `apps/rosea/dist-tauri/`: base `/`; `vite-plugin-pwa` disabled (no worker, no manifest; `registerSW` becomes its no-op); no `<meta>` CSP; no source maps. One build-time constant, `__ROSEA_SHELL__`, read in `App.svelte` only. | Tauri serves the files at the root of its own origin; the files are already on the device, so a worker would only cache a second copy and could serve a stale game after an update; see D4 for the CSP. A separate folder means a shell build can never overwrite the PWA's and be deployed by mistake. Source maps would ship inside every installer. |
|
||||
| D3 | **Name, identifier, version.** `productName` and the window title `Rosea Domi` (a test holds them equal to `PRODUCT_NAME`); identifier **`cz.mareknovak.domi.rosea`**, like Culina's `cz.mareknovak.domi.culina`; `version` read from `apps/rosea/package.json` (Tauri accepts a path to a `package.json`). | The name may change in one commit (CLAUDE.md preamble). The identifier may not, once an app has reached a player: Android and iOS treat a new identifier as a different app, which would leave the rose behind in the old one. One version for the game and the apps; Android refuses a lower version as a downgrade. |
|
||||
| D4 | **The CSP comes from Tauri**, the same string as the PWA's `<meta>` (`apps/rosea/csp.ts`), held equal by the shell's test. | A page with both a `<meta>` policy and a header obeys both; Tauri adds hashes for what it injects only to its own header, so a `<meta>` copy would block that. One string in source, two delivery routes. |
|
||||
| D5 | **The Rust side opens a window and does nothing else.** No command, no plugin, no `@tauri-apps/api` in the game, and no `capabilities/` folder, so the page is granted no IPC. | The game already works fully in a webview. Every plugin is a new path for bytes to leave the device; each is reviewed before it is added (notifications, Phase 6). |
|
||||
| D6 | **Android privacy, applied to the generated project before every build** (`src/android-privacy.ts`, `scripts/android.ts`, run from `tauri.android.conf.json`'s `beforeBuildCommand`): no `INTERNET` permission; `allowBackup="false"` and rules excluding every domain from cloud backup and device transfer; WebView metrics opt-out and Safe Browsing off. **Verified on the built APK** with `aapt2`. | `gen/android` is regenerated by `tauri android init` and never committed. Amicitia measured on 2026-11-08 that Android System WebView sends an Autofill query to Google the moment a field takes focus, and that manifest switches do not stop it; only the missing permission does. Rosea has a field (*Where do you want your sunset?*). Auto Backup would copy the care log, the keys and the town to the player's cloud without their choosing. |
|
||||
| D7 | **Windows: WebView2's own traffic switched off** with `additionalBrowserArgs` — Amicitia's measured list (DNS-over-HTTPS upgrade, SmartScreen, experimentation, Autofill server, background networking, component updates, sync, pings, phishing detection, DNS prefetch). | Amicitia measured WebView2 reaching Google, Cloudflare and Microsoft within seconds of opening with no request of its own. The flags are undocumented feature names; a runtime update can break them, so the measurement is repeated per release (G-T6). |
|
||||
| D8 | **Icons are made at build time** from `apps/rosea/public/icon.svg` with `tauri icon` and never committed. | No raster images in git except art in `art/final/` (CLAUDE.md §5.2). The SVG is a placeholder until the art pipeline makes the real icon (G0.21). |
|
||||
| D9 | **In the apps, the game counts as installed**: it asks `navigator.storage.persist()` after the first care, as an installed PWA does, and never shows the iOS hint to add the page to the home screen. | WKWebView's user agent says *iPhone*; without this, the iOS app would tell the player to install the app they are in. |
|
||||
| D10 | **`useHttpsScheme: true`**: the game's origin is `https://tauri.localhost` on Windows and Android. | IndexedDB is per origin. Tauri warns that changing this value between releases moves the database and the app can no longer see the old one: it must be chosen before the first release and never changed. `https` is a secure context without relying on the `*.localhost` exception (WebCrypto makes the player's key). |
|
||||
| D11 | **Per-platform bundle targets** in `tauri.{windows,macos,linux}.conf.json`: NSIS (current user) on Windows; `.app` and `.dmg` on macOS; `.deb` and AppImage on Linux. | One config would try to make targets the machine cannot (MSI needs WiX, a download). |
|
||||
| D12 | **Commands**: `pnpm tauri:dev`, `tauri:build`, `tauri:android` (a debug APK for arm64, then `verify`), `tauri:ios` (refuses off macOS with the reason). No Android dev command yet. | An Android dev build needs `INTERNET` to reach the dev server and `adb reverse` to keep it on 127.0.0.1 (CLAUDE.md §5.7); not needed to test what exists. |
|
||||
|
||||
What did **not** change: every package; the PWA's build, base path, worker, manifest and `<meta>`
|
||||
policy (the PWA's `dist/` is byte-for-byte the same apart from the build hash — checked in the review).
|
||||
|
||||
## 3. Risk analysis
|
||||
|
||||
Risk here means *a lonely person feeling worse*, *someone's location*, or *someone being reachable who
|
||||
did not ask to be* (CLAUDE.md §5.1).
|
||||
|
||||
| Risk | Platform | Answer |
|
||||
|:--|:--|:--|
|
||||
| **The rose is lost** when the app is uninstalled, the phone is replaced, or the app's data is cleared. | all apps | Uninstalling an app deletes its data; Android Auto Backup is deliberately off (D6). *Keep her safe* is the way to move or keep her, and on Android saving a file is unproven (G-T4). Said plainly in this doc and in the review; the Letter may say it to the player later. |
|
||||
| **The rose is lost to an origin change** (`useHttpsScheme`, identifier, scheme). | Windows, Android | D3, D10: both fixed before the first release, with a test each. CLAUDE.md §8 records both as *forever*. |
|
||||
| **Two roses** for one player (PWA and app). | all | Expected and stated (§1). Nothing in the game counts or compares them. |
|
||||
| **The webview phones home** — bytes leave without the player. | Android | No `INTERNET`: the kernel refuses any socket (D6). Proof: `aapt2` on the APK, `dumpsys package` on the tablet. |
|
||||
| | Windows | `additionalBrowserArgs` (D7). Not measured for Rosea on this machine (G-T6). WebView2 itself is updated by Windows Update, outside the app. |
|
||||
| | iOS / macOS | WKWebView has no telemetry switch to set; not measured (G-T1). |
|
||||
| **Location leaves the device.** | all | The town stays in IndexedDB. No backup (Android), no network (Android), no plugin (all). |
|
||||
| **An SDK that counts.** | all | No analytics, crash-reporting or ads library: `Cargo.toml` has `tauri` alone and a test keeps it so; the game has no new dependency. Tauri itself sends nothing. |
|
||||
| **The Windows installer fetches WebView2** if it is missing (Tauri's default `downloadBootstrapper`). | Windows | A one-time download from Microsoft during installation, on a machine without WebView2 (Windows 10 and 11 ship it). Noted, not changed: an offline installer would embed ~150 MB. |
|
||||
| **Reachability.** | all | Nothing new: no free text, no network, no IPC. |
|
||||
| **A stale game after an update.** | apps | No service worker (D2): the game is the one inside the installed package. |
|
||||
| **Guilt or dependence.** | all | The app adds no notification, badge or reminder. Notifications are Phase 6, with their own Soul review. |
|
||||
|
||||
## 4. Gap analysis
|
||||
|
||||
| Id | Gap | Designed solution / state |
|
||||
|:--|:--|:--|
|
||||
| G-T1 | **iOS** cannot be built on Windows. | Needs macOS with Xcode (and its command-line tools, CocoaPods not required by Tauri 2), the Rust targets `aarch64-apple-ios` and `aarch64-apple-ios-sim`, and an **Apple developer account**: a free Apple ID can sign for one's own device for 7 days; TestFlight and the App Store need the paid programme. Then `pnpm tauri:ios`. Unknown until measured there: where WKWebView keeps IndexedDB, whether iOS purges it for an unused app, and whether `<a download>` saves her file. **Open.** |
|
||||
| G-T2 | **macOS and Linux desktop builds** are not built. | Each on its own system: `pnpm tauri:build` (`.app`/`.dmg`; `.deb`/AppImage). macOS outside the App Store also needs signing and notarisation with a paid account, or Gatekeeper warns. **Open.** |
|
||||
| G-T3 | **Release signing** for Android (a keystore) and Windows (a code-signing certificate). | Debug builds only today. The keystore and its passwords never enter the repository (CLAUDE.md §5.2). Phase 6. **Open.** |
|
||||
| G-T4 | **Saving her to a file inside an app.** The game saves through `<a download>` on a blob URL. | Android WebView and WKWebView do not save blob downloads by default. Measured on the tablet: see the review. If it does nothing, the design is a small Rust command behind the dialog plugin (`tauri-plugin-dialog` save, write the file), the first plugin, reviewed for network access; or the Android share sheet. **Open** until measured and built. |
|
||||
| G-T5 | **Bringing her back from a file** (`<input type="file">`) inside the apps. | Android WebView needs the app to answer the file chooser; Tauri's Android activity does. Measured on the tablet: see the review. |
|
||||
| G-T6 | **WebView2's traffic not measured for Rosea.** | Amicitia's `watch-desktop-network.ps1` approach: run the built exe, list its connections. Before the first desktop release. **Open.** |
|
||||
| G-T7 | **No CI** builds the apps (G0.22). | Builds by hand on this machine; never committed. |
|
||||
| G-T8 | **Storage eviction in WebView2 and Android WebView** is predicted, not measured. | `persist()` is asked after the first care (D9). Measure what `persisted()` answers in each webview (review). |
|
||||
| G-T9 | **The icon is the PWA's placeholder.** | G0.21; the art pipeline. Android adaptive icons need a foreground layer then. |
|
||||
|
||||
## 5. Verification matrix
|
||||
|
||||
| Case | Kind | Where |
|
||||
|:--|:--|:--|
|
||||
| Name and window title equal `PRODUCT_NAME`; identifier is `cz.mareknovak.domi.rosea`; version read from `apps/rosea/package.json`, which exists | unit | `apps/rosea-tauri/test/config.test.ts` |
|
||||
| Tauri's CSP equals `apps/rosea/csp.ts`; the shell's dev server and build point at `dev:shell` / `build:shell` and `dist-tauri`, dev on 127.0.0.1 | unit | same |
|
||||
| `useHttpsScheme` is `true` (the origin is forever) | unit | same |
|
||||
| WebView2's privacy flags are all in `additionalBrowserArgs` | unit | same |
|
||||
| `Cargo.toml` depends on `tauri` alone; no `capabilities/` folder | unit | same |
|
||||
| The Android build runs the privacy patch before the game's build | unit | same |
|
||||
| Patch on Tauri's stock manifest: `INTERNET` gone, three attributes set, both meta-data present; a second run changes nothing; CRLF kept; an unexpected shape throws | unit | `apps/rosea-tauri/test/android-privacy.test.ts` |
|
||||
| `manifestProblems` names each missing piece on the stock manifest and none on the patched one | unit | same |
|
||||
| The committed rule files exclude every domain everywhere; a file missing one, or including something, is caught | unit | same |
|
||||
| `apkProblems` on real `aapt2` output: the patched APK passes; a stock one (INTERNET, backup on) fails with names | unit | same |
|
||||
| `vite build --mode tauri`: no worker, no `registerSW` script, no manifest, no `<meta>` CSP, assets under `/assets/`, `__ROSEA_SHELL__` replaced | integration | `apps/rosea-tauri/test/shell-build.test.ts` |
|
||||
| The PWA build is unchanged: `<meta>` CSP, worker, manifest scope `/Rosea/` | e2e | `e2e/` (existing suites) |
|
||||
| Windows: the release `.exe` opens the garden; water her; close; open again; she is still watered | manual + script | review (Playwright over WebView2's debugging port on 127.0.0.1) |
|
||||
| Android: the debug APK installs on the WAVE 10C (Android 16), opens the garden, water her, force-stop, open again: still watered; the app has no `INTERNET` (offline by construction) | device | review (`adb`, Playwright over the WebView's DevTools socket) |
|
||||
| The APK asks for no permission, sets `allowBackup=false`, metrics and Safe Browsing off | artefact | `pnpm tauri:android` → `android.ts verify` (aapt2) |
|
||||
| `pnpm tauri:ios` on Windows refuses with the reason and builds nothing | manual | review |
|
||||
| iOS, macOS, Linux | — | not possible here (G-T1, G-T2) |
|
||||
Reference in New Issue
Block a user