@digipair/skill-client-websocket 0.49.0 → 0.49.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/index.cjs.js CHANGED
@@ -4952,34 +4952,37 @@ var WS = /*#__PURE__*/_mergeNamespaces({
4952
4952
 
4953
4953
  let ClientWebSocketService = class ClientWebSocketService {
4954
4954
  async connect(params, _pinsSettingsList, context) {
4955
+ var _context_protected;
4955
4956
  const { url = '', message = [], open = [], close = [], error = [], retryInterval = 1000, maxRetries = 10 } = params;
4956
4957
  this.retryInterval = retryInterval;
4957
4958
  this.maxRetries = maxRetries;
4958
4959
  // Crée une nouvelle instance WebSocket
4959
- this.ws = new WS(url);
4960
+ this.ws = new WS(url, {
4961
+ signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal
4962
+ });
4960
4963
  // Event onopen: Connexion réussie
4961
- this.ws.onopen = async ()=>{
4964
+ this.ws.on('open', async ()=>{
4962
4965
  this.retryCount = 0; // Réinitialise le compteur de tentatives après une connexion réussie
4963
4966
  await engine.executePinsList(open, _extends({}, context));
4964
- };
4967
+ });
4965
4968
  // Event onmessage: Réception d'un message
4966
- this.ws.onmessage = (notification)=>{
4967
- engine.executePinsList(message, _extends({}, context, {
4968
- message: JSON.parse(notification.data)
4969
+ this.ws.on('message', async (notification)=>{
4970
+ await engine.executePinsList(message, _extends({}, context, {
4971
+ message: JSON.parse(notification)
4969
4972
  }));
4970
- };
4973
+ });
4971
4974
  // Event onclose: Déconnexion
4972
- this.ws.onclose = async ()=>{
4975
+ this.ws.on('close', async ()=>{
4973
4976
  await engine.executePinsList(close, _extends({}, context));
4974
4977
  this.reconnectWebSocket(params, _pinsSettingsList, context);
4975
- };
4978
+ });
4976
4979
  // Event onerror: Erreur
4977
- this.ws.onerror = (err)=>{
4978
- this.ws.close(); // Ferme la connexion en cas d'erreur
4979
- engine.executePinsList(error, _extends({}, context, {
4980
+ this.ws.on('error', async (err)=>{
4981
+ await engine.executePinsList(error, _extends({}, context, {
4980
4982
  error: err
4981
4983
  }));
4982
- };
4984
+ this.ws.close(); // Ferme la connexion en cas d'erreur
4985
+ });
4983
4986
  return this.ws;
4984
4987
  }
4985
4988
  reconnectWebSocket(params, _pinsSettingsList, context) {
package/index.esm.js CHANGED
@@ -23927,14 +23927,14 @@ function indent(str, spaces) {
23927
23927
  var match = parseIdentifier(input, i1, namePart) || namePart && parseAdditionalSymbol(input, i1) || maybeSpace && parseSpaces(input, i1);
23928
23928
  // match is required
23929
23929
  if (!match) {
23930
- return nextMatch = nextMatch1, tokens = tokens1, i = i1, {
23930
+ return tokens = tokens1, nextMatch = nextMatch1, i = i1, {
23931
23931
  v: nextMatch1
23932
23932
  };
23933
23933
  }
23934
23934
  var token = match.token, offset = match.offset;
23935
23935
  i1 += offset;
23936
23936
  if (token === " ") {
23937
- return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
23937
+ return tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
23938
23938
  }
23939
23939
  tokens1 = _to_consumable_array$1(tokens1).concat([
23940
23940
  token
@@ -23953,7 +23953,7 @@ function indent(str, spaces) {
23953
23953
  if (contextKeys.some(function(el) {
23954
23954
  return el.startsWith(name);
23955
23955
  })) {
23956
- return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
23956
+ return tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
23957
23957
  }
23958
23958
  if (dateTimeIdentifiers.some(function(el) {
23959
23959
  return el === name;
@@ -23972,9 +23972,9 @@ function indent(str, spaces) {
23972
23972
  if (dateTimeIdentifiers.some(function(el) {
23973
23973
  return el.startsWith(name);
23974
23974
  })) {
23975
- return nextMatch = nextMatch1, tokens = tokens1, i = i1, "continue";
23975
+ return tokens = tokens1, nextMatch = nextMatch1, i = i1, "continue";
23976
23976
  }
23977
- return nextMatch = nextMatch1, tokens = tokens1, i = i1, {
23977
+ return tokens = tokens1, nextMatch = nextMatch1, i = i1, {
23978
23978
  v: nextMatch1
23979
23979
  };
23980
23980
  };
@@ -32876,34 +32876,37 @@ var WS = /*#__PURE__*/_mergeNamespaces({
32876
32876
 
32877
32877
  let ClientWebSocketService = class ClientWebSocketService {
32878
32878
  async connect(params, _pinsSettingsList, context) {
32879
+ var _context_protected;
32879
32880
  const { url = '', message = [], open = [], close = [], error = [], retryInterval = 1000, maxRetries = 10 } = params;
32880
32881
  this.retryInterval = retryInterval;
32881
32882
  this.maxRetries = maxRetries;
32882
32883
  // Crée une nouvelle instance WebSocket
32883
- this.ws = new WS(url);
32884
+ this.ws = new WS(url, {
32885
+ signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal
32886
+ });
32884
32887
  // Event onopen: Connexion réussie
32885
- this.ws.onopen = async ()=>{
32888
+ this.ws.on('open', async ()=>{
32886
32889
  this.retryCount = 0; // Réinitialise le compteur de tentatives après une connexion réussie
32887
32890
  await executePinsList(open, _extends({}, context));
32888
- };
32891
+ });
32889
32892
  // Event onmessage: Réception d'un message
32890
- this.ws.onmessage = (notification)=>{
32891
- executePinsList(message, _extends({}, context, {
32892
- message: JSON.parse(notification.data)
32893
+ this.ws.on('message', async (notification)=>{
32894
+ await executePinsList(message, _extends({}, context, {
32895
+ message: JSON.parse(notification)
32893
32896
  }));
32894
- };
32897
+ });
32895
32898
  // Event onclose: Déconnexion
32896
- this.ws.onclose = async ()=>{
32899
+ this.ws.on('close', async ()=>{
32897
32900
  await executePinsList(close, _extends({}, context));
32898
32901
  this.reconnectWebSocket(params, _pinsSettingsList, context);
32899
- };
32902
+ });
32900
32903
  // Event onerror: Erreur
32901
- this.ws.onerror = (err)=>{
32902
- this.ws.close(); // Ferme la connexion en cas d'erreur
32903
- executePinsList(error, _extends({}, context, {
32904
+ this.ws.on('error', async (err)=>{
32905
+ await executePinsList(error, _extends({}, context, {
32904
32906
  error: err
32905
32907
  }));
32906
- };
32908
+ this.ws.close(); // Ferme la connexion en cas d'erreur
32909
+ });
32907
32910
  return this.ws;
32908
32911
  }
32909
32912
  reconnectWebSocket(params, _pinsSettingsList, context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-client-websocket",
3
- "version": "0.49.0",
3
+ "version": "0.49.2",
4
4
  "dependencies": {},
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js"