@tauri-apps/plugin-clipboard-manager 2.0.0-beta.2 → 2.0.0-rc.1

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.
package/README.md CHANGED
@@ -18,7 +18,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file:
18
18
 
19
19
  ```toml
20
20
  [dependencies]
21
- tauri-plugin-clipboard-manager = "2.0.0-beta"
21
+ tauri-plugin-clipboard-manager = "2.0.0-rc"
22
22
  # alternatively with Git:
23
23
  tauri-plugin-clipboard-manager = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
24
24
  ```
package/dist-js/index.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var core = require('@tauri-apps/api/core');
4
+ var image = require('@tauri-apps/api/image');
4
5
 
5
6
  // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
6
7
  // SPDX-License-Identifier: Apache-2.0
@@ -24,13 +25,9 @@ var core = require('@tauri-apps/api/core');
24
25
  * @since 2.0.0
25
26
  */
26
27
  async function writeText(text, opts) {
27
- return core.invoke("plugin:clipboard-manager|write", {
28
- data: {
29
- plainText: {
30
- label: opts?.label,
31
- text,
32
- },
33
- },
28
+ await core.invoke("plugin:clipboard-manager|write_text", {
29
+ label: opts?.label,
30
+ text,
34
31
  });
35
32
  }
36
33
  /**
@@ -43,11 +40,48 @@ async function writeText(text, opts) {
43
40
  * @since 2.0.0
44
41
  */
45
42
  async function readText() {
46
- const kind = await core.invoke("plugin:clipboard-manager|read");
47
- return kind.plainText.text;
43
+ return await core.invoke("plugin:clipboard-manager|read_text");
48
44
  }
49
45
  /**
50
- * Writes HTML or fallbacks to write provided plain text to the clipboard.
46
+ * Writes image buffer to the clipboard.
47
+ * @example
48
+ * ```typescript
49
+ * import { writeImage } from '@tauri-apps/plugin-clipboard-manager';
50
+ * const buffer = [
51
+ * // A red pixel
52
+ * 255, 0, 0, 255,
53
+ *
54
+ * // A green pixel
55
+ * 0, 255, 0, 255,
56
+ * ];
57
+ * await writeImage(buffer);
58
+ *
59
+ * @returns A promise indicating the success or failure of the operation.
60
+ *
61
+ * @since 2.0.0
62
+ */
63
+ async function writeImage(image$1) {
64
+ await core.invoke("plugin:clipboard-manager|write_image", {
65
+ image: image.transformImage(image$1),
66
+ });
67
+ }
68
+ /**
69
+ * Gets the clipboard content as Uint8Array image.
70
+ * @example
71
+ * ```typescript
72
+ * import { readImage } from '@tauri-apps/plugin-clipboard-manager';
73
+ *
74
+ * const clipboardImage = await readImage();
75
+ * const blob = new Blob([clipboardImage.bytes], { type: 'image' })
76
+ * const url = URL.createObjectURL(blob)
77
+ * ```
78
+ * @since 2.0.0
79
+ */
80
+ async function readImage() {
81
+ return await core.invoke("plugin:clipboard-manager|read_image").then((rid) => new image.Image(rid));
82
+ }
83
+ /**
84
+ * * Writes HTML or fallbacks to write provided plain text to the clipboard.
51
85
  * @example
52
86
  * ```typescript
53
87
  * import { writeHtml, readHtml } from '@tauri-apps/plugin-clipboard-manager';
@@ -61,13 +95,9 @@ async function readText() {
61
95
  * @since 2.0.0
62
96
  */
63
97
  async function writeHtml(html, altHtml) {
64
- return core.invoke("plugin:clipboard-manager|write_html", {
65
- data: {
66
- html: {
67
- html,
68
- altHtml,
69
- },
70
- },
98
+ await core.invoke("plugin:clipboard-manager|write_html", {
99
+ html,
100
+ altHtml,
71
101
  });
72
102
  }
73
103
  /**
@@ -81,10 +111,11 @@ async function writeHtml(html, altHtml) {
81
111
  */
82
112
  async function clear() {
83
113
  await core.invoke("plugin:clipboard-manager|clear");
84
- return;
85
114
  }
86
115
 
87
116
  exports.clear = clear;
117
+ exports.readImage = readImage;
88
118
  exports.readText = readText;
89
119
  exports.writeHtml = writeHtml;
120
+ exports.writeImage = writeImage;
90
121
  exports.writeText = writeText;
@@ -1,3 +1,4 @@
1
+ import { Image } from "@tauri-apps/api/image";
1
2
  /**
2
3
  * Writes plain text to the clipboard.
3
4
  * @example
@@ -25,7 +26,39 @@ declare function writeText(text: string, opts?: {
25
26
  */
26
27
  declare function readText(): Promise<string>;
27
28
  /**
28
- * Writes HTML or fallbacks to write provided plain text to the clipboard.
29
+ * Writes image buffer to the clipboard.
30
+ * @example
31
+ * ```typescript
32
+ * import { writeImage } from '@tauri-apps/plugin-clipboard-manager';
33
+ * const buffer = [
34
+ * // A red pixel
35
+ * 255, 0, 0, 255,
36
+ *
37
+ * // A green pixel
38
+ * 0, 255, 0, 255,
39
+ * ];
40
+ * await writeImage(buffer);
41
+ *
42
+ * @returns A promise indicating the success or failure of the operation.
43
+ *
44
+ * @since 2.0.0
45
+ */
46
+ declare function writeImage(image: string | Image | Uint8Array | ArrayBuffer | number[]): Promise<void>;
47
+ /**
48
+ * Gets the clipboard content as Uint8Array image.
49
+ * @example
50
+ * ```typescript
51
+ * import { readImage } from '@tauri-apps/plugin-clipboard-manager';
52
+ *
53
+ * const clipboardImage = await readImage();
54
+ * const blob = new Blob([clipboardImage.bytes], { type: 'image' })
55
+ * const url = URL.createObjectURL(blob)
56
+ * ```
57
+ * @since 2.0.0
58
+ */
59
+ declare function readImage(): Promise<Image>;
60
+ /**
61
+ * * Writes HTML or fallbacks to write provided plain text to the clipboard.
29
62
  * @example
30
63
  * ```typescript
31
64
  * import { writeHtml, readHtml } from '@tauri-apps/plugin-clipboard-manager';
@@ -49,4 +82,4 @@ declare function writeHtml(html: string, altHtml?: string): Promise<void>;
49
82
  * @since 2.0.0
50
83
  */
51
84
  declare function clear(): Promise<void>;
52
- export { writeText, readText, writeHtml, clear };
85
+ export { writeText, readText, writeHtml, clear, readImage, writeImage };
package/dist-js/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { invoke } from '@tauri-apps/api/core';
2
+ import { transformImage, Image } from '@tauri-apps/api/image';
2
3
 
3
4
  // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
4
5
  // SPDX-License-Identifier: Apache-2.0
@@ -22,13 +23,9 @@ import { invoke } from '@tauri-apps/api/core';
22
23
  * @since 2.0.0
23
24
  */
24
25
  async function writeText(text, opts) {
25
- return invoke("plugin:clipboard-manager|write", {
26
- data: {
27
- plainText: {
28
- label: opts?.label,
29
- text,
30
- },
31
- },
26
+ await invoke("plugin:clipboard-manager|write_text", {
27
+ label: opts?.label,
28
+ text,
32
29
  });
33
30
  }
34
31
  /**
@@ -41,11 +38,48 @@ async function writeText(text, opts) {
41
38
  * @since 2.0.0
42
39
  */
43
40
  async function readText() {
44
- const kind = await invoke("plugin:clipboard-manager|read");
45
- return kind.plainText.text;
41
+ return await invoke("plugin:clipboard-manager|read_text");
46
42
  }
47
43
  /**
48
- * Writes HTML or fallbacks to write provided plain text to the clipboard.
44
+ * Writes image buffer to the clipboard.
45
+ * @example
46
+ * ```typescript
47
+ * import { writeImage } from '@tauri-apps/plugin-clipboard-manager';
48
+ * const buffer = [
49
+ * // A red pixel
50
+ * 255, 0, 0, 255,
51
+ *
52
+ * // A green pixel
53
+ * 0, 255, 0, 255,
54
+ * ];
55
+ * await writeImage(buffer);
56
+ *
57
+ * @returns A promise indicating the success or failure of the operation.
58
+ *
59
+ * @since 2.0.0
60
+ */
61
+ async function writeImage(image) {
62
+ await invoke("plugin:clipboard-manager|write_image", {
63
+ image: transformImage(image),
64
+ });
65
+ }
66
+ /**
67
+ * Gets the clipboard content as Uint8Array image.
68
+ * @example
69
+ * ```typescript
70
+ * import { readImage } from '@tauri-apps/plugin-clipboard-manager';
71
+ *
72
+ * const clipboardImage = await readImage();
73
+ * const blob = new Blob([clipboardImage.bytes], { type: 'image' })
74
+ * const url = URL.createObjectURL(blob)
75
+ * ```
76
+ * @since 2.0.0
77
+ */
78
+ async function readImage() {
79
+ return await invoke("plugin:clipboard-manager|read_image").then((rid) => new Image(rid));
80
+ }
81
+ /**
82
+ * * Writes HTML or fallbacks to write provided plain text to the clipboard.
49
83
  * @example
50
84
  * ```typescript
51
85
  * import { writeHtml, readHtml } from '@tauri-apps/plugin-clipboard-manager';
@@ -59,13 +93,9 @@ async function readText() {
59
93
  * @since 2.0.0
60
94
  */
61
95
  async function writeHtml(html, altHtml) {
62
- return invoke("plugin:clipboard-manager|write_html", {
63
- data: {
64
- html: {
65
- html,
66
- altHtml,
67
- },
68
- },
96
+ await invoke("plugin:clipboard-manager|write_html", {
97
+ html,
98
+ altHtml,
69
99
  });
70
100
  }
71
101
  /**
@@ -79,7 +109,6 @@ async function writeHtml(html, altHtml) {
79
109
  */
80
110
  async function clear() {
81
111
  await invoke("plugin:clipboard-manager|clear");
82
- return;
83
112
  }
84
113
 
85
- export { clear, readText, writeHtml, writeText };
114
+ export { clear, readImage, readText, writeHtml, writeImage, writeText };
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-clipboard-manager",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-rc.1",
4
4
  "license": "MIT or APACHE-2.0",
5
5
  "authors": [
6
6
  "Tauri Programme within The Commons Conservancy"
7
7
  ],
8
+ "repository": "https://github.com/tauri-apps/plugins-workspace",
8
9
  "type": "module",
9
10
  "types": "./dist-js/index.d.ts",
10
11
  "main": "./dist-js/index.cjs",
@@ -14,15 +15,15 @@
14
15
  "import": "./dist-js/index.js",
15
16
  "require": "./dist-js/index.cjs"
16
17
  },
18
+ "scripts": {
19
+ "build": "rollup -c"
20
+ },
17
21
  "files": [
18
22
  "dist-js",
19
23
  "README.md",
20
24
  "LICENSE"
21
25
  ],
22
26
  "dependencies": {
23
- "@tauri-apps/api": "2.0.0-beta.4"
24
- },
25
- "scripts": {
26
- "build": "rollup -c"
27
+ "@tauri-apps/api": "^2.0.0-rc.4"
27
28
  }
28
- }
29
+ }