mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-22 21:30:44 +02:00
currently each script inlines what it needs from @tauri-apps/api, so type checks like `image instanceof Image` all fail
2 lines
2.7 KiB
JavaScript
2 lines
2.7 KiB
JavaScript
if("__TAURI__"in window){var __TAURI_PLUGIN_STORE__=function(t,e,a){"use strict";async function s(t,e){return await i.load(t,e)}class i extends a.Resource{constructor(t){super(t)}static async load(t,e){const s=await a.invoke("plugin:store|load",{path:t,options:e});return new i(s)}static async get(t){return await a.invoke("plugin:store|get_store",{path:t}).then(t=>t?new i(t):null)}async set(t,e){await a.invoke("plugin:store|set",{rid:this.rid,key:t,value:e})}async get(t){const[e,s]=await a.invoke("plugin:store|get",{rid:this.rid,key:t});return s?e:void 0}async has(t){return await a.invoke("plugin:store|has",{rid:this.rid,key:t})}async delete(t){return await a.invoke("plugin:store|delete",{rid:this.rid,key:t})}async clear(){await a.invoke("plugin:store|clear",{rid:this.rid})}async reset(){await a.invoke("plugin:store|reset",{rid:this.rid})}async keys(){return await a.invoke("plugin:store|keys",{rid:this.rid})}async values(){return await a.invoke("plugin:store|values",{rid:this.rid})}async entries(){return await a.invoke("plugin:store|entries",{rid:this.rid})}async length(){return await a.invoke("plugin:store|length",{rid:this.rid})}async reload(t){await a.invoke("plugin:store|reload",{rid:this.rid,...t})}async save(){await a.invoke("plugin:store|save",{rid:this.rid})}async onKeyChange(t,a){return await e.listen("store://change",e=>{e.payload.resourceId===this.rid&&e.payload.key===t&&a(e.payload.exists?e.payload.value:void 0)})}async onChange(t){return await e.listen("store://change",e=>{e.payload.resourceId===this.rid&&t(e.payload.key,e.payload.exists?e.payload.value:void 0)})}}return t.LazyStore=class{get store(){return this._store||(this._store=s(this.path,this.options)),this._store}constructor(t,e){this.path=t,this.options=e}async init(){await this.store}async set(t,e){return(await this.store).set(t,e)}async get(t){return(await this.store).get(t)}async has(t){return(await this.store).has(t)}async delete(t){return(await this.store).delete(t)}async clear(){await(await this.store).clear()}async reset(){await(await this.store).reset()}async keys(){return(await this.store).keys()}async values(){return(await this.store).values()}async entries(){return(await this.store).entries()}async length(){return(await this.store).length()}async reload(t){await(await this.store).reload(t)}async save(){await(await this.store).save()}async onKeyChange(t,e){return(await this.store).onKeyChange(t,e)}async onChange(t){return(await this.store).onChange(t)}async close(){this._store&&await(await this._store).close()}},t.Store=i,t.getStore=async function(t){return await i.get(t)},t.load=s,t}({},window.__TAURI__.event,window.__TAURI__.core);Object.defineProperty(window.__TAURI__,"store",{value:__TAURI_PLUGIN_STORE__})}
|