insite-client 2.2.0 → 2.2.2

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 R=Object.defineProperty;var b=e=>{throw TypeError(e)};var E=(e,o,t)=>o in e?R(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t;var n=(e,o,t)=>E(e,typeof o!="symbol"?o+"":o,t),M=(e,o,t)=>o.has(e)||b("Cannot "+t);var v=(e,o,t)=>(M(e,o,"read from private field"),t?t.call(e):o.get(e)),P=(e,o,t)=>o.has(e)?b("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(e):o.set(e,t);import B from"eventemitter3";function d(){}function W(e,o=0,t={}){let{leading:r=!1,trailing:i=!0}=t,{maxWait:f=1/0}=t,s,l,m,O,y,p,c,w,$=async()=>{let x=Date.now();x>=m?(s=void 0,m=void 0,clearTimeout(l),typeof c=="function"&&await c(),u.resolve(w),u.promise.isResolved=!0,p=r):(clearTimeout(s),s=setTimeout($,m-x))},I=Number.isFinite(f)?()=>{c===a&&(c=!1),a(),l=setTimeout(I,f)}:null;async function a(){return w=await e.apply(O,y)}r&&typeof r=="boolean"&&(r=a),p=r,i&&typeof i=="boolean"&&(i=a),c=i;let u=Object.assign(function(...x){return y=x,O=this,m=Date.now()+o,c=i,u.promise.isResolved&&(u.promise=Object.assign(new Promise(k=>{u.resolve=k,typeof p=="function"&&(p(),p=!1,c===a&&(c=!1)),s||(s=setTimeout($,o),I&&(l=setTimeout(I,f)))}),{isResolved:!1})),u.promise},{callback:e,promise:Object.assign(Promise.resolve(),{isResolved:!0}),resolve:d,run:a,clear:async x=>{clearTimeout(s),s=void 0,clearTimeout(l),u.promise.isResolved=!0,u.resolve(x?await a():w)}});return u}W.noop=Object.assign(()=>{},{callback:d,promise:Object.assign(Promise.resolve(),{isResolved:!0}),resolve:d,run:d,clear:d});function j(e,o,t,r,i=!0){return Array.isArray(e)&&(e=e.length),typeof r!="string"&&(i=r??!0,r=t),(i?`${e}\xA0`:"")+j.raw(e,o,t,r)}j.raw=(e,o,t,r=t)=>{e=Math.abs(e);let i=e%10,f=e%100;return i===1&&f!==11?o:i>=2&&i<=4&&!(f>=12&&f<=15)?t:r};var h=new WeakMap,S=class extends Promise{constructor(t){let r,i;super((f,s)=>{r=f,i=s});n(this,"isPending",!0);n(this,"isFulfilled",!1);n(this,"isRejected",!1);n(this,"state","pending");n(this,"result");n(this,"resolve",t=>{if(this.isPending){this.isPending=!1,this.isFulfilled=!0,this.state="fulfilled",this.result=t;let r=h.get(this);r&&(r.resolve.call(this,t),h.delete(this))}});n(this,"reject",t=>{if(this.isPending){this.isPending=!1,this.isRejected=!0,this.state="rejected",this.result=t;let r=h.get(this);r&&(r.reject.call(this,t),h.delete(this))}});h.set(this,{resolve:r,reject:i}),t?.(this.resolve,this.reject)}};import{CookieSetter as L}from"insite-cookie/client";import{Subscription as U}from"insite-subscriptions-client";import{UsersSubscriptionGroup as C}from"insite-users-client";import{IncomingTransport as G,OutgoingTransport as F}from"insite-ws-transfers/browser";import{WS as _}from"insite-ws/client";function q(e,o){return this.ws.sendRequest("login",e,o)}function N(){return this.ws.sendRequest("logout")}var g,T=class T extends B{constructor(t){super();n(this,"ws");n(this,"incomingTransport");n(this,"outgoingTransport");n(this,"cookie");n(this,"usersSubscriptionGroup");n(this,"user");n(this,"users");n(this,"orgs");n(this,"roles");n(this,"isLoggedIn",!1);n(this,"login");n(this,"logout");n(this,"isReady",!1);P(this,g,new S);t&&this.init(t)}async init(t){if(!this.isReady){let{ws:r={},cookie:i,users:f}=t??{},{subscriptions:s,incomingTransport:l,outgoingTransport:m,...O}=r;this.ws=new _(O),s!==null&&U.bindTo(this.ws),l&&(this.incomingTransport=new G(this.ws,typeof l=="object"?l:{})),m&&(this.outgoingTransport=new F(this.ws)),i!==null&&(this.cookie=new L(this.ws,i)),f!==null&&s!==null&&i!==null&&(this.user=null,this.login=q,this.logout=N,this.usersSubscriptionGroup=new C({target:this}),await new Promise(y=>{this.usersSubscriptionGroup.once("init",()=>{this.isLoggedIn=!!this.user,this.usersSubscriptionGroup.on("update.user",p=>{p.valueOf()?this.isLoggedIn||(this.isLoggedIn=!0,this.emit("login",!0)):this.isLoggedIn&&(this.isLoggedIn=!1,this.emit("logout",!1))}),y(),this.isLoggedIn&&this.emit("login",!0)})})),this.isReady=!0,this.emit("ready",!0),v(this,g).resolve(this)}}whenReady(){return v(this,g)}static init(t,r=!1){let i=new T(t);return r?i.whenReady():i}};g=new WeakMap;var A=T;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{A as InSite};
1
+ var A=Object.defineProperty;var R=t=>{throw TypeError(t)};var E=(t,o,e)=>o in t?A(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e;var n=(t,o,e)=>E(t,typeof o!="symbol"?o+"":o,e),M=(t,o,e)=>o.has(t)||R("Cannot "+e);var T=(t,o,e)=>(M(t,o,"read from private field"),e?e.call(t):o.get(t)),b=(t,o,e)=>o.has(t)?R("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(t):o.set(t,e);import B from"eventemitter3";function d(){}function W(t,o=0,e={}){let{leading:r=!1,trailing:i=!0}=e,{maxWait:f=1/0}=e,s,l,m,O,y,p,c,S,$=async()=>{let x=Date.now();x>=m?(s=void 0,m=void 0,clearTimeout(l),typeof c=="function"&&await c(),u.resolve(S),u.promise.isResolved=!0,p=r):(clearTimeout(s),s=setTimeout($,m-x))},I=Number.isFinite(f)?()=>{c===a&&(c=!1),a(),l=setTimeout(I,f)}:null;async function a(){return S=await t.apply(O,y)}r&&typeof r=="boolean"&&(r=a),p=r,i&&typeof i=="boolean"&&(i=a),c=i;let u=Object.assign(function(...x){return y=x,O=this,m=Date.now()+o,c=i,u.promise.isResolved&&(u.promise=Object.assign(new Promise(k=>{u.resolve=k,typeof p=="function"&&(p(),p=!1,c===a&&(c=!1)),s||(s=setTimeout($,o),I&&(l=setTimeout(I,f)))}),{isResolved:!1})),u.promise},{callback:t,promise:Object.assign(Promise.resolve(),{isResolved:!0}),resolve:d,run:a,clear:async x=>{clearTimeout(s),s=void 0,clearTimeout(l),u.promise.isResolved=!0,u.resolve(x?await a():S)}});return u}W.noop=Object.assign(()=>{},{callback:d,promise:Object.assign(Promise.resolve(),{isResolved:!0}),resolve:d,run:d,clear:d});function P(t,o,e,r,i=!0){return Array.isArray(t)&&(t=t.length),typeof r!="string"&&(i=r??!0,r=e),(i?`${t}\xA0`:"")+P.raw(t,o,e,r)}P.raw=(t,o,e,r=e)=>{t=Math.abs(t);let i=t%10,f=t%100;return i===1&&f!==11?o:i>=2&&i<=4&&!(f>=12&&f<=15)?e:r};var h=new WeakMap,w=class extends Promise{constructor(e){let r,i;super((f,s)=>{r=f,i=s});n(this,"isPending",!0);n(this,"isFulfilled",!1);n(this,"isRejected",!1);n(this,"state","pending");n(this,"result");n(this,"resolve",e=>{if(this.isPending){this.isPending=!1,this.isFulfilled=!0,this.state="fulfilled",this.result=e;let r=h.get(this);r&&(r.resolve.call(this,e),h.delete(this))}});n(this,"reject",e=>{if(this.isPending){this.isPending=!1,this.isRejected=!0,this.state="rejected",this.result=e;let r=h.get(this);r&&(r.reject.call(this,e),h.delete(this))}});h.set(this,{resolve:r,reject:i}),e?.(this.resolve,this.reject)}};import{CookieSetter as C}from"insite-cookie/client";import{Subscription as L}from"insite-subscriptions-client";import{UsersSubscriptionGroup as U}from"insite-users-client";import{IncomingTransport as D,OutgoingTransport as F}from"insite-ws-transfers/browser";import{WS as G}from"insite-ws/client";function N(t,o){return this.ws.sendRequest("login",t,o)}function _(){return this.ws.sendRequest("logout")}var g,v=class v extends B{constructor(e){super();n(this,"ws");n(this,"incomingTransport");n(this,"outgoingTransport");n(this,"cookie");n(this,"usersSubscriptionGroup");n(this,"user");n(this,"users");n(this,"orgs");n(this,"roles");n(this,"isLoggedIn",!1);n(this,"login");n(this,"logout");n(this,"isReady",!1);b(this,g,new w);e&&this.init(e)}async init(e){if(!this.isReady){let{ws:r={},cookie:i,users:f}=e??{},{subscriptions:s,incomingTransport:l,outgoingTransport:m,...O}=r;this.ws=new G(O),s!==null&&L.bindTo(this.ws),l&&(this.incomingTransport=new D(this.ws,typeof l=="object"?l:{})),m&&(this.outgoingTransport=new F(this.ws)),i!==null&&(this.cookie=new C(this.ws,i)),f!==null&&s!==null&&i!==null&&(this.user=null,this.login=N,this.logout=_,this.usersSubscriptionGroup=new U({target:this}),await new Promise(y=>{this.usersSubscriptionGroup.once("init",()=>{this.isLoggedIn=!!this.user,this.usersSubscriptionGroup.on("update.user",p=>{p.valueOf()?this.isLoggedIn||(this.isLoggedIn=!0,this.emit("login",!0)):this.isLoggedIn&&(this.isLoggedIn=!1,this.emit("logout",!1))}),y(),this.isLoggedIn&&this.emit("login",!0)})})),this.isReady=!0,this.emit("ready",!0),T(this,g).resolve(this)}}whenReady(){return T(this,g)}static init(e,r=!1){let i=new v(e);return r?i.whenReady():i}};g=new WeakMap;var j=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{j 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.2.0",
3
+ "version": "2.2.2",
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.3",
8
+ "packageManager": "bun@1.2.7",
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.1.24",
26
+ "@nesvet/n": "^1.1.28",
27
27
  "eventemitter3": "^5.0.1",
28
- "insite-common": "^2.2.0",
29
- "insite-cookie": "^2.2.0",
30
- "insite-subscriptions-client": "^2.2.0",
31
- "insite-users-client": "^2.2.0",
32
- "insite-ws": "^2.2.0",
33
- "insite-ws-transfers": "^2.2.0"
28
+ "insite-common": "^2.2.2",
29
+ "insite-cookie": "^2.2.2",
30
+ "insite-subscriptions-client": "^2.2.2",
31
+ "insite-users-client": "^2.2.2",
32
+ "insite-ws": "^2.2.2",
33
+ "insite-ws-transfers": "^2.2.2"
34
34
  },
35
35
  "devDependencies": {
36
- "@nesvet/conveyer": "^2.4.3",
37
- "@nesvet/eslint-config": "^2.0.48",
38
- "typescript": "^5.7.3"
36
+ "@nesvet/conveyer": "^2.5.1",
37
+ "@nesvet/eslint-config": "^2.0.51",
38
+ "typescript": "^5.8.2"
39
39
  }
40
40
  }