mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-21 11:26:15 +02:00
9606089b2a
* init geolocation plugin * ios impl (w/o js api) * generate ts api * use newer tauri commit * add temporary postinstall * include src in files * guest-js * just ship dist-js for now * fix watcher * fix android compile error * fix android build for real * fix heading type * initial getCurrentPosition android impl (wip) * prevent panics if errors (strings) are sent over the channel * Add android watchPosition implementation * init haptics plugin (android) * ios and new apis (ANDROID IS LIKELY BROKEN - MAY NOT EVEN COMPILE) * use tauri-specta that accounts for raw fn arg idents * add complete android support (it's not working great due to random soft-/hardware support) * fix(haptics): Fix the NotificationFeedbackType::Success and Version (#1) * Fix success feedback and version * Apply suggestions from code review * Update package.json --------- Co-authored-by: Fabian-Lars <118197967+FabianLars-crabnebula@users.noreply.github.com> * android: improve permission callback handling * keep track of ongoing perms requests * rebuild * license headers * rm sqlite feat * fmt * what diff u talkin bout? * ignore dist-js again * fix audits * dedupe api.js * clippy * changefiles * readmes * clean up todos * rm dsstore * rm wrong feats * mirror * covector * rebuild * ios requires the wry feature * lint * update lock --------- Co-authored-by: fabianlars <fabianlars@fabianlars.de> Co-authored-by: Brendan Allan <brendonovich@outlook.com> Co-authored-by: Naman Garg <155433377+naman-crabnebula@users.noreply.github.com> Co-authored-by: Lucas Nogueira <lucas@crabnebula.dev>
101 lines
2.6 KiB
Rust
101 lines
2.6 KiB
Rust
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
use tauri::{
|
|
plugin::{Builder, TauriPlugin},
|
|
Manager, Runtime,
|
|
};
|
|
|
|
//use tauri_specta::*;
|
|
|
|
pub use models::*;
|
|
|
|
#[cfg(desktop)]
|
|
mod desktop;
|
|
#[cfg(mobile)]
|
|
mod mobile;
|
|
|
|
mod commands;
|
|
mod error;
|
|
mod models;
|
|
|
|
pub use error::{Error, Result};
|
|
|
|
#[cfg(desktop)]
|
|
use desktop::Geolocation;
|
|
#[cfg(mobile)]
|
|
use mobile::Geolocation;
|
|
|
|
/* macro_rules! specta_builder {
|
|
() => {
|
|
ts::builder()
|
|
.commands(collect_commands![
|
|
commands::get_current_position,
|
|
commands::watch_position,
|
|
commands::clear_watch,
|
|
commands::check_permissions,
|
|
commands::request_permissions
|
|
])
|
|
.header("// @ts-nocheck")
|
|
.config(
|
|
specta::ts::ExportConfig::default()
|
|
.bigint(specta::ts::BigIntExportBehavior::Number),
|
|
)
|
|
};
|
|
} */
|
|
|
|
/// Extensions to [`tauri::App`], [`tauri::AppHandle`], [`tauri::WebviewWindow`], [`tauri::Webview`] and [`tauri::Window`] to access the geolocation APIs.
|
|
pub trait GeolocationExt<R: Runtime> {
|
|
fn geolocation(&self) -> &Geolocation<R>;
|
|
}
|
|
|
|
impl<R: Runtime, T: Manager<R>> crate::GeolocationExt<R> for T {
|
|
fn geolocation(&self) -> &Geolocation<R> {
|
|
self.state::<Geolocation<R>>().inner()
|
|
}
|
|
}
|
|
|
|
/// Initializes the plugin.
|
|
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
|
/* let (invoke_handler, register_events) =
|
|
specta_builder!().build_plugin_utils("geolocation").unwrap(); */
|
|
|
|
Builder::new("geolocation")
|
|
.invoke_handler(tauri::generate_handler![
|
|
commands::get_current_position,
|
|
commands::watch_position,
|
|
commands::clear_watch,
|
|
commands::check_permissions,
|
|
commands::request_permissions
|
|
])
|
|
.setup(|app, api| {
|
|
#[cfg(mobile)]
|
|
let geolocation = mobile::init(app, api)?;
|
|
#[cfg(desktop)]
|
|
let geolocation = desktop::init(app, api)?;
|
|
app.manage(geolocation);
|
|
Ok(())
|
|
})
|
|
.build()
|
|
}
|
|
|
|
/* #[cfg(test)]
|
|
mod test {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn export_types() {
|
|
specta_builder!()
|
|
.path("./guest-js/bindings.ts")
|
|
.config(
|
|
specta::ts::ExportConfig::default()
|
|
.formatter(specta::ts::formatter::prettier)
|
|
.bigint(specta::ts::BigIntExportBehavior::Number),
|
|
)
|
|
.export_for_plugin("geolocation")
|
|
.expect("failed to export specta types");
|
|
}
|
|
}
|
|
*/
|