@tauri-apps/plugin-sql 2.0.0-alpha.1 → 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
@@ -4,7 +4,7 @@ Interface with SQL databases through [sqlx](https://github.com/launchbadge/sqlx)
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
  export interface QueryResult {
7
2
  /** The number of rows affected by the query. */
8
3
  rowsAffected: number;
@@ -33,7 +28,7 @@ export default class Database {
33
28
  *
34
29
  * # Sqlite
35
30
  *
36
- * The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
31
+ * The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
37
32
  *
38
33
  * @example
39
34
  * ```ts
@@ -50,7 +45,7 @@ export default class Database {
50
45
  *
51
46
  * # Sqlite
52
47
  *
53
- * The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
48
+ * The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
54
49
  *
55
50
  * @example
56
51
  * ```ts
@@ -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
@@ -19,7 +23,7 @@ class Database {
19
23
  *
20
24
  * # Sqlite
21
25
  *
22
- * The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
26
+ * The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
23
27
  *
24
28
  * @example
25
29
  * ```ts
@@ -27,7 +31,7 @@ class Database {
27
31
  * ```
28
32
  */
29
33
  static async load(path) {
30
- const _path = await window.__TAURI_INVOKE__("plugin:sql|load", {
34
+ const _path = await u("plugin:sql|load", {
31
35
  db: path,
32
36
  });
33
37
  return new Database(_path);
@@ -41,7 +45,7 @@ class Database {
41
45
  *
42
46
  * # Sqlite
43
47
  *
44
- * The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
48
+ * The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
45
49
  *
46
50
  * @example
47
51
  * ```ts
@@ -84,7 +88,7 @@ class Database {
84
88
  * ```
85
89
  */
86
90
  async execute(query, bindValues) {
87
- const [rowsAffected, lastInsertId] = await window.__TAURI_INVOKE__("plugin:sql|execute", {
91
+ const [rowsAffected, lastInsertId] = await u("plugin:sql|execute", {
88
92
  db: this.path,
89
93
  query,
90
94
  values: bindValues !== null && bindValues !== void 0 ? bindValues : [],
@@ -113,7 +117,7 @@ class Database {
113
117
  * ```
114
118
  */
115
119
  async select(query, bindValues) {
116
- const result = await window.__TAURI_INVOKE__("plugin:sql|select", {
120
+ const result = await u("plugin:sql|select", {
117
121
  db: this.path,
118
122
  query,
119
123
  values: bindValues !== null && bindValues !== void 0 ? bindValues : [],
@@ -132,7 +136,7 @@ class Database {
132
136
  * @param db - Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope.
133
137
  */
134
138
  async close(db) {
135
- const success = await window.__TAURI_INVOKE__("plugin:sql|close", {
139
+ const success = await u("plugin:sql|close", {
136
140
  db,
137
141
  });
138
142
  return success;
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
@@ -19,7 +21,7 @@ class Database {
19
21
  *
20
22
  * # Sqlite
21
23
  *
22
- * The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
24
+ * The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
23
25
  *
24
26
  * @example
25
27
  * ```ts
@@ -27,7 +29,7 @@ class Database {
27
29
  * ```
28
30
  */
29
31
  static async load(path) {
30
- const _path = await window.__TAURI_INVOKE__("plugin:sql|load", {
32
+ const _path = await invoke("plugin:sql|load", {
31
33
  db: path,
32
34
  });
33
35
  return new Database(_path);
@@ -41,7 +43,7 @@ class Database {
41
43
  *
42
44
  * # Sqlite
43
45
  *
44
- * The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
46
+ * The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
45
47
  *
46
48
  * @example
47
49
  * ```ts
@@ -84,7 +86,7 @@ class Database {
84
86
  * ```
85
87
  */
86
88
  async execute(query, bindValues) {
87
- const [rowsAffected, lastInsertId] = await window.__TAURI_INVOKE__("plugin:sql|execute", {
89
+ const [rowsAffected, lastInsertId] = await invoke("plugin:sql|execute", {
88
90
  db: this.path,
89
91
  query,
90
92
  values: bindValues !== null && bindValues !== void 0 ? bindValues : [],
@@ -113,7 +115,7 @@ class Database {
113
115
  * ```
114
116
  */
115
117
  async select(query, bindValues) {
116
- const result = await window.__TAURI_INVOKE__("plugin:sql|select", {
118
+ const result = await invoke("plugin:sql|select", {
117
119
  db: this.path,
118
120
  query,
119
121
  values: bindValues !== null && bindValues !== void 0 ? bindValues : [],
@@ -132,7 +134,7 @@ class Database {
132
134
  * @param db - Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope.
133
135
  */
134
136
  async close(db) {
135
- const success = await window.__TAURI_INVOKE__("plugin:sql|close", {
137
+ const success = await invoke("plugin:sql|close", {
136
138
  db,
137
139
  });
138
140
  return success;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-sql",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.2",
4
4
  "description": "Interface with SQL databases",
5
5
  "license": "MIT or APACHE-2.0",
6
6
  "authors": [
@@ -25,7 +25,7 @@
25
25
  "tslib": "2.6.0"
26
26
  },
27
27
  "dependencies": {
28
- "@tauri-apps/api": "2.0.0-alpha.6"
28
+ "@tauri-apps/api": "2.0.0-alpha.9"
29
29
  },
30
30
  "scripts": {
31
31
  "build": "rollup -c"