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

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
@@ -67,6 +67,22 @@ Afterwards all the plugin's APIs are available through the JavaScript guest bind
67
67
 
68
68
  PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
69
69
 
70
+ ## Partners
71
+
72
+ <table>
73
+ <tbody>
74
+ <tr>
75
+ <td align="center" valign="middle">
76
+ <a href="https://crabnebula.dev" target="_blank">
77
+ <img src="https://github.com/tauri-apps/plugins-workspace/raw/v2/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
78
+ </a>
79
+ </td>
80
+ </tr>
81
+ </tbody>
82
+ </table>
83
+
84
+ For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
85
+
70
86
  ## License
71
87
 
72
88
  Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
@@ -1,6 +1,6 @@
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
+ 'use strict';
2
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)}
3
+ var primitives = require('@tauri-apps/api/primitives');
4
4
 
5
5
  // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
6
6
  // SPDX-License-Identifier: Apache-2.0
@@ -61,7 +61,7 @@ async function open(options = {}) {
61
61
  if (typeof options === "object") {
62
62
  Object.freeze(options);
63
63
  }
64
- return u("plugin:dialog|open", { options });
64
+ return primitives.invoke("plugin:dialog|open", { options });
65
65
  }
66
66
  /**
67
67
  * Open a file/directory save dialog.
@@ -91,7 +91,7 @@ async function save(options = {}) {
91
91
  if (typeof options === "object") {
92
92
  Object.freeze(options);
93
93
  }
94
- return u("plugin:dialog|save", { options });
94
+ return primitives.invoke("plugin:dialog|save", { options });
95
95
  }
96
96
  /**
97
97
  * Shows a message dialog with an `Ok` button.
@@ -111,13 +111,12 @@ async function save(options = {}) {
111
111
  *
112
112
  */
