Remove Tauri desktop shell
Not going to be used — drop src-tauri/ and all references to it in the docs. MapTool stays a plain Sinatra web app for now.
This commit is contained in:
1 parent
5afb130c45
commit
16e06b2ffe
17 files changed
+5
-4756
No files matched your search
@@ -5,9 +5,6 @@
|
||||
/log/
|
||||
/tmp/
|
||||
|
||||
# Rust / Tauri
|
||||
/src-tauri/target/
|
||||
|
||||
# Offline map tile data (large binary; obtained/generated locally,
|
||||
# see docs/development.adoc)
|
||||
/data/*.pmtiles
|
||||
|
||||
+2
-6
@@ -3,8 +3,7 @@
|
||||
:toclevels: 2
|
||||
:source-highlighter: rouge
|
||||
|
||||
A mapping application backend written in Ruby with Sinatra, optionally
|
||||
wrapped as a native desktop app with Tauri.
|
||||
A mapping application written in Ruby with Sinatra.
|
||||
|
||||
The project's shape is still open — this is the initial scaffold.
|
||||
|
||||
@@ -12,14 +11,11 @@ The project's shape is still open — this is the initial scaffold.
|
||||
|
||||
Early scaffold. The web application serves a vector map (MapLibre GL
|
||||
JS), with an online style and an optional offline style backed by a
|
||||
local PMTiles file; the desktop shell boots the same server inside a
|
||||
native window.
|
||||
local PMTiles file, plus an animated RainViewer radar overlay.
|
||||
|
||||
== Requirements
|
||||
|
||||
* Ruby (see `.ruby-version`) and Bundler
|
||||
* Rust and the Tauri CLI, only if you want to build the desktop shell
|
||||
(see `docs/development.adoc`)
|
||||
|
||||
== Getting started
|
||||
|
||||
|
||||
+3
-51
@@ -4,27 +4,8 @@
|
||||
|
||||
== Overview
|
||||
|
||||
MapTool is a Sinatra web application. The desktop build does not
|
||||
reimplement anything natively — it wraps the same Sinatra app in a
|
||||
https://tauri.app[Tauri] window, which is the standard way to ship a
|
||||
non-JavaScript backend as a desktop app with Tauri: the Rust shell owns
|
||||
the native window and starts the web server as a local process; the
|
||||
window then simply loads `http://127.0.0.1:4567` as if it were a
|
||||
regular page.
|
||||
|
||||
[source]
|
||||
----
|
||||
+----------------------------+
|
||||
| Tauri window (WebView) |
|
||||
| loads http://127.0.0.1:PORT
|
||||
+--------------+-------------+
|
||||
|
|
||||
v
|
||||
+----------------------------+
|
||||
| Sinatra app (Puma) |
|
||||
| app.rb / config.ru |
|
||||
+----------------------------+
|
||||
----
|
||||
MapTool is a Sinatra web application, served locally by Puma and
|
||||
opened in a browser.
|
||||
|
||||
== Directory layout
|
||||
|
||||
@@ -51,38 +32,10 @@ regular page.
|
||||
| `data/`
|
||||
| Local, gitignored data files, e.g. `offline.pmtiles`.
|
||||
|
||||
| `src-tauri/`
|
||||
| The Tauri (Rust) desktop shell.
|
||||
|
||||
| `docs/`
|
||||
| Project documentation, in AsciiDoc.
|
||||
|===
|
||||
|
||||
== Desktop shell (Tauri)
|
||||
|
||||
In *development*, `src-tauri/tauri.conf.json` sets `beforeDevCommand`
|
||||
to start Puma, and `devUrl` points the window at it. Running the dev
|
||||
build (see `docs/development.adoc`) starts both together.
|
||||
|
||||
In a *packaged build* there is no `beforeDevCommand` hook, so
|
||||
`src-tauri/src/lib.rs` starts the server itself (`bundle exec puma`)
|
||||
next to the bundled resources when the app launches, and stops it when
|
||||
the window closes.
|
||||
|
||||
=== Known limitation: production packaging
|
||||
|
||||
The packaged-build server spawn currently assumes a Ruby + Bundler
|
||||
installation already present on the machine running the app. That is
|
||||
fine for internal or developer builds, but not for a distributable,
|
||||
self-contained desktop app.
|
||||
|
||||
Shipping a real self-contained build would mean embedding a Ruby
|
||||
runtime as a Tauri https://tauri.app/develop/sidecar/[sidecar] binary
|
||||
(for example, produced with https://github.com/tebako/tebako[tebako]),
|
||||
instead of relying on the system Ruby. That decision — and the
|
||||
resulting sidecar build step — is not implemented yet and should be
|
||||
revisited before any real distribution build.
|
||||
|
||||
== Offline maps
|
||||
|
||||
Map data is vector, not raster: the app ships
|
||||
@@ -160,5 +113,4 @@ terms, the API is free for personal/non-commercial use.
|
||||
== Networking
|
||||
|
||||
The Sinatra server only binds to `127.0.0.1`. It is not meant to be
|
||||
reachable from other machines; the Tauri window talks to it over
|
||||
loopback only.
|
||||
reachable from other machines.
|
||||
@@ -42,68 +42,3 @@ build one locally:
|
||||
|
||||
Once the file is in place, `GET /api/offline-tiles` reports
|
||||
`available: true` and the map defaults to the offline style.
|
||||
|
||||
This is picked up automatically for `cargo tauri dev` (it just runs
|
||||
the Sinatra app from the project root). To ship it inside a *packaged*
|
||||
build, add it to `bundle.resources` in `src-tauri/tauri.conf.json`:
|
||||
`"../data/offline.pmtiles": "data/offline.pmtiles"`. Not added by
|
||||
default, since these files can be large and are picked per
|
||||
deployment.
|
||||
|
||||
== Desktop shell (Tauri)
|
||||
|
||||
=== Prerequisites
|
||||
|
||||
* Rust (stable) and the Tauri CLI: `cargo install tauri-cli --version "^2"`
|
||||
* Ruby + Bundler, with gems installed (`bundle install` in the project
|
||||
root)
|
||||
* Platform build tools required by Tauri itself:
|
||||
** *Linux*: WebKitGTK and GTK development packages, e.g. on
|
||||
Debian/Ubuntu:
|
||||
+
|
||||
[source,shell]
|
||||
----
|
||||
sudo apt install libwebkit2gtk-4.1-dev libjavascriptcoregtk-4.1-dev \
|
||||
libgtk-3-dev libsoup-3.0-dev build-essential
|
||||
----
|
||||
** *macOS*: Xcode command line tools.
|
||||
** *Windows*: the WebView2 runtime (preinstalled on current Windows) and
|
||||
the MSVC build tools.
|
||||
|
||||
See the upstream https://tauri.app/start/prerequisites/[Tauri
|
||||
prerequisites] page for the current package names on your platform.
|
||||
|
||||
=== Running in development
|
||||
|
||||
[source,shell]
|
||||
----
|
||||
cd src-tauri
|
||||
cargo tauri dev
|
||||
----
|
||||
|
||||
This runs `beforeDevCommand` (starts Puma on `127.0.0.1:4567`) and
|
||||
opens a native window pointed at it, per `src-tauri/tauri.conf.json`.
|
||||
|
||||
=== Building
|
||||
|
||||
[source,shell]
|
||||
----
|
||||
cd src-tauri
|
||||
cargo tauri build
|
||||
----
|
||||
|
||||
Requires `Gemfile.lock` to exist (`bundle install` beforehand), since
|
||||
the Ruby app files are embedded into the bundle as resources. See
|
||||
`docs/architecture.adoc` for the current limitation around this build
|
||||
still depending on a system Ruby installation on the target machine.
|
||||
|
||||
=== Regenerating icons
|
||||
|
||||
Desktop icons live in `src-tauri/icons/`. To regenerate them from a
|
||||
new source image (at least 1024x1024 PNG):
|
||||
|
||||
[source,shell]
|
||||
----
|
||||
cd src-tauri
|
||||
cargo tauri icon path/to/source.png
|
||||
----
|
||||
Generated
-4495
File diff suppressed because it is too large.
Load diff
@@ -1,22 +0,0 @@
|
||||
[package]
|
||||
name = "maptool"
|
||||
version = "0.1.0"
|
||||
description = "Desktop shell for the MapTool mapping application"
|
||||
edition = "2021"
|
||||
rust-version = "1.77"
|
||||
|
||||
[lib]
|
||||
name = "maptool_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "2", features = [] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
||||
[[bin]]
|
||||
name = "maptool"
|
||||
path = "src/main.rs"
|
||||
@@ -1,3 +0,0 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 19 KiB |
@@ -1,59 +0,0 @@
|
||||
#[cfg(not(debug_assertions))]
|
||||
use std::process::{Child, Command};
|
||||
#[cfg(not(debug_assertions))]
|
||||
use std::sync::Mutex;
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
use tauri::Manager;
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
struct ServerProcess(Mutex<Option<Child>>);
|
||||
|
||||
pub fn run() {
|
||||
let builder = tauri::Builder::default();
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
let builder = builder.setup(|app| {
|
||||
let child = spawn_server(&app.handle())
|
||||
.expect("failed to start the Sinatra server (is Ruby/Bundler installed?)");
|
||||
app.manage(ServerProcess(Mutex::new(Some(child))));
|
||||
Ok(())
|
||||
});
|
||||
|
||||
let app = builder
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while building the tauri application");
|
||||
|
||||
app.run(|_app_handle, event| {
|
||||
#[cfg(not(debug_assertions))]
|
||||
if let tauri::RunEvent::ExitRequested { .. } = event {
|
||||
if let Some(state) = _app_handle.try_state::<ServerProcess>() {
|
||||
if let Some(mut child) = state.0.lock().unwrap().take() {
|
||||
let _ = child.kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// In development, `beforeDevCommand` (see tauri.conf.json) already starts the
|
||||
// Sinatra server, so the window just points at it. In a packaged build there
|
||||
// is no such hook, so the shell starts the server itself, next to the bundled
|
||||
// resources, and stops it again when the window closes.
|
||||
//
|
||||
// NOTE: this assumes a Ruby + Bundler installation on the target machine.
|
||||
// Producing a fully self-contained bundle (no external Ruby dependency)
|
||||
// requires embedding a Ruby runtime as a sidecar (e.g. via tebako) — see
|
||||
// docs/architecture.adoc for the open follow-up.
|
||||
#[cfg(not(debug_assertions))]
|
||||
fn spawn_server(app: &tauri::AppHandle) -> std::io::Result<Child> {
|
||||
let resource_dir = app
|
||||
.path()
|
||||
.resource_dir()
|
||||
.expect("failed to resolve the resource directory");
|
||||
|
||||
Command::new("bundle")
|
||||
.args(["exec", "puma", "-C", "config/puma.rb"])
|
||||
.current_dir(resource_dir)
|
||||
.spawn()
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
// Prevents an additional console window on Windows in release builds.
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
maptool_lib::run();
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "MapTool",
|
||||
"version": "0.1.0",
|
||||
"identifier": "net.priesol.maptool",
|
||||
"build": {
|
||||
"beforeDevCommand": "bundle exec puma -C ../config/puma.rb",
|
||||
"devUrl": "http://127.0.0.1:4567",
|
||||
"frontendDist": "http://127.0.0.1:4567"
|
||||
},
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "MapTool",
|
||||
"width": 1200,
|
||||
"height": 800,
|
||||
"minWidth": 800,
|
||||
"minHeight": 600
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": null
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"resources": {
|
||||
"../Gemfile": "Gemfile",
|
||||
"../Gemfile.lock": "Gemfile.lock",
|
||||
"../app.rb": "app.rb",
|
||||
"../config.ru": "config.ru",
|
||||
"../config/*": "config/",
|
||||
"../lib/*": "lib/",
|
||||
"../public/*": "public/",
|
||||
"../views/*": "views/"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user