Socket
Socket
Sign inDemoInstall

jotai

Package Overview
Dependencies
Maintainers
2
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jotai - npm Package Compare versions

Comparing version 2.8.2 to 2.8.3

13

experimental.js

@@ -192,2 +192,6 @@ 'use strict';

var atomStateMap = new WeakMap();
var debugMountedAtoms;
if (process.env.NODE_ENV !== 'production') {
debugMountedAtoms = new Set();
}
var getAtomState = function getAtomState(atom) {

@@ -488,2 +492,5 @@ var atomState = atomStateMap.get(atom);

};
if (process.env.NODE_ENV !== 'production') {
debugMountedAtoms.add(atom);
}
if (isActuallyWritableAtom(atom) && atom.onMount) {

@@ -517,2 +524,5 @@ var mounted = atomState.m;

delete atomState.m;
if (process.env.NODE_ENV !== 'production') {
debugMountedAtoms.delete(atom);
}
for (var _iterator8 = _createForOfIteratorHelperLoose(atomState.d.keys()), _step8; !(_step8 = _iterator8()).done;) {

@@ -552,2 +562,5 @@ var a = _step8.value;

},
dev4_get_mounted_atoms: function dev4_get_mounted_atoms() {
return debugMountedAtoms;
},
dev4_restore_atoms: function dev4_restore_atoms(values) {

@@ -554,0 +567,0 @@ var pending = createPending();

2

package.json

@@ -6,3 +6,3 @@ {

"type": "commonjs",
"version": "2.8.2",
"version": "2.8.3",
"main": "./index.js",

@@ -9,0 +9,0 @@ "types": "./index.d.ts",

@@ -149,2 +149,6 @@ System.register([], (function (exports) {

const atomStateMap = /* @__PURE__ */ new WeakMap();
let debugMountedAtoms;
{
debugMountedAtoms = /* @__PURE__ */ new Set();
}
const getAtomState = (atom) => {

@@ -428,2 +432,5 @@ let atomState = atomStateMap.get(atom);

};
{
debugMountedAtoms.add(atom);
}
if (isActuallyWritableAtom(atom) && atom.onMount) {

@@ -452,2 +459,5 @@ const mounted = atomState.m;

delete atomState.m;
{
debugMountedAtoms.delete(atom);
}
for (const a of atomState.d.keys()) {

@@ -486,2 +496,3 @@ const aMounted = unmountAtom(pending, a);

dev4_get_internal_weak_map: () => atomStateMap,
dev4_get_mounted_atoms: () => debugMountedAtoms,
dev4_restore_atoms: (values) => {

@@ -488,0 +499,0 @@ const pending = createPending();

@@ -1,1 +0,1 @@

System.register([],function(_){"use strict";return{execute:function(){_("atom",P);let N=0;function P(t,s){const d=`atom${++N}`,m={toString:()=>d};return typeof t=="function"?m.read=t:(m.init=t,m.read=R,m.write=T),s&&(m.write=s),m}function R(t){return t(this)}function T(t,s,d){return s(this,typeof d=="function"?d(t(this)):d)}const B=(t,s)=>t.unstable_is?t.unstable_is(s):s===t,F=t=>"init"in t,G=t=>!!t.write,M=Symbol(""),C="pending",U="fulfilled",$="rejected",x=t=>typeof t=="object"&&t!==null&&M in t,D=new WeakMap,K=(t,s,d)=>{if(!D.has(t)){let m;const w=new Promise((j,q)=>{let g=t;const z=v=>p=>{g===v&&(w.status=U,w.value=p,j(p),d())},b=v=>p=>{g===v&&(w.status=$,w.reason=p,q(p),d())};t.then(z(t),b(t)),m=(v,p)=>{v&&(D.set(v,w),g=v,v.then(z(v),b(v))),s(),s=p}});w.status=C,w[M]=m,D.set(t,w)}return D.get(t)},Q=t=>typeof(t==null?void 0:t.then)=="function",H=t=>"v"in t||"e"in t,O=t=>{if("e"in t)throw t.e;return t.v},W=t=>{const s=t.v;return x(s)&&s.status===C?s:null},I=(t,s,d)=>{d.p.has(t)||(d.p.add(t),s.then(()=>{d.p.delete(t)},()=>{d.p.delete(t)}))},E=()=>[new Map,new Map,new Set],J=(t,s,d)=>{t[0].has(s)||t[0].set(s,new Set),t[1].set(s,d)},X=(t,s,d)=>{const m=t[0].get(s);m&&m.add(d)},Y=(t,s)=>t[0].get(s),L=(t,s)=>{t[2].add(s)},y=t=>{for(;t[1].size||t[2].size;){t[0].clear();const s=new Set(t[1].values());t[1].clear();const d=new Set(t[2]);t[2].clear(),s.forEach(m=>{var w;return(w=m.m)==null?void 0:w.l.forEach(j=>j())}),d.forEach(m=>m())}},Z=_("createStore",()=>{const t=new WeakMap,s=r=>{let e=t.get(r);return e||(e={d:new Map,p:new Set,n:0},t.set(r,e)),e},d=(r,e,n,o=()=>{},u=()=>{})=>{const l="v"in e,a=e.v,h=W(e);if(Q(n))if(h)h!==n&&(h[M](n,o),++e.n);else{const i=K(n,o,u);if(i.status===C)for(const c of e.d.keys()){const f=s(c);I(r,i,f)}e.v=i,delete e.e}else h&&h[M](Promise.resolve(n),o),e.v=n,delete e.e;(!l||!Object.is(a,e.v))&&++e.n},m=(r,e,n,o)=>{var u;const l=s(e);l.d.set(n,o.n);const a=W(l);a&&I(e,a,o),(u=o.m)==null||u.t.add(e),r&&X(r,n,e)},w=(r,e,n)=>{const o=s(e);if(!(n!=null&&n(e))&&H(o)&&(o.m||Array.from(o.d).every(([c,f])=>w(r,c,n).n===f)))return o;o.d.clear();let u=!0;const l=c=>{if(B(e,c)){const S=s(c);if(!H(S))if(F(c))d(c,S,c.init);else throw new Error("no atom init");return O(S)}const f=w(r,c,n);if(u)m(r,e,c,f);else{const S=E();m(S,e,c,f),b(S,e,o),y(S)}return O(f)};let a,h;const i={get signal(){return a||(a=new AbortController),a.signal},get setSelf(){return!h&&G(e)&&(h=(...c)=>{if(!u)return z(e,...c)}),h}};try{const c=e.read(l,i);return d(e,o,c,()=>a==null?void 0:a.abort(),()=>{if(o.m){const f=E();b(f,e,o),y(f)}}),o}catch(c){return delete o.v,o.e=c,++o.n,o}finally{u=!1}},j=r=>O(w(void 0,r)),q=(r,e)=>{const n=i=>{var c,f;const S=s(i),k=new Set((c=S.m)==null?void 0:c.t);for(const A of S.p)k.add(A);return(f=Y(r,i))==null||f.forEach(A=>{k.add(A)}),k},o=[],u=new Set,l=i=>{if(!u.has(i)){u.add(i);for(const c of n(i))i!==c&&l(c);o.push(i)}};l(e);const a=new Set([e]),h=i=>u.has(i);for(let i=o.length-1;i>=0;--i){const c=o[i],f=s(c),S=f.n;let k=!1;for(const A of f.d.keys())if(A!==c&&a.has(A)){k=!0;break}k&&(w(r,c,h),b(r,c,f),S!==f.n&&(J(r,c,f),a.add(c))),u.delete(c)}},g=(r,e,...n)=>{const o=l=>O(w(r,l)),u=(l,...a)=>{let h;if(B(e,l)){if(!F(l))throw new Error("atom not writable");const i=s(l),c="v"in i,f=i.v,S=a[0];d(l,i,S),b(r,l,i),(!c||!Object.is(f,i.v))&&(J(r,l,i),q(r,l))}else h=g(r,l,...a);return y(r),h};return e.write(o,u,...n)},z=(r,...e)=>{const n=E(),o=g(n,r,...e);return y(n),o},b=(r,e,n)=>{if(n.m&&!W(n)){for(const o of n.d.keys())n.m.d.has(o)||(v(r,o).t.add(e),n.m.d.add(o));for(const o of n.m.d||[])if(!n.d.has(o)){const u=p(r,o);u==null||u.t.delete(e),n.m.d.delete(o)}}},v=(r,e)=>{const n=s(e);if(!n.m){w(r,e);for(const o of n.d.keys())v(r,o).t.add(e);if(n.m={l:new Set,d:new Set(n.d.keys()),t:new Set},G(e)&&e.onMount){const o=n.m,{onMount:u}=e;L(r,()=>{const l=u((...a)=>g(r,e,...a));l&&(o.u=l)})}}return n.m},p=(r,e)=>{const n=s(e);if(n.m&&!n.m.l.size&&!Array.from(n.m.t).some(o=>s(o).m)){const o=n.m.u;o&&L(r,o),delete n.m;for(const l of n.d.keys()){const a=p(r,l);a==null||a.t.delete(e)}const u=W(n);u&&u[M](void 0,()=>{});return}return n.m};return{get:j,set:z,sub:(r,e)=>{const n=E(),o=v(n,r);y(n);const u=o.l;return u.add(e),()=>{u.delete(e);const l=E();p(l,r),y(l)}}}});let V;const tt=_("getDefaultStore",()=>(V||(V=Z()),V))}}});
System.register([],function(_){"use strict";return{execute:function(){_("atom",N);let L=0;function N(t,s){const f=`atom${++L}`,m={toString:()=>f};return typeof t=="function"?m.read=t:(m.init=t,m.read=P,m.write=R),s&&(m.write=s),m}function P(t){return t(this)}function R(t,s,f){return s(this,typeof f=="function"?f(t(this)):f)}const B=(t,s)=>t.unstable_is?t.unstable_is(s):s===t,F=t=>"init"in t,G=t=>!!t.write,M=Symbol(""),C="pending",T="fulfilled",U="rejected",$=t=>typeof t=="object"&&t!==null&&M in t,D=new WeakMap,x=(t,s,f)=>{if(!D.has(t)){let m;const w=new Promise((j,q)=>{let y=t;const z=v=>p=>{y===v&&(w.status=T,w.value=p,j(p),f())},g=v=>p=>{y===v&&(w.status=U,w.reason=p,q(p),f())};t.then(z(t),g(t)),m=(v,p)=>{v&&(D.set(v,w),y=v,v.then(z(v),g(v))),s(),s=p}});w.status=C,w[M]=m,D.set(t,w)}return D.get(t)},Q=t=>typeof(t==null?void 0:t.then)=="function",H=t=>"v"in t||"e"in t,O=t=>{if("e"in t)throw t.e;return t.v},W=t=>{const s=t.v;return $(s)&&s.status===C?s:null},I=(t,s,f)=>{f.p.has(t)||(f.p.add(t),s.then(()=>{f.p.delete(t)},()=>{f.p.delete(t)}))},E=()=>[new Map,new Map,new Set],J=(t,s,f)=>{t[0].has(s)||t[0].set(s,new Set),t[1].set(s,f)},X=(t,s,f)=>{const m=t[0].get(s);m&&m.add(f)},Y=(t,s)=>t[0].get(s),K=(t,s)=>{t[2].add(s)},b=t=>{for(;t[1].size||t[2].size;){t[0].clear();const s=new Set(t[1].values());t[1].clear();const f=new Set(t[2]);t[2].clear(),s.forEach(m=>{var w;return(w=m.m)==null?void 0:w.l.forEach(j=>j())}),f.forEach(m=>m())}},Z=_("createStore",()=>{const t=new WeakMap,s=r=>{let e=t.get(r);return e||(e={d:new Map,p:new Set,n:0},t.set(r,e)),e},f=(r,e,n,o=()=>{},i=()=>{})=>{const a="v"in e,u=e.v,h=W(e);if(Q(n))if(h)h!==n&&(h[M](n,o),++e.n);else{const l=x(n,o,i);if(l.status===C)for(const c of e.d.keys()){const d=s(c);I(r,l,d)}e.v=l,delete e.e}else h&&h[M](Promise.resolve(n),o),e.v=n,delete e.e;(!a||!Object.is(u,e.v))&&++e.n},m=(r,e,n,o)=>{var i;const a=s(e);a.d.set(n,o.n);const u=W(a);u&&I(e,u,o),(i=o.m)==null||i.t.add(e),r&&X(r,n,e)},w=(r,e,n)=>{const o=s(e);if(!(n!=null&&n(e))&&H(o)&&(o.m||Array.from(o.d).every(([c,d])=>w(r,c,n).n===d)))return o;o.d.clear();let i=!0;const a=c=>{if(B(e,c)){const S=s(c);if(!H(S))if(F(c))f(c,S,c.init);else throw new Error("no atom init");return O(S)}const d=w(r,c,n);if(i)m(r,e,c,d);else{const S=E();m(S,e,c,d),g(S,e,o),b(S)}return O(d)};let u,h;const l={get signal(){return u||(u=new AbortController),u.signal},get setSelf(){return!h&&G(e)&&(h=(...c)=>{if(!i)return z(e,...c)}),h}};try{const c=e.read(a,l);return f(e,o,c,()=>u==null?void 0:u.abort(),()=>{if(o.m){const d=E();g(d,e,o),b(d)}}),o}catch(c){return delete o.v,o.e=c,++o.n,o}finally{i=!1}},j=r=>O(w(void 0,r)),q=(r,e)=>{const n=l=>{var c,d;const S=s(l),k=new Set((c=S.m)==null?void 0:c.t);for(const A of S.p)k.add(A);return(d=Y(r,l))==null||d.forEach(A=>{k.add(A)}),k},o=[],i=new Set,a=l=>{if(!i.has(l)){i.add(l);for(const c of n(l))l!==c&&a(c);o.push(l)}};a(e);const u=new Set([e]),h=l=>i.has(l);for(let l=o.length-1;l>=0;--l){const c=o[l],d=s(c),S=d.n;let k=!1;for(const A of d.d.keys())if(A!==c&&u.has(A)){k=!0;break}k&&(w(r,c,h),g(r,c,d),S!==d.n&&(J(r,c,d),u.add(c))),i.delete(c)}},y=(r,e,...n)=>{const o=a=>O(w(r,a)),i=(a,...u)=>{let h;if(B(e,a)){if(!F(a))throw new Error("atom not writable");const l=s(a),c="v"in l,d=l.v,S=u[0];f(a,l,S),g(r,a,l),(!c||!Object.is(d,l.v))&&(J(r,a,l),q(r,a))}else h=y(r,a,...u);return b(r),h};return e.write(o,i,...n)},z=(r,...e)=>{const n=E(),o=y(n,r,...e);return b(n),o},g=(r,e,n)=>{if(n.m&&!W(n)){for(const o of n.d.keys())n.m.d.has(o)||(v(r,o).t.add(e),n.m.d.add(o));for(const o of n.m.d||[])if(!n.d.has(o)){const i=p(r,o);i==null||i.t.delete(e),n.m.d.delete(o)}}},v=(r,e)=>{const n=s(e);if(!n.m){w(r,e);for(const o of n.d.keys())v(r,o).t.add(e);if(n.m={l:new Set,d:new Set(n.d.keys()),t:new Set},G(e)&&e.onMount){const o=n.m,{onMount:i}=e;K(r,()=>{const a=i((...u)=>y(r,e,...u));a&&(o.u=a)})}}return n.m},p=(r,e)=>{const n=s(e);if(n.m&&!n.m.l.size&&!Array.from(n.m.t).some(o=>s(o).m)){const o=n.m.u;o&&K(r,o),delete n.m;for(const a of n.d.keys()){const u=p(r,a);u==null||u.t.delete(e)}const i=W(n);i&&i[M](void 0,()=>{});return}return n.m};return{get:j,set:z,sub:(r,e)=>{const n=E(),o=v(n,r);b(n);const i=o.l;return i.add(e),()=>{i.delete(e);const a=E();p(a,r),b(a)}}}});let V;const tt=_("getDefaultStore",()=>(V||(V=Z()),V))}}});

@@ -426,5 +426,13 @@ System.register(['jotai/vanilla'], (function (exports) {

});
let subscriber = (_a = getStringStorage()) == null ? void 0 : _a.subscribe;
if (!subscriber && typeof window !== "undefined" && typeof window.addEventListener === "function" && window.Storage && getStringStorage() instanceof window.Storage) {
let subscriber;
try {
subscriber = (_a = getStringStorage()) == null ? void 0 : _a.subscribe;
} catch (e) {
}
if (!subscriber && typeof window !== "undefined" && typeof window.addEventListener === "function" && window.Storage) {
subscriber = (key, callback) => {
if (!(getStringStorage() instanceof window.Storage)) {
return () => {
};
}
const storageEventCallback = (e) => {

@@ -431,0 +439,0 @@ if (e.storageArea === getStringStorage() && e.key === key) {

@@ -1,1 +0,1 @@

System.register(["jotai/vanilla"],function(x){"use strict";var d;return{setters:[function(k){d=k.atom}],execute:function(){x({atomFamily:_,atomWithDefault:X,atomWithLazy:ft,atomWithObservable:et,atomWithReducer:$,atomWithRefresh:lt,atomWithReset:J,atomWithStorage:tt,createJSONStorage:D,freezeAtom:A,freezeAtomCreator:q,loadable:ot,selectAtom:K,splitAtom:U,unstable_withStorageValidator:Y,unwrap:ct});const k=x("RESET",Symbol(""));function J(t){const n=d(t,(r,u,a)=>{const s=typeof a=="function"?a(r(n)):a;u(n,s===k?t:s)});return n}function $(t,n){return d(t,function(r,u,a){u(this,n(r(this),a))})}function _(t,n){let r=null;const u=new Map,a=s=>{let e;if(n===void 0)e=u.get(s);else for(const[c,o]of u)if(n(c,s)){e=o;break}if(e!==void 0)if(r!=null&&r(e[1],s))a.remove(s);else return e[0];const i=t(s);return u.set(s,[i,Date.now()]),i};return a.remove=s=>{if(n===void 0)u.delete(s);else for(const[e]of u)if(n(e,s)){u.delete(e);break}},a.setShouldRemove=s=>{if(r=s,!!r)for(const[e,i]of u)r(i[1],e)&&u.delete(e)},a}const I=(t,n,r)=>(n.has(r)?n:n.set(r,t())).get(r),C=new WeakMap,F=(t,n,r,u)=>{const a=I(()=>new WeakMap,C,n),s=I(()=>new WeakMap,a,r);return I(t,s,u)};function K(t,n,r=Object.is){return F(()=>{const u=Symbol(),a=([e,i])=>{if(i===u)return n(e);const c=n(e,i);return r(i,c)?i:c},s=d(e=>{const i=e(s),c=e(t);return a([c,i])});return s.init=u,s},t,n,r)}const j=new WeakSet,M=t=>{if(typeof t!="object"||t===null)return;Object.freeze(t);const n=Object.getOwnPropertyNames(t);for(const r of n){const u=t[r];M(u)}return t};function A(t){if(j.has(t))return t;j.add(t);const n=t.read;if(t.read=function(r,u){return M(n.call(this,r,u))},"write"in t){const r=t.write;t.write=function(u,a,...s){return r.call(this,u,(...e)=>(e[0]===t&&(e[1]=M(e[1])),a(...e)),...s)}}return t}function q(t){return(...n)=>A(t(...n))}const R=(t,n,r)=>(n.has(r)?n:n.set(r,t())).get(r),B=new WeakMap,G=(t,n,r)=>{const u=R(()=>new WeakMap,B,n);return R(t,u,r)},H={},P=t=>!!t.write,Q=t=>typeof t=="function";function U(t,n){return G(()=>{const r=new WeakMap,u=(e,i)=>{let c=r.get(e);if(c)return c;const o=i&&r.get(i),l=[],f=[];return e.forEach((b,h)=>{const m=n?n(b):h;f[h]=m;const p=o&&o.atomList[o.keyList.indexOf(m)];if(p){l[h]=p;return}const O=g=>{const v=g(a),y=g(t),S=u(y,v==null?void 0:v.arr).keyList.indexOf(m);if(S<0||S>=y.length){const w=e[u(e).keyList.indexOf(m)];if(w)return w;throw new Error("splitAtom: index out of bounds for read")}return y[S]},L=(g,v,y)=>{const S=g(a),w=g(t),W=u(w,S==null?void 0:S.arr).keyList.indexOf(m);if(W<0||W>=w.length)throw new Error("splitAtom: index out of bounds for write");const V=Q(y)?y(w[W]):y;Object.is(w[W],V)||v(t,[...w.slice(0,W),V,...w.slice(W+1)])};l[h]=P(t)?d(O,L):d(O)}),o&&o.keyList.length===f.length&&o.keyList.every((b,h)=>b===f[h])?c=o:c={arr:e,atomList:l,keyList:f},r.set(e,c),c},a=d(e=>{const i=e(a),c=e(t);return u(c,i==null?void 0:i.arr)});a.init=void 0;const s=P(t)?d(e=>e(a).atomList,(e,i,c)=>{switch(c.type){case"remove":{const o=e(s).indexOf(c.atom);if(o>=0){const l=e(t);i(t,[...l.slice(0,o),...l.slice(o+1)])}break}case"insert":{const o=c.before?e(s).indexOf(c.before):e(s).length;if(o>=0){const l=e(t);i(t,[...l.slice(0,o),c.value,...l.slice(o)])}break}case"move":{const o=e(s).indexOf(c.atom),l=c.before?e(s).indexOf(c.before):e(s).length;if(o>=0&&l>=0){const f=e(t);o<l?i(t,[...f.slice(0,o),...f.slice(o+1,l),f[o],...f.slice(l)]):i(t,[...f.slice(0,l),f[o],...f.slice(l,o),...f.slice(o+1)])}break}}}):d(e=>e(a).atomList);return s},t,n||H)}function X(t){const n=Symbol(),r=d(n),u=d((a,s)=>{const e=a(r);return e!==n?e:t(a,s)},(a,s,e)=>{if(e===k)s(r,n);else if(typeof e=="function"){const i=a(u);s(r,e(i))}else s(r,e)});return u}const z=t=>typeof(t==null?void 0:t.then)=="function";function Y(t){return n=>({...n,getItem:(r,u)=>{const a=e=>t(e)?e:u,s=n.getItem(r,u);return z(s)?s.then(a):a(s)}})}function D(t=()=>{try{return window.localStorage}catch(r){return}},n){var r;let u,a;const s={getItem:(c,o)=>{var l,f;const b=m=>{if(m=m||"",u!==m){try{a=JSON.parse(m,n==null?void 0:n.reviver)}catch(p){return o}u=m}return a},h=(f=(l=t())==null?void 0:l.getItem(c))!=null?f:null;return z(h)?h.then(b):b(h)},setItem:(c,o)=>{var l;return(l=t())==null?void 0:l.setItem(c,JSON.stringify(o,n==null?void 0:n.replacer))},removeItem:c=>{var o;return(o=t())==null?void 0:o.removeItem(c)}},e=c=>(o,l,f)=>c(o,b=>{let h;try{h=JSON.parse(b||"")}catch(m){h=f}l(h)});let i=(r=t())==null?void 0:r.subscribe;return!i&&typeof window!="undefined"&&typeof window.addEventListener=="function"&&window.Storage&&t()instanceof window.Storage&&(i=(c,o)=>{const l=f=>{f.storageArea===t()&&f.key===c&&o(f.newValue)};return window.addEventListener("storage",l),()=>{window.removeEventListener("storage",l)}}),i&&(s.subscribe=e(i)),s}const Z=D();function tt(t,n,r=Z,u){const a=u==null?void 0:u.getOnInit,s=d(a?r.getItem(t,n):n);return s.onMount=e=>{e(r.getItem(t,n));let i;return r.subscribe&&(i=r.subscribe(t,e,n)),i},d(e=>e(s),(e,i,c)=>{const o=typeof c=="function"?c(e(s)):c;return o===k?(i(s,n),r.removeItem(t)):o instanceof Promise?o.then(l=>(i(s,l),r.setItem(t,l))):(i(s,o),r.setItem(t,o))})}function et(t,n){const r=a=>{if("e"in a)throw a.e;return a.d},u=d(a=>{var s;let e=t(a);const i=(s=e[Symbol.observable])==null?void 0:s.call(e);i&&(e=i);let c;const o=()=>new Promise(v=>{c=v}),l=n&&"initialValue"in n?{d:typeof n.initialValue=="function"?n.initialValue():n.initialValue}:o();let f,b;const h=v=>{b=v,c==null||c(v),f==null||f(v)};let m,p;const O=()=>!f,L=()=>{m&&(clearTimeout(p),m.unsubscribe()),m=e.subscribe({next:v=>h({d:v}),error:v=>h({e:v}),complete:()=>{}}),O()&&n!=null&&n.unstable_timeout&&(p=setTimeout(()=>{m&&(m.unsubscribe(),m=void 0)},n.unstable_timeout))};L();const g=d(b||l);return g.onMount=v=>(f=v,b&&v(b),m?clearTimeout(p):L(),()=>{f=void 0,m&&(m.unsubscribe(),m=void 0)}),[g,e,o,L,O]});return d(a=>{const[s]=a(u),e=a(s);return e instanceof Promise?e.then(r):r(e)},(a,s,e)=>{const[i,c,o,l,f]=a(u);if("next"in c)f()&&(s(i,o()),l()),c.next(e);else throw new Error("observable is not subject")})}const E=new WeakMap,nt=(t,n)=>(E.has(n)?E:E.set(n,t())).get(n),rt=t=>t instanceof Promise,N={state:"loading"};function ot(t){return nt(()=>{const n=new WeakMap,r=d(0),u=d((a,{setSelf:s})=>{a(r);let e;try{e=a(t)}catch(l){return{state:"hasError",error:l}}if(!rt(e))return{state:"hasData",data:e};const i=e,c=n.get(i);return c||(i.status==="fulfilled"?n.set(i,{state:"hasData",data:i.value}):i.status==="rejected"?n.set(i,{state:"hasError",error:i.reason}):i.then(l=>{n.set(i,{state:"hasData",data:l})},l=>{n.set(i,{state:"hasError",error:l})}).finally(s),n.get(i)||(n.set(i,N),N))},(a,s)=>{s(r,e=>e+1)});return d(a=>a(u))},t)}const T=(t,n,r)=>(n.has(r)?n:n.set(r,t())).get(r),st=new WeakMap,it=(t,n,r)=>{const u=T(()=>new WeakMap,st,n);return T(t,u,r)},at=t=>t instanceof Promise,ut=()=>{};function ct(t,n=ut){return it(()=>{const r=new WeakMap,u=new WeakMap,a=d(0),s=d((e,{setSelf:i})=>{e(a);const c=e(s),o=e(t);if(!at(o))return{v:o};if(o!==(c==null?void 0:c.p)&&(o.status==="fulfilled"?u.set(o,o.value):o.status==="rejected"?r.set(o,o.reason):o.then(l=>u.set(o,l),l=>r.set(o,l)).finally(i)),r.has(o))throw r.get(o);return u.has(o)?{p:o,v:u.get(o)}:c&&"v"in c?{p:o,f:n(c.v),v:c.v}:{p:o,f:n()}},(e,i)=>{i(a,c=>c+1)});return s.init=void 0,d(e=>{const i=e(s);return"f"in i?i.f:i.v},(e,i,...c)=>i(t,...c))},t,n)}function lt(t,n){const r=d(0);return d((u,a)=>(u(r),t(u,a)),(u,a,...s)=>{if(s.length===0)a(r,e=>e+1);else if(n)return n(u,a,...s)})}function ft(t){const n=d(void 0);return delete n.init,Object.defineProperty(n,"init",{get(){return t()}}),n}}}});
System.register(["jotai/vanilla"],function(x){"use strict";var d;return{setters:[function(k){d=k.atom}],execute:function(){x({atomFamily:_,atomWithDefault:X,atomWithLazy:ft,atomWithObservable:et,atomWithReducer:$,atomWithRefresh:lt,atomWithReset:J,atomWithStorage:tt,createJSONStorage:D,freezeAtom:A,freezeAtomCreator:q,loadable:ot,selectAtom:K,splitAtom:U,unstable_withStorageValidator:Y,unwrap:ct});const k=x("RESET",Symbol(""));function J(t){const n=d(t,(r,c,a)=>{const s=typeof a=="function"?a(r(n)):a;c(n,s===k?t:s)});return n}function $(t,n){return d(t,function(r,c,a){c(this,n(r(this),a))})}function _(t,n){let r=null;const c=new Map,a=s=>{let e;if(n===void 0)e=c.get(s);else for(const[u,o]of c)if(n(u,s)){e=o;break}if(e!==void 0)if(r!=null&&r(e[1],s))a.remove(s);else return e[0];const i=t(s);return c.set(s,[i,Date.now()]),i};return a.remove=s=>{if(n===void 0)c.delete(s);else for(const[e]of c)if(n(e,s)){c.delete(e);break}},a.setShouldRemove=s=>{if(r=s,!!r)for(const[e,i]of c)r(i[1],e)&&c.delete(e)},a}const I=(t,n,r)=>(n.has(r)?n:n.set(r,t())).get(r),C=new WeakMap,F=(t,n,r,c)=>{const a=I(()=>new WeakMap,C,n),s=I(()=>new WeakMap,a,r);return I(t,s,c)};function K(t,n,r=Object.is){return F(()=>{const c=Symbol(),a=([e,i])=>{if(i===c)return n(e);const u=n(e,i);return r(i,u)?i:u},s=d(e=>{const i=e(s),u=e(t);return a([u,i])});return s.init=c,s},t,n,r)}const j=new WeakSet,M=t=>{if(typeof t!="object"||t===null)return;Object.freeze(t);const n=Object.getOwnPropertyNames(t);for(const r of n){const c=t[r];M(c)}return t};function A(t){if(j.has(t))return t;j.add(t);const n=t.read;if(t.read=function(r,c){return M(n.call(this,r,c))},"write"in t){const r=t.write;t.write=function(c,a,...s){return r.call(this,c,(...e)=>(e[0]===t&&(e[1]=M(e[1])),a(...e)),...s)}}return t}function q(t){return(...n)=>A(t(...n))}const R=(t,n,r)=>(n.has(r)?n:n.set(r,t())).get(r),B=new WeakMap,G=(t,n,r)=>{const c=R(()=>new WeakMap,B,n);return R(t,c,r)},H={},P=t=>!!t.write,Q=t=>typeof t=="function";function U(t,n){return G(()=>{const r=new WeakMap,c=(e,i)=>{let u=r.get(e);if(u)return u;const o=i&&r.get(i),l=[],f=[];return e.forEach((b,h)=>{const m=n?n(b):h;f[h]=m;const p=o&&o.atomList[o.keyList.indexOf(m)];if(p){l[h]=p;return}const O=g=>{const v=g(a),y=g(t),S=c(y,v==null?void 0:v.arr).keyList.indexOf(m);if(S<0||S>=y.length){const w=e[c(e).keyList.indexOf(m)];if(w)return w;throw new Error("splitAtom: index out of bounds for read")}return y[S]},L=(g,v,y)=>{const S=g(a),w=g(t),W=c(w,S==null?void 0:S.arr).keyList.indexOf(m);if(W<0||W>=w.length)throw new Error("splitAtom: index out of bounds for write");const V=Q(y)?y(w[W]):y;Object.is(w[W],V)||v(t,[...w.slice(0,W),V,...w.slice(W+1)])};l[h]=P(t)?d(O,L):d(O)}),o&&o.keyList.length===f.length&&o.keyList.every((b,h)=>b===f[h])?u=o:u={arr:e,atomList:l,keyList:f},r.set(e,u),u},a=d(e=>{const i=e(a),u=e(t);return c(u,i==null?void 0:i.arr)});a.init=void 0;const s=P(t)?d(e=>e(a).atomList,(e,i,u)=>{switch(u.type){case"remove":{const o=e(s).indexOf(u.atom);if(o>=0){const l=e(t);i(t,[...l.slice(0,o),...l.slice(o+1)])}break}case"insert":{const o=u.before?e(s).indexOf(u.before):e(s).length;if(o>=0){const l=e(t);i(t,[...l.slice(0,o),u.value,...l.slice(o)])}break}case"move":{const o=e(s).indexOf(u.atom),l=u.before?e(s).indexOf(u.before):e(s).length;if(o>=0&&l>=0){const f=e(t);o<l?i(t,[...f.slice(0,o),...f.slice(o+1,l),f[o],...f.slice(l)]):i(t,[...f.slice(0,l),f[o],...f.slice(l,o),...f.slice(o+1)])}break}}}):d(e=>e(a).atomList);return s},t,n||H)}function X(t){const n=Symbol(),r=d(n),c=d((a,s)=>{const e=a(r);return e!==n?e:t(a,s)},(a,s,e)=>{if(e===k)s(r,n);else if(typeof e=="function"){const i=a(c);s(r,e(i))}else s(r,e)});return c}const z=t=>typeof(t==null?void 0:t.then)=="function";function Y(t){return n=>({...n,getItem:(r,c)=>{const a=e=>t(e)?e:c,s=n.getItem(r,c);return z(s)?s.then(a):a(s)}})}function D(t=()=>{try{return window.localStorage}catch(r){return}},n){var r;let c,a;const s={getItem:(u,o)=>{var l,f;const b=m=>{if(m=m||"",c!==m){try{a=JSON.parse(m,n==null?void 0:n.reviver)}catch(p){return o}c=m}return a},h=(f=(l=t())==null?void 0:l.getItem(u))!=null?f:null;return z(h)?h.then(b):b(h)},setItem:(u,o)=>{var l;return(l=t())==null?void 0:l.setItem(u,JSON.stringify(o,n==null?void 0:n.replacer))},removeItem:u=>{var o;return(o=t())==null?void 0:o.removeItem(u)}},e=u=>(o,l,f)=>u(o,b=>{let h;try{h=JSON.parse(b||"")}catch(m){h=f}l(h)});let i;try{i=(r=t())==null?void 0:r.subscribe}catch(u){}return!i&&typeof window!="undefined"&&typeof window.addEventListener=="function"&&window.Storage&&(i=(u,o)=>{if(!(t()instanceof window.Storage))return()=>{};const l=f=>{f.storageArea===t()&&f.key===u&&o(f.newValue)};return window.addEventListener("storage",l),()=>{window.removeEventListener("storage",l)}}),i&&(s.subscribe=e(i)),s}const Z=D();function tt(t,n,r=Z,c){const a=c==null?void 0:c.getOnInit,s=d(a?r.getItem(t,n):n);return s.onMount=e=>{e(r.getItem(t,n));let i;return r.subscribe&&(i=r.subscribe(t,e,n)),i},d(e=>e(s),(e,i,u)=>{const o=typeof u=="function"?u(e(s)):u;return o===k?(i(s,n),r.removeItem(t)):o instanceof Promise?o.then(l=>(i(s,l),r.setItem(t,l))):(i(s,o),r.setItem(t,o))})}function et(t,n){const r=a=>{if("e"in a)throw a.e;return a.d},c=d(a=>{var s;let e=t(a);const i=(s=e[Symbol.observable])==null?void 0:s.call(e);i&&(e=i);let u;const o=()=>new Promise(v=>{u=v}),l=n&&"initialValue"in n?{d:typeof n.initialValue=="function"?n.initialValue():n.initialValue}:o();let f,b;const h=v=>{b=v,u==null||u(v),f==null||f(v)};let m,p;const O=()=>!f,L=()=>{m&&(clearTimeout(p),m.unsubscribe()),m=e.subscribe({next:v=>h({d:v}),error:v=>h({e:v}),complete:()=>{}}),O()&&n!=null&&n.unstable_timeout&&(p=setTimeout(()=>{m&&(m.unsubscribe(),m=void 0)},n.unstable_timeout))};L();const g=d(b||l);return g.onMount=v=>(f=v,b&&v(b),m?clearTimeout(p):L(),()=>{f=void 0,m&&(m.unsubscribe(),m=void 0)}),[g,e,o,L,O]});return d(a=>{const[s]=a(c),e=a(s);return e instanceof Promise?e.then(r):r(e)},(a,s,e)=>{const[i,u,o,l,f]=a(c);if("next"in u)f()&&(s(i,o()),l()),u.next(e);else throw new Error("observable is not subject")})}const E=new WeakMap,nt=(t,n)=>(E.has(n)?E:E.set(n,t())).get(n),rt=t=>t instanceof Promise,N={state:"loading"};function ot(t){return nt(()=>{const n=new WeakMap,r=d(0),c=d((a,{setSelf:s})=>{a(r);let e;try{e=a(t)}catch(l){return{state:"hasError",error:l}}if(!rt(e))return{state:"hasData",data:e};const i=e,u=n.get(i);return u||(i.status==="fulfilled"?n.set(i,{state:"hasData",data:i.value}):i.status==="rejected"?n.set(i,{state:"hasError",error:i.reason}):i.then(l=>{n.set(i,{state:"hasData",data:l})},l=>{n.set(i,{state:"hasError",error:l})}).finally(s),n.get(i)||(n.set(i,N),N))},(a,s)=>{s(r,e=>e+1)});return d(a=>a(c))},t)}const T=(t,n,r)=>(n.has(r)?n:n.set(r,t())).get(r),st=new WeakMap,it=(t,n,r)=>{const c=T(()=>new WeakMap,st,n);return T(t,c,r)},at=t=>t instanceof Promise,ut=()=>{};function ct(t,n=ut){return it(()=>{const r=new WeakMap,c=new WeakMap,a=d(0),s=d((e,{setSelf:i})=>{e(a);const u=e(s),o=e(t);if(!at(o))return{v:o};if(o!==(u==null?void 0:u.p)&&(o.status==="fulfilled"?c.set(o,o.value):o.status==="rejected"?r.set(o,o.reason):o.then(l=>c.set(o,l),l=>r.set(o,l)).finally(i)),r.has(o))throw r.get(o);return c.has(o)?{p:o,v:c.get(o)}:u&&"v"in u?{p:o,f:n(u.v),v:u.v}:{p:o,f:n()}},(e,i)=>{i(a,u=>u+1)});return s.init=void 0,d(e=>{const i=e(s);return"f"in i?i.f:i.v},(e,i,...u)=>i(t,...u))},t,n)}function lt(t,n){const r=d(0);return d((c,a)=>(c(r),t(c,a)),(c,a,...s)=>{if(s.length===0)a(r,e=>e+1);else if(n)return n(c,a,...s)})}function ft(t){const n=d(void 0);return delete n.init,Object.defineProperty(n,"init",{get(){return t()}}),n}}}});

@@ -50,2 +50,3 @@ import type { Atom, WritableAtom } from './atom';

dev4_get_internal_weak_map: () => WeakMap<AnyAtom, AtomState>;
dev4_get_mounted_atoms: () => Set<AnyAtom>;
dev4_restore_atoms: (values: Iterable<readonly [

@@ -52,0 +53,0 @@ AnyAtom,

@@ -50,2 +50,3 @@ import type { Atom, WritableAtom } from './atom';

dev4_get_internal_weak_map: () => WeakMap<AnyAtom, AtomState>;
dev4_get_mounted_atoms: () => Set<AnyAtom>;
dev4_restore_atoms: (values: Iterable<readonly [

@@ -52,0 +53,0 @@ AnyAtom,

@@ -196,2 +196,6 @@ (function (global, factory) {

var atomStateMap = new WeakMap();
var debugMountedAtoms;
{
debugMountedAtoms = new Set();
}
var getAtomState = function getAtomState(atom) {

@@ -492,2 +496,5 @@ var atomState = atomStateMap.get(atom);

};
{
debugMountedAtoms.add(atom);
}
if (isActuallyWritableAtom(atom) && atom.onMount) {

@@ -521,2 +528,5 @@ var mounted = atomState.m;

delete atomState.m;
{
debugMountedAtoms.delete(atom);
}
for (var _iterator8 = _createForOfIteratorHelperLoose(atomState.d.keys()), _step8; !(_step8 = _iterator8()).done;) {

@@ -556,2 +566,5 @@ var a = _step8.value;

},
dev4_get_mounted_atoms: function dev4_get_mounted_atoms() {
return debugMountedAtoms;
},
dev4_restore_atoms: function dev4_restore_atoms(values) {

@@ -558,0 +571,0 @@ var pending = createPending();

@@ -389,3 +389,2 @@ (function (global, factory) {

function createJSONStorage(getStringStorage, options) {
var _getStringStorage4;
if (getStringStorage === void 0) {

@@ -450,5 +449,12 @@ getStringStorage = function getStringStorage() {

};
var subscriber = (_getStringStorage4 = getStringStorage()) == null ? void 0 : _getStringStorage4.subscribe;
if (!subscriber && typeof window !== 'undefined' && typeof window.addEventListener === 'function' && window.Storage && getStringStorage() instanceof window.Storage) {
var subscriber;
try {
var _getStringStorage4;
subscriber = (_getStringStorage4 = getStringStorage()) == null ? void 0 : _getStringStorage4.subscribe;
} catch (_unused3) {}
if (!subscriber && typeof window !== 'undefined' && typeof window.addEventListener === 'function' && window.Storage) {
subscriber = function subscriber(key, callback) {
if (!(getStringStorage() instanceof window.Storage)) {
return function () {};
}
var storageEventCallback = function storageEventCallback(e) {

@@ -455,0 +461,0 @@ if (e.storageArea === getStringStorage() && e.key === key) {

@@ -1,1 +0,1 @@

!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("jotai/vanilla")):"function"==typeof define&&define.amd?define(["exports","jotai/vanilla"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).jotaiVanillaUtils={},t.jotaiVanilla)}(this,(function(t,n){"use strict";var e=Symbol("");function r(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=Array(n);e<n;e++)r[e]=t[e];return r}function o(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return r(t,n);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?r(t,n):void 0}}(t))||n){e&&(t=e);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)({}).hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},i.apply(null,arguments)}var a=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},u=new WeakMap;var f=new WeakSet,c=function t(n){if("object"==typeof n&&null!==n){Object.freeze(n);for(var e,r=o(Object.getOwnPropertyNames(n));!(e=r()).done;){t(n[e.value])}return n}};function l(t){if(f.has(t))return t;f.add(t);var n=t.read;if(t.read=function(t,e){return c(n.call(this,t,e))},"write"in t){var e=t.write;t.write=function(n,r){for(var o=arguments.length,i=new Array(o>2?o-2:0),a=2;a<o;a++)i[a-2]=arguments[a];return e.call.apply(e,[this,n,function(){for(var n=arguments.length,e=new Array(n),o=0;o<n;o++)e[o]=arguments[o];return e[0]===t&&(e[1]=c(e[1])),r.apply(void 0,e)}].concat(i))}}return t}var s=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},v=new WeakMap,d={},m=function(t){return!!t.write};var h=function(t){return"function"==typeof(null==t?void 0:t.then)};function p(t,n){var e,r,o;void 0===t&&(t=function(){try{return window.localStorage}catch(t){return}});var i={getItem:function(e,i){var a,u,f=function(t){if(r!==(t=t||"")){try{o=JSON.parse(t,null==n?void 0:n.reviver)}catch(t){return i}r=t}return o},c=null!=(a=null==(u=t())?void 0:u.getItem(e))?a:null;return h(c)?c.then(f):f(c)},setItem:function(e,r){var o;return null==(o=t())?void 0:o.setItem(e,JSON.stringify(r,null==n?void 0:n.replacer))},removeItem:function(n){var e;return null==(e=t())?void 0:e.removeItem(n)}},a=null==(e=t())?void 0:e.subscribe;return!a&&"undefined"!=typeof window&&"function"==typeof window.addEventListener&&window.Storage&&t()instanceof window.Storage&&(a=function(n,e){var r=function(r){r.storageArea===t()&&r.key===n&&e(r.newValue)};return window.addEventListener("storage",r),function(){window.removeEventListener("storage",r)}}),a&&(i.subscribe=function(t){return function(n,e,r){return t(n,(function(t){var n;try{n=JSON.parse(t||"")}catch(t){n=r}e(n)}))}}(a)),i}var b=p();var y=new WeakMap,w={state:"loading"};var g=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},k=new WeakMap,O=function(){};t.RESET=e,t.atomFamily=function(t,n){var e=null,r=new Map,i=function i(a){var u;if(void 0===n)u=r.get(a);else for(var f,c=o(r);!(f=c()).done;){var l=f.value,s=l[0],v=l[1];if(n(s,a)){u=v;break}}if(void 0!==u){if(null==e||!e(u[1],a))return u[0];i.remove(a)}var d=t(a);return r.set(a,[d,Date.now()]),d};return i.remove=function(t){if(void 0===n)r.delete(t);else for(var e,i=o(r);!(e=i()).done;){var a=e.value[0];if(n(a,t)){r.delete(a);break}}},i.setShouldRemove=function(t){if(e=t)for(var n,i=o(r);!(n=i()).done;){var a=n.value,u=a[0],f=a[1];e(f[1],u)&&r.delete(u)}},i},t.atomWithDefault=function(t){var r=Symbol(),o=n.atom(r),i=n.atom((function(n,e){var i=n(o);return i!==r?i:t(n,e)}),(function(t,n,a){if(a===e)n(o,r);else if("function"==typeof a){var u=t(i);n(o,a(u))}else n(o,a)}));return i},t.atomWithLazy=function(t){var e=n.atom(void 0);return delete e.init,Object.defineProperty(e,"init",{get:function(){return t()}}),e},t.atomWithObservable=function(t,e){var r=function(t){if("e"in t)throw t.e;return t.d},o=n.atom((function(r){var o,i,a,u=t(r),f=null==(o=(i=u)[Symbol.observable])?void 0:o.call(i);f&&(u=f);var c,l,s,v,d=function(){return new Promise((function(t){a=t}))},m=e&&"initialValue"in e?{d:"function"==typeof e.initialValue?e.initialValue():e.initialValue}:d(),h=function(t){l=t,null==a||a(t),null==c||c(t)},p=function(){return!c},b=function(){s&&(clearTimeout(v),s.unsubscribe()),s=u.subscribe({next:function(t){return h({d:t})},error:function(t){return h({e:t})},complete:function(){}}),p()&&null!=e&&e.unstable_timeout&&(v=setTimeout((function(){s&&(s.unsubscribe(),s=void 0)}),e.unstable_timeout))};b();var y=n.atom(l||m);return y.onMount=function(t){return c=t,l&&t(l),s?clearTimeout(v):b(),function(){c=void 0,s&&(s.unsubscribe(),s=void 0)}},[y,u,d,b,p]}));return n.atom((function(t){var n=t(o),e=t(n[0]);return e instanceof Promise?e.then(r):r(e)}),(function(t,n,e){var r=t(o),i=r[0],a=r[1],u=r[2],f=r[3],c=r[4];if(!("next"in a))throw new Error("observable is not subject");c()&&(n(i,u()),f()),a.next(e)}))},t.atomWithReducer=function(t,e){return n.atom(t,(function(t,n,r){n(this,e(t(this),r))}))},t.atomWithRefresh=function(t,e){var r=n.atom(0);return n.atom((function(n,e){return n(r),t(n,e)}),(function(t,n){for(var o=arguments.length,i=new Array(o>2?o-2:0),a=2;a<o;a++)i[a-2]=arguments[a];if(0===i.length)n(r,(function(t){return t+1}));else if(e)return e.apply(void 0,[t,n].concat(i))}))},t.atomWithReset=function(t){var r=n.atom(t,(function(n,o,i){var a="function"==typeof i?i(n(r)):i;o(r,a===e?t:a)}));return r},t.atomWithStorage=function(t,r,o,i){void 0===o&&(o=b);var a=null==i?void 0:i.getOnInit,u=n.atom(a?o.getItem(t,r):r);return u.onMount=function(n){var e;return n(o.getItem(t,r)),o.subscribe&&(e=o.subscribe(t,n,r)),e},n.atom((function(t){return t(u)}),(function(n,i,a){var f="function"==typeof a?a(n(u)):a;return f===e?(i(u,r),o.removeItem(t)):f instanceof Promise?f.then((function(n){return i(u,n),o.setItem(t,n)})):(i(u,f),o.setItem(t,f))}))},t.createJSONStorage=p,t.freezeAtom=l,t.freezeAtomCreator=function(t){return function(){return l(t.apply(void 0,arguments))}},t.loadable=function(t){return e=function(){var e=new WeakMap,r=n.atom(0),o=n.atom((function(n,o){var i,a=o.setSelf;n(r);try{i=n(t)}catch(t){return{state:"hasError",error:t}}if(!(i instanceof Promise))return{state:"hasData",data:i};var u=i,f=e.get(u);if(f)return f;"fulfilled"===u.status?e.set(u,{state:"hasData",data:u.value}):"rejected"===u.status?e.set(u,{state:"hasError",error:u.reason}):u.then((function(t){e.set(u,{state:"hasData",data:t})}),(function(t){e.set(u,{state:"hasError",error:t})})).finally(a);var c=e.get(u);return c||(e.set(u,w),w)}),(function(t,n){n(r,(function(t){return t+1}))}));return n.atom((function(t){return t(o)}))},r=t,(y.has(r)?y:y.set(r,e())).get(r);var e,r},t.selectAtom=function(t,e,r){return void 0===r&&(r=Object.is),o=function(){var o=Symbol(),i=n.atom((function(n){var a=n(i);return function(t){var n=t[0],i=t[1];if(i===o)return e(n);var a=e(n,i);return r(i,a)?i:a}([n(t),a])}));return i.init=o,i},i=e,f=r,c=a((function(){return new WeakMap}),u,t),l=a((function(){return new WeakMap}),c,i),a(o,l,f);var o,i,f,c,l},t.splitAtom=function(t,e){return r=function(){var r=new WeakMap,o=function o(a,u){var f=r.get(a);if(f)return f;var c=u&&r.get(u),l=[],s=[];return a.forEach((function(r,u){var f=e?e(r):u;s[u]=f;var v=c&&c.atomList[c.keyList.indexOf(f)];if(v)l[u]=v;else{var d=function(n){var e=n(i),r=n(t),u=o(r,null==e?void 0:e.arr).keyList.indexOf(f);if(u<0||u>=r.length){var c=a[o(a).keyList.indexOf(f)];if(c)return c;throw new Error("splitAtom: index out of bounds for read")}return r[u]};l[u]=m(t)?n.atom(d,(function(n,e,r){var a=n(i),u=n(t),c=o(u,null==a?void 0:a.arr).keyList.indexOf(f);if(c<0||c>=u.length)throw new Error("splitAtom: index out of bounds for write");var l="function"==typeof r?r(u[c]):r;Object.is(u[c],l)||e(t,[].concat(u.slice(0,c),[l],u.slice(c+1)))})):n.atom(d)}})),f=c&&c.keyList.length===s.length&&c.keyList.every((function(t,n){return t===s[n]}))?c:{arr:a,atomList:l,keyList:s},r.set(a,f),f},i=n.atom((function(n){var e=n(i),r=n(t);return o(r,null==e?void 0:e.arr)}));i.init=void 0;var a=m(t)?n.atom((function(t){return t(i).atomList}),(function(n,e,r){switch(r.type){case"remove":var o=n(a).indexOf(r.atom);if(o>=0){var i=n(t);e(t,[].concat(i.slice(0,o),i.slice(o+1)))}break;case"insert":var u=r.before?n(a).indexOf(r.before):n(a).length;if(u>=0){var f=n(t);e(t,[].concat(f.slice(0,u),[r.value],f.slice(u)))}break;case"move":var c=n(a).indexOf(r.atom),l=r.before?n(a).indexOf(r.before):n(a).length;if(c>=0&&l>=0){var s=n(t);e(t,c<l?[].concat(s.slice(0,c),s.slice(c+1,l),[s[c]],s.slice(l)):[].concat(s.slice(0,l),[s[c]],s.slice(l,c),s.slice(c+1)))}}})):n.atom((function(t){return t(i).atomList}));return a},o=e||d,i=s((function(){return new WeakMap}),v,t),s(r,i,o);var r,o,i},t.unstable_withStorageValidator=function(t){return function(n){return i({},n,{getItem:function(e,r){var o=function(n){return t(n)?n:r},i=n.getItem(e,r);return h(i)?i.then(o):o(i)}})}},t.unwrap=function(t,e){return void 0===e&&(e=O),r=function(){var r=new WeakMap,o=new WeakMap,i=n.atom(0),a=n.atom((function(n,u){var f=u.setSelf;n(i);var c=n(a),l=n(t);if(!(l instanceof Promise))return{v:l};if(l!==(null==c?void 0:c.p)&&("fulfilled"===l.status?o.set(l,l.value):"rejected"===l.status?r.set(l,l.reason):l.then((function(t){return o.set(l,t)}),(function(t){return r.set(l,t)})).finally(f)),r.has(l))throw r.get(l);return o.has(l)?{p:l,v:o.get(l)}:c&&"v"in c?{p:l,f:e(c.v),v:c.v}:{p:l,f:e()}}),(function(t,n){n(i,(function(t){return t+1}))}));return a.init=void 0,n.atom((function(t){var n=t(a);return"f"in n?n.f:n.v}),(function(n,e){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return e.apply(void 0,[t].concat(o))}))},o=e,i=g((function(){return new WeakMap}),k,t),g(r,i,o);var r,o,i}}));
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("jotai/vanilla")):"function"==typeof define&&define.amd?define(["exports","jotai/vanilla"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).jotaiVanillaUtils={},t.jotaiVanilla)}(this,(function(t,n){"use strict";var e=Symbol("");function r(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=Array(n);e<n;e++)r[e]=t[e];return r}function o(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return r(t,n);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?r(t,n):void 0}}(t))||n){e&&(t=e);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)({}).hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},i.apply(null,arguments)}var a=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},u=new WeakMap;var f=new WeakSet,c=function t(n){if("object"==typeof n&&null!==n){Object.freeze(n);for(var e,r=o(Object.getOwnPropertyNames(n));!(e=r()).done;){t(n[e.value])}return n}};function l(t){if(f.has(t))return t;f.add(t);var n=t.read;if(t.read=function(t,e){return c(n.call(this,t,e))},"write"in t){var e=t.write;t.write=function(n,r){for(var o=arguments.length,i=new Array(o>2?o-2:0),a=2;a<o;a++)i[a-2]=arguments[a];return e.call.apply(e,[this,n,function(){for(var n=arguments.length,e=new Array(n),o=0;o<n;o++)e[o]=arguments[o];return e[0]===t&&(e[1]=c(e[1])),r.apply(void 0,e)}].concat(i))}}return t}var s=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},v=new WeakMap,d={},m=function(t){return!!t.write};var h=function(t){return"function"==typeof(null==t?void 0:t.then)};function p(t,n){var e,r;void 0===t&&(t=function(){try{return window.localStorage}catch(t){return}});var o,i={getItem:function(o,i){var a,u,f=function(t){if(e!==(t=t||"")){try{r=JSON.parse(t,null==n?void 0:n.reviver)}catch(t){return i}e=t}return r},c=null!=(a=null==(u=t())?void 0:u.getItem(o))?a:null;return h(c)?c.then(f):f(c)},setItem:function(e,r){var o;return null==(o=t())?void 0:o.setItem(e,JSON.stringify(r,null==n?void 0:n.replacer))},removeItem:function(n){var e;return null==(e=t())?void 0:e.removeItem(n)}};try{var a;o=null==(a=t())?void 0:a.subscribe}catch(t){}return!o&&"undefined"!=typeof window&&"function"==typeof window.addEventListener&&window.Storage&&(o=function(n,e){if(!(t()instanceof window.Storage))return function(){};var r=function(r){r.storageArea===t()&&r.key===n&&e(r.newValue)};return window.addEventListener("storage",r),function(){window.removeEventListener("storage",r)}}),o&&(i.subscribe=function(t){return function(n,e,r){return t(n,(function(t){var n;try{n=JSON.parse(t||"")}catch(t){n=r}e(n)}))}}(o)),i}var b=p();var y=new WeakMap,w={state:"loading"};var g=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},k=new WeakMap,O=function(){};t.RESET=e,t.atomFamily=function(t,n){var e=null,r=new Map,i=function i(a){var u;if(void 0===n)u=r.get(a);else for(var f,c=o(r);!(f=c()).done;){var l=f.value,s=l[0],v=l[1];if(n(s,a)){u=v;break}}if(void 0!==u){if(null==e||!e(u[1],a))return u[0];i.remove(a)}var d=t(a);return r.set(a,[d,Date.now()]),d};return i.remove=function(t){if(void 0===n)r.delete(t);else for(var e,i=o(r);!(e=i()).done;){var a=e.value[0];if(n(a,t)){r.delete(a);break}}},i.setShouldRemove=function(t){if(e=t)for(var n,i=o(r);!(n=i()).done;){var a=n.value,u=a[0],f=a[1];e(f[1],u)&&r.delete(u)}},i},t.atomWithDefault=function(t){var r=Symbol(),o=n.atom(r),i=n.atom((function(n,e){var i=n(o);return i!==r?i:t(n,e)}),(function(t,n,a){if(a===e)n(o,r);else if("function"==typeof a){var u=t(i);n(o,a(u))}else n(o,a)}));return i},t.atomWithLazy=function(t){var e=n.atom(void 0);return delete e.init,Object.defineProperty(e,"init",{get:function(){return t()}}),e},t.atomWithObservable=function(t,e){var r=function(t){if("e"in t)throw t.e;return t.d},o=n.atom((function(r){var o,i,a,u=t(r),f=null==(o=(i=u)[Symbol.observable])?void 0:o.call(i);f&&(u=f);var c,l,s,v,d=function(){return new Promise((function(t){a=t}))},m=e&&"initialValue"in e?{d:"function"==typeof e.initialValue?e.initialValue():e.initialValue}:d(),h=function(t){l=t,null==a||a(t),null==c||c(t)},p=function(){return!c},b=function(){s&&(clearTimeout(v),s.unsubscribe()),s=u.subscribe({next:function(t){return h({d:t})},error:function(t){return h({e:t})},complete:function(){}}),p()&&null!=e&&e.unstable_timeout&&(v=setTimeout((function(){s&&(s.unsubscribe(),s=void 0)}),e.unstable_timeout))};b();var y=n.atom(l||m);return y.onMount=function(t){return c=t,l&&t(l),s?clearTimeout(v):b(),function(){c=void 0,s&&(s.unsubscribe(),s=void 0)}},[y,u,d,b,p]}));return n.atom((function(t){var n=t(o),e=t(n[0]);return e instanceof Promise?e.then(r):r(e)}),(function(t,n,e){var r=t(o),i=r[0],a=r[1],u=r[2],f=r[3],c=r[4];if(!("next"in a))throw new Error("observable is not subject");c()&&(n(i,u()),f()),a.next(e)}))},t.atomWithReducer=function(t,e){return n.atom(t,(function(t,n,r){n(this,e(t(this),r))}))},t.atomWithRefresh=function(t,e){var r=n.atom(0);return n.atom((function(n,e){return n(r),t(n,e)}),(function(t,n){for(var o=arguments.length,i=new Array(o>2?o-2:0),a=2;a<o;a++)i[a-2]=arguments[a];if(0===i.length)n(r,(function(t){return t+1}));else if(e)return e.apply(void 0,[t,n].concat(i))}))},t.atomWithReset=function(t){var r=n.atom(t,(function(n,o,i){var a="function"==typeof i?i(n(r)):i;o(r,a===e?t:a)}));return r},t.atomWithStorage=function(t,r,o,i){void 0===o&&(o=b);var a=null==i?void 0:i.getOnInit,u=n.atom(a?o.getItem(t,r):r);return u.onMount=function(n){var e;return n(o.getItem(t,r)),o.subscribe&&(e=o.subscribe(t,n,r)),e},n.atom((function(t){return t(u)}),(function(n,i,a){var f="function"==typeof a?a(n(u)):a;return f===e?(i(u,r),o.removeItem(t)):f instanceof Promise?f.then((function(n){return i(u,n),o.setItem(t,n)})):(i(u,f),o.setItem(t,f))}))},t.createJSONStorage=p,t.freezeAtom=l,t.freezeAtomCreator=function(t){return function(){return l(t.apply(void 0,arguments))}},t.loadable=function(t){return e=function(){var e=new WeakMap,r=n.atom(0),o=n.atom((function(n,o){var i,a=o.setSelf;n(r);try{i=n(t)}catch(t){return{state:"hasError",error:t}}if(!(i instanceof Promise))return{state:"hasData",data:i};var u=i,f=e.get(u);if(f)return f;"fulfilled"===u.status?e.set(u,{state:"hasData",data:u.value}):"rejected"===u.status?e.set(u,{state:"hasError",error:u.reason}):u.then((function(t){e.set(u,{state:"hasData",data:t})}),(function(t){e.set(u,{state:"hasError",error:t})})).finally(a);var c=e.get(u);return c||(e.set(u,w),w)}),(function(t,n){n(r,(function(t){return t+1}))}));return n.atom((function(t){return t(o)}))},r=t,(y.has(r)?y:y.set(r,e())).get(r);var e,r},t.selectAtom=function(t,e,r){return void 0===r&&(r=Object.is),o=function(){var o=Symbol(),i=n.atom((function(n){var a=n(i);return function(t){var n=t[0],i=t[1];if(i===o)return e(n);var a=e(n,i);return r(i,a)?i:a}([n(t),a])}));return i.init=o,i},i=e,f=r,c=a((function(){return new WeakMap}),u,t),l=a((function(){return new WeakMap}),c,i),a(o,l,f);var o,i,f,c,l},t.splitAtom=function(t,e){return r=function(){var r=new WeakMap,o=function o(a,u){var f=r.get(a);if(f)return f;var c=u&&r.get(u),l=[],s=[];return a.forEach((function(r,u){var f=e?e(r):u;s[u]=f;var v=c&&c.atomList[c.keyList.indexOf(f)];if(v)l[u]=v;else{var d=function(n){var e=n(i),r=n(t),u=o(r,null==e?void 0:e.arr).keyList.indexOf(f);if(u<0||u>=r.length){var c=a[o(a).keyList.indexOf(f)];if(c)return c;throw new Error("splitAtom: index out of bounds for read")}return r[u]};l[u]=m(t)?n.atom(d,(function(n,e,r){var a=n(i),u=n(t),c=o(u,null==a?void 0:a.arr).keyList.indexOf(f);if(c<0||c>=u.length)throw new Error("splitAtom: index out of bounds for write");var l="function"==typeof r?r(u[c]):r;Object.is(u[c],l)||e(t,[].concat(u.slice(0,c),[l],u.slice(c+1)))})):n.atom(d)}})),f=c&&c.keyList.length===s.length&&c.keyList.every((function(t,n){return t===s[n]}))?c:{arr:a,atomList:l,keyList:s},r.set(a,f),f},i=n.atom((function(n){var e=n(i),r=n(t);return o(r,null==e?void 0:e.arr)}));i.init=void 0;var a=m(t)?n.atom((function(t){return t(i).atomList}),(function(n,e,r){switch(r.type){case"remove":var o=n(a).indexOf(r.atom);if(o>=0){var i=n(t);e(t,[].concat(i.slice(0,o),i.slice(o+1)))}break;case"insert":var u=r.before?n(a).indexOf(r.before):n(a).length;if(u>=0){var f=n(t);e(t,[].concat(f.slice(0,u),[r.value],f.slice(u)))}break;case"move":var c=n(a).indexOf(r.atom),l=r.before?n(a).indexOf(r.before):n(a).length;if(c>=0&&l>=0){var s=n(t);e(t,c<l?[].concat(s.slice(0,c),s.slice(c+1,l),[s[c]],s.slice(l)):[].concat(s.slice(0,l),[s[c]],s.slice(l,c),s.slice(c+1)))}}})):n.atom((function(t){return t(i).atomList}));return a},o=e||d,i=s((function(){return new WeakMap}),v,t),s(r,i,o);var r,o,i},t.unstable_withStorageValidator=function(t){return function(n){return i({},n,{getItem:function(e,r){var o=function(n){return t(n)?n:r},i=n.getItem(e,r);return h(i)?i.then(o):o(i)}})}},t.unwrap=function(t,e){return void 0===e&&(e=O),r=function(){var r=new WeakMap,o=new WeakMap,i=n.atom(0),a=n.atom((function(n,u){var f=u.setSelf;n(i);var c=n(a),l=n(t);if(!(l instanceof Promise))return{v:l};if(l!==(null==c?void 0:c.p)&&("fulfilled"===l.status?o.set(l,l.value):"rejected"===l.status?r.set(l,l.reason):l.then((function(t){return o.set(l,t)}),(function(t){return r.set(l,t)})).finally(f)),r.has(l))throw r.get(l);return o.has(l)?{p:l,v:o.get(l)}:c&&"v"in c?{p:l,f:e(c.v),v:c.v}:{p:l,f:e()}}),(function(t,n){n(i,(function(t){return t+1}))}));return a.init=void 0,n.atom((function(t){var n=t(a);return"f"in n?n.f:n.v}),(function(n,e){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return e.apply(void 0,[t].concat(o))}))},o=e,i=g((function(){return new WeakMap}),k,t),g(r,i,o);var r,o,i}}));

@@ -50,2 +50,3 @@ import type { Atom, WritableAtom } from './atom';

dev4_get_internal_weak_map: () => WeakMap<AnyAtom, AtomState>;
dev4_get_mounted_atoms: () => Set<AnyAtom>;
dev4_restore_atoms: (values: Iterable<readonly [AnyAtom, AnyValue]>) => void;

@@ -52,0 +53,0 @@ };

@@ -387,3 +387,2 @@ 'use strict';

function createJSONStorage(getStringStorage, options) {
var _getStringStorage4;
if (getStringStorage === void 0) {

@@ -448,5 +447,12 @@ getStringStorage = function getStringStorage() {

};
var subscriber = (_getStringStorage4 = getStringStorage()) == null ? void 0 : _getStringStorage4.subscribe;
if (!subscriber && typeof window !== 'undefined' && typeof window.addEventListener === 'function' && window.Storage && getStringStorage() instanceof window.Storage) {
var subscriber;
try {
var _getStringStorage4;
subscriber = (_getStringStorage4 = getStringStorage()) == null ? void 0 : _getStringStorage4.subscribe;
} catch (_unused3) {}
if (!subscriber && typeof window !== 'undefined' && typeof window.addEventListener === 'function' && window.Storage) {
subscriber = function subscriber(key, callback) {
if (!(getStringStorage() instanceof window.Storage)) {
return function () {};
}
var storageEventCallback = function storageEventCallback(e) {

@@ -453,0 +459,0 @@ if (e.storageArea === getStringStorage() && e.key === key) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc