feat: update to alpha.17, typed mobile plugin IPC arguments (#676)

Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
This commit is contained in:
Lucas Fernandes Nogueira
2023-10-29 16:06:44 -03:00
committed by GitHub
parent 76cfdc32b4
commit e438e0a62d
158 changed files with 1677 additions and 1658 deletions
+2 -4
View File
@@ -7,7 +7,8 @@ license = { workspace = true }
links = "tauri-plugin-{{name}}"
[package.metadata.docs.rs]
features = [ "dox" ]
rustc-args = [ "--cfg", "docsrs" ]
rustdoc-args = [ "--cfg", "docsrs" ]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -20,6 +21,3 @@ serde_json = { workspace = true }
tauri = { workspace = true }
log = { workspace = true }
thiserror = { workspace = true }
[features]
dox = [ "tauri/dox" ]
@@ -6,18 +6,27 @@ package {{android_package_id}}
import android.app.Activity
import app.tauri.annotation.Command
import app.tauri.annotation.InvokeArg
import app.tauri.annotation.TauriPlugin
import app.tauri.plugin.JSObject
import app.tauri.plugin.Plugin
import app.tauri.plugin.Invoke
@InvokeArg
class PingArgs {
var value: String? = null
}
@TauriPlugin
class ExamplePlugin(private val activity: Activity): Plugin(activity) {
private val implementation = Example()
@Command
fun ping(invoke: Invoke) {
val value = invoke.getString("value") ?: ""
val args = invoke.parseArgs(PingArgs::class.java)
val ret = JSObject()
ret.put("value", value)
ret.put("value", implementation.pong(args.value ?: "default value :("))
invoke.resolve(ret)
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ fn main() {
{
println!("{error:#}");
// when building documentation for Android the plugin build result is irrelevant to the crate itself
if !(cfg!(feature = "dox") && std::env::var("TARGET").unwrap().contains("android")) {
if !(cfg!(docsrs) && std::env::var("TARGET").unwrap().contains("android")) {
std::process::exit(1);
}
}
@@ -2,16 +2,20 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import SwiftRs
import Tauri
import UIKit
import WebKit
import Tauri
import SwiftRs
class PingArgs: Decodable {
let value: String?
}
class ExamplePlugin: Plugin {
@objc public func ping(_ invoke: Invoke) throws {
let value = invoke.getString("value")
invoke.resolve(["value": value as Any])
}
@objc public func ping(_ invoke: Invoke) throws {
let args = try invoke.parseArgs(PingArgs.self)
invoke.resolve(["value": args.value ?? ""])
}
}
@_cdecl("init_plugin_{{ plugin_name_snake_case }}")
+1 -1
View File
@@ -27,6 +27,6 @@
"tslib": "2.6.0"
},
"dependencies": {
"@tauri-apps/api": "2.0.0-alpha.9"
"@tauri-apps/api": "2.0.0-alpha.11"
}
}