atomaric 0.0.73 → 0.0.75

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/build/atomaric.js CHANGED
@@ -204,7 +204,7 @@ class pe {
204
204
  if (this.setDeferred = (r, u = 500, x, b = !0) => {
205
205
  b && w === void 0 && S(r, x), clearTimeout(w), w = setTimeout(re, u, r, x);
206
206
  }, i == null) return y;
207
- let A = null, j = null, q = !0, F = !0, N = !1, $ = 0, T = 0, K = -1, I = e instanceof Set || e instanceof Map ? (r) => new Set(r) : (r) => r, L = e instanceof Set ? (r) => {
207
+ let A = null, j = null, q = !0, F = !0, N = !1, $ = 0, T = 0, K = -1, I = e instanceof Set ? (r) => new Set(r) : e instanceof Map ? (r) => new Map(r) : (r) => r, L = e instanceof Set ? (r) => {
208
208
  if (r instanceof Set) return Array.from(r);
209
209
  throw console.error(r), "The value is not Set instance";
210
210
  } : e instanceof Map ? (r) => {
@@ -1 +1 @@
1
- (function(f,j){typeof exports=="object"&&typeof module<"u"?j(exports):typeof define=="function"&&define.amd?define(["exports"],j):(f=typeof globalThis<"u"?globalThis:f||self,j(f.atomaric={}))})(this,function(f){"use strict";let j=()=>{throw"call configureAtomaric() before all!"};const $={},de=t=>{$.useSyncExternalStore=j=t.useSyncExternalStore,$.keyPathSeparator=t.keyPathSeparator,$.securifyKeyLevel=t.securifyKeyLevel,$.securifyValueLevel=t.securifyValueLevel},Y=t=>j(t.subscribe,t.get),Z=t=>t.set,ge=t=>t.setDeferred,Ae=t=>t.get,me=t=>t.do,pe=t=>[Y(t),Z(t)],we=(t,e)=>new ie(t,e);class I{constructor(e){if(e)return new Proxy(this,{get:(i,s)=>s in this?i[s]:e[s]})}}const ye=(t,e)=>{const i=(s,r,o)=>new Proxy(s,{get:(l,d,m)=>{const A=o===0&&e.get!=null?e.get(l,d,m):l[d];return typeof A=="object"&&A!==null?i(Array.isArray(A)?A.slice(0):{...A},r.concat(Array.isArray(l)?+d:d),o+1):A},set:(l,d,m)=>(e.onSet(l,r,d,m,l[d])&&(l[d]=m),!0)});return i(t,[],0)};class v extends I{constructor(){super(...arguments),this.updateValue=(e,i)=>{const s=Array.isArray(e)?e.slice(0):{...e};let r=!1;const o=ye(e,{onSet:(l,d,m,A,p)=>{if(A===p)return!0;let S=s;r=!0;for(const h of d){const g=S[h];S=S[h]=Array.isArray(g)?g.slice():{...g}}return S[m]=A,!0}});return i(o),r?s:e}}}class k extends v{constructor(e,i){super(i),this.a=e,this.push=(...s)=>{s.length!==0&&this.a.set(this.a.get().concat(s))},this.unshift=(...s)=>{s.length!==0&&this.a.set(s.concat(this.a.get()))},this.update=s=>{const r=this.a.get(),o=this.updateValue(r,s);o!==r&&this.a.set(o)},this.filter=s=>{const r=this.a.get().filter(s??Se);r.length!==this.a.get().length&&this.a.set(r)},this.add=s=>{this.a.get().includes(s)||this.a.set(this.a.get().concat([s]))},this.removeFirst=s=>{const r=this.a.get().indexOf(s);if(r<0)return;const o=this.a.get().slice(0);o.splice(r,1),this.a.set(o)},this.toggle=(s,r)=>{const o=this.a.get().slice(),l=o.indexOf(s);l<0?r?o.unshift(s):o.push(s):o.splice(l,1),this.a.set(o)}}}const Se=t=>t;class O extends I{constructor(e,i){super(i),this.a=e,this.toggle=()=>{this.a.set(!this.a.get())}}}class ee extends I{constructor(e,i){super(i),this.a=e,this.setValue=(s,r)=>{if(this.a.get().get(s)===r)return;const o=new Map(this.a.get());o.set(s,r),this.a.set(o)},this.setIfNo=(s,r)=>{if(this.a.get().has(s))return;const o=new Map(this.a.get());o.set(s,r),this.a.set(o)},this.delete=s=>{if(!this.a.get().has(s))return;const r=new Map(this.a.get());r.delete(s),this.a.set(r)},this.toggle=(s,r)=>{const o=new Map(this.a.get());o.has(s)?o.delete(s):o.set(s,r),this.a.set(o)},this.clear=()=>{this.a.set(new Map)},this.a=e}}class te extends I{constructor(e,i){super(i),this.a=e,this.increment=s=>{this.a.set(+this.a.get()+(s??1))}}}class se extends v{constructor(e,i){super(i),this.a=e,this.setPartial=s=>this.a.set(r=>({...r,...typeof s=="function"?s(this.a.get()):s})),this.update=s=>{const r=this.a.get(),o=this.updateValue(r,s);o!==r&&this.a.set(o)},this.setDeepPartial=(s,r,o,l=$.keyPathSeparator||".")=>{if(!l)return;if(s.includes(l)){let A=s.split(l);const p=A[A.length-1];A=A.slice(0,-1);const S={...this.a.get()};let h=S,g=o;for(const w of A){g=g==null?void 0:g[Array.isArray(g)?"0":w];const M=h[ne(h,w)]??(Array.isArray(g)?[]:{});if(M==null||typeof M!="object"){if(o==null)throw"Incorrect path for setDeepPartial";const b=typeof r=="function"?r(void 0):r;this.a.get()[s]!==b&&this.setPartial({[s]:b});return}h=h[ne(h,w)]=Array.isArray(M)?[...M]:{...M}}const q=h[p];h[p]=typeof r=="function"?r(h[p]):r,q!==h[p]&&this.a.set(S);return}const d=this.a.get()[s],m=typeof r=="function"?r(d):r;m!==d&&this.setPartial({[s]:m})}}}const ne=(t,e)=>Array.isArray(t)?`${+e}`:e;class re extends I{constructor(e,i){super(i),this.a=e,this.add=s=>{this.a.get().has(s)||this.a.set(new Set(this.a.get()).add(s))},this.delete=s=>{if(!this.a.get().has(s))return;const r=new Set(this.a.get());r.delete(s),this.a.set(r)},this.toggle=s=>{const r=new Set(this.a.get());r.has(s)?r.delete(s):r.add(s),this.a.set(r)},this.clear=()=>{this.a.set(new Set)},this.a=e}}const be=(t,e,i)=>{const s=typeof i=="object"&&i!=null&&"do"in i?i.do((o,l)=>e.set(o,l),()=>e.get(),e,(o,l,d)=>e.setDeferred(o,l,d)):null,r={};return s&&Object.keys(s).forEach(o=>Object.defineProperty(r,o,{get:()=>s[o]})),typeof t=="number"?new te(e,s):typeof t=="boolean"?new O(e,s):Array.isArray(t)?new k(e,s):t instanceof Set?new re(e,s):t instanceof Map?new ee(e,s):t instanceof Object?new se(e,s):new I(s)};class ie{constructor(e,i){e=typeof e=="function"?e():e;const s=n=>A=n,r=()=>A,o=new Set,l=n=>n(h());let d=!0,m=!1,A=e,p,S=()=>{},h=()=>r(),g=null,q=()=>{const n=be(e,w,i);return q=()=>n,n};const w=new Proxy(this,{get:(n,u)=>u==="do"?q():n[u],set:De}),M=()=>{d=!0,m!==!0&&S(h()),m=!1;try{B.postMessage({key:a,value:r()})}catch{}},b=(n,u)=>{const D=typeof n=="function"?n(h()):n;D!==h()&&(s(D),m=u,d&&(d=!1,o.forEach(l),queueMicrotask(M)))};this.set=(n,u)=>b(n,u),this.get=()=>h(),this.initialValue=e,this.isInitialValue=()=>e===r(),this.subscribe=n=>(o.add(n),()=>{o.delete(n)}),this.reset=()=>{b(e,!0)};const Te=(n,u)=>{b(n,u),p=void 0};if(this.setDeferred=(n,u=500,D,x=!0)=>{x&&p===void 0&&b(n,D),clearTimeout(p),p=setTimeout(Te,u,n,D)},i==null)return w;let y=null,z=null,H=!0,J=!0,Q=!1,T=0,V=0,ue=-1,_=e instanceof Set||e instanceof Map?n=>new Set(n):n=>n,E=e instanceof Set?n=>{if(n instanceof Set)return Array.from(n);throw console.error(n),"The value is not Set instance"}:e instanceof Map?n=>{if(n instanceof Map){const u=[];return n.forEach((D,x)=>u.push([x,D])),u}throw console.error(n),"The value is not Set instance"}:n=>n;if(typeof i=="string")y=i;else if("storeKey"in i)H=i.warnOnDuplicateStoreKey??H,J=i.listenStorageChanges??J,y=i.storeKey,_=i.unzipValue??_,E=i.zipValue??E,Q=i.unchangable??Q,T=i.securifyKeyLevel??$.securifyKeyLevel??T,V=i.securifyValueLevel??$.securifyValueLevel??V,z=i.exp??z;else return w;const K=T?C(y,T):y,a=`${V?F:P}${K}`;if(T){const n=`${P}${y}`;n in c&&(c[a]=c[n],delete c[n])}else{const n=`${P}${C(y,T)}`;n in c&&(c[a]=c[n],delete c[n])}const X=z===null||!(z(w,a in c)instanceof Date)?n=>C([E(n)],0):n=>(g??(g={}),g.exp=z(w,a in c).getTime(),g.exp-Date.now()<24*60*60*1e3&&(clearTimeout(ue),clearTimeout(oe[a]),ue=setTimeout(()=>this.reset(),g.exp-Date.now())),g.exp=Math.trunc(g.exp/1e3),C([E(n),g],0));if(V){const n=`${P}${K}`,u=E,D=_;if(E=x=>{try{return C([u(x)],V)}catch{return delete c[a],""}},n in c){const x=`${P}${C(y,T)}`;try{c[x]=X(_(U(c[n],0)[0])),delete c[n]}catch{}}_=x=>{try{return D(U(x,V)[0])}catch{return delete c[a],""}}}else delete c[`${F}${K}`];const fe=n=>{const u=U(n,0);return g=u[1],_(u[0])};let le=!0;if(W[a]=w,c[`atom/${y}`]&&(c[a]||(c[a]=`[${c[`atom/${y}`]}]`),delete c[`atom/${y}`]),h=()=>{if(h=r,le){le=!1;try{s(a in c?fe(c[a]):e)}catch{console.warn("Invalid json value",c[a])}}return r()},S=n=>{if(n===e){this.reset();return}c[a]=X(n)},this.reset=()=>{delete c[a],b(e,!0)},H&&L[a]!==void 0&&console.warn("Duplicate Atom key",y),J)if(Q){let n=!1,u;R[a]=this,L[a]=()=>{clearTimeout(u),u=setTimeout(()=>n=!1,10),!n&&(n=!0,c[a]=X(r()))}}else L[a]=n=>{if(n.newValue===null){this.reset();return}try{b(fe(n.newValue))}catch{console.warn("Invalid json value",n.newValue)}};return w}}let B;try{B=new BroadcastChannel("updateHere"),B.addEventListener("message",t=>{var e;(e=R[t.data.key])==null||e.set(t.data.value,!0)})}catch{}const c=localStorage,L={},R={},De=(t,e)=>{throw`${e} is readonly property`};window.addEventListener("storage",t=>{var e;t.key===null||t.newValue===t.oldValue||(e=L[t.key])==null||e.call(L,t)});const xe=c.setItem.bind(c),$e=c.removeItem.bind(c);c.setItem=(t,e)=>{R[t]===void 0&&xe.call(c,t,e)},c.removeItem=t=>{R[t]===void 0&&$e.call(c,t)};const Me=/"exp":\s*(\d+)/,P="atom\\",F="atom`s\\",W={},oe={},ce=/[a-z]/gi,N=5,G={};for(let t=54;t<80;t++){if(t===68||t===72||t===55)continue;const e=String.fromCharCode(t+43).toUpperCase(),i=String.fromCharCode(t+43).toLowerCase();G[e]=i,G[i]=e}const ae=t=>G[t]??t,C=(()=>{const t=[e=>JSON.stringify(e),e=>btoa(encodeURI(t[0](e))),e=>{const i=t[1](e);return`${i.slice(0,N)}${i.slice(N).replace(ce,ae)}`},e=>btoa(t[2](e))];return(e,i)=>{try{return t[i](e)}catch(s){if(i===0)throw s;return t[0](e)}}})(),U=(()=>{const t=[e=>JSON.parse(e),e=>t[0](decodeURI(atob(e))),e=>t[1](`${e.slice(0,N)}${e.slice(N).replace(ce,ae)}`),e=>t[2](atob(e))];return(e,i)=>{try{return t[i](e)}catch(s){if(i===0)throw s;return t[0](e)}}})();setTimeout(()=>{Object.keys(c).forEach(t=>{var s;if(typeof c[t]!="string"||!t.startsWith(P)&&!t.startsWith(F))return;const e=+((s=c[t].match(Me))==null?void 0:s[1]);if(!e||e*1e3-Date.now()>24*60*60*1e3)return;const i=U(c[t],0);!Array.isArray(i)||i[1]==null||!("exp"in i[1])||i[1].exp!==e||(oe[t]=setTimeout(()=>{W[t]?W[t].reset():delete c[t]},e*1e3-Date.now()))})},1e3),f.Atom=ie,f.AtomArrayDoActions=k,f.AtomBooleanDoActions=O,f.AtomMapDoActions=ee,f.AtomNumberDoActions=te,f.AtomObjectDoActions=se,f.AtomSetDoActions=re,f.atom=we,f.configureAtomaric=de,f.configuredOptions=$,f.useAtom=pe,f.useAtomDo=me,f.useAtomGet=Ae,f.useAtomSet=Z,f.useAtomSetDeferred=ge,f.useAtomValue=Y,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
1
+ (function(f,j){typeof exports=="object"&&typeof module<"u"?j(exports):typeof define=="function"&&define.amd?define(["exports"],j):(f=typeof globalThis<"u"?globalThis:f||self,j(f.atomaric={}))})(this,function(f){"use strict";let j=()=>{throw"call configureAtomaric() before all!"};const $={},de=t=>{$.useSyncExternalStore=j=t.useSyncExternalStore,$.keyPathSeparator=t.keyPathSeparator,$.securifyKeyLevel=t.securifyKeyLevel,$.securifyValueLevel=t.securifyValueLevel},Y=t=>j(t.subscribe,t.get),Z=t=>t.set,ge=t=>t.setDeferred,Ae=t=>t.get,me=t=>t.do,pe=t=>[Y(t),Z(t)],we=(t,e)=>new ie(t,e);class I{constructor(e){if(e)return new Proxy(this,{get:(i,s)=>s in this?i[s]:e[s]})}}const ye=(t,e)=>{const i=(s,r,o)=>new Proxy(s,{get:(l,d,m)=>{const A=o===0&&e.get!=null?e.get(l,d,m):l[d];return typeof A=="object"&&A!==null?i(Array.isArray(A)?A.slice(0):{...A},r.concat(Array.isArray(l)?+d:d),o+1):A},set:(l,d,m)=>(e.onSet(l,r,d,m,l[d])&&(l[d]=m),!0)});return i(t,[],0)};class v extends I{constructor(){super(...arguments),this.updateValue=(e,i)=>{const s=Array.isArray(e)?e.slice(0):{...e};let r=!1;const o=ye(e,{onSet:(l,d,m,A,p)=>{if(A===p)return!0;let S=s;r=!0;for(const h of d){const g=S[h];S=S[h]=Array.isArray(g)?g.slice():{...g}}return S[m]=A,!0}});return i(o),r?s:e}}}class k extends v{constructor(e,i){super(i),this.a=e,this.push=(...s)=>{s.length!==0&&this.a.set(this.a.get().concat(s))},this.unshift=(...s)=>{s.length!==0&&this.a.set(s.concat(this.a.get()))},this.update=s=>{const r=this.a.get(),o=this.updateValue(r,s);o!==r&&this.a.set(o)},this.filter=s=>{const r=this.a.get().filter(s??Se);r.length!==this.a.get().length&&this.a.set(r)},this.add=s=>{this.a.get().includes(s)||this.a.set(this.a.get().concat([s]))},this.removeFirst=s=>{const r=this.a.get().indexOf(s);if(r<0)return;const o=this.a.get().slice(0);o.splice(r,1),this.a.set(o)},this.toggle=(s,r)=>{const o=this.a.get().slice(),l=o.indexOf(s);l<0?r?o.unshift(s):o.push(s):o.splice(l,1),this.a.set(o)}}}const Se=t=>t;class O extends I{constructor(e,i){super(i),this.a=e,this.toggle=()=>{this.a.set(!this.a.get())}}}class ee extends I{constructor(e,i){super(i),this.a=e,this.setValue=(s,r)=>{if(this.a.get().get(s)===r)return;const o=new Map(this.a.get());o.set(s,r),this.a.set(o)},this.setIfNo=(s,r)=>{if(this.a.get().has(s))return;const o=new Map(this.a.get());o.set(s,r),this.a.set(o)},this.delete=s=>{if(!this.a.get().has(s))return;const r=new Map(this.a.get());r.delete(s),this.a.set(r)},this.toggle=(s,r)=>{const o=new Map(this.a.get());o.has(s)?o.delete(s):o.set(s,r),this.a.set(o)},this.clear=()=>{this.a.set(new Map)},this.a=e}}class te extends I{constructor(e,i){super(i),this.a=e,this.increment=s=>{this.a.set(+this.a.get()+(s??1))}}}class se extends v{constructor(e,i){super(i),this.a=e,this.setPartial=s=>this.a.set(r=>({...r,...typeof s=="function"?s(this.a.get()):s})),this.update=s=>{const r=this.a.get(),o=this.updateValue(r,s);o!==r&&this.a.set(o)},this.setDeepPartial=(s,r,o,l=$.keyPathSeparator||".")=>{if(!l)return;if(s.includes(l)){let A=s.split(l);const p=A[A.length-1];A=A.slice(0,-1);const S={...this.a.get()};let h=S,g=o;for(const w of A){g=g==null?void 0:g[Array.isArray(g)?"0":w];const M=h[ne(h,w)]??(Array.isArray(g)?[]:{});if(M==null||typeof M!="object"){if(o==null)throw"Incorrect path for setDeepPartial";const b=typeof r=="function"?r(void 0):r;this.a.get()[s]!==b&&this.setPartial({[s]:b});return}h=h[ne(h,w)]=Array.isArray(M)?[...M]:{...M}}const q=h[p];h[p]=typeof r=="function"?r(h[p]):r,q!==h[p]&&this.a.set(S);return}const d=this.a.get()[s],m=typeof r=="function"?r(d):r;m!==d&&this.setPartial({[s]:m})}}}const ne=(t,e)=>Array.isArray(t)?`${+e}`:e;class re extends I{constructor(e,i){super(i),this.a=e,this.add=s=>{this.a.get().has(s)||this.a.set(new Set(this.a.get()).add(s))},this.delete=s=>{if(!this.a.get().has(s))return;const r=new Set(this.a.get());r.delete(s),this.a.set(r)},this.toggle=s=>{const r=new Set(this.a.get());r.has(s)?r.delete(s):r.add(s),this.a.set(r)},this.clear=()=>{this.a.set(new Set)},this.a=e}}const be=(t,e,i)=>{const s=typeof i=="object"&&i!=null&&"do"in i?i.do((o,l)=>e.set(o,l),()=>e.get(),e,(o,l,d)=>e.setDeferred(o,l,d)):null,r={};return s&&Object.keys(s).forEach(o=>Object.defineProperty(r,o,{get:()=>s[o]})),typeof t=="number"?new te(e,s):typeof t=="boolean"?new O(e,s):Array.isArray(t)?new k(e,s):t instanceof Set?new re(e,s):t instanceof Map?new ee(e,s):t instanceof Object?new se(e,s):new I(s)};class ie{constructor(e,i){e=typeof e=="function"?e():e;const s=n=>A=n,r=()=>A,o=new Set,l=n=>n(h());let d=!0,m=!1,A=e,p,S=()=>{},h=()=>r(),g=null,q=()=>{const n=be(e,w,i);return q=()=>n,n};const w=new Proxy(this,{get:(n,u)=>u==="do"?q():n[u],set:De}),M=()=>{d=!0,m!==!0&&S(h()),m=!1;try{B.postMessage({key:a,value:r()})}catch{}},b=(n,u)=>{const D=typeof n=="function"?n(h()):n;D!==h()&&(s(D),m=u,d&&(d=!1,o.forEach(l),queueMicrotask(M)))};this.set=(n,u)=>b(n,u),this.get=()=>h(),this.initialValue=e,this.isInitialValue=()=>e===r(),this.subscribe=n=>(o.add(n),()=>{o.delete(n)}),this.reset=()=>{b(e,!0)};const Te=(n,u)=>{b(n,u),p=void 0};if(this.setDeferred=(n,u=500,D,x=!0)=>{x&&p===void 0&&b(n,D),clearTimeout(p),p=setTimeout(Te,u,n,D)},i==null)return w;let y=null,z=null,H=!0,J=!0,Q=!1,T=0,V=0,ue=-1,_=e instanceof Set?n=>new Set(n):e instanceof Map?n=>new Map(n):n=>n,E=e instanceof Set?n=>{if(n instanceof Set)return Array.from(n);throw console.error(n),"The value is not Set instance"}:e instanceof Map?n=>{if(n instanceof Map){const u=[];return n.forEach((D,x)=>u.push([x,D])),u}throw console.error(n),"The value is not Set instance"}:n=>n;if(typeof i=="string")y=i;else if("storeKey"in i)H=i.warnOnDuplicateStoreKey??H,J=i.listenStorageChanges??J,y=i.storeKey,_=i.unzipValue??_,E=i.zipValue??E,Q=i.unchangable??Q,T=i.securifyKeyLevel??$.securifyKeyLevel??T,V=i.securifyValueLevel??$.securifyValueLevel??V,z=i.exp??z;else return w;const K=T?C(y,T):y,a=`${V?F:P}${K}`;if(T){const n=`${P}${y}`;n in c&&(c[a]=c[n],delete c[n])}else{const n=`${P}${C(y,T)}`;n in c&&(c[a]=c[n],delete c[n])}const X=z===null||!(z(w,a in c)instanceof Date)?n=>C([E(n)],0):n=>(g??(g={}),g.exp=z(w,a in c).getTime(),g.exp-Date.now()<24*60*60*1e3&&(clearTimeout(ue),clearTimeout(oe[a]),ue=setTimeout(()=>this.reset(),g.exp-Date.now())),g.exp=Math.trunc(g.exp/1e3),C([E(n),g],0));if(V){const n=`${P}${K}`,u=E,D=_;if(E=x=>{try{return C([u(x)],V)}catch{return delete c[a],""}},n in c){const x=`${P}${C(y,T)}`;try{c[x]=X(_(U(c[n],0)[0])),delete c[n]}catch{}}_=x=>{try{return D(U(x,V)[0])}catch{return delete c[a],""}}}else delete c[`${F}${K}`];const fe=n=>{const u=U(n,0);return g=u[1],_(u[0])};let le=!0;if(W[a]=w,c[`atom/${y}`]&&(c[a]||(c[a]=`[${c[`atom/${y}`]}]`),delete c[`atom/${y}`]),h=()=>{if(h=r,le){le=!1;try{s(a in c?fe(c[a]):e)}catch{console.warn("Invalid json value",c[a])}}return r()},S=n=>{if(n===e){this.reset();return}c[a]=X(n)},this.reset=()=>{delete c[a],b(e,!0)},H&&L[a]!==void 0&&console.warn("Duplicate Atom key",y),J)if(Q){let n=!1,u;R[a]=this,L[a]=()=>{clearTimeout(u),u=setTimeout(()=>n=!1,10),!n&&(n=!0,c[a]=X(r()))}}else L[a]=n=>{if(n.newValue===null){this.reset();return}try{b(fe(n.newValue))}catch{console.warn("Invalid json value",n.newValue)}};return w}}let B;try{B=new BroadcastChannel("updateHere"),B.addEventListener("message",t=>{var e;(e=R[t.data.key])==null||e.set(t.data.value,!0)})}catch{}const c=localStorage,L={},R={},De=(t,e)=>{throw`${e} is readonly property`};window.addEventListener("storage",t=>{var e;t.key===null||t.newValue===t.oldValue||(e=L[t.key])==null||e.call(L,t)});const xe=c.setItem.bind(c),$e=c.removeItem.bind(c);c.setItem=(t,e)=>{R[t]===void 0&&xe.call(c,t,e)},c.removeItem=t=>{R[t]===void 0&&$e.call(c,t)};const Me=/"exp":\s*(\d+)/,P="atom\\",F="atom`s\\",W={},oe={},ce=/[a-z]/gi,N=5,G={};for(let t=54;t<80;t++){if(t===68||t===72||t===55)continue;const e=String.fromCharCode(t+43).toUpperCase(),i=String.fromCharCode(t+43).toLowerCase();G[e]=i,G[i]=e}const ae=t=>G[t]??t,C=(()=>{const t=[e=>JSON.stringify(e),e=>btoa(encodeURI(t[0](e))),e=>{const i=t[1](e);return`${i.slice(0,N)}${i.slice(N).replace(ce,ae)}`},e=>btoa(t[2](e))];return(e,i)=>{try{return t[i](e)}catch(s){if(i===0)throw s;return t[0](e)}}})(),U=(()=>{const t=[e=>JSON.parse(e),e=>t[0](decodeURI(atob(e))),e=>t[1](`${e.slice(0,N)}${e.slice(N).replace(ce,ae)}`),e=>t[2](atob(e))];return(e,i)=>{try{return t[i](e)}catch(s){if(i===0)throw s;return t[0](e)}}})();setTimeout(()=>{Object.keys(c).forEach(t=>{var s;if(typeof c[t]!="string"||!t.startsWith(P)&&!t.startsWith(F))return;const e=+((s=c[t].match(Me))==null?void 0:s[1]);if(!e||e*1e3-Date.now()>24*60*60*1e3)return;const i=U(c[t],0);!Array.isArray(i)||i[1]==null||!("exp"in i[1])||i[1].exp!==e||(oe[t]=setTimeout(()=>{W[t]?W[t].reset():delete c[t]},e*1e3-Date.now()))})},1e3),f.Atom=ie,f.AtomArrayDoActions=k,f.AtomBooleanDoActions=O,f.AtomMapDoActions=ee,f.AtomNumberDoActions=te,f.AtomObjectDoActions=se,f.AtomSetDoActions=re,f.atom=we,f.configureAtomaric=de,f.configuredOptions=$,f.useAtom=pe,f.useAtomDo=me,f.useAtomGet=Ae,f.useAtomSet=Z,f.useAtomSetDeferred=ge,f.useAtomValue=Y,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "atomaric",
3
3
  "description": "Manage your project state",
4
- "version": "0.0.73",
4
+ "version": "0.0.75",
5
5
  "type": "module",
6
6
  "main": "./build/atomaric.umd.cjs",
7
7
  "module": "./build/atomaric.js",