@ancon/wildcat-utils 1.43.0 → 1.43.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.
- package/currency/getFormattedCurrency.d.ts +5 -0
- package/currency/getFormattedCurrency.js +1 -1
- package/currency/getFormattedCurrency.mjs +22 -18
- package/package.json +1 -1
- package/signalr/SignalR.d.ts +1 -0
- package/signalr/SignalR.js +1 -1
- package/signalr/SignalR.mjs +27 -25
- package/signalr/createUseSignalRHook.js +1 -1
- package/signalr/createUseSignalRHook.mjs +49 -47
|
@@ -24,6 +24,11 @@ declare type Options = {
|
|
|
24
24
|
* @default true
|
|
25
25
|
*/
|
|
26
26
|
onlyShowAsManyDecimalsAsNeededWhenZeroInt?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether or not to show the currency postfix, formatted or not
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
showCurrencyPostfix?: boolean;
|
|
27
32
|
};
|
|
28
33
|
/**
|
|
29
34
|
* Formats the given monetary value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const N=require("./getFormattedCurrencyPostfix.js");function h(d=0,A="SEK",e=!0){let l=0;const c=typeof e=="object"?{formatPostfix:(e==null?void 0:e.formatPostfix)??!0,trimTrailingZeros:(e==null?void 0:e.trimTrailingZeros)??!0,showAsManyDecimalsAsNeeded:(e==null?void 0:e.showAsManyDecimalsAsNeeded)??!1,maxAsManyDecimalsAsNeeded:(e==null?void 0:e.maxAsManyDecimalsAsNeeded)??8,onlyShowAsManyDecimalsAsNeededWhenZeroInt:(e==null?void 0:e.onlyShowAsManyDecimalsAsNeededWhenZeroInt)??!0,showCurrencyPostfix:(e==null?void 0:e.showCurrencyPostfix)??!0}:{formatPostfix:e,trimTrailingZeros:!0,showAsManyDecimalsAsNeeded:!1,maxAsManyDecimalsAsNeeded:8,onlyShowAsManyDecimalsAsNeededWhenZeroInt:!0,showCurrencyPostfix:!0};if(!d||Number.isNaN(Number(d)))l=0;else if(c.trimTrailingZeros&&Number.isInteger(Number(d)))l=d;else if(c.showAsManyDecimalsAsNeeded){l=Number(d).toFixed(c.maxAsManyDecimalsAsNeeded);const[u,s]=l.split("."),n=s!=null&&s.length>2?s.replace(/0+$/,""):s;(c.onlyShowAsManyDecimalsAsNeededWhenZeroInt?u==="0":!0)&&u!=null&&n!=null&&n.length>2?l=`${u}.${n}`:l=Number(d).toFixed(2)}else l=Number(d).toFixed(2),c.trimTrailingZeros&&l.endsWith(".00")&&(l=Number.parseInt(l,10).toString());if(c.showCurrencyPostfix===!1)return`${l}`;const y=c.formatPostfix?N(A):A;return`${l} ${y}`}module.exports=h;
|
|
@@ -1,32 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
3
|
-
let
|
|
4
|
-
const
|
|
1
|
+
import N from "./getFormattedCurrencyPostfix.mjs";
|
|
2
|
+
function D(d = 0, s = "SEK", e = !0) {
|
|
3
|
+
let l = 0;
|
|
4
|
+
const c = typeof e == "object" ? {
|
|
5
5
|
formatPostfix: (e == null ? void 0 : e.formatPostfix) ?? !0,
|
|
6
6
|
trimTrailingZeros: (e == null ? void 0 : e.trimTrailingZeros) ?? !0,
|
|
7
7
|
showAsManyDecimalsAsNeeded: (e == null ? void 0 : e.showAsManyDecimalsAsNeeded) ?? !1,
|
|
8
8
|
maxAsManyDecimalsAsNeeded: (e == null ? void 0 : e.maxAsManyDecimalsAsNeeded) ?? 8,
|
|
9
|
-
onlyShowAsManyDecimalsAsNeededWhenZeroInt: (e == null ? void 0 : e.onlyShowAsManyDecimalsAsNeededWhenZeroInt) ?? !0
|
|
9
|
+
onlyShowAsManyDecimalsAsNeededWhenZeroInt: (e == null ? void 0 : e.onlyShowAsManyDecimalsAsNeededWhenZeroInt) ?? !0,
|
|
10
|
+
showCurrencyPostfix: (e == null ? void 0 : e.showCurrencyPostfix) ?? !0
|
|
10
11
|
} : {
|
|
11
12
|
formatPostfix: e,
|
|
12
13
|
trimTrailingZeros: !0,
|
|
13
14
|
showAsManyDecimalsAsNeeded: !1,
|
|
14
15
|
maxAsManyDecimalsAsNeeded: 8,
|
|
15
|
-
onlyShowAsManyDecimalsAsNeededWhenZeroInt: !0
|
|
16
|
+
onlyShowAsManyDecimalsAsNeededWhenZeroInt: !0,
|
|
17
|
+
showCurrencyPostfix: !0
|
|
16
18
|
};
|
|
17
|
-
if (!
|
|
18
|
-
|
|
19
|
-
else if (
|
|
20
|
-
|
|
21
|
-
else if (
|
|
22
|
-
|
|
23
|
-
const [
|
|
24
|
-
(
|
|
19
|
+
if (!d || Number.isNaN(Number(d)))
|
|
20
|
+
l = 0;
|
|
21
|
+
else if (c.trimTrailingZeros && Number.isInteger(Number(d)))
|
|
22
|
+
l = d;
|
|
23
|
+
else if (c.showAsManyDecimalsAsNeeded) {
|
|
24
|
+
l = Number(d).toFixed(c.maxAsManyDecimalsAsNeeded);
|
|
25
|
+
const [u, A] = l.split("."), n = A != null && A.length > 2 ? A.replace(/0+$/, "") : A;
|
|
26
|
+
(c.onlyShowAsManyDecimalsAsNeededWhenZeroInt ? u === "0" : !0) && u != null && n != null && n.length > 2 ? l = `${u}.${n}` : l = Number(d).toFixed(2);
|
|
25
27
|
} else
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
l = Number(d).toFixed(2), c.trimTrailingZeros && l.endsWith(".00") && (l = Number.parseInt(l, 10).toString());
|
|
29
|
+
if (c.showCurrencyPostfix === !1)
|
|
30
|
+
return `${l}`;
|
|
31
|
+
const y = c.formatPostfix ? N(s) : s;
|
|
32
|
+
return `${l} ${y}`;
|
|
29
33
|
}
|
|
30
34
|
export {
|
|
31
|
-
|
|
35
|
+
D as default
|
|
32
36
|
};
|
package/package.json
CHANGED
package/signalr/SignalR.d.ts
CHANGED
package/signalr/SignalR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var d=(r,e,t)=>e in r?f(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var n=(r,e,t)=>(d(r,typeof e!="symbol"?e+"":e,t),t);const h=require("@microsoft/signalr"),a=require("@ancon/wildcat-types"),l=require("../shared/wait.js"),u=require("../api/generateBackoffWithEqualJitter.js");require("../number/randomIntFromInterval.js");class g{constructor(e){n(this,"internalEvents");n(this,"signalREvents");n(this,"hubConnection");n(this,"clientId");n(this,"logger");n(this,"backoff",[]);n(this,"reconnectAttempt",0);n(this,"shouldReconnect",!0);n(this,"groups");n(this,"info",(e,t)=>{var i;(i=this.logger)==null||i.info(e,t)});n(this,"generateBackoff",()=>{this.backoff=u(50,500,5e3),this.info("Generated new backoff")});n(this,"reconnect",async()=>{if(this.shouldReconnect)try{this.info("Attempting to reconnect...",{attempt:this.reconnectAttempt+1}),await this.connect(!0),this.info("Reconnected"),this.reconnectAttempt=0}catch{if(this.backoff[this.reconnectAttempt]!=null){const t=this.backoff[this.reconnectAttempt];if(t!=null)await l(t);else throw new Error("Could not resolve ms from backoff")}else{this.reconnectAttempt>0&&this.info("Ran out of backoff intervals, restarting backoff..."),this.reconnectAttempt=0,this.generateBackoff();const t=this.backoff[this.reconnectAttempt];if(t!=null)await l(t);else throw new Error("Could not resolve ms from backoff")}this.reconnectAttempt+=1,await this.reconnect()}});n(this,"buildInitialListeners",()=>{this.hubConnection.onclose(()=>{this.groups=[],this.info("Hub connection closed"),this.emitEvent("disconnected"),this.reconnect()}),this.hubConnection.onreconnected(()=>this.emitEvent("reconnected"))});n(this,"emitEvent",(e,...t)=>{if(this.internalEvents.has(e)){this.info(`Emitting event "${e}"`);const i=this.internalEvents.get(e);i&&i.forEach(s=>s(...t))}else this.info(`Failed to emit event "${e}". There were no listeners.`)});n(this,"skipSignal",(e,t)=>{this.info(`Skipped signal "${e}"`,t)});n(this,"enhanceListener",(e,t,i)=>s=>{const o=JSON.parse(s),c=i&&o.clientId&&o.clientId===this.clientId;return c||this.info(`Received signal "${e}"`,s),c?this.skipSignal(e,s):t(o)});n(this,"setClientId",e=>{this.clientId=e});n(this,"connect",async(e=!1)=>{try{this.info("Connecting..."),await this.hubConnection.start(),this.info("Connected"),this.emitEvent("connected")}catch(t){if(this.info("Failed to connect"),e)throw t}});n(this,"disconnect",async()=>{try{this.shouldReconnect=!1,this.info("Disconnecting..."),await this.hubConnection.stop(),this.info("Disconnected"),this.emitEvent("disconnected")}catch{this.info("Failed to disconnect")}});n(this,"addEventListener",(e,t)=>{this.internalEvents.has(e)||this.internalEvents.set(e,[]);const i=this.internalEvents.get(e);return i&&i.push(t),()=>this.removeEventListener(e,t)});n(this,"removeEventListener",(e,t)=>{var i;if(this.internalEvents.has(e)){const s=this.internalEvents.get(e),o=((i=s==null?void 0:s.indexOf)==null?void 0:i.call(s,t))??-1;o>=0?(s.splice(o,1),this.info(`Removed event listener for event "${e}"`)):this.info(`Failed to remove event listener for event "${e}". Specified listener was not found.`)}else this.info(`Failed to remove event listener for event "${e}". Event doesn't have any listeners.`)});n(this,"addSignalListener",(e,t,i=!0)=>{this.signalREvents.has(e)||this.signalREvents.set(e,[]);const s=this.signalREvents.get(e),o=this.enhanceListener(e,t,i);return s&&s.push(o),this.hubConnection.on(e,o),this.info(`Added signal listener for signal "${e}"`),()=>this.removeSignalListener(e,o)});n(this,"removeSignalListener",(e,t)=>{var i;if(this.signalREvents.has(e)){const s=this.signalREvents.get(e),o=((i=s==null?void 0:s.indexOf)==null?void 0:i.call(s,t))??-1;o>=0?(this.hubConnection.off(e,t),s.splice(o,1),this.info(`Removed signal listener for signal "${e}"`)):this.info(`Failed to remove signal listener for signal "${e}". Specified listener was not found.`)}else this.info(`Failed to remove signal listener for signal "${e}". Signal doesn't have any listeners.`)});n(this,"joinGroup",async e=>{this.info(`Joining group "${e}"...`);const t=this.groups.push(e)-1;try{await this.hubConnection.invoke(a.SignalRMethodName.JoinGroup,e),this.info(`Joined group "${e}"`)}catch(i){this.info(`Failed to join group "${e}"`,i),t>=0&&this.groups.splice(t,1)}});n(this,"leaveGroup",async e=>{this.info(`Leaving group "${e}"...`);const t=this.groups.indexOf(e);t>=0&&this.groups.splice(t,1);try{await this.hubConnection.invoke(a.SignalRMethodName.LeaveGroup,e),this.info(`Left group "${e}"`)}catch(i){this.groups.indexOf(e)<0&&this.groups.push(e),this.info(`Failed to leave group "${e}"`,i)}});n(this,"leaveAllGroups",async()=>{this.info(`Leaving all (${this.groups.length}) groups...`);const e=[...this.groups].map(t=>this.leaveGroup(t));await Promise.all(e),this.info("Left all groups")});n(this,"getHubConnectionId",()=>this.hubConnection.connectionId);this.internalEvents=new Map,this.signalREvents=new Map,this.groups=[],e.enableLogging&&(this.logger=e.logger),this.hubConnection=new h.HubConnectionBuilder().withUrl(`${e.signalRApiUrl}/${e.hub}`).configureLogging(h.LogLevel.None).build(),this.buildInitialListeners()}}module.exports=g;
|
package/signalr/SignalR.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var f = Object.defineProperty;
|
|
2
2
|
var l = (r, t, e) => t in r ? f(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
3
|
var n = (r, t, e) => (l(r, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
-
import { HubConnectionBuilder as d, LogLevel as
|
|
4
|
+
import { HubConnectionBuilder as d, LogLevel as u } from "@microsoft/signalr";
|
|
5
5
|
import { SignalRMethodName as h } from "@ancon/wildcat-types";
|
|
6
6
|
import a from "../shared/wait.mjs";
|
|
7
|
-
import
|
|
7
|
+
import g from "../api/generateBackoffWithEqualJitter.mjs";
|
|
8
8
|
import "../number/randomIntFromInterval.mjs";
|
|
9
9
|
class L {
|
|
10
10
|
constructor(t) {
|
|
@@ -15,36 +15,38 @@ class L {
|
|
|
15
15
|
n(this, "logger");
|
|
16
16
|
n(this, "backoff", []);
|
|
17
17
|
n(this, "reconnectAttempt", 0);
|
|
18
|
+
n(this, "shouldReconnect", !0);
|
|
18
19
|
n(this, "groups");
|
|
19
20
|
n(this, "info", (t, e) => {
|
|
20
21
|
var i;
|
|
21
22
|
(i = this.logger) == null || i.info(t, e);
|
|
22
23
|
});
|
|
23
24
|
n(this, "generateBackoff", () => {
|
|
24
|
-
this.backoff =
|
|
25
|
+
this.backoff = g(50, 500, 5e3), this.info("Generated new backoff");
|
|
25
26
|
});
|
|
26
27
|
n(this, "reconnect", async () => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
if (this.shouldReconnect)
|
|
29
|
+
try {
|
|
30
|
+
this.info("Attempting to reconnect...", {
|
|
31
|
+
attempt: this.reconnectAttempt + 1
|
|
32
|
+
}), await this.connect(!0), this.info("Reconnected"), this.reconnectAttempt = 0;
|
|
33
|
+
} catch {
|
|
34
|
+
if (this.backoff[this.reconnectAttempt] != null) {
|
|
35
|
+
const e = this.backoff[this.reconnectAttempt];
|
|
36
|
+
if (e != null)
|
|
37
|
+
await a(e);
|
|
38
|
+
else
|
|
39
|
+
throw new Error("Could not resolve ms from backoff");
|
|
40
|
+
} else {
|
|
41
|
+
this.reconnectAttempt > 0 && this.info("Ran out of backoff intervals, restarting backoff..."), this.reconnectAttempt = 0, this.generateBackoff();
|
|
42
|
+
const e = this.backoff[this.reconnectAttempt];
|
|
43
|
+
if (e != null)
|
|
44
|
+
await a(e);
|
|
45
|
+
else
|
|
46
|
+
throw new Error("Could not resolve ms from backoff");
|
|
47
|
+
}
|
|
48
|
+
this.reconnectAttempt += 1, await this.reconnect();
|
|
45
49
|
}
|
|
46
|
-
this.reconnectAttempt += 1, await this.reconnect();
|
|
47
|
-
}
|
|
48
50
|
});
|
|
49
51
|
n(this, "buildInitialListeners", () => {
|
|
50
52
|
this.hubConnection.onclose(() => {
|
|
@@ -84,7 +86,7 @@ class L {
|
|
|
84
86
|
});
|
|
85
87
|
n(this, "disconnect", async () => {
|
|
86
88
|
try {
|
|
87
|
-
this.info("Disconnecting..."), await this.hubConnection.stop(), this.info("Disconnected"), this.emitEvent("disconnected");
|
|
89
|
+
this.shouldReconnect = !1, this.info("Disconnecting..."), await this.hubConnection.stop(), this.info("Disconnected"), this.emitEvent("disconnected");
|
|
88
90
|
} catch {
|
|
89
91
|
this.info("Failed to disconnect");
|
|
90
92
|
}
|
|
@@ -172,7 +174,7 @@ class L {
|
|
|
172
174
|
await Promise.all(t), this.info("Left all groups");
|
|
173
175
|
});
|
|
174
176
|
n(this, "getHubConnectionId", () => this.hubConnection.connectionId);
|
|
175
|
-
this.internalEvents = /* @__PURE__ */ new Map(), this.signalREvents = /* @__PURE__ */ new Map(), this.groups = [], t.enableLogging && (this.logger = t.logger), this.hubConnection = new d().withUrl(`${t.signalRApiUrl}/${t.hub}`).configureLogging(
|
|
177
|
+
this.internalEvents = /* @__PURE__ */ new Map(), this.signalREvents = /* @__PURE__ */ new Map(), this.groups = [], t.enableLogging && (this.logger = t.logger), this.hubConnection = new d().withUrl(`${t.signalRApiUrl}/${t.hub}`).configureLogging(u.None).build(), this.buildInitialListeners();
|
|
176
178
|
}
|
|
177
179
|
}
|
|
178
180
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("react"),
|
|
1
|
+
"use strict";const n=require("react"),h=require("react-redux"),C=require("../noop-7ea3b37b.js"),B=a=>Object.freeze(Object.defineProperty({__proto__:null,default:a},Symbol.toStringTag,{value:"Module"}));function F(a,_,g,j){const{logger:q,enableLogging:x}=a;let{signalRApiUrl:I}=a;const{clientIdSelector:D,isSignalROnlineSelector:s}=_??{},{setIsSignalROnlineAction:l}=g??{},{useAppStore:G=h.useStore,useAppDispatch:m=h.useDispatch,useAppSelector:M=h.useSelector}=j??{},b=new Set;function P(o){const[f,z]=n.useState(I),[e,N]=n.useState(null),d=G(),p=m(),E=M(D??(()=>{})),[u,T]=n.useState(!1),[r,v]=n.useState(!1),O=n.useRef(u),S=n.useCallback(()=>{(s==null?void 0:s(d.getState()))===!1&&l&&p(l({isSignalROnline:!0})),r||v(!0)},[p,r,d]),k=S,H=n.useCallback(()=>{(s==null?void 0:s(d.getState()))===!0&&l&&p(l({isSignalROnline:!1})),r&&v(!1)},[p,r,d]),y=n.useCallback(async t=>{e&&e.groups.indexOf(t)<0&&await(e==null?void 0:e.joinGroup(t))},[e]),A=n.useCallback(async t=>{e&&e.groups.indexOf(t)>=0&&await(e==null?void 0:e.leaveGroup(t))},[e]),L=n.useCallback((t,c,i)=>e?e==null?void 0:e.addSignalListener(t,c,i):C.noop,[e]),U=n.useCallback((t,c)=>{e&&e.removeSignalListener(t,c)},[e]),w=n.useCallback(()=>e?e.getHubConnectionId():null,[e]);return n.useEffect(()=>{let t=!1;return Promise.resolve().then(()=>B(require("./SignalR.js"))).then(({default:c})=>{t||N(new c({signalRApiUrl:f,hub:o,logger:q,enableLogging:x}))}),()=>{t=!0}},[o,f]),n.useEffect(()=>{function t(c){z(c)}return b.add(t),()=>{b.delete(t)}},[]),n.useEffect(()=>{O.current=u},[u]),n.useEffect(()=>{const t=e==null?void 0:e.addEventListener("connected",S),c=e==null?void 0:e.addEventListener("reconnected",k),i=e==null?void 0:e.addEventListener("disconnected",H);return e&&!O.current&&T(!0),()=>{t==null||t(),c==null||c(),i==null||i()}},[e,S,H,k]),n.useEffect(()=>{e==null||e.setClientId(E||void 0)},[e,E]),n.useEffect(()=>{async function t(){await(e==null?void 0:e.connect())}u&&t()},[e,u]),n.useEffect(()=>()=>{e==null||e.leaveAllGroups().then(()=>{e==null||e.disconnect()}).catch(C.noop).finally(()=>{e==null||e.disconnect().catch(C.noop)})},[e]),n.useMemo(()=>({isHubConnected:r,join:y,leave:A,subscribe:L,unsubscribe:U,getHubConnectionId:w}),[r,y,A,L,U,w])}return{useSignalR:P,setUrl(o){I=o,b.forEach(f=>{f(o)})}}}module.exports=F;
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { useState as S, useRef as
|
|
2
|
-
import { useStore as
|
|
3
|
-
import { n as
|
|
4
|
-
function $(
|
|
5
|
-
const { logger:
|
|
6
|
-
let { signalRApiUrl:
|
|
7
|
-
const { clientIdSelector:
|
|
8
|
-
useAppStore:
|
|
9
|
-
useAppDispatch:
|
|
10
|
-
useAppSelector:
|
|
11
|
-
} =
|
|
12
|
-
function
|
|
13
|
-
const [l,
|
|
14
|
-
})), [u,
|
|
15
|
-
(
|
|
16
|
-
}, [p,
|
|
17
|
-
(
|
|
18
|
-
}, [p,
|
|
1
|
+
import { useState as S, useRef as P, useCallback as c, useEffect as r, useMemo as Q } from "react";
|
|
2
|
+
import { useStore as T, useDispatch as V, useSelector as W } from "react-redux";
|
|
3
|
+
import { n as I } from "../noop-378485d5.mjs";
|
|
4
|
+
function $(v, D, G, g) {
|
|
5
|
+
const { logger: j, enableLogging: k } = v;
|
|
6
|
+
let { signalRApiUrl: H } = v;
|
|
7
|
+
const { clientIdSelector: M, isSignalROnlineSelector: s } = D ?? {}, { setIsSignalROnlineAction: a } = G ?? {}, {
|
|
8
|
+
useAppStore: q = T,
|
|
9
|
+
useAppDispatch: z = V,
|
|
10
|
+
useAppSelector: B = W
|
|
11
|
+
} = g ?? {}, b = /* @__PURE__ */ new Set();
|
|
12
|
+
function F(i) {
|
|
13
|
+
const [l, J] = S(H), [e, K] = S(null), f = q(), p = z(), A = B(M ?? (() => {
|
|
14
|
+
})), [u, N] = S(!1), [o, L] = S(!1), U = P(u), h = c(() => {
|
|
15
|
+
(s == null ? void 0 : s(f.getState())) === !1 && a && p(a({ isSignalROnline: !0 })), o || L(!0);
|
|
16
|
+
}, [p, o, f]), m = h, C = c(() => {
|
|
17
|
+
(s == null ? void 0 : s(f.getState())) === !0 && a && p(a({ isSignalROnline: !1 })), o && L(!1);
|
|
18
|
+
}, [p, o, f]), O = c(
|
|
19
19
|
async (t) => {
|
|
20
20
|
e && e.groups.indexOf(t) < 0 && await (e == null ? void 0 : e.joinGroup(t));
|
|
21
21
|
},
|
|
22
22
|
[e]
|
|
23
|
-
),
|
|
23
|
+
), w = c(
|
|
24
24
|
async (t) => {
|
|
25
25
|
e && e.groups.indexOf(t) >= 0 && await (e == null ? void 0 : e.leaveGroup(t));
|
|
26
26
|
},
|
|
27
27
|
[e]
|
|
28
|
-
),
|
|
28
|
+
), E = c(
|
|
29
29
|
(t, n, d) => e ? e == null ? void 0 : e.addSignalListener(
|
|
30
30
|
t,
|
|
31
31
|
n,
|
|
32
32
|
d
|
|
33
|
-
) :
|
|
33
|
+
) : I,
|
|
34
34
|
[e]
|
|
35
|
-
),
|
|
35
|
+
), y = c(
|
|
36
36
|
(t, n) => {
|
|
37
37
|
e && e.removeSignalListener(t, n);
|
|
38
38
|
},
|
|
39
39
|
[e]
|
|
40
|
-
),
|
|
40
|
+
), x = c(() => e ? e.getHubConnectionId() : null, [e]);
|
|
41
41
|
return r(() => {
|
|
42
42
|
let t = !1;
|
|
43
43
|
return import("./SignalR.mjs").then(({ default: n }) => {
|
|
44
|
-
t ||
|
|
44
|
+
t || K(
|
|
45
45
|
new n({
|
|
46
46
|
signalRApiUrl: l,
|
|
47
47
|
hub: i,
|
|
48
|
-
logger:
|
|
49
|
-
enableLogging:
|
|
48
|
+
logger: j,
|
|
49
|
+
enableLogging: k
|
|
50
50
|
})
|
|
51
51
|
);
|
|
52
52
|
}), () => {
|
|
@@ -54,35 +54,35 @@ function $(h, x, y, D) {
|
|
|
54
54
|
};
|
|
55
55
|
}, [i, l]), r(() => {
|
|
56
56
|
function t(n) {
|
|
57
|
-
|
|
57
|
+
J(n);
|
|
58
58
|
}
|
|
59
59
|
return b.add(t), () => {
|
|
60
60
|
b.delete(t);
|
|
61
61
|
};
|
|
62
62
|
}, []), r(() => {
|
|
63
|
-
|
|
63
|
+
U.current = u;
|
|
64
64
|
}, [u]), r(() => {
|
|
65
65
|
const t = e == null ? void 0 : e.addEventListener(
|
|
66
66
|
"connected",
|
|
67
|
-
|
|
67
|
+
h
|
|
68
68
|
), n = e == null ? void 0 : e.addEventListener(
|
|
69
69
|
"reconnected",
|
|
70
|
-
|
|
70
|
+
m
|
|
71
71
|
), d = e == null ? void 0 : e.addEventListener(
|
|
72
72
|
"disconnected",
|
|
73
|
-
|
|
73
|
+
C
|
|
74
74
|
);
|
|
75
|
-
return e && !
|
|
75
|
+
return e && !U.current && N(!0), () => {
|
|
76
76
|
t == null || t(), n == null || n(), d == null || d();
|
|
77
77
|
};
|
|
78
78
|
}, [
|
|
79
79
|
e,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
h,
|
|
81
|
+
C,
|
|
82
|
+
m
|
|
83
83
|
]), r(() => {
|
|
84
|
-
e == null || e.setClientId(
|
|
85
|
-
}, [e,
|
|
84
|
+
e == null || e.setClientId(A || void 0);
|
|
85
|
+
}, [e, A]), r(() => {
|
|
86
86
|
async function t() {
|
|
87
87
|
await (e == null ? void 0 : e.connect());
|
|
88
88
|
}
|
|
@@ -91,25 +91,27 @@ function $(h, x, y, D) {
|
|
|
91
91
|
() => () => {
|
|
92
92
|
e == null || e.leaveAllGroups().then(() => {
|
|
93
93
|
e == null || e.disconnect();
|
|
94
|
+
}).catch(I).finally(() => {
|
|
95
|
+
e == null || e.disconnect().catch(I);
|
|
94
96
|
});
|
|
95
97
|
},
|
|
96
98
|
[e]
|
|
97
|
-
),
|
|
99
|
+
), Q(
|
|
98
100
|
() => ({
|
|
99
|
-
isHubConnected:
|
|
100
|
-
join:
|
|
101
|
-
leave:
|
|
102
|
-
subscribe:
|
|
103
|
-
unsubscribe:
|
|
104
|
-
getHubConnectionId:
|
|
101
|
+
isHubConnected: o,
|
|
102
|
+
join: O,
|
|
103
|
+
leave: w,
|
|
104
|
+
subscribe: E,
|
|
105
|
+
unsubscribe: y,
|
|
106
|
+
getHubConnectionId: x
|
|
105
107
|
}),
|
|
106
|
-
[
|
|
108
|
+
[o, O, w, E, y, x]
|
|
107
109
|
);
|
|
108
110
|
}
|
|
109
111
|
return {
|
|
110
|
-
useSignalR:
|
|
112
|
+
useSignalR: F,
|
|
111
113
|
setUrl(i) {
|
|
112
|
-
|
|
114
|
+
H = i, b.forEach((l) => {
|
|
113
115
|
l(i);
|
|
114
116
|
});
|
|
115
117
|
}
|