Comparing version 1.2.2 to 1.2.3
@@ -1,1 +0,1 @@ | ||
import{useState as t,useRef as e,useEffect as n,memo as r}from"react";function s(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}var i,o,a,c,f,u,h,l;class d{constructor(t){i.add(this),o.set(this,{}),a.set(this,new Map),s(this,i,"m",u).call(this,t)}subscribe(t,e){return"function"!=typeof e?(n=["listener must be a function"],console.warn(n.join("\n")),()=>!1):("string"==typeof t&&(t=[t]),s(this,i,"m",f).call(this,e),t.forEach((t=>{s(this,i,"m",c).call(this,t),s(this,a,"f").get(e).add(t),s(this,o,"f")[t].listeners.add(e)})),()=>{s(this,a,"f").delete(e),t.forEach((t=>s(this,o,"f")[t].listeners.delete(e)))});var n}set(t,{silent:e}={silent:!1}){if("object"!=typeof t)return;const n=s(this,i,"m",u).call(this,t);!e&&n&&s(this,i,"m",h).call(this,n)}get(t){var e,n;return"string"==typeof t?null===(n=null===(e=s(this,o,"f"))||void 0===e?void 0:e[t.toLowerCase()])||void 0===n?void 0:n.value:Array.isArray(t)?Object.fromEntries(t.map((t=>[t,m.get(t)]))):void 0}isValid(t){return void 0!==s(this,o,"f")[t]}}o=new WeakMap,a=new WeakMap,i=new WeakSet,c=function(t){s(this,o,"f")[t]||(s(this,o,"f")[t]={listeners:new Set})},f=function(t){s(this,a,"f").has(t)||s(this,a,"f").set(t,new Set)},u=function(t){if("object"!=typeof t)return;const e=Object.keys(t);return e.forEach((e=>{s(this,i,"m",c).call(this,e),s(this,o,"f")[e].value=t[e]})),e},h=function(t){const e=new Set;t.forEach((t=>{s(this,o,"f")[t].listeners.forEach((t=>e.add(t)))})),e.forEach((t=>t(s(this,i,"m",l).call(this,t))))},l=function(t){const e=Array.from(s(this,a,"f").get(t));return 1===e.length?s(this,o,"f")[e[0]].value:Object.fromEntries(e.map((t=>[t,s(this,o,"f")[t].value])))};const m=new d;function p(r=undefined){const s=r instanceof d,i=s?void 0:r,o=s?r:m,a=t({}),c=e({keys:new Set});return n((()=>{const{keys:t}=c.current;if(0===t.size)return;const e=o.subscribe(Array.from(t),(function(t){a[1]({value:t})}));return()=>e()}),[]),new Proxy({},{get(t,e){const{keys:n}=c.current;if((e=e.toLowerCase()).startsWith("set")){const t=e.replace("set","");return void 0!==i&&f(t),e=>{o.set({[t]:u(e,t)})}}return t[e]?t[e]:(n.add(e),f(e))}});function f(t){let e=o.get(t);return o.isValid(t)||(e=u(i,t),o.set({[t]:e})),e}function u(t,e){return"function"==typeof t?t(o.get(e)):t}}function v(t,e){function n(n){const r=p(e);return Object.defineProperties(r,Object.fromEntries(Object.entries(n).map((([t,e])=>[t,{value:e}])))),t(r)}return r(n)}export{d as Observer,m as observer,p as useObserver,v as withState}; | ||
import{useState as t,useRef as e,useEffect as r,memo as n}from"react";function s(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)}var i,o,a,c,f,u,h,l;class d{constructor(t){i.add(this),o.set(this,{}),a.set(this,new Map),s(this,i,"m",u).call(this,t)}subscribe(t,e){if("function"!=typeof e)return r=["listener must be a function"],console.warn(r.join("\n")),()=>!1;var r;Array.isArray(t)||(t=[t]),s(this,i,"m",f).call(this,e);const n=t.map((t=>t.toString().toLowerCase()));return n.forEach((t=>{s(this,i,"m",c).call(this,t),s(this,a,"f").get(e).add(t),s(this,o,"f")[t].listeners.add(e)})),()=>{s(this,a,"f").delete(e),n.forEach((t=>s(this,o,"f")[t.toLowerCase()].listeners.delete(e)))}}set(t,{silent:e}={silent:!1}){if("object"!=typeof t)return;const r=s(this,i,"m",u).call(this,t);!e&&r&&s(this,i,"m",h).call(this,r)}get(t){var e,r;return"string"==typeof t?null===(r=null===(e=s(this,o,"f"))||void 0===e?void 0:e[t.toLowerCase()])||void 0===r?void 0:r.value:Array.isArray(t)?Object.fromEntries(t.map((t=>[t,m.get(t)]))):void 0}isValid(t){return void 0!==s(this,o,"f")[t]}}o=new WeakMap,a=new WeakMap,i=new WeakSet,c=function(t){s(this,o,"f")[t]||(s(this,o,"f")[t]={listeners:new Set})},f=function(t){s(this,a,"f").has(t)||s(this,a,"f").set(t,new Set)},u=function(t){if("object"!=typeof t)return;const e=Object.keys(t);return e.forEach((e=>{s(this,i,"m",c).call(this,e),s(this,o,"f")[e].value=t[e]})),e},h=function(t){const e=new Set;t.forEach((t=>{s(this,o,"f")[t].listeners.forEach((t=>e.add(t)))})),e.forEach((t=>t(s(this,i,"m",l).call(this,t))))},l=function(t){const e=Array.from(s(this,a,"f").get(t));return 1===e.length?s(this,o,"f")[e[0]].value:Object.fromEntries(e.map((t=>[t,s(this,o,"f")[t].value])))};const m=new d;function w(n=undefined){const s=n instanceof d,i=s?void 0:n,o=s?n:m,a=t({}),c=e({keys:new Set});return r((()=>{const{keys:t}=c.current;if(0===t.size)return;const e=o.subscribe(Array.from(t),(function(t){a[1]({value:t})}));return()=>e()}),[]),new Proxy({},{get(t,e){const{keys:r}=c.current;if((e=e.toLowerCase()).startsWith("set")){const t=e.replace("set","");return void 0!==i&&f(t),e=>{o.set({[t]:u(e,t)})}}return t[e]?t[e]:(r.add(e),f(e))}});function f(t){let e=o.get(t);return o.isValid(t)||(e=u(i,t),o.set({[t]:e})),e}function u(t,e){return"function"==typeof t?t(o.get(e)):t}}function p(t,e){function r(r){const n=w(e);return Object.defineProperties(n,Object.fromEntries(Object.entries(r).map((([t,e])=>[t,{value:e}])))),t(n)}return n(r)}export{d as Observer,m as observer,w as useObserver,p as withState}; |
{ | ||
"name": "rosma", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13164