update camera android project

pull/260/head
Lucas Nogueira 2 years ago
parent a2c43553ad
commit 66949e2490
No known key found for this signature in database
GPG Key ID: 7C32FCA95C8C95D7

@ -1,2 +1,2 @@
include ':tauri-android'
project(':tauri-android').projectDir = new File('./tauri-api')
project(':tauri-android').projectDir = new File('./.tauri/tauri-api')

@ -1,4 +1,4 @@
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

@ -1,8 +1,103 @@
var f$1=Object.defineProperty;var g=(a,b)=>{for(var c in b)f$1(a,c,{get:b[c],enumerable:!0});};var e=(a,b,c)=>{if(!b.has(a))throw TypeError("Cannot "+c)};var h$1=(a,b,c)=>(e(a,b,"read from private field"),c?c.call(a):b.get(a)),i$1=(a,b,c)=>{if(b.has(a))throw TypeError("Cannot add the same private member more than once");b instanceof WeakSet?b.add(a):b.set(a,c);},j=(a,b,c,d)=>(e(a,b,"write to private field"),d?d.call(a,c):b.set(a,c),c);
var f$1 = Object.defineProperty;
var g = (a, b) => {
for (var c in b) f$1(a, c, {
get: b[c],
enumerable: !0
});
};
var e = (a, b, c) => {
if (!b.has(a)) throw TypeError("Cannot " + c)
};
var h$1 = (a, b, c) => (e(a, b, "read from private field"), c ? c.call(a) : b.get(a)),
i$1 = (a, b, c) => {
if (b.has(a)) throw TypeError("Cannot add the same private member more than once");
b instanceof WeakSet ? b.add(a) : b.set(a, c);
},
j = (a, b, c, d) => (e(a, b, "write to private field"), d ? d.call(a, c) : b.set(a, c), c);
var h={};g(h,{Channel:()=>o,PluginListener:()=>a,addPluginListener:()=>m,convertFileSrc:()=>y,invoke:()=>u,transformCallback:()=>s});function f(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function s(n,e=!1){let t=f(),r=`_${t}`;return Object.defineProperty(window,r,{value:c=>(e&&Reflect.deleteProperty(window,r),n?.(c)),writable:!1,configurable:!0}),t}var i,o=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0;i$1(this,i,()=>{});this.id=s(e=>{h$1(this,i).call(this,e);});}set onmessage(e){j(this,i,e);}get onmessage(){return h$1(this,i)}toJSON(){return `__CHANNEL__:${this.id}`}};i=new WeakMap;var a=class{constructor(e,t,r){this.plugin=e,this.event=t,this.channelId=r;}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function m(n,e,t){let r=new o;return r.onmessage=t,u(`plugin:${n}|register_listener`,{event:e,handler:r}).then(()=>new a(n,e,r.id))}async function u(n,e={},t){return new Promise((r,c)=>{let g=s(d=>{r(d),Reflect.deleteProperty(window,`_${_}`);},!0),_=s(d=>{c(d),Reflect.deleteProperty(window,`_${g}`);},!0);window.__TAURI_IPC__({cmd:n,callback:g,error:_,payload:e,options:t});})}function y(n,e="asset"){return window.__TAURI__.convertFileSrc(n,e)}
var h = {};
g(h, {
Channel: () => o,
PluginListener: () => a,
addPluginListener: () => m,
convertFileSrc: () => y,
invoke: () => u,
transformCallback: () => s
});
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
function f() {
return window.crypto.getRandomValues(new Uint32Array(1))[0]
}
function s(n, e = !1) {
let t = f(),
r = `_${t}`;
return Object.defineProperty(window, r, {
value: c => (e && Reflect.deleteProperty(window, r), n ? .(c)),
writable: !1,
configurable: !0
}), t
}
var i, o = class {
constructor() {
this.__TAURI_CHANNEL_MARKER__ = !0;
i$1(this, i, () => {});
this.id = s(e => {
h$1(this, i).call(this, e);
});
}
set onmessage(e) {
j(this, i, e);
}
get onmessage() {
return h$1(this, i)
}
toJSON() {
return `__CHANNEL__:${this.id}`
}
};
i = new WeakMap;
var a = class {
constructor(e, t, r) {
this.plugin = e, this.event = t, this.channelId = r;
}
async unregister() {
return u(`plugin:${this.plugin}|remove_listener`, {
event: this.event,
channelId: this.channelId
})
}
};
async function m(n, e, t) {
let r = new o;
return r.onmessage = t, u(`plugin:${n}|register_listener`, {
event: e,
handler: r
}).then(() => new a(n, e, r.id))
}
async function u(n, e = {}, t) {
return new Promise((r, c) => {
let g = s(d => {
r(d), Reflect.deleteProperty(window, `_${_}`);
}, !0),
_ = s(d => {
c(d), Reflect.deleteProperty(window, `_${g}`);
}, !0);
window.__TAURI_IPC__({
cmd: n,
callback: g,
error: _,
payload: e,
options: t
});
})
}
function y(n, e = "asset") {
return window.__TAURI__.convertFileSrc(n, e)
}
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
var Source;
@ -23,8 +118,15 @@ var CameraDirection;
CameraDirection["Front"] = "FRONT";
})(CameraDirection || (CameraDirection = {}));
async function getPhoto(options) {
return await u("plugin:camera|getPhoto", { ...options });
return await u("plugin:camera|getPhoto", {
...options
});
}
export { CameraDirection, ResultType, Source, getPhoto };
//# sourceMappingURL=index.min.js.map
export {
CameraDirection,
ResultType,
Source,
getPhoto
};
//# sourceMappingURL=index.min.js.map

