@ancon/wildcat-utils 1.55.0-check-optimizations.3 → 1.56.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.
Files changed (37) hide show
  1. package/check/getOrganizedCheckItemModifications.d.ts +2 -2
  2. package/check/getOrganizedCheckItemModifications.js +1 -1
  3. package/check/getOrganizedCheckItemModifications.mjs +68 -74
  4. package/check/getUniqueCheckItemModificationId.d.ts +2 -2
  5. package/check/getUniqueCheckItemModificationId.js +1 -1
  6. package/check/getUniqueCheckItemModificationId.mjs +5 -5
  7. package/checkout/getCheckoutAdyenAmount.d.ts +9 -0
  8. package/checkout/getCheckoutAdyenAmount.js +1 -0
  9. package/checkout/getCheckoutAdyenAmount.mjs +13 -0
  10. package/checkout/getCheckoutGrandTotalAmount.d.ts +6 -2
  11. package/checkout/getCheckoutGrandTotalAmount.js +1 -1
  12. package/checkout/getCheckoutGrandTotalAmount.mjs +8 -6
  13. package/checkout/getCheckoutMinimumOrderDifferenceAmount.d.ts +7 -0
  14. package/checkout/getCheckoutMinimumOrderDifferenceAmount.js +1 -0
  15. package/checkout/getCheckoutMinimumOrderDifferenceAmount.mjs +12 -0
  16. package/checkout/index.d.ts +3 -1
  17. package/checkout/index.js +1 -1
  18. package/checkout/index.mjs +59 -55
  19. package/checkout/types.d.ts +5 -0
  20. package/index.js +1 -1
  21. package/index.mjs +231 -225
  22. package/multilingual/createLocalizedCheckDetails.d.ts +2 -2
  23. package/multilingual/createLocalizedCheckDetails.js +1 -1
  24. package/multilingual/createLocalizedCheckDetails.mjs +27 -31
  25. package/package.json +16 -1
  26. package/signalr/SignalR.d.ts +3 -1
  27. package/signalr/SignalR.js +1 -1
  28. package/signalr/SignalR.mjs +93 -86
  29. package/signalr/createUseSignalRHook.js +1 -1
  30. package/signalr/createUseSignalRHook.mjs +38 -36
  31. package/signalr/index.d.ts +4 -3
  32. package/signalr/index.js +1 -1
  33. package/signalr/index.mjs +6 -4
  34. package/signalr/types.d.ts +12 -0
  35. package/signalr/useSignalRGroup.d.ts +13 -0
  36. package/signalr/useSignalRGroup.js +1 -0
  37. package/signalr/useSignalRGroup.mjs +13 -0
@@ -1,5 +1,5 @@
1
1
  import { IETFLanguageTag as r } from "@ancon/wildcat-types";
