insite-client 2.3.0 → 2.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +12 -12
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var M=Object.defineProperty;var $=t=>{throw TypeError(t)};var W=(t,r,e)=>r in t?M(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e;var i=(t,r,e)=>W(t,typeof r!="symbol"?r+"":r,e),L=(t,r,e)=>r.has(t)||$("Cannot "+e);var T=(t,r,e)=>(L(t,r,"read from private field"),e?e.call(t):r.get(t)),j=(t,r,e)=>r.has(t)?$("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(t):r.set(t,e);import D from"eventemitter3";function x(){}var g=new WeakMap,d=class t extends Promise{constructor(e,o){let n,f;super((s,c)=>{n=s,f=c});i(this,"isPending",!0);i(this,"isFulfilled",!1);i(this,"isRejected",!1);i(this,"state","pending");i(this,"result");i(this,"resolve",e=>{if(this.isPending){this.isPending=!1,this.isFulfilled=!0,this.state="fulfilled",this.result=e;let o=g.get(this);o&&(o.resolve.call(this,e),g.delete(this))}});i(this,"reject",e=>{if(this.isPending){this.isPending=!1,this.isRejected=!0,this.state="rejected",this.result=e;let o=g.get(this);o&&(o.reject.call(this,e),g.delete(this))}});if(g.set(this,{resolve:n,reject:f}),o?.signal)if(o.signal.aborted)this.reject(new DOMException("Aborted","AbortError"));else{let s=()=>this.reject(new DOMException("Aborted","AbortError"));o.signal.addEventListener("abort",s),this.finally(()=>o.signal?.removeEventListener("abort",s))}if(typeof o?.timeout=="number"&&Number.isFinite(o.timeout)){let s=setTimeout(()=>this.reject(new DOMException("Timeout exceeded","TimeoutError")),o.timeout);this.finally(()=>clearTimeout(s))}e?.(this.resolve,this.reject)}static resolved(e){return new t(o=>o(e))}static rejected(e){return new t((o,n)=>n(e))}};function B(t,r=0,e={}){let{leading:o=!1,trailing:n=!0}=e,{maxWait:f=1/0}=e,s,c,m,y,w,l,u,S,b=async()=>{let a=Date.now();a>=m?(s=void 0,m=void 0,clearTimeout(c),c=void 0,typeof u=="function"&&await u(),p.resolve(S),l=o):(clearTimeout(s),s=setTimeout(b,m-a))},I=Number.isFinite(f)?()=>{u===h&&(u=!1),h(),c=setTimeout(I,f)}:null;async function h(){try{return S=await t.apply(y,w),S}catch(a){throw p.reject(a),a}}o&&typeof o=="boolean"&&(o=h),l=o,n&&typeof n=="boolean"&&(n=h),u=n;let p=Object.assign(function(...a){return w=a,y=this,m=Date.now()+r,u=n,p.promise.isPending||(p.promise=new d((A,R)=>{p.resolve=A,p.reject=R,typeof l=="function"&&(l(),l=!1,u===h&&(u=!1)),s||(s=setTimeout(b,r),I&&(c=setTimeout(I,f)))})),p.promise},{callback:t,promise:d.resolved(void 0),resolve:x,reject:x,run:h,clear:async a=>{clearTimeout(s),s=void 0,clearTimeout(c),c=void 0,p.resolve(a?await h():S)}});return p}B.noop=Object.assign(()=>{},{callback:x,promise:d.resolved(void 0),resolve:x,reject:x,run:x,clear:x});function E(t,r,e,o,n=!0){return Array.isArray(t)&&(t=t.length),typeof o!="string"&&(n=o??!0,o=e),(n?`${t}\xA0`:"")+E.raw(t,r,e,o)}E.raw=(t,r,e,o=e)=>{t=Math.abs(t);let n=t%10,f=t%100;return n===1&&f!==11?r:n>=2&&n<=4&&!(f>=12&&f<=15)?e:o};import{CookieSetter as C}from"insite-cookie/client";import{Subscription as k}from"insite-subscriptions-client";import{UsersSubscriptionGroup as F}from"insite-users-client";import{IncomingTransport as U,OutgoingTransport as N}from"insite-ws-transfers/browser";import{WS as G}from"insite-ws/client";function q(t,r){return this.ws.sendRequest("login",t,r)}function _(){return this.ws.sendRequest("logout")}var O,v=class v extends D{constructor(e){super();i(this,"ws");i(this,"incomingTransport");i(this,"outgoingTransport");i(this,"cookie");i(this,"usersSubscriptionGroup");i(this,"user");i(this,"users");i(this,"orgs");i(this,"roles");i(this,"isLoggedIn",!1);i(this,"login");i(this,"logout");i(this,"isReady",!1);j(this,O,new d);e&&this.init(e)}async init(e){if(!this.isReady){let{ws:o={},cookie:n,users:f,public:s}=e??{},{subscriptions:c,incomingTransport:m,outgoingTransport:y,...w}=o;this.ws=new G(w),c!==null&&k.bindTo(this.ws),m&&(this.incomingTransport=new U(this.ws,typeof m=="object"?m:{})),y&&(this.outgoingTransport=new N(this.ws)),n!==null&&(this.cookie=new C(this.ws,n)),f!==null&&c!==null&&n!==null&&(this.user=null,this.login=q,this.logout=_,s?await new Promise(l=>{new k("object","user",[!0],u=>{this.user=u,this.user?this.isLoggedIn||(this.isLoggedIn=!0,this.emit("login",!0)):this.isLoggedIn&&(this.isLoggedIn=!1,this.emit("logout",!1)),this.isReady||l()})}):(this.usersSubscriptionGroup=new F({target:this}),await new Promise(l=>{this.usersSubscriptionGroup.once("init",()=>{this.isLoggedIn=!!this.user,this.usersSubscriptionGroup.on("update.user",u=>{u.valueOf()?this.isLoggedIn||(this.isLoggedIn=!0,this.emit("login",!0)):this.isLoggedIn&&(this.isLoggedIn=!1,this.emit("logout",!1))}),l(),this.isLoggedIn&&this.emit("login",!0)})}))),this.isReady=!0,this.emit("ready",!0),T(this,O).resolve(this)}}whenReady(){return T(this,O)}static init(e,o=!1){let n=new v(e);return o?n.whenReady():n}};O=new WeakMap;var P=v;export*from"insite-common/frontend";export*from"insite-cookie/client";export*from"insite-subscriptions-client";export*from"insite-users-client";export*from"insite-ws-transfers/browser";export*from"insite-ws/client";export{P as InSite};
1
+ var R=Object.defineProperty;var k=t=>{throw TypeError(t)};var W=(t,o,e)=>o in t?R(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e;var i=(t,o,e)=>W(t,typeof o!="symbol"?o+"":o,e),L=(t,o,e)=>o.has(t)||k("Cannot "+e);var b=(t,o,e)=>(L(t,o,"read from private field"),e?e.call(t):o.get(t)),E=(t,o,e)=>o.has(t)?k("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(t):o.set(t,e);import D from"eventemitter3";function m(){}var g=new WeakMap,h=class t extends Promise{constructor(e,r){let n,u;super((s,c)=>{n=s,u=c});i(this,"isPending",!0);i(this,"isFulfilled",!1);i(this,"isRejected",!1);i(this,"state","pending");i(this,"result");i(this,"resolve",e=>{if(this.isPending){this.isPending=!1,this.isFulfilled=!0,this.state="fulfilled",this.result=e;let r=g.get(this);r&&(r.resolve.call(this,e),g.delete(this))}});i(this,"reject",e=>{if(this.isPending){this.isPending=!1,this.isRejected=!0,this.state="rejected",this.result=e;let r=g.get(this);r&&(r.reject.call(this,e),g.delete(this))}});if(g.set(this,{resolve:n,reject:u}),r?.signal)if(r.signal.aborted)this.reject(new DOMException("Aborted","AbortError"));else{let s=()=>this.reject(new DOMException("Aborted","AbortError"));r.signal.addEventListener("abort",s),this.finally(()=>r.signal?.removeEventListener("abort",s))}if(typeof r?.timeout=="number"&&Number.isFinite(r.timeout)){let s=setTimeout(()=>this.reject(new DOMException("Timeout exceeded","TimeoutError")),r.timeout);this.finally(()=>clearTimeout(s))}e?.(this.resolve,this.reject)}static resolved(e){return new t(r=>r(e))}static rejected(e){return new t((r,n)=>n(e))}};function C(t,o=0,e={}){let{leading:r=!1,trailing:n=!0}=e,{maxWait:u=1/0}=e,s,c,d,w,O,l,f,S,$=async()=>{let p=Date.now();p>=d?(s=void 0,d=void 0,clearTimeout(c),c=void 0,typeof f=="function"&&await f(),a.resolve(S),l=r):(clearTimeout(s),s=setTimeout($,d-p))},I=Number.isFinite(u)?()=>{f===x&&(f=!1),x(),c=setTimeout(I,u)}:null;async function x(){try{return S=await t.apply(w,O),S}catch(p){throw a.reject(p),p}}r&&typeof r=="boolean"&&(r=x),l=r,n&&typeof n=="boolean"&&(n=x),f=n;let a=Object.assign(function(...p){return O=p,w=this,d=Date.now()+o,f=n,a.promise.isPending||(a.promise=new h((P,A)=>{a.resolve=P,a.reject=A,typeof l=="function"&&(l(),l=!1,f===x&&(f=!1)),s||(s=setTimeout($,o),I&&(c=setTimeout(I,u)))})),a.promise},{callback:t,promise:h.resolved(void 0),resolve:m,reject:m,run:x,clear:async p=>{clearTimeout(s),s=void 0,clearTimeout(c),c=void 0,a.resolve(p?await x():S)}});return a}C.noop=Object.assign(()=>{},{callback:m,promise:h.resolved(void 0),resolve:m,reject:m,run:m,clear:m});function T(t,o,e,r,n=!0){return Array.isArray(t)&&(t=t.length),typeof r!="string"&&(n=r??!0,r=e),(n?`${t}\xA0`:"")+T.raw(t,o,e,r)}T.raw=(t,o,e,r=e)=>{t=Math.abs(t);let n=t%10,u=t%100;return n===1&&u!==11?o:n>=2&&n<=4&&!(u>=12&&u<=15)?e:r};import{CookieSetter as N}from"insite-cookie/client";import{Subscription as v}from"insite-subscriptions-client";import{UsersSubscriptionGroup as B}from"insite-users-client";import{IncomingTransport as F,OutgoingTransport as U}from"insite-ws-transfers/browser";import{WS as _}from"insite-ws/client";function G(t,o){return this.ws.sendRequest("login",t,o)}function q(){return this.ws.sendRequest("logout")}var y,j=class j extends D{constructor(e){super();i(this,"ws");i(this,"incomingTransport");i(this,"outgoingTransport");i(this,"cookie");i(this,"usersSubscriptionGroup");i(this,"user");i(this,"users");i(this,"orgs");i(this,"roles");i(this,"isLoggedIn",!1);i(this,"login");i(this,"logout");i(this,"isReady",!1);E(this,y,new h);e&&this.init(e)}async init(e){if(!this.isReady){let{ws:r={},cookie:n,users:u,public:s}=e??{},{subscriptions:c,incomingTransport:d,outgoingTransport:w,...O}=r;this.ws=new _(O),c!==null&&v.bindTo(this.ws),d&&(this.incomingTransport=new F(this.ws,typeof d=="object"?d:{})),w&&(this.outgoingTransport=new U(this.ws)),n!==null&&(this.cookie=new N(this.ws,n)),u!==null&&c!==null&&n!==null&&(this.user=null,this.login=G,this.logout=q,s?await new Promise(l=>{new v("object","user",[!0],f=>{this.user=f,this.user?this.isLoggedIn||(this.isLoggedIn=!0,this.emit("login",!0)):this.isLoggedIn&&(this.isLoggedIn=!1,this.emit("logout",!1)),this.isReady||l()})}):(this.usersSubscriptionGroup=new B({target:this}),await new Promise(l=>{this.usersSubscriptionGroup.once("init",()=>{this.isLoggedIn=!!this.user,this.usersSubscriptionGroup.on("update.user",f=>{f.valueOf()?this.isLoggedIn||(this.isLoggedIn=!0,this.emit("login",!0)):this.isLoggedIn&&(this.isLoggedIn=!1,this.emit("logout",!1))}),l(),this.isLoggedIn&&this.emit("login",!0)})}))),this.isReady=!0,this.emit("ready",!0),b(this,y).resolve(this)}}whenReady(){return b(this,y)}static init(e,r=!1){let n=new j(e);return r?n.whenReady():n}};y=new WeakMap;var M=j;export*from"insite-common/frontend";export*from"insite-cookie/client";export*from"insite-subscriptions-client";export*from"insite-users-client";export*from"insite-ws-transfers/browser";export*from"insite-ws/client";export{M as InSite};
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "insite-client",
3
- "version": "2.3.0",
3
+ "version": "2.3.5",
4
4
  "description": "Client-side inSite app",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
8
- "packageManager": "bun@1.2.11",
8
+ "packageManager": "bun@1.2.21",
9
9
  "scripts": {
10
10
  "test": "echo \"Error: no test specified\" && exit 1",
11
11
  "build": "bun .conveyer.js",
@@ -23,18 +23,18 @@
23
23
  "author": "Eugene Nesvetaev <dev@nesvet.dev> (https://nesvet.dev/)",
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
- "@nesvet/n": "^1.2.0",
26
+ "@nesvet/n": "^1.2.1",
27
27
  "eventemitter3": "^5.0.1",
28
- "insite-common": "^2.3.0",
29
- "insite-cookie": "^2.3.0",
30
- "insite-subscriptions-client": "^2.3.0",
31
- "insite-users-client": "^2.3.0",
32
- "insite-ws": "^2.3.0",
33
- "insite-ws-transfers": "^2.3.0"
28
+ "insite-common": "^2.3.5",
29
+ "insite-cookie": "^2.3.5",
30
+ "insite-subscriptions-client": "^2.3.5",
31
+ "insite-users-client": "^2.3.5",
32
+ "insite-ws": "^2.3.5",
33
+ "insite-ws-transfers": "^2.3.5"
34
34
  },
35
35
  "devDependencies": {
36
- "@nesvet/conveyer": "^2.5.2",
37
- "@nesvet/eslint-config": "^2.1.1",
38
- "typescript": "^5.8.3"
36
+ "@nesvet/eslint-config": "^2.1.2",
37
+ "cnvr": "^2.7.2",
38
+ "typescript": "^5.9.2"
39
39
  }
40
40
  }