8000 Tauri 2 host prototype (WKWebView / WebView2) by DominikPalo · Pull Request #23 · DominikPalo/OOXML-Toolkit · GitHub
[go: up one dir, main page]

Skip to content

Tauri 2 host prototype (WKWebView / WebView2) - #23

Closed
DominikPalo wants to merge 1 commit into
mainfrom
spike/tauri-prototype
Closed

DominikPalo wants to merge 1 commit into
mainfrom
spike/tauri-prototype

Conversation

@DominikPalo
Copy link
Copy Markdown
Owner

Summary

A prototype that hosts the unchanged renderer in Tauri 2 (system WKWebView on macOS, WebView2 on Windows) next to the existing Electron build. It is meant to show what dropping Electron would cost and gain. Nothing in src/core or the React UI was rewritten.

Headline: the macOS arm64 release bundle is 4.1 MB (.app) / 2.6 MB (DMG), against 128 MB for the Electron 0.3.0 DMG.

What changed

  • src-tauri/ (new): the Rust host, a port of src/main + src/preload.
    • files.rs: the allowlist of user-picked / dropped / remembered paths, atomic writes (temp file + rename, file mode kept, optional .bak), per-file write serialization.
    • store.rs: the same JSON key/value store.
    • main.rs: dialogs, the close handshake, single instance, command-line / Finder "open document" handling, drag-drop paths.
    • macos.rs: title-bar document and edited dot, Recent Items (AppKit via objc2).
    • tauri.conf.json: window, bundle, and the same file associations as electron-builder.yml.
  • hostTauri.ts implements HostApi with invoke/listen. File bytes go both ways as raw binary (ipc::Response / raw body + percent-encoded path header), never as JSON number arrays.
  • tauriMenu.ts builds the native menu from shared/commands.ts, the same source as the Electron menu.
  • Small shared/renderer changes:
    • HostKind gains 'tauri', and the Reveal buttons now check host.kind !== 'web'.
    • New optional HostApi.onFileDrag: Tauri takes OS file drops away from the page (no HTML5 drop), so this drives the drop overlay.
    • data-tauri-drag-region on the tab bar on macOS.
  • tests/tauri-config.test.ts keeps the Rust extension list and file associations in sync with shared/api.ts / electron-builder.yml.
  • New scripts: npm run dev:tauri, npm run dist:tauri. Building needs a Rust toolchain.

Security note

Dialogs run in Rust, so only paths the user actually picked, dropped or opened before are approved. Unlike the Electron build, the renderer cannot approve paths itself: approvePaths is a no-op, and dropped paths are approved on the native side.

Verified on macOS (Apple Silicon)

  • npm test, npm run typecheck, cargo clippy (clean), and npm run e2e still passes against Electron.
  • Running app, driven through its native menu:
    • Opening files: command line, Finder/open into the running instance, session restore.
    • Menu: every shortcut is present, and Open Recent updates.
    • Format → Save: atomic write, .bak identical to the original, file mode kept, path with spaces, valid ZIP. The edited dot toggles.
    • Quit / close: Quit exits cleanly. Closing with unsaved changes keeps the window open for the renderer's dialog.
  • Rendering: the UI was rendered in the system WKWebView (editor, tree, preview) with no console errors.

Not done / reviewer notes

  • Windows has not been built or run: WebView2, menu shortcuts while the web view has focus, the NSIS installer, file associations, and the jump list (TODO) are all unchecked.
  • No automated e2e for the Tauri build. Playwright's _electron can't drive it and tauri-driver has no macOS support. Screenshots and the demo stay on Electron.
  • macOS lifecycle: the app quits when its window closes (Electron stays in the Dock). Quitting from the Dock or at logout skips the unsaved-changes check. A hung renderer can keep the window open.
  • Settings and history live in a new data directory; nothing is migrated from Electron.
  • @tauri-apps/api is pinned to ~2.11 to match the tauri crate. The CLI refuses mismatched minors.
  • This branch is based on main before the Save button work (Add Save and Save As buttons to the tab bar #22). It merges cleanly.

Full details are in src-tauri/README.md.

🤖 Generated with Claude Code

Hosts the unchanged renderer in Tauri next to the Electron build:

- src-tauri: Rust ports of main/files.ts (allow-list, atomic writes,
  .bak), main/store.ts, the close handshake, single instance, file
  associations and macOS open-document events; AppKit calls for the
  title-bar document and recent documents.
- hostTauri.ts implements HostApi over invoke/listen with raw binary
  IPC for file bytes; tauriMenu.ts builds the native menu from
  shared/commands.ts.
- HostKind gains 'tauri'; optional HostApi.onFileDrag drives the drop
  overlay because Tauri takes OS drops away from the page.

Release bundle on macOS arm64: 4.1 MB .app / 2.6 MB DMG (Electron: 128 MB).
Windows is untested; see src-tauri/README.md for verified flows and gaps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DominikPalo
DominikPalo deleted the spike/tauri-prototype branch October 27, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0