insite-client 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
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)),P=(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(j=>{u.resolve=j,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 b(t,o,e,r,i=!0){return Array.isArray(t)&&(t=t.length),typeof r!="string"&&(i=r??!0,r=e),(i?`${t}\xA0`:"")+b.raw(t,o,e,r)}b.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);P(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 k=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{k 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.
|
|
3
|
+
"version": "2.2.1",
|
|
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.
|
|
8
|
+
"packageManager": "bun@1.2.5",
|
|
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.
|
|
26
|
+
"@nesvet/n": "^1.1.26",
|
|
27
27
|
"eventemitter3": "^5.0.1",
|
|
28
|
-
"insite-common": "^2.2.
|
|
29
|
-
"insite-cookie": "^2.2.
|
|
30
|
-
"insite-subscriptions-client": "^2.2.
|
|
31
|
-
"insite-users-client": "^2.2.
|
|
32
|
-
"insite-ws": "^2.2.
|
|
33
|
-
"insite-ws-transfers": "^2.2.
|
|
28
|
+
"insite-common": "^2.2.1",
|
|
29
|
+
"insite-cookie": "^2.2.1",
|
|
30
|
+
"insite-subscriptions-client": "^2.2.1",
|
|
31
|
+
"insite-users-client": "^2.2.1",
|
|
32
|
+
"insite-ws": "^2.2.1",
|
|
33
|
+
"insite-ws-transfers": "^2.2.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@nesvet/conveyer": "^2.
|
|
36
|
+
"@nesvet/conveyer": "^2.5.0",
|
|
37
37
|
"@nesvet/eslint-config": "^2.0.48",
|
|
38
|
-
"typescript": "^5.
|
|
38
|
+
"typescript": "^5.8.2"
|
|
39
39
|
}
|
|
40
40
|
}
|