@tauri-apps/plugin-dialog 2.0.0-alpha.0 → 2.0.0-alpha.2

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
@@ -1,10 +1,10 @@
1
- # Dialog
1
+ ![plugin-dialog](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/dialog/banner.png)
2
2
 
3
3
  Native system dialogs for opening and saving files along with message dialogs.
4
4
 
5
5
  ## Install
6
6
 
7
- _This plugin requires a Rust version of at least **1.65**_
7
+ _This plugin requires a Rust version of at least **1.70**_
8
8
 
9
9
  There are three general methods of installation that we can recommend.
10
10
 
@@ -1,8 +1,3 @@
1
- declare global {
2
- interface Window {
3
- __TAURI_INVOKE__: <T>(cmd: string, args?: unknown) => Promise<T>;
4
- }
5
- }
6
1
  interface FileResponse {
7
2
  base64Data?: string;
8
3
  duration?: number;
@@ -118,7 +113,7 @@ declare function open(options?: OpenDialogOptions & {
118
113
  * You can save it to the filesystem using [tauri-plugin-persisted-scope](https://github.com/tauri-apps/tauri-plugin-persisted-scope).
119
114
  * @example
120
115
  * ```typescript
121
- * import { save } from '@tauri-apps/api/dialog';
116
+ * import { save } from '@tauri-apps/plugin-dialog';
122
117
  * const filePath = await save({
123
118
  * filters: [{
124
119
  * name: 'Image',
@@ -136,7 +131,7 @@ declare function save(options?: SaveDialogOptions): Promise<string | null>;
136
131
  * Shows a message dialog with an `Ok` button.
137
132
  * @example
138
133
  * ```typescript
139
- * import { message } from '@tauri-apps/api/dialog';
134
+ * import { message } from '@tauri-apps/plugin-dialog';
140
135
  * await message('Tauri is awesome', 'Tauri');
141
136
  * await message('File not found', { title: 'Tauri', type: 'error' });
142
137
  * ```
@@ -154,7 +149,7 @@ declare function message(message: string, options?: string | MessageDialogOption
154
149
  * Shows a question dialog with `Yes` and `No` buttons.
155
150
  * @example
156
151
  * ```typescript
157
- * import { ask } from '@tauri-apps/api/dialog';
152
+ * import { ask } from '@tauri-apps/plugin-dialog';
158
153
  * const yes = await ask('Are you sure?', 'Tauri');
159
154
  * const yes2 = await ask('This action cannot be reverted. Are you sure?', { title: 'Tauri', type: 'warning' });
160
155
  * ```
@@ -171,7 +166,7 @@ declare function ask(message: string, options?: string | ConfirmDialogOptions):
171
166
  * Shows a question dialog with `Ok` and `Cancel` buttons.
172
167
  * @example
173
168
  * ```typescript
174
- * import { confirm } from '@tauri-apps/api/dialog';
169
+ * import { confirm } from '@tauri-apps/plugin-dialog';
175
170
  * const confirmed = await confirm('Are you sure?', 'Tauri');
176
171
  * const confirmed2 = await confirm('This action cannot be reverted. Are you sure?', { title: 'Tauri', type: 'warning' });
177
172
  * ```
@@ -1,3 +1,7 @@
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);
2
+
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)}
4
+
1
5
  // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
2
6
  // SPDX-License-Identifier: Apache-2.0
3
7
  // SPDX-License-Identifier: MIT
@@ -12,7 +16,7 @@
12
16
  * You can save it to the filesystem using [tauri-plugin-persisted-scope](https://github.com/tauri-apps/tauri-plugin-persisted-scope).
13
17
  * @example
14
18
  * ```typescript
15
- * import { open } from '@tauri-apps/api/dialog';
19
+ * import { open } from '@tauri-apps/plugin-dialog';
16
20
  * // Open a selection dialog for image files
17
21
  * const selected = await open({
18
22
  * multiple: true,
@@ -32,7 +36,7 @@
32
36
  *
33
37
  * @example
34
38
  * ```typescript
35
- * import { open } from '@tauri-apps/api/dialog';
39
+ * import { open } from '@tauri-apps/plugin-dialog';
36
40
  * import { appDir } from '@tauri-apps/api/path';
37
41
  * // Open a selection dialog for directories
38
42
  * const selected = await open({
@@ -57,7 +61,7 @@ async function open(options = {}) {
57
61
  if (typeof options === "object") {
58
62
  Object.freeze(options);
59
63
  }
60
- return window.__TAURI_INVOKE__("plugin:dialog|open", { options });
64
+ return u("plugin:dialog|open", { options });
61
65
  }
62
66
  /**
63
67
  * Open a file/directory save dialog.
@@ -70,7 +74,7 @@ async function open(options = {}) {
70
74
  * You can save it to the filesystem using [tauri-plugin-persisted-scope](https://github.com/tauri-apps/tauri-plugin-persisted-scope).
71
75
  * @example
72
76
  * ```typescript
73
- * import { save } from '@tauri-apps/api/dialog';
77
+ * import { save } from '@tauri-apps/plugin-dialog';
74
78
  * const filePath = await save({
75
79
  * filters: [{
76
80
  * name: 'Image',
@@ -87,13 +91,13 @@ async function save(options = {}) {
87
91
  if (typeof options === "object") {
88
92
  Object.freeze(options);
89
93
  }
90
- return window.__TAURI_INVOKE__("plugin:dialog|save", { options });
94
+ return u("plugin:dialog|save", { options });
91
95
  }
92
96
  /**
93
97
  * Shows a message dialog with an `Ok` button.
94
98
  * @example
95
99
  * ```typescript
96
- * import { message } from '@tauri-apps/api/dialog';
100
+ * import { message } from '@tauri-apps/plugin-dialog';
97
101
  * await message('Tauri is awesome', 'Tauri');
98
102
  * await message('File not found', { title: 'Tauri', type: 'error' });
99
103
  * ```
@@ -109,7 +113,7 @@ async function save(options = {}) {
109
113
  async function message(message, options) {
110
114
  var _a, _b;
111
115
  const opts = typeof options === "string" ? { title: options } : options;
112
- return window.__TAURI_INVOKE__("plugin:dialog|message", {
116
+ return u("plugin:dialog|message", {
113
117
  message: message.toString(),
114
118
  title: (_a = opts === null || opts === void 0 ? void 0 : opts.title) === null || _a === void 0 ? void 0 : _a.toString(),
115
119
  type_: opts === null || opts === void 0 ? void 0 : opts.type,
@@ -120,7 +124,7 @@ async function message(message, options) {
120
124
  * Shows a question dialog with `Yes` and `No` buttons.
121
125
  * @example
122
126
  * ```typescript
123
- * import { ask } from '@tauri-apps/api/dialog';
127
+ * import { ask } from '@tauri-apps/plugin-dialog';
124
128
  * const yes = await ask('Are you sure?', 'Tauri');
125
129
  * const yes2 = await ask('This action cannot be reverted. Are you sure?', { title: 'Tauri', type: 'warning' });
126
130
  * ```
@@ -135,7 +139,7 @@ async function message(message, options) {
135
139
  async function ask(message, options) {
136
140
  var _a, _b, _c, _d, _e;
137
141
  const opts = typeof options === "string" ? { title: options } : options;
138
- return window.__TAURI_INVOKE__("plugin:dialog|ask", {
142
+ return u("plugin:dialog|ask", {
139
143
  message: message.toString(),
140
144
  title: (_a = opts === null || opts === void 0 ? void 0 : opts.title) === null || _a === void 0 ? void 0 : _a.toString(),
141
145
  type_: opts === null || opts === void 0 ? void 0 : opts.type,
@@ -147,7 +151,7 @@ async function ask(message, options) {
147
151
  * Shows a question dialog with `Ok` and `Cancel` buttons.
148
152
  * @example
149
153
  * ```typescript
150
- * import { confirm } from '@tauri-apps/api/dialog';
154
+ * import { confirm } from '@tauri-apps/plugin-dialog';
151
155
  * const confirmed = await confirm('Are you sure?', 'Tauri');
152
156
  * const confirmed2 = await confirm('This action cannot be reverted. Are you sure?', { title: 'Tauri', type: 'warning' });
153
157
  * ```
@@ -162,7 +166,7 @@ async function ask(message, options) {
162
166
  async function confirm(message, options) {
163
167
  var _a, _b, _c, _d, _e;
164
168
  const opts = typeof options === "string" ? { title: options } : options;
165
- return window.__TAURI_INVOKE__("plugin:dialog|confirm", {
169
+ return u("plugin:dialog|confirm", {
166
170
  message: message.toString(),
167
171
  title: (_a = opts === null || opts === void 0 ? void 0 : opts.title) === null || _a === void 0 ? void 0 : _a.toString(),
168
172
  type_: opts === null || opts === void 0 ? void 0 : opts.type,
package/dist-js/index.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import { invoke } from '@tauri-apps/api/primitives';
2
+
1
3
  // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
2
4
  // SPDX-License-Identifier: Apache-2.0
3
5
  // SPDX-License-Identifier: MIT
@@ -12,7 +14,7 @@
12
14
  * You can save it to the filesystem using [tauri-plugin-persisted-scope](https://github.com/tauri-apps/tauri-plugin-persisted-scope).
13
15
  * @example
14
16
  * ```typescript
15
- * import { open } from '@tauri-apps/api/dialog';
17
+ * import { open } from '@tauri-apps/plugin-dialog';
16
18
  * // Open a selection dialog for image files
17
19
  * const selected = await open({
18
20
  * multiple: true,
@@ -32,7 +34,7 @@
32
34
  *
33
35
  * @example
34
36
  * ```typescript
35
- * import { open } from '@tauri-apps/api/dialog';
37
+ * import { open } from '@tauri-apps/plugin-dialog';
36
38
  * import { appDir } from '@tauri-apps/api/path';
37
39
  * // Open a selection dialog for directories
38
40
  * const selected = await open({
@@ -57,7 +59,7 @@ async function open(options = {}) {
57
59
  if (typeof options === "object") {
58
60
  Object.freeze(options);
59
61
  }
60
- return window.__TAURI_INVOKE__("plugin:dialog|open", { options });
62
+ return invoke("plugin:dialog|open", { options });
61
63
  }
62
64
  /**
63
65
  * Open a file/directory save dialog.
@@ -70,7 +72,7 @@ async function open(options = {}) {
70
72
  * You can save it to the filesystem using [tauri-plugin-persisted-scope](https://github.com/tauri-apps/tauri-plugin-persisted-scope).
71
73
  * @example
72
74
  * ```typescript
73
- * import { save } from '@tauri-apps/api/dialog';
75
+ * import { save } from '@tauri-apps/plugin-dialog';
74
76
  * const filePath = await save({
75
77
  * filters: [{
76
78
  * name: 'Image',
@@ -87,13 +89,13 @@ async function save(options = {}) {
87
89
  if (typeof options === "object") {
88
90
  Object.freeze(options);
89
91
  }
90
- return window.__TAURI_INVOKE__("plugin:dialog|save", { options });
92
+ return invoke("plugin:dialog|save", { options });
91
93
  }
92
94
  /**
93
95
  * Shows a message dialog with an `Ok` button.
94
96
  * @example
95
97
  * ```typescript
96
- * import { message } from '@tauri-apps/api/dialog';
98
+ * import { message } from '@tauri-apps/plugin-dialog';
97
99
  * await message('Tauri is awesome', 'Tauri');
98
100
  * await message('File not found', { title: 'Tauri', type: 'error' });
99
101
  * ```
@@ -109,7 +111,7 @@ async function save(options = {}) {
109
111
  async function message(message, options) {
110
112
  var _a, _b;
111
113
  const opts = typeof options === "string" ? { title: options } : options;
112
- return window.__TAURI_INVOKE__("plugin:dialog|message", {
114
+ return invoke("plugin:dialog|message", {
113
115
  message: message.toString(),
114
116
  title: (_a = opts === null || opts === void 0 ? void 0 : opts.title) === null || _a === void 0 ? void 0 : _a.toString(),
115
117
  type_: opts === null || opts === void 0 ? void 0 : opts.type,
@@ -120,7 +122,7 @@ async function message(message, options) {
120
122
  * Shows a question dialog with `Yes` and `No` buttons.
121
123
  * @example
122
124
  * ```typescript
123
- * import { ask } from '@tauri-apps/api/dialog';
125
+ * import { ask } from '@tauri-apps/plugin-dialog';
124
126
  * const yes = await ask('Are you sure?', 'Tauri');
125
127
  * const yes2 = await ask('This action cannot be reverted. Are you sure?', { title: 'Tauri', type: 'warning' });
126
128
  * ```
@@ -135,7 +137,7 @@ async function message(message, options) {
135
137
  async function ask(message, options) {
136
138
  var _a, _b, _c, _d, _e;
137
139
  const opts = typeof options === "string" ? { title: options } : options;
138
- return window.__TAURI_INVOKE__("plugin:dialog|ask", {
140
+ return invoke("plugin:dialog|ask", {
139
141
  message: message.toString(),
140
142
  title: (_a = opts === null || opts === void 0 ? void 0 : opts.title) === null || _a === void 0 ? void 0 : _a.toString(),
141
143
  type_: opts === null || opts === void 0 ? void 0 : opts.type,
@@ -147,7 +149,7 @@ async function ask(message, options) {
147
149
  * Shows a question dialog with `Ok` and `Cancel` buttons.
148
150
  * @example
149
151
  * ```typescript
150
- * import { confirm } from '@tauri-apps/api/dialog';
152
+ * import { confirm } from '@tauri-apps/plugin-dialog';
151
153
  * const confirmed = await confirm('Are you sure?', 'Tauri');
152
154
  * const confirmed2 = await confirm('This action cannot be reverted. Are you sure?', { title: 'Tauri', type: 'warning' });
153
155
  * ```
@@ -162,7 +164,7 @@ async function ask(message, options) {
162
164
  async function confirm(message, options) {
163
165
  var _a, _b, _c, _d, _e;
164
166
  const opts = typeof options === "string" ? { title: options } : options;
165
- return window.__TAURI_INVOKE__("plugin:dialog|confirm", {
167
+ return invoke("plugin:dialog|confirm", {
166
168
  message: message.toString(),
167
169
  title: (_a = opts === null || opts === void 0 ? void 0 : opts.title) === null || _a === void 0 ? void 0 : _a.toString(),
168
170
  type_: opts === null || opts === void 0 ? void 0 : opts.type,
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-dialog",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.2",
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.4"
27
+ "@tauri-apps/api": "2.0.0-alpha.9"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "rollup -c"