insite-subscriptions-client 2.2.2 → 2.3.0
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/SubscriptionMap.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/package.json +34 -34
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionMap.d.ts","sourceRoot":"","sources":["../src/SubscriptionMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACN,WAAW,EACX,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,WAAW,EACX,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,MAAM,WAAW,CAAC;AAGnB,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzD,KAAK,IAAI,GAAG,WAAW,GAAG,mBAAmB,CAAC;AAE9C,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,IAAI,CAAC,EAAE,GAAG;IAClD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,CAAC,EAAE,CAAC;CACX,CAAC;AAEF,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAEvC,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,IACxC,CACC;IAAE,GAAG;IAAc,IAAI,EAAE,CAAC;CAAE,GAC5B;IAAE,GAAG;IAAc,GAAG,EAAE,MAAM;CAAE,GAChC;IAAE,GAAG;IAAe,KAAK,EAAE,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI;CAAE,GAC5D;IAAE,GAAG;IAAc,WAAW,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,+BAA+B,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;gBACjF,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,WAAW,UAAO;IAWtG,eAAe,SAAC;IAChB,MAAM,YAAC;IAEP,YAAY,EAAE,YAAY,GAAG,IAAI,CAAQ;IAEzC,SAAS;IAOT,IAAI,CAAC,eAAe,CAAC,eAEpB;IAED,WAAW;IASX,IAAI,CAAC,iBAAiB,CAAC,eAEtB;IAED,KAAK,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE;IAmBlD,IAAI,CAAC,WAAW,CAAC,uBAnBO,MAAM,WAAW,OAAO,EAAE,UAqBjD;IAED,CAAC,qBAAqB,CAAC;IAIvB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;IAGD,MAAM,CAAC,eAAe,SAAmB;IACzC,MAAM,CAAC,iBAAiB,SAAqB;IAC7C,MAAM,CAAC,WAAW,SAAe;IACjC,MAAM,CAAC,qBAAqB,SAAyB;CAErD;AAKD,qBAAa,mBAAmB;;gBACnB,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW;IAOtD,GAAG,EAAG,MAAM,CAAC;IAIb,MAAM,CAAC,OAAO,EAAE,WAAW;IAK3B,MAAM;CAMN"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var Jt=Object.defineProperty;var Tt=o=>{throw TypeError(o)};var qt=(o,s,t)=>s in o?Jt(o,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[s]=t;var i=(o,s,t)=>qt(o,typeof s!="symbol"?s+"":s,t),yt=(o,s,t)=>s.has(o)||Tt("Cannot "+t);var a=(o,s,t)=>(yt(o,s,"read from private field"),t?t.call(o):s.get(o)),h=(o,s,t)=>s.has(o)?Tt("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(o):s.set(o,t),d=(o,s,t,e)=>(yt(o,s,"write to private field"),e?e.call(o,t):s.set(o,t),t),g=(o,s,t)=>(yt(o,s,"access private method"),t);var wt,et,L,q=class{constructor(s,t,e=[],r,n=!0){i(this,"i");i(this,"type");i(this,"publicationName");i(this,"args");i(this,"handler");i(this,"immediately");i(this,"isActive");i(this,"start",()=>{L.sendMessage("s-s",this.type,this.publicationName,this.i,this.args,this.immediately),this.immediately=!0});if(!L)throw new Error("Subscription is not binded to WS. Do Subscription.bindTo(ws) first");this.i=wt++,this.type=s,this.publicationName=t,this.args=e,this.handler=r,this.immediately=n&&!globalThis.__initials,et.set(this.i,this),L.on("open",this.start),L.isOpen&&this.start(),globalThis.__initials?(this.isActive=!0,this.handler(globalThis.__initials.splice(0,1)[0])):this.isActive=!1}cancel(){et.delete(this.i),L.off("open",this.start),L.sendMessage("s-u",this.i)}static bindTo(s){L=s,wt=0,et=new Map,L.on("message:s-c",(t,e)=>{let r=et.get(t);r&&(r.isActive=!0,r.handler(e))}),L.on("close",()=>{for(let t of et.values())t.isActive=!1}),L.on("server-change",()=>{for(let t of et.values())t.handler(null)})}};function it(){}function lt(o,s=0,t={}){let{leading:e=!1,trailing:r=!0}=t,{maxWait:n=1/0}=t,u,f,p,c,b,l,m,S,ht=async()=>{let tt=Date.now();tt>=p?(u=void 0,p=void 0,clearTimeout(f),typeof m=="function"&&await m(),V.resolve(S),V.promise.isResolved=!0,l=e):(clearTimeout(u),u=setTimeout(ht,p-tt))},pt=Number.isFinite(n)?()=>{m===X&&(m=!1),X(),f=setTimeout(pt,n)}:null;async function X(){return S=await o.apply(c,b)}e&&typeof e=="boolean"&&(e=X),l=e,r&&typeof r=="boolean"&&(r=X),m=r;let V=Object.assign(function(...tt){return b=tt,c=this,p=Date.now()+s,m=r,V.promise.isResolved&&(V.promise=Object.assign(new Promise(Vt=>{V.resolve=Vt,typeof l=="function"&&(l(),l=!1,m===X&&(m=!1)),u||(u=setTimeout(ht,s),pt&&(f=setTimeout(pt,n)))}),{isResolved:!1})),V.promise},{callback:o,promise:Object.assign(Promise.resolve(),{isResolved:!0}),resolve:it,run:X,clear:async tt=>{clearTimeout(u),u=void 0,clearTimeout(f),V.promise.isResolved=!0,V.resolve(tt?await X():S)}});return V}lt.noop=Object.assign(()=>{},{callback:it,promise:Object.assign(Promise.resolve(),{isResolved:!0}),resolve:it,run:it,clear:it});function Ot(o,s,t,e,r=!0){return Array.isArray(o)&&(o=o.length),typeof e!="string"&&(r=e??!0,e=t),(r?`${o}\xA0`:"")+Ot.raw(o,s,t,e)}Ot.raw=(o,s,t,e=t)=>{o=Math.abs(o);let r=o%10,n=o%100;return r===1&&n!==11?s:r>=2&&r<=4&&!(n>=12&&n<=15)?t:e};function Q(o,s){let t=o.indexOf(s);return t>-1?(o.splice(t,1),!0):!1}var ct=new WeakMap,x=class extends Promise{constructor(t){let e,r;super((n,u)=>{e=n,r=u});i(this,"isPending",!0);i(this,"isFulfilled",!1);i(this,"isRejected",!1);i(this,"state","pending");i(this,"result");i(this,"resolve",t=>{if(this.isPending){this.isPending=!1,this.isFulfilled=!0,this.state="fulfilled",this.result=t;let e=ct.get(this);e&&(e.resolve.call(this,t),ct.delete(this))}});i(this,"reject",t=>{if(this.isPending){this.isPending=!1,this.isRejected=!0,this.state="rejected",this.result=t;let e=ct.get(this);e&&(e.reject.call(this,t),ct.delete(this))}});ct.set(this,{resolve:e,reject:r}),t?.(this.resolve,this.reject)}};function At(o){return[...new Set(o)]}var O=Symbol("update"),A=Symbol("getHandleUpdate"),U=Symbol("setHandleUpdate"),D=Symbol("getAsUpdates"),H=Symbol("getAsInitialUpdated"),_=Symbol("clear"),y=Symbol("subscribe"),I=Symbol("unsubscribe"),j=Symbol("renew"),$=Symbol("getSubscription"),zt=Symbol("getHandleSubscription"),Kt=Symbol("setHandleSubscription");var Xt=(o,s)=>o>s?1:o<s?-1:0,Qt=(o,s)=>o>s?-1:o<s?1:0,Dt,Ht,jt,Pt,P=class extends Array{constructor(t,e){super();i(this,"sorted",[]);i(this,"handleUpdate");i(this,"sortDirection",0);i(this,"sortCompareFunction",null);i(this,Pt,this.update);i(this,jt,this.getAsUpdates);i(this,Ht,this.getAsInitialUpdated);i(this,Dt,this.clear);e&&(this.handleUpdate=e),Array.isArray(t)&&this.update(t)}[A](){return this.handleUpdate}[U](t){return this.handleUpdate=t}update(t){let e=Object.assign([],{deleted:[],added:[]});if(t){let r=!1;for(let n of t)switch(n?.[0]){case"i":{let[,u,f]=n;f?(this.sortDirection=f,this.sortCompareFunction=f>0?Xt:Qt,r=!0):(this.sortDirection=0,this.sortCompareFunction=null),this.length=0;for(let p of u)this.push(p),e.push(p),e.added.push(p);break}case"a":{let[,u]=n;this.includes(u)||(this.push(u),this.sortDirection&&(r=!0),e.push(u),e.added.push(u));break}case"d":{let[,u]=n;Q(this,u)&&e.deleted.push(u);break}default:this.clear()}r&&this.sortCompareFunction&&this.sort(this.sortCompareFunction)}else this.clear();return this.handleUpdate?.(this,e,t?.[0]?t:null),this}getAsUpdates(){return this.length||this.sortDirection?[["i",[...this],this.sortDirection]]:null}getAsInitialUpdated(){return Object.assign([...this.sorted],{added:[...this.sorted],deleted:[]})}clear(){this.length=0,this.sortDirection=0,this.sortCompareFunction=null}valueOf(){return this}get[(Pt=O,jt=D,Ht=H,Dt=_,Symbol.toStringTag)](){return"SubscriptionArray"}};i(P,"updateSymbol",O),i(P,"getHandleUpdateSymbol",A),i(P,"setHandleUpdateSymbol",U),i(P,"getAsUpdatesSymbol",D),i(P,"getAsInitialUpdatedSymbol",H),i(P,"clearSymbol",_),i(P,"WithSubscription");var G=class extends P{constructor(t,e,r,n=!0){super(null,r);i(this,"publicationName");i(this,"params");i(this,"subscription",null);this.publicationName=t,this.params=e,n&&this.subscribe()}subscribe(){this.subscription||(this.subscription=new q("array",this.publicationName,this.params,t=>this.update(t)))}get[y](){return this.subscribe}unsubscribe(){this.subscription&&(this.subscription.cancel(),this.subscription=null)}get[I](){return this.unsubscribe}renew(t,e){this.subscription&&(this.unsubscribe(),t&&(Array.isArray(t)?e=t:this.publicationName=t),e&&(this.params=e),this.subscribe())}get[j](){return this.renew}[$](){return this.subscription}get[Symbol.toStringTag](){return"SubscriptionArrayWithSubscription"}};i(G,"subscribeSymbol",y),i(G,"unsubscribeSymbol",I),i(G,"renewSymbol",j),i(G,"getSubscriptionSymbol",$);P.WithSubscription=G;import te from"eventemitter3";var v={};import Zt from"eventemitter3";function Yt(o){let s=document.createElement("script");s.textContent=`window.__insite_subscription_map_sort_function = function sort(a, b) { return ${Object.entries(o).map(([e,r])=>r>0?`a.${e} > b.${e} ? 1 : a.${e} < b.${e} ? -1 :`:`a.${e} < b.${e} ? 1 : a.${e} > b.${e} ? -1 :`).concat("0").join(" ")};}`,document.head.append(s);let t=globalThis.__insite_subscription_map_sort_function;return s.remove(),delete globalThis.__insite_subscription_map_sort_function,t}var kt,_t,Lt,$t,st,Y,rt,T=class extends Map{constructor(t,e){super();i(this,"handleUpdate");h(this,st,new Map);i(this,"sortList",null);i(this,"sortCompareFunction",null);h(this,Y,[]);i(this,"sorted",[]);h(this,rt);i(this,$t,this.update);i(this,Lt,this.getAsUpdates);i(this,_t,this.getAsInitialUpdated);i(this,kt,this.clear);e&&(this.handleUpdate=e),t&&this.update(t)}sort(){this.sortCompareFunction&&this.sorted.sort(this.sortCompareFunction)}[A](){return this.handleUpdate}[U](t){return this.handleUpdate=t}set Item(t){if(d(this,rt,t),this.size)for(let[e,r]of this)this.set(e,new t(this,r))}get Item(){return a(this,rt)}update(t){let e=Object.assign([],{added:[],deleted:[]});if(t){let r=!1,n=a(this,rt),u=a(this,st);for(let f of t)switch(f?.[0]){case"i":{let[,p,c]=f;if(c?(this.sortList=c,this.sortCompareFunction=Yt(c),d(this,Y,At(Object.keys(c).map(b=>b.replace(/\..+/,"")))),r=!0):(this.sortList=null,this.sortCompareFunction=null,d(this,Y,[])),this.size){let b=new Map;for(let l of p)b.set(l._id,l);for(let[l,m]of this){let S=b.get(l);if(S){let ht=u.get(l);if(n)m.update(S);else{for(let pt in ht)delete m[pt];Object.assign(m,S)}u.set(l,S),e.push(m),b.delete(l)}else n?m.delete():this.delete(l),u.delete(l),e.deleted.push(l)}for(let[l,m]of b){let S=n?new n(this,m):{...m};this.set(l,S),u.set(l,m),e.push(S),e.added.push(S)}this.sortList&&(this.sorted=p.map(l=>this.get(l._id)))}else for(let b of p){let l=n?new n(this,b):{...b};this.set(l._id,l),this.sorted.push(l),u.set(l._id,b),e.push(l),e.added.push(l)}break}case"c":case"u":{let[,p]=f,c=this.get(p._id);if(c){let b=f[2]===!0,l=b?Object.keys(p):f[2],m=u.get(c._id);if(n)c.update(p);else{if(!b)for(let S in m)delete c[S];Object.assign(c,p)}b&&(p=Object.assign(m,p)),this.sortList&&!r&&(!l||l.some(S=>a(this,Y).includes(S)))&&(r=!0)}else c=n?new n(this,p):{...p},this.set(c._id,c),this.sorted.push(c),this.sortList&&(r=!0),e.added.push(c);u.set(c._id,p),e.push(c);break}case"d":{let[,p]=f,c=this.get(p);c&&(n?c.delete():this.delete(p),u.delete(p),Q(this.sorted,c),e.deleted.push(p));break}default:this.clear()}r&&this.sort()}else this.clear();return this.handleUpdate?.(this,e,t?.[0]?t:null),this}getAsUpdates(){return this.size||this.sortList?[["i",[...a(this,st).values()],this.sortList]]:null}getAsInitialUpdated(){return Object.assign([...this.sorted],{added:[...this.sorted],deleted:[]})}clear(){super.clear(),a(this,st).clear(),this.sorted=[],this.sortList=null,this.sortCompareFunction=null,d(this,Y,[])}valueOf(){return this.sorted}get[($t=O,Lt=D,_t=H,kt=_,Symbol.toStringTag)](){return"SubscriptionMap"}};st=new WeakMap,Y=new WeakMap,rt=new WeakMap,i(T,"updateSymbol",O),i(T,"getHandleUpdateSymbol",A),i(T,"setHandleUpdateSymbol",U),i(T,"getAsUpdatesSymbol",D),i(T,"getAsInitialUpdatedSymbol",H),i(T,"clearSymbol",_),i(T,"WithSubscription"),i(T,"Item");var M=class extends T{constructor(t,e,r,n=!0){super(null,r);i(this,"publicationName");i(this,"params");i(this,"subscription",null);this.publicationName=t,this.params=e,n&&this.subscribe()}subscribe(){this.subscription||(this.subscription=new q("map",this.publicationName,this.params,t=>this.update(t)))}get[y](){return this.subscribe}unsubscribe(){this.subscription&&(this.subscription.cancel(),this.subscription=null)}get[I](){return this.unsubscribe}renew(t,e){this.subscription&&(this.unsubscribe(),t&&(Array.isArray(t)?e=t:this.publicationName=t),e&&(this.params=e),this.subscribe())}get[j](){return this.renew}[$](){return this.subscription}get[Symbol.toStringTag](){return"SubscriptionMapWithSubscription"}};i(M,"subscribeSymbol",y),i(M,"unsubscribeSymbol",I),i(M,"renewSymbol",j),i(M,"getSubscriptionSymbol",$);T.WithSubscription=M;var dt,gt=class{constructor(s,t){i(this,"_id");h(this,dt);d(this,dt,s),this.update(t)}update(s){Object.assign(this,s)}delete(){a(this,dt).delete(this._id)}};dt=new WeakMap;T.Item=gt;var ft=Symbol("handleUpdate"),z=Symbol("updates"),Gt,Mt,k=class{constructor(s,t){i(this,Mt);i(this,Gt,null);t&&(this[ft]=t),s&&this[O](s)}[(Mt=ft,Gt=z,A)](){return this[ft]}[U](s){return this[ft]=s}[O](s){if(s){for(let t in this[z])delete this[t];for(let t in s)this[t]=s[t];this[z]=s}else this[_]();return this[ft]?.(this,this,this[z]),this}[D](){return this[z]&&{...this[z]}}[H](){return this.valueOf()}[_](){for(let s in this)delete this[s];this[z]=null}valueOf(){return this[z]&&this}get[Symbol.toStringTag](){return"SubscriptionObject"}};i(k,"updateSymbol",O),i(k,"getHandleUpdateSymbol",A),i(k,"setHandleUpdateSymbol",U),i(k,"getAsUpdatesSymbol",D),i(k,"getAsInitialUpdatedSymbol",H),i(k,"clearSymbol",_),i(k,"WithSubscription");var ot,nt,B,F=class extends k{constructor(t,e,r,n=!0){super(null,r);h(this,ot);h(this,nt);h(this,B,null);d(this,ot,t),d(this,nt,e),n&&this[y]()}[y](){a(this,B)||d(this,B,new q("object",a(this,ot),a(this,nt),t=>this[O](t)))}[I](){a(this,B)&&(a(this,B).cancel(),d(this,B,null))}[j](t,e){a(this,B)&&(this[I](),t&&(Array.isArray(t)?e=t:d(this,ot,t)),e&&d(this,nt,e),this[y]())}[$](){return a(this,B)}get[Symbol.toStringTag](){return"SubscriptionObjectWithSubscription"}};ot=new WeakMap,nt=new WeakMap,B=new WeakMap,i(F,"subscribeSymbol",y),i(F,"unsubscribeSymbol",I),i(F,"renewSymbol",j),i(F,"getSubscriptionSymbol",$);k.WithSubscription=F;function Bt(o){return Array.isArray(o)}var R,K,E,w,xt,Ft,J,at,Rt,Et,Ut,bt=class bt extends Zt{constructor(t,e){super();h(this,w);i(this,"name");i(this,"group");i(this,"value");i(this,"type");i(this,"publicationName");i(this,"params");i(this,"handle");i(this,"onBeforeInit");i(this,"preventBind");i(this,"emitUpdate");i(this,"isLoaded",!1);i(this,"isInited",!1);h(this,R);h(this,K);h(this,E);h(this,J,null);h(this,at,(t,e,r)=>{if(r)if(this.group.isLoaded){if(this.handle)switch(this.type){case"array":this.handle.call(this.group,e,this.group);break;case"map":this.handle.call(this.group,e,this.group);break;default:this.handle.call(this.group,e,this.group)}this.emitUpdate(e)}else d(this,J,e),this.isLoaded=!0,v.groupLoad(this.group);else this.isLoaded&&(this.isLoaded=!1,v.groupUnload(this.group));this.isInited||(this.isInited=!0,v.groupInit(this.group))});this.name=t.name,this.define(t,e)}define(t,e=this.group){if(!e)throw new Error("group is undefined");let{value:r,type:n="object",publicationName:u,params:f,handle:p,onBeforeInit:c,debounce:b=bt.debounceLimit,preventBind:l}=t;if(this.group){if((!r||this.value===r)&&this.type===n&&this.publicationName===u&&JSON.stringify(this.params)===JSON.stringify(f)&&this.handle===p&&this.onBeforeInit===c)return g(this,w,xt).call(this,{debounceLimit:b,preventBind:l});this.detach(),delete this.value,delete this.publicationName,delete this.params}this.type=n,this.handle=p,this.onBeforeInit=c,r?this.value=r:(this.publicationName=u??this.name,this.params=f??[]),g(this,w,xt).call(this,{debounceLimit:b,preventBind:l}),g(this,w,Ft).call(this,e)}detach(){this.group&&(this.value?.[I](),this.isLoaded=!1,g(this,w,Ut).call(this),delete this.group.values[this.name],Q(this.group.values,this.value),delete this.group.items[this.name],Q(this.group.items,this),delete this.group)}loaded(){return a(this,R)}inited(){return a(this,K)}unloaded(){return a(this,E)}subscribe(){if(this.value){if(this.value[y])return this.value[y]();{let t=this.value[A]();if(t){let e=this.value[H](),r=this.value[D]();switch(this.type){case"array":return t(this.value,e,r);case"map":return t(this.value,e,r);default:return t(this.value,e,r)}}}}}unsubscribe(){return this.value?.[I]?.()}renew(t,e){return this.value?.[j]?.(t,e)}valueOf(){return this.value}};R=new WeakMap,K=new WeakMap,E=new WeakMap,w=new WeakSet,xt=function({debounceLimit:t,preventBind:e}){let r=n=>{this.emit("update",this.value,n),this.group?.emit(`update.${this.name}`,this.value,n),this.group?.emitUpdate()};if(typeof t=="number"){let n,u,f=lt(()=>{let p=!this.group;p&&(this.group=u),r(n),p&&delete this.group,n=void 0},t);this.emitUpdate=p=>{if(p!==void 0)if(Bt(p))if(Bt(n))for(let c of p)n.push(c);else n=Object.assign([...p],{added:[...p.added],deleted:[...p.deleted]});else typeof p=="object"?n?Object.assign(n,p):n={...p}:n=p;return u=this.group,f()}}else this.emitUpdate=r;this.preventBind===void 0?delete this.preventBind:this.preventBind=e},Ft=function(t){if(!this.group){switch(this.group=t,this.group.items.push(this),this.group.items[this.name]=this,(!a(this,R)||a(this,R).isFulfilled)&&d(this,R,new x),(!a(this,K)||a(this,K).isFulfilled)&&d(this,K,new x),(!a(this,E)||a(this,E).isFulfilled)&&d(this,E,new x),this.type){case"array":{let e=a(this,at);this.value?this.value[U](e):this.value=new G(this.publicationName,this.params,e,!1);break}case"map":{let e=a(this,at);this.value?this.value[U](e):this.value=new M(this.publicationName,this.params,e,!1);break}default:{let e=a(this,at);this.value?this.value[U](e):this.value=new F(this.publicationName,this.params,e,!1)}}if(this.group.values.push(this.value),this.group.values[this.name]=this.value,this.onBeforeInit)switch(this.type){case"array":this.onBeforeInit.call(this.group,this.value);break;case"map":this.onBeforeInit.call(this.group,this.value);break;default:this.onBeforeInit.call(this.group,this.value)}}},J=new WeakMap,at=new WeakMap,Rt=function(){if(a(this,J)){if(this.handle)switch(this.type){case"array":this.handle.call(this.group,a(this,J),this.group);break;case"map":this.handle.call(this.group,a(this,J),this.group);break;default:this.handle.call(this.group,a(this,J),this.group)}d(this,J,null),this.emit("load",this.value),a(this,R).resolve(this),a(this,E).isFulfilled&&d(this,E,new x)}},Et=function(){this.emit("init",this.value),a(this,K).resolve(this)},Ut=function(){if(this.handle)switch(this.type){case"array":this.handle.call(this.group,null,this.group);break;case"map":this.handle.call(this.group,null,this.group);break;default:this.handle.call(this.group,null,this.group)}this.emit("unload",this.value),a(this,E).resolve(this),a(this,R).isFulfilled&&d(this,R,new x)},i(bt,"debounceLimit",4),v.itemLoad=t=>{var e;return g(e=t,w,Rt).call(e)},v.itemInit=t=>{var e;return g(e=t,w,Et).call(e)},v.itemUnload=t=>{var e;return g(e=t,w,Ut).call(e)};var mt=bt;function ee(o){return Array.isArray(o)}function Wt(o){if(ee(o)){let s=o.slice(),t={};if(t.name=s.shift(),typeof s[0]=="object"&&!Array.isArray(s[0])){if(t.value=s.shift(),t.type=t.value.toString().match(/Subscription(Object|Array|Map)/)?.[1].toLowerCase(),!t.type)throw new Error("Unknown value type")}else typeof s[0]=="string"&&(t.type=s.shift()),typeof s[0]=="string"&&(t.publicationName=s.shift()),Array.isArray(s[0])&&(t.params=s.shift());return typeof s[0]=="function"&&(t.handle=s.shift()),typeof s[0]=="function"&&(t.onBeforeInit=s.shift()),typeof s[0]=="number"&&(t.debounce=s.shift()),typeof s[0]=="boolean"&&(t.preventBind=s.shift()),t}return o.type??(o.type="object"),o}var W,ut,N,Z,C,It,Ct,vt,St=class St extends te{constructor(t,{target:e,debounce:r=St.debounceLimit,immediately:n}={}){super();h(this,C);i(this,"target");i(this,"emitUpdate");i(this,"items",[]);i(this,"values",[]);i(this,"isLoaded",!1);i(this,"isInited",!1);h(this,W);h(this,ut);h(this,N);h(this,Z,null);this.applyOptions({target:e,debounceLimit:r}),d(this,ut,new x),this.attach(t,!1,n)}applyOptions({target:t,debounceLimit:e}){if(this.target!==t){if(this.target)for(let r of this.items)r.isLoaded&&!r.preventBind&&delete this.target[r.name];if(this.target=t,this.target)for(let r of this.items)r.isLoaded&&!r.preventBind&&(this.target[r.name]=r.value)}if(a(this,Z)!==e)if(d(this,Z,e),typeof a(this,Z)=="number"){let r=lt(()=>this.emit("update",this.values),a(this,Z));this.emitUpdate=()=>r()}else this.emitUpdate=()=>this.emit("update",this.values)}attach(t,e=this.isLoaded,r=!0){return e&&(this.isLoaded=!1),(!a(this,W)||a(this,W).isFulfilled)&&d(this,W,new x),(!a(this,N)||a(this,N).isFulfilled)&&d(this,N,new x),Promise.all(t.map(n=>new mt(Wt(n),this)).map(n=>(r&&n.subscribe(),n.loaded())))}detach(t,e=!0){for(let r of t)this.items[r]?.detach();e&&(g(this,C,vt).call(this),g(this,C,It).call(this))}redefine(t){let e=new Map(this.items.map(u=>[u.name,u])),r=[],n=[];for(let u of t)u=Wt(u),e.delete(u.name)?r.push(u):n.push(u);return this.isLoaded=!1,this.detach([...e.keys()],!1),Promise.all([...r.map(u=>{let f=this.items[u.name];return f.define(u),f.subscribe(),f.loaded()}),...n.length?[this.attach(n,!1)]:[]])}subscribe(){return this.items.map(t=>t.subscribe())}unsubscribe(){return this.items.map(t=>t.unsubscribe())}loaded(){return a(this,W)}inited(){return a(this,ut)}unloaded(){return a(this,N)}valueOf(){return this.values}[Symbol.iterator](){return this.values[Symbol.iterator]()}};W=new WeakMap,ut=new WeakMap,N=new WeakMap,Z=new WeakMap,C=new WeakSet,It=function(){if(!this.isLoaded&&this.items.every(t=>t.isLoaded)){if(this.target)for(let t of this.items)t.preventBind||(this.target[t.name]=t.value);this.isLoaded=!0;for(let t of this.items)v.itemLoad(t);if(this.emit("load",this.values),this.isInited)if(this.items.length)for(let t of this.items)t.emitUpdate();else this.emitUpdate();a(this,W).resolve(this),a(this,N).isFulfilled&&d(this,N,new x)}},Ct=function(){if(!this.isInited&&this.items.every(t=>t.isInited)){if(this.isInited=!0,this.isLoaded)if(this.items.length)for(let t of this.items)t.emitUpdate();else this.emitUpdate();for(let t of this.items)v.itemInit(t);this.emit("init",this.values),a(this,ut).resolve(this)}},vt=function(){if(this.isLoaded&&this.items.every(t=>!t.isLoaded)){if(this.target)for(let t of this.items)t.preventBind||delete this.target[t.name];this.isLoaded=!1;for(let t of this.items)v.itemUnload(t);if(this.emit("unload",this.values),this.items.length)for(let t of this.items)t.emitUpdate();else this.emitUpdate();a(this,N).resolve(this),a(this,W).isFulfilled&&d(this,W,new x)}},i(St,"debounceLimit",8),v.groupLoad=t=>{var e;return g(e=t,C,It).call(e)},v.groupInit=t=>{var e;return g(e=t,C,Ct).call(e)},v.groupUnload=t=>{var e;return g(e=t,C,vt).call(e)};var Nt=St;export{q as Subscription,P as SubscriptionArray,G as SubscriptionArrayWithSubscription,Nt as SubscriptionGroup,T as SubscriptionMap,M as SubscriptionMapWithSubscription,k as SubscriptionObject,F as SubscriptionObjectWithSubscription,_ as clearSymbol,H as getAsInitialUpdatedSymbol,D as getAsUpdatesSymbol,zt as getHandleSubscriptionSymbol,A as getHandleUpdateSymbol,$ as getSubscriptionSymbol,j as renewSymbol,Kt as setHandleSubscriptionSymbol,U as setHandleUpdateSymbol,y as subscribeSymbol,I as unsubscribeSymbol,O as updateSymbol};
|
|
1
|
+
var qt=Object.defineProperty;var Tt=o=>{throw TypeError(o)};var zt=(o,s,t)=>s in o?qt(o,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[s]=t;var i=(o,s,t)=>zt(o,typeof s!="symbol"?s+"":s,t),yt=(o,s,t)=>s.has(o)||Tt("Cannot "+t);var a=(o,s,t)=>(yt(o,s,"read from private field"),t?t.call(o):s.get(o)),h=(o,s,t)=>s.has(o)?Tt("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(o):s.set(o,t),f=(o,s,t,e)=>(yt(o,s,"write to private field"),e?e.call(o,t):s.set(o,t),t),x=(o,s,t)=>(yt(o,s,"access private method"),t);var wt,it,_,z=class{constructor(s,t,e=[],r,n=!0){i(this,"i");i(this,"type");i(this,"publicationName");i(this,"args");i(this,"handler");i(this,"immediately");i(this,"isActive");i(this,"start",()=>{_.sendMessage("s-s",this.type,this.publicationName,this.i,this.args,this.immediately),this.immediately=!0});if(!_)throw new Error("Subscription is not binded to WS. Do Subscription.bindTo(ws) first");this.i=wt++,this.type=s,this.publicationName=t,this.args=e,this.handler=r,this.immediately=n&&!globalThis.__initials,it.set(this.i,this),_.on("open",this.start),_.isOpen&&this.start(),globalThis.__initials?(this.isActive=!0,this.handler(globalThis.__initials.splice(0,1)[0])):this.isActive=!1}cancel(){it.delete(this.i),_.off("open",this.start),_.sendMessage("s-u",this.i)}static bindTo(s){_=s,wt=0,it=new Map,_.on("message:s-c",(t,e)=>{let r=it.get(t);r&&(r.isActive=!0,r.handler(e))}),_.on("close",()=>{for(let t of it.values())t.isActive=!1}),_.on("server-change",()=>{for(let t of it.values())t.handler(null)})}};function K(){}var lt=new WeakMap,S=class o extends Promise{constructor(t,e){let r,n;super((u,d)=>{r=u,n=d});i(this,"isPending",!0);i(this,"isFulfilled",!1);i(this,"isRejected",!1);i(this,"state","pending");i(this,"result");i(this,"resolve",t=>{if(this.isPending){this.isPending=!1,this.isFulfilled=!0,this.state="fulfilled",this.result=t;let e=lt.get(this);e&&(e.resolve.call(this,t),lt.delete(this))}});i(this,"reject",t=>{if(this.isPending){this.isPending=!1,this.isRejected=!0,this.state="rejected",this.result=t;let e=lt.get(this);e&&(e.reject.call(this,t),lt.delete(this))}});if(lt.set(this,{resolve:r,reject:n}),e?.signal)if(e.signal.aborted)this.reject(new DOMException("Aborted","AbortError"));else{let u=()=>this.reject(new DOMException("Aborted","AbortError"));e.signal.addEventListener("abort",u),this.finally(()=>e.signal?.removeEventListener("abort",u))}if(typeof e?.timeout=="number"&&Number.isFinite(e.timeout)){let u=setTimeout(()=>this.reject(new DOMException("Timeout exceeded","TimeoutError")),e.timeout);this.finally(()=>clearTimeout(u))}t?.(this.resolve,this.reject)}static resolved(t){return new o(e=>e(t))}static rejected(t){return new o((e,r)=>r(t))}};function ct(o,s=0,t={}){let{leading:e=!1,trailing:r=!0}=t,{maxWait:n=1/0}=t,u,d,p,c,b,l,m,y,ht=async()=>{let J=Date.now();J>=p?(u=void 0,p=void 0,clearTimeout(d),d=void 0,typeof m=="function"&&await m(),V.resolve(y),l=e):(clearTimeout(u),u=setTimeout(ht,p-J))},pt=Number.isFinite(n)?()=>{m===Y&&(m=!1),Y(),d=setTimeout(pt,n)}:null;async function Y(){try{return y=await o.apply(c,b),y}catch(J){throw V.reject(J),J}}e&&typeof e=="boolean"&&(e=Y),l=e,r&&typeof r=="boolean"&&(r=Y),m=r;let V=Object.assign(function(...J){return b=J,c=this,p=Date.now()+s,m=r,V.promise.isPending||(V.promise=new S((Vt,Jt)=>{V.resolve=Vt,V.reject=Jt,typeof l=="function"&&(l(),l=!1,m===Y&&(m=!1)),u||(u=setTimeout(ht,s),pt&&(d=setTimeout(pt,n)))})),V.promise},{callback:o,promise:S.resolved(void 0),resolve:K,reject:K,run:Y,clear:async J=>{clearTimeout(u),u=void 0,clearTimeout(d),d=void 0,V.resolve(J?await Y():y)}});return V}ct.noop=Object.assign(()=>{},{callback:K,promise:S.resolved(void 0),resolve:K,reject:K,run:K,clear:K});function At(o,s,t,e,r=!0){return Array.isArray(o)&&(o=o.length),typeof e!="string"&&(r=e??!0,e=t),(r?`${o}\xA0`:"")+At.raw(o,s,t,e)}At.raw=(o,s,t,e=t)=>{o=Math.abs(o);let r=o%10,n=o%100;return r===1&&n!==11?s:r>=2&&r<=4&&!(n>=12&&n<=15)?t:e};function Z(o,s){let t=o.indexOf(s);return t>-1?(o.splice(t,1),!0):!1}function Dt(o){return[...new Set(o)]}var A=Symbol("update"),D=Symbol("getHandleUpdate"),U=Symbol("setHandleUpdate"),O=Symbol("getAsUpdates"),H=Symbol("getAsInitialUpdated"),L=Symbol("clear"),g=Symbol("subscribe"),I=Symbol("unsubscribe"),j=Symbol("renew"),M=Symbol("getSubscription"),Kt=Symbol("getHandleSubscription"),Xt=Symbol("setHandleSubscription");var Qt=(o,s)=>o>s?1:o<s?-1:0,Yt=(o,s)=>o>s?-1:o<s?1:0,Ot,Ht,jt,Pt,P=class extends Array{constructor(t,e){super();i(this,"sorted",[]);i(this,"handleUpdate");i(this,"sortDirection",0);i(this,"sortCompareFunction",null);i(this,Pt,this.update);i(this,jt,this.getAsUpdates);i(this,Ht,this.getAsInitialUpdated);i(this,Ot,this.clear);e&&(this.handleUpdate=e),Array.isArray(t)&&this.update(t)}[D](){return this.handleUpdate}[U](t){return this.handleUpdate=t}update(t){let e=Object.assign([],{deleted:[],added:[]});if(t){let r=!1;for(let n of t)switch(n?.[0]){case"i":{let[,u,d]=n;d?(this.sortDirection=d,this.sortCompareFunction=d>0?Qt:Yt,r=!0):(this.sortDirection=0,this.sortCompareFunction=null),this.length=0;for(let p of u)this.push(p),e.push(p),e.added.push(p);break}case"a":{let[,u]=n;this.includes(u)||(this.push(u),this.sortDirection&&(r=!0),e.push(u),e.added.push(u));break}case"d":{let[,u]=n;Z(this,u)&&e.deleted.push(u);break}default:this.clear()}r&&this.sortCompareFunction&&this.sort(this.sortCompareFunction)}else this.clear();return this.handleUpdate?.(this,e,t?.[0]?t:null),this}getAsUpdates(){return this.length||this.sortDirection?[["i",[...this],this.sortDirection]]:null}getAsInitialUpdated(){return Object.assign([...this.sorted],{added:[...this.sorted],deleted:[]})}clear(){this.length=0,this.sortDirection=0,this.sortCompareFunction=null}valueOf(){return this}get[(Pt=A,jt=O,Ht=H,Ot=L,Symbol.toStringTag)](){return"SubscriptionArray"}};i(P,"updateSymbol",A),i(P,"getHandleUpdateSymbol",D),i(P,"setHandleUpdateSymbol",U),i(P,"getAsUpdatesSymbol",O),i(P,"getAsInitialUpdatedSymbol",H),i(P,"clearSymbol",L),i(P,"WithSubscription");var $=class extends P{constructor(t,e,r,n=!0){super(null,r);i(this,"publicationName");i(this,"params");i(this,"subscription",null);this.publicationName=t,this.params=e,n&&this.subscribe()}subscribe(){this.subscription||(this.subscription=new z("array",this.publicationName,this.params,t=>this.update(t)))}get[g](){return this.subscribe}unsubscribe(){this.subscription&&(this.subscription.cancel(),this.subscription=null)}get[I](){return this.unsubscribe}renew(t,e){this.subscription&&(this.unsubscribe(),t&&(Array.isArray(t)?e=t:this.publicationName=t),e&&(this.params=e),this.subscribe())}get[j](){return this.renew}[M](){return this.subscription}get[Symbol.toStringTag](){return"SubscriptionArrayWithSubscription"}};i($,"subscribeSymbol",g),i($,"unsubscribeSymbol",I),i($,"renewSymbol",j),i($,"getSubscriptionSymbol",M);P.WithSubscription=$;import ee from"eventemitter3";var v={};import te from"eventemitter3";function Zt(o){let s=document.createElement("script");s.textContent=`window.__insite_subscription_map_sort_function = function sort(a, b) { return ${Object.entries(o).map(([e,r])=>(e.includes(".")&&(e=e.replaceAll(".","?.")),r>0?`a.${e} > b.${e} ? 1 : a.${e} < b.${e} ? -1 :`:`a.${e} < b.${e} ? 1 : a.${e} > b.${e} ? -1 :`)).concat("0").join(" ")};}`,document.head.append(s);let t=globalThis.__insite_subscription_map_sort_function;return s.remove(),delete globalThis.__insite_subscription_map_sort_function,t}var kt,Lt,_t,Mt,st,tt,rt,T=class extends Map{constructor(t,e){super();i(this,"handleUpdate");h(this,st,new Map);i(this,"sortList",null);i(this,"sortCompareFunction",null);h(this,tt,[]);i(this,"sorted",[]);h(this,rt);i(this,Mt,this.update);i(this,_t,this.getAsUpdates);i(this,Lt,this.getAsInitialUpdated);i(this,kt,this.clear);e&&(this.handleUpdate=e),t&&this.update(t)}sort(){this.sortCompareFunction&&this.sorted.sort(this.sortCompareFunction)}[D](){return this.handleUpdate}[U](t){return this.handleUpdate=t}set Item(t){if(f(this,rt,t),this.size)for(let[e,r]of this)this.set(e,new t(this,r))}get Item(){return a(this,rt)}update(t){let e=Object.assign([],{added:[],deleted:[]});if(t){let r=!1,n=a(this,rt),u=a(this,st);for(let d of t)switch(d?.[0]){case"i":{let[,p,c]=d;if(c?(this.sortList=c,this.sortCompareFunction=Zt(c),f(this,tt,Dt(Object.keys(c).map(b=>b.replace(/\..+/,"")))),r=!0):(this.sortList=null,this.sortCompareFunction=null,f(this,tt,[])),this.size){let b=new Map;for(let l of p)b.set(l._id,l);for(let[l,m]of this){let y=b.get(l);if(y){let ht=u.get(l);if(n)m.update(y);else{for(let pt in ht)delete m[pt];Object.assign(m,y)}u.set(l,y),e.push(m),b.delete(l)}else n?m.delete():this.delete(l),u.delete(l),e.deleted.push(l)}for(let[l,m]of b){let y=n?new n(this,m):{...m};this.set(l,y),u.set(l,m),e.push(y),e.added.push(y)}this.sortList&&(this.sorted=p.map(l=>this.get(l._id)))}else for(let b of p){let l=n?new n(this,b):{...b};this.set(l._id,l),this.sorted.push(l),u.set(l._id,b),e.push(l),e.added.push(l)}break}case"c":case"u":{let[,p]=d,c=this.get(p._id);if(c){let b=d[2]===!0,l=b?Object.keys(p):d[2],m=u.get(c._id);if(n)c.update(p);else{if(!b)for(let y in m)delete c[y];Object.assign(c,p)}b&&(p=Object.assign(m,p)),this.sortList&&!r&&(!l||l.some(y=>a(this,tt).includes(y)))&&(r=!0),console.log("\u2B55\uFE0F\u{1F7E2}\u2B55\uFE0F\u{1F7E2}\u2B55\uFE0F shouldSort",r)}else c=n?new n(this,p):{...p},this.set(c._id,c),this.sorted.push(c),this.sortList&&(r=!0),e.added.push(c);u.set(c._id,p),e.push(c);break}case"d":{let[,p]=d,c=this.get(p);c&&(n?c.delete():this.delete(p),u.delete(p),Z(this.sorted,c),e.deleted.push(p));break}default:this.clear()}r&&this.sort()}else this.clear();return this.handleUpdate?.(this,e,t?.[0]?t:null),this}getAsUpdates(){return this.size||this.sortList?[["i",[...a(this,st).values()],this.sortList]]:null}getAsInitialUpdated(){return Object.assign([...this.sorted],{added:[...this.sorted],deleted:[]})}clear(){super.clear(),a(this,st).clear(),this.sorted=[],this.sortList=null,this.sortCompareFunction=null,f(this,tt,[])}valueOf(){return this.sorted}get[(Mt=A,_t=O,Lt=H,kt=L,Symbol.toStringTag)](){return"SubscriptionMap"}};st=new WeakMap,tt=new WeakMap,rt=new WeakMap,i(T,"updateSymbol",A),i(T,"getHandleUpdateSymbol",D),i(T,"setHandleUpdateSymbol",U),i(T,"getAsUpdatesSymbol",O),i(T,"getAsInitialUpdatedSymbol",H),i(T,"clearSymbol",L),i(T,"WithSubscription"),i(T,"Item");var G=class extends T{constructor(t,e,r,n=!0){super(null,r);i(this,"publicationName");i(this,"params");i(this,"subscription",null);this.publicationName=t,this.params=e,n&&this.subscribe()}subscribe(){this.subscription||(this.subscription=new z("map",this.publicationName,this.params,t=>this.update(t)))}get[g](){return this.subscribe}unsubscribe(){this.subscription&&(this.subscription.cancel(),this.subscription=null)}get[I](){return this.unsubscribe}renew(t,e){this.subscription&&(this.unsubscribe(),t&&(Array.isArray(t)?e=t:this.publicationName=t),e&&(this.params=e),this.subscribe())}get[j](){return this.renew}[M](){return this.subscription}get[Symbol.toStringTag](){return"SubscriptionMapWithSubscription"}};i(G,"subscribeSymbol",g),i(G,"unsubscribeSymbol",I),i(G,"renewSymbol",j),i(G,"getSubscriptionSymbol",M);T.WithSubscription=G;var dt,gt=class{constructor(s,t){i(this,"_id");h(this,dt);f(this,dt,s),this.update(t)}update(s){Object.assign(this,s)}delete(){a(this,dt).delete(this._id)}};dt=new WeakMap;T.Item=gt;var ft=Symbol("handleUpdate"),X=Symbol("updates"),$t,Gt,k=class{constructor(s,t){i(this,Gt);i(this,$t,null);t&&(this[ft]=t),s&&this[A](s)}[(Gt=ft,$t=X,D)](){return this[ft]}[U](s){return this[ft]=s}[A](s){if(s){for(let t in this[X])delete this[t];for(let t in s)this[t]=s[t];this[X]=s}else this[L]();return this[ft]?.(this,this,this[X]),this}[O](){return this[X]&&{...this[X]}}[H](){return this.valueOf()}[L](){for(let s in this)delete this[s];this[X]=null}valueOf(){return this[X]&&this}get[Symbol.toStringTag](){return"SubscriptionObject"}};i(k,"updateSymbol",A),i(k,"getHandleUpdateSymbol",D),i(k,"setHandleUpdateSymbol",U),i(k,"getAsUpdatesSymbol",O),i(k,"getAsInitialUpdatedSymbol",H),i(k,"clearSymbol",L),i(k,"WithSubscription");var ot,nt,B,E=class extends k{constructor(t,e,r,n=!0){super(null,r);h(this,ot);h(this,nt);h(this,B,null);f(this,ot,t),f(this,nt,e),n&&this[g]()}[g](){a(this,B)||f(this,B,new z("object",a(this,ot),a(this,nt),t=>this[A](t)))}[I](){a(this,B)&&(a(this,B).cancel(),f(this,B,null))}[j](t,e){a(this,B)&&(this[I](),t&&(Array.isArray(t)?e=t:f(this,ot,t)),e&&f(this,nt,e),this[g]())}[M](){return a(this,B)}get[Symbol.toStringTag](){return"SubscriptionObjectWithSubscription"}};ot=new WeakMap,nt=new WeakMap,B=new WeakMap,i(E,"subscribeSymbol",g),i(E,"unsubscribeSymbol",I),i(E,"renewSymbol",j),i(E,"getSubscriptionSymbol",M);k.WithSubscription=E;function Bt(o){return Array.isArray(o)}var F,Q,N,w,xt,Et,q,at,Ft,Nt,Ut,bt=class bt extends te{constructor(t,e){super();h(this,w);i(this,"name");i(this,"group");i(this,"value");i(this,"type");i(this,"publicationName");i(this,"params");i(this,"handle");i(this,"onBeforeInit");i(this,"preventBind");i(this,"emitUpdate");i(this,"isLoaded",!1);i(this,"isInited",!1);h(this,F);h(this,Q);h(this,N);h(this,q,null);h(this,at,(t,e,r)=>{if(r)if(this.group.isLoaded){if(this.handle)switch(this.type){case"array":this.handle.call(this.group,e,this.group);break;case"map":this.handle.call(this.group,e,this.group);break;default:this.handle.call(this.group,e,this.group)}this.emitUpdate(e)}else f(this,q,e),this.isLoaded=!0,v.groupLoad(this.group);else this.isLoaded&&(this.isLoaded=!1,v.groupUnload(this.group));this.isInited||(this.isInited=!0,v.groupInit(this.group))});this.name=t.name,this.define(t,e)}define(t,e=this.group){if(!e)throw new Error("group is undefined");let{value:r,type:n="object",publicationName:u,params:d,handle:p,onBeforeInit:c,debounce:b=bt.debounceLimit,preventBind:l}=t;if(this.group){if((!r||this.value===r)&&this.type===n&&this.publicationName===u&&JSON.stringify(this.params)===JSON.stringify(d)&&this.handle===p&&this.onBeforeInit===c)return x(this,w,xt).call(this,{debounceLimit:b,preventBind:l});this.detach(),delete this.value,delete this.publicationName,delete this.params}this.type=n,this.handle=p,this.onBeforeInit=c,r?this.value=r:(this.publicationName=u??this.name,this.params=d??[]),x(this,w,xt).call(this,{debounceLimit:b,preventBind:l}),x(this,w,Et).call(this,e)}detach(){this.group&&(this.value?.[I](),this.isLoaded=!1,x(this,w,Ut).call(this),delete this.group.values[this.name],Z(this.group.values,this.value),delete this.group.items[this.name],Z(this.group.items,this),delete this.group)}loaded(){return a(this,F)}inited(){return a(this,Q)}unloaded(){return a(this,N)}subscribe(){if(this.value){if(this.value[g])return this.value[g]();{let t=this.value[D]();if(t){let e=this.value[H](),r=this.value[O]();switch(this.type){case"array":return t(this.value,e,r);case"map":return t(this.value,e,r);default:return t(this.value,e,r)}}}}}unsubscribe(){return this.value?.[I]?.()}renew(t,e){return this.value?.[j]?.(t,e)}valueOf(){return this.value}};F=new WeakMap,Q=new WeakMap,N=new WeakMap,w=new WeakSet,xt=function({debounceLimit:t,preventBind:e}){let r=n=>{this.emit("update",this.value,n),this.group?.emit(`update.${this.name}`,this.value,n),this.group?.emitUpdate()};if(typeof t=="number"){let n,u,d=ct(()=>{let p=!this.group;p&&(this.group=u),r(n),p&&delete this.group,n=void 0},t);this.emitUpdate=p=>{if(p!==void 0)if(Bt(p))if(Bt(n))for(let c of p)n.push(c);else n=Object.assign([...p],{added:[...p.added],deleted:[...p.deleted]});else typeof p=="object"?n?Object.assign(n,p):n={...p}:n=p;return u=this.group,d()}}else this.emitUpdate=r;this.preventBind===void 0?delete this.preventBind:this.preventBind=e},Et=function(t){if(!this.group){switch(this.group=t,this.group.items.push(this),this.group.items[this.name]=this,(!a(this,F)||a(this,F).isFulfilled)&&f(this,F,new S),(!a(this,Q)||a(this,Q).isFulfilled)&&f(this,Q,new S),(!a(this,N)||a(this,N).isFulfilled)&&f(this,N,new S),this.type){case"array":{let e=a(this,at);this.value?this.value[U](e):this.value=new $(this.publicationName,this.params,e,!1);break}case"map":{let e=a(this,at);this.value?this.value[U](e):this.value=new G(this.publicationName,this.params,e,!1);break}default:{let e=a(this,at);this.value?this.value[U](e):this.value=new E(this.publicationName,this.params,e,!1)}}if(this.group.values.push(this.value),this.group.values[this.name]=this.value,this.onBeforeInit)switch(this.type){case"array":this.onBeforeInit.call(this.group,this.value);break;case"map":this.onBeforeInit.call(this.group,this.value);break;default:this.onBeforeInit.call(this.group,this.value)}}},q=new WeakMap,at=new WeakMap,Ft=function(){if(a(this,q)){if(this.handle)switch(this.type){case"array":this.handle.call(this.group,a(this,q),this.group);break;case"map":this.handle.call(this.group,a(this,q),this.group);break;default:this.handle.call(this.group,a(this,q),this.group)}f(this,q,null),this.emit("load",this.value),a(this,F).resolve(this),a(this,N).isFulfilled&&f(this,N,new S)}},Nt=function(){this.emit("init",this.value),a(this,Q).resolve(this)},Ut=function(){if(this.handle)switch(this.type){case"array":this.handle.call(this.group,null,this.group);break;case"map":this.handle.call(this.group,null,this.group);break;default:this.handle.call(this.group,null,this.group)}this.emit("unload",this.value),a(this,N).resolve(this),a(this,F).isFulfilled&&f(this,F,new S)},i(bt,"debounceLimit",4),v.itemLoad=t=>{var e;return x(e=t,w,Ft).call(e)},v.itemInit=t=>{var e;return x(e=t,w,Nt).call(e)},v.itemUnload=t=>{var e;return x(e=t,w,Ut).call(e)};var mt=bt;function ie(o){return Array.isArray(o)}function Wt(o){if(ie(o)){let s=o.slice(),t={};if(t.name=s.shift(),typeof s[0]=="object"&&!Array.isArray(s[0])){if(t.value=s.shift(),t.type=t.value.toString().match(/Subscription(Object|Array|Map)/)?.[1].toLowerCase(),!t.type)throw new Error("Unknown value type")}else typeof s[0]=="string"&&(t.type=s.shift()),typeof s[0]=="string"&&(t.publicationName=s.shift()),Array.isArray(s[0])&&(t.params=s.shift());return typeof s[0]=="function"&&(t.handle=s.shift()),typeof s[0]=="function"&&(t.onBeforeInit=s.shift()),typeof s[0]=="number"&&(t.debounce=s.shift()),typeof s[0]=="boolean"&&(t.preventBind=s.shift()),t}return o.type??(o.type="object"),o}var W,ut,R,et,C,It,Ct,vt,St=class St extends ee{constructor(t,{target:e,debounce:r=St.debounceLimit,immediately:n}={}){super();h(this,C);i(this,"target");i(this,"emitUpdate");i(this,"items",[]);i(this,"values",[]);i(this,"isLoaded",!1);i(this,"isInited",!1);h(this,W);h(this,ut);h(this,R);h(this,et,null);this.applyOptions({target:e,debounceLimit:r}),f(this,ut,new S),this.attach(t,!1,n)}applyOptions({target:t,debounceLimit:e}){if(this.target!==t){if(this.target)for(let r of this.items)r.isLoaded&&!r.preventBind&&delete this.target[r.name];if(this.target=t,this.target)for(let r of this.items)r.isLoaded&&!r.preventBind&&(this.target[r.name]=r.value)}if(a(this,et)!==e)if(f(this,et,e),typeof a(this,et)=="number"){let r=ct(()=>this.emit("update",this.values),a(this,et));this.emitUpdate=()=>r()}else this.emitUpdate=()=>this.emit("update",this.values)}attach(t,e=this.isLoaded,r=!0){return e&&(this.isLoaded=!1),(!a(this,W)||a(this,W).isFulfilled)&&f(this,W,new S),(!a(this,R)||a(this,R).isFulfilled)&&f(this,R,new S),Promise.all(t.map(n=>new mt(Wt(n),this)).map(n=>(r&&n.subscribe(),n.loaded())))}detach(t,e=!0){for(let r of t)this.items[r]?.detach();e&&(x(this,C,vt).call(this),x(this,C,It).call(this))}redefine(t){let e=new Map(this.items.map(u=>[u.name,u])),r=[],n=[];for(let u of t)u=Wt(u),e.delete(u.name)?r.push(u):n.push(u);return this.isLoaded=!1,this.detach([...e.keys()],!1),Promise.all([...r.map(u=>{let d=this.items[u.name];return d.define(u),d.subscribe(),d.loaded()}),...n.length?[this.attach(n,!1)]:[]])}subscribe(){return this.items.map(t=>t.subscribe())}unsubscribe(){return this.items.map(t=>t.unsubscribe())}loaded(){return a(this,W)}inited(){return a(this,ut)}unloaded(){return a(this,R)}valueOf(){return this.values}[Symbol.iterator](){return this.values[Symbol.iterator]()}};W=new WeakMap,ut=new WeakMap,R=new WeakMap,et=new WeakMap,C=new WeakSet,It=function(){if(!this.isLoaded&&this.items.every(t=>t.isLoaded)){if(this.target)for(let t of this.items)t.preventBind||(this.target[t.name]=t.value);this.isLoaded=!0;for(let t of this.items)v.itemLoad(t);if(this.emit("load",this.values),this.isInited)if(this.items.length)for(let t of this.items)t.emitUpdate();else this.emitUpdate();a(this,W).resolve(this),a(this,R).isFulfilled&&f(this,R,new S)}},Ct=function(){if(!this.isInited&&this.items.every(t=>t.isInited)){if(this.isInited=!0,this.isLoaded)if(this.items.length)for(let t of this.items)t.emitUpdate();else this.emitUpdate();for(let t of this.items)v.itemInit(t);this.emit("init",this.values),a(this,ut).resolve(this)}},vt=function(){if(this.isLoaded&&this.items.every(t=>!t.isLoaded)){if(this.target)for(let t of this.items)t.preventBind||delete this.target[t.name];this.isLoaded=!1;for(let t of this.items)v.itemUnload(t);if(this.emit("unload",this.values),this.items.length)for(let t of this.items)t.emitUpdate();else this.emitUpdate();a(this,R).resolve(this),a(this,W).isFulfilled&&f(this,W,new S)}},i(St,"debounceLimit",8),v.groupLoad=t=>{var e;return x(e=t,C,It).call(e)},v.groupInit=t=>{var e;return x(e=t,C,Ct).call(e)},v.groupUnload=t=>{var e;return x(e=t,C,vt).call(e)};var Rt=St;export{z as Subscription,P as SubscriptionArray,$ as SubscriptionArrayWithSubscription,Rt as SubscriptionGroup,T as SubscriptionMap,G as SubscriptionMapWithSubscription,k as SubscriptionObject,E as SubscriptionObjectWithSubscription,L as clearSymbol,H as getAsInitialUpdatedSymbol,O as getAsUpdatesSymbol,Kt as getHandleSubscriptionSymbol,D as getHandleUpdateSymbol,M as getSubscriptionSymbol,j as renewSymbol,Xt as setHandleSubscriptionSymbol,U as setHandleUpdateSymbol,g as subscribeSymbol,I as unsubscribeSymbol,A as updateSymbol};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/Subscription.ts", "../../../../@nesvet/npm/n/src/noop.ts", "../../../../@nesvet/npm/n/src/
|
|
4
|
-
"sourcesContent": ["import type { WS } from \"insite-ws/client\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\ndeclare global {\n\tvar __initials: unknown[] | undefined;// eslint-disable-line no-var\n}\n\n\nlet i: number;\nlet subscriptions: Map<number, Subscription>;\nlet ws: WS;\n\n\nexport class Subscription {\n\tconstructor(type: \"array\" | \"map\" | \"object\", publicationName: string, args: unknown[] = [], handler: (updates: any) => void, immediately = true) {\n\t\t\n\t\tif (!ws)\n\t\t\tthrow new Error(\"Subscription is not binded to WS. Do Subscription.bindTo(ws) first\");\n\t\t\n\t\tthis.i = i++;\n\t\tthis.type = type;\n\t\tthis.publicationName = publicationName;\n\t\tthis.args = args;\n\t\tthis.handler = handler;\n\t\tthis.immediately = immediately && !globalThis.__initials;\n\t\t\n\t\tsubscriptions.set(this.i, this);\n\t\t\n\t\tws.on(\"open\", this.start);\n\t\t\n\t\tif (ws.isOpen)\n\t\t\tthis.start();\n\t\t\n\t\tif (globalThis.__initials) {\n\t\t\tthis.isActive = true;\n\t\t\tthis.handler(globalThis.__initials.splice(0, 1)[0]);\n\t\t} else\n\t\t\tthis.isActive = false;\n\t\t\n\t}\n\t\n\ti;\n\ttype;\n\tpublicationName;\n\targs;\n\thandler;\n\timmediately;\n\tisActive;\n\t\n\tstart = () => {\n\t\t\n\t\tws.sendMessage(\"s-s\"/* subscription subscribe */, this.type, this.publicationName, this.i, this.args, this.immediately);\n\t\t\n\t\tthis.immediately = true;\n\t\t\n\t};\n\t\n\tcancel() {\n\t\t\n\t\tsubscriptions.delete(this.i);\n\t\t\n\t\tws.off(\"open\", this.start);\n\t\t\n\t\tws.sendMessage(\"s-u\"/* subscription unsubscribe */, this.i);\n\t\t\n\t}\n\t\n\t\n\tstatic bindTo(_ws: WS) {\n\t\tws = _ws;\n\t\t\n\t\ti = 0;\n\t\t\n\t\tsubscriptions = new Map();\n\t\t\n\t\tws.on(\"message:s-c\"/* subscription changed */, (si: number, updates: any) => {\n\t\t\tconst subscription = subscriptions.get(si);\n\t\t\tif (subscription) {\n\t\t\t\tsubscription.isActive = true;\n\t\t\t\tsubscription.handler(updates);\n\t\t\t}\n\t\t\t\n\t\t});\n\t\t\n\t\tws.on(\"close\", () => {\n\t\t\t\n\t\t\tfor (const subscription of subscriptions.values())\n\t\t\t\tsubscription.isActive = false;\n\t\t\t\n\t\t});\n\t\t\n\t\tws.on(\"server-change\", () => {\n\t\t\t\n\t\t\tfor (const subscription of subscriptions.values())\n\t\t\t\tsubscription.handler(null);\n\t\t\t\n\t\t});\n\t\t\n\t}\n\t\n}\n", "export function noop() { /**/ }\n", "import { noop } from \"./noop.js\";\n\n\ntype Callback<Result> = (...args: unknown[]) => Result;\ntype FunctionOrBoolean = (() => unknown) | boolean;\ntype Options = { leading?: FunctionOrBoolean; maxWait?: number; trailing?: FunctionOrBoolean };\ntype NumberOrUndefined = number | undefined;\n\ntype DebouncedFunction<Result> = {\n\t(this: unknown, ..._args: unknown[]): Promise<Result>;\n};\n\nexport type Debounced<Result> = {\n\tcallback: Callback<Result>;\n\tpromise: {\n\t\tisResolved: boolean;\n\t} & Promise<unknown>;\n\tresolve: (value: Result) => void;\n\trun(): Promise<Result>;\n\tclear(shouldRun?: boolean): Promise<void>;\n} & DebouncedFunction<Result>;\n\n\nexport function debounce<Result>(callback: Callback<Result>, limit = 0, options: Options = {}) {\n\tlet { leading = false, trailing = true } = options;\n\tconst { maxWait = Infinity } = options;\n\t\n\tlet timeout: NumberOrUndefined;\n\tlet maxWaitTimeout: NumberOrUndefined;\n\tlet end: NumberOrUndefined;\n\tlet context: unknown;\n\tlet args: unknown[];\n\tlet initial: FunctionOrBoolean;\n\tlet final: FunctionOrBoolean;\n\tlet result: Result;\n\t\n\tconst expired = async () => {\n\t\t\n\t\tconst n = Date.now();\n\t\t\n\t\tif (n >= end!) {\n\t\t\ttimeout = undefined;\n\t\t\tend = undefined;\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\tif (typeof final == \"function\")\n\t\t\t\tawait final();\n\t\t\tdebounced.resolve(result);\n\t\t\tdebounced.promise.isResolved = true;\n\t\t\tinitial = leading;\n\t\t} else {\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = setTimeout(expired, end! - n);\n\t\t}\n\t\t\n\t};\n\t\n\tconst maxWaitExpired = Number.isFinite(maxWait) ? () => {\n\t\t\n\t\tif (final === run)\n\t\t\tfinal = false;\n\t\trun();\n\t\tmaxWaitTimeout = setTimeout(maxWaitExpired as TimerHandler, maxWait);\n\t\t\n\t} : null;\n\t\n\tasync function run() {\n\t\treturn (result = await callback.apply(context, args));\n\t}\n\t\n\tif (leading && typeof leading == \"boolean\")\n\t\tleading = run;\n\tinitial = leading;\n\t\n\tif (trailing && typeof trailing == \"boolean\")\n\t\ttrailing = run;\n\tfinal = trailing;\n\t\n\tconst debounced: Debounced<Result> = Object.assign(function (..._args) {\n\t\targs = _args;\n\t\tcontext = this;// eslint-disable-line no-invalid-this\n\t\t\n\t\tend = Date.now() + limit;\n\t\tfinal = trailing;\n\t\t\n\t\tif (debounced.promise.isResolved)\n\t\t\tdebounced.promise = Object.assign(new Promise(resolve => {\n\t\t\t\tdebounced.resolve = resolve;\n\t\t\t\t\n\t\t\t\tif (typeof initial == \"function\") {\n\t\t\t\t\tinitial();\n\t\t\t\t\tinitial = false;\n\t\t\t\t\tif (final === run)\n\t\t\t\t\t\tfinal = false;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!timeout) {\n\t\t\t\t\ttimeout = setTimeout(expired, limit);\n\t\t\t\t\tif (maxWaitExpired)\n\t\t\t\t\t\tmaxWaitTimeout = setTimeout(maxWaitExpired, maxWait);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}), {\n\t\t\t\tisResolved: false\n\t\t\t});\n\t\t\n\t\treturn debounced.promise;\n\t} as DebouncedFunction<Result>, {\n\t\tcallback,\n\t\tpromise: Object.assign(Promise.resolve(), {\n\t\t\tisResolved: true\n\t\t}),\n\t\tresolve: noop,\n\t\trun,\n\t\tclear: async (shouldRun?: boolean) => {\n\t\t\t\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = undefined;\n\t\t\t\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\t\n\t\t\tdebounced.promise.isResolved = true;\n\t\t\tdebounced.resolve(shouldRun ? await run() : result);\n\t\t\t\n\t\t}\n\t});\n\t\n\treturn debounced;\n}\n\n\ndebounce.noop = Object.assign(() => { /**/ }, {\n\tcallback: noop,\n\tpromise: Object.assign(Promise.resolve(), {\n\t\tisResolved: true\n\t}),\n\tresolve: noop,\n\trun: noop,\n\tclear: noop\n}) as unknown as Debounced<void>;\n\n\nexport function throttle<Result>(callback: Callback<Result>, limit?: number, options?: Options) {\n\treturn debounce(callback, limit, {\n\t\tmaxWait: limit,\n\t\tleading: true,\n\t\ttrailing: true,\n\t\t...options\n\t});\n}\n", "export function howmuch(number: [] | number, one: string, two: string, five: boolean | string, shouldPrintNumber = true) {\n\tif (Array.isArray(number))\n\t\tnumber = number.length;\n\t\n\tif (typeof five != \"string\") {\n\t\tshouldPrintNumber = five ?? true;\n\t\tfive = two;\n\t}\n\t\n\t\n\treturn (shouldPrintNumber ? `${number}\u00A0` : \"\") + howmuch.raw(number, one, two, five);\n}\n\nhowmuch.raw = (number: number, one: string, two: string, five = two) => {\n\tnumber = Math.abs(number);\n\tconst u = number % 10;\n\tconst d = number % 100;\n\t\n\treturn (\n\t\t(u === 1 && d !== 11) ?\n\t\t\tone :\n\t\t\t((u >= 2 && u <= 4) && !(d >= 12 && d <= 15)) ?\n\t\t\t\ttwo :\n\t\t\t\tfive\n\t);\n};\n", "export function removeOne<T>(array: T[], item: T): boolean {\n\tconst i = array.indexOf(item);\n\tif (i > -1) {\n\t\tarray.splice(i, 1);\n\t\t\n\t\treturn true;\n\t}\n\t\n\treturn false;\n}\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype Value<T> = PromiseLike<T> | T;\ntype Resolve<T> = (value: Value<T>) => void;\ntype Reject = (reason?: any) => void;\n\nconst nativesMap = new WeakMap<StatefulPromise<any>, { resolve: Resolve<any>; reject: Reject }>();\n\n\nexport class StatefulPromise<T> extends Promise<T> {\n\tconstructor(executor?: (resolve: Resolve<T>, reject: Reject) => void) {\n\t\t\n\t\tlet nativeResolve: Resolve<T>;\n\t\tlet nativeReject: Reject;\n\t\t\n\t\tsuper((resolve, reject) => {\n\t\t\tnativeResolve = resolve;\n\t\t\tnativeReject = reject;\n\t\t\t\n\t\t});\n\t\t\n\t\tnativesMap.set(this, { resolve: nativeResolve!, reject: nativeReject! });\n\t\t\n\t\texecutor?.(this.resolve, this.reject);\n\t\t\n\t}\n\t\n\tisPending = true;\n\tisFulfilled = false;\n\tisRejected = false;\n\t\n\tstate: \"fulfilled\" | \"pending\" | \"rejected\" = \"pending\";\n\t\n\tresult?: any;\n\t\n\tresolve = (value: Value<T>) => {\n\t\t\n\t\tif (this.isPending) {\n\t\t\tthis.isPending = false;\n\t\t\tthis.isFulfilled = true;\n\t\t\tthis.state = \"fulfilled\";\n\t\t\tthis.result = value;\n\t\t\t\n\t\t\tconst native = nativesMap.get(this);\n\t\t\t\n\t\t\tif (native) {\n\t\t\t\tnative.resolve.call(this, value);\n\t\t\t\tnativesMap.delete(this);\n\t\t\t}\n\t\t}\n\t\t\n\t};\n\t\n\treject = (reason?: any) => {\n\t\t\n\t\tif (this.isPending) {\n\t\t\tthis.isPending = false;\n\t\t\tthis.isRejected = true;\n\t\t\tthis.state = \"rejected\";\n\t\t\tthis.result = reason;\n\t\t\t\n\t\t\tconst native = nativesMap.get(this);\n\t\t\t\n\t\t\tif (native) {\n\t\t\t\tnative.reject.call(this, reason);\n\t\t\t\tnativesMap.delete(this);\n\t\t\t}\n\t\t}\n\t\t\n\t};\n\t\n}\n", "export function unique<T>(array: T[]): T[] {\n\treturn [ ...new Set(array) ];\n}\n", "export const updateSymbol = Symbol(\"update\");\nexport const getHandleUpdateSymbol = Symbol(\"getHandleUpdate\");\nexport const setHandleUpdateSymbol = Symbol(\"setHandleUpdate\");\nexport const getAsUpdatesSymbol = Symbol(\"getAsUpdates\");\nexport const getAsInitialUpdatedSymbol = Symbol(\"getAsInitialUpdated\");\nexport const clearSymbol = Symbol(\"clear\");\nexport const subscribeSymbol = Symbol(\"subscribe\");\nexport const unsubscribeSymbol = Symbol(\"unsubscribe\");\nexport const renewSymbol = Symbol(\"renew\");\nexport const getSubscriptionSymbol = Symbol(\"getSubscription\");\nexport const getHandleSubscriptionSymbol = Symbol(\"getHandleSubscription\");\nexport const setHandleSubscriptionSymbol = Symbol(\"setHandleSubscription\");\n", "import { removeOne } from \"@nesvet/n\";\nimport { Subscription } from \"./Subscription\";\nimport {\n\tclearSymbol,\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\tgetSubscriptionSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol,\n\tupdateSymbol\n} from \"./symbols\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\ntype Item = unknown;\n\nexport type Updated<I extends Item = Item> = I[] & {\n\tdeleted: I[];\n\tadded: I[];\n};\n\nexport type Updates<I extends Item = Item> =\n\t(\n\t\t[ \"a\"/* add */, newItem: I ] |\n\t\t[ \"d\"/* delete */, itemToDelete: I ] |\n\t\t[ \"i\"/* initial */, items: I[], sort?: -1 | 0 | 1 ] |\n\t\tnull\n\t)[] |\n\tnull;\n\nexport type UpdateHandler<I extends Item = Item> = (array: SubscriptionArray<I>, updated: Updated<I>, updates: Updates<I>) => void;\n\nconst ascSort = (a: any, b: any) => a > b ? 1 : a < b ? -1 : 0;\nconst descSort = (a: any, b: any) => a > b ? -1 : a < b ? 1 : 0;\n\n\nexport class SubscriptionArray<I extends Item = Item> extends Array<I> {\n\tconstructor(updates?: Updates<I>, onUpdate?: UpdateHandler<I>) {\n\t\tsuper();\n\t\t\n\t\tif (onUpdate)\n\t\t\tthis.handleUpdate = onUpdate;\n\t\t\n\t\tif (Array.isArray(updates))\n\t\t\tthis.update(updates);\n\t\t\n\t}\n\t\n\tsorted: I[] = [];\n\t\n\thandleUpdate;\n\t\n\tsortDirection: -1 | 0 | 1 = 0;\n\t\n\tsortCompareFunction: typeof ascSort | typeof descSort | null = null;\n\t\n\t[getHandleUpdateSymbol]() {\n\t\treturn this.handleUpdate;\n\t}\n\t\n\t[setHandleUpdateSymbol](handleUpdate: UpdateHandler<I>) {\n\t\treturn (this.handleUpdate = handleUpdate);\n\t}\n\t\n\tupdate(updates: Updates<I>) {\n\t\t\n\t\tconst updated: Updated<I> = Object.assign([], {\n\t\t\tdeleted: [],\n\t\t\tadded: []\n\t\t});\n\t\t\n\t\tif (updates) {\n\t\t\tlet shouldSort = false;\n\t\t\t\n\t\t\tfor (const update of updates)\n\t\t\t\tswitch (update?.[0]) {\n\t\t\t\t\tcase \"i\"/* initial */: {\n\t\t\t\t\t\tconst [ , array, sort ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (sort) {\n\t\t\t\t\t\t\tthis.sortDirection = sort;\n\t\t\t\t\t\t\tthis.sortCompareFunction = sort > 0 ? ascSort : descSort;\n\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.sortDirection = 0;\n\t\t\t\t\t\t\tthis.sortCompareFunction = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.length = 0;\n\t\t\t\t\t\t\n\t\t\t\t\t\tfor (const newItem of array) {\n\t\t\t\t\t\t\tthis.push(newItem);\n\t\t\t\t\t\t\tupdated.push(newItem);\n\t\t\t\t\t\t\tupdated.added.push(newItem);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"a\"/* add */: {\n\t\t\t\t\t\tconst [ , newItem ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (!this.includes(newItem)) {\n\t\t\t\t\t\t\tthis.push(newItem);\n\t\t\t\t\t\t\tif (this.sortDirection)\n\t\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t\tupdated.push(newItem);\n\t\t\t\t\t\t\tupdated.added.push(newItem);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"d\"/* delete */: {\n\t\t\t\t\t\tconst [ , itemToDelete ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (removeOne(this, itemToDelete))\n\t\t\t\t\t\t\tupdated.deleted.push(itemToDelete);\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthis.clear();\n\t\t\t\t}\n\t\t\t\n\t\t\tif (shouldSort && this.sortCompareFunction)\n\t\t\t\tthis.sort(this.sortCompareFunction);\n\t\t\t\n\t\t} else\n\t\t\tthis.clear();\n\t\t\n\t\tthis.handleUpdate?.(this, updated, updates?.[0] ? updates : null);\n\t\t\n\t\treturn this;\n\t}\n\t\n\t[updateSymbol] = this.update;\n\t\n\tgetAsUpdates(): Updates<I> {\n\t\treturn (\n\t\t\t(this.length || this.sortDirection) ?\n\t\t\t\t[ [ \"i\"/* initial */, [ ...this ], this.sortDirection ] ] :\n\t\t\t\tnull\n\t\t);\n\t}\n\t\n\t[getAsUpdatesSymbol] = this.getAsUpdates;\n\t\n\tgetAsInitialUpdated(): Updated<I> {\n\t\treturn Object.assign([ ...this.sorted ], {\n\t\t\tadded: [ ...this.sorted ],\n\t\t\tdeleted: []\n\t\t});\n\t}\n\t\n\t[getAsInitialUpdatedSymbol] = this.getAsInitialUpdated;\n\t\n\tclear() {\n\t\t\n\t\tthis.length = 0;\n\t\tthis.sortDirection = 0;\n\t\tthis.sortCompareFunction = null;\n\t\t\n\t}\n\t\n\t[clearSymbol] = this.clear;\n\t\n\tvalueOf() {\n\t\treturn this;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionArray\";\n\t}\n\t\n\t\n\tstatic updateSymbol = updateSymbol;\n\tstatic getHandleUpdateSymbol = getHandleUpdateSymbol;\n\tstatic setHandleUpdateSymbol = setHandleUpdateSymbol;\n\tstatic getAsUpdatesSymbol = getAsUpdatesSymbol;\n\tstatic getAsInitialUpdatedSymbol = getAsInitialUpdatedSymbol;\n\tstatic clearSymbol = clearSymbol;\n\tstatic WithSubscription: typeof SubscriptionArrayWithSubscription;\n\t\n}\n\n\nexport class SubscriptionArrayWithSubscription<I extends Item = Item> extends SubscriptionArray<I> {\n\tconstructor(publicationName: string, params: unknown[], onUpdate: UpdateHandler<I>, immediately = true) {\n\t\tsuper(null, onUpdate);\n\t\t\n\t\tthis.publicationName = publicationName;\n\t\tthis.params = params;\n\t\t\n\t\tif (immediately)\n\t\t\tthis.subscribe();\n\t\t\n\t}\n\t\n\tpublicationName;\n\tparams;\n\tsubscription: Subscription | null = null;\n\t\n\tsubscribe() {\n\t\t\n\t\tif (!this.subscription)\n\t\t\tthis.subscription = new Subscription(\"array\", this.publicationName, this.params, updates => this.update(updates as Updates<I>));\n\t\t\n\t}\n\t\n\tget [subscribeSymbol]() {\n\t\treturn this.subscribe;\n\t}\n\t\n\tunsubscribe() {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.subscription.cancel();\n\t\t\tthis.subscription = null;\n\t\t}\n\t\t\n\t}\n\t\n\tget [unsubscribeSymbol]() {\n\t\treturn this.unsubscribe;\n\t}\n\t\n\trenew(publicationName?: string, params?: unknown[]) {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.unsubscribe();\n\t\t\t\n\t\t\tif (publicationName)\n\t\t\t\tif (Array.isArray(publicationName))\n\t\t\t\t\tparams = publicationName;\n\t\t\t\telse\n\t\t\t\t\tthis.publicationName = publicationName;\n\t\t\t\n\t\t\tif (params)\n\t\t\t\tthis.params = params;\n\t\t\t\n\t\t\tthis.subscribe();\n\t\t}\n\t\t\n\t}\n\t\n\tget [renewSymbol]() {\n\t\treturn this.renew;\n\t}\n\t\n\t[getSubscriptionSymbol]() {\n\t\treturn this.subscription;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionArrayWithSubscription\";\n\t}\n\t\n\t\n\tstatic subscribeSymbol = subscribeSymbol;\n\tstatic unsubscribeSymbol = unsubscribeSymbol;\n\tstatic renewSymbol = renewSymbol;\n\tstatic getSubscriptionSymbol = getSubscriptionSymbol;\n\t\n}\n\nSubscriptionArray.WithSubscription = SubscriptionArrayWithSubscription;\n", "import EventEmitter from \"eventemitter3\";\nimport { debounce, StatefulPromise } from \"@nesvet/n\";\nimport { privates } from \"./common\";\nimport { SubscriptionGroupItem } from \"./SubscriptionGroupItem\";\nimport {\n\tDefinition,\n\tParseValues,\n\tSubscriptionHandle,\n\tSubscriptionOnBeforeInit,\n\tSubscriptionType,\n\tTupleDefinition,\n\tUnparsedDefinition\n} from \"./types\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\nfunction isTupleDefinition<T extends SubscriptionType>(definition: UnparsedDefinition<T>): definition is TupleDefinition {\n\treturn Array.isArray(definition);\n}\n\ntype Target = any;\n\ntype Options = {\n\ttarget?: Target;\n\tdebounce?: number;\n\timmediately?: boolean;\n};\n\n\nfunction parseDefinition<T extends SubscriptionType>(definition: UnparsedDefinition<T>) {\n\tif (isTupleDefinition(definition)) {\n\t\tconst args = definition.slice();\n\t\t\n\t\tconst parsed: Partial<Definition<T>> = {};\n\t\t\n\t\tparsed.name = args.shift() as Definition<T>[\"name\"];\n\t\tif (typeof args[0] == \"object\" && !Array.isArray(args[0])) {\n\t\t\tparsed.value = args.shift() as Definition<T>[\"value\"];\n\t\t\tparsed.type = parsed.value!.toString().match(/Subscription(Object|Array|Map)/)?.[1].toLowerCase() as Definition<T>[\"type\"];\n\t\t\tif (!parsed.type)\n\t\t\t\tthrow new Error(\"Unknown value type\");\n\t\t} else {\n\t\t\tif (typeof args[0] == \"string\")\n\t\t\t\tparsed.type = args.shift() as Definition<T>[\"type\"];\n\t\t\tif (typeof args[0] == \"string\")\n\t\t\t\tparsed.publicationName = args.shift() as Definition<T>[\"publicationName\"];\n\t\t\tif (Array.isArray(args[0]))\n\t\t\t\tparsed.params = args.shift() as Definition<T>[\"params\"];\n\t\t}\n\t\t\n\t\tif (typeof args[0] == \"function\")\n\t\t\tparsed.handle = args.shift() as SubscriptionHandle<T>;\n\t\tif (typeof args[0] == \"function\")\n\t\t\tparsed.onBeforeInit = args.shift() as SubscriptionOnBeforeInit<T>;\n\t\tif (typeof args[0] == \"number\")\n\t\t\tparsed.debounce = args.shift() as Definition<T>[\"debounce\"];\n\t\tif (typeof args[0] == \"boolean\")\n\t\t\tparsed.preventBind = args.shift() as Definition<T>[\"preventBind\"];\n\t\t\n\t\treturn parsed as Definition<T>;\n\t}\n\t\n\tdefinition.type ??= \"object\" as T;\n\t\n\treturn definition;\n}\n\nexport class SubscriptionGroup<DS extends UnparsedDefinition[] = any[]> extends EventEmitter {\n\tconstructor(\n\t\tdefinitions: DS,\n\t\t{\n\t\t\ttarget,\n\t\t\tdebounce: debounceLimit = SubscriptionGroup.debounceLimit,\n\t\t\timmediately\n\t\t}: Options = {}\n\t) {\n\t\tsuper();\n\t\t\n\t\tthis.applyOptions({ target, debounceLimit });\n\t\t\n\t\tthis.#initPromise = new StatefulPromise();\n\t\t\n\t\tthis.attach(definitions, false, immediately);\n\t\t\n\t}\n\t\n\ttarget?: Target;\n\temitUpdate!: () => void;\n\t\n\titems = [] as unknown as Record<string, SubscriptionGroupItem> & SubscriptionGroupItem[];\n\tvalues = [] as DS extends any ? (any[] & Record<string, any>) : ParseValues<DS>;\n\t\n\tisLoaded = false;\n\tisInited = false;\n\t\n\t#loadPromise!: StatefulPromise<SubscriptionGroup>;\n\t#initPromise: StatefulPromise<SubscriptionGroup>;\n\t#unloadPromise!: StatefulPromise<SubscriptionGroup>;\n\t\n\t#debounceLimit?: number | null = null;\n\t\n\tapplyOptions({ target, debounceLimit }: { target?: Target; debounceLimit?: number }) {\n\t\t\n\t\tif (this.target !== target) {\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (item.isLoaded && !item.preventBind)\n\t\t\t\t\t\tdelete this.target[item.name];\n\t\t\t\n\t\t\tthis.target = target;\n\t\t\t\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (item.isLoaded && !item.preventBind)\n\t\t\t\t\t\tthis.target[item.name] = item.value;\n\t\t}\n\t\t\n\t\tif (this.#debounceLimit !== debounceLimit) {\n\t\t\tthis.#debounceLimit = debounceLimit;\n\t\t\tif (typeof this.#debounceLimit == \"number\") {\n\t\t\t\tconst emitUpdateDebounced = debounce(() => this.emit(\"update\", this.values), this.#debounceLimit);\n\t\t\t\tthis.emitUpdate = () => emitUpdateDebounced();\n\t\t\t} else\n\t\t\t\tthis.emitUpdate = () => this.emit(\"update\", this.values);\n\t\t}\n\t\t\n\t}\n\t\n\tattach(definitions: DS, shouldReload = this.isLoaded, immediately = true) {\n\t\tif (shouldReload)\n\t\t\tthis.isLoaded = false;\n\t\t\n\t\tif (!this.#loadPromise || this.#loadPromise.isFulfilled)\n\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t\n\t\tif (!this.#unloadPromise || this.#unloadPromise.isFulfilled)\n\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t\n\t\treturn Promise.all(definitions.map(definition =>\n\t\t\tnew SubscriptionGroupItem(parseDefinition(definition), this)\n\t\t).map(item => {\n\t\t\t\n\t\t\tif (immediately)\n\t\t\t\titem.subscribe();\n\t\t\t\n\t\t\treturn item.loaded();\n\t\t}));\n\t}\n\t\n\tdetach(names: string[], shouldUpdate = true) {\n\t\t\n\t\tfor (const name of names)\n\t\t\tthis.items[name]?.detach();\n\t\t\n\t\tif (shouldUpdate) {\n\t\t\tthis.#unload();\n\t\t\tthis.#load();\n\t\t}\n\t\t\n\t}\n\t\n\tredefine(definitions: DS) {\n\t\t\n\t\tconst itemsToDetach = new Map(this.items.map(item => [ item.name, item ]));\n\t\tconst definitionsToRedefine = [];\n\t\tconst definitionsToAttach = [] as unknown as DS;\n\t\t\n\t\tfor (let definition of definitions) {\n\t\t\tdefinition = parseDefinition(definition);\n\t\t\tif (itemsToDetach.delete(definition.name))\n\t\t\t\tdefinitionsToRedefine.push(definition);\n\t\t\telse\n\t\t\t\tdefinitionsToAttach.push(definition);\n\t\t}\n\t\t\n\t\tthis.isLoaded = false;\n\t\t\n\t\tthis.detach([ ...itemsToDetach.keys() ], false);\n\t\t\n\t\treturn Promise.all([\n\t\t\t...definitionsToRedefine.map(definition => {\n\t\t\t\tconst item = this.items[definition.name];\n\t\t\t\titem.define(definition);\n\t\t\t\t\n\t\t\t\titem.subscribe();\n\t\t\t\t\n\t\t\t\treturn item.loaded();\n\t\t\t}),\n\t\t\t...definitionsToAttach.length ? [ this.attach(definitionsToAttach, false) ] : []\n\t\t]);\n\t}\n\t\n\tsubscribe() {\n\t\treturn this.items.map(item => item.subscribe());\n\t}\n\t\n\tunsubscribe() {\n\t\treturn this.items.map(item => item.unsubscribe());\n\t}\n\t\n\t#load() {\n\t\t\n\t\tif (!this.isLoaded && this.items.every(item => item.isLoaded)) {\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (!item.preventBind)\n\t\t\t\t\t\tthis.target[item.name] = item.value;\n\t\t\t\n\t\t\tthis.isLoaded = true;\n\t\t\t\n\t\t\tfor (const item of this.items)\n\t\t\t\tprivates.itemLoad!(item);\n\t\t\t\n\t\t\tthis.emit(\"load\", this.values);\n\t\t\t\n\t\t\tif (this.isInited)\n\t\t\t\tif (this.items.length)\n\t\t\t\t\tfor (const item of this.items)\n\t\t\t\t\t\titem.emitUpdate();\n\t\t\t\telse\n\t\t\t\t\tthis.emitUpdate();\n\t\t\t\n\t\t\t\n\t\t\tthis.#loadPromise.resolve(this);\n\t\t\t\n\t\t\tif (this.#unloadPromise.isFulfilled)\n\t\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t}\n\t\t\n\t}\n\t\n\t#init() {\n\t\t\n\t\tif (!this.isInited && this.items.every(item => item.isInited)) {\n\t\t\tthis.isInited = true;\n\t\t\t\n\t\t\tif (this.isLoaded)\n\t\t\t\tif (this.items.length)\n\t\t\t\t\tfor (const item of this.items)\n\t\t\t\t\t\titem.emitUpdate();\n\t\t\t\telse\n\t\t\t\t\tthis.emitUpdate();\n\t\t\t\n\t\t\t\n\t\t\tfor (const item of this.items)\n\t\t\t\tprivates.itemInit!(item);\n\t\t\t\n\t\t\tthis.emit(\"init\", this.values);\n\t\t\t\n\t\t\tthis.#initPromise.resolve(this);\n\t\t}\n\t\t\n\t}\n\t\n\t#unload() {\n\t\t\n\t\tif (this.isLoaded && this.items.every(item => !item.isLoaded)) {\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (!item.preventBind)\n\t\t\t\t\t\tdelete this.target[item.name];\n\t\t\t\n\t\t\tthis.isLoaded = false;\n\t\t\t\n\t\t\tfor (const item of this.items)\n\t\t\t\tprivates.itemUnload!(item);\n\t\t\t\n\t\t\tthis.emit(\"unload\", this.values);\n\t\t\t\n\t\t\tif (this.items.length)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\titem.emitUpdate();\n\t\t\telse\n\t\t\t\tthis.emitUpdate();\n\t\t\t\n\t\t\tthis.#unloadPromise.resolve(this);\n\t\t\t\n\t\t\tif (this.#loadPromise.isFulfilled)\n\t\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t}\n\t\t\n\t}\n\t\n\tloaded() {\n\t\treturn this.#loadPromise;\n\t}\n\t\n\tinited() {\n\t\treturn this.#initPromise;\n\t}\n\t\n\tunloaded() {\n\t\treturn this.#unloadPromise;\n\t}\n\t\n\tvalueOf() {\n\t\treturn this.values;\n\t}\n\t\n\t[Symbol.iterator]() {\n\t\treturn this.values[Symbol.iterator]();\n\t}\n\t\n\t\n\tstatic debounceLimit = 8;\n\t\n\tstatic {\n\t\t\n\t\tprivates.groupLoad = (group: SubscriptionGroup) => group.#load();\n\t\tprivates.groupInit = (group: SubscriptionGroup) => group.#init();\n\t\tprivates.groupUnload = (group: SubscriptionGroup) => group.#unload();\n\t\t\n\t}\n\t\n}\n\nexport { Options as SubscriptionGroupOptions, Target as SubscriptionGroupTarget };\n", "import type { SubscriptionGroup } from \"./SubscriptionGroup\";\nimport type { SubscriptionGroupItem } from \"./SubscriptionGroupItem\";\nimport type { SubscriptionType } from \"./types\";\n\n\nexport const privates: {\n\tgroupLoad?: (group: SubscriptionGroup) => void;\n\tgroupInit?: (group: SubscriptionGroup) => void;\n\tgroupUnload?: (group: SubscriptionGroup) => void;\n\titemLoad?: <T extends SubscriptionType>(item: SubscriptionGroupItem<T>) => void;\n\titemInit?: <T extends SubscriptionType>(item: SubscriptionGroupItem<T>) => void;\n\titemUnload?: <T extends SubscriptionType>(item: SubscriptionGroupItem<T>) => void;\n} = {};\n", "import EventEmitter from \"eventemitter3\";\nimport { debounce, removeOne, StatefulPromise } from \"@nesvet/n\";\nimport {\n\tSubscriptionArrayWithSubscription,\n\ttype Updated as SubscriptionArrayUpdated,\n\ttype UpdateHandler as SubscriptionArrayUpdateHandler,\n\ttype Updates as SubscriptionArrayUpdates\n} from \"../SubscriptionArray\";\nimport {\n\tSubscriptionMapWithSubscription,\n\ttype Updated as SubscriptionMapUpdated,\n\ttype UpdateHandler as SubscriptionMapUpdateHandler,\n\ttype Updates as SubscriptionMapUpdates\n} from \"../SubscriptionMap\";\nimport {\n\tSubscriptionObjectWithSubscription,\n\ttype Updated as SubscriptionObjectUpdated,\n\ttype UpdateHandler as SubscriptionObjectUpdateHandler,\n\ttype Updates as SubscriptionObjectUpdates\n} from \"../SubscriptionObject\";\nimport {\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol\n} from \"../symbols\";\nimport { privates } from \"./common\";\nimport type { SubscriptionGroup } from \"./SubscriptionGroup\";\nimport type {\n\tDefinition,\n\tSubscriptionHandle,\n\tSubscriptionOnBeforeInit,\n\tSubscriptionType,\n\tSubscriptionUpdated,\n\tSubscriptionUpdates,\n\tSubscriptionValue\n} from \"./types\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\ntype HandleSubscription<T> = (_: any, updated: SubscriptionUpdated<T>, updates: SubscriptionUpdates<T>) => void;\n\nfunction isUpdatedMapOrArray(updated: SubscriptionUpdated<SubscriptionType>): updated is SubscriptionArrayUpdated | SubscriptionMapUpdated {\n\treturn Array.isArray(updated);\n}\n\n\nexport class SubscriptionGroupItem<T extends SubscriptionType = SubscriptionType, D extends Definition<T> = Definition<T>> extends EventEmitter {\n\tconstructor(definition: D, group: SubscriptionGroup) {\n\t\tsuper();\n\t\t\n\t\tthis.name = definition.name;\n\t\t\n\t\tthis.define(definition, group);\n\t\t\n\t}\n\t\n\tname;\n\tgroup?: SubscriptionGroup;\n\tvalue?: SubscriptionValue<T>;\n\ttype!: T | \"object\";\n\tpublicationName!: Definition<T>[\"publicationName\"];\n\tparams!: Definition<T>[\"params\"];\n\thandle!: Definition<T>[\"handle\"];\n\tonBeforeInit!: Definition<T>[\"onBeforeInit\"];\n\tpreventBind!: Definition<T>[\"preventBind\"];\n\t\n\temitUpdate!: (updated?: SubscriptionUpdated<T>) => void;\n\t\n\tisLoaded = false;\n\tisInited = false;\n\t\n\t#loadPromise!: StatefulPromise<SubscriptionGroupItem<T, D>>;\n\t#initPromise!: StatefulPromise<SubscriptionGroupItem<T, D>>;\n\t#unloadPromise!: StatefulPromise<SubscriptionGroupItem<T, D>>;\n\t\n\tdefine(definition: Definition<T>, group: SubscriptionGroup | undefined = this.group) {\n\t\tif (!group)\n\t\t\tthrow new Error(\"group is undefined\");\n\t\t\n\t\tconst {\n\t\t\tvalue,\n\t\t\ttype = \"object\",\n\t\t\tpublicationName,\n\t\t\tparams,\n\t\t\thandle,\n\t\t\tonBeforeInit,\n\t\t\tdebounce: debounceLimit = SubscriptionGroupItem.debounceLimit,\n\t\t\tpreventBind\n\t\t} = definition;\n\t\t\n\t\tif (this.group) {\n\t\t\tif (\n\t\t\t\t(!value || this.value === value) &&\n\t\t\t\tthis.type === type &&\n\t\t\t\tthis.publicationName === publicationName &&\n\t\t\t\tJSON.stringify(this.params) === JSON.stringify(params) &&\n\t\t\t\tthis.handle === handle &&\n\t\t\t\tthis.onBeforeInit === onBeforeInit\n\t\t\t)\n\t\t\t\treturn this.#applyOptions({ debounceLimit, preventBind });\n\t\t\t\n\t\t\tthis.detach();\n\t\t\tdelete this.value;\n\t\t\tdelete this.publicationName;\n\t\t\tdelete this.params;\n\t\t}\n\t\t\n\t\tthis.type = type;\n\t\tthis.handle = handle;\n\t\tthis.onBeforeInit = onBeforeInit;\n\t\tif (value)\n\t\t\tthis.value = value;\n\t\telse {\n\t\t\tthis.publicationName = publicationName ?? this.name;\n\t\t\tthis.params = params ?? [];\n\t\t}\n\t\t\n\t\tthis.#applyOptions({ debounceLimit, preventBind });\n\t\t\n\t\tthis.#attachTo(group);\n\t\t\n\t}\n\t\n\t#applyOptions({ debounceLimit, preventBind }: { debounceLimit?: number; preventBind?: boolean }) {\n\t\t\n\t\tconst emitUpdate: typeof this.emitUpdate = updated => {\n\t\t\tthis.emit(\"update\", this.value, updated);\n\t\t\tthis.group?.emit(`update.${this.name}`, this.value, updated);\n\t\t\tthis.group?.emitUpdate();\n\t\t\t\n\t\t};\n\t\t\n\t\tif (typeof debounceLimit == \"number\") {\n\t\t\tlet debouncedUpdated: SubscriptionUpdated<T> | undefined;\n\t\t\tlet group: SubscriptionGroup;\n\t\t\t\n\t\t\tconst emitUpdateDebounced = debounce(() => {\n\t\t\t\t\n\t\t\t\tconst isDetached = !this.group;\n\t\t\t\t\n\t\t\t\tif (isDetached)\n\t\t\t\t\tthis.group = group;\n\t\t\t\t\n\t\t\t\temitUpdate(debouncedUpdated!);\n\t\t\t\t\n\t\t\t\tif (isDetached)\n\t\t\t\t\tdelete this.group;\n\t\t\t\t\n\t\t\t\tdebouncedUpdated = undefined;\n\t\t\t\t\n\t\t\t}, debounceLimit);\n\t\t\t\n\t\t\tthis.emitUpdate = updated => {\n\t\t\t\tif (updated !== undefined)\n\t\t\t\t\tif (isUpdatedMapOrArray(updated))\n\t\t\t\t\t\tif (isUpdatedMapOrArray(debouncedUpdated!))\n\t\t\t\t\t\t\tfor (const item of updated)\n\t\t\t\t\t\t\t\tdebouncedUpdated.push(item as any);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tdebouncedUpdated = Object.assign([ ...updated ], {\n\t\t\t\t\t\t\t\tadded: [ ...updated.added ],\n\t\t\t\t\t\t\t\tdeleted: [ ...updated.deleted ]\n\t\t\t\t\t\t\t}) as SubscriptionUpdated<T>;\n\t\t\t\t\telse if (typeof updated == \"object\")\n\t\t\t\t\t\tif (debouncedUpdated)\n\t\t\t\t\t\t\tObject.assign(debouncedUpdated, updated);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tdebouncedUpdated = { ...updated };\n\t\t\t\t\telse\n\t\t\t\t\t\tdebouncedUpdated = updated;\n\t\t\t\t\n\t\t\t\tgroup = this.group!;\n\t\t\t\t\n\t\t\t\treturn emitUpdateDebounced();\n\t\t\t};\n\t\t} else\n\t\t\tthis.emitUpdate = emitUpdate;\n\t\t\n\t\tif (this.preventBind === undefined)\n\t\t\tdelete this.preventBind;\n\t\telse\n\t\t\tthis.preventBind = preventBind;\n\t\t\n\t}\n\t\n\t#attachTo(group: SubscriptionGroup) {\n\t\tif (!this.group) {\n\t\t\tthis.group = group;\n\t\t\t\n\t\t\tthis.group.items.push(this as SubscriptionGroupItem<any>);\n\t\t\tthis.group.items[this.name] = this as SubscriptionGroupItem<any>;\n\t\t\t\n\t\t\tif (!this.#loadPromise || this.#loadPromise.isFulfilled)\n\t\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t\t\n\t\t\tif (!this.#initPromise || this.#initPromise.isFulfilled)\n\t\t\t\tthis.#initPromise = new StatefulPromise();\n\t\t\t\n\t\t\tif (!this.#unloadPromise || this.#unloadPromise.isFulfilled)\n\t\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t\t\n\t\t\tswitch (this.type) {\n\t\t\t\tcase \"array\": {\n\t\t\t\t\tconst handleSubscription = this.#handleSubscription as HandleSubscription<\"array\">;\n\t\t\t\t\tif (this.value)\n\t\t\t\t\t\t(this.value as SubscriptionArrayWithSubscription)[setHandleUpdateSymbol](handleSubscription);\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.value = new SubscriptionArrayWithSubscription(this.publicationName!, this.params!, handleSubscription, false) as SubscriptionValue<T>;\n\t\t\t\t\tbreak;\n\t\t\t\t} case \"map\": {\n\t\t\t\t\tconst handleSubscription = this.#handleSubscription as HandleSubscription<\"map\">;\n\t\t\t\t\tif (this.value)\n\t\t\t\t\t\t(this.value as SubscriptionMapWithSubscription)[setHandleUpdateSymbol](handleSubscription);\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.value = new SubscriptionMapWithSubscription(this.publicationName!, this.params!, handleSubscription, false) as SubscriptionValue<T>;\n\t\t\t\t\tbreak;\n\t\t\t\t} default: {\n\t\t\t\t\tconst handleSubscription = this.#handleSubscription as HandleSubscription<\"object\">;\n\t\t\t\t\tif (this.value)\n\t\t\t\t\t\t(this.value as SubscriptionObjectWithSubscription)[setHandleUpdateSymbol](handleSubscription);\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.value = new SubscriptionObjectWithSubscription(this.publicationName!, this.params!, handleSubscription, false) as SubscriptionValue<T>;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tthis.group.values.push(this.value);\n\t\t\tthis.group.values[this.name] = this.value;\n\t\t\t\n\t\t\tif (this.onBeforeInit)\n\t\t\t\tswitch (this.type) {\n\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t(this.onBeforeInit as SubscriptionOnBeforeInit<\"array\">).call(this.group, this.value as SubscriptionArrayWithSubscription);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t(this.onBeforeInit as SubscriptionOnBeforeInit<\"map\">).call(this.group, this.value as SubscriptionMapWithSubscription);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t(this.onBeforeInit as SubscriptionOnBeforeInit<\"object\">).call(this.group, this.value as SubscriptionObjectWithSubscription);\n\t\t\t\t}\n\t\t}\n\t\t\n\t}\n\t\n\tdetach() {\n\t\t\n\t\tif (this.group) {\n\t\t\tthis.value?.[unsubscribeSymbol]();\n\t\t\t\n\t\t\tthis.isLoaded = false;\n\t\t\tthis.#unload();\n\t\t\t\n\t\t\tdelete this.group.values[this.name];\n\t\t\tremoveOne(this.group.values, this.value);\n\t\t\tdelete this.group.items[this.name];\n\t\t\tremoveOne(this.group.items, this as SubscriptionGroupItem<any>);\n\t\t\t\n\t\t\tdelete this.group;\n\t\t}\n\t\t\n\t}\n\t\n\t#loadUpdated: SubscriptionUpdated<T> | null = null;\n\t\n\t#handleSubscription: HandleSubscription<T> = (_, updated, updates) => {\n\t\tif (updates)\n\t\t\tif (this.group!.isLoaded) {\n\t\t\t\tif (this.handle)\n\t\t\t\t\tswitch (this.type) {\n\t\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"array\">).call(this.group!, updated as SubscriptionArrayUpdated, this.group!);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"map\">).call(this.group!, updated as SubscriptionMapUpdated, this.group!);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"object\">).call(this.group!, updated as SubscriptionObjectUpdated, this.group!);\n\t\t\t\t\t}\n\t\t\t\tthis.emitUpdate(updated);\n\t\t\t} else {\n\t\t\t\tthis.#loadUpdated = updated;\n\t\t\t\tthis.isLoaded = true;\n\t\t\t\tprivates.groupLoad!(this.group!);\n\t\t\t}\n\t\telse if (this.isLoaded) {\n\t\t\tthis.isLoaded = false;\n\t\t\tprivates.groupUnload!(this.group!);\n\t\t}\n\t\t\n\t\tif (!this.isInited) {\n\t\t\tthis.isInited = true;\n\t\t\tprivates.groupInit!(this.group!);\n\t\t}\n\t\t\n\t};\n\t\n\t#load() {\n\t\t\n\t\tif (this.#loadUpdated) {\n\t\t\tif (this.handle)\n\t\t\t\tswitch (this.type) {\n\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"array\">).call(this.group!, this.#loadUpdated as SubscriptionArrayUpdated, this.group!);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"map\">).call(this.group!, this.#loadUpdated as SubscriptionMapUpdated, this.group!);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"object\">).call(this.group!, this.#loadUpdated as SubscriptionObjectUpdated, this.group!);\n\t\t\t\t}\n\t\t\t\n\t\t\tthis.#loadUpdated = null;\n\t\t\t\n\t\t\tthis.emit(\"load\", this.value);\n\t\t\t\n\t\t\tthis.#loadPromise.resolve(this);\n\t\t\t\n\t\t\tif (this.#unloadPromise.isFulfilled)\n\t\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t}\n\t\t\n\t}\n\t\n\t#init() {\n\t\t\n\t\tthis.emit(\"init\", this.value);\n\t\t\n\t\tthis.#initPromise.resolve(this);\n\t\t\n\t}\n\t\n\t#unload() {\n\t\t\n\t\tif (this.handle)\n\t\t\tswitch (this.type) {\n\t\t\t\tcase \"array\":\n\t\t\t\t\t(this.handle as SubscriptionHandle<\"array\">).call(this.group!, null, this.group!);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"map\":\n\t\t\t\t\t(this.handle as SubscriptionHandle<\"map\">).call(this.group!, null, this.group!);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t(this.handle as SubscriptionHandle<\"object\">).call(this.group!, null, this.group!);\n\t\t\t}\n\t\t\n\t\tthis.emit(\"unload\", this.value);\n\t\t\n\t\tthis.#unloadPromise.resolve(this);\n\t\t\n\t\tif (this.#loadPromise.isFulfilled)\n\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t\n\t}\n\t\n\tloaded() {\n\t\treturn this.#loadPromise;\n\t}\n\t\n\tinited() {\n\t\treturn this.#initPromise;\n\t}\n\t\n\tunloaded() {\n\t\treturn this.#unloadPromise;\n\t}\n\t\n\tsubscribe() {\n\t\t\n\t\tif (this.value)\n\t\t\tif (this.value[subscribeSymbol])\n\t\t\t\treturn this.value[subscribeSymbol]();\n\t\t\telse {\n\t\t\t\tconst handleUpdate = this.value[getHandleUpdateSymbol]();\n\t\t\t\t\n\t\t\t\tif (handleUpdate) {\n\t\t\t\t\tconst initialUpdated = this.value[getAsInitialUpdatedSymbol]();\n\t\t\t\t\tconst updates = this.value[getAsUpdatesSymbol]();\n\t\t\t\t\t\n\t\t\t\t\tswitch (this.type) {\n\t\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t\treturn (handleUpdate as SubscriptionArrayUpdateHandler)(this.value as SubscriptionArrayWithSubscription, initialUpdated as SubscriptionArrayUpdated, updates as SubscriptionArrayUpdates);\n\t\t\t\t\t\t\n\t\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t\treturn (handleUpdate as SubscriptionMapUpdateHandler)(this.value as SubscriptionMapWithSubscription, initialUpdated as SubscriptionMapUpdated, updates as SubscriptionMapUpdates);\n\t\t\t\t\t\t\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn (handleUpdate as SubscriptionObjectUpdateHandler)(this.value as SubscriptionObjectWithSubscription, initialUpdated as SubscriptionObjectUpdated, updates as SubscriptionObjectUpdates);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t}\n\t\n\tunsubscribe() {\n\t\treturn this.value?.[unsubscribeSymbol]?.();\n\t}\n\t\n\trenew(publicationName: Definition<T>[\"publicationName\"], params: Definition<T>[\"params\"]) {\n\t\treturn this.value?.[renewSymbol]?.(publicationName, params);\n\t}\n\t\n\tvalueOf() {\n\t\treturn this.value;\n\t}\n\t\n\t\n\tstatic debounceLimit = 4;\n\t\n\tstatic {\n\t\t\n\t\tprivates.itemLoad = <\n\t\t\tDP extends Definition<TP>,\n\t\t\tTP extends SubscriptionType\n\t\t>(item: SubscriptionGroupItem<TP, DP>) => item.#load();\n\t\tprivates.itemInit = <\n\t\t\tDP extends Definition<TP>,\n\t\t\tTP extends SubscriptionType\n\t\t>(item: SubscriptionGroupItem<TP, DP>) => item.#init();\n\t\tprivates.itemUnload = <\n\t\t\tDP extends Definition<TP>,\n\t\t\tTP extends SubscriptionType\n\t\t>(item: SubscriptionGroupItem<TP, DP>) => item.#unload();\n\t\t\n\t}\n\t\n}\n", "import { removeOne, unique } from \"@nesvet/n\";\nimport { Subscription } from \"./Subscription\";\nimport {\n\tclearSymbol,\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\tgetSubscriptionSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol,\n\tupdateSymbol\n} from \"./symbols\";\n\n\ntype GenericItem = Record<string, any> & { _id: string };// eslint-disable-line @typescript-eslint/no-explicit-any\n\ntype Item = GenericItem | SubscriptionMapItem;\n\nexport type Updated<I extends Item = Item> = I[] & {\n\tdeleted: string[];\n\tadded: I[];\n};\n\ntype SortList = Record<string, -1 | 1>;\n\nexport type Updates<I extends Item = Item> =\n\t(\n\t\t[ \"c\"/* create */, item: I ] |\n\t\t[ \"d\"/* delete */, _id: string ] |\n\t\t[ \"i\"/* initial */, items: I[], sortList?: SortList | null ] |\n\t\t[ \"u\"/* update */, itemUpdates: Partial<I> & { _id: string }, isAtomicOrUpdatedFields: string[] | true ] |\n\t\tnull\n\t)[] |\n\tnull;\n\nexport type UpdateHandler<I extends Item = Item> = (map: SubscriptionMap<I>, updated: Updated<I>, updates: Updates<I>) => void;\n\ndeclare global {\n\tvar __insite_subscription_map_sort_function: ((a: Item, b: Item) => -1 | 0 | 1) | undefined;// eslint-disable-line no-var, camelcase\n}\n\nfunction createSortFunction(sortList: SortList) {\n\t\n\tconst tempScript = document.createElement(\"script\");\n\t\n\ttempScript.textContent = `window.__insite_subscription_map_sort_function = function sort(a, b) { return ${\n\t\tObject.entries(sortList)\n\t\t\t.map(([ key, value ]) => value > 0 ? `a.${key} > b.${key} ? 1 : a.${key} < b.${key} ? -1 :` : `a.${key} < b.${key} ? 1 : a.${key} > b.${key} ? -1 :`)\n\t\t\t.concat(\"0\")\n\t\t\t.join(\" \")\n\t};}`;\n\t\n\tdocument.head.append(tempScript);\n\t\n\tconst sortFunction = globalThis.__insite_subscription_map_sort_function!;\n\t\n\ttempScript.remove();\n\tdelete globalThis.__insite_subscription_map_sort_function;\n\t\n\treturn sortFunction;\n}\n\n// function createSortFunction(sortList: SortList) {\n// return new Function(// eslint-disable-line no-new-func\n// \t\t\"a\"/* Item */,\n// \t\t\"b\"/* Item */,\n// \t\t`return ${\n// \t\t\tObject.entries(sortList)\n// \t\t\t\t.map(([ key, value ]) => value > 0 ? `a.${key} > b.${key} ? 1 : a.${key} < b.${key} ? -1 :` : `a.${key} < b.${key} ? 1 : a.${key} > b.${key} ? -1 :`)\n// \t\t\t\t.concat(\"0\")\n// \t\t\t\t.join(\" \")\n// \t\t}`\n// \t) as (a: Item, b: Item) => -1 | 0 | 1;\n// }\n\n\nexport class SubscriptionMap<I extends Item = Item> extends Map<string, I> {\n\tconstructor(updates?: Updates<I>, onUpdate?: UpdateHandler<I>) {\n\t\tsuper();\n\t\t\n\t\tif (onUpdate)\n\t\t\tthis.handleUpdate = onUpdate;\n\t\t\n\t\tif (updates)\n\t\t\tthis.update(updates);\n\t\t\n\t}\n\t\n\thandleUpdate;\n\t\n\t#updates = new Map<string, I>();\n\t\n\tsortList: SortList | null = null;\n\t\n\tsortCompareFunction: ((a: I, b: I) => number) | null = null;\n\t\n\t#fieldsToSort: string[] = [];\n\t\n\tsorted: I[] = [];\n\t\n\tsort() {\n\t\t\n\t\tif (this.sortCompareFunction)\n\t\t\tthis.sorted.sort(this.sortCompareFunction);\n\t\t\n\t}\n\t\n\t[getHandleUpdateSymbol]() {\n\t\treturn this.handleUpdate;\n\t}\n\t\n\t[setHandleUpdateSymbol](handleUpdate: UpdateHandler<I>) {\n\t\treturn (this.handleUpdate = handleUpdate);\n\t}\n\t\n\t#Item!: { new (map: SubscriptionMap<I>, updates: GenericItem): I };\n\t\n\tset Item(TheItem: { new (map: SubscriptionMap<I>, updates: GenericItem): I }) {\n\t\tthis.#Item = TheItem;\n\t\t\n\t\tif (this.size)\n\t\t\tfor (const [ _id, item ] of this)\n\t\t\t\tthis.set(_id, new TheItem(this, item));\n\t\t\n\t}\n\t\n\tget Item() {\n\t\treturn this.#Item;\n\t}\n\t\n\tupdate(updates: Updates<I>) {\n\t\t\n\t\tconst updated: Updated<I> = Object.assign([], {\n\t\t\tadded: [],\n\t\t\tdeleted: []\n\t\t});\n\t\t\n\t\tif (updates) {\n\t\t\tlet shouldSort = false;\n\t\t\t\n\t\t\tconst TheItem = this.#Item;\n\t\t\tconst prevUpdates = this.#updates;\n\t\t\t\n\t\t\tfor (const update of updates)\n\t\t\t\tswitch (update?.[0]) {\n\t\t\t\t\tcase \"i\"/* initial */: {\n\t\t\t\t\t\tconst [ , array, sortList ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (sortList) {\n\t\t\t\t\t\t\tthis.sortList = sortList;\n\t\t\t\t\t\t\tthis.sortCompareFunction = createSortFunction(sortList);\n\t\t\t\t\t\t\tthis.#fieldsToSort = unique(Object.keys(sortList).map(key => key.replace(/\\..+/, \"\")));\n\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.sortList = null;\n\t\t\t\t\t\t\tthis.sortCompareFunction = null;\n\t\t\t\t\t\t\tthis.#fieldsToSort = [];\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (this.size) {\n\t\t\t\t\t\t\tconst updatesMap = new Map<string, I>();\n\t\t\t\t\t\t\tfor (const itemUpdates of array)\n\t\t\t\t\t\t\t\tupdatesMap.set(itemUpdates._id, itemUpdates);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tfor (const [ _id, item ] of this) {\n\t\t\t\t\t\t\t\tconst itemUpdates = updatesMap.get(_id);\n\t\t\t\t\t\t\t\tif (itemUpdates) {\n\t\t\t\t\t\t\t\t\tconst prevItemUpdates = prevUpdates.get(_id);\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\t\t\titem.update(itemUpdates);\n\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\tfor (const key in prevItemUpdates)// eslint-disable-line guard-for-in\n\t\t\t\t\t\t\t\t\t\t\tdelete item[key as keyof typeof item];\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tObject.assign(item, itemUpdates);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tprevUpdates.set(_id, itemUpdates);\n\t\t\t\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\t\t\tupdatesMap.delete(_id);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\t\t\titem.delete();\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\tthis.delete(_id);\n\t\t\t\t\t\t\t\t\tprevUpdates.delete(_id);\n\t\t\t\t\t\t\t\t\tupdated.deleted.push(_id);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tfor (const [ _id, itemUpdates ] of updatesMap) {\n\t\t\t\t\t\t\t\tconst item = TheItem ? new TheItem(this, itemUpdates) : { ...itemUpdates };\n\t\t\t\t\t\t\t\tthis.set(_id, item);\n\t\t\t\t\t\t\t\tprevUpdates.set(_id, itemUpdates);\n\t\t\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\t\tupdated.added.push(item);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (this.sortList)\n\t\t\t\t\t\t\t\tthis.sorted = array.map(newItem => this.get(newItem._id)!);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t\tfor (const itemUpdates of array) {\n\t\t\t\t\t\t\t\tconst item = (TheItem ? new TheItem(this, itemUpdates) : { ...itemUpdates }) as I;\n\t\t\t\t\t\t\t\tthis.set(item._id, item);\n\t\t\t\t\t\t\t\tthis.sorted.push(item);\n\t\t\t\t\t\t\t\tprevUpdates.set(item._id, itemUpdates);\n\t\t\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\t\tupdated.added.push(item);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"c\"/* create */:\n\t\t\t\t\tcase \"u\"/* update */: {\n\t\t\t\t\t\tlet [ , itemUpdates ] = update;\n\t\t\t\t\t\tlet item = this.get(itemUpdates._id);\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (item) {\n\t\t\t\t\t\t\tconst isAtomic = update[2] === true;\n\t\t\t\t\t\t\tconst updatedFields = isAtomic ? Object.keys(itemUpdates) : update[2] as string[];\n\t\t\t\t\t\t\tconst prevItemUpdates = prevUpdates.get(item._id)!;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\titem.update(itemUpdates);\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tif (!isAtomic)\n\t\t\t\t\t\t\t\t\tfor (const key in prevItemUpdates)// eslint-disable-line guard-for-in\n\t\t\t\t\t\t\t\t\t\tdelete item[key as keyof typeof item];\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tObject.assign(item, itemUpdates);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (isAtomic)\n\t\t\t\t\t\t\t\titemUpdates = Object.assign(prevItemUpdates, itemUpdates);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (this.sortList && !shouldSort && (!updatedFields || updatedFields.some(fieldName => this.#fieldsToSort.includes(fieldName))))\n\t\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\titem = (TheItem ? new TheItem(this, itemUpdates) : { ...itemUpdates }) as I;\n\t\t\t\t\t\t\tthis.set(item._id, item);\n\t\t\t\t\t\t\tthis.sorted.push(item);\n\t\t\t\t\t\t\tif (this.sortList)\n\t\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t\tupdated.added.push(item);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tprevUpdates.set(item._id, itemUpdates as I);\n\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"d\"/* delete */: {\n\t\t\t\t\t\tconst [ , _id ] = update;\n\t\t\t\t\t\tconst itemToDelete = this.get(_id);\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (itemToDelete) {\n\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\titemToDelete.delete();\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tthis.delete(_id);\n\t\t\t\t\t\t\tprevUpdates.delete(_id);\n\t\t\t\t\t\t\tremoveOne(this.sorted, itemToDelete);\n\t\t\t\t\t\t\tupdated.deleted.push(_id);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthis.clear();\n\t\t\t\t}\n\t\t\t\n\t\t\tif (shouldSort)\n\t\t\t\tthis.sort();\n\t\t\t\n\t\t} else\n\t\t\tthis.clear();\n\t\t\n\t\tthis.handleUpdate?.(this, updated, updates?.[0] ? updates : null);\n\t\t\n\t\treturn this;\n\t}\n\t\n\t[updateSymbol] = this.update;\n\t\n\tgetAsUpdates(): Updates<I> {\n\t\treturn (\n\t\t\t(this.size || this.sortList) ?\n\t\t\t\t[ [ \"i\"/* initial */, [ ...this.#updates.values() ], this.sortList ] ] :\n\t\t\t\tnull\n\t\t);\n\t}\n\t\n\t[getAsUpdatesSymbol] = this.getAsUpdates;\n\t\n\tgetAsInitialUpdated(): Updated<I> {\n\t\treturn Object.assign([ ...this.sorted ], {\n\t\t\tadded: [ ...this.sorted ],\n\t\t\tdeleted: []\n\t\t});\n\t}\n\t\n\t[getAsInitialUpdatedSymbol] = this.getAsInitialUpdated;\n\t\n\tclear() {\n\t\t\n\t\tsuper.clear();\n\t\tthis.#updates.clear();\n\t\tthis.sorted = [];\n\t\tthis.sortList = null;\n\t\tthis.sortCompareFunction = null;\n\t\tthis.#fieldsToSort = [];\n\t\t\n\t}\n\t\n\t[clearSymbol] = this.clear;\n\t\n\tvalueOf() {\n\t\treturn this.sorted;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionMap\";\n\t}\n\t\n\t\n\tstatic updateSymbol = updateSymbol;\n\tstatic getHandleUpdateSymbol = getHandleUpdateSymbol;\n\tstatic setHandleUpdateSymbol = setHandleUpdateSymbol;\n\tstatic getAsUpdatesSymbol = getAsUpdatesSymbol;\n\tstatic getAsInitialUpdatedSymbol = getAsInitialUpdatedSymbol;\n\tstatic clearSymbol = clearSymbol;\n\tstatic WithSubscription: typeof SubscriptionMapWithSubscription;\n\tstatic Item: typeof SubscriptionMapItem;\n\t\n}\n\n\nexport class SubscriptionMapWithSubscription<I extends Item = Item> extends SubscriptionMap<I> {\n\tconstructor(publicationName: string, params: unknown[], onUpdate: UpdateHandler<I>, immediately = true) {\n\t\tsuper(null, onUpdate);\n\t\t\n\t\tthis.publicationName = publicationName;\n\t\tthis.params = params;\n\t\t\n\t\tif (immediately)\n\t\t\tthis.subscribe();\n\t\t\n\t}\n\t\n\tpublicationName;\n\tparams;\n\t\n\tsubscription: Subscription | null = null;\n\t\n\tsubscribe() {\n\t\t\n\t\tif (!this.subscription)\n\t\t\tthis.subscription = new Subscription(\"map\", this.publicationName, this.params, updates => this.update(updates as Updates<I>));\n\t\t\n\t}\n\t\n\tget [subscribeSymbol]() {\n\t\treturn this.subscribe;\n\t}\n\t\n\tunsubscribe() {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.subscription.cancel();\n\t\t\tthis.subscription = null;\n\t\t}\n\t\t\n\t}\n\t\n\tget [unsubscribeSymbol]() {\n\t\treturn this.unsubscribe;\n\t}\n\t\n\trenew(publicationName?: string, params?: unknown[]) {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.unsubscribe();\n\t\t\t\n\t\t\tif (publicationName)\n\t\t\t\tif (Array.isArray(publicationName))\n\t\t\t\t\tparams = publicationName;\n\t\t\t\telse\n\t\t\t\t\tthis.publicationName = publicationName;\n\t\t\t\n\t\t\tif (params)\n\t\t\t\tthis.params = params;\n\t\t\t\n\t\t\tthis.subscribe();\n\t\t}\n\t\t\n\t}\n\t\n\tget [renewSymbol]() {\n\t\treturn this.renew;\n\t}\n\t\n\t[getSubscriptionSymbol]() {\n\t\treturn this.subscription;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionMapWithSubscription\";\n\t}\n\t\n\t\n\tstatic subscribeSymbol = subscribeSymbol;\n\tstatic unsubscribeSymbol = unsubscribeSymbol;\n\tstatic renewSymbol = renewSymbol;\n\tstatic getSubscriptionSymbol = getSubscriptionSymbol;\n\t\n}\n\nSubscriptionMap.WithSubscription = SubscriptionMapWithSubscription;\n\n\nexport class SubscriptionMapItem {\n\tconstructor(map: SubscriptionMap, updates: GenericItem) {\n\t\tthis.#map = map;\n\t\t\n\t\tthis.update(updates);\n\t\t\n\t}\n\t\n\t_id!: string;\n\t\n\t#map;\n\t\n\tupdate(updates: GenericItem) {\n\t\tObject.assign(this, updates);\n\t\t\n\t}\n\t\n\tdelete() {\n\t\t\n\t\tthis.#map.delete(this._id);\n\t\t\n\t}\n\t\n}\n\nSubscriptionMap.Item = SubscriptionMapItem;\n", "import { Subscription } from \"./Subscription\";\nimport {\n\tclearSymbol,\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\tgetSubscriptionSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol,\n\tupdateSymbol\n} from \"./symbols\";\n\n\nconst handleUpdateSymbol = Symbol(\"handleUpdate\");\nconst updatesSymbol = Symbol(\"updates\");\n\nexport type Updated = Record<string, unknown>;\nexport type Updates = Record<string, unknown> | null;\nexport type UpdateHandler = (object: SubscriptionObject, updated: Updated, updates: Updates) => void;\n\n\nexport class SubscriptionObject {\n\tconstructor(updates?: Updates, onUpdate?: UpdateHandler) {\n\t\tif (onUpdate)\n\t\t\tthis[handleUpdateSymbol] = onUpdate;\n\t\t\n\t\tif (updates)\n\t\t\tthis[updateSymbol](updates);\n\t\t\n\t}\n\t\n\t[handleUpdateSymbol]?: UpdateHandler;\n\t\n\t[updatesSymbol]: Updates = null;\n\t\n\t[getHandleUpdateSymbol]() {\n\t\treturn this[handleUpdateSymbol];\n\t}\n\t\n\t[setHandleUpdateSymbol](handleUpdate: UpdateHandler) {\n\t\treturn (this[handleUpdateSymbol] = handleUpdate);\n\t}\n\t\n\t[updateSymbol](updates: Updates) {\n\t\tif (updates) {\n\t\t\tfor (const key in this[updatesSymbol])// eslint-disable-line guard-for-in\n\t\t\t\tdelete this[key];\n\t\t\tfor (const key in updates)// eslint-disable-line guard-for-in\n\t\t\t\tthis[key] = updates[key];\n\t\t\tthis[updatesSymbol] = updates;\n\t\t} else\n\t\t\tthis[clearSymbol]();\n\t\t\n\t\tthis[handleUpdateSymbol]?.(this, this, this[updatesSymbol]);\n\t\t\n\t\treturn this;\n\t}\n\t\n\t[getAsUpdatesSymbol](): Updates {\n\t\treturn this[updatesSymbol] && { ...this[updatesSymbol] };\n\t}\n\t\n\t[getAsInitialUpdatedSymbol](): Updated {\n\t\treturn this.valueOf()!;\n\t}\n\t\n\t[clearSymbol]() {\n\t\t\n\t\tfor (const key in this)// eslint-disable-line guard-for-in\n\t\t\tdelete this[key];\n\t\tthis[updatesSymbol] = null;\n\t\t\n\t}\n\t\n\tvalueOf() {\n\t\treturn this[updatesSymbol] && this;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionObject\";\n\t}\n\t\n\t[key: string]: unknown;\n\t\n\t\n\tstatic updateSymbol = updateSymbol;\n\tstatic getHandleUpdateSymbol = getHandleUpdateSymbol;\n\tstatic setHandleUpdateSymbol = setHandleUpdateSymbol;\n\tstatic getAsUpdatesSymbol = getAsUpdatesSymbol;\n\tstatic getAsInitialUpdatedSymbol = getAsInitialUpdatedSymbol;\n\tstatic clearSymbol = clearSymbol;\n\tstatic WithSubscription: typeof SubscriptionObjectWithSubscription;\n\t\n}\n\n\nexport class SubscriptionObjectWithSubscription extends SubscriptionObject {\n\tconstructor(publicationName: string, params: unknown[], onUpdate: UpdateHandler, immediately = true) {\n\t\tsuper(null, onUpdate);\n\t\t\n\t\tthis.#publicationName = publicationName;\n\t\tthis.#params = params;\n\t\t\n\t\tif (immediately)\n\t\t\tthis[subscribeSymbol]();\n\t\t\n\t}\n\t\n\t#publicationName;\n\t#params;\n\t#subscription: Subscription | null = null;\n\t\n\t[subscribeSymbol]() {\n\t\t\n\t\tif (!this.#subscription)\n\t\t\tthis.#subscription = new Subscription(\"object\", this.#publicationName, this.#params, updates => this[updateSymbol](updates as Updates));\n\t\t\n\t}\n\t\n\t[unsubscribeSymbol]() {\n\t\t\n\t\tif (this.#subscription) {\n\t\t\tthis.#subscription.cancel();\n\t\t\tthis.#subscription = null;\n\t\t}\n\t\t\n\t}\n\t\n\t[renewSymbol](publicationName?: string, params?: unknown[]) {\n\t\t\n\t\tif (this.#subscription) {\n\t\t\tthis[unsubscribeSymbol]();\n\t\t\t\n\t\t\tif (publicationName)\n\t\t\t\tif (Array.isArray(publicationName))\n\t\t\t\t\tparams = publicationName;\n\t\t\t\telse\n\t\t\t\t\tthis.#publicationName = publicationName;\n\t\t\t\n\t\t\tif (params)\n\t\t\t\tthis.#params = params;\n\t\t\t\n\t\t\tthis[subscribeSymbol]();\n\t\t}\n\t\t\n\t}\n\t\n\t[getSubscriptionSymbol]() {\n\t\treturn this.#subscription;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionObjectWithSubscription\";\n\t}\n\t\n\t\n\tstatic subscribeSymbol = subscribeSymbol;\n\tstatic unsubscribeSymbol = unsubscribeSymbol;\n\tstatic renewSymbol = renewSymbol;\n\tstatic getSubscriptionSym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handler", "immediately", "__publicField", "_ws", "si", "updates", "subscription", "noop", "
|
|
3
|
+
"sources": ["../src/Subscription.ts", "../../../../@nesvet/npm/n/src/noop.ts", "../../../../@nesvet/npm/n/src/StatefulPromise.ts", "../../../../@nesvet/npm/n/src/debounce.ts", "../../../../@nesvet/npm/n/src/howmuch.ts", "../../../../@nesvet/npm/n/src/removeOne.ts", "../../../../@nesvet/npm/n/src/unique.ts", "../src/symbols.ts", "../src/SubscriptionArray.ts", "../src/SubscriptionGroup/SubscriptionGroup.ts", "../src/SubscriptionGroup/common.ts", "../src/SubscriptionGroup/SubscriptionGroupItem.ts", "../src/SubscriptionMap.ts", "../src/SubscriptionObject.ts"],
|
|
4
|
+
"sourcesContent": ["import type { WS } from \"insite-ws/client\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\ndeclare global {\n\tvar __initials: unknown[] | undefined;// eslint-disable-line no-var\n}\n\n\nlet i: number;\nlet subscriptions: Map<number, Subscription>;\nlet ws: WS;\n\n\nexport class Subscription {\n\tconstructor(type: \"array\" | \"map\" | \"object\", publicationName: string, args: unknown[] = [], handler: (updates: any) => void, immediately = true) {\n\t\t\n\t\tif (!ws)\n\t\t\tthrow new Error(\"Subscription is not binded to WS. Do Subscription.bindTo(ws) first\");\n\t\t\n\t\tthis.i = i++;\n\t\tthis.type = type;\n\t\tthis.publicationName = publicationName;\n\t\tthis.args = args;\n\t\tthis.handler = handler;\n\t\tthis.immediately = immediately && !globalThis.__initials;\n\t\t\n\t\tsubscriptions.set(this.i, this);\n\t\t\n\t\tws.on(\"open\", this.start);\n\t\t\n\t\tif (ws.isOpen)\n\t\t\tthis.start();\n\t\t\n\t\tif (globalThis.__initials) {\n\t\t\tthis.isActive = true;\n\t\t\tthis.handler(globalThis.__initials.splice(0, 1)[0]);\n\t\t} else\n\t\t\tthis.isActive = false;\n\t\t\n\t}\n\t\n\ti;\n\ttype;\n\tpublicationName;\n\targs;\n\thandler;\n\timmediately;\n\tisActive;\n\t\n\tstart = () => {\n\t\t\n\t\tws.sendMessage(\"s-s\"/* subscription subscribe */, this.type, this.publicationName, this.i, this.args, this.immediately);\n\t\t\n\t\tthis.immediately = true;\n\t\t\n\t};\n\t\n\tcancel() {\n\t\t\n\t\tsubscriptions.delete(this.i);\n\t\t\n\t\tws.off(\"open\", this.start);\n\t\t\n\t\tws.sendMessage(\"s-u\"/* subscription unsubscribe */, this.i);\n\t\t\n\t}\n\t\n\t\n\tstatic bindTo(_ws: WS) {\n\t\tws = _ws;\n\t\t\n\t\ti = 0;\n\t\t\n\t\tsubscriptions = new Map();\n\t\t\n\t\tws.on(\"message:s-c\"/* subscription changed */, (si: number, updates: any) => {\n\t\t\tconst subscription = subscriptions.get(si);\n\t\t\tif (subscription) {\n\t\t\t\tsubscription.isActive = true;\n\t\t\t\tsubscription.handler(updates);\n\t\t\t}\n\t\t\t\n\t\t});\n\t\t\n\t\tws.on(\"close\", () => {\n\t\t\t\n\t\t\tfor (const subscription of subscriptions.values())\n\t\t\t\tsubscription.isActive = false;\n\t\t\t\n\t\t});\n\t\t\n\t\tws.on(\"server-change\", () => {\n\t\t\t\n\t\t\tfor (const subscription of subscriptions.values())\n\t\t\t\tsubscription.handler(null);\n\t\t\t\n\t\t});\n\t\t\n\t}\n\t\n}\n", "export function noop() { /**/ }\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype Value<T> = PromiseLike<T> | T;\ntype Resolve<T> = (value: Value<T>) => void;\ntype Reject = (reason?: any) => void;\n\ntype Options = {\n\tsignal?: AbortSignal;\n\ttimeout?: number;\n};\n\nconst nativesMap = new WeakMap<StatefulPromise<any>, { resolve: Resolve<any>; reject: Reject }>();\n\n\nexport class StatefulPromise<T> extends Promise<T> {\n\tconstructor(\n\t\texecutor?: (resolve: Resolve<T>, reject: Reject) => void,\n\t\toptions?: Options\n\t) {\n\t\tlet nativeResolve: Resolve<T>;\n\t\tlet nativeReject: Reject;\n\t\t\n\t\tsuper((resolve, reject) => {\n\t\t\tnativeResolve = resolve;\n\t\t\tnativeReject = reject;\n\t\t\t\n\t\t});\n\t\t\n\t\tnativesMap.set(this, { resolve: nativeResolve!, reject: nativeReject! });\n\t\t\n\t\tif (options?.signal)\n\t\t\tif (options.signal.aborted)\n\t\t\t\tthis.reject(new DOMException(\"Aborted\", \"AbortError\"));\n\t\t\telse {\n\t\t\t\tconst abortListener = () => this.reject(new DOMException(\"Aborted\", \"AbortError\"));\n\t\t\t\t\n\t\t\t\toptions.signal.addEventListener(\"abort\", abortListener);\n\t\t\t\t\n\t\t\t\tthis.finally(() => options.signal?.removeEventListener(\"abort\", abortListener));\n\t\t\t}\n\t\t\n\t\tif (typeof options?.timeout === \"number\" && Number.isFinite(options.timeout)) {\n\t\t\tconst timeout = setTimeout(() => this.reject(new DOMException(\"Timeout exceeded\", \"TimeoutError\")), options.timeout);\n\t\t\t\n\t\t\tthis.finally(() => clearTimeout(timeout));\n\t\t}\n\t\t\n\t\texecutor?.(this.resolve, this.reject);\n\t\t\n\t}\n\t\n\tisPending = true;\n\tisFulfilled = false;\n\tisRejected = false;\n\t\n\tstate: \"fulfilled\" | \"pending\" | \"rejected\" = \"pending\";\n\t\n\tresult?: T | unknown;\n\t\n\treadonly resolve = (value: Value<T>) => {\n\t\t\n\t\tif (this.isPending) {\n\t\t\tthis.isPending = false;\n\t\t\tthis.isFulfilled = true;\n\t\t\tthis.state = \"fulfilled\";\n\t\t\tthis.result = value;\n\t\t\t\n\t\t\tconst native = nativesMap.get(this);\n\t\t\t\n\t\t\tif (native) {\n\t\t\t\tnative.resolve.call(this, value);\n\t\t\t\tnativesMap.delete(this);\n\t\t\t}\n\t\t}\n\t\t\n\t};\n\t\n\treadonly reject = (reason?: any) => {\n\t\t\n\t\tif (this.isPending) {\n\t\t\tthis.isPending = false;\n\t\t\tthis.isRejected = true;\n\t\t\tthis.state = \"rejected\";\n\t\t\tthis.result = reason;\n\t\t\t\n\t\t\tconst native = nativesMap.get(this);\n\t\t\t\n\t\t\tif (native) {\n\t\t\t\tnative.reject.call(this, reason);\n\t\t\t\tnativesMap.delete(this);\n\t\t\t}\n\t\t}\n\t\t\n\t};\n\t\n\t\n\tstatic resolved<U>(value: U): StatefulPromise<U> {\n\t\treturn new StatefulPromise<U>(resolve => resolve(value));\n\t}\n\t\n\tstatic rejected(reason: unknown): StatefulPromise<never> {\n\t\treturn new StatefulPromise((_, reject) => reject(reason));\n\t}\n\t\n}\n", "import { noop } from \"./noop.js\";\nimport { StatefulPromise } from \"./StatefulPromise.js\";\n\n\ntype Callback = (...args: any[]) => unknown;// eslint-disable-line @typescript-eslint/no-explicit-any\ntype FunctionOrBoolean = (() => unknown) | boolean;\ntype Options = { leading?: FunctionOrBoolean; maxWait?: number; trailing?: FunctionOrBoolean };\n\ntype DebouncedFunction<C extends Callback> = {\n\t(this: ThisParameterType<C>, ...args: Parameters<C>): Promise<Awaited<ReturnType<C>>>;\n};\n\nexport type Debounced<C extends Callback, R extends ReturnType<C>> = DebouncedFunction<C> & {\n\tcallback: C;\n\tpromise: StatefulPromise<R>;\n\tresolve: (value: R) => void;\n\treject: (reason?: unknown) => void;\n\trun(): Promise<R>;\n\tclear(shouldRun?: boolean): Promise<void>;\n};\n\n\nexport function debounce<C extends Callback, R extends ReturnType<C>>(callback: C, limit = 0, options: Options = {}) {\n\tlet { leading = false, trailing = true } = options;\n\tconst { maxWait = Infinity } = options;\n\t\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\tlet maxWaitTimeout: ReturnType<typeof setTimeout> | undefined;\n\tlet end: number | undefined;\n\tlet context: ThisParameterType<C>;\n\tlet args: unknown[];\n\tlet initial: FunctionOrBoolean;\n\tlet final: FunctionOrBoolean;\n\tlet result: R;\n\t\n\tconst expired = async () => {\n\t\t\n\t\tconst n = Date.now();\n\t\t\n\t\tif (n >= end!) {\n\t\t\ttimeout = undefined;\n\t\t\tend = undefined;\n\t\t\t\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\tmaxWaitTimeout = undefined;\n\t\t\t\n\t\t\tif (typeof final == \"function\")\n\t\t\t\tawait final();\n\t\t\t\n\t\t\tdebounced.resolve(result);\n\t\t\t\n\t\t\tinitial = leading;\n\t\t} else {\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = setTimeout(expired, end! - n);\n\t\t}\n\t\t\n\t};\n\t\n\tconst maxWaitExpired = Number.isFinite(maxWait) ? () => {\n\t\t\n\t\tif (final === run)\n\t\t\tfinal = false;\n\t\t\n\t\trun();\n\t\t\n\t\tmaxWaitTimeout = setTimeout(maxWaitExpired as TimerHandler, maxWait);\n\t\t\n\t} : null;\n\t\n\tasync function run() {\n\t\ttry {\n\t\t\tresult = await callback.apply(context, args) as R;\n\t\t\t\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tdebounced.reject(error);\n\t\t\t\n\t\t\tthrow error;\n\t\t}\n\t}\n\t\n\tif (leading && typeof leading == \"boolean\")\n\t\tleading = run;\n\tinitial = leading;\n\t\n\tif (trailing && typeof trailing == \"boolean\")\n\t\ttrailing = run;\n\tfinal = trailing;\n\t\n\tconst debounced: Debounced<C, R> = Object.assign(function (..._args) {\n\t\targs = _args;\n\t\tcontext = this;// eslint-disable-line no-invalid-this\n\t\t\n\t\tend = Date.now() + limit;\n\t\tfinal = trailing;\n\t\t\n\t\tif (!debounced.promise.isPending)\n\t\t\tdebounced.promise = new StatefulPromise<R>((resolve, reject) => {\n\t\t\t\tdebounced.resolve = resolve;\n\t\t\t\tdebounced.reject = reject;\n\t\t\t\t\n\t\t\t\tif (typeof initial == \"function\") {\n\t\t\t\t\tinitial();\n\t\t\t\t\t\n\t\t\t\t\tinitial = false;\n\t\t\t\t\t\n\t\t\t\t\tif (final === run)\n\t\t\t\t\t\tfinal = false;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!timeout) {\n\t\t\t\t\ttimeout = setTimeout(expired, limit);\n\t\t\t\t\t\n\t\t\t\t\tif (maxWaitExpired)\n\t\t\t\t\t\tmaxWaitTimeout = setTimeout(maxWaitExpired, maxWait);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t});\n\t\t\n\t\treturn debounced.promise;\n\t} as DebouncedFunction<C>, {\n\t\tcallback,\n\t\tpromise: StatefulPromise.resolved(undefined as unknown as R),\n\t\tresolve: noop,\n\t\treject: noop,\n\t\trun,\n\t\tclear: async (shouldRun?: boolean) => {\n\t\t\t\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = undefined;\n\t\t\t\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\tmaxWaitTimeout = undefined;\n\t\t\t\n\t\t\tdebounced.resolve(shouldRun ? await run() : result);\n\t\t\t\n\t\t}\n\t});\n\t\n\treturn debounced;\n}\n\n\ndebounce.noop = Object.assign(() => { /**/ }, {\n\tcallback: noop,\n\tpromise: StatefulPromise.resolved(undefined), // eslint-disable-line unicorn/no-useless-undefined\n\tresolve: noop,\n\treject: noop,\n\trun: noop,\n\tclear: noop\n}) as Debounced<() => void, void>;\n\n\nexport function throttle(callback: Callback, limit?: number, options?: Options) {\n\treturn debounce(callback, limit, {\n\t\tmaxWait: limit,\n\t\tleading: true,\n\t\ttrailing: true,\n\t\t...options\n\t});\n}\n", "export function howmuch(number: [] | number, one: string, two: string, five: boolean | string, shouldPrintNumber = true) {\n\tif (Array.isArray(number))\n\t\tnumber = number.length;\n\t\n\tif (typeof five != \"string\") {\n\t\tshouldPrintNumber = five ?? true;\n\t\tfive = two;\n\t}\n\t\n\t\n\treturn (shouldPrintNumber ? `${number}\u00A0` : \"\") + howmuch.raw(number, one, two, five);\n}\n\nhowmuch.raw = (number: number, one: string, two: string, five = two) => {\n\tnumber = Math.abs(number);\n\tconst u = number % 10;\n\tconst d = number % 100;\n\t\n\treturn (\n\t\t(u === 1 && d !== 11) ?\n\t\t\tone :\n\t\t\t((u >= 2 && u <= 4) && !(d >= 12 && d <= 15)) ?\n\t\t\t\ttwo :\n\t\t\t\tfive\n\t);\n};\n", "export function removeOne<T>(array: T[], item: T): boolean {\n\tconst i = array.indexOf(item);\n\tif (i > -1) {\n\t\tarray.splice(i, 1);\n\t\t\n\t\treturn true;\n\t}\n\t\n\treturn false;\n}\n", "export function unique<T>(array: T[]): T[] {\n\treturn [ ...new Set(array) ];\n}\n", "export const updateSymbol = Symbol(\"update\");\nexport const getHandleUpdateSymbol = Symbol(\"getHandleUpdate\");\nexport const setHandleUpdateSymbol = Symbol(\"setHandleUpdate\");\nexport const getAsUpdatesSymbol = Symbol(\"getAsUpdates\");\nexport const getAsInitialUpdatedSymbol = Symbol(\"getAsInitialUpdated\");\nexport const clearSymbol = Symbol(\"clear\");\nexport const subscribeSymbol = Symbol(\"subscribe\");\nexport const unsubscribeSymbol = Symbol(\"unsubscribe\");\nexport const renewSymbol = Symbol(\"renew\");\nexport const getSubscriptionSymbol = Symbol(\"getSubscription\");\nexport const getHandleSubscriptionSymbol = Symbol(\"getHandleSubscription\");\nexport const setHandleSubscriptionSymbol = Symbol(\"setHandleSubscription\");\n", "import { removeOne } from \"@nesvet/n\";\nimport { Subscription } from \"./Subscription\";\nimport {\n\tclearSymbol,\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\tgetSubscriptionSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol,\n\tupdateSymbol\n} from \"./symbols\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\ntype Item = unknown;\n\nexport type Updated<I extends Item = Item> = I[] & {\n\tdeleted: I[];\n\tadded: I[];\n};\n\nexport type Updates<I extends Item = Item> =\n\t(\n\t\t[ \"a\"/* add */, newItem: I ] |\n\t\t[ \"d\"/* delete */, itemToDelete: I ] |\n\t\t[ \"i\"/* initial */, items: I[], sort?: -1 | 0 | 1 ] |\n\t\tnull\n\t)[] |\n\tnull;\n\nexport type UpdateHandler<I extends Item = Item> = (array: SubscriptionArray<I>, updated: Updated<I>, updates: Updates<I>) => void;\n\nconst ascSort = (a: any, b: any) => a > b ? 1 : a < b ? -1 : 0;\nconst descSort = (a: any, b: any) => a > b ? -1 : a < b ? 1 : 0;\n\n\nexport class SubscriptionArray<I extends Item = Item> extends Array<I> {\n\tconstructor(updates?: Updates<I>, onUpdate?: UpdateHandler<I>) {\n\t\tsuper();\n\t\t\n\t\tif (onUpdate)\n\t\t\tthis.handleUpdate = onUpdate;\n\t\t\n\t\tif (Array.isArray(updates))\n\t\t\tthis.update(updates);\n\t\t\n\t}\n\t\n\tsorted: I[] = [];\n\t\n\thandleUpdate;\n\t\n\tsortDirection: -1 | 0 | 1 = 0;\n\t\n\tsortCompareFunction: typeof ascSort | typeof descSort | null = null;\n\t\n\t[getHandleUpdateSymbol]() {\n\t\treturn this.handleUpdate;\n\t}\n\t\n\t[setHandleUpdateSymbol](handleUpdate: UpdateHandler<I>) {\n\t\treturn (this.handleUpdate = handleUpdate);\n\t}\n\t\n\tupdate(updates: Updates<I>) {\n\t\t\n\t\tconst updated: Updated<I> = Object.assign([], {\n\t\t\tdeleted: [],\n\t\t\tadded: []\n\t\t});\n\t\t\n\t\tif (updates) {\n\t\t\tlet shouldSort = false;\n\t\t\t\n\t\t\tfor (const update of updates)\n\t\t\t\tswitch (update?.[0]) {\n\t\t\t\t\tcase \"i\"/* initial */: {\n\t\t\t\t\t\tconst [ , array, sort ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (sort) {\n\t\t\t\t\t\t\tthis.sortDirection = sort;\n\t\t\t\t\t\t\tthis.sortCompareFunction = sort > 0 ? ascSort : descSort;\n\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.sortDirection = 0;\n\t\t\t\t\t\t\tthis.sortCompareFunction = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.length = 0;\n\t\t\t\t\t\t\n\t\t\t\t\t\tfor (const newItem of array) {\n\t\t\t\t\t\t\tthis.push(newItem);\n\t\t\t\t\t\t\tupdated.push(newItem);\n\t\t\t\t\t\t\tupdated.added.push(newItem);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"a\"/* add */: {\n\t\t\t\t\t\tconst [ , newItem ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (!this.includes(newItem)) {\n\t\t\t\t\t\t\tthis.push(newItem);\n\t\t\t\t\t\t\tif (this.sortDirection)\n\t\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t\tupdated.push(newItem);\n\t\t\t\t\t\t\tupdated.added.push(newItem);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"d\"/* delete */: {\n\t\t\t\t\t\tconst [ , itemToDelete ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (removeOne(this, itemToDelete))\n\t\t\t\t\t\t\tupdated.deleted.push(itemToDelete);\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthis.clear();\n\t\t\t\t}\n\t\t\t\n\t\t\tif (shouldSort && this.sortCompareFunction)\n\t\t\t\tthis.sort(this.sortCompareFunction);\n\t\t\t\n\t\t} else\n\t\t\tthis.clear();\n\t\t\n\t\tthis.handleUpdate?.(this, updated, updates?.[0] ? updates : null);\n\t\t\n\t\treturn this;\n\t}\n\t\n\t[updateSymbol] = this.update;\n\t\n\tgetAsUpdates(): Updates<I> {\n\t\treturn (\n\t\t\t(this.length || this.sortDirection) ?\n\t\t\t\t[ [ \"i\"/* initial */, [ ...this ], this.sortDirection ] ] :\n\t\t\t\tnull\n\t\t);\n\t}\n\t\n\t[getAsUpdatesSymbol] = this.getAsUpdates;\n\t\n\tgetAsInitialUpdated(): Updated<I> {\n\t\treturn Object.assign([ ...this.sorted ], {\n\t\t\tadded: [ ...this.sorted ],\n\t\t\tdeleted: []\n\t\t});\n\t}\n\t\n\t[getAsInitialUpdatedSymbol] = this.getAsInitialUpdated;\n\t\n\tclear() {\n\t\t\n\t\tthis.length = 0;\n\t\tthis.sortDirection = 0;\n\t\tthis.sortCompareFunction = null;\n\t\t\n\t}\n\t\n\t[clearSymbol] = this.clear;\n\t\n\tvalueOf() {\n\t\treturn this;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionArray\";\n\t}\n\t\n\t\n\tstatic updateSymbol = updateSymbol;\n\tstatic getHandleUpdateSymbol = getHandleUpdateSymbol;\n\tstatic setHandleUpdateSymbol = setHandleUpdateSymbol;\n\tstatic getAsUpdatesSymbol = getAsUpdatesSymbol;\n\tstatic getAsInitialUpdatedSymbol = getAsInitialUpdatedSymbol;\n\tstatic clearSymbol = clearSymbol;\n\tstatic WithSubscription: typeof SubscriptionArrayWithSubscription;\n\t\n}\n\n\nexport class SubscriptionArrayWithSubscription<I extends Item = Item> extends SubscriptionArray<I> {\n\tconstructor(publicationName: string, params: unknown[], onUpdate: UpdateHandler<I>, immediately = true) {\n\t\tsuper(null, onUpdate);\n\t\t\n\t\tthis.publicationName = publicationName;\n\t\tthis.params = params;\n\t\t\n\t\tif (immediately)\n\t\t\tthis.subscribe();\n\t\t\n\t}\n\t\n\tpublicationName;\n\tparams;\n\tsubscription: Subscription | null = null;\n\t\n\tsubscribe() {\n\t\t\n\t\tif (!this.subscription)\n\t\t\tthis.subscription = new Subscription(\"array\", this.publicationName, this.params, updates => this.update(updates as Updates<I>));\n\t\t\n\t}\n\t\n\tget [subscribeSymbol]() {\n\t\treturn this.subscribe;\n\t}\n\t\n\tunsubscribe() {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.subscription.cancel();\n\t\t\tthis.subscription = null;\n\t\t}\n\t\t\n\t}\n\t\n\tget [unsubscribeSymbol]() {\n\t\treturn this.unsubscribe;\n\t}\n\t\n\trenew(publicationName?: string, params?: unknown[]) {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.unsubscribe();\n\t\t\t\n\t\t\tif (publicationName)\n\t\t\t\tif (Array.isArray(publicationName))\n\t\t\t\t\tparams = publicationName;\n\t\t\t\telse\n\t\t\t\t\tthis.publicationName = publicationName;\n\t\t\t\n\t\t\tif (params)\n\t\t\t\tthis.params = params;\n\t\t\t\n\t\t\tthis.subscribe();\n\t\t}\n\t\t\n\t}\n\t\n\tget [renewSymbol]() {\n\t\treturn this.renew;\n\t}\n\t\n\t[getSubscriptionSymbol]() {\n\t\treturn this.subscription;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionArrayWithSubscription\";\n\t}\n\t\n\t\n\tstatic subscribeSymbol = subscribeSymbol;\n\tstatic unsubscribeSymbol = unsubscribeSymbol;\n\tstatic renewSymbol = renewSymbol;\n\tstatic getSubscriptionSymbol = getSubscriptionSymbol;\n\t\n}\n\nSubscriptionArray.WithSubscription = SubscriptionArrayWithSubscription;\n", "import EventEmitter from \"eventemitter3\";\nimport { debounce, StatefulPromise } from \"@nesvet/n\";\nimport { privates } from \"./common\";\nimport { SubscriptionGroupItem } from \"./SubscriptionGroupItem\";\nimport {\n\tDefinition,\n\tParseValues,\n\tSubscriptionHandle,\n\tSubscriptionOnBeforeInit,\n\tSubscriptionType,\n\tTupleDefinition,\n\tUnparsedDefinition\n} from \"./types\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\nfunction isTupleDefinition<T extends SubscriptionType>(definition: UnparsedDefinition<T>): definition is TupleDefinition {\n\treturn Array.isArray(definition);\n}\n\ntype Target = any;\n\ntype Options = {\n\ttarget?: Target;\n\tdebounce?: number;\n\timmediately?: boolean;\n};\n\n\nfunction parseDefinition<T extends SubscriptionType>(definition: UnparsedDefinition<T>) {\n\tif (isTupleDefinition(definition)) {\n\t\tconst args = definition.slice();\n\t\t\n\t\tconst parsed: Partial<Definition<T>> = {};\n\t\t\n\t\tparsed.name = args.shift() as Definition<T>[\"name\"];\n\t\tif (typeof args[0] == \"object\" && !Array.isArray(args[0])) {\n\t\t\tparsed.value = args.shift() as Definition<T>[\"value\"];\n\t\t\tparsed.type = parsed.value!.toString().match(/Subscription(Object|Array|Map)/)?.[1].toLowerCase() as Definition<T>[\"type\"];\n\t\t\tif (!parsed.type)\n\t\t\t\tthrow new Error(\"Unknown value type\");\n\t\t} else {\n\t\t\tif (typeof args[0] == \"string\")\n\t\t\t\tparsed.type = args.shift() as Definition<T>[\"type\"];\n\t\t\tif (typeof args[0] == \"string\")\n\t\t\t\tparsed.publicationName = args.shift() as Definition<T>[\"publicationName\"];\n\t\t\tif (Array.isArray(args[0]))\n\t\t\t\tparsed.params = args.shift() as Definition<T>[\"params\"];\n\t\t}\n\t\t\n\t\tif (typeof args[0] == \"function\")\n\t\t\tparsed.handle = args.shift() as SubscriptionHandle<T>;\n\t\tif (typeof args[0] == \"function\")\n\t\t\tparsed.onBeforeInit = args.shift() as SubscriptionOnBeforeInit<T>;\n\t\tif (typeof args[0] == \"number\")\n\t\t\tparsed.debounce = args.shift() as Definition<T>[\"debounce\"];\n\t\tif (typeof args[0] == \"boolean\")\n\t\t\tparsed.preventBind = args.shift() as Definition<T>[\"preventBind\"];\n\t\t\n\t\treturn parsed as Definition<T>;\n\t}\n\t\n\tdefinition.type ??= \"object\" as T;\n\t\n\treturn definition;\n}\n\nexport class SubscriptionGroup<DS extends UnparsedDefinition[] = any[]> extends EventEmitter {\n\tconstructor(\n\t\tdefinitions: DS,\n\t\t{\n\t\t\ttarget,\n\t\t\tdebounce: debounceLimit = SubscriptionGroup.debounceLimit,\n\t\t\timmediately\n\t\t}: Options = {}\n\t) {\n\t\tsuper();\n\t\t\n\t\tthis.applyOptions({ target, debounceLimit });\n\t\t\n\t\tthis.#initPromise = new StatefulPromise();\n\t\t\n\t\tvoid this.attach(definitions, false, immediately);\n\t\t\n\t}\n\t\n\ttarget?: Target;\n\temitUpdate!: () => void;\n\t\n\titems = [] as unknown as Record<string, SubscriptionGroupItem> & SubscriptionGroupItem[];\n\tvalues = [] as DS extends any ? (any[] & Record<string, any>) : ParseValues<DS>;\n\t\n\tisLoaded = false;\n\tisInited = false;\n\t\n\t#loadPromise!: StatefulPromise<SubscriptionGroup>;\n\t#initPromise: StatefulPromise<SubscriptionGroup>;\n\t#unloadPromise!: StatefulPromise<SubscriptionGroup>;\n\t\n\t#debounceLimit?: number | null = null;\n\t\n\tapplyOptions({ target, debounceLimit }: { target?: Target; debounceLimit?: number }) {\n\t\t\n\t\tif (this.target !== target) {\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (item.isLoaded && !item.preventBind)\n\t\t\t\t\t\tdelete this.target[item.name];\n\t\t\t\n\t\t\tthis.target = target;\n\t\t\t\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (item.isLoaded && !item.preventBind)\n\t\t\t\t\t\tthis.target[item.name] = item.value;\n\t\t}\n\t\t\n\t\tif (this.#debounceLimit !== debounceLimit) {\n\t\t\tthis.#debounceLimit = debounceLimit;\n\t\t\tif (typeof this.#debounceLimit == \"number\") {\n\t\t\t\tconst emitUpdateDebounced = debounce(() => this.emit(\"update\", this.values), this.#debounceLimit);\n\t\t\t\tthis.emitUpdate = () => emitUpdateDebounced();\n\t\t\t} else\n\t\t\t\tthis.emitUpdate = () => this.emit(\"update\", this.values);\n\t\t}\n\t\t\n\t}\n\t\n\tattach(definitions: DS, shouldReload = this.isLoaded, immediately = true) {\n\t\tif (shouldReload)\n\t\t\tthis.isLoaded = false;\n\t\t\n\t\tif (!this.#loadPromise || this.#loadPromise.isFulfilled)\n\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t\n\t\tif (!this.#unloadPromise || this.#unloadPromise.isFulfilled)\n\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t\n\t\treturn Promise.all(definitions.map(definition =>\n\t\t\tnew SubscriptionGroupItem(parseDefinition(definition), this)\n\t\t).map(item => {\n\t\t\t\n\t\t\tif (immediately)\n\t\t\t\titem.subscribe();\n\t\t\t\n\t\t\treturn item.loaded();\n\t\t}));\n\t}\n\t\n\tdetach(names: string[], shouldUpdate = true) {\n\t\t\n\t\tfor (const name of names)\n\t\t\tthis.items[name]?.detach();\n\t\t\n\t\tif (shouldUpdate) {\n\t\t\tthis.#unload();\n\t\t\tthis.#load();\n\t\t}\n\t\t\n\t}\n\t\n\tredefine(definitions: DS) {\n\t\t\n\t\tconst itemsToDetach = new Map(this.items.map(item => [ item.name, item ]));\n\t\tconst definitionsToRedefine = [];\n\t\tconst definitionsToAttach = [] as unknown as DS;\n\t\t\n\t\tfor (let definition of definitions) {\n\t\t\tdefinition = parseDefinition(definition);\n\t\t\tif (itemsToDetach.delete(definition.name))\n\t\t\t\tdefinitionsToRedefine.push(definition);\n\t\t\telse\n\t\t\t\tdefinitionsToAttach.push(definition);\n\t\t}\n\t\t\n\t\tthis.isLoaded = false;\n\t\t\n\t\tthis.detach([ ...itemsToDetach.keys() ], false);\n\t\t\n\t\treturn Promise.all([\n\t\t\t...definitionsToRedefine.map(definition => {\n\t\t\t\tconst item = this.items[definition.name];\n\t\t\t\titem.define(definition);\n\t\t\t\t\n\t\t\t\titem.subscribe();\n\t\t\t\t\n\t\t\t\treturn item.loaded();\n\t\t\t}),\n\t\t\t...definitionsToAttach.length ? [ this.attach(definitionsToAttach, false) ] : []\n\t\t]);\n\t}\n\t\n\tsubscribe() {\n\t\treturn this.items.map(item => item.subscribe());\n\t}\n\t\n\tunsubscribe() {\n\t\treturn this.items.map(item => item.unsubscribe());\n\t}\n\t\n\t#load() {\n\t\t\n\t\tif (!this.isLoaded && this.items.every(item => item.isLoaded)) {\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (!item.preventBind)\n\t\t\t\t\t\tthis.target[item.name] = item.value;\n\t\t\t\n\t\t\tthis.isLoaded = true;\n\t\t\t\n\t\t\tfor (const item of this.items)\n\t\t\t\tprivates.itemLoad!(item);\n\t\t\t\n\t\t\tthis.emit(\"load\", this.values);\n\t\t\t\n\t\t\tif (this.isInited)\n\t\t\t\tif (this.items.length)\n\t\t\t\t\tfor (const item of this.items)\n\t\t\t\t\t\titem.emitUpdate();\n\t\t\t\telse\n\t\t\t\t\tthis.emitUpdate();\n\t\t\t\n\t\t\t\n\t\t\tthis.#loadPromise.resolve(this);\n\t\t\t\n\t\t\tif (this.#unloadPromise.isFulfilled)\n\t\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t}\n\t\t\n\t}\n\t\n\t#init() {\n\t\t\n\t\tif (!this.isInited && this.items.every(item => item.isInited)) {\n\t\t\tthis.isInited = true;\n\t\t\t\n\t\t\tif (this.isLoaded)\n\t\t\t\tif (this.items.length)\n\t\t\t\t\tfor (const item of this.items)\n\t\t\t\t\t\titem.emitUpdate();\n\t\t\t\telse\n\t\t\t\t\tthis.emitUpdate();\n\t\t\t\n\t\t\t\n\t\t\tfor (const item of this.items)\n\t\t\t\tprivates.itemInit!(item);\n\t\t\t\n\t\t\tthis.emit(\"init\", this.values);\n\t\t\t\n\t\t\tthis.#initPromise.resolve(this);\n\t\t}\n\t\t\n\t}\n\t\n\t#unload() {\n\t\t\n\t\tif (this.isLoaded && this.items.every(item => !item.isLoaded)) {\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (!item.preventBind)\n\t\t\t\t\t\tdelete this.target[item.name];\n\t\t\t\n\t\t\tthis.isLoaded = false;\n\t\t\t\n\t\t\tfor (const item of this.items)\n\t\t\t\tprivates.itemUnload!(item);\n\t\t\t\n\t\t\tthis.emit(\"unload\", this.values);\n\t\t\t\n\t\t\tif (this.items.length)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\titem.emitUpdate();\n\t\t\telse\n\t\t\t\tthis.emitUpdate();\n\t\t\t\n\t\t\tthis.#unloadPromise.resolve(this);\n\t\t\t\n\t\t\tif (this.#loadPromise.isFulfilled)\n\t\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t}\n\t\t\n\t}\n\t\n\tloaded() {\n\t\treturn this.#loadPromise;\n\t}\n\t\n\tinited() {\n\t\treturn this.#initPromise;\n\t}\n\t\n\tunloaded() {\n\t\treturn this.#unloadPromise;\n\t}\n\t\n\tvalueOf() {\n\t\treturn this.values;\n\t}\n\t\n\t[Symbol.iterator]() {\n\t\treturn this.values[Symbol.iterator]();\n\t}\n\t\n\t\n\tstatic debounceLimit = 8;\n\t\n\tstatic {\n\t\t\n\t\tprivates.groupLoad = (group: SubscriptionGroup) => group.#load();\n\t\tprivates.groupInit = (group: SubscriptionGroup) => group.#init();\n\t\tprivates.groupUnload = (group: SubscriptionGroup) => group.#unload();\n\t\t\n\t}\n\t\n}\n\nexport { Options as SubscriptionGroupOptions, Target as SubscriptionGroupTarget };\n", "import type { SubscriptionGroup } from \"./SubscriptionGroup\";\nimport type { SubscriptionGroupItem } from \"./SubscriptionGroupItem\";\nimport type { SubscriptionType } from \"./types\";\n\n\nexport const privates: {\n\tgroupLoad?: (group: SubscriptionGroup) => void;\n\tgroupInit?: (group: SubscriptionGroup) => void;\n\tgroupUnload?: (group: SubscriptionGroup) => void;\n\titemLoad?: <T extends SubscriptionType>(item: SubscriptionGroupItem<T>) => void;\n\titemInit?: <T extends SubscriptionType>(item: SubscriptionGroupItem<T>) => void;\n\titemUnload?: <T extends SubscriptionType>(item: SubscriptionGroupItem<T>) => void;\n} = {};\n", "import EventEmitter from \"eventemitter3\";\nimport { debounce, removeOne, StatefulPromise } from \"@nesvet/n\";\nimport {\n\tSubscriptionArrayWithSubscription,\n\ttype Updated as SubscriptionArrayUpdated,\n\ttype UpdateHandler as SubscriptionArrayUpdateHandler,\n\ttype Updates as SubscriptionArrayUpdates\n} from \"../SubscriptionArray\";\nimport {\n\tSubscriptionMapWithSubscription,\n\ttype Updated as SubscriptionMapUpdated,\n\ttype UpdateHandler as SubscriptionMapUpdateHandler,\n\ttype Updates as SubscriptionMapUpdates\n} from \"../SubscriptionMap\";\nimport {\n\tSubscriptionObjectWithSubscription,\n\ttype Updated as SubscriptionObjectUpdated,\n\ttype UpdateHandler as SubscriptionObjectUpdateHandler,\n\ttype Updates as SubscriptionObjectUpdates\n} from \"../SubscriptionObject\";\nimport {\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol\n} from \"../symbols\";\nimport { privates } from \"./common\";\nimport type { SubscriptionGroup } from \"./SubscriptionGroup\";\nimport type {\n\tDefinition,\n\tSubscriptionHandle,\n\tSubscriptionOnBeforeInit,\n\tSubscriptionType,\n\tSubscriptionUpdated,\n\tSubscriptionUpdates,\n\tSubscriptionValue\n} from \"./types\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\ntype HandleSubscription<T> = (_: any, updated: SubscriptionUpdated<T>, updates: SubscriptionUpdates<T>) => void;\n\nfunction isUpdatedMapOrArray(updated: SubscriptionUpdated<SubscriptionType>): updated is SubscriptionArrayUpdated | SubscriptionMapUpdated {\n\treturn Array.isArray(updated);\n}\n\n\nexport class SubscriptionGroupItem<T extends SubscriptionType = SubscriptionType, D extends Definition<T> = Definition<T>> extends EventEmitter {\n\tconstructor(definition: D, group: SubscriptionGroup) {\n\t\tsuper();\n\t\t\n\t\tthis.name = definition.name;\n\t\t\n\t\tthis.define(definition, group);\n\t\t\n\t}\n\t\n\tname;\n\tgroup?: SubscriptionGroup;\n\tvalue?: SubscriptionValue<T>;\n\ttype!: T | \"object\";\n\tpublicationName!: Definition<T>[\"publicationName\"];\n\tparams!: Definition<T>[\"params\"];\n\thandle!: Definition<T>[\"handle\"];\n\tonBeforeInit!: Definition<T>[\"onBeforeInit\"];\n\tpreventBind!: Definition<T>[\"preventBind\"];\n\t\n\temitUpdate!: (updated?: SubscriptionUpdated<T>) => void;\n\t\n\tisLoaded = false;\n\tisInited = false;\n\t\n\t#loadPromise!: StatefulPromise<SubscriptionGroupItem<T, D>>;\n\t#initPromise!: StatefulPromise<SubscriptionGroupItem<T, D>>;\n\t#unloadPromise!: StatefulPromise<SubscriptionGroupItem<T, D>>;\n\t\n\tdefine(definition: Definition<T>, group: SubscriptionGroup | undefined = this.group) {\n\t\tif (!group)\n\t\t\tthrow new Error(\"group is undefined\");\n\t\t\n\t\tconst {\n\t\t\tvalue,\n\t\t\ttype = \"object\",\n\t\t\tpublicationName,\n\t\t\tparams,\n\t\t\thandle,\n\t\t\tonBeforeInit,\n\t\t\tdebounce: debounceLimit = SubscriptionGroupItem.debounceLimit,\n\t\t\tpreventBind\n\t\t} = definition;\n\t\t\n\t\tif (this.group) {\n\t\t\tif (\n\t\t\t\t(!value || this.value === value) &&\n\t\t\t\tthis.type === type &&\n\t\t\t\tthis.publicationName === publicationName &&\n\t\t\t\tJSON.stringify(this.params) === JSON.stringify(params) &&\n\t\t\t\tthis.handle === handle &&\n\t\t\t\tthis.onBeforeInit === onBeforeInit\n\t\t\t)\n\t\t\t\treturn this.#applyOptions({ debounceLimit, preventBind });\n\t\t\t\n\t\t\tthis.detach();\n\t\t\tdelete this.value;\n\t\t\tdelete this.publicationName;\n\t\t\tdelete this.params;\n\t\t}\n\t\t\n\t\tthis.type = type;\n\t\tthis.handle = handle;\n\t\tthis.onBeforeInit = onBeforeInit;\n\t\tif (value)\n\t\t\tthis.value = value;\n\t\telse {\n\t\t\tthis.publicationName = publicationName ?? this.name;\n\t\t\tthis.params = params ?? [];\n\t\t}\n\t\t\n\t\tthis.#applyOptions({ debounceLimit, preventBind });\n\t\t\n\t\tthis.#attachTo(group);\n\t\t\n\t}\n\t\n\t#applyOptions({ debounceLimit, preventBind }: { debounceLimit?: number; preventBind?: boolean }) {\n\t\t\n\t\tconst emitUpdate: typeof this.emitUpdate = updated => {\n\t\t\tthis.emit(\"update\", this.value, updated);\n\t\t\tthis.group?.emit(`update.${this.name}`, this.value, updated);\n\t\t\tthis.group?.emitUpdate();\n\t\t\t\n\t\t};\n\t\t\n\t\tif (typeof debounceLimit == \"number\") {\n\t\t\tlet debouncedUpdated: SubscriptionUpdated<T> | undefined;\n\t\t\tlet group: SubscriptionGroup;\n\t\t\t\n\t\t\tconst emitUpdateDebounced = debounce(() => {\n\t\t\t\t\n\t\t\t\tconst isDetached = !this.group;\n\t\t\t\t\n\t\t\t\tif (isDetached)\n\t\t\t\t\tthis.group = group;\n\t\t\t\t\n\t\t\t\temitUpdate(debouncedUpdated);\n\t\t\t\t\n\t\t\t\tif (isDetached)\n\t\t\t\t\tdelete this.group;\n\t\t\t\t\n\t\t\t\tdebouncedUpdated = undefined;\n\t\t\t\t\n\t\t\t}, debounceLimit);\n\t\t\t\n\t\t\tthis.emitUpdate = updated => {\n\t\t\t\tif (updated !== undefined)\n\t\t\t\t\tif (isUpdatedMapOrArray(updated))\n\t\t\t\t\t\tif (isUpdatedMapOrArray(debouncedUpdated!))\n\t\t\t\t\t\t\tfor (const item of updated)\n\t\t\t\t\t\t\t\tdebouncedUpdated.push(item);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tdebouncedUpdated = Object.assign([ ...updated ], {\n\t\t\t\t\t\t\t\tadded: [ ...updated.added ],\n\t\t\t\t\t\t\t\tdeleted: [ ...updated.deleted ]\n\t\t\t\t\t\t\t}) as SubscriptionUpdated<T>;\n\t\t\t\t\telse if (typeof updated == \"object\")\n\t\t\t\t\t\tif (debouncedUpdated)\n\t\t\t\t\t\t\tObject.assign(debouncedUpdated, updated);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tdebouncedUpdated = { ...updated };// eslint-disable-line @typescript-eslint/no-misused-spread\n\t\t\t\t\telse\n\t\t\t\t\t\tdebouncedUpdated = updated;\n\t\t\t\t\n\t\t\t\tgroup = this.group!;\n\t\t\t\t\n\t\t\t\treturn emitUpdateDebounced();\n\t\t\t};\n\t\t} else\n\t\t\tthis.emitUpdate = emitUpdate;\n\t\t\n\t\tif (this.preventBind === undefined)\n\t\t\tdelete this.preventBind;\n\t\telse\n\t\t\tthis.preventBind = preventBind;\n\t\t\n\t}\n\t\n\t#attachTo(group: SubscriptionGroup) {\n\t\tif (!this.group) {\n\t\t\tthis.group = group;\n\t\t\t\n\t\t\tthis.group.items.push(this as SubscriptionGroupItem<any>);\n\t\t\tthis.group.items[this.name] = this as SubscriptionGroupItem<any>;\n\t\t\t\n\t\t\tif (!this.#loadPromise || this.#loadPromise.isFulfilled)\n\t\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t\t\n\t\t\tif (!this.#initPromise || this.#initPromise.isFulfilled)\n\t\t\t\tthis.#initPromise = new StatefulPromise();\n\t\t\t\n\t\t\tif (!this.#unloadPromise || this.#unloadPromise.isFulfilled)\n\t\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t\t\n\t\t\tswitch (this.type) {\n\t\t\t\tcase \"array\": {\n\t\t\t\t\tconst handleSubscription = this.#handleSubscription as HandleSubscription<\"array\">;\n\t\t\t\t\tif (this.value)\n\t\t\t\t\t\t(this.value as SubscriptionArrayWithSubscription)[setHandleUpdateSymbol](handleSubscription);\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.value = new SubscriptionArrayWithSubscription(this.publicationName!, this.params!, handleSubscription, false) as SubscriptionValue<T>;\n\t\t\t\t\tbreak;\n\t\t\t\t} case \"map\": {\n\t\t\t\t\tconst handleSubscription = this.#handleSubscription as HandleSubscription<\"map\">;\n\t\t\t\t\tif (this.value)\n\t\t\t\t\t\t(this.value as SubscriptionMapWithSubscription)[setHandleUpdateSymbol](handleSubscription);\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.value = new SubscriptionMapWithSubscription(this.publicationName!, this.params!, handleSubscription, false) as SubscriptionValue<T>;\n\t\t\t\t\tbreak;\n\t\t\t\t} default: {\n\t\t\t\t\tconst handleSubscription = this.#handleSubscription as HandleSubscription<\"object\">;\n\t\t\t\t\tif (this.value)\n\t\t\t\t\t\t(this.value as SubscriptionObjectWithSubscription)[setHandleUpdateSymbol](handleSubscription);\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.value = new SubscriptionObjectWithSubscription(this.publicationName!, this.params!, handleSubscription, false) as SubscriptionValue<T>;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tthis.group.values.push(this.value);\n\t\t\tthis.group.values[this.name] = this.value;\n\t\t\t\n\t\t\tif (this.onBeforeInit)\n\t\t\t\tswitch (this.type) {\n\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t(this.onBeforeInit as SubscriptionOnBeforeInit<\"array\">).call(this.group, this.value as SubscriptionArrayWithSubscription);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t(this.onBeforeInit as SubscriptionOnBeforeInit<\"map\">).call(this.group, this.value as SubscriptionMapWithSubscription);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t(this.onBeforeInit as SubscriptionOnBeforeInit<\"object\">).call(this.group, this.value as SubscriptionObjectWithSubscription);\n\t\t\t\t}\n\t\t}\n\t\t\n\t}\n\t\n\tdetach() {\n\t\t\n\t\tif (this.group) {\n\t\t\tthis.value?.[unsubscribeSymbol]();\n\t\t\t\n\t\t\tthis.isLoaded = false;\n\t\t\tthis.#unload();\n\t\t\t\n\t\t\tdelete this.group.values[this.name];// eslint-disable-line @typescript-eslint/no-array-delete\n\t\t\tremoveOne(this.group.values, this.value);\n\t\t\tdelete this.group.items[this.name];// eslint-disable-line @typescript-eslint/no-array-delete\n\t\t\tremoveOne(this.group.items, this as SubscriptionGroupItem<any>);\n\t\t\t\n\t\t\tdelete this.group;\n\t\t}\n\t\t\n\t}\n\t\n\t#loadUpdated: SubscriptionUpdated<T> | null = null;\n\t\n\t#handleSubscription: HandleSubscription<T> = (_, updated, updates) => {\n\t\tif (updates)\n\t\t\tif (this.group!.isLoaded) {\n\t\t\t\tif (this.handle)\n\t\t\t\t\tswitch (this.type) {\n\t\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"array\">).call(this.group!, updated as SubscriptionArrayUpdated, this.group!);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"map\">).call(this.group!, updated as SubscriptionMapUpdated, this.group!);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"object\">).call(this.group!, updated as SubscriptionObjectUpdated, this.group!);\n\t\t\t\t\t}\n\t\t\t\tthis.emitUpdate(updated);\n\t\t\t} else {\n\t\t\t\tthis.#loadUpdated = updated;\n\t\t\t\tthis.isLoaded = true;\n\t\t\t\tprivates.groupLoad!(this.group!);\n\t\t\t}\n\t\telse if (this.isLoaded) {\n\t\t\tthis.isLoaded = false;\n\t\t\tprivates.groupUnload!(this.group!);\n\t\t}\n\t\t\n\t\tif (!this.isInited) {\n\t\t\tthis.isInited = true;\n\t\t\tprivates.groupInit!(this.group!);\n\t\t}\n\t\t\n\t};\n\t\n\t#load() {\n\t\t\n\t\tif (this.#loadUpdated) {\n\t\t\tif (this.handle)\n\t\t\t\tswitch (this.type) {\n\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"array\">).call(this.group!, this.#loadUpdated as SubscriptionArrayUpdated, this.group!);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"map\">).call(this.group!, this.#loadUpdated as SubscriptionMapUpdated, this.group!);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"object\">).call(this.group!, this.#loadUpdated as SubscriptionObjectUpdated, this.group!);\n\t\t\t\t}\n\t\t\t\n\t\t\tthis.#loadUpdated = null;\n\t\t\t\n\t\t\tthis.emit(\"load\", this.value);\n\t\t\t\n\t\t\tthis.#loadPromise.resolve(this);\n\t\t\t\n\t\t\tif (this.#unloadPromise.isFulfilled)\n\t\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t}\n\t\t\n\t}\n\t\n\t#init() {\n\t\t\n\t\tthis.emit(\"init\", this.value);\n\t\t\n\t\tthis.#initPromise.resolve(this);\n\t\t\n\t}\n\t\n\t#unload() {\n\t\t\n\t\tif (this.handle)\n\t\t\tswitch (this.type) {\n\t\t\t\tcase \"array\":\n\t\t\t\t\t(this.handle as SubscriptionHandle<\"array\">).call(this.group!, null, this.group!);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"map\":\n\t\t\t\t\t(this.handle as SubscriptionHandle<\"map\">).call(this.group!, null, this.group!);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t(this.handle as SubscriptionHandle<\"object\">).call(this.group!, null, this.group!);\n\t\t\t}\n\t\t\n\t\tthis.emit(\"unload\", this.value);\n\t\t\n\t\tthis.#unloadPromise.resolve(this);\n\t\t\n\t\tif (this.#loadPromise.isFulfilled)\n\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t\n\t}\n\t\n\tloaded() {\n\t\treturn this.#loadPromise;\n\t}\n\t\n\tinited() {\n\t\treturn this.#initPromise;\n\t}\n\t\n\tunloaded() {\n\t\treturn this.#unloadPromise;\n\t}\n\t\n\tsubscribe() {\n\t\t\n\t\tif (this.value)\n\t\t\tif (this.value[subscribeSymbol])\n\t\t\t\treturn this.value[subscribeSymbol]();\n\t\t\telse {\n\t\t\t\tconst handleUpdate = this.value[getHandleUpdateSymbol]();\n\t\t\t\t\n\t\t\t\tif (handleUpdate) {\n\t\t\t\t\tconst initialUpdated = this.value[getAsInitialUpdatedSymbol]();\n\t\t\t\t\tconst updates = this.value[getAsUpdatesSymbol]();\n\t\t\t\t\t\n\t\t\t\t\tswitch (this.type) {\n\t\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t\treturn (handleUpdate as SubscriptionArrayUpdateHandler)(this.value as SubscriptionArrayWithSubscription, initialUpdated as SubscriptionArrayUpdated, updates as SubscriptionArrayUpdates);\n\t\t\t\t\t\t\n\t\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t\treturn (handleUpdate as SubscriptionMapUpdateHandler)(this.value as SubscriptionMapWithSubscription, initialUpdated as SubscriptionMapUpdated, updates as SubscriptionMapUpdates);\n\t\t\t\t\t\t\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn (handleUpdate as SubscriptionObjectUpdateHandler)(this.value as SubscriptionObjectWithSubscription, initialUpdated as SubscriptionObjectUpdated, updates as SubscriptionObjectUpdates);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t}\n\t\n\tunsubscribe() {\n\t\treturn this.value?.[unsubscribeSymbol]?.();\n\t}\n\t\n\trenew(publicationName: Definition<T>[\"publicationName\"], params: Definition<T>[\"params\"]) {\n\t\treturn this.value?.[renewSymbol]?.(publicationName, params);\n\t}\n\t\n\tvalueOf() {\n\t\treturn this.value;\n\t}\n\t\n\t\n\tstatic debounceLimit = 4;\n\t\n\tstatic {\n\t\t\n\t\tprivates.itemLoad = <\n\t\t\tDP extends Definition<TP>,\n\t\t\tTP extends SubscriptionType\n\t\t>(item: SubscriptionGroupItem<TP, DP>) => item.#load();\n\t\tprivates.itemInit = <\n\t\t\tDP extends Definition<TP>,\n\t\t\tTP extends SubscriptionType\n\t\t>(item: SubscriptionGroupItem<TP, DP>) => item.#init();\n\t\tprivates.itemUnload = <\n\t\t\tDP extends Definition<TP>,\n\t\t\tTP extends SubscriptionType\n\t\t>(item: SubscriptionGroupItem<TP, DP>) => item.#unload();\n\t\t\n\t}\n\t\n}\n", "import { removeOne, unique } from \"@nesvet/n\";\nimport { Subscription } from \"./Subscription\";\nimport {\n\tclearSymbol,\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\tgetSubscriptionSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol,\n\tupdateSymbol\n} from \"./symbols\";\n\n\ntype GenericItem = Record<string, any> & { _id: string };// eslint-disable-line @typescript-eslint/no-explicit-any\n\ntype Item = GenericItem | SubscriptionMapItem;\n\nexport type Updated<I extends Item = Item> = I[] & {\n\tdeleted: string[];\n\tadded: I[];\n};\n\ntype SortList = Record<string, -1 | 1>;\n\nexport type Updates<I extends Item = Item> =\n\t(\n\t\t[ \"c\"/* create */, item: I ] |\n\t\t[ \"d\"/* delete */, _id: string ] |\n\t\t[ \"i\"/* initial */, items: I[], sortList?: SortList | null ] |\n\t\t[ \"u\"/* update */, itemUpdates: Partial<I> & { _id: string }, isAtomicOrUpdatedFields: string[] | true ] |\n\t\tnull\n\t)[] |\n\tnull;\n\nexport type UpdateHandler<I extends Item = Item> = (map: SubscriptionMap<I>, updated: Updated<I>, updates: Updates<I>) => void;\n\ndeclare global {\n\tvar __insite_subscription_map_sort_function: ((a: Item, b: Item) => -1 | 0 | 1) | undefined;// eslint-disable-line no-var, @typescript-eslint/naming-convention\n}\n\nfunction createSortFunction(sortList: SortList) {\n\t\n\tconst tempScript = document.createElement(\"script\");\n\t\n\ttempScript.textContent = `window.__insite_subscription_map_sort_function = function sort(a, b) { return ${\n\t\tObject.entries(sortList)\n\t\t\t.map(([ key, value ]) => {\n\t\t\t\tif (key.includes(\".\"))\n\t\t\t\t\tkey = key.replaceAll(\".\", \"?.\");\n\t\t\t\t\n\t\t\t\treturn value > 0 ? `a.${key} > b.${key} ? 1 : a.${key} < b.${key} ? -1 :` : `a.${key} < b.${key} ? 1 : a.${key} > b.${key} ? -1 :`;\n\t\t\t})\n\t\t\t.concat(\"0\")\n\t\t\t.join(\" \")\n\t};}`;\n\t\n\tdocument.head.append(tempScript);\n\t\n\tconst sortFunction = globalThis.__insite_subscription_map_sort_function!;\n\t\n\ttempScript.remove();\n\tdelete globalThis.__insite_subscription_map_sort_function;\n\t\n\treturn sortFunction;\n}\n\n// function createSortFunction(sortList: SortList) {\n// return new Function(// eslint-disable-line no-new-func\n// \t\t\"a\"/* Item */,\n// \t\t\"b\"/* Item */,\n// \t\t`return ${\n// \t\t\tObject.entries(sortList)\n// \t\t\t\t.map(([ key, value ]) => value > 0 ? `a.${key} > b.${key} ? 1 : a.${key} < b.${key} ? -1 :` : `a.${key} < b.${key} ? 1 : a.${key} > b.${key} ? -1 :`)\n// \t\t\t\t.concat(\"0\")\n// \t\t\t\t.join(\" \")\n// \t\t}`\n// \t) as (a: Item, b: Item) => -1 | 0 | 1;\n// }\n\n\nexport class SubscriptionMap<I extends Item = Item> extends Map<string, I> {\n\tconstructor(updates?: Updates<I>, onUpdate?: UpdateHandler<I>) {\n\t\tsuper();\n\t\t\n\t\tif (onUpdate)\n\t\t\tthis.handleUpdate = onUpdate;\n\t\t\n\t\tif (updates)\n\t\t\tthis.update(updates);\n\t\t\n\t}\n\t\n\thandleUpdate;\n\t\n\t#updates = new Map<string, I>();\n\t\n\tsortList: SortList | null = null;\n\t\n\tsortCompareFunction: ((a: I, b: I) => number) | null = null;\n\t\n\t#fieldsToSort: string[] = [];\n\t\n\tsorted: I[] = [];\n\t\n\tsort() {\n\t\t\n\t\tif (this.sortCompareFunction)\n\t\t\tthis.sorted.sort(this.sortCompareFunction);\n\t\t\n\t}\n\t\n\t[getHandleUpdateSymbol]() {\n\t\treturn this.handleUpdate;\n\t}\n\t\n\t[setHandleUpdateSymbol](handleUpdate: UpdateHandler<I>) {\n\t\treturn (this.handleUpdate = handleUpdate);\n\t}\n\t\n\t#Item!: { new (map: SubscriptionMap<I>, updates: GenericItem): I };\n\t\n\tset Item(TheItem: { new (map: SubscriptionMap<I>, updates: GenericItem): I }) { // eslint-disable-line @typescript-eslint/naming-convention\n\t\tthis.#Item = TheItem;\n\t\t\n\t\tif (this.size)\n\t\t\tfor (const [ _id, item ] of this)\n\t\t\t\tthis.set(_id, new TheItem(this, item));\n\t\t\n\t}\n\t\n\tget Item() {\n\t\treturn this.#Item;\n\t}\n\t\n\tupdate(updates: Updates<I>) {\n\t\t\n\t\tconst updated: Updated<I> = Object.assign([], {\n\t\t\tadded: [],\n\t\t\tdeleted: []\n\t\t});\n\t\t\n\t\tif (updates) {\n\t\t\tlet shouldSort = false;\n\t\t\t\n\t\t\tconst TheItem = this.#Item;// eslint-disable-line @typescript-eslint/naming-convention\n\t\t\tconst prevUpdates = this.#updates;\n\t\t\t\n\t\t\tfor (const update of updates)\n\t\t\t\tswitch (update?.[0]) {\n\t\t\t\t\tcase \"i\"/* initial */: {\n\t\t\t\t\t\tconst [ , array, sortList ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (sortList) {\n\t\t\t\t\t\t\tthis.sortList = sortList;\n\t\t\t\t\t\t\tthis.sortCompareFunction = createSortFunction(sortList);\n\t\t\t\t\t\t\tthis.#fieldsToSort = unique(Object.keys(sortList).map(key => key.replace(/\\..+/, \"\")));\n\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.sortList = null;\n\t\t\t\t\t\t\tthis.sortCompareFunction = null;\n\t\t\t\t\t\t\tthis.#fieldsToSort = [];\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (this.size) {\n\t\t\t\t\t\t\tconst updatesMap = new Map<string, I>();\n\t\t\t\t\t\t\tfor (const itemUpdates of array)\n\t\t\t\t\t\t\t\tupdatesMap.set(itemUpdates._id, itemUpdates);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tfor (const [ _id, item ] of this) {\n\t\t\t\t\t\t\t\tconst itemUpdates = updatesMap.get(_id);\n\t\t\t\t\t\t\t\tif (itemUpdates) {\n\t\t\t\t\t\t\t\t\tconst prevItemUpdates = prevUpdates.get(_id);\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\t\t\titem.update(itemUpdates);\n\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\tfor (const key in prevItemUpdates)// eslint-disable-line guard-for-in\n\t\t\t\t\t\t\t\t\t\t\tdelete item[key as keyof typeof item];\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tObject.assign(item, itemUpdates);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tprevUpdates.set(_id, itemUpdates);\n\t\t\t\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\t\t\tupdatesMap.delete(_id);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\t\t\titem.delete();\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\tthis.delete(_id);\n\t\t\t\t\t\t\t\t\tprevUpdates.delete(_id);\n\t\t\t\t\t\t\t\t\tupdated.deleted.push(_id);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tfor (const [ _id, itemUpdates ] of updatesMap) {\n\t\t\t\t\t\t\t\tconst item = TheItem ? new TheItem(this, itemUpdates) : { ...itemUpdates };\n\t\t\t\t\t\t\t\tthis.set(_id, item);\n\t\t\t\t\t\t\t\tprevUpdates.set(_id, itemUpdates);\n\t\t\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\t\tupdated.added.push(item);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (this.sortList)\n\t\t\t\t\t\t\t\tthis.sorted = array.map(newItem => this.get(newItem._id)!);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t\tfor (const itemUpdates of array) {\n\t\t\t\t\t\t\t\tconst item = (TheItem ? new TheItem(this, itemUpdates) : { ...itemUpdates });\n\t\t\t\t\t\t\t\tthis.set(item._id, item);\n\t\t\t\t\t\t\t\tthis.sorted.push(item);\n\t\t\t\t\t\t\t\tprevUpdates.set(item._id, itemUpdates);\n\t\t\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\t\tupdated.added.push(item);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"c\"/* create */:\n\t\t\t\t\tcase \"u\"/* update */: {\n\t\t\t\t\t\tlet [ , itemUpdates ] = update;\n\t\t\t\t\t\tlet item = this.get(itemUpdates._id);\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (item) {\n\t\t\t\t\t\t\tconst isAtomic = update[2] === true;\n\t\t\t\t\t\t\tconst updatedFields = isAtomic ? Object.keys(itemUpdates) : update[2] as string[];\n\t\t\t\t\t\t\tconst prevItemUpdates = prevUpdates.get(item._id)!;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\titem.update(itemUpdates);\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tif (!isAtomic)\n\t\t\t\t\t\t\t\t\tfor (const key in prevItemUpdates)// eslint-disable-line guard-for-in\n\t\t\t\t\t\t\t\t\t\tdelete item[key as keyof typeof item];\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tObject.assign(item, itemUpdates);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (isAtomic)\n\t\t\t\t\t\t\t\titemUpdates = Object.assign(prevItemUpdates, itemUpdates);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (this.sortList && !shouldSort && (!updatedFields || updatedFields.some(fieldName => this.#fieldsToSort.includes(fieldName))))\n\t\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tconsole.log(\"\u2B55\uFE0F\uD83D\uDFE2\u2B55\uFE0F\uD83D\uDFE2\u2B55\uFE0F shouldSort\", shouldSort);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\titem = (TheItem ? new TheItem(this, itemUpdates) : { ...itemUpdates }) as I;\n\t\t\t\t\t\t\tthis.set(item._id, item);\n\t\t\t\t\t\t\tthis.sorted.push(item);\n\t\t\t\t\t\t\tif (this.sortList)\n\t\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t\tupdated.added.push(item);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tprevUpdates.set(item._id, itemUpdates as I);\n\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"d\"/* delete */: {\n\t\t\t\t\t\tconst [ , _id ] = update;\n\t\t\t\t\t\tconst itemToDelete = this.get(_id);\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (itemToDelete) {\n\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\titemToDelete.delete();\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tthis.delete(_id);\n\t\t\t\t\t\t\tprevUpdates.delete(_id);\n\t\t\t\t\t\t\tremoveOne(this.sorted, itemToDelete);\n\t\t\t\t\t\t\tupdated.deleted.push(_id);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthis.clear();\n\t\t\t\t}\n\t\t\t\n\t\t\tif (shouldSort)\n\t\t\t\tthis.sort();\n\t\t\t\n\t\t} else\n\t\t\tthis.clear();\n\t\t\n\t\tthis.handleUpdate?.(this, updated, updates?.[0] ? updates : null);\n\t\t\n\t\treturn this;\n\t}\n\t\n\t[updateSymbol] = this.update;\n\t\n\tgetAsUpdates(): Updates<I> {\n\t\treturn (\n\t\t\t(this.size || this.sortList) ?\n\t\t\t\t[ [ \"i\"/* initial */, [ ...this.#updates.values() ], this.sortList ] ] :\n\t\t\t\tnull\n\t\t);\n\t}\n\t\n\t[getAsUpdatesSymbol] = this.getAsUpdates;\n\t\n\tgetAsInitialUpdated(): Updated<I> {\n\t\treturn Object.assign([ ...this.sorted ], {\n\t\t\tadded: [ ...this.sorted ],\n\t\t\tdeleted: []\n\t\t});\n\t}\n\t\n\t[getAsInitialUpdatedSymbol] = this.getAsInitialUpdated;\n\t\n\tclear() {\n\t\t\n\t\tsuper.clear();\n\t\tthis.#updates.clear();\n\t\tthis.sorted = [];\n\t\tthis.sortList = null;\n\t\tthis.sortCompareFunction = null;\n\t\tthis.#fieldsToSort = [];\n\t\t\n\t}\n\t\n\t[clearSymbol] = this.clear;\n\t\n\tvalueOf() {\n\t\treturn this.sorted;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionMap\";\n\t}\n\t\n\t\n\tstatic updateSymbol = updateSymbol;\n\tstatic getHandleUpdateSymbol = getHandleUpdateSymbol;\n\tstatic setHandleUpdateSymbol = setHandleUpdateSymbol;\n\tstatic getAsUpdatesSymbol = getAsUpdatesSymbol;\n\tstatic getAsInitialUpdatedSymbol = getAsInitialUpdatedSymbol;\n\tstatic clearSymbol = clearSymbol;\n\tstatic WithSubscription: typeof SubscriptionMapWithSubscription;\n\tstatic Item: typeof SubscriptionMapItem;\n\t\n}\n\n\nexport class SubscriptionMapWithSubscription<I extends Item = Item> extends SubscriptionMap<I> {\n\tconstructor(publicationName: string, params: unknown[], onUpdate: UpdateHandler<I>, immediately = true) {\n\t\tsuper(null, onUpdate);\n\t\t\n\t\tthis.publicationName = publicationName;\n\t\tthis.params = params;\n\t\t\n\t\tif (immediately)\n\t\t\tthis.subscribe();\n\t\t\n\t}\n\t\n\tpublicationName;\n\tparams;\n\t\n\tsubscription: Subscription | null = null;\n\t\n\tsubscribe() {\n\t\t\n\t\tif (!this.subscription)\n\t\t\tthis.subscription = new Subscription(\"map\", this.publicationName, this.params, updates => this.update(updates as Updates<I>));\n\t\t\n\t}\n\t\n\tget [subscribeSymbol]() {\n\t\treturn this.subscribe;\n\t}\n\t\n\tunsubscribe() {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.subscription.cancel();\n\t\t\tthis.subscription = null;\n\t\t}\n\t\t\n\t}\n\t\n\tget [unsubscribeSymbol]() {\n\t\treturn this.unsubscribe;\n\t}\n\t\n\trenew(publicationName?: string, params?: unknown[]) {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.unsubscribe();\n\t\t\t\n\t\t\tif (publicationName)\n\t\t\t\tif (Array.isArray(publicationName))\n\t\t\t\t\tparams = publicationName;\n\t\t\t\telse\n\t\t\t\t\tthis.publicationName = publicationName;\n\t\t\t\n\t\t\tif (params)\n\t\t\t\tthis.params = params;\n\t\t\t\n\t\t\tthis.subscribe();\n\t\t}\n\t\t\n\t}\n\t\n\tget [renewSymbol]() {\n\t\treturn this.renew;\n\t}\n\t\n\t[getSubscriptionSymbol]() {\n\t\treturn this.subscription;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionMapWithSubscription\";\n\t}\n\t\n\t\n\tstatic subscribeSymbol = subscribeSymbol;\n\tstatic unsubscribeSymbol = unsubscribeSymbol;\n\tstatic renewSymbol = renewSymbol;\n\tstatic getSubscriptionSymbol = getSubscriptionSymbol;\n\t\n}\n\nSubscriptionMap.WithSubscription = SubscriptionMapWithSubscription;\n\n\nexport class SubscriptionMapItem {\n\tconstructor(map: SubscriptionMap, updates: GenericItem) {\n\t\tthis.#map = map;\n\t\t\n\t\tthis.update(updates);\n\t\t\n\t}\n\t\n\t_id!: string;\n\t\n\t#map;\n\t\n\tupdate(updates: GenericItem) {\n\t\tObject.assign(this, updates);\n\t\t\n\t}\n\t\n\tdelete() {\n\t\t\n\t\tthis.#map.delete(this._id);\n\t\t\n\t}\n\t\n}\n\nSubscriptionMap.Item = SubscriptionMapItem;\n", "import { Subscription } from \"./Subscription\";\nimport {\n\tclearSymbol,\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\tgetSubscriptionSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol,\n\tupdateSymbol\n} from \"./symbols\";\n\n\nconst handleUpdateSymbol = Symbol(\"handleUpdate\");\nconst updatesSymbol = Symbol(\"updates\");\n\nexport type Updated = Record<string, unknown>;\nexport type Updates = Record<string, unknown> | null;\nexport type UpdateHandler = (object: SubscriptionObject, updated: Updated, updates: Updates) => void;\n\n\nexport class SubscriptionObject {\n\tconstructor(updates?: Updates, onUpdate?: UpdateHandler) {\n\t\tif (onUpdate)\n\t\t\tthis[handleUpdateSymbol] = onUpdate;\n\t\t\n\t\tif (updates)\n\t\t\tthis[updateSymbol](updates);\n\t\t\n\t}\n\t\n\t[handleUpdateSymbol]?: UpdateHandler;\n\t\n\t[updatesSymbol]: Updates = null;\n\t\n\t[getHandleUpdateSymbol]() {\n\t\treturn this[handleUpdateSymbol];\n\t}\n\t\n\t[setHandleUpdateSymbol](handleUpdate: UpdateHandler) {\n\t\treturn (this[handleUpdateSymbol] = handleUpdate);\n\t}\n\t\n\t[updateSymbol](updates: Updates) {\n\t\tif (updates) {\n\t\t\tfor (const key in this[updatesSymbol])// eslint-disable-line guard-for-in\n\t\t\t\tdelete this[key];\n\t\t\tfor (const key in updates)// eslint-disable-line guard-for-in\n\t\t\t\tthis[key] = updates[key];\n\t\t\tthis[updatesSymbol] = updates;\n\t\t} else\n\t\t\tthis[clearSymbol]();\n\t\t\n\t\tthis[handleUpdateSymbol]?.(this, this, this[updatesSymbol]);\n\t\t\n\t\treturn this;\n\t}\n\t\n\t[getAsUpdatesSymbol](): Updates {\n\t\treturn this[updatesSymbol] && { ...this[updatesSymbol] };\n\t}\n\t\n\t[getAsInitialUpdatedSymbol](): Updated {\n\t\treturn this.valueOf()!;\n\t}\n\t\n\t[clearSymbol]() {\n\t\t\n\t\tfor (const key in this)// eslint-disable-line guard-for-in\n\t\t\tdelete this[key];\n\t\tthis[updatesSymbol] = null;\n\t\t\n\t}\n\t\n\tvalueOf() {\n\t\treturn this[updatesSymbol] && this;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionObject\";\n\t}\n\t\n\t[key: string]: unknown;\n\t\n\t\n\tstatic updateSymbol = updateSymbol;\n\tstatic getHandleUpdateSymbol = getHandleUpdateSymbol;\n\tstatic setHandleUpdateSymbol = setHandleUpdateSymbol;\n\tstatic getAsUpdatesSymbol = getAsUpdatesSymbol;\n\tstatic getAsInitialUpdatedSymbol = getAsInitialUpdatedSymbol;\n\tstatic clearSymbol = clearSymbol;\n\tstatic WithSubscription: typeof SubscriptionObjectWithSubscription;\n\t\n}\n\n\nexport class SubscriptionObjectWithSubscription extends SubscriptionObject {\n\tconstructor(publicationName: string, params: unknown[], onUpdate: UpdateHandler, immediately = true) {\n\t\tsuper(null, onUpdate);\n\t\t\n\t\tthis.#publicationName = publicationName;\n\t\tthis.#params = params;\n\t\t\n\t\tif (immediately)\n\t\t\tthis[subscribeSymbol]();\n\t\t\n\t}\n\t\n\t#publicationName;\n\t#params;\n\t#subscription: Subscription | null = null;\n\t\n\t[subscribeSymbol]() {\n\t\t\n\t\tif (!this.#subscription)\n\t\t\tthis.#subscription = new Subscription(\"object\", this.#publicationName, this.#params, updates => this[updateSymbol](updates as Updates));\n\t\t\n\t}\n\t\n\t[unsubscribeSymbol]() {\n\t\t\n\t\tif (this.#subscription) {\n\t\t\tthis.#subscription.cancel();\n\t\t\tthis.#subscription = null;\n\t\t}\n\t\t\n\t}\n\t\n\t[renewSymbol](publicationName?: string, params?: unknown[]) {\n\t\t\n\t\tif (this.#subscription) {\n\t\t\tthis[unsubscribeSymbol]();\n\t\t\t\n\t\t\tif (publicationName)\n\t\t\t\tif (Array.isArray(publicationName))\n\t\t\t\t\tparams = publicationName;\n\t\t\t\telse\n\t\t\t\t\tthis.#publicationName = publicationName;\n\t\t\t\n\t\t\tif (params)\n\t\t\t\tthis.#params = params;\n\t\t\t\n\t\t\tthis[subscribeSymbol]();\n\t\t}\n\t\t\n\t}\n\t\n\t[getSubscriptionSymbol]() {\n\t\treturn this.#subscription;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionObjectWithSubscription\";\n\t}\n\t\n\t\n\tstatic subscribeSymbol = subscribeSymbol;\n\tstatic unsubscribeSymbol = unsubscribeSymbol;\n\tstatic renewSymbol = renewSymbol;\n\tstatic getSubscriptionSymbol = getSubscriptionSymbol;\n\t\n}\n\nSubscriptionObject.WithSubscription = SubscriptionObjectWithSubscription;\n"],
|
|
5
|
+
"mappings": "oiBAWA,IAAIA,GACAC,GACAC,EAGSC,EAAN,KAAmB,CACzB,YAAYC,EAAkCC,EAAyBC,EAAkB,CAAC,EAAGC,EAAiCC,EAAc,GAAM,CA2BlJC,EAAA,UACAA,EAAA,aACAA,EAAA,wBACAA,EAAA,aACAA,EAAA,gBACAA,EAAA,oBACAA,EAAA,iBAEAA,EAAA,aAAQ,IAAM,CAEbP,EAAG,YAAY,MAAmC,KAAK,KAAM,KAAK,gBAAiB,KAAK,EAAG,KAAK,KAAM,KAAK,WAAW,EAEtH,KAAK,YAAc,EAEpB,GAvCC,GAAI,CAACA,EACJ,MAAM,IAAI,MAAM,oEAAoE,EAErF,KAAK,EAAIF,KACT,KAAK,KAAOI,EACZ,KAAK,gBAAkBC,EACvB,KAAK,KAAOC,EACZ,KAAK,QAAUC,EACf,KAAK,YAAcC,GAAe,CAAC,WAAW,WAE9CP,GAAc,IAAI,KAAK,EAAG,IAAI,EAE9BC,EAAG,GAAG,OAAQ,KAAK,KAAK,EAEpBA,EAAG,QACN,KAAK,MAAM,EAER,WAAW,YACd,KAAK,SAAW,GAChB,KAAK,QAAQ,WAAW,WAAW,OAAO,EAAG,CAAC,EAAE,CAAC,CAAC,GAElD,KAAK,SAAW,EAElB,CAkBA,QAAS,CAERD,GAAc,OAAO,KAAK,C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KAAK,MAAM,OACd,QAAWA,KAAQ,KAAK,MACvBA,EAAK,WAAW,OAEjB,KAAK,WAAW,EAGlB,QAAWA,KAAQ,KAAK,MACvBa,EAAS,SAAUb,CAAI,EAExB,KAAK,KAAK,OAAQ,KAAK,MAAM,EAE7BC,EAAA,KAAKlB,IAAa,QAAQ,IAAI,CAC/B,CAED,EAEAM,GAAO,UAAG,CAET,GAAI,KAAK,UAAY,KAAK,MAAM,MAAMW,GAAQ,CAACA,EAAK,QAAQ,EAAG,CAC9D,GAAI,KAAK,OACR,QAAWA,KAAQ,KAAK,MAClBA,EAAK,aACT,OAAO,KAAK,OAAOA,EAAK,IAAI,EAE/B,KAAK,SAAW,GAEhB,QAAWA,KAAQ,KAAK,MACvBa,EAAS,WAAYb,CAAI,EAI1B,GAFA,KAAK,KAAK,SAAU,KAAK,MAAM,EAE3B,KAAK,MAAM,OACd,QAAWA,KAAQ,KAAK,MACvBA,EAAK,WAAW,OAEjB,KAAK,WAAW,EAEjBC,EAAA,KAAKjB,GAAe,QAAQ,IAAI,EAE5BiB,EAAA,KAAKnB,GAAa,aACrBgB,EAAA,KAAKhB,EAAe,IAAIiB,EAC1B,CAED,EAuBAF,EA7OYP,GA6OL,gBAAgB,GAItBuB,EAAS,UAAaC,GAA0B,CAtTlD,IAAAC,EAsTqD,OAAAN,EAAAM,EAAAD,EAAM5B,EAAAC,IAAN,KAAA4B,IACnDF,EAAS,UAAaC,GAA0B,CAvTlD,IAAAC,EAuTqD,OAAAN,EAAAM,EAAAD,EAAM5B,EAAAE,IAAN,KAAA2B,IACnDF,EAAS,YAAeC,GAA0B,CAxTpD,IAAAC,EAwTuD,OAAAN,EAAAM,EAAAD,EAAM5B,EAAAG,IAAN,KAAA0B,IAnPhD,IAAMC,GAAN1B",
|
|
6
|
+
"names": ["i", "subscriptions", "ws", "Subscription", "type", "publicationName", "args", "handler", "immediately", "__publicField", "_ws", "si", "updates", "subscription", "noop", "nativesMap", "StatefulPromise", "_StatefulPromise", "executor", "options", "nativeResolve", "nativeReject", "resolve", "reject", "__publicField", "value", "native", "reason", "abortListener", "timeout", "_", "debounce", "callback", "limit", "options", "leading", "trailing", "maxWait", "timeout", "maxWaitTimeout", "end", "context", "args", "initial", "final", "result", "expired", "n", "debounced", "maxWaitExpired", "run", "error", "_args", "StatefulPromise", "resolve", "reject", "noop", "shouldRun", "howmuch", "number", "one", "two", "five", "shouldPrintNumber", "u", "d", "removeOne", "array", "item", "i", "unique", "array", "updateSymbol", "getHandleUpdateSymbol", "setHandleUpdateSymbol", "getAsUpdatesSymbol", "getAsInitialUpdatedSymbol", "clearSymbol", "subscribeSymbol", "unsubscribeSymbol", "renewSymbol", "getSubscriptionSymbol", "getHandleSubscriptionSymbol", "setHandleSubscriptionSymbol", "ascSort", "a", "b", "descSort", "_a", "_b", "_c", "_d", "SubscriptionArray", "updates", "onUpdate", "__publicField", "getHandleUpdateSymbol", "setHandleUpdateSymbol", "handleUpdate", "updated", "shouldSort", "update", "array", "sort", "newItem", "itemToDelete", "removeOne", "updateSymbol", "getAsUpdatesSymbol", "getAsInitialUpdatedSymbol", "clearSymbol", "SubscriptionArrayWithSubscription", "publicationName", "params", "immediately", "Subscription", "subscribeSymbol", "unsubscribeSymbol", "renewSymbol", "getSubscriptionSymbol", "EventEmitter", "privates", "EventEmitter", "createSortFunction", "sortList", "tempScript", "key", "value", "sortFunction", "_a", "_b", "_c", "_d", "_updates", "_fieldsToSort", "_Item", "SubscriptionMap", "updates", "onUpdate", "__publicField", "__privateAdd", "getHandleUpdateSymbol", "setHandleUpdateSymbol", "handleUpdate", "TheItem", "__privateSet", "_id", "item", "__privateGet", "updated", "shouldSort", "prevUpdates", "update", "array", "unique", "updatesMap", "itemUpdates", "prevItemUpdates", "newItem", "isAtomic", "updatedFields", "fieldName", "itemToDelete", "removeOne", "updateSymbol", "getAsUpdatesSymbol", "getAsInitialUpdatedSymbol", "clearSymbol", "SubscriptionMapWithSubscription", "publicationName", "params", "immediately", "Subscription", "subscribeSymbol", "unsubscribeSymbol", "renewSymbol", "getSubscriptionSymbol", "_map", "SubscriptionMapItem", "map", "handleUpdateSymbol", "updatesSymbol", "_a", "_b", "SubscriptionObject", "updates", "onUpdate", "__publicField", "updateSymbol", "getHandleUpdateSymbol", "setHandleUpdateSymbol", "handleUpdate", "key", "clearSymbol", "getAsUpdatesSymbol", "getAsInitialUpdatedSymbol", "_publicationName", "_params", "_subscription", "SubscriptionObjectWithSubscription", "publicationName", "params", "immediately", "__privateAdd", "__privateSet", "subscribeSymbol", "__privateGet", "Subscription", "unsubscribeSymbol", "renewSymbol", "getSubscriptionSymbol", "isUpdatedMapOrArray", "updated", "_loadPromise", "_initPromise", "_unloadPromise", "_SubscriptionGroupItem_instances", "applyOptions_fn", "attachTo_fn", "_loadUpdated", "_handleSubscription", "load_fn", "init_fn", "unload_fn", "_SubscriptionGroupItem", "EventEmitter", "definition", "group", "__privateAdd", "__publicField", "_", "updates", "__privateSet", "privates", "value", "type", "publicationName", "params", "handle", "onBeforeInit", "debounceLimit", "preventBind", "__privateMethod", "unsubscribeSymbol", "removeOne", "__privateGet", "subscribeSymbol", "handleUpdate", "getHandleUpdateSymbol", "initialUpdated", "getAsInitialUpdatedSymbol", "getAsUpdatesSymbol", "renewSymbol", "emitUpdate", "debouncedUpdated", "emitUpdateDebounced", "debounce", "isDetached", "item", "StatefulPromise", "handleSubscription", "setHandleUpdateSymbol", "SubscriptionArrayWithSubscription", "SubscriptionMapWithSubscription", "SubscriptionObjectWithSubscription", "_a", "SubscriptionGroupItem", "isTupleDefinition", "definition", "parseDefinition", "args", "parsed", "_loadPromise", "_initPromise", "_unloadPromise", "_debounceLimit", "_SubscriptionGroup_instances", "load_fn", "init_fn", "unload_fn", "_SubscriptionGroup", "EventEmitter", "definitions", "target", "debounceLimit", "immediately", "__privateAdd", "__publicField", "__privateSet", "StatefulPromise", "item", "__privateGet", "emitUpdateDebounced", "debounce", "shouldReload", "SubscriptionGroupItem", "names", "shouldUpdate", "name", "__privateMethod", "itemsToDetach", "definitionsToRedefine", "definitionsToAttach", "privates", "group", "_a", "SubscriptionGroup"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
2
|
+
"name": "insite-subscriptions-client",
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "inSite subscriptions client side",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"packageManager": "bun@1.2.11",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
+
"build": "bun .conveyer.js",
|
|
12
|
+
"postbuild": "tsc -p ."
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/nesvet/insite-subscriptions-client.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"insite",
|
|
20
|
+
"publications",
|
|
21
|
+
"subscriptions",
|
|
22
|
+
"client"
|
|
23
|
+
],
|
|
24
|
+
"author": "Eugene Nesvetaev <dev@nesvet.dev> (https://nesvet.dev/)",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@nesvet/n": "^1.2.0",
|
|
28
|
+
"eventemitter3": "^5.0.1",
|
|
29
|
+
"insite-ws": "^2.3.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@nesvet/conveyer": "^2.5.2",
|
|
33
|
+
"@nesvet/eslint-config": "^2.1.1",
|
|
34
|
+
"typescript": "^5.8.3"
|
|
35
|
+
}
|
|
36
36
|
}
|