@multiplatform.one/desktop
v7.4.1
Published
Desktop platform APIs (Tauri) for multiplatform.one
Readme
@multiplatform.one/desktop
Capability interfaces for desktop-only concerns — file system, dialogs, paths, and updater — behind one import that no-ops (or throws clearly) everywhere the capability does not exist.
Install
pnpm add @multiplatform.one/desktopPeers (Tauri builds only, all optional): @tauri-apps/api,
@tauri-apps/plugin-dialog, @tauri-apps/plugin-fs,
@tauri-apps/plugin-updater.
What it owns
fs—readTextFile,writeTextFile,exists,mkdir,remove,rename,copyFiledialog—open,save,message,ask,confirm,promptpaths— well-known directories (home, app data, …)updater— check/install app updates
Each API is an interface plus a default implementation, so shared code (for
example @multiplatform.one/frappe-ui's FrappeForm delete confirm) can
import it unconditionally on every platform.
State of play. Tauri is the one backend with a full implementation: each API has a
.taurifile (selected at build time in Tauri bundles) that rides the matching@tauri-apps/plugin-*peer. A Tauri window running the plain web bundle (dev mode) gets the web defaults, which work there — the webview has the browser modals.Outside Tauri:
dialog.message,.ask,.confirmand.promptare the browser's modal globals and are therefore web-only. On GNOME they throw a named error: GJS has nowindow.confirm, and neither silently returningfalse(a confirm button that appears broken) nor silently returningtrue(a delete nobody agreed to) is a defensible default for a confirmation.dialog.openand.savereturnnullon both.fsandpathsreport unsupported outside Tauri;updateris a no-op there.The GNOME target has real GTK equivalents available (
Gtk.FileDialog,Adw.AlertDialog,GLib.get_user_*_dir); wiring them up asindex.gnome.tsfiles behind these same interfaces is the natural next step — the interfaces exist precisely so that lands as an implementation rather than an API change.
What it must not do
- No UI and no window management — this package wraps capabilities, not chrome
Usage
import { dialog, fs } from "@multiplatform.one/desktop";
export async function exportNotes(contents: string) {
const path = await dialog.save({ defaultPath: "notes.md" });
if (!path) return;
await fs.writeTextFile(path, contents);
await dialog.message("Notes exported");
}License
Apache-2.0
