UNPKG

856 BJavaScriptView Raw
1System.register(["immer","jotai","react"],function(f){"use strict";var m,i,s,a;return{setters:[function(c){m=c.produce},function(c){i=c.atom,s=c.useAtom},function(c){a=c.useCallback}],execute:function(){f({atomWithImmer:c,useImmerAtom:h,withImmer:w});function c(e){const t=i(e,(o,n,r)=>n(t,m(o(t),typeof r=="function"?r:()=>r)));return t}function h(e,t){const[o,n]=s(e,t),r=a(u=>n(m(u)),[n]);return[o,r]}const l=(e,t)=>{do{const[o,...n]=t,r=e.get(o);if(!r)return;if(!n.length)return r[1];e=r[0],t=n}while(t.length)},g=(e,t,o)=>{do{const[n,...r]=t;let u=e.get(n);if(u||(u=[new WeakMap],e.set(n,u)),!r.length){u[1]=o;return}e=u[0],t=r}while(t.length)},p=(()=>{const e=new WeakMap;return(t,o)=>{const n=l(e,o);if(n)return n;const r=t();return g(e,o,r),r}})();function w(e){return p(()=>i(t=>t(e),(t,o,n)=>o(e,m(t(e),typeof n=="function"?n:()=>n))),[e])}}}});