pinia-persist.umd.js 962 B

1
  1. (function(s,i){typeof exports=="object"&&typeof module!="undefined"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(s=typeof globalThis!="undefined"?globalThis:s||self,i(s.piniaPersist={}))})(this,function(s){"use strict";const i=(t,e)=>{const n=t.storage||sessionStorage,a=t.key||e.$id;if(t.paths){const d=t.paths.reduce((o,f)=>(o[f]=e.$state[f],o),{});n.setItem(a,JSON.stringify(d))}else n.setItem(a,JSON.stringify(e.$state))};var g=({options:t,store:e})=>{var n,a,d,o;if((n=t.persist)!=null&&n.enabled){const f=[{key:e.$id,storage:sessionStorage}],u=(d=(a=t.persist)==null?void 0:a.strategies)!=null&&d.length?(o=t.persist)==null?void 0:o.strategies:f;u.forEach(r=>{const p=r.storage||sessionStorage,l=r.key||e.$id,c=p.getItem(l);c&&(e.$patch(JSON.parse(c)),i(r,e))}),e.$subscribe(()=>{u.forEach(r=>{i(r,e)})})}};s.default=g,s.updateStorage=i,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});