summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-27 19:13:03 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-27 19:13:03 +0100
commit2df51e89039b9b160aafb52b700e874411eb0555 (patch)
treeffed8ff63fb39a422f7d14d1c6da3e8281997631
parent2d3cba97ff6ffbfe094ed0045329d875c6d1960b (diff)
wipfel: PWA — manifest, service worker, Web Share Target
- manifest.webmanifest: standalone, dark theme, mountain icons (regular + maskable) - sw.js: network-first with cache fallback -> full offline after first visit (wasm + hill DB included); versioned cache, stale caches pruned - share_target: images shared to the installed app are POSTed to __share; the SW stashes the bytes at __shared and redirects with ?shared=1; the app picks them up on startup and cleans the URL - index.html: manifest link, theme-color, icons, SW registration - build/serve scripts ship the new files; dist refreshed Note: sharing does not bypass AOSP GPS redaction when the share source passes a MediaStore URI (the browser is still the reader) — the .nomedia/rename trick remains the way to get GPS EXIF into a browser.
-rwxr-xr-xcrates/wipfel/build-release.sh3
-rwxr-xr-xcrates/wipfel/serve-here.sh3
-rw-r--r--crates/wipfel/src/app.rs32
-rw-r--r--crates/wipfel/www/icons/icon-192.pngbin0 -> 1425 bytes
-rw-r--r--crates/wipfel/www/icons/icon-512.pngbin0 -> 4371 bytes
-rw-r--r--crates/wipfel/www/icons/icon-maskable-512.pngbin0 -> 4005 bytes
-rw-r--r--crates/wipfel/www/index.html11
-rw-r--r--crates/wipfel/www/manifest.webmanifest25
-rw-r--r--crates/wipfel/www/sw.js115
-rw-r--r--dist/wipfel/icons/icon-192.pngbin0 -> 1425 bytes
-rw-r--r--dist/wipfel/icons/icon-512.pngbin0 -> 4371 bytes
-rw-r--r--dist/wipfel/icons/icon-maskable-512.pngbin0 -> 4005 bytes
-rw-r--r--dist/wipfel/index.html11
-rw-r--r--dist/wipfel/manifest.webmanifest25
-rw-r--r--dist/wipfel/sw.js115
-rw-r--r--dist/wipfel/wipfel.js22
-rw-r--r--dist/wipfel/wipfel_bg.wasmbin511473 -> 515519 bytes
17 files changed, 360 insertions, 2 deletions
diff --git a/crates/wipfel/build-release.sh b/crates/wipfel/build-release.sh
index 1ee09b7..bf41513 100755
--- a/crates/wipfel/build-release.sh
+++ b/crates/wipfel/build-release.sh
@@ -16,6 +16,9 @@ wasm-bindgen --remove-name-section --target web --out-dir "$DIST" target/wasm32-
# the loader page (not the trunk entry point, which is dev-only)
rm -f "$DIST"/wipfel.d.ts "$DIST"/wipfel_bg.wasm.d.ts
cp crates/wipfel/www/index.html crates/wipfel/www/style.css "$DIST/"
+cp crates/wipfel/www/sw.js crates/wipfel/www/manifest.webmanifest "$DIST/"
+mkdir -p "$DIST/icons"
+cp crates/wipfel/www/icons/*.png "$DIST/icons/"
gzip -9 -n -c gipfel.dat > "$DIST/gipfel.dat.gz"
echo "site assembled in $DIST ($(du -sh "$DIST" | cut -f1)):"
ls "$DIST"
diff --git a/crates/wipfel/serve-here.sh b/crates/wipfel/serve-here.sh
index 2accdb9..9951829 100755
--- a/crates/wipfel/serve-here.sh
+++ b/crates/wipfel/serve-here.sh
@@ -8,5 +8,8 @@ DIST=/tmp/wipfel-dist
mkdir -p "$DIST"
wasm-bindgen --target web --out-dir "$DIST" target/wasm32-unknown-unknown/release/wipfel.wasm
cp crates/wipfel/www/index.html crates/wipfel/www/style.css "$DIST/"
+cp crates/wipfel/www/sw.js crates/wipfel/www/manifest.webmanifest "$DIST/"
+mkdir -p "$DIST/icons"
+cp crates/wipfel/www/icons/*.png "$DIST/icons/"
gzip -9 -n -c gipfel.dat > "$DIST/gipfel.dat.gz"
echo "dist refreshed: $(ls -la "$DIST" | awk '{s+=$5} END {print s" bytes"}')"
diff --git a/crates/wipfel/src/app.rs b/crates/wipfel/src/app.rs
index 78961fc..441f17c 100644
--- a/crates/wipfel/src/app.rs
+++ b/crates/wipfel/src/app.rs
@@ -11,6 +11,7 @@ use gipfel_core::metadata::{apply_image_metadata, ImageMetaData};
use gipfel_core::panorama::Panorama;
use wasm_bindgen::closure::Closure;
use wasm_bindgen::JsCast;
+use wasm_bindgen::JsValue;
use wasm_bindgen_futures::spawn_local;
use web_sys::{DragEvent, Event, HtmlCanvasElement, HtmlInputElement, InputEvent, MouseEvent};
use yew::prelude::*;
@@ -450,6 +451,37 @@ pub fn app() -> Html {
})
};
+ // Web Share Target handoff: the service worker stashes the shared
+ // file at `__shared` and redirects here with ?shared=1
+ {
+ let load_bytes = load_bytes.clone();
+ let status = status.clone();
+ use_effect_with((), move |_| {
+ let shared = web_sys::window()
+ .map(|w| {
+ w.location()
+ .search()
+ .map(|s| s.contains("shared=1"))
+ .unwrap_or(false)
+ })
+ .unwrap_or(false);
+ if shared {
+ spawn_local(async move {
+ match bridge::fetch_bytes("__shared").await {
+ Ok(bytes) => load_bytes.emit((bytes, "shared image".into())),
+ Err(e) => status.set(format!("shared image missing: {e}")),
+ }
+ });
+ if let Some(w) = web_sys::window() {
+ let _ = w
+ .history()
+ .and_then(|h| h.replace_state_with_url(&JsValue::NULL, "", Some("./")));
+ }
+ }
+ || ()
+ });
+ }
+
let on_drop = {
let read_file = read_file.clone();
let status = status.clone();
diff --git a/crates/wipfel/www/icons/icon-192.png b/crates/wipfel/www/icons/icon-192.png
new file mode 100644
index 0000000..07262f1
--- /dev/null
+++ b/crates/wipfel/www/icons/icon-192.png
Binary files differ
diff --git a/crates/wipfel/www/icons/icon-512.png b/crates/wipfel/www/icons/icon-512.png
new file mode 100644
index 0000000..e1f8dd0
--- /dev/null
+++ b/crates/wipfel/www/icons/icon-512.png
Binary files differ
diff --git a/crates/wipfel/www/icons/icon-maskable-512.png b/crates/wipfel/www/icons/icon-maskable-512.png
new file mode 100644
index 0000000..6dd4595
--- /dev/null
+++ b/crates/wipfel/www/icons/icon-maskable-512.png
Binary files differ
diff --git a/crates/wipfel/www/index.html b/crates/wipfel/www/index.html
index 98f81e8..69dd433 100644
--- a/crates/wipfel/www/index.html
+++ b/crates/wipfel/www/index.html
@@ -3,7 +3,11 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
+ <meta name="theme-color" content="#141418" />
<title>wipfel — web based gipfel photogrammetry</title>
+ <link rel="manifest" href="manifest.webmanifest" />
+ <link rel="icon" type="image/png" sizes="192x192" href="icons/icon-192.png" />
+ <link rel="apple-touch-icon" href="icons/icon-192.png" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
@@ -11,5 +15,12 @@
import init from './wipfel.js';
init();
</script>
+ <script>
+ if ('serviceWorker' in navigator) {
+ window.addEventListener('load', () => {
+ navigator.serviceWorker.register('./sw.js');
+ });
+ }
+ </script>
</body>
</html>
diff --git a/crates/wipfel/www/manifest.webmanifest b/crates/wipfel/www/manifest.webmanifest
new file mode 100644
index 0000000..29996fb
--- /dev/null
+++ b/crates/wipfel/www/manifest.webmanifest
@@ -0,0 +1,25 @@
+{
+ "name": "wipfel — web based gipfel photogrammetry",
+ "short_name": "wipfel",
+ "description": "Measure mountains from photographs. All processing stays on your device.",
+ "start_url": "./",
+ "scope": "./",
+ "display": "standalone",
+ "background_color": "#141418",
+ "theme_color": "#141418",
+ "icons": [
+ { "src": "icons/icon-192.png", "sizes": "192x192", "type": "image/png" },
+ { "src": "icons/icon-512.png", "sizes": "512x512", "type": "image/png" },
+ { "src": "icons/icon-maskable-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }
+ ],
+ "share_target": {
+ "action": "__share",
+ "method": "POST",
+ "enctype": "multipart/form-data",
+ "params": {
+ "files": [
+ { "name": "files", "accept": ["image/jpeg", "image/png", "image/webp"] }
+ ]
+ }
+ }
+}
diff --git a/crates/wipfel/www/sw.js b/crates/wipfel/www/sw.js
new file mode 100644
index 0000000..2a5cfdc
--- /dev/null
+++ b/crates/wipfel/www/sw.js
@@ -0,0 +1,115 @@
+/* wipfel service worker: full offline + Web Share Target.
+ *
+ * Strategy: network-first with cache fallback, so an online app is
+ * always fresh and the app still starts offline after the first visit.
+ *
+ * Share target: the browser POSTs multipart/form-data to __share; we
+ * stash the file in a cache under __shared and redirect to the app
+ * with ?shared=1, which the app picks up on startup.
+ */
+const VERSION = "wipfel-v1";
+const SHARE_CACHE = "wipfel-share";
+const base = self.registration.scope;
+const url = (p) => new URL(p, base).href;
+const sharePath = new URL("__share", base).pathname;
+const sharedPath = new URL("__shared", base).pathname;
+
+const SHELL = [
+ "",
+ "index.html",
+ "wipfel.js",
+ "wipfel_bg.wasm",
+ "style.css",
+ "gipfel.dat.gz",
+ "manifest.webmanifest",
+ "icons/icon-192.png",
+ "icons/icon-512.png",
+ "icons/icon-maskable-512.png",
+].map(url);
+
+self.addEventListener("install", (e) => {
+ e.waitUntil(
+ caches
+ .open(VERSION)
+ .then((c) => c.addAll(SHELL))
+ .then(() => self.skipWaiting())
+ );
+});
+
+self.addEventListener("activate", (e) => {
+ e.waitUntil(
+ caches
+ .keys()
+ .then((keys) =>
+ Promise.all(
+ keys.filter((k) => k !== VERSION && k !== SHARE_CACHE).map((k) => caches.delete(k))
+ )
+ )
+ .then(() => self.clients.claim())
+ );
+});
+
+self.addEventListener("fetch", (e) => {
+ const req = e.request;
+ const u = new URL(req.url);
+ if (u.origin !== self.location.origin) return;
+
+ // Web Share Target handoff
+ if (req.method === "POST" && u.pathname === sharePath) {
+ e.respondWith(
+ (async () => {
+ const form = await req.formData();
+ const file = form.getAll("files")[0] || form.get("files");
+ if (file && file.size) {
+ const buf = await file.arrayBuffer();
+ const cache = await caches.open(SHARE_CACHE);
+ await cache.put(
+ sharedPath,
+ new Response(buf, {
+ headers: {
+ "Content-Type": file.type || "image/jpeg",
+ "X-File-Name": encodeURIComponent(file.name || "shared.jpg"),
+ },
+ })
+ );
+ }
+ return Response.redirect(url("?shared=1"), 303);
+ })()
+ );
+ return;
+ }
+
+ // the stashed shared image
+ if (req.method === "GET" && u.pathname === sharedPath) {
+ e.respondWith(
+ caches.open(SHARE_CACHE).then((c) =>
+ c.match(sharedPath).then(
+ (r) => r || new Response("no shared image", { status: 410 })
+ )
+ )
+ );
+ return;
+ }
+
+ // app assets: network first, cache fallback
+ e.respondWith(
+ (async () => {
+ try {
+ const res = await fetch(req);
+ if (res.ok) {
+ const cache = await caches.open(VERSION);
+ cache.put(req, res.clone());
+ }
+ return res;
+ } catch (err) {
+ const cached = await caches.match(req, { ignoreSearch: true });
+ if (cached) return cached;
+ if (req.mode === "navigate") {
+ const idx = await caches.match(url("index.html"));
+ if (idx) return idx;
+ }
+ throw err;
+ }
+ })()
+ );
+});
diff --git a/dist/wipfel/icons/icon-192.png b/dist/wipfel/icons/icon-192.png
new file mode 100644
index 0000000..07262f1
--- /dev/null
+++ b/dist/wipfel/icons/icon-192.png
Binary files differ
diff --git a/dist/wipfel/icons/icon-512.png b/dist/wipfel/icons/icon-512.png
new file mode 100644
index 0000000..e1f8dd0
--- /dev/null
+++ b/dist/wipfel/icons/icon-512.png
Binary files differ
diff --git a/dist/wipfel/icons/icon-maskable-512.png b/dist/wipfel/icons/icon-maskable-512.png
new file mode 100644
index 0000000..6dd4595
--- /dev/null
+++ b/dist/wipfel/icons/icon-maskable-512.png
Binary files differ
diff --git a/dist/wipfel/index.html b/dist/wipfel/index.html
index 98f81e8..69dd433 100644
--- a/dist/wipfel/index.html
+++ b/dist/wipfel/index.html
@@ -3,7 +3,11 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
+ <meta name="theme-color" content="#141418" />
<title>wipfel — web based gipfel photogrammetry</title>
+ <link rel="manifest" href="manifest.webmanifest" />
+ <link rel="icon" type="image/png" sizes="192x192" href="icons/icon-192.png" />
+ <link rel="apple-touch-icon" href="icons/icon-192.png" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
@@ -11,5 +15,12 @@
import init from './wipfel.js';
init();
</script>
+ <script>
+ if ('serviceWorker' in navigator) {
+ window.addEventListener('load', () => {
+ navigator.serviceWorker.register('./sw.js');
+ });
+ }
+ </script>
</body>
</html>
diff --git a/dist/wipfel/manifest.webmanifest b/dist/wipfel/manifest.webmanifest
new file mode 100644
index 0000000..29996fb
--- /dev/null
+++ b/dist/wipfel/manifest.webmanifest
@@ -0,0 +1,25 @@
+{
+ "name": "wipfel — web based gipfel photogrammetry",
+ "short_name": "wipfel",
+ "description": "Measure mountains from photographs. All processing stays on your device.",
+ "start_url": "./",
+ "scope": "./",
+ "display": "standalone",
+ "background_color": "#141418",
+ "theme_color": "#141418",
+ "icons": [
+ { "src": "icons/icon-192.png", "sizes": "192x192", "type": "image/png" },
+ { "src": "icons/icon-512.png", "sizes": "512x512", "type": "image/png" },
+ { "src": "icons/icon-maskable-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }
+ ],
+ "share_target": {
+ "action": "__share",
+ "method": "POST",
+ "enctype": "multipart/form-data",
+ "params": {
+ "files": [
+ { "name": "files", "accept": ["image/jpeg", "image/png", "image/webp"] }
+ ]
+ }
+ }
+}
diff --git a/dist/wipfel/sw.js b/dist/wipfel/sw.js
new file mode 100644
index 0000000..2a5cfdc
--- /dev/null
+++ b/dist/wipfel/sw.js
@@ -0,0 +1,115 @@
+/* wipfel service worker: full offline + Web Share Target.
+ *
+ * Strategy: network-first with cache fallback, so an online app is
+ * always fresh and the app still starts offline after the first visit.
+ *
+ * Share target: the browser POSTs multipart/form-data to __share; we
+ * stash the file in a cache under __shared and redirect to the app
+ * with ?shared=1, which the app picks up on startup.
+ */
+const VERSION = "wipfel-v1";
+const SHARE_CACHE = "wipfel-share";
+const base = self.registration.scope;
+const url = (p) => new URL(p, base).href;
+const sharePath = new URL("__share", base).pathname;
+const sharedPath = new URL("__shared", base).pathname;
+
+const SHELL = [
+ "",
+ "index.html",
+ "wipfel.js",
+ "wipfel_bg.wasm",
+ "style.css",
+ "gipfel.dat.gz",
+ "manifest.webmanifest",
+ "icons/icon-192.png",
+ "icons/icon-512.png",
+ "icons/icon-maskable-512.png",
+].map(url);
+
+self.addEventListener("install", (e) => {
+ e.waitUntil(
+ caches
+ .open(VERSION)
+ .then((c) => c.addAll(SHELL))
+ .then(() => self.skipWaiting())
+ );
+});
+
+self.addEventListener("activate", (e) => {
+ e.waitUntil(
+ caches
+ .keys()
+ .then((keys) =>
+ Promise.all(
+ keys.filter((k) => k !== VERSION && k !== SHARE_CACHE).map((k) => caches.delete(k))
+ )
+ )
+ .then(() => self.clients.claim())
+ );
+});
+
+self.addEventListener("fetch", (e) => {
+ const req = e.request;
+ const u = new URL(req.url);
+ if (u.origin !== self.location.origin) return;
+
+ // Web Share Target handoff
+ if (req.method === "POST" && u.pathname === sharePath) {
+ e.respondWith(
+ (async () => {
+ const form = await req.formData();
+ const file = form.getAll("files")[0] || form.get("files");
+ if (file && file.size) {
+ const buf = await file.arrayBuffer();
+ const cache = await caches.open(SHARE_CACHE);
+ await cache.put(
+ sharedPath,
+ new Response(buf, {
+ headers: {
+ "Content-Type": file.type || "image/jpeg",
+ "X-File-Name": encodeURIComponent(file.name || "shared.jpg"),
+ },
+ })
+ );
+ }
+ return Response.redirect(url("?shared=1"), 303);
+ })()
+ );
+ return;
+ }
+
+ // the stashed shared image
+ if (req.method === "GET" && u.pathname === sharedPath) {
+ e.respondWith(
+ caches.open(SHARE_CACHE).then((c) =>
+ c.match(sharedPath).then(
+ (r) => r || new Response("no shared image", { status: 410 })
+ )
+ )
+ );
+ return;
+ }
+
+ // app assets: network first, cache fallback
+ e.respondWith(
+ (async () => {
+ try {
+ const res = await fetch(req);
+ if (res.ok) {
+ const cache = await caches.open(VERSION);
+ cache.put(req, res.clone());
+ }
+ return res;
+ } catch (err) {
+ const cached = await caches.match(req, { ignoreSearch: true });
+ if (cached) return cached;
+ if (req.mode === "navigate") {
+ const idx = await caches.match(url("index.html"));
+ if (idx) return idx;
+ }
+ throw err;
+ }
+ })()
+ );
+});
diff --git a/dist/wipfel/wipfel.js b/dist/wipfel/wipfel.js
index e1eedc0..9e90bc5 100644
--- a/dist/wipfel/wipfel.js
+++ b/dist/wipfel/wipfel.js
@@ -210,6 +210,10 @@ function __wbg_get_imports() {
const ret = arg0.height;
return ret;
},
+ __wbg_history_4128e7793fa4758c: function() { return handleError(function (arg0) {
+ const ret = arg0.history;
+ return ret;
+ }, arguments); },
__wbg_host_c1e5897b2ece281c: function(arg0) {
const ret = arg0.host;
return ret;
@@ -313,6 +317,10 @@ function __wbg_get_imports() {
const ret = arg0.__yew_listener_id;
return isLikeNone(ret) ? Number.MAX_SAFE_INTEGER : (ret) >>> 0;
},
+ __wbg_location_9c46e8ada95d3174: function(arg0) {
+ const ret = arg0.location;
+ return ret;
+ },
__wbg_measureText_1035b288be51876c: function() { return handleError(function (arg0, arg1, arg2) {
const ret = arg0.measureText(getStringFromWasm0(arg1, arg2));
return ret;
@@ -441,10 +449,20 @@ function __wbg_get_imports() {
const ret = arg0.removeChild(arg1);
return ret;
}, arguments); },
+ __wbg_replaceState_8814bbf1e44e1990: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
+ arg0.replaceState(arg1, getStringFromWasm0(arg2, arg3), arg4 === 0 ? undefined : getStringFromWasm0(arg4, arg5));
+ }, arguments); },
__wbg_resolve_0076e10020304ede: function(arg0) {
const ret = Promise.resolve(arg0);
return ret;
},
+ __wbg_search_31c06ba77ebf51f4: function() { return handleError(function (arg0, arg1) {
+ const ret = arg1.search;
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
+ const len1 = WASM_VECTOR_LEN;
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
+ }, arguments); },
__wbg_setAttribute_9e7d603908f63705: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
arg0.setAttribute(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
}, arguments); },
@@ -605,7 +623,7 @@ function __wbg_get_imports() {
return ret;
},
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Array<any>"), NamedExternref("ResizeObserver")], shim_idx: 75, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Array<any>"), NamedExternref("ResizeObserver")], shim_idx: 70, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
const ret = makeClosure(arg0, arg1, wasm_bindgen_f1f668f83a5f514b___convert__closures_____invoke___js_sys_351dd7d36d5f7033___Array__web_sys_d6718dd818f67bd6___features__gen_ResizeObserver__ResizeObserver______true_);
return ret;
},
@@ -615,7 +633,7 @@ function __wbg_get_imports() {
return ret;
},
__wbindgen_generic_0000000000000004: function(arg0, arg1) {
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 77, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 72, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
const ret = makeClosure(arg0, arg1, wasm_bindgen_f1f668f83a5f514b___convert__closures_____invoke_______true_);
return ret;
},
diff --git a/dist/wipfel/wipfel_bg.wasm b/dist/wipfel/wipfel_bg.wasm
index 3b906d2..97cec2d 100644
--- a/dist/wipfel/wipfel_bg.wasm
+++ b/dist/wipfel/wipfel_bg.wasm
Binary files differ