bansa 0.0.22 → 0.0.23

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/dist/atom.js CHANGED
@@ -124,7 +124,7 @@ const isAtom = (x) => x instanceof CommonAtomInternal;
124
124
  const isPrimitiveAtom = (x) => x instanceof PrimitiveAtomInternal;
125
125
  const createScope = (parentScope, atomValuePairs) => {
126
126
  const scopeMap = /* @__PURE__ */ new WeakMap();
127
- const atomMap = /* @__PURE__ */ new WeakMap();
127
+ const atomMap = parentScope ? /* @__PURE__ */ new WeakMap() : scopeMap;
128
128
  const scope = ((baseAtom, strict = false) => {
129
129
  let scopedAtom = scopeMap.get(baseAtom);
130
130
  if (!strict) scopedAtom ||= atomMap.get(baseAtom);
@@ -1 +1 @@
1
- var p=class{a;m;n;r;s;get(){if(this.l||(P(this),d(this)),this.state.error)throw this.state.error;if(this.state.promise)throw this.state.promise;return this.state.value}watch(t){return this.l||O(this),(this.r||=new Set).add(t),()=>{this.r.delete(t),this.r.size||d(this)}}subscribe(t){let n={v:t,A:{get signal(){return(n.t||=j()).signal}}};if(!this.l)O(this);else if(!this.state.error&&!this.state.promise)try{t(this.state.value,n.A)}catch(o){m(o)}return(this.s||=new Set).add(n),()=>{this.s.delete(n),n.t&&(n.t.abort(),n.t=void 0),this.s.size||d(this)}}[Symbol.toPrimitive](){return this.state.value}},i=class extends p{o=!1;V=!1;constructor(t,n){super(),this.d=t,this.f=n?.equals,this.a=t,this.state={promise:void 0,error:void 0,value:t}}set(t){let n=t instanceof Function?t(this.a):t;g(n,this.state.value,this.f)||(this.a=n,b(this))}};i.prototype.y=!0;i.prototype.l=!0;i.prototype.i=!1;var y=class extends p{l=!1;i=!1;o=!1;V=!1;p=0;t;u;c;constructor(t,n){super(),this.d=t,this.f=n?.equals,this.b=!!n?.persist;let o=this;this.A={get signal(){return(o.t||=j()).signal}},this.state={promise:I,error:void 0,value:void 0}}};y.prototype.y=!1;var I=Promise.reject();I.catch(()=>{});var c=(e,t)=>e instanceof Function?new y(e,t):new i(e,t),v=e=>e instanceof p,_=e=>e instanceof i,H=(e,t)=>{let n=new WeakMap,o=new WeakMap,a=((r,l=!1)=>{let s=n.get(r);if(l||(s||=o.get(r)),!s){let h=e?.(r,!0);if(l)return h;let f=h||r;o.set(r,s=f.d instanceof Function?c((K,z)=>f.d((E,L)=>K(a(E),L),z),{equals:f.f,persist:f.b}):h||c(f.d))}return s});if(t)for(let[r,l]of t)n.set(r,v(l)?(e||a)(l):c(l));return a},S=!1,x=[],w=[],O=e=>{e.i||(e.i=!0,b(e))},b=e=>{e.o||(e.o=!0,x.push(e),S||(S=!0,queueMicrotask(M)))},M=()=>{S=!1;{let t=x;x=[];for(let n of t)n.state.promise=void 0,n.state.error=n.m,n.state.value=n.a,q(n)}let e=w;w=[];for(let t=e.length;t--;){let n=e[t];n.V=!1,n.i&&(n.o=!0,P(n)),n.o&&D(n)}},D=e=>{if(e.o=!1,e.r)for(let t of e.r)try{t()}catch(n){m(n)}if(!e.state.error&&!e.state.promise){if(e.s)for(let t of e.s){t.t&&(t.t.abort(),t.t=void 0);try{t.v(e.state.value,t.A)}catch(n){m(n)}}if(e.n)for(let t of e.n)t.i=!0}},q=e=>{if(!e.V){if(e.V=!0,e.n)for(let t of e.n)q(t);w.push(e)}},u=class{e;constructor(t){this.e=t}},G=Symbol(),P=e=>{let t=++e.p;e.l=!0,e.i=!1,e.state.promise=void 0,e.t&&(e.t.abort(),e.t=void 0);try{let n=e.d((o,a=!0)=>{if(t!==e.p)throw G;if(e!==o&&(o.l||(P(o),o.o&&D(o)),(e.c||=new Set).add(o),(o.n||=new Set).add(e)),!a)return o.state;if(o.state.error)throw new u(o.state.error);if(o.state.promise)throw new u(o.state.promise);return o.state.value},e.A);W(n)?(e.state.promise=n,n.then(o=>{t===e.p&&(V(e),g(o,e.state.value,e.f)?e.state.promise=void 0:(e.a=o,e.m=void 0),b(e))},o=>{t===e.p&&(V(e),o instanceof u?o=o.e:m(o),e.m=o,b(e))})):(V(e),e.state.error=void 0,g(n,e.state.value,e.f)?e.o=!1:e.state.value=e.a=n)}catch(n){V(e),n===G?e.o=!1:(n instanceof u?n=n.e:m(n),e.state.error=n)}},V=e=>{++e.p;let t=e.u;if(e.u=e.c,t){for(let n of t)e.u?.has(n)||(n.n.delete(e),d(n));t.clear()}e.c=t},k=!1,T=new Set,d=e=>{!e.y&&!e.b&&!e.n?.size&&!e.r?.size&&!e.s?.size&&(T.add(e),k||(k=!0,setTimeout(U,0)))},U=()=>{for(let e of T)if(!e.y&&!e.b&&!e.n?.size&&!e.r?.size&&!e.s?.size&&(e.state.promise=I,e.a=e.m=e.state.error=e.state.value=void 0,e.o=e.i=e.l=!1,e.t&&(e.t.abort(),e.t=void 0),e.u)){for(let t of e.u)t.n.delete(e),d(t);if(e.u.clear(),e.c){for(let t of e.c)t.n.delete(e),d(t);e.c.clear()}}T.clear(),k=!1},g=(e,t,n)=>Object.is(e,t)||n!==void 0&&t!==void 0&&n(e,t),W=e=>typeof e?.then=="function",j=()=>{let e=new AbortController,t=e.signal,n=new Promise(o=>{t.then=a=>n.then(a),t.addEventListener("abort",o,{once:!0,passive:!0})});return{abort:()=>e.abort(),signal:t}},m=e=>{queueMicrotask(()=>{throw e})};var A=()=>A,R=()=>{};Object.setPrototypeOf(A,new Proxy(A,{get:(e,t)=>t===Symbol.toPrimitive?R:A}));var C=e=>{if(typeof e!="object"||e===null)return c(e);if(Array.isArray(e))return e.map(C);let t=Object.create(null);for(let n in e)t[n]=C(e[n]);return t},$=e=>e.get(),F=(e,t=$)=>{let n=o=>{if(typeof o!="object"||o===null)return o;if(v(o))return t(o);if(Array.isArray(o))return o.map(n);let a=Object.create(null);for(let r in o)a[r]=n(o[r]);return a};return n(e)},X=(e,t)=>{let n=(o,a)=>{if(typeof o=="object"&&o!==null)if(v(o))_(o)&&o.set(a);else for(let r in a)n(o[r],a[r])};n(e,t)},B=e=>e instanceof Function?c((t,n)=>{let o,a,r=e(l=>{let s=t(l,!1);if(s.error)a=s.error;else if(s.promise)(o||=[]).push(s.promise);else return s.value;return A},n);if(a)throw a;if(o)throw Promise.all(o);return r},{equals:Q}):B(t=>F(e,t)),Q=(e,t)=>{if(typeof e!="object"||typeof t!="object"||!e||!t)return!1;let n=e.constructor;if(n!==t.constructor)return!1;if(n===Array){let a=e.length;if(a!==t.length)return!1;for(;(a=a-1|0)>=0;)if(!Object.is(e[a],t[a]))return!1;return!0}let o=0;for(let a in e){if(!(a in t&&Object.is(e[a],t[a])))return!1;o=o+1|0}for(let a in t)if((o=o-1|0)<0)return!1;return!0};export{c as $,B as $$,C as atomize,F as collectAtoms,H as createScope,I as inactive,v as isAtom,_ as isPrimitiveAtom,X as setAtoms};
1
+ var p=class{a;m;n;r;s;get(){if(this.l||(P(this),d(this)),this.state.error)throw this.state.error;if(this.state.promise)throw this.state.promise;return this.state.value}watch(t){return this.l||O(this),(this.r||=new Set).add(t),()=>{this.r.delete(t),this.r.size||d(this)}}subscribe(t){let n={v:t,A:{get signal(){return(n.t||=j()).signal}}};if(!this.l)O(this);else if(!this.state.error&&!this.state.promise)try{t(this.state.value,n.A)}catch(o){m(o)}return(this.s||=new Set).add(n),()=>{this.s.delete(n),n.t&&(n.t.abort(),n.t=void 0),this.s.size||d(this)}}[Symbol.toPrimitive](){return this.state.value}},i=class extends p{o=!1;V=!1;constructor(t,n){super(),this.d=t,this.f=n?.equals,this.a=t,this.state={promise:void 0,error:void 0,value:t}}set(t){let n=t instanceof Function?t(this.a):t;g(n,this.state.value,this.f)||(this.a=n,b(this))}};i.prototype.y=!0;i.prototype.l=!0;i.prototype.i=!1;var y=class extends p{l=!1;i=!1;o=!1;V=!1;p=0;t;u;c;constructor(t,n){super(),this.d=t,this.f=n?.equals,this.b=!!n?.persist;let o=this;this.A={get signal(){return(o.t||=j()).signal}},this.state={promise:I,error:void 0,value:void 0}}};y.prototype.y=!1;var I=Promise.reject();I.catch(()=>{});var c=(e,t)=>e instanceof Function?new y(e,t):new i(e,t),v=e=>e instanceof p,_=e=>e instanceof i,H=(e,t)=>{let n=new WeakMap,o=e?new WeakMap:n,a=((r,l=!1)=>{let s=n.get(r);if(l||(s||=o.get(r)),!s){let h=e?.(r,!0);if(l)return h;let f=h||r;o.set(r,s=f.d instanceof Function?c((K,z)=>f.d((E,L)=>K(a(E),L),z),{equals:f.f,persist:f.b}):h||c(f.d))}return s});if(t)for(let[r,l]of t)n.set(r,v(l)?(e||a)(l):c(l));return a},S=!1,x=[],w=[],O=e=>{e.i||(e.i=!0,b(e))},b=e=>{e.o||(e.o=!0,x.push(e),S||(S=!0,queueMicrotask(M)))},M=()=>{S=!1;{let t=x;x=[];for(let n of t)n.state.promise=void 0,n.state.error=n.m,n.state.value=n.a,q(n)}let e=w;w=[];for(let t=e.length;t--;){let n=e[t];n.V=!1,n.i&&(n.o=!0,P(n)),n.o&&D(n)}},D=e=>{if(e.o=!1,e.r)for(let t of e.r)try{t()}catch(n){m(n)}if(!e.state.error&&!e.state.promise){if(e.s)for(let t of e.s){t.t&&(t.t.abort(),t.t=void 0);try{t.v(e.state.value,t.A)}catch(n){m(n)}}if(e.n)for(let t of e.n)t.i=!0}},q=e=>{if(!e.V){if(e.V=!0,e.n)for(let t of e.n)q(t);w.push(e)}},u=class{e;constructor(t){this.e=t}},G=Symbol(),P=e=>{let t=++e.p;e.l=!0,e.i=!1,e.state.promise=void 0,e.t&&(e.t.abort(),e.t=void 0);try{let n=e.d((o,a=!0)=>{if(t!==e.p)throw G;if(e!==o&&(o.l||(P(o),o.o&&D(o)),(e.c||=new Set).add(o),(o.n||=new Set).add(e)),!a)return o.state;if(o.state.error)throw new u(o.state.error);if(o.state.promise)throw new u(o.state.promise);return o.state.value},e.A);W(n)?(e.state.promise=n,n.then(o=>{t===e.p&&(V(e),g(o,e.state.value,e.f)?e.state.promise=void 0:(e.a=o,e.m=void 0),b(e))},o=>{t===e.p&&(V(e),o instanceof u?o=o.e:m(o),e.m=o,b(e))})):(V(e),e.state.error=void 0,g(n,e.state.value,e.f)?e.o=!1:e.state.value=e.a=n)}catch(n){V(e),n===G?e.o=!1:(n instanceof u?n=n.e:m(n),e.state.error=n)}},V=e=>{++e.p;let t=e.u;if(e.u=e.c,t){for(let n of t)e.u?.has(n)||(n.n.delete(e),d(n));t.clear()}e.c=t},k=!1,T=new Set,d=e=>{!e.y&&!e.b&&!e.n?.size&&!e.r?.size&&!e.s?.size&&(T.add(e),k||(k=!0,setTimeout(U,0)))},U=()=>{for(let e of T)if(!e.y&&!e.b&&!e.n?.size&&!e.r?.size&&!e.s?.size&&(e.state.promise=I,e.a=e.m=e.state.error=e.state.value=void 0,e.o=e.i=e.l=!1,e.t&&(e.t.abort(),e.t=void 0),e.u)){for(let t of e.u)t.n.delete(e),d(t);if(e.u.clear(),e.c){for(let t of e.c)t.n.delete(e),d(t);e.c.clear()}}T.clear(),k=!1},g=(e,t,n)=>Object.is(e,t)||n!==void 0&&t!==void 0&&n(e,t),W=e=>typeof e?.then=="function",j=()=>{let e=new AbortController,t=e.signal,n=new Promise(o=>{t.then=a=>n.then(a),t.addEventListener("abort",o,{once:!0,passive:!0})});return{abort:()=>e.abort(),signal:t}},m=e=>{queueMicrotask(()=>{throw e})};var A=()=>A,R=()=>{};Object.setPrototypeOf(A,new Proxy(A,{get:(e,t)=>t===Symbol.toPrimitive?R:A}));var C=e=>{if(typeof e!="object"||e===null)return c(e);if(Array.isArray(e))return e.map(C);let t=Object.create(null);for(let n in e)t[n]=C(e[n]);return t},$=e=>e.get(),F=(e,t=$)=>{let n=o=>{if(typeof o!="object"||o===null)return o;if(v(o))return t(o);if(Array.isArray(o))return o.map(n);let a=Object.create(null);for(let r in o)a[r]=n(o[r]);return a};return n(e)},X=(e,t)=>{let n=(o,a)=>{if(typeof o=="object"&&o!==null)if(v(o))_(o)&&o.set(a);else for(let r in a)n(o[r],a[r])};n(e,t)},B=e=>e instanceof Function?c((t,n)=>{let o,a,r=e(l=>{let s=t(l,!1);if(s.error)a=s.error;else if(s.promise)(o||=[]).push(s.promise);else return s.value;return A},n);if(a)throw a;if(o)throw Promise.all(o);return r},{equals:Q}):B(t=>F(e,t)),Q=(e,t)=>{if(typeof e!="object"||typeof t!="object"||!e||!t)return!1;let n=e.constructor;if(n!==t.constructor)return!1;if(n===Array){let a=e.length;if(a!==t.length)return!1;for(;(a=a-1|0)>=0;)if(!Object.is(e[a],t[a]))return!1;return!0}let o=0;for(let a in e){if(!(a in t&&Object.is(e[a],t[a])))return!1;o=o+1|0}for(let a in t)if((o=o-1|0)<0)return!1;return!0};export{c as $,B as $$,C as atomize,F as collectAtoms,H as createScope,I as inactive,v as isAtom,_ as isPrimitiveAtom,X as setAtoms};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bansa",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",