113
113
  async function message(message, options) {
114
- var _a, _b;
115
114
  const opts = typeof options === "string" ? { title: options } : options;
116
- return u("plugin:dialog|message", {
115
+ return primitives.invoke("plugin:dialog|message", {
117
116
  message: message.toString(),
118
- title: (_a = opts === null || opts === void 0 ? void 0 : opts.title) === null || _a === void 0 ? void 0 : _a.toString(),
119
- type_: opts === null || opts === void 0 ? void 0 : opts.type,
120
- okButtonLabel: (_b = opts === null || opts === void 0 ? void 0 : opts.okLabel) === null || _b === void 0 ? void 0 : _b.toString(),
117
+ title: opts?.title?.toString(),
118
+ type_: opts?.type,
119
+ okButtonLabel: opts?.okLabel?.toString(),
121
120
  });
122
121
  }
123
122
  /**
@@ -137,14 +136,13 @@ async function message(message, options) {
137
136
  * @since 2.0.0
138
137
  */
139
138
  async function ask(message, options) {
140
- var _a, _b, _c, _d, _e;
141
139
  const opts = typeof options === "string" ? { title: options } : options;
142
- return u("plugin:dialog|ask", {
140
+ return primitives.invoke("plugin:dialog|ask", {
143
141
  message: message.toString(),
144
- title: (_a = opts === null || opts === void 0 ? void 0 : opts.title) === null || _a === void 0 ? void 0 : _a.toString(),
145
- type_: opts === null || opts === void 0 ? void 0 : opts.type,
146
- okButtonLabel: (_c = (_b = opts === null || opts === void 0 ? void 0 : opts.okLabel) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "Yes",
147
- cancelButtonLabel: (_e = (_d = opts === null || opts === void 0 ? void 0 : opts.cancelLabel) === null || _d === void 0 ? void 0 : _d.toString()) !== null && _e !== void 0 ? _e : "No",
142
+ title: opts?.title?.toString(),
143
+ type_: opts?.type,
144
+ okButtonLabel: opts?.okLabel?.toString() ?? "Yes",
145
+ cancelButtonLabel: opts?.cancelLabel?.toString() ?? "No",
148
146
  });
149
147
  }
150
148
  /**
@@ -164,16 +162,18 @@ async function ask(message, options) {
164
162
  * @since 2.0.0
165
163
  */
166
164
  async function confirm(message, options) {
167
- var _a, _b, _c, _d, _e;
168
165
  const opts = typeof options === "string" ? { title: options } : options;
169
- return u("plugin:dialog|confirm", {
166
+ return primitives.invoke("plugin:dialog|confirm", {
170
167
  message: message.toString(),
171
- title: (_a = opts === null || opts === void 0 ? void 0 : opts.title) === null || _a === void 0 ? void 0 : _a.toString(),
172
- type_: opts === null || opts === void 0 ? void 0 : opts.type,
173
- okButtonLabel: (_c = (_b = opts === null || opts === void 0 ? void 0 : opts.okLabel) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "Ok",
174
- cancelButtonLabel: (_e = (_d = opts === null || opts === void 0 ? void 0 : opts.cancelLabel) === null || _d === void 0 ? void 0 : _d.toString()) !== null && _e !== void 0 ? _e : "Cancel",
168
+ title: opts?.title?.toString(),
169
+ type_: opts?.type,
170
+ okButtonLabel: opts?.okLabel?.toString() ?? "Ok",
171
+ cancelButtonLabel: opts?.cancelLabel?.toString() ?? "Cancel",
175
172
  });
176
173
  }
177
174
 
178
- export { ask, confirm, message, open, save };
179
- //# sourceMappingURL=index.min.js.map
175
+ exports.ask = ask;
176
+ exports.confirm = confirm;
177
+ exports.message = message;
178
+ exports.open = open;
179
+ exports.save = save;
@@ -109,13 +109,12 @@ async function save(options = {}) {
109
109
  *
110
110
  */
111
111
  async function message(message, options) {
112
- var _a, _b;
113
112
  const opts = typeof options === "string" ? { title: options } : options;
114
113
  return invoke("plugin:dialog|message", {
115
114
  message: message.toString(),
116
- title: (_a = opts === null || opts === void 0 ? void 0 : opts.title) === null || _a === void 0 ? void 0 : _a.toString(),
117
- type_: opts === null || opts === void 0 ? void 0 : opts.type,
118
- okButtonLabel: (_b = opts === null || opts === void 0 ? void 0 : opts.okLabel) === null || _b === void 0 ? void 0 : _b.toString(),
115
+ title: opts?.title?.toString(),
116
+ type_: opts?.type,
117
+ okButtonLabel: opts?.okLabel?.toString(),
119
118
  });
120
119
  }
121
120
  /**
@@ -135,14 +134,13 @@ async function message(message, options) {
135
134
  * @since 2.0.0
136
135
  */
137
136
  async function ask(message, options) {
138
- var _a, _b, _c, _d, _e;
139
137
  const opts = typeof options === "string" ? { title: options } : options;
140
138
  return invoke("plugin:dialog|ask", {
141
139
  message: message.toString(),
142
- title: (_a = opts === null || opts === void 0 ? void 0 : opts.title) === null || _a === void 0 ? void 0 : _a.toString(),
143
- type_: opts === null || opts === void 0 ? void 0 : opts.type,
144
- okButtonLabel: (_c = (_b = opts === null || opts === void 0 ? void 0 : opts.okLabel) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "Yes",
145
- cancelButtonLabel: (_e = (_d = opts === null || opts === void 0 ? void 0 : opts.cancelLabel) === null || _d === void 0 ? void 0 : _d.toString()) !== null && _e !== void 0 ? _e : "No",
140
+ title: opts?.title?.toString(),
141
+ type_: opts?.type,
142
+ okButtonLabel: opts?.okLabel?.toString() ?? "Yes",
143
+ cancelButtonLabel: opts?.cancelLabel?.toString() ?? "No",
146
144
  });
147
145
  }
148
146
  /**
@@ -162,16 +160,14 @@ async function ask(message, options) {
162
160
  * @since 2.0.0
163
161
  */
164
162
  async function confirm(message, options) {
165
- var _a, _b, _c, _d, _e;
166
163
  const opts = typeof options === "string" ? { title: options } : options;
167
164
  return invoke("plugin:dialog|confirm", {
168
165
  message: message.toString(),
169
- title: (_a = opts === null || opts === void 0 ? void 0 : opts.title) === null || _a === void 0 ? void 0 : _a.toString(),
170
- type_: opts === null || opts === void 0 ? void 0 : opts.type,
171
- okButtonLabel: (_c = (_b = opts === null || opts === void 0 ? void 0 : opts.okLabel) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "Ok",
172
- cancelButtonLabel: (_e = (_d = opts === null || opts === void 0 ? void 0 : opts.cancelLabel) === null || _d === void 0 ? void 0 : _d.toString()) !== null && _e !== void 0 ? _e : "Cancel",
166
+ title: opts?.title?.toString(),
167
+ type_: opts?.type,
168
+ okButtonLabel: opts?.okLabel?.toString() ?? "Ok",
169
+ cancelButtonLabel: opts?.cancelLabel?.toString() ?? "Cancel",
173
170
  });
174
171
  }
175
172
 
176
173
  export { ask, confirm, message, open, save };
177
- //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,30 +1,26 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-dialog",
3
- "version": "2.0.0-alpha.2",
3
+ "version": "2.0.0-alpha.4",
4
4
  "license": "MIT or APACHE-2.0",
5
5
  "authors": [
6
6
  "Tauri Programme within The Commons Conservancy"
7
7
  ],
8
8
  "type": "module",
9
- "browser": "dist-js/index.min.js",
10
- "module": "dist-js/index.mjs",
11
- "types": "dist-js/index.d.ts",
9
+ "types": "./dist-js/index.d.ts",
10
+ "main": "./dist-js/index.cjs",
11
+ "module": "./dist-js/index.js",
12
12
  "exports": {
13
- "import": "./dist-js/index.mjs",
14
13
  "types": "./dist-js/index.d.ts",
15
- "browser": "./dist-js/index.min.js"
14
+ "import": "./dist-js/index.js",
15
+ "require": "./dist-js/index.cjs"
16
16
  },
17
17
  "files": [
18
18
  "dist-js",
19
- "!dist-js/**/*.map",
20
19
  "README.md",
21
20
  "LICENSE"
22
21
  ],
23
- "devDependencies": {
24
- "tslib": "^2.4.1"
25
- },
26
22
  "dependencies": {
27
- "@tauri-apps/api": "2.0.0-alpha.9"
23
+ "@tauri-apps/api": "2.0.0-alpha.12"
28
24
  },
29
25
  "scripts": {
30
26
  "build": "rollup -c"