react-state-custom 1.0.4 → 1.0.5
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/index.d.ts +1 -0
- package/dist/index.es.js +626 -552
- package/dist/index.umd.js +4 -4
- package/package.json +1 -1
- package/src/index.ts +1 -0
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(y,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],m):(y=typeof globalThis<"u"?globalThis:y||self,m(y.RState={},y.React))})(this,function(y,m){"use strict";var fr=Object.defineProperty;var cr=(y,m,W)=>m in y?fr(y,m,{enumerable:!0,configurable:!0,writable:!0,value:W}):y[m]=W;var oe=(y,m,W)=>cr(y,typeof m!="symbol"?m+"":m,W);function W(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var B={exports:{}},le;function Ae(){if(le)return B.exports;le=1;var e=typeof Reflect=="object"?Reflect:null,t=e&&typeof e.apply=="function"?e.apply:function(a,o,f){return Function.prototype.apply.call(a,o,f)},r;e&&typeof e.ownKeys=="function"?r=e.ownKeys:Object.getOwnPropertySymbols?r=function(a){return Object.getOwnPropertyNames(a).concat(Object.getOwnPropertySymbols(a))}:r=function(a){return Object.getOwnPropertyNames(a)};function u(s){console&&console.warn&&console.warn(s)}var c=Number.isNaN||function(a){return a!==a};function n(){n.init.call(this)}B.exports=n,B.exports.once=A,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._eventsCount=0,n.prototype._maxListeners=void 0;var d=10;function h(s){if(typeof s!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof s)}Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return d},set:function(s){if(typeof s!="number"||s<0||c(s))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+s+".");d=s}}),n.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},n.prototype.setMaxListeners=function(a){if(typeof a!="number"||a<0||c(a))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+a+".");return this._maxListeners=a,this};function b(s){return s._maxListeners===void 0?n.defaultMaxListeners:s._maxListeners}n.prototype.getMaxListeners=function(){return b(this)},n.prototype.emit=function(a){for(var o=[],f=1;f<arguments.length;f++)o.push(arguments[f]);var l=a==="error",g=this._events;if(g!==void 0)l=l&&g.error===void 0;else if(!l)return!1;if(l){var v;if(o.length>0&&(v=o[0]),v instanceof Error)throw v;var j=new Error("Unhandled error."+(v?" ("+v.message+")":""));throw j.context=v,j}var M=g[a];if(M===void 0)return!1;if(typeof M=="function")t(M,this,o);else for(var ne=M.length,K=F(M,ne),f=0;f<ne;++f)t(K[f],this,o);return!0};function _(s,a,o,f){var l,g,v;if(h(o),g=s._events,g===void 0?(g=s._events=Object.create(null),s._eventsCount=0):(g.newListener!==void 0&&(s.emit("newListener",a,o.listener?o.listener:o),g=s._events),v=g[a]),v===void 0)v=g[a]=o,++s._eventsCount;else if(typeof v=="function"?v=g[a]=f?[o,v]:[v,o]:f?v.unshift(o):v.push(o),l=b(s),l>0&&v.length>l&&!v.warned){v.warned=!0;var j=new Error("Possible EventEmitter memory leak detected. "+v.length+" "+String(a)+" listeners added. Use emitter.setMaxListeners() to increase limit");j.name="MaxListenersExceededWarning",j.emitter=s,j.type=a,j.count=v.length,u(j)}return s}n.prototype.addListener=function(a,o){return _(this,a,o,!1)},n.prototype.on=n.prototype.addListener,n.prototype.prependListener=function(a,o){return _(this,a,o,!0)};function w(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function O(s,a,o){var f={fired:!1,wrapFn:void 0,target:s,type:a,listener:o},l=w.bind(f);return l.listener=o,f.wrapFn=l,l}n.prototype.once=function(a,o){return h(o),this.on(a,O(this,a,o)),this},n.prototype.prependOnceListener=function(a,o){return h(o),this.prependListener(a,O(this,a,o)),this},n.prototype.removeListener=function(a,o){var f,l,g,v,j;if(h(o),l=this._events,l===void 0)return this;if(f=l[a],f===void 0)return this;if(f===o||f.listener===o)--this._eventsCount===0?this._events=Object.create(null):(delete l[a],l.removeListener&&this.emit("removeListener",a,f.listener||o));else if(typeof f!="function"){for(g=-1,v=f.length-1;v>=0;v--)if(f[v]===o||f[v].listener===o){j=f[v].listener,g=v;break}if(g<0)return this;g===0?f.shift():E(f,g),f.length===1&&(l[a]=f[0]),l.removeListener!==void 0&&this.emit("removeListener",a,j||o)}return this},n.prototype.off=n.prototype.removeListener,n.prototype.removeAllListeners=function(a){var o,f,l;if(f=this._events,f===void 0)return this;if(f.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):f[a]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete f[a]),this;if(arguments.length===0){var g=Object.keys(f),v;for(l=0;l<g.length;++l)v=g[l],v!=="removeListener"&&this.removeAllListeners(v);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(o=f[a],typeof o=="function")this.removeListener(a,o);else if(o!==void 0)for(l=o.length-1;l>=0;l--)this.removeListener(a,o[l]);return this};function L(s,a,o){var f=s._events;if(f===void 0)return[];var l=f[a];return l===void 0?[]:typeof l=="function"?o?[l.listener||l]:[l]:o?S(l):F(l,l.length)}n.prototype.listeners=function(a){return L(this,a,!0)},n.prototype.rawListeners=function(a){return L(this,a,!1)},n.listenerCount=function(s,a){return typeof s.listenerCount=="function"?s.listenerCount(a):P.call(s,a)},n.prototype.listenerCount=P;function P(s){var a=this._events;if(a!==void 0){var o=a[s];if(typeof o=="function")return 1;if(o!==void 0)return o.length}return 0}n.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};function F(s,a){for(var o=new Array(a),f=0;f<a;++f)o[f]=s[f];return o}function E(s,a){for(;a+1<s.length;a++)s[a]=s[a+1];s.pop()}function S(s){for(var a=new Array(s.length),o=0;o<a.length;++o)a[o]=s[o].listener||s[o];return a}function A(s,a){return new Promise(function(o,f){function l(v){s.removeListener(a,g),f(v)}function g(){typeof s.removeListener=="function"&&s.removeListener("error",l),o([].slice.call(arguments))}G(s,a,g,{once:!0}),a!=="error"&&Y(s,l,{once:!0})})}function Y(s,a,o){typeof s.on=="function"&&G(s,"error",a,o)}function G(s,a,o,f){if(typeof s.on=="function")f.once?s.once(a,o):s.on(a,o);else if(typeof s.addEventListener=="function")s.addEventListener(a,function l(g){f.once&&s.removeEventListener(a,l),o(g)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof s)}return B.exports}var Me=Ae();const ke=W(Me);var De=typeof global=="object"&&global&&global.Object===Object&&global,Ie=typeof self=="object"&&self&&self.Object===Object&&self,Q=De||Ie||Function("return this")(),Z=Q.Symbol,de=Object.prototype,Fe=de.hasOwnProperty,We=de.toString,V=Z?Z.toStringTag:void 0;function ze(e){var t=Fe.call(e,V),r=e[V];try{e[V]=void 0;var u=!0}catch{}var c=We.call(e);return u&&(t?e[V]=r:delete e[V]),c}var xe=Object.prototype,Ye=xe.toString;function Ge(e){return Ye.call(e)}var Ue="[object Null]",Ve="[object Undefined]",he=Z?Z.toStringTag:void 0;function pe(e){return e==null?e===void 0?Ve:Ue:he&&he in Object(e)?ze(e):Ge(e)}function He(e){return e!=null&&typeof e=="object"}var Je="[object Symbol]";function Xe(e){return typeof e=="symbol"||He(e)&&pe(e)==Je}var Ke=/\s/;function Be(e){for(var t=e.length;t--&&Ke.test(e.charAt(t)););return t}var Qe=/^\s+/;function Ze(e){return e&&e.slice(0,Be(e)+1).replace(Qe,"")}function z(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var ve=NaN,$e=/^[-+]0x[0-9a-f]+$/i,qe=/^0b[01]+$/i,et=/^0o[0-7]+$/i,tt=parseInt;function me(e){if(typeof e=="number")return e;if(Xe(e))return ve;if(z(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=z(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Ze(e);var r=qe.test(e);return r||et.test(e)?tt(e.slice(2),r?2:8):$e.test(e)?ve:+e}var rt="[object AsyncFunction]",nt="[object Function]",ot="[object GeneratorFunction]",at="[object Proxy]";function it(e){if(!z(e))return!1;var t=pe(e);return t==nt||t==ot||t==rt||t==at}var ae=Q["__core-js_shared__"],be=function(){var e=/[^.]+$/.exec(ae&&ae.keys&&ae.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function st(e){return!!be&&be in e}var ut=Function.prototype,ft=ut.toString;function ct(e){if(e!=null){try{return ft.call(e)}catch{}try{return e+""}catch{}}return""}var lt=/[\\^$.*+?()[\]{}|]/g,dt=/^\[object .+?Constructor\]$/,ht=Function.prototype,pt=Object.prototype,vt=ht.toString,mt=pt.hasOwnProperty,bt=RegExp("^"+vt.call(mt).replace(lt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function gt(e){if(!z(e)||st(e))return!1;var t=it(e)?bt:dt;return t.test(ct(e))}function _t(e,t){return e==null?void 0:e[t]}function ge(e,t){var r=_t(e,t);return gt(r)?r:void 0}function Et(e,t){return e===t||e!==e&&t!==t}var H=ge(Object,"create");function yt(){this.__data__=H?H(null):{},this.size=0}function Tt(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var wt="__lodash_hash_undefined__",Ot=Object.prototype,St=Ot.hasOwnProperty;function Rt(e){var t=this.__data__;if(H){var r=t[e];return r===wt?void 0:r}return St.call(t,e)?t[e]:void 0}var Ct=Object.prototype,jt=Ct.hasOwnProperty;function Lt(e){var t=this.__data__;return H?t[e]!==void 0:jt.call(t,e)}var Pt="__lodash_hash_undefined__";function Nt(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=H&&t===void 0?Pt:t,this}function D(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var u=e[t];this.set(u[0],u[1])}}D.prototype.clear=yt,D.prototype.delete=Tt,D.prototype.get=Rt,D.prototype.has=Lt,D.prototype.set=Nt;function At(){this.__data__=[],this.size=0}function $(e,t){for(var r=e.length;r--;)if(Et(e[r][0],t))return r;return-1}var Mt=Array.prototype,kt=Mt.splice;function Dt(e){var t=this.__data__,r=$(t,e);if(r<0)return!1;var u=t.length-1;return r==u?t.pop():kt.call(t,r,1),--this.size,!0}function It(e){var t=this.__data__,r=$(t,e);return r<0?void 0:t[r][1]}function Ft(e){return $(this.__data__,e)>-1}function Wt(e,t){var r=this.__data__,u=$(r,e);return u<0?(++this.size,r.push([e,t])):r[u][1]=t,this}function x(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var u=e[t];this.set(u[0],u[1])}}x.prototype.clear=At,x.prototype.delete=Dt,x.prototype.get=It,x.prototype.has=Ft,x.prototype.set=Wt;var zt=ge(Q,"Map");function xt(){this.size=0,this.__data__={hash:new D,map:new(zt||x),string:new D}}function Yt(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function q(e,t){var r=e.__data__;return Yt(t)?r[typeof t=="string"?"string":"hash"]:r.map}function Gt(e){var t=q(this,e).delete(e);return this.size-=t?1:0,t}function Ut(e){return q(this,e).get(e)}function Vt(e){return q(this,e).has(e)}function Ht(e,t){var r=q(this,e),u=r.size;return r.set(e,t),this.size+=r.size==u?0:1,this}function I(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var u=e[t];this.set(u[0],u[1])}}I.prototype.clear=xt,I.prototype.delete=Gt,I.prototype.get=Ut,I.prototype.has=Vt,I.prototype.set=Ht;var Jt="Expected a function";function ie(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Jt);var r=function(){var u=arguments,c=t?t.apply(this,u):u[0],n=r.cache;if(n.has(c))return n.get(c);var d=e.apply(this,u);return r.cache=n.set(c,d)||n,d};return r.cache=new(ie.Cache||I),r}ie.Cache=I;var se=function(){return Q.Date.now()},Xt="Expected a function",Kt=Math.max,Bt=Math.min;function ee(e,t,r){var u,c,n,d,h,b,_=0,w=!1,O=!1,L=!0;if(typeof e!="function")throw new TypeError(Xt);t=me(t)||0,z(r)&&(w=!!r.leading,O="maxWait"in r,n=O?Kt(me(r.maxWait)||0,t):n,L="trailing"in r?!!r.trailing:L);function P(o){var f=u,l=c;return u=c=void 0,_=o,d=e.apply(l,f),d}function F(o){return _=o,h=setTimeout(A,t),w?P(o):d}function E(o){var f=o-b,l=o-_,g=t-f;return O?Bt(g,n-l):g}function S(o){var f=o-b,l=o-_;return b===void 0||f>=t||f<0||O&&l>=n}function A(){var o=se();if(S(o))return Y(o);h=setTimeout(A,E(o))}function Y(o){return h=void 0,L&&u?P(o):(u=c=void 0,d)}function G(){h!==void 0&&clearTimeout(h),_=0,u=b=c=h=void 0}function s(){return h===void 0?d:Y(se())}function a(){var o=se(),f=S(o);if(u=arguments,c=this,b=o,f){if(h===void 0)return F(b);if(O)return clearTimeout(h),h=setTimeout(A,t),P(b)}return h===void 0&&(h=setTimeout(A,t)),d}return a.cancel=G,a.flush=s,a}var Qt="Expected a function";function Zt(e,t,r){var u=!0,c=!0;if(typeof e!="function")throw new TypeError(Qt);return z(r)&&(u="leading"in r?!!r.leading:u,c="trailing"in r?!!r.trailing:c),ee(e,t,{leading:u,maxWait:t,trailing:c})}class _e{constructor(t){oe(this,"event",new ke.EventEmitter);oe(this,"data",{});oe(this,"registry",new Set);this.name=t,console.log("[CONTEXT] %s",t),this.event.setMaxListeners(100)}publish(t,r){r!=this.data[t]&&(this.data[t]=r,this.event.emit(String(t),{value:r}))}subscribe(t,r){const u=({value:c})=>{r(c)};return this.event.addListener(String(t),u),console.log("listenerCount:",String(t),this.event.listenerCount(String(t))),t in this.data&&r(this.data[t]),()=>(this.event.removeListener(String(t),u),void 0)}}const Ee=ie(e=>new _e(e)),te=(e="noname")=>m.useMemo(()=>Ee(e),[e]),ye=(e,...t)=>{const r=new Error("[ctx] useRegistryChecker failed "+JSON.stringify({names:t,ctx:(e==null?void 0:e.name)??"undefined"}));m.useEffect(()=>{if(e)return t.some(u=>e.registry.has(u))&&console.error(r),t.forEach(u=>e.registry.add(u)),()=>{t.forEach(u=>e.registry.delete(u))}},[e,t.length])},$t=(e,t,r)=>{m.useEffect(()=>{e&&e.data[t]!=r&&e.publish(t,r)},[t,r,e]),ye(e,t)},qt=(e,t,r=0)=>{const[{value:u},c]=m.useState(()=>{var n;return{value:(n=e==null?void 0:e.data)==null?void 0:n[t]}});return m.useEffect(()=>{if(e){let n=r==0?h=>c({value:h}):ee(h=>c({value:h}),r),d=e.subscribe(t,n);return u!=e.data[t]&&c({value:e.data[t]}),()=>{d()}}},[t,e]),e==null?void 0:e.data[t]},er=(e,t,r)=>{const[,u]=m.useState(0),c=m.useMemo(()=>r(e==null?void 0:e.data[t]),[r,e==null?void 0:e.data[t]]);return m.useEffect(()=>{if(e){let n=c,d=()=>{let b=r(e.data[t]);b!=n&&(n=b,u(_=>_+1))},h=e.subscribe(t,d);return d(),()=>h()}},[t,e]),c},Te=(e,...t)=>{m.useEffect(()=>{if(e)for(let[r,u]of t)e.data[r]!=u&&e.publish(r,u)},[e,...t.flat()]),ye(e,...t.map(r=>r[0]))},tr=(e,...t)=>{const[,r]=m.useState(0),u=t.map(c=>{var n;return(n=e==null?void 0:e.data)==null?void 0:n[c]});return m.useEffect(()=>{if(e){let c=u;const n=ee(()=>{let b=t.map(_=>{var w;return(w=e==null?void 0:e.data)==null?void 0:w[_]});t.some((_,w)=>c[w]!=b[w])&&(c=b,r(_=>_+1))},1);let d=t.map(b=>e.subscribe(b,n)),h=setTimeout(n,1);return()=>{clearTimeout(h),n.cancel(),d.forEach(b=>b())}}},[e,...t]),Object.fromEntries(t.map((c,n)=>[c,u[n]]))},rr=(e,t=100,...r)=>{const[,u]=m.useState(0),c=r.map(n=>{var d;return(d=e==null?void 0:e.data)==null?void 0:d[n]});return m.useEffect(()=>{if(e){let n=c;const d=Zt(()=>{let _=r.map(w=>{var O;return(O=e==null?void 0:e.data)==null?void 0:O[w]});r.some((w,O)=>n[O]!=_[O])&&(n=_,u(w=>w+1))},t);let h=r.map(_=>e.subscribe(_,d)),b=setTimeout(d,1);return()=>{clearTimeout(b),d.cancel(),h.forEach(_=>_())}}},[e,...r]),c};var re={exports:{}},J={};/**
|
|
1
|
+
(function(T,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],v):(T=typeof globalThis<"u"?globalThis:T||self,v(T.RState={},T.React))})(this,function(T,v){"use strict";var pn=Object.defineProperty;var vn=(T,v,W)=>v in T?pn(T,v,{enumerable:!0,configurable:!0,writable:!0,value:W}):T[v]=W;var ae=(T,v,W)=>vn(T,typeof v!="symbol"?v+"":v,W);function W(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Z={exports:{}},he;function Me(){if(he)return Z.exports;he=1;var e=typeof Reflect=="object"?Reflect:null,t=e&&typeof e.apply=="function"?e.apply:function(a,o,f){return Function.prototype.apply.call(a,o,f)},n;e&&typeof e.ownKeys=="function"?n=e.ownKeys:Object.getOwnPropertySymbols?n=function(a){return Object.getOwnPropertyNames(a).concat(Object.getOwnPropertySymbols(a))}:n=function(a){return Object.getOwnPropertyNames(a)};function u(i){console&&console.warn&&console.warn(i)}var c=Number.isNaN||function(a){return a!==a};function r(){r.init.call(this)}Z.exports=r,Z.exports.once=A,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._eventsCount=0,r.prototype._maxListeners=void 0;var l=10;function h(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return l},set:function(i){if(typeof i!="number"||i<0||c(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");l=i}}),r.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(a){if(typeof a!="number"||a<0||c(a))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+a+".");return this._maxListeners=a,this};function p(i){return i._maxListeners===void 0?r.defaultMaxListeners:i._maxListeners}r.prototype.getMaxListeners=function(){return p(this)},r.prototype.emit=function(a){for(var o=[],f=1;f<arguments.length;f++)o.push(arguments[f]);var d=a==="error",E=this._events;if(E!==void 0)d=d&&E.error===void 0;else if(!d)return!1;if(d){var g;if(o.length>0&&(g=o[0]),g instanceof Error)throw g;var L=new Error("Unhandled error."+(g?" ("+g.message+")":""));throw L.context=g,L}var M=E[a];if(M===void 0)return!1;if(typeof M=="function")t(M,this,o);else for(var oe=M.length,Q=x(M,oe),f=0;f<oe;++f)t(Q[f],this,o);return!0};function b(i,a,o,f){var d,E,g;if(h(o),E=i._events,E===void 0?(E=i._events=Object.create(null),i._eventsCount=0):(E.newListener!==void 0&&(i.emit("newListener",a,o.listener?o.listener:o),E=i._events),g=E[a]),g===void 0)g=E[a]=o,++i._eventsCount;else if(typeof g=="function"?g=E[a]=f?[o,g]:[g,o]:f?g.unshift(o):g.push(o),d=p(i),d>0&&g.length>d&&!g.warned){g.warned=!0;var L=new Error("Possible EventEmitter memory leak detected. "+g.length+" "+String(a)+" listeners added. Use emitter.setMaxListeners() to increase limit");L.name="MaxListenersExceededWarning",L.emitter=i,L.type=a,L.count=g.length,u(L)}return i}r.prototype.addListener=function(a,o){return b(this,a,o,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(a,o){return b(this,a,o,!0)};function _(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function S(i,a,o){var f={fired:!1,wrapFn:void 0,target:i,type:a,listener:o},d=_.bind(f);return d.listener=o,f.wrapFn=d,d}r.prototype.once=function(a,o){return h(o),this.on(a,S(this,a,o)),this},r.prototype.prependOnceListener=function(a,o){return h(o),this.prependListener(a,S(this,a,o)),this},r.prototype.removeListener=function(a,o){var f,d,E,g,L;if(h(o),d=this._events,d===void 0)return this;if(f=d[a],f===void 0)return this;if(f===o||f.listener===o)--this._eventsCount===0?this._events=Object.create(null):(delete d[a],d.removeListener&&this.emit("removeListener",a,f.listener||o));else if(typeof f!="function"){for(E=-1,g=f.length-1;g>=0;g--)if(f[g]===o||f[g].listener===o){L=f[g].listener,E=g;break}if(E<0)return this;E===0?f.shift():y(f,E),f.length===1&&(d[a]=f[0]),d.removeListener!==void 0&&this.emit("removeListener",a,L||o)}return this},r.prototype.off=r.prototype.removeListener,r.prototype.removeAllListeners=function(a){var o,f,d;if(f=this._events,f===void 0)return this;if(f.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):f[a]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete f[a]),this;if(arguments.length===0){var E=Object.keys(f),g;for(d=0;d<E.length;++d)g=E[d],g!=="removeListener"&&this.removeAllListeners(g);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(o=f[a],typeof o=="function")this.removeListener(a,o);else if(o!==void 0)for(d=o.length-1;d>=0;d--)this.removeListener(a,o[d]);return this};function O(i,a,o){var f=i._events;if(f===void 0)return[];var d=f[a];return d===void 0?[]:typeof d=="function"?o?[d.listener||d]:[d]:o?R(d):x(d,d.length)}r.prototype.listeners=function(a){return O(this,a,!0)},r.prototype.rawListeners=function(a){return O(this,a,!1)},r.listenerCount=function(i,a){return typeof i.listenerCount=="function"?i.listenerCount(a):P.call(i,a)},r.prototype.listenerCount=P;function P(i){var a=this._events;if(a!==void 0){var o=a[i];if(typeof o=="function")return 1;if(o!==void 0)return o.length}return 0}r.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function x(i,a){for(var o=new Array(a),f=0;f<a;++f)o[f]=i[f];return o}function y(i,a){for(;a+1<i.length;a++)i[a]=i[a+1];i.pop()}function R(i){for(var a=new Array(i.length),o=0;o<a.length;++o)a[o]=i[o].listener||i[o];return a}function A(i,a){return new Promise(function(o,f){function d(g){i.removeListener(a,E),f(g)}function E(){typeof i.removeListener=="function"&&i.removeListener("error",d),o([].slice.call(arguments))}V(i,a,E,{once:!0}),a!=="error"&&U(i,d,{once:!0})})}function U(i,a,o){typeof i.on=="function"&&V(i,"error",a,o)}function V(i,a,o,f){if(typeof i.on=="function")f.once?i.once(a,o):i.on(a,o);else if(typeof i.addEventListener=="function")i.addEventListener(a,function d(E){f.once&&i.removeEventListener(a,d),o(E)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof i)}return Z.exports}var ke=Me();const De=W(ke);var Ie=typeof global=="object"&&global&&global.Object===Object&&global,Fe=typeof self=="object"&&self&&self.Object===Object&&self,$=Ie||Fe||Function("return this")(),q=$.Symbol,pe=Object.prototype,xe=pe.hasOwnProperty,We=pe.toString,J=q?q.toStringTag:void 0;function ze(e){var t=xe.call(e,J),n=e[J];try{e[J]=void 0;var u=!0}catch{}var c=We.call(e);return u&&(t?e[J]=n:delete e[J]),c}var Ye=Object.prototype,Ge=Ye.toString;function Ue(e){return Ge.call(e)}var Ve="[object Null]",He="[object Undefined]",ve=q?q.toStringTag:void 0;function me(e){return e==null?e===void 0?He:Ve:ve&&ve in Object(e)?ze(e):Ue(e)}function Je(e){return e!=null&&typeof e=="object"}var Xe="[object Symbol]";function Ke(e){return typeof e=="symbol"||Je(e)&&me(e)==Xe}var Be=/\s/;function Qe(e){for(var t=e.length;t--&&Be.test(e.charAt(t)););return t}var Ze=/^\s+/;function $e(e){return e&&e.slice(0,Qe(e)+1).replace(Ze,"")}function z(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var be=NaN,qe=/^[-+]0x[0-9a-f]+$/i,et=/^0b[01]+$/i,tt=/^0o[0-7]+$/i,nt=parseInt;function ge(e){if(typeof e=="number")return e;if(Ke(e))return be;if(z(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=z(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=$e(e);var n=et.test(e);return n||tt.test(e)?nt(e.slice(2),n?2:8):qe.test(e)?be:+e}var rt="[object AsyncFunction]",ot="[object Function]",at="[object GeneratorFunction]",st="[object Proxy]";function it(e){if(!z(e))return!1;var t=me(e);return t==ot||t==at||t==rt||t==st}var se=$["__core-js_shared__"],_e=function(){var e=/[^.]+$/.exec(se&&se.keys&&se.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function ut(e){return!!_e&&_e in e}var ct=Function.prototype,ft=ct.toString;function lt(e){if(e!=null){try{return ft.call(e)}catch{}try{return e+""}catch{}}return""}var dt=/[\\^$.*+?()[\]{}|]/g,ht=/^\[object .+?Constructor\]$/,pt=Function.prototype,vt=Object.prototype,mt=pt.toString,bt=vt.hasOwnProperty,gt=RegExp("^"+mt.call(bt).replace(dt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function _t(e){if(!z(e)||ut(e))return!1;var t=it(e)?gt:ht;return t.test(lt(e))}function Et(e,t){return e==null?void 0:e[t]}function Ee(e,t){var n=Et(e,t);return _t(n)?n:void 0}function yt(e,t){return e===t||e!==e&&t!==t}var X=Ee(Object,"create");function Tt(){this.__data__=X?X(null):{},this.size=0}function St(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var wt="__lodash_hash_undefined__",Ot=Object.prototype,Rt=Ot.hasOwnProperty;function Ct(e){var t=this.__data__;if(X){var n=t[e];return n===wt?void 0:n}return Rt.call(t,e)?t[e]:void 0}var jt=Object.prototype,Lt=jt.hasOwnProperty;function Pt(e){var t=this.__data__;return X?t[e]!==void 0:Lt.call(t,e)}var Nt="__lodash_hash_undefined__";function At(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=X&&t===void 0?Nt:t,this}function D(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var u=e[t];this.set(u[0],u[1])}}D.prototype.clear=Tt,D.prototype.delete=St,D.prototype.get=Ct,D.prototype.has=Pt,D.prototype.set=At;function Mt(){this.__data__=[],this.size=0}function ee(e,t){for(var n=e.length;n--;)if(yt(e[n][0],t))return n;return-1}var kt=Array.prototype,Dt=kt.splice;function It(e){var t=this.__data__,n=ee(t,e);if(n<0)return!1;var u=t.length-1;return n==u?t.pop():Dt.call(t,n,1),--this.size,!0}function Ft(e){var t=this.__data__,n=ee(t,e);return n<0?void 0:t[n][1]}function xt(e){return ee(this.__data__,e)>-1}function Wt(e,t){var n=this.__data__,u=ee(n,e);return u<0?(++this.size,n.push([e,t])):n[u][1]=t,this}function Y(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var u=e[t];this.set(u[0],u[1])}}Y.prototype.clear=Mt,Y.prototype.delete=It,Y.prototype.get=Ft,Y.prototype.has=xt,Y.prototype.set=Wt;var zt=Ee($,"Map");function Yt(){this.size=0,this.__data__={hash:new D,map:new(zt||Y),string:new D}}function Gt(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function te(e,t){var n=e.__data__;return Gt(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Ut(e){var t=te(this,e).delete(e);return this.size-=t?1:0,t}function Vt(e){return te(this,e).get(e)}function Ht(e){return te(this,e).has(e)}function Jt(e,t){var n=te(this,e),u=n.size;return n.set(e,t),this.size+=n.size==u?0:1,this}function I(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var u=e[t];this.set(u[0],u[1])}}I.prototype.clear=Yt,I.prototype.delete=Ut,I.prototype.get=Vt,I.prototype.has=Ht,I.prototype.set=Jt;var Xt="Expected a function";function ie(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Xt);var n=function(){var u=arguments,c=t?t.apply(this,u):u[0],r=n.cache;if(r.has(c))return r.get(c);var l=e.apply(this,u);return n.cache=r.set(c,l)||r,l};return n.cache=new(ie.Cache||I),n}ie.Cache=I;var ue=function(){return $.Date.now()},Kt="Expected a function",Bt=Math.max,Qt=Math.min;function ne(e,t,n){var u,c,r,l,h,p,b=0,_=!1,S=!1,O=!0;if(typeof e!="function")throw new TypeError(Kt);t=ge(t)||0,z(n)&&(_=!!n.leading,S="maxWait"in n,r=S?Bt(ge(n.maxWait)||0,t):r,O="trailing"in n?!!n.trailing:O);function P(o){var f=u,d=c;return u=c=void 0,b=o,l=e.apply(d,f),l}function x(o){return b=o,h=setTimeout(A,t),_?P(o):l}function y(o){var f=o-p,d=o-b,E=t-f;return S?Qt(E,r-d):E}function R(o){var f=o-p,d=o-b;return p===void 0||f>=t||f<0||S&&d>=r}function A(){var o=ue();if(R(o))return U(o);h=setTimeout(A,y(o))}function U(o){return h=void 0,O&&u?P(o):(u=c=void 0,l)}function V(){h!==void 0&&clearTimeout(h),b=0,u=p=c=h=void 0}function i(){return h===void 0?l:U(ue())}function a(){var o=ue(),f=R(o);if(u=arguments,c=this,p=o,f){if(h===void 0)return x(p);if(S)return clearTimeout(h),h=setTimeout(A,t),P(p)}return h===void 0&&(h=setTimeout(A,t)),l}return a.cancel=V,a.flush=i,a}var Zt="Expected a function";function $t(e,t,n){var u=!0,c=!0;if(typeof e!="function")throw new TypeError(Zt);return z(n)&&(u="leading"in n?!!n.leading:u,c="trailing"in n?!!n.trailing:c),ne(e,t,{leading:u,maxWait:t,trailing:c})}class ye{constructor(t){ae(this,"event",new De.EventEmitter);ae(this,"data",{});ae(this,"registry",new Set);this.name=t,console.log("[CONTEXT] %s",t),this.event.setMaxListeners(100)}publish(t,n){n!=this.data[t]&&(this.data[t]=n,this.event.emit(String(t),{value:n}))}subscribe(t,n){const u=({value:c})=>{n(c)};return this.event.addListener(String(t),u),console.log("listenerCount:",String(t),this.event.listenerCount(String(t))),t in this.data&&n(this.data[t]),()=>(this.event.removeListener(String(t),u),void 0)}}const Te=ie(e=>new ye(e)),F=(e="noname")=>v.useMemo(()=>Te(e),[e]),Se=(e,...t)=>{const n=new Error("[ctx] useRegistryChecker failed "+JSON.stringify({names:t,ctx:(e==null?void 0:e.name)??"undefined"}));v.useEffect(()=>{if(e)return t.some(u=>e.registry.has(u))&&console.error(n),t.forEach(u=>e.registry.add(u)),()=>{t.forEach(u=>e.registry.delete(u))}},[e,t.length])},qt=(e,t,n)=>{v.useEffect(()=>{e&&e.data[t]!=n&&e.publish(t,n)},[t,n,e]),Se(e,t)},we=(e,t,n=0)=>{const[{value:u},c]=v.useState(()=>{var r;return{value:(r=e==null?void 0:e.data)==null?void 0:r[t]}});return v.useEffect(()=>{if(e){let r=n==0?h=>c({value:h}):ne(h=>c({value:h}),n),l=e.subscribe(t,r);return u!=e.data[t]&&c({value:e.data[t]}),()=>{l()}}},[t,e]),e==null?void 0:e.data[t]},en=(e,t,n)=>{const[,u]=v.useState(0),c=v.useMemo(()=>n(e==null?void 0:e.data[t]),[n,e==null?void 0:e.data[t]]);return v.useEffect(()=>{if(e){let r=c,l=()=>{let p=n(e.data[t]);p!=r&&(r=p,u(b=>b+1))},h=e.subscribe(t,l);return l(),()=>h()}},[t,e]),c},ce=(e,...t)=>{v.useEffect(()=>{if(e)for(let[n,u]of t)e.data[n]!=u&&e.publish(n,u)},[e,...t.flat()]),Se(e,...t.map(n=>n[0]))},tn=(e,...t)=>{const[,n]=v.useState(0),u=t.map(c=>{var r;return(r=e==null?void 0:e.data)==null?void 0:r[c]});return v.useEffect(()=>{if(e){let c=u;const r=ne(()=>{let p=t.map(b=>{var _;return(_=e==null?void 0:e.data)==null?void 0:_[b]});t.some((b,_)=>c[_]!=p[_])&&(c=p,n(b=>b+1))},1);let l=t.map(p=>e.subscribe(p,r)),h=setTimeout(r,1);return()=>{clearTimeout(h),r.cancel(),l.forEach(p=>p())}}},[e,...t]),Object.fromEntries(t.map((c,r)=>[c,u[r]]))},nn=(e,t=100,...n)=>{const[,u]=v.useState(0),c=n.map(r=>{var l;return(l=e==null?void 0:e.data)==null?void 0:l[r]});return v.useEffect(()=>{if(e){let r=c;const l=$t(()=>{let b=n.map(_=>{var S;return(S=e==null?void 0:e.data)==null?void 0:S[_]});n.some((_,S)=>r[S]!=b[S])&&(r=b,u(_=>_+1))},t);let h=n.map(b=>e.subscribe(b,l)),p=setTimeout(l,1);return()=>{clearTimeout(p),l.cancel(),h.forEach(b=>b())}}},[e,...n]),c};var re={exports:{}},K={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var Oe;function rn(){if(Oe)return K;Oe=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(u,c,r){var l=null;if(r!==void 0&&(l=""+r),c.key!==void 0&&(l=""+c.key),"key"in c){r={};for(var h in c)h!=="key"&&(r[h]=c[h])}else r=c;return c=r.ref,{$$typeof:e,type:u,key:l,ref:c!==void 0?c:null,props:r}}return K.Fragment=t,K.jsx=n,K.jsxs=n,K}var B={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var Re;function on(){return Re||(Re=1,process.env.NODE_ENV!=="production"&&function(){function e(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===g?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case y:return"Fragment";case A:return"Profiler";case R:return"StrictMode";case a:return"Suspense";case o:return"SuspenseList";case E:return"Activity"}if(typeof s=="object")switch(typeof s.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case x:return"Portal";case V:return(s.displayName||"Context")+".Provider";case U:return(s._context.displayName||"Context")+".Consumer";case i:var m=s.render;return s=s.displayName,s||(s=m.displayName||m.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case f:return m=s.displayName||null,m!==null?m:e(s.type)||"Memo";case d:m=s._payload,s=s._init;try{return e(s(m))}catch{}}return null}function t(s){return""+s}function n(s){try{t(s);var m=!1}catch{m=!0}if(m){m=console;var w=m.error,C=typeof Symbol=="function"&&Symbol.toStringTag&&s[Symbol.toStringTag]||s.constructor.name||"Object";return w.call(m,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",C),t(s)}}function u(s){if(s===y)return"<>";if(typeof s=="object"&&s!==null&&s.$$typeof===d)return"<...>";try{var m=e(s);return m?"<"+m+">":"<...>"}catch{return"<...>"}}function c(){var s=L.A;return s===null?null:s.getOwner()}function r(){return Error("react-stack-top-frame")}function l(s){if(M.call(s,"key")){var m=Object.getOwnPropertyDescriptor(s,"key").get;if(m&&m.isReactWarning)return!1}return s.key!==void 0}function h(s,m){function w(){je||(je=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",m))}w.isReactWarning=!0,Object.defineProperty(s,"key",{get:w,configurable:!0})}function p(){var s=e(this.type);return Le[s]||(Le[s]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),s=this.props.ref,s!==void 0?s:null}function b(s,m,w,C,k,N,fe,le){return w=N.ref,s={$$typeof:P,type:s,key:m,props:N,_owner:k},(w!==void 0?w:null)!==null?Object.defineProperty(s,"ref",{enumerable:!1,get:p}):Object.defineProperty(s,"ref",{enumerable:!1,value:null}),s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(s,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(s,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:fe}),Object.defineProperty(s,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:le}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s}function _(s,m,w,C,k,N,fe,le){var j=m.children;if(j!==void 0)if(C)if(oe(j)){for(C=0;C<j.length;C++)S(j[C]);Object.freeze&&Object.freeze(j)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else S(j);if(M.call(m,"key")){j=e(s);var H=Object.keys(m).filter(function(hn){return hn!=="key"});C=0<H.length?"{key: someKey, "+H.join(": ..., ")+": ...}":"{key: someKey}",Ae[j+C]||(H=0<H.length?"{"+H.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,
|
|
22
|
+
<%s key={someKey} {...props} />`,C,j,H,j),Ae[j+C]=!0)}if(j=null,w!==void 0&&(n(w),j=""+w),l(m)&&(n(m.key),j=""+m.key),"key"in m){w={};for(var de in m)de!=="key"&&(w[de]=m[de])}else w=m;return j&&h(w,typeof s=="function"?s.displayName||s.name||"Unknown":s),b(s,j,N,k,c(),w,fe,le)}function S(s){typeof s=="object"&&s!==null&&s.$$typeof===P&&s._store&&(s._store.validated=1)}var O=v,P=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),U=Symbol.for("react.consumer"),V=Symbol.for("react.context"),i=Symbol.for("react.forward_ref"),a=Symbol.for("react.suspense"),o=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),g=Symbol.for("react.client.reference"),L=O.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M=Object.prototype.hasOwnProperty,oe=Array.isArray,Q=console.createTask?console.createTask:function(){return null};O={"react-stack-bottom-frame":function(s){return s()}};var je,Le={},Pe=O["react-stack-bottom-frame"].bind(O,r)(),Ne=Q(u(r)),Ae={};B.Fragment=y,B.jsx=function(s,m,w,C,k){var N=1e4>L.recentlyCreatedOwnerStacks++;return _(s,m,w,!1,C,k,N?Error("react-stack-top-frame"):Pe,N?Q(u(s)):Ne)},B.jsxs=function(s,m,w,C,k){var N=1e4>L.recentlyCreatedOwnerStacks++;return _(s,m,w,!0,C,k,N?Error("react-stack-top-frame"):Pe,N?Q(u(s)):Ne)}}()),B}var Ce;function an(){return Ce||(Ce=1,process.env.NODE_ENV==="production"?re.exports=rn():re.exports=on()),re.exports}var G=an();const sn=(e,t)=>{const n=c=>[e,...Object.entries(c??{}).sort((r,l)=>r[0].localeCompare(l[0])).flat()].join("-");let u=new Set;return{resolveCtxName:n,Root:c=>{const r=n(c),l=F(r),h=t(c),p=v.useMemo(()=>new Error().stack,[]);return ce(l,...Object.entries(h)),v.useEffect(()=>{if(u.has(r)){const b=new Error("RootContext "+r+" are mounted more than once");throw b.stack=p,b}return u.add(r),()=>{u.delete(r)}}),G.jsx(G.Fragment,{})},useCtxStateStrict:c=>{const r=n(c),l=v.useMemo(()=>new Error().stack,[]);return v.useEffect(()=>{if(!u.has(r)){const h=new Error("RootContext ["+r+"] is not mounted");throw h.stack=l,h}},[r]),F(r)},useCtxState:c=>{const r=n(c),l=v.useMemo(()=>new Error().stack,[]);return v.useEffect(()=>{if(!u.has(r)){const h=new Error("RootContext ["+r+"] is not mounted");h.stack=l;let p=setTimeout(()=>console.error(h),1e3);return()=>clearTimeout(p)}},[u.has(r)]),F(r)}}},un=function(){const e=new WeakMap;return t=>{let n=e.get(t);return n||e.set(t,n=((t==null?void 0:t.name)??"")+Math.random().toString()),n}}(),cn=e=>[...Object.entries(e??{}).sort((t,n)=>t[0].localeCompare(n[0])).flat()].join("-"),fn=({Wrapper:e=v.Fragment})=>{const t=F("auto-ctx"),[n,u]=v.useState({}),c=v.useCallback((r,l)=>{const h=un(r),p=cn(l);return u(({[h]:{Component:b=r,subState:{[p]:_={params:l,counter:0},...S}={}}={},...O})=>({...O,[h]:{Component:b,subState:{...S,[p]:{..._,counter:_.counter+1}}}})),()=>u(({[h]:{Component:b=r,subState:{[p]:_={params:l,counter:0},...S}={}}={},...O})=>({...O,[h]:{Component:b,subState:{...S,..._.counter>1?{[p]:{..._,counter:_.counter-1}}:{}}}}))},[]);return ce(t,["subscribe",c],["state",n]),G.jsx(G.Fragment,{children:Object.entries(n).flatMap(([r,{Component:l,subState:h}])=>Object.entries(h).map(([p,{counter:b,params:_}])=>({key:r+p,Component:l,params:_,counter:b})).filter(p=>p.counter>0).map(({key:p,params:b,Component:_})=>G.jsx(e,{children:G.jsx(_,{...b})},p)))})},ln=({Root:e,useCtxState:t,useCtxStateStrict:n,resolveCtxName:u})=>({useCtxState:c=>{const r=u(c),l=we(F("auto-ctx"),"subscribe");return v.useEffect(()=>l(e,c),[l,r]),F(r)}}),dn=e=>{const[,t]=v.useState(0),{proxy:n,finalGetter:u,openGetter:c,clean:r}=v.useMemo(()=>{const l=new Set,h={},p=new Map,b=new Proxy(e==null?void 0:e.data,{get(y,R){if(_)return l.add(R),h[R]=y[R];throw new Error("now allow here")}});let _=!0,S=ne(()=>{[...l.values()].some(y=>{var R;return h[y]!=((R=e==null?void 0:e.data)==null?void 0:R[y])})&&t(y=>y+1)},0),O=()=>{_=!0,l.clear()},P=()=>{_=!1,[...l.values()].filter(y=>!p.has(y)).forEach(y=>{p.set(y,e==null?void 0:e.subscribe(y,S))}),[...p.keys()].filter(y=>!l.has(y)).forEach(y=>{let R=p.get(y);R==null||R(),p.delete(y)})};return{proxy:b,finalGetter:P,openGetter:O,clean:()=>{O(),P(),t(y=>y+1)}}},[e]);return c(),setTimeout(u,0),v.useEffect(()=>()=>r(),[r]),n};T.AutoRootCtx=fn,T.Context=ye,T.createAutoCtx=ln,T.createRootCtx=sn,T.getContext=Te,T.useDataContext=F,T.useDataSource=qt,T.useDataSourceMultiple=ce,T.useDataSubscribe=we,T.useDataSubscribeMultiple=tn,T.useDataSubscribeMultipleWithDebounce=nn,T.useDataSubscribeWithTransform=en,T.useQuickSubscribe=dn,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ export {
|
|
|
13
13
|
} from "./state-utils/ctx"
|
|
14
14
|
|
|
15
15
|
export { createRootCtx } from "./state-utils/createRootCtx"
|
|
16
|
+
export { AutoRootCtx, createAutoCtx } from "./state-utils/createAutoCtx"
|
|
16
17
|
|
|
17
18
|
export { useQuickSubscribeV2 as useQuickSubscribe } from "./state-utils/useQuickSubscribeV2"
|
|
18
19
|
|