@tauri-apps/plugin-clipboard-manager 2.0.0-alpha.2 → 2.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,43 @@
1
- var f=Object.defineProperty;var g=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0});};var e=(a,b,c)=>{if(!b.has(a))throw TypeError("Cannot "+c)};var h=(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);
1
+ /******************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */
15
+ /* global Reflect, Promise, SuppressedError, Symbol */
16
+
17
+
18
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
19
+ var e = new Error(message);
20
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
21
+ };
2
22
 
3
- var T={};g(T,{Channel:()=>i,PluginListener:()=>o,addPluginListener:()=>l,convertFileSrc:()=>v,invoke:()=>u,transformCallback:()=>_});function _(e,n=!1){return window.__TAURI_INTERNALS__.transformCallback(e,n)}var r,i=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0;i$1(this,r,()=>{});this.id=_(n=>{h(this,r).call(this,n);});}set onmessage(n){j(this,r,n);}get onmessage(){return h(this,r)}toJSON(){return `__CHANNEL__:${this.id}`}};r=new WeakMap;var o=class{constructor(n,s,t){this.plugin=n,this.event=s,this.channelId=t;}async unregister(){return u(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function l(e,n,s){let t=new i;return t.onmessage=s,u(`plugin:${e}|register_listener`,{event:n,handler:t}).then(()=>new o(e,n,t.id))}async function u(e,n={},s){return window.__TAURI_INTERNALS__.invoke(e,n,s)}function v(e,n="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,n)}
23
+ /**
24
+ * Sends a message to the backend.
25
+ * @example
26
+ * ```typescript
27
+ * import { invoke } from '@tauri-apps/api/primitives';
28
+ * await invoke('login', { user: 'tauri', password: 'poiwe3h4r5ip3yrhtew9ty' });
29
+ * ```
30
+ *
31
+ * @param cmd The command name.
32
+ * @param args The optional arguments to pass to the command.
33
+ * @param options The request options.
34
+ * @return A promise resolving or rejecting to the backend response.
35
+ *
36
+ * @since 1.0.0
37
+ */
38
+ async function invoke(cmd, args = {}, options) {
39
+ return window.__TAURI_INTERNALS__.invoke(cmd, args, options);
40
+ }
4
41
 
5
42
  // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
6
43
  // SPDX-License-Identifier: Apache-2.0
@@ -24,10 +61,9 @@ var T={};g(T,{Channel:()=>i,PluginListener:()=>o,addPluginListener:()=>l,convert
24
61
  * @since 2.0.0
25
62
  */
26
63
  async function writeText(text, opts) {
27
- return u("plugin:clipboard|write", {
64
+ return invoke("plugin:clipboard|write", {
28
65
  data: {
29
- kind: "PlainText",
30
- options: {
66
+ plainText: {
31
67
  label: opts === null || opts === void 0 ? void 0 : opts.label,
32
68
  text,
33
69
  },
@@ -44,8 +80,8 @@ async function writeText(text, opts) {
44
80
  * @since 2.0.0
45
81
  */
46
82
  async function readText() {
47
- const kind = await u("plugin:clipboard|read");
48
- return kind.options;
83
+ const kind = await invoke("plugin:clipboard|read");
84
+ return kind.plainText.text;
49
85
  }
50
86
 
51
87
  export { readText, writeText };
package/dist-js/index.mjs CHANGED
@@ -24,8 +24,7 @@ import { invoke } from '@tauri-apps/api/primitives';
24
24
  async function writeText(text, opts) {
25
25
  return invoke("plugin:clipboard|write", {
26
26
  data: {
27
- kind: "PlainText",
28
- options: {
27
+ plainText: {
29
28
  label: opts === null || opts === void 0 ? void 0 : opts.label,
30
29
  text,
31
30
  },
@@ -43,7 +42,7 @@ async function writeText(text, opts) {
43
42
  */
44
43
  async function readText() {
45
44
  const kind = await invoke("plugin:clipboard|read");
46
- return kind.options;
45
+ return kind.plainText.text;
47
46
  }
48
47
 
49
48
  export { readText, writeText };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-clipboard-manager",
3
- "version": "2.0.0-alpha.2",
3
+ "version": "2.0.0-alpha.3",
4
4
  "license": "MIT or APACHE-2.0",
5
5
  "authors": [
6
6
  "Tauri Programme within The Commons Conservancy"
@@ -24,7 +24,7 @@
24
24
  "tslib": "^2.4.1"
25
25
  },
26
26
  "dependencies": {
27
- "@tauri-apps/api": "2.0.0-alpha.9"
27
+ "@tauri-apps/api": "2.0.0-alpha.11"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "rollup -c"