feat: update to tauri beta, add permissions (#862)

Co-authored-by: Lucas Nogueira <lucas@tauri.app>
Co-authored-by: Lucas Nogueira <lucas@crabnebula.dev>
This commit is contained in:
Tillmann
2024-02-04 03:14:41 +09:00
committed by GitHub
parent 506ce4835b
commit d198c01486
387 changed files with 21883 additions and 943 deletions
+4 -4
View File
@@ -9,12 +9,12 @@ rust-version = { workspace = true }
links = "tauri-plugin-barcode-scanner"
[package.metadata.docs.rs]
rustc-args = [ "--cfg", "docsrs" ]
rustdoc-args = [ "--cfg", "docsrs" ]
targets = [ "x86_64-linux-android" ]
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]
targets = ["x86_64-linux-android"]
[build-dependencies]
tauri-build = { workspace = true }
tauri-plugin = { workspace = true, features = ["build"] }
[dependencies]
serde = { workspace = true }
+11 -2
View File
@@ -2,11 +2,20 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
const COMMANDS: &[&str] = &[
"scan",
"cancel",
"request_permissions",
"check_permissions",
"open_app_settings",
"vibrate",
];
fn main() {
if let Err(error) = tauri_build::mobile::PluginBuilder::new()
if let Err(error) = tauri_plugin::Builder::new(COMMANDS)
.android_path("android")
.ios_path("ios")
.run()
.try_build()
{
println!("{error:#}");
// when building documentation for Android the plugin build result is irrelevant to the crate itself
+5 -5
View File
@@ -39,14 +39,14 @@ export interface Scanned {
* @param options
*/
export async function scan(options?: ScanOptions): Promise<Scanned> {
return await invoke("plugin:barcodeScanner|scan", { ...options });
return await invoke("plugin:barcode-scanner|scan", { ...options });
}
/**
* Cancel the current scan process.
*/
export async function cancel(): Promise<void> {
return await invoke("plugin:barcodeScanner|cancel");
return await invoke("plugin:barcode-scanner|cancel");
}
/**
@@ -54,7 +54,7 @@ export async function cancel(): Promise<void> {
*/
export async function checkPermissions(): Promise<PermissionState> {
return await invoke<{ camera: PermissionState }>(
"plugin:barcodeScanner|checkPermissions",
"plugin:barcode-scanner|check_permissions",
).then((r) => r.camera);
}
@@ -63,7 +63,7 @@ export async function checkPermissions(): Promise<PermissionState> {
*/
export async function requestPermissions(): Promise<PermissionState> {
return await invoke<{ camera: PermissionState }>(
"plugin:barcodeScanner|requestPermissions",
"plugin:barcode-scanner|request_permissions",
).then((r) => r.camera);
}
@@ -71,5 +71,5 @@ export async function requestPermissions(): Promise<PermissionState> {
* Open application settings. Useful if permission was denied and the user must manually enable it.
*/
export async function openAppSettings(): Promise<void> {
return await invoke("plugin:barcodeScanner|openAppSettings");
return await invoke("plugin:barcode-scanner|open_app_settings");
}
+1 -1
View File
@@ -24,6 +24,6 @@
"LICENSE"
],
"dependencies": {
"@tauri-apps/api": "2.0.0-alpha.13"
"@tauri-apps/api": "2.0.0-beta.0"
}
}
@@ -0,0 +1 @@
schemas/
@@ -0,0 +1 @@
schemas/
@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-cancel"
description = "Enables the cancel command without any pre-configured scope."
commands.allow = ["cancel"]
[[permission]]
identifier = "deny-cancel"
description = "Denies the cancel command without any pre-configured scope."
commands.deny = ["cancel"]
@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-check-permissions"
description = "Enables the check_permissions command without any pre-configured scope."
commands.allow = ["check_permissions"]
[[permission]]
identifier = "deny-check-permissions"
description = "Denies the check_permissions command without any pre-configured scope."
commands.deny = ["check_permissions"]
@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-open-app-settings"
description = "Enables the open_app_settings command without any pre-configured scope."
commands.allow = ["open_app_settings"]
[[permission]]
identifier = "deny-open-app-settings"
description = "Denies the open_app_settings command without any pre-configured scope."
commands.deny = ["open_app_settings"]
@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-request-permissions"
description = "Enables the request_permissions command without any pre-configured scope."
commands.allow = ["request_permissions"]
[[permission]]
identifier = "deny-request-permissions"
description = "Denies the request_permissions command without any pre-configured scope."
commands.deny = ["request_permissions"]
@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-scan"
description = "Enables the scan command without any pre-configured scope."
commands.allow = ["scan"]
[[permission]]
identifier = "deny-scan"
description = "Denies the scan command without any pre-configured scope."
commands.deny = ["scan"]
@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!
"$schema" = "../../schemas/schema.json"
[[permission]]
identifier = "allow-vibrate"
description = "Enables the vibrate command without any pre-configured scope."
commands.allow = ["vibrate"]
[[permission]]
identifier = "deny-vibrate"
description = "Denies the vibrate command without any pre-configured scope."
commands.deny = ["vibrate"]
@@ -0,0 +1,50 @@
# Permissions
## allow-cancel
Enables the cancel command without any pre-configured scope.
## deny-cancel
Denies the cancel command without any pre-configured scope.
## allow-check-permissions
Enables the check_permissions command without any pre-configured scope.
## deny-check-permissions
Denies the check_permissions command without any pre-configured scope.
## allow-open-app-settings
Enables the open_app_settings command without any pre-configured scope.
## deny-open-app-settings
Denies the open_app_settings command without any pre-configured scope.
## allow-request-permissions
Enables the request_permissions command without any pre-configured scope.
## deny-request-permissions
Denies the request_permissions command without any pre-configured scope.
## allow-scan
Enables the scan command without any pre-configured scope.
## deny-scan
Denies the scan command without any pre-configured scope.
## allow-vibrate
Enables the vibrate command without any pre-configured scope.
## deny-vibrate
Denies the vibrate command without any pre-configured scope.
+1 -1
View File
@@ -1 +1 @@
if("__TAURI__"in window){var __TAURI_PLUGIN_BARCODESCANNER__=function(n){"use strict";async function e(n,e={},r){return window.__TAURI_INTERNALS__.invoke(n,e,r)}var r;return"function"==typeof SuppressedError&&SuppressedError,n.Format=void 0,(r=n.Format||(n.Format={})).QRCode="QR_CODE",r.UPC_A="UPC_A",r.UPC_E="UPC_E",r.EAN8="EAN_8",r.EAN13="EAN_13",r.Code39="CODE_39",r.Code93="CODE_93",r.Code128="CODE_128",r.Codabar="CODABAR",r.ITF="ITF",r.Aztec="AZTEC",r.DataMatrix="DATA_MATRIX",r.PDF417="PDF_417",n.cancel=async function(){return await e("plugin:barcodeScanner|cancel")},n.checkPermissions=async function(){return await e("plugin:barcodeScanner|checkPermissions").then((n=>n.camera))},n.openAppSettings=async function(){return await e("plugin:barcodeScanner|openAppSettings")},n.requestPermissions=async function(){return await e("plugin:barcodeScanner|requestPermissions").then((n=>n.camera))},n.scan=async function(n){return await e("plugin:barcodeScanner|scan",{...n})},n}({});Object.defineProperty(window.__TAURI__,"barcodeScanner",{value:__TAURI_PLUGIN_BARCODESCANNER__})}
if("__TAURI__"in window){var __TAURI_PLUGIN_BARCODESCANNER__=function(n){"use strict";async function e(n,e={},r){return window.__TAURI_INTERNALS__.invoke(n,e,r)}var r;return"function"==typeof SuppressedError&&SuppressedError,n.Format=void 0,(r=n.Format||(n.Format={})).QRCode="QR_CODE",r.UPC_A="UPC_A",r.UPC_E="UPC_E",r.EAN8="EAN_8",r.EAN13="EAN_13",r.Code39="CODE_39",r.Code93="CODE_93",r.Code128="CODE_128",r.Codabar="CODABAR",r.ITF="ITF",r.Aztec="AZTEC",r.DataMatrix="DATA_MATRIX",r.PDF417="PDF_417",n.cancel=async function(){return await e("plugin:barcode-scanner|cancel")},n.checkPermissions=async function(){return await e("plugin:barcode-scanner|check_permissions").then((n=>n.camera))},n.openAppSettings=async function(){return await e("plugin:barcode-scanner|open_app_settings")},n.requestPermissions=async function(){return await e("plugin:barcode-scanner|request_permissions").then((n=>n.camera))},n.scan=async function(n){return await e("plugin:barcode-scanner|scan",{...n})},n}({});Object.defineProperty(window.__TAURI__,"barcodeScanner",{value:__TAURI_PLUGIN_BARCODESCANNER__})}
+1 -1
View File
@@ -40,7 +40,7 @@ impl<R: Runtime, T: Manager<R>> crate::BarcodeScannerExt<R> for T {
/// Initializes the plugin.
pub fn init<R: Runtime>() -> TauriPlugin<R> {
Builder::new("barcodeScanner")
Builder::new("barcode-scanner")
.setup(|app, api| {
#[cfg(target_os = "android")]
let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "BarcodeScannerPlugin")?;