-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapi-iife.js
More file actions
1 lines (1 loc) · 3.64 KB
/
api-iife.js
File metadata and controls
1 lines (1 loc) · 3.64 KB
1
if("__TAURI__"in window){var __TAURI_PLUGIN_SQLITE__=function(t){"use strict";async function e(t,e={},a){return window.__TAURI_INTERNALS__.invoke(t,e,a)}"function"==typeof SuppressedError&&SuppressedError;class a{constructor(t,e){this._dbPath=t,this._transactionId=e}async read(t,a){return await e("plugin:sqlite|transaction_read",{token:{dbPath:this._dbPath,transactionId:this._transactionId},query:t,values:a??[]})}async continueWith(t){const n=await e("plugin:sqlite|transaction_continue",{token:{dbPath:this._dbPath,transactionId:this._transactionId},action:{type:"Continue",statements:t.map(([t,e])=>({query:t,values:e??[]}))}});return new a(n.dbPath,n.transactionId)}async commit(){await e("plugin:sqlite|transaction_continue",{token:{dbPath:this._dbPath,transactionId:this._transactionId},action:{type:"Commit"}})}async rollback(){await e("plugin:sqlite|transaction_continue",{token:{dbPath:this._dbPath,transactionId:this._transactionId},action:{type:"Rollback"}})}}class n{constructor(t,e,a,n=[]){this._db=t,this._query=e,this._bindValues=a,this._attached=n}attach(t){return this._attached=t,this}then(t,e){return this._execute().then(t,e)}async _execute(){return await e("plugin:sqlite|fetch_all",{db:this._db.path,query:this._query,values:this._bindValues,attached:this._attached.length>0?this._attached:null})}}class s{constructor(t,e,a,n=[]){this._db=t,this._query=e,this._bindValues=a,this._attached=n}attach(t){return this._attached=t,this}then(t,e){return this._execute().then(t,e)}async _execute(){return await e("plugin:sqlite|fetch_one",{db:this._db.path,query:this._query,values:this._bindValues,attached:this._attached.length>0?this._attached:null})}}class i{constructor(t,e,a,n=[]){this._db=t,this._query=e,this._bindValues=a,this._attached=n}attach(t){return this._attached=t,this}then(t,e){return this._execute().then(t,e)}async _execute(){const[t,a]=await e("plugin:sqlite|execute",{db:this._db.path,query:this._query,values:this._bindValues,attached:this._attached.length>0?this._attached:null});return{lastInsertId:a,rowsAffected:t}}}class h{constructor(t,e,a=[]){this._db=t,this._initialStatements=e,this._attached=a}attach(t){return this._attached=t,this}then(t,e){return this._execute().then(t,e)}async _execute(){const t=await e("plugin:sqlite|begin_interruptible_transaction",{db:this._db.path,initialStatements:this._initialStatements.map(([t,e])=>({query:t,values:e??[]})),attached:this._attached.length>0?this._attached:null});return new a(t.dbPath,t.transactionId)}}class r{constructor(t,e,a=[]){this._db=t,this._statements=e,this._attached=a}attach(t){return this._attached=t,this}then(t,e){return this._execute().then(t,e)}async _execute(){return await e("plugin:sqlite|execute_transaction",{db:this._db.path,statements:this._statements.map(([t,e])=>({query:t,values:e??[]})),attached:this._attached.length>0?this._attached:null})}}class c{constructor(t){this.path=t}static async load(t,a){const n=await e("plugin:sqlite|load",{db:t,customConfig:a});return new c(n)}static get(t){return new c(t)}static async close_all(){await e("plugin:sqlite|close_all")}execute(t,e){return new i(this,t,e??[])}executeTransaction(t){return new r(this,t)}fetchAll(t,e){return new n(this,t,e??[])}fetchOne(t,e){return new s(this,t,e??[])}async close(){return await e("plugin:sqlite|close",{db:this.path})}async remove(){return await e("plugin:sqlite|remove",{db:this.path})}beginInterruptibleTransaction(t){return new h(this,t)}async getMigrationEvents(){return await e("plugin:sqlite|get_migration_events",{db:this.path})}}return t.InterruptibleTransaction=a,t.default=c,Object.defineProperty(t,"__esModule",{value:!0}),t}({});Object.defineProperty(window.__TAURI__,"sqlite",{value:__TAURI_PLUGIN_SQLITE__})}