mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-05-07 12:26:41 +02:00
Merge remote-tracking branch 'origin/v2' into feat/camera
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
[package]
|
||||
name = "tauri-plugin-camera"
|
||||
version = "0.0.0"
|
||||
version = "1.0.0"
|
||||
description = "Ask the user take a photo with the camera or select an image from the gallery."
|
||||
authors.workspace = true
|
||||
license.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
exclude.workspace = true
|
||||
|
||||
[dependencies]
|
||||
serde.workspace = true
|
||||
|
||||
Vendored
+27
-27
@@ -1,38 +1,38 @@
|
||||
export declare enum Source {
|
||||
Prompt = "PROMPT",
|
||||
Camera = "CAMERA",
|
||||
Photos = "PHOTOS",
|
||||
Prompt = "PROMPT",
|
||||
Camera = "CAMERA",
|
||||
Photos = "PHOTOS"
|
||||
}
|
||||
export declare enum ResultType {
|
||||
Uri = "uri",
|
||||
Base64 = "base64",
|
||||
DataUrl = "dataUrl",
|
||||
Uri = "uri",
|
||||
Base64 = "base64",
|
||||
DataUrl = "dataUrl"
|
||||
}
|
||||
export declare enum CameraDirection {
|
||||
Rear = "REAR",
|
||||
Front = "FRONT",
|
||||
Rear = "REAR",
|
||||
Front = "FRONT"
|
||||
}
|
||||
export interface ImageOptions {
|
||||
quality?: number;
|
||||
allowEditing?: boolean;
|
||||
resultType?: ResultType;
|
||||
saveToGallery?: boolean;
|
||||
width?: number;
|
||||
height?: number;
|
||||
correctOrientation?: boolean;
|
||||
source?: Source;
|
||||
direction?: CameraDirection;
|
||||
presentationStyle?: "fullscreen" | "popover";
|
||||
promptLabelHeader?: string;
|
||||
promptLabelCancel?: string;
|
||||
promptLabelPhoto?: string;
|
||||
promptLabelPicture?: string;
|
||||
quality?: number;
|
||||
allowEditing?: boolean;
|
||||
resultType?: ResultType;
|
||||
saveToGallery?: boolean;
|
||||
width?: number;
|
||||
height?: number;
|
||||
correctOrientation?: boolean;
|
||||
source?: Source;
|
||||
direction?: CameraDirection;
|
||||
presentationStyle?: "fullscreen" | "popover";
|
||||
promptLabelHeader?: string;
|
||||
promptLabelCancel?: string;
|
||||
promptLabelPhoto?: string;
|
||||
promptLabelPicture?: string;
|
||||
}
|
||||
export interface Image {
|
||||
data: string;
|
||||
assetUrl?: string;
|
||||
format: string;
|
||||
saved: boolean;
|
||||
exif: unknown;
|
||||
data: string;
|
||||
assetUrl?: string;
|
||||
format: string;
|
||||
saved: boolean;
|
||||
exif: unknown;
|
||||
}
|
||||
export declare function getPhoto(options?: ImageOptions): Promise<Image>;
|
||||
|
||||
Vendored
+13
-47
@@ -1,63 +1,29 @@
|
||||
var d$1 = Object.defineProperty;
|
||||
var e = (c, a) => {
|
||||
for (var b in a) d$1(c, b, { get: a[b], enumerable: !0 });
|
||||
};
|
||||
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 w = {};
|
||||
e(w, { convertFileSrc: () => u, invoke: () => d, transformCallback: () => s });
|
||||
function l() {
|
||||
return window.crypto.getRandomValues(new Uint32Array(1))[0];
|
||||
}
|
||||
function s(r, n = !1) {
|
||||
let e = l(),
|
||||
t = `_${e}`;
|
||||
return (
|
||||
Object.defineProperty(window, t, {
|
||||
value: (o) => (n && Reflect.deleteProperty(window, t), r?.(o)),
|
||||
writable: !1,
|
||||
configurable: !0,
|
||||
}),
|
||||
e
|
||||
);
|
||||
}
|
||||
async function d(r, n = {}) {
|
||||
return new Promise((e, t) => {
|
||||
let o = s((i) => {
|
||||
e(i), Reflect.deleteProperty(window, `_${a}`);
|
||||
}, !0),
|
||||
a = s((i) => {
|
||||
t(i), Reflect.deleteProperty(window, `_${o}`);
|
||||
}, !0);
|
||||
window.__TAURI_IPC__({ cmd: r, callback: o, error: a, ...n });
|
||||
});
|
||||
}
|
||||
function u(r, n = "asset") {
|
||||
let e = encodeURIComponent(r);
|
||||
return navigator.userAgent.includes("Windows")
|
||||
? `https://${n}.localhost/${e}`
|
||||
: `${n}://localhost/${e}`;
|
||||
}
|
||||
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)}
|
||||
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
var Source;
|
||||
(function (Source) {
|
||||
Source["Prompt"] = "PROMPT";
|
||||
Source["Camera"] = "CAMERA";
|
||||
Source["Photos"] = "PHOTOS";
|
||||
Source["Prompt"] = "PROMPT";
|
||||
Source["Camera"] = "CAMERA";
|
||||
Source["Photos"] = "PHOTOS";
|
||||
})(Source || (Source = {}));
|
||||
var ResultType;
|
||||
(function (ResultType) {
|
||||
ResultType["Uri"] = "uri";
|
||||
ResultType["Base64"] = "base64";
|
||||
ResultType["DataUrl"] = "dataUrl";
|
||||
ResultType["Uri"] = "uri";
|
||||
ResultType["Base64"] = "base64";
|
||||
ResultType["DataUrl"] = "dataUrl";
|
||||
})(ResultType || (ResultType = {}));
|
||||
var CameraDirection;
|
||||
(function (CameraDirection) {
|
||||
CameraDirection["Rear"] = "REAR";
|
||||
CameraDirection["Front"] = "FRONT";
|
||||
CameraDirection["Rear"] = "REAR";
|
||||
CameraDirection["Front"] = "FRONT";
|
||||
})(CameraDirection || (CameraDirection = {}));
|
||||
async function getPhoto(options) {
|
||||
return await d("plugin:camera|getPhoto", { ...options });
|
||||
return await u("plugin:camera|getPhoto", { ...options });
|
||||
}
|
||||
|
||||
export { CameraDirection, ResultType, Source, getPhoto };
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,25 +1,27 @@
|
||||
import { invoke } from "@tauri-apps/api/tauri";
|
||||
import { invoke } from '@tauri-apps/api/tauri';
|
||||
|
||||
// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
var Source;
|
||||
(function (Source) {
|
||||
Source["Prompt"] = "PROMPT";
|
||||
Source["Camera"] = "CAMERA";
|
||||
Source["Photos"] = "PHOTOS";
|
||||
Source["Prompt"] = "PROMPT";
|
||||
Source["Camera"] = "CAMERA";
|
||||
Source["Photos"] = "PHOTOS";
|
||||
})(Source || (Source = {}));
|
||||
var ResultType;
|
||||
(function (ResultType) {
|
||||
ResultType["Uri"] = "uri";
|
||||
ResultType["Base64"] = "base64";
|
||||
ResultType["DataUrl"] = "dataUrl";
|
||||
ResultType["Uri"] = "uri";
|
||||
ResultType["Base64"] = "base64";
|
||||
ResultType["DataUrl"] = "dataUrl";
|
||||
})(ResultType || (ResultType = {}));
|
||||
var CameraDirection;
|
||||
(function (CameraDirection) {
|
||||
CameraDirection["Rear"] = "REAR";
|
||||
CameraDirection["Front"] = "FRONT";
|
||||
CameraDirection["Rear"] = "REAR";
|
||||
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 };
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.mjs","sources":["../guest-js/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;IAKY,OAIX;AAJD,CAAA,UAAY,MAAM,EAAA;AAChB,IAAA,MAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,MAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,MAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACnB,CAAC,EAJW,MAAM,KAAN,MAAM,GAIjB,EAAA,CAAA,CAAA,CAAA;IAEW,WAIX;AAJD,CAAA,UAAY,UAAU,EAAA;AACpB,IAAA,UAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,UAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,UAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACrB,CAAC,EAJW,UAAU,KAAV,UAAU,GAIrB,EAAA,CAAA,CAAA,CAAA;IAEW,gBAGX;AAHD,CAAA,UAAY,eAAe,EAAA;AACzB,IAAA,eAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,I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;"}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tauri-plugin-camera-api",
|
||||
"version": "0.0.0",
|
||||
"name": "@tauri-apps/plugin-camera",
|
||||
"version": "1.0.0",
|
||||
"description": "Ask the user take a photo with the camera or select an image from the gallery.",
|
||||
"license": "MIT or APACHE-2.0",
|
||||
"authors": [
|
||||
@@ -28,6 +28,6 @@
|
||||
"tslib": "^2.4.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.0.0-alpha.0"
|
||||
"@tauri-apps/api": "2.0.0-alpha.8"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
if("__TAURI__"in window){var __TAURI_CAMERA__=function(e){"use strict";var t=Object.defineProperty,r=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},n=(e,t,n)=>(r(e,t,"read from private field"),n?n.call(e):t.get(e)),i=(e,t,n,i)=>(r(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n);function a(e,t=!1){let r=window.crypto.getRandomValues(new Uint32Array(1))[0],n=`_${r}`;return Object.defineProperty(window,n,{value:r=>(t&&Reflect.deleteProperty(window,n),e?.(r)),writable:!1,configurable:!0}),r}((e,r)=>{for(var n in r)t(e,n,{get:r[n],enumerable:!0})})({},{Channel:()=>s,PluginListener:()=>d,addPluginListener:()=>u,convertFileSrc:()=>w,invoke:()=>h,transformCallback:()=>a});var o,s=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,((e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)})(this,o,(()=>{})),this.id=a((e=>{n(this,o).call(this,e)}))}set onmessage(e){i(this,o,e)}get onmessage(){return n(this,o)}toJSON(){return`__CHANNEL__:${this.id}`}};o=new WeakMap;var l,c,_,d=class{constructor(e,t,r){this.plugin=e,this.event=t,this.channelId=r}async unregister(){return h(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function u(e,t,r){let n=new s;return n.onmessage=r,h(`plugin:${e}|register_listener`,{event:t,handler:n}).then((()=>new d(e,t,n.id)))}async function h(e,t={},r){return new Promise(((n,i)=>{let o=a((e=>{n(e),Reflect.deleteProperty(window,`_${s}`)}),!0),s=a((e=>{i(e),Reflect.deleteProperty(window,`_${o}`)}),!0);window.__TAURI_IPC__({cmd:e,callback:o,error:s,payload:t,options:r})}))}function w(e,t="asset"){return window.__TAURI__.convertFileSrc(e,t)}return e.Source=void 0,(l=e.Source||(e.Source={})).Prompt="PROMPT",l.Camera="CAMERA",l.Photos="PHOTOS",e.ResultType=void 0,(c=e.ResultType||(e.ResultType={})).Uri="uri",c.Base64="base64",c.DataUrl="dataUrl",e.CameraDirection=void 0,(_=e.CameraDirection||(e.CameraDirection={})).Rear="REAR",_.Front="FRONT",e.getPhoto=async function(e){return await h("plugin:camera|getPhoto",{...e})},e}({});Object.defineProperty(window.__TAURI__,"camera",{value:__TAURI_CAMERA__})}
|
||||
Reference in New Issue
Block a user