2
- function m(e) {
2
+ function u(e) {
3
3
  switch (e) {
4
4
  case "sv":
5
5
  return r.Swedish;
@@ -11,47 +11,43 @@ function m(e) {
11
11
  return null;
12
12
  }
13
13
  }
14
- function u(e, a) {
15
- var t, i;
16
- if (e) {
17
- const c = e, n = (t = e.localizedProductNames) == null ? void 0 : t[a], o = (i = e.localizedVariantNames) == null ? void 0 : i[a];
18
- return n && (c.productName = n), o && (c.variantName = o), c;
19
- }
20
- return e;
14
+ function d(e, c) {
15
+ var i, n;
16
+ const t = e, a = (i = e.localizedProductNames) == null ? void 0 : i[c], o = (n = e.localizedVariantNames) == null ? void 0 : n[c];
17
+ return a && (t.productName = a), o && (t.variantName = o), t;
21
18
  }
22
- function s(e, a) {
23
- var n, o;
24
- const t = e, i = (n = e.localizedNames) == null ? void 0 : n[a], c = (o = e.localizedReplacementNames) == null ? void 0 : o[a];
25
- return i && (t.name = i), c && (t.replacementName = c), t;
19
+ function m(e, c) {
20
+ var i, n;
21
+ const t = e, a = (i = e.localizedNames) == null ? void 0 : i[c], o = (n = e.localizedReplacementNames) == null ? void 0 : n[c];
22
+ return a && (t.name = a), o && (t.replacementName = o), t;
26
23
  }
27
- function f(e, a) {
24
+ function f(e, c) {
28
25
  const t = e;
29
- return t.product = u(
26
+ return t.product = d(
30
27
  e.product,
31
- a
28
+ c
32
29
  ), t;
33
30
  }
34
- function d(e, a) {
35
- const t = e, { product: i, modifications: c, addOnProducts: n, subCheckItems: o } = e;
36
- return t.product = u(i, a), c != null && c.length && (t.modifications = c.map(
37
- (l) => s(l, a)
38
- )), n != null && n.length && (t.addOnProducts = n == null ? void 0 : n.map(
39
- (l) => f(l, a)
40
- )), o != null && o.length && (t.subCheckItems = o.map(
41
- (l) => d(l, a)
31
+ function s(e, c) {
32
+ const t = e, { product: a, modifications: o, addOnProducts: i, subCheckItems: n } = e;
33
+ return t.product = d(a, c), o.length && (t.modifications = o.map(
34
+ (l) => m(l, c)
35
+ )), i != null && i.length && (t.addOnProducts = i.map(
36
+ (l) => f(l, c)
37
+ )), n.length && (t.subCheckItems = n.map(
38
+ (l) => s(l, c)
42
39
  )), t;
43
40
  }
44
- function N(e, a) {
45
- var i;
46
- const t = m(a);
41
+ function p(e, c) {
42
+ const t = u(c);
47
43
  if (t) {
48
- const c = e;
49
- return c.items = (i = e.items) == null ? void 0 : i.map(
50
- (n) => d(n, t)
51
- ), c;
44
+ const a = e;
45
+ return a.items = e.items.map(
46
+ (o) => s(o, t)
47
+ ), a;
52
48
  }
53
49
  return e;
54
50
  }
55
51
  export {
56
- N as default
52
+ p as default
57
53
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancon/wildcat-utils",
3
- "version": "1.55.0-check-optimizations.3",
3
+ "version": "1.56.0",
4
4
  "main": "index.js",
5
5
  "module": "index.mjs",
6
6
  "types": "index.d.ts",
@@ -180,6 +180,11 @@
180
180
  "require": "./checkout/checkoutHasWallet.js",
181
181
  "types": "./checkout/checkoutHasWallet.d.ts"
182
182
  },
183
+ "./checkout/getCheckoutAdyenAmount": {
184
+ "import": "./checkout/getCheckoutAdyenAmount.mjs",
185
+ "require": "./checkout/getCheckoutAdyenAmount.js",
186
+ "types": "./checkout/getCheckoutAdyenAmount.d.ts"
187
+ },
183
188
  "./checkout/getCheckoutGiftCardMetaData": {
184
189
  "import": "./checkout/getCheckoutGiftCardMetaData.mjs",
185
190
  "require": "./checkout/getCheckoutGiftCardMetaData.js",
@@ -210,6 +215,11 @@
210
215
  "require": "./checkout/getCheckoutItemsMappedByTicketItemStatus.js",
211
216
  "types": "./checkout/getCheckoutItemsMappedByTicketItemStatus.d.ts"
212
217
  },
218
+ "./checkout/getCheckoutMinimumOrderDifferenceAmount": {
219
+ "import": "./checkout/getCheckoutMinimumOrderDifferenceAmount.mjs",
220
+ "require": "./checkout/getCheckoutMinimumOrderDifferenceAmount.js",
221
+ "types": "./checkout/getCheckoutMinimumOrderDifferenceAmount.d.ts"
222
+ },
213
223
  "./checkout/getCheckoutOrderStatusTexts": {
214
224
  "import": "./checkout/getCheckoutOrderStatusTexts.mjs",
215
225
  "require": "./checkout/getCheckoutOrderStatusTexts.js",
@@ -1220,6 +1230,11 @@
1220
1230
  "require": "./signalr/types.js",
1221
1231
  "types": "./signalr/types.d.ts"
1222
1232
  },
1233
+ "./signalr/useSignalRGroup": {
1234
+ "import": "./signalr/useSignalRGroup.mjs",
1235
+ "require": "./signalr/useSignalRGroup.js",
1236
+ "types": "./signalr/useSignalRGroup.d.ts"
1237
+ },
1223
1238
  "./string/base64Decode": {
1224
1239
  "import": "./string/base64Decode.mjs",
1225
1240
  "require": "./string/base64Decode.js",
@@ -14,6 +14,7 @@ declare class SignalR {
14
14
  private isReconnecting;
15
15
  private pendingJoins;
16
16
  private initialReconnectDelayMs;
17
+ private maxReconnectAttempts;
17
18
  groups: string[];
18
19
  constructor(options: SignalRConfig);
19
20
  info: (message: string, data?: any) => void;
@@ -21,7 +22,8 @@ declare class SignalR {
21
22
  private getNextBackoffMs;
22
23
  private getInitialReconnectDelayMs;
23
24
  /**
24
- * Keep trying to connect, with backoff, until connected or `disconnect()` is called.
25
+ * Keep trying to connect, with backoff, until connected, `disconnect()` is
26
+ * called or `maxReconnectAttempts` attempts in a row have failed.
25
27
  * Only one reconnect loop runs at a time.
26
28
  *
27
29
  * @param withInitialDelay Wait a random `initialReconnectDelayMs` before the
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var d=(c,e,n)=>e in c?f(c,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):c[e]=n;var t=(c,e,n)=>(d(c,typeof e!="symbol"?e+"":e,n),n);const h=require("@microsoft/signalr"),a=require("@ancon/wildcat-types"),l=require("../shared/wait.js"),u=require("../api/generateBackoffWithEqualJitter.js"),g=require("../number/randomIntFromInterval.js");require("axios");const v={min:500,max:5e3};class p{constructor(e){t(this,"internalEvents");t(this,"signalREvents");t(this,"hubConnection");t(this,"clientId");t(this,"logger");t(this,"backoff",[]);t(this,"reconnectAttempt",0);t(this,"shouldReconnect",!0);t(this,"isReconnecting",!1);t(this,"pendingJoins",new Map);t(this,"initialReconnectDelayMs");t(this,"groups");t(this,"info",(e,n)=>{var i;(i=this.logger)==null||i.info(e,n)});t(this,"generateBackoff",()=>{this.backoff=u(50,500,5e3),this.info("Generated new backoff")});t(this,"getNextBackoffMs",()=>{this.backoff[this.reconnectAttempt]==null&&(this.reconnectAttempt>0&&this.info("Ran out of backoff intervals, restarting backoff..."),this.reconnectAttempt=0,this.generateBackoff());const e=this.backoff[this.reconnectAttempt];if(e==null)throw new Error("Could not resolve ms from backoff");return e});t(this,"getInitialReconnectDelayMs",()=>{const e=Math.max(0,this.initialReconnectDelayMs.min),n=Math.max(e,this.initialReconnectDelayMs.max);return g(e,n)});t(this,"reconnect",async(e=!1)=>{if(!this.isReconnecting){this.isReconnecting=!0;try{if(e){const n=this.getInitialReconnectDelayMs();this.info("Waiting before reconnecting...",{delayMs:n}),await l(n)}for(;this.shouldReconnect;)try{this.info("Attempting to reconnect...",{attempt:this.reconnectAttempt+1}),await this.connect(!0),this.info("Reconnected"),this.reconnectAttempt=0;return}catch{if(!this.shouldReconnect)break;await l(this.getNextBackoffMs()),this.reconnectAttempt+=1}}finally{this.isReconnecting=!1}}});t(this,"buildInitialListeners",()=>{this.hubConnection.onclose(()=>{this.groups=[],this.info("Hub connection closed"),this.emitEvent("disconnected"),this.reconnect(!0)}),this.hubConnection.onreconnected(()=>this.emitEvent("reconnected"))});t(this,"emitEvent",(e,...n)=>{if(this.internalEvents.has(e)){this.info(`Emitting event "${e}"`);const i=this.internalEvents.get(e);i&&i.forEach(s=>s(...n))}else this.info(`Failed to emit event "${e}". There were no listeners.`)});t(this,"skipSignal",(e,n)=>{this.info(`Skipped signal "${e}"`,n)});t(this,"enhanceListener",(e,n,i)=>s=>{const o=JSON.parse(s),r=i&&o.clientId&&o.clientId===this.clientId;return r||this.info(`Received signal "${e}"`,s),r?this.skipSignal(e,s):n(o)});t(this,"setClientId",e=>{this.clientId=e});t(this,"connect",async(e=!1)=>{try{this.info("Connecting..."),await this.hubConnection.start(),this.info("Connected"),this.emitEvent("connected")}catch(n){if(this.info("Failed to connect"),e)throw n;this.shouldReconnect&&(this.emitEvent("disconnected"),await this.reconnect())}});t(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")}});t(this,"addEventListener",(e,n)=>{this.internalEvents.has(e)||this.internalEvents.set(e,[]);const i=this.internalEvents.get(e);return i&&i.push(n),()=>this.removeEventListener(e,n)});t(this,"removeEventListener",(e,n)=>{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,n))??-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.`)});t(this,"addSignalListener",(e,n,i=!0)=>{this.signalREvents.has(e)||this.signalREvents.set(e,[]);const s=this.signalREvents.get(e),o=this.enhanceListener(e,n,i);return s&&s.push(o),this.hubConnection.on(e,o),this.info(`Added signal listener for signal "${e}"`),()=>this.removeSignalListener(e,o)});t(this,"removeSignalListener",(e,n)=>{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,n))??-1;o>=0?(this.hubConnection.off(e,n),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.`)});t(this,"joinGroup",async e=>{const n=this.pendingJoins.get(e);if(n)return n;if(this.groups.includes(e))return!0;const i=this.invokeJoinGroup(e).finally(()=>{this.pendingJoins.delete(e)});return this.pendingJoins.set(e,i),i});t(this,"invokeJoinGroup",async e=>{this.info(`Joining group "${e}"...`),this.groups.push(e);try{return await this.hubConnection.invoke(a.SignalRMethodName.JoinGroup,e),this.info(`Joined group "${e}"`),!0}catch(n){this.info(`Failed to join group "${e}"`,n);const i=this.groups.indexOf(e);return i>=0&&this.groups.splice(i,1),!1}});t(this,"leaveGroup",async e=>{this.info(`Leaving group "${e}"...`);const n=this.groups.indexOf(e);n>=0&&this.groups.splice(n,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)}});t(this,"leaveAllGroups",async()=>{this.info(`Leaving all (${this.groups.length}) groups...`);const e=[...this.groups].map(n=>this.leaveGroup(n));await Promise.all(e),this.info("Left all groups")});t(this,"getHubConnectionId",()=>this.hubConnection.connectionId);this.internalEvents=new Map,this.signalREvents=new Map,this.groups=[],this.initialReconnectDelayMs=e.initialReconnectDelayMs??v,e.enableLogging&&(this.logger=e.logger),this.hubConnection=new h.HubConnectionBuilder().withUrl(`${e.signalRApiUrl}/${e.hub}`).configureLogging(h.LogLevel.None).build(),e.serverTimeoutInMilliseconds!=null&&(this.hubConnection.serverTimeoutInMilliseconds=e.serverTimeoutInMilliseconds),e.keepAliveIntervalInMilliseconds!=null&&(this.hubConnection.keepAliveIntervalInMilliseconds=e.keepAliveIntervalInMilliseconds),this.buildInitialListeners()}}module.exports=p;
1
+ "use strict";var f=Object.defineProperty;var d=(c,e,t)=>e in c?f(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t;var n=(c,e,t)=>(d(c,typeof e!="symbol"?e+"":e,t),t);const a=require("@microsoft/signalr"),h=require("@ancon/wildcat-types"),l=require("../shared/wait.js"),u=require("../api/generateBackoffWithEqualJitter.js"),g=require("../number/randomIntFromInterval.js");require("axios");const v={min:500,max:5e3};class m{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,"isReconnecting",!1);n(this,"pendingJoins",new Map);n(this,"initialReconnectDelayMs");n(this,"maxReconnectAttempts");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,"getNextBackoffMs",()=>{this.backoff[this.reconnectAttempt]==null&&(this.reconnectAttempt>0&&this.info("Ran out of backoff intervals, restarting backoff..."),this.reconnectAttempt=0,this.generateBackoff());const e=this.backoff[this.reconnectAttempt];if(e==null)throw new Error("Could not resolve ms from backoff");return e});n(this,"getInitialReconnectDelayMs",()=>{const e=Math.max(0,this.initialReconnectDelayMs.min),t=Math.max(e,this.initialReconnectDelayMs.max);return g(e,t)});n(this,"reconnect",async(e=!1)=>{if(this.isReconnecting)return;this.isReconnecting=!0;let t=0;try{if(e){const i=this.getInitialReconnectDelayMs();this.info("Waiting before reconnecting...",{delayMs:i}),await l(i)}for(;this.shouldReconnect;)try{this.info("Attempting to reconnect...",{attempt:this.reconnectAttempt+1}),await this.connect(!0),this.info("Reconnected"),this.reconnectAttempt=0;return}catch{if(!this.shouldReconnect)break;if(t+=1,t>=this.maxReconnectAttempts){this.info(`Gave up reconnecting after ${t} attempts`),this.reconnectAttempt=0;break}await l(this.getNextBackoffMs()),this.reconnectAttempt+=1}}finally{this.isReconnecting=!1}});n(this,"buildInitialListeners",()=>{this.hubConnection.onclose(()=>{this.groups=[],this.info("Hub connection closed"),this.emitEvent("disconnected"),this.reconnect(!0)}),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),r=i&&o.clientId&&o.clientId===this.clientId;return r||this.info(`Received signal "${e}"`,s),r?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;this.shouldReconnect&&(this.emitEvent("disconnected"),await this.reconnect())}});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=>{const t=this.pendingJoins.get(e);if(t)return t;if(this.groups.includes(e))return!0;const i=this.invokeJoinGroup(e).finally(()=>{this.pendingJoins.delete(e)});return this.pendingJoins.set(e,i),i});n(this,"invokeJoinGroup",async e=>{this.info(`Joining group "${e}"...`),this.groups.push(e);try{return await this.hubConnection.invoke(h.SignalRMethodName.JoinGroup,e),this.info(`Joined group "${e}"`),!0}catch(t){this.info(`Failed to join group "${e}"`,t);const i=this.groups.indexOf(e);return i>=0&&this.groups.splice(i,1),!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(h.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=[],this.initialReconnectDelayMs=e.initialReconnectDelayMs??v,this.maxReconnectAttempts=e.maxReconnectAttempts??1/0,e.enableLogging&&(this.logger=e.logger),this.hubConnection=new a.HubConnectionBuilder().withUrl(`${e.signalRApiUrl}/${e.hub}`).configureLogging(a.LogLevel.None).build(),e.serverTimeoutInMilliseconds!=null&&(this.hubConnection.serverTimeoutInMilliseconds=e.serverTimeoutInMilliseconds),e.keepAliveIntervalInMilliseconds!=null&&(this.hubConnection.keepAliveIntervalInMilliseconds=e.keepAliveIntervalInMilliseconds),this.buildInitialListeners()}}module.exports=m;
@@ -1,80 +1,87 @@
1
1
  var l = Object.defineProperty;
2
- var f = (c, e, n) => e in c ? l(c, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : c[e] = n;
3
- var t = (c, e, n) => (f(c, typeof e != "symbol" ? e + "" : e, n), n);
2
+ var f = (c, e, t) => e in c ? l(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t;
3
+ var n = (c, e, t) => (f(c, typeof e != "symbol" ? e + "" : e, t), t);
4
4
  import { HubConnectionBuilder as d, LogLevel as u } from "@microsoft/signalr";
5
- import { SignalRMethodName as h } from "@ancon/wildcat-types";
6
- import a from "../shared/wait.mjs";
5
+ import { SignalRMethodName as a } from "@ancon/wildcat-types";
6
+ import h from "../shared/wait.mjs";
7
7
  import g from "../api/generateBackoffWithEqualJitter.mjs";
8
- import v from "../number/randomIntFromInterval.mjs";
8
+ import m from "../number/randomIntFromInterval.mjs";
9
9
  import "axios";
10
- const m = {
10
+ const p = {
11
11
  min: 500,
12
12
  max: 5e3
13
13
  };
14
- class w {
14
+ class A {
15
15
  constructor(e) {
16
- t(this, "internalEvents");
17
- t(this, "signalREvents");
18
- t(this, "hubConnection");
19
- t(this, "clientId");
20
- t(this, "logger");
21
- t(this, "backoff", []);
22
- t(this, "reconnectAttempt", 0);
23
- t(this, "shouldReconnect", !0);
24
- t(this, "isReconnecting", !1);
25
- t(this, "pendingJoins", /* @__PURE__ */ new Map());
26
- t(this, "initialReconnectDelayMs");
27
- t(this, "groups");
28
- t(this, "info", (e, n) => {
16
+ n(this, "internalEvents");
17
+ n(this, "signalREvents");
18
+ n(this, "hubConnection");
19
+ n(this, "clientId");
20
+ n(this, "logger");
21
+ n(this, "backoff", []);
22
+ n(this, "reconnectAttempt", 0);
23
+ n(this, "shouldReconnect", !0);
24
+ n(this, "isReconnecting", !1);
25
+ n(this, "pendingJoins", /* @__PURE__ */ new Map());
26
+ n(this, "initialReconnectDelayMs");
27
+ n(this, "maxReconnectAttempts");
28
+ n(this, "groups");
29
+ n(this, "info", (e, t) => {
29
30
  var i;
30
- (i = this.logger) == null || i.info(e, n);
31
+ (i = this.logger) == null || i.info(e, t);
31
32
  });
32
- t(this, "generateBackoff", () => {
33
+ n(this, "generateBackoff", () => {
33
34
  this.backoff = g(50, 500, 5e3), this.info("Generated new backoff");
34
35
  });
35
- t(this, "getNextBackoffMs", () => {
36
+ n(this, "getNextBackoffMs", () => {
36
37
  this.backoff[this.reconnectAttempt] == null && (this.reconnectAttempt > 0 && this.info("Ran out of backoff intervals, restarting backoff..."), this.reconnectAttempt = 0, this.generateBackoff());
37
38
  const e = this.backoff[this.reconnectAttempt];
38
39
  if (e == null)
39
40
  throw new Error("Could not resolve ms from backoff");
40
41
  return e;
41
42
  });
42
- t(this, "getInitialReconnectDelayMs", () => {
43
- const e = Math.max(0, this.initialReconnectDelayMs.min), n = Math.max(e, this.initialReconnectDelayMs.max);
44
- return v(e, n);
43
+ n(this, "getInitialReconnectDelayMs", () => {
44
+ const e = Math.max(0, this.initialReconnectDelayMs.min), t = Math.max(e, this.initialReconnectDelayMs.max);
45
+ return m(e, t);
45
46
  });
46
47
  /**
47
- * Keep trying to connect, with backoff, until connected or `disconnect()` is called.
48
+ * Keep trying to connect, with backoff, until connected, `disconnect()` is
49
+ * called or `maxReconnectAttempts` attempts in a row have failed.
48
50
  * Only one reconnect loop runs at a time.
49
51
  *
50
52
  * @param withInitialDelay Wait a random `initialReconnectDelayMs` before the
51
53
  * first attempt, so clients dropped at the same moment don't all reconnect at once.
52
54
  */
53
- t(this, "reconnect", async (e = !1) => {
54
- if (!this.isReconnecting) {
55
- this.isReconnecting = !0;
56
- try {
57
- if (e) {
58
- const n = this.getInitialReconnectDelayMs();
59
- this.info("Waiting before reconnecting...", { delayMs: n }), await a(n);
60
- }
61
- for (; this.shouldReconnect; )
62
- try {
63
- this.info("Attempting to reconnect...", {
64
- attempt: this.reconnectAttempt + 1
65
- }), await this.connect(!0), this.info("Reconnected"), this.reconnectAttempt = 0;
66
- return;
67
- } catch {
68
- if (!this.shouldReconnect)
69
- break;
70
- await a(this.getNextBackoffMs()), this.reconnectAttempt += 1;
71
- }
72
- } finally {
73
- this.isReconnecting = !1;
55
+ n(this, "reconnect", async (e = !1) => {
56
+ if (this.isReconnecting)
57
+ return;
58
+ this.isReconnecting = !0;
59
+ let t = 0;
60
+ try {
61
+ if (e) {
62
+ const i = this.getInitialReconnectDelayMs();
63
+ this.info("Waiting before reconnecting...", { delayMs: i }), await h(i);
74
64
  }
65
+ for (; this.shouldReconnect; )
66
+ try {
67
+ this.info("Attempting to reconnect...", {
68
+ attempt: this.reconnectAttempt + 1
69
+ }), await this.connect(!0), this.info("Reconnected"), this.reconnectAttempt = 0;
70
+ return;
71
+ } catch {
72
+ if (!this.shouldReconnect)
73
+ break;
74
+ if (t += 1, t >= this.maxReconnectAttempts) {
75
+ this.info(`Gave up reconnecting after ${t} attempts`), this.reconnectAttempt = 0;
76
+ break;
77
+ }
78
+ await h(this.getNextBackoffMs()), this.reconnectAttempt += 1;
79
+ }
80
+ } finally {
81
+ this.isReconnecting = !1;
75
82
  }
76
83
  });
77
- t(this, "buildInitialListeners", () => {
84
+ n(this, "buildInitialListeners", () => {
78
85
  this.hubConnection.onclose(() => {
79
86
  this.groups = [], this.info("Hub connection closed"), this.emitEvent("disconnected"), this.reconnect(!0);
80
87
  }), this.hubConnection.onreconnected(() => this.emitEvent("reconnected"));
@@ -84,22 +91,22 @@ class w {
84
91
  * @param event Event to emit
85
92
  * @param args Arguments to send to the listeners
86
93
  */
87
- t(this, "emitEvent", (e, ...n) => {
94
+ n(this, "emitEvent", (e, ...t) => {
88
95
  if (this.internalEvents.has(e)) {
89
96
  this.info(`Emitting event "${e}"`);
90
97
  const i = this.internalEvents.get(e);
91
- i && i.forEach((s) => s(...n));
98
+ i && i.forEach((s) => s(...t));
92
99
  } else
93
100
  this.info(`Failed to emit event "${e}". There were no listeners.`);
94
101
  });
95
- t(this, "skipSignal", (e, n) => {
96
- this.info(`Skipped signal "${e}"`, n);
102
+ n(this, "skipSignal", (e, t) => {
103
+ this.info(`Skipped signal "${e}"`, t);
97
104
  });
98
- t(this, "enhanceListener", (e, n, i) => (s) => {
105
+ n(this, "enhanceListener", (e, t, i) => (s) => {
99
106
  const o = JSON.parse(s), r = i && o.clientId && o.clientId === this.clientId;
100
- return r || this.info(`Received signal "${e}"`, s), r ? this.skipSignal(e, s) : n(o);
107
+ return r || this.info(`Received signal "${e}"`, s), r ? this.skipSignal(e, s) : t(o);
101
108
  });
102
- t(this, "setClientId", (e) => {
109
+ n(this, "setClientId", (e) => {
103
110
  this.clientId = e;
104
111
  });
105
112
  /**
@@ -110,16 +117,16 @@ class w {
110
117
  * until it connects or `disconnect()` is called; the returned promise settles
111
118
  * when that happens.
112
119
  */
113
- t(this, "connect", async (e = !1) => {
120
+ n(this, "connect", async (e = !1) => {
114
121
  try {
115
122
  this.info("Connecting..."), await this.hubConnection.start(), this.info("Connected"), this.emitEvent("connected");
116
- } catch (n) {
123
+ } catch (t) {
117
124
  if (this.info("Failed to connect"), e)
118
- throw n;
125
+ throw t;
119
126
  this.shouldReconnect && (this.emitEvent("disconnected"), await this.reconnect());
120
127
  }
121
128
  });
122
- t(this, "disconnect", async () => {
129
+ n(this, "disconnect", async () => {
123
130
  try {
124
131
  this.shouldReconnect = !1, this.info("Disconnecting..."), await this.hubConnection.stop(), this.info("Disconnected"), this.emitEvent("disconnected");
125
132
  } catch {
@@ -131,20 +138,20 @@ class w {
131
138
  * @param event Event to listen on
132
139
  * @param listener Event listener function
133
140
  */
134
- t(this, "addEventListener", (e, n) => {
141
+ n(this, "addEventListener", (e, t) => {
135
142
  this.internalEvents.has(e) || this.internalEvents.set(e, []);
136
143
  const i = this.internalEvents.get(e);
137
- return i && i.push(n), () => this.removeEventListener(e, n);
144
+ return i && i.push(t), () => this.removeEventListener(e, t);
138
145
  });
139
146
  /**
140
147
  * Remove internal event listener
141
148
  * @param event Event to stop listening to
142
149
  * @param listener Event listener function
143
150
  */
144
- t(this, "removeEventListener", (e, n) => {
151
+ n(this, "removeEventListener", (e, t) => {
145
152
  var i;
146
153
  if (this.internalEvents.has(e)) {
147
- const s = this.internalEvents.get(e), o = ((i = s == null ? void 0 : s.indexOf) == null ? void 0 : i.call(s, n)) ?? -1;
154
+ const s = this.internalEvents.get(e), o = ((i = s == null ? void 0 : s.indexOf) == null ? void 0 : i.call(s, t)) ?? -1;
148
155
  o >= 0 ? (s.splice(o, 1), this.info(`Removed event listener for event "${e}"`)) : this.info(
149
156
  `Failed to remove event listener for event "${e}". Specified listener was not found.`
150
157
  );
@@ -158,11 +165,11 @@ class w {
158
165
  * @param signal Signal name
159
166
  * @param listener Signal listener function
160
167
  */
161
- t(this, "addSignalListener", (e, n, i = !0) => {
168
+ n(this, "addSignalListener", (e, t, i = !0) => {
162
169
  this.signalREvents.has(e) || this.signalREvents.set(e, []);
163
170
  const s = this.signalREvents.get(e), o = this.enhanceListener(
164
171
  e,
165
- n,
172
+ t,
166
173
  i
167
174
  );
168
175
  return s && s.push(o), this.hubConnection.on(e, o), this.info(`Added signal listener for signal "${e}"`), () => this.removeSignalListener(e, o);
@@ -172,11 +179,11 @@ class w {
172
179
  * @param signal Signal name
173
180
  * @param listener Signal listener function
174
181
  */
175
- t(this, "removeSignalListener", (e, n) => {
182
+ n(this, "removeSignalListener", (e, t) => {
176
183
  var i;
177
184
  if (this.signalREvents.has(e)) {
178
- const s = this.signalREvents.get(e), o = ((i = s == null ? void 0 : s.indexOf) == null ? void 0 : i.call(s, n)) ?? -1;
179
- o >= 0 ? (this.hubConnection.off(e, n), s.splice(o, 1), this.info(`Removed signal listener for signal "${e}"`)) : this.info(
185
+ const s = this.signalREvents.get(e), o = ((i = s == null ? void 0 : s.indexOf) == null ? void 0 : i.call(s, t)) ?? -1;
186
+ o >= 0 ? (this.hubConnection.off(e, t), s.splice(o, 1), this.info(`Removed signal listener for signal "${e}"`)) : this.info(
180
187
  `Failed to remove signal listener for signal "${e}". Specified listener was not found.`
181
188
  );
182
189
  } else
@@ -188,10 +195,10 @@ class w {
188
195
  * Join a group. A group that is already joined, or being joined, is not joined again.
189
196
  * @returns Whether the group is joined
190
197
  */
191
- t(this, "joinGroup", async (e) => {
192
- const n = this.pendingJoins.get(e);
193
- if (n)
194
- return n;
198
+ n(this, "joinGroup", async (e) => {
199
+ const t = this.pendingJoins.get(e);
200
+ if (t)
201
+ return t;
195
202
  if (this.groups.includes(e))
196
203
  return !0;
197
204
  const i = this.invokeJoinGroup(e).finally(() => {
@@ -199,35 +206,35 @@ class w {
199
206
  });
200
207
  return this.pendingJoins.set(e, i), i;
201
208
  });
202
- t(this, "invokeJoinGroup", async (e) => {
209
+ n(this, "invokeJoinGroup", async (e) => {
203
210
  this.info(`Joining group "${e}"...`), this.groups.push(e);
204
211
  try {
205
- return await this.hubConnection.invoke(h.JoinGroup, e), this.info(`Joined group "${e}"`), !0;
206
- } catch (n) {
207
- this.info(`Failed to join group "${e}"`, n);
212
+ return await this.hubConnection.invoke(a.JoinGroup, e), this.info(`Joined group "${e}"`), !0;
213
+ } catch (t) {
214
+ this.info(`Failed to join group "${e}"`, t);
208
215
  const i = this.groups.indexOf(e);
209
216
  return i >= 0 && this.groups.splice(i, 1), !1;
210
217
  }
211
218
  });
212
- t(this, "leaveGroup", async (e) => {
219
+ n(this, "leaveGroup", async (e) => {
213
220
  this.info(`Leaving group "${e}"...`);
214
- const n = this.groups.indexOf(e);
215
- n >= 0 && this.groups.splice(n, 1);
221
+ const t = this.groups.indexOf(e);
222
+ t >= 0 && this.groups.splice(t, 1);
216
223
  try {
217
- await this.hubConnection.invoke(h.LeaveGroup, e), this.info(`Left group "${e}"`);
224
+ await this.hubConnection.invoke(a.LeaveGroup, e), this.info(`Left group "${e}"`);
218
225
  } catch (i) {
219
226
  this.groups.indexOf(e) < 0 && this.groups.push(e), this.info(`Failed to leave group "${e}"`, i);
220
227
  }
221
228
  });
222
- t(this, "leaveAllGroups", async () => {
229
+ n(this, "leaveAllGroups", async () => {
223
230
  this.info(`Leaving all (${this.groups.length}) groups...`);
224
- const e = [...this.groups].map((n) => this.leaveGroup(n));
231
+ const e = [...this.groups].map((t) => this.leaveGroup(t));
225
232
  await Promise.all(e), this.info("Left all groups");
226
233
  });
227
- t(this, "getHubConnectionId", () => this.hubConnection.connectionId);
228
- this.internalEvents = /* @__PURE__ */ new Map(), this.signalREvents = /* @__PURE__ */ new Map(), this.groups = [], this.initialReconnectDelayMs = e.initialReconnectDelayMs ?? m, e.enableLogging && (this.logger = e.logger), this.hubConnection = new d().withUrl(`${e.signalRApiUrl}/${e.hub}`).configureLogging(u.None).build(), e.serverTimeoutInMilliseconds != null && (this.hubConnection.serverTimeoutInMilliseconds = e.serverTimeoutInMilliseconds), e.keepAliveIntervalInMilliseconds != null && (this.hubConnection.keepAliveIntervalInMilliseconds = e.keepAliveIntervalInMilliseconds), this.buildInitialListeners();
234
+ n(this, "getHubConnectionId", () => this.hubConnection.connectionId);
235
+ this.internalEvents = /* @__PURE__ */ new Map(), this.signalREvents = /* @__PURE__ */ new Map(), this.groups = [], this.initialReconnectDelayMs = e.initialReconnectDelayMs ?? p, this.maxReconnectAttempts = e.maxReconnectAttempts ?? 1 / 0, e.enableLogging && (this.logger = e.logger), this.hubConnection = new d().withUrl(`${e.signalRApiUrl}/${e.hub}`).configureLogging(u.None).build(), e.serverTimeoutInMilliseconds != null && (this.hubConnection.serverTimeoutInMilliseconds = e.serverTimeoutInMilliseconds), e.keepAliveIntervalInMilliseconds != null && (this.hubConnection.keepAliveIntervalInMilliseconds = e.keepAliveIntervalInMilliseconds), this.buildInitialListeners();
229
236
  }
230
237
  }
231
238
  export {
232
- w as default
239
+ A as default
233
240
  };
@@ -1 +1 @@
1
- "use strict";const n=require("react"),I=require("react-redux"),h=require("../noop-7ea3b37b.js"),K=l=>Object.freeze(Object.defineProperty({__proto__:null,default:l},Symbol.toStringTag,{value:"Module"}));function Q(l,D,M,_){const{logger:j,enableLogging:q,serverTimeoutInMilliseconds:w,keepAliveIntervalInMilliseconds:m,initialReconnectDelayMs:x}=l;let{signalRApiUrl:v}=l;const{clientIdSelector:G,isSignalROnlineSelector:c}=D??{},{setIsSignalROnlineAction:a}=M??{},{useAppStore:P=I.useStore,useAppDispatch:T=I.useDispatch,useAppSelector:z=I.useSelector}=_??{},b=new Set;function N(o){const[f,B]=n.useState(v),[e,F]=n.useState(null),d=P(),p=T(),C=z(G??(()=>{})),[u,J]=n.useState(!1),[r,E]=n.useState(!1),k=n.useRef(u),S=n.useCallback(()=>{(c==null?void 0:c(d.getState()))===!1&&a&&p(a({isSignalROnline:!0})),r||E(!0)},[p,r,d]),y=S,A=n.useCallback(()=>{(c==null?void 0:c(d.getState()))===!0&&a&&p(a({isSignalROnline:!1})),r&&E(!1)},[p,r,d]),H=n.useCallback(async t=>e?e.joinGroup(t):!1,[e]),O=n.useCallback(async t=>{e&&e.groups.indexOf(t)>=0&&await(e==null?void 0:e.leaveGroup(t))},[e]),L=n.useCallback((t,s,i)=>e?e==null?void 0:e.addSignalListener(t,s,i):h.noop,[e]),U=n.useCallback((t,s)=>{e&&e.removeSignalListener(t,s)},[e]),g=n.useCallback(()=>e?e.getHubConnectionId():null,[e]);return n.useEffect(()=>{let t=!1;return Promise.resolve().then(()=>K(require("./SignalR.js"))).then(({default:s})=>{t||F(new s({signalRApiUrl:f,hub:o,logger:j,enableLogging:q,serverTimeoutInMilliseconds:w,keepAliveIntervalInMilliseconds:m,initialReconnectDelayMs:x}))}),()=>{t=!0}},[o,f]),n.useEffect(()=>{function t(s){B(s)}return b.add(t),()=>{b.delete(t)}},[]),n.useEffect(()=>{k.current=u},[u]),n.useEffect(()=>{const t=e==null?void 0:e.addEventListener("connected",S),s=e==null?void 0:e.addEventListener("reconnected",y),i=e==null?void 0:e.addEventListener("disconnected",A);return e&&!k.current&&J(!0),()=>{t==null||t(),s==null||s(),i==null||i()}},[e,S,A,y]),n.useEffect(()=>{e==null||e.setClientId(C||void 0)},[e,C]),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(h.noop).finally(()=>{e==null||e.disconnect().catch(h.noop)})},[e]),n.useMemo(()=>({isHubConnected:r,join:H,leave:O,subscribe:L,unsubscribe:U,getHubConnectionId:g}),[r,H,O,L,U,g])}return{useSignalR:N,setUrl(o){v=o,b.forEach(f=>{f(o)})}}}module.exports=Q;
1
+ "use strict";const n=require("react"),I=require("react-redux"),h=require("../noop-7ea3b37b.js"),Q=l=>Object.freeze(Object.defineProperty({__proto__:null,default:l},Symbol.toStringTag,{value:"Module"}));function V(l,m,D,M){const{logger:_,enableLogging:j,serverTimeoutInMilliseconds:q,keepAliveIntervalInMilliseconds:w,initialReconnectDelayMs:x,maxReconnectAttempts:G}=l;let{signalRApiUrl:v}=l;const{clientIdSelector:P,isSignalROnlineSelector:c}=m??{},{setIsSignalROnlineAction:a}=D??{},{useAppStore:T=I.useStore,useAppDispatch:z=I.useDispatch,useAppSelector:N=I.useSelector}=M??{},b=new Set;function B(o){const[f,F]=n.useState(v),[e,J]=n.useState(null),d=T(),p=z(),C=N(P??(()=>{})),[u,K]=n.useState(!1),[r,E]=n.useState(!1),k=n.useRef(u),S=n.useCallback(()=>{(c==null?void 0:c(d.getState()))===!1&&a&&p(a({isSignalROnline:!0})),r||E(!0)},[p,r,d]),A=S,y=n.useCallback(()=>{(c==null?void 0:c(d.getState()))===!0&&a&&p(a({isSignalROnline:!1})),r&&E(!1)},[p,r,d]),H=n.useCallback(async t=>e?e.joinGroup(t):!1,[e]),O=n.useCallback(async t=>{e&&e.groups.indexOf(t)>=0&&await(e==null?void 0:e.leaveGroup(t))},[e]),L=n.useCallback((t,s,i)=>e?e==null?void 0:e.addSignalListener(t,s,i):h.noop,[e]),U=n.useCallback((t,s)=>{e&&e.removeSignalListener(t,s)},[e]),g=n.useCallback(()=>e?e.getHubConnectionId():null,[e]);return n.useEffect(()=>{let t=!1;return Promise.resolve().then(()=>Q(require("./SignalR.js"))).then(({default:s})=>{t||J(new s({signalRApiUrl:f,hub:o,logger:_,enableLogging:j,serverTimeoutInMilliseconds:q,keepAliveIntervalInMilliseconds:w,initialReconnectDelayMs:x,maxReconnectAttempts:G}))}),()=>{t=!0}},[o,f]),n.useEffect(()=>{function t(s){F(s)}return b.add(t),()=>{b.delete(t)}},[]),n.useEffect(()=>{k.current=u},[u]),n.useEffect(()=>{const t=e==null?void 0:e.addEventListener("connected",S),s=e==null?void 0:e.addEventListener("reconnected",A),i=e==null?void 0:e.addEventListener("disconnected",y);return e&&!k.current&&K(!0),()=>{t==null||t(),s==null||s(),i==null||i()}},[e,S,y,A]),n.useEffect(()=>{e==null||e.setClientId(C||void 0)},[e,C]),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(h.noop).finally(()=>{e==null||e.disconnect().catch(h.noop)})},[e]),n.useMemo(()=>({isHubConnected:r,join:H,leave:O,subscribe:L,unsubscribe:U,getHubConnectionId:g}),[r,H,O,L,U,g])}return{useSignalR:B,setUrl(o){v=o,b.forEach(f=>{f(o)})}}}module.exports=V;
@@ -1,26 +1,27 @@
1
- import { useState as I, useRef as V, useCallback as s, useEffect as r, useMemo as W } from "react";
2
- import { useStore as X, useDispatch as Y, useSelector as Z } from "react-redux";
1
+ import { useState as I, useRef as W, useCallback as s, useEffect as c, useMemo as X } from "react";
2
+ import { useStore as Y, useDispatch as Z, useSelector as _ } from "react-redux";
3
3
  import { n as h } from "../noop-378485d5.mjs";
4
- function te(v, D, M, k) {
4
+ function ne(v, D, M, k) {
5
5
  const {
6
- logger: G,
7
- enableLogging: j,
8
- serverTimeoutInMilliseconds: x,
6
+ logger: x,
7
+ enableLogging: G,
8
+ serverTimeoutInMilliseconds: j,
9
9
  keepAliveIntervalInMilliseconds: T,
10
- initialReconnectDelayMs: q
10
+ initialReconnectDelayMs: q,
11
+ maxReconnectAttempts: z
11
12
  } = v;
12
- let { signalRApiUrl: A } = v;
13
- const { clientIdSelector: z, isSignalROnlineSelector: c } = D ?? {}, { setIsSignalROnlineAction: a } = M ?? {}, {
14
- useAppStore: B = X,
15
- useAppDispatch: F = Y,
16
- useAppSelector: J = Z
13
+ let { signalRApiUrl: m } = v;
14
+ const { clientIdSelector: B, isSignalROnlineSelector: r } = D ?? {}, { setIsSignalROnlineAction: a } = M ?? {}, {
15
+ useAppStore: F = Y,
16
+ useAppDispatch: J = Z,
17
+ useAppSelector: K = _
17
18
  } = k ?? {}, S = /* @__PURE__ */ new Set();
18
- function K(i) {
19
- const [d, N] = I(A), [e, P] = I(null), f = B(), p = F(), H = J(z ?? (() => {
20
- })), [u, Q] = I(!1), [o, m] = I(!1), L = V(u), b = s(() => {
21
- (c == null ? void 0 : c(f.getState())) === !1 && a && p(a({ isSignalROnline: !0 })), o || m(!0);
19
+ function N(i) {
20
+ const [d, P] = I(m), [e, Q] = I(null), f = F(), p = J(), A = K(B ?? (() => {
21
+ })), [u, V] = I(!1), [o, H] = I(!1), L = W(u), b = s(() => {
22
+ (r == null ? void 0 : r(f.getState())) === !1 && a && p(a({ isSignalROnline: !0 })), o || H(!0);
22
23
  }, [p, o, f]), U = b, C = s(() => {
23
- (c == null ? void 0 : c(f.getState())) === !0 && a && p(a({ isSignalROnline: !1 })), o && m(!1);
24
+ (r == null ? void 0 : r(f.getState())) === !0 && a && p(a({ isSignalROnline: !1 })), o && H(!1);
24
25
  }, [p, o, f]), y = s(
25
26
  async (t) => e ? e.joinGroup(t) : !1,
26
27
  [e]
@@ -42,33 +43,34 @@ function te(v, D, M, k) {
42
43
  },
43
44
  [e]
44
45
  ), w = s(() => e ? e.getHubConnectionId() : null, [e]);
45
- return r(() => {
46
+ return c(() => {
46
47
  let t = !1;
47
48
  return import("./SignalR.mjs").then(({ default: n }) => {
48
- t || P(
49
+ t || Q(
49
50
  new n({
50
51
  signalRApiUrl: d,
51
52
  hub: i,
52
- logger: G,
53
- enableLogging: j,
54
- serverTimeoutInMilliseconds: x,
53
+ logger: x,
54
+ enableLogging: G,
55
+ serverTimeoutInMilliseconds: j,
55
56
  keepAliveIntervalInMilliseconds: T,
56
- initialReconnectDelayMs: q
57
+ initialReconnectDelayMs: q,
58
+ maxReconnectAttempts: z
57
59
  })
58
60
  );
59
61
  }), () => {
60
62
  t = !0;
61
63
  };
62
- }, [i, d]), r(() => {
64
+ }, [i, d]), c(() => {
63
65
  function t(n) {
64
- N(n);
66
+ P(n);
65
67
  }
66
68
  return S.add(t), () => {
67
69
  S.delete(t);
68
70
  };
69
- }, []), r(() => {
71
+ }, []), c(() => {
70
72
  L.current = u;
71
- }, [u]), r(() => {
73
+ }, [u]), c(() => {
72
74
  const t = e == null ? void 0 : e.addEventListener(
73
75
  "connected",
74
76
  b
@@ -79,7 +81,7 @@ function te(v, D, M, k) {
79
81
  "disconnected",
80
82
  C
81
83
  );
82
- return e && !L.current && Q(!0), () => {
84
+ return e && !L.current && V(!0), () => {
83
85
  t == null || t(), n == null || n(), l == null || l();
84
86
  };
85
87
  }, [
@@ -87,14 +89,14 @@ function te(v, D, M, k) {
87
89
  b,
88
90
  C,
89
91
  U
90
- ]), r(() => {
91
- e == null || e.setClientId(H || void 0);
92
- }, [e, H]), r(() => {
92
+ ]), c(() => {
93
+ e == null || e.setClientId(A || void 0);
94
+ }, [e, A]), c(() => {
93
95
  async function t() {
94
96
  await (e == null ? void 0 : e.connect());
95
97
  }
96
98
  u && t();
97
- }, [e, u]), r(
99
+ }, [e, u]), c(
98
100
  () => () => {
99
101
  e == null || e.leaveAllGroups().then(() => {
100
102
  e == null || e.disconnect();
@@ -103,7 +105,7 @@ function te(v, D, M, k) {
103
105
  });
104
106
  },
105
107
  [e]
106
- ), W(
108
+ ), X(
107
109
  () => ({
108
110
  isHubConnected: o,
109
111
  join: y,
@@ -116,14 +118,14 @@ function te(v, D, M, k) {
116
118
  );
117
119
  }
118
120
  return {
119
- useSignalR: K,
121
+ useSignalR: N,
120
122
  setUrl(i) {
121
- A = i, S.forEach((d) => {
123
+ m = i, S.forEach((d) => {
122
124
  d(i);
123
125
  });
124
126
  }
125
127
  };
126
128
  }
127
129
  export {
128
- te as default
130
+ ne as default
129
131
  };