@ -1,6 +1,8 @@
import { invoke } from '@tauri-apps/api/tauri';
import {
invoke
} from '@tauri-apps/api/tauri';
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
var Source;
@ -21,8 +23,15 @@ var CameraDirection;
CameraDirection["Front"] = "FRONT";
})(CameraDirection || (CameraDirection = {}));
async function getPhoto(options) {
return await invoke("plugin:camera|getPhoto", { ...options });
return await invoke("plugin:camera|getPhoto", {
...options
});
}
export { CameraDirection, ResultType, Source, getPhoto };
//# sourceMappingURL=index.mjs.map
export {
CameraDirection,
ResultType,
Source,
getPhoto
};
//# sourceMappingURL=index.mjs.map

@ -1,4 +1,4 @@
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
import { invoke } from "@tauri-apps/api/tauri";

@ -1,4 +1,4 @@
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
@ -8,17 +8,17 @@ pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
}
impl Serialize for Error {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(self.to_string().as_ref())
}
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(self.to_string().as_ref())
}
}

@ -1,12 +1,12 @@
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
#![cfg(mobile)]
use tauri::{
plugin::{Builder, PluginHandle, TauriPlugin},
Manager, Runtime,
plugin::{Builder, PluginHandle, TauriPlugin},
Manager, Runtime,
};
pub use models::*;
@ -24,35 +24,34 @@ tauri::ios_plugin_binding!(init_plugin_camera);
pub struct Camera<R: Runtime>(PluginHandle<R>);
impl<R: Runtime> Camera<R> {
pub fn get_photo(&self, options: ImageOptions) -> Result<Image> {
self
.0
.run_mobile_plugin("getPhoto", options)
.map_err(Into::into)
}
pub fn get_photo(&self, options: ImageOptions) -> Result<Image> {
self.0
.run_mobile_plugin("getPhoto", options)
.map_err(Into::into)
}
}
/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the camera APIs.
pub trait CameraExt<R: Runtime> {
fn camera(&self) -> &Camera<R>;
fn camera(&self) -> &Camera<R>;
}
impl<R: Runtime, T: Manager<R>> CameraExt<R> for T {
fn camera(&self) -> &Camera<R> {
self.state::<Camera<R>>().inner()
}
fn camera(&self) -> &Camera<R> {
self.state::<Camera<R>>().inner()
}
}
/// Initializes the plugin.
pub fn init<R: Runtime>() -> TauriPlugin<R> {
Builder::new("camera")
.setup(|app, api| {
#[cfg(target_os = "android")]
let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "CameraPlugin")?;
#[cfg(target_os = "ios")]
let handle = api.register_ios_plugin(init_plugin_camera)?;
app.manage(Camera(handle));
Ok(())
})
.build()
Builder::new("camera")
.setup(|app, api| {
#[cfg(target_os = "android")]
let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "CameraPlugin")?;
#[cfg(target_os = "ios")]
let handle = api.register_ios_plugin(init_plugin_camera)?;
app.manage(Camera(handle));
Ok(())
})
.build()
}

@ -1,4 +1,4 @@
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

Loading…
Cancel
Save