Installable PWA with a share target; design for an item-based library
CI / check (push) Successful in 18s
CI / deploy (push) Successful in 13s

Android's share sheet (OsmAnd, Locus, mapy.com, ...) can now send
GPX/FIT/GeoJSON/ZIP files to the installed app: the service worker parks
them and the page offers to import them into a Tracks & Points folder,
waiting through a login if needed. Manifest, app icon, a server-side
fallback for /share-target.

docs/library-design.adoc proposes replacing the file-based GpxStore with
folders and items (stable ids, timestamps, tombstones, a change feed) as
the base for syncing with OsmAnd and Locus.
This commit is contained in:
randy committed 2026-11-12 13:42:04 +01:00
1 parent e2461f794c
commit 25b87b94fe
14 files changed
+637 -5

No files matched your search

+17 -3
View File
@@ -957,10 +957,11 @@ export class GpxPanelControl {
// file already in this app's own shape (e.g. a previous /api/gpx/file
// response, saved and re-uploaded) can skip GPX/FIT entirely.
const files = [...fileList].filter((file) => /\.(gpx|fit|geojson|zip)$/i.test(file.name));
if (files.length === 0) return;
if (files.length === 0) return [];
let tree = null;
let failed = 0;
const uploaded = [];
for (const [index, file] of files.entries()) {
this._setStatus(files.length === 1 ? "Uploading…" : `Uploading ${index + 1} of ${files.length}…`);
@@ -978,10 +979,12 @@ export class GpxPanelControl {
const xhr = await uploadFile(formData, () => this._setStatus("Converting…"));
if (xhr.status === 401) {
window.location.href = "/login";
return;
return uploaded;
}
if (xhr.status < 200 || xhr.status >= 300) throw new Error("upload failed");
({ tree } = JSON.parse(xhr.responseText));
let paths;
({ tree, paths } = JSON.parse(xhr.responseText));
uploaded.push(...paths);
} catch (err) {
failed += 1;
}
@@ -989,6 +992,17 @@ export class GpxPanelControl {
if (tree) this._renderTree(tree);
this._setStatus(failed > 0 ? `${failed} of ${files.length} uploads failed.` : "Uploaded.");
return uploaded;
}
// Files shared to the installed app (share_import.js): uploaded like a
// drop onto the tree, then shown on the map straight away — whoever
// shared a track from OsmAnd/Locus wants to see it, not hunt for it.
async importFiles(files, folder) {
this._togglePanel(true);
const paths = await this._uploadFiles(files, folder);
await Promise.all(paths.map((path) => this.show(path)));
return paths;
}
async _deleteFile(path) {