aotrautils-srv 0.0.222 → 0.0.225

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.
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- /*utils COMMONS library associated with aotra version : «1.0.0.000 (22/07/2022-01:01:02)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (30/07/2022-00:15:34)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -23,7 +23,6 @@
23
23
 
24
24
 
25
25
  // COMPATIBILITY browser javascript / nodejs environment :
26
-
27
26
  if(typeof(window)==="undefined") window=global;
28
27
 
29
28
 
@@ -4828,7 +4827,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4828
4827
 
4829
4828
 
4830
4829
 
4831
- /*utils SERVER library associated with aotra version : «1.0.0.000 (22/07/2022-01:01:02)»*/
4830
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (30/07/2022-00:15:34)»*/
4832
4831
  /*-----------------------------------------------------------------------------*/
4833
4832
 
4834
4833
 
@@ -4852,7 +4851,6 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4852
4851
 
4853
4852
 
4854
4853
  // COMPATIBILITY browser javascript / nodejs environment :
4855
-
4856
4854
  if(typeof(window)==="undefined") window=global;
4857
4855
 
4858
4856
 
@@ -4888,12 +4886,12 @@ const FILE_ENCODING="utf8";
4888
4886
  if(typeof(fs)==="undefined"){
4889
4887
  // TRACE
4890
4888
  console.log("WARN : Could not find the nodejs dependency «fs», aborting persister setup.");
4891
- window.getPersister=()=>{ return null; };
4889
+ getPersister=()=>{ return null; };
4892
4890
 
4893
4891
  }else{
4894
4892
 
4895
4893
 
4896
- window.getPersister=function(dataDirPath,suffix=""){
4894
+ getPersister=function(dataDirPath,suffix=""){
4897
4895
 
4898
4896
  let self={
4899
4897
 
@@ -5071,17 +5069,33 @@ WebsocketImplementation={
5071
5069
  lognow("INFO : (SERVER/CLIENT) Using socket.io websocket implementation.");
5072
5070
 
5073
5071
  if(isNodeContext){
5072
+
5073
+ // NODE SERVER :
5074
5074
  if(typeof(Socket)==="undefined"){
5075
5075
  // TRACE
5076
- console.log("«socket.io» SERVER library not called yet, calling it now.");
5076
+ console.log("«socket.io» NODE SERVER library not called yet, calling it now.");
5077
5077
  Socket=require("socket.io");
5078
5078
  return WebsocketImplementation;
5079
5079
  }
5080
5080
  if(typeof(Socket)==="undefined"){
5081
5081
  // TRACE
5082
- console.log("ERROR : «socket.io» CONSOLE/BROWSER CLIENT/SERVER library not found. Cannot launch nodejs server. Aborting.");
5082
+ console.log("ERROR : «socket.io» NODE CLIENT/SERVER library not found. Cannot launch nodejs server. Aborting.");
5083
+ return WebsocketImplementation;
5084
+ }
5085
+
5086
+ // NODE CLIENT :
5087
+ if(typeof(io)==="undefined"){
5088
+ // TRACE
5089
+ console.log("«socket.io-client» NODE CLIENT library not called yet, calling it now.");
5090
+ io=require("socket.io-client");
5091
+ }
5092
+ if(typeof(io)==="undefined"){
5093
+ // TRACE
5094
+ console.log("ERROR : «socket-client.io» NODE CLIENT library not found. Cannot launch nodejs server. Aborting.");
5083
5095
  return WebsocketImplementation;
5084
5096
  }
5097
+
5098
+
5085
5099
  }
5086
5100
 
5087
5101
  }else{
@@ -5091,16 +5105,15 @@ WebsocketImplementation={
5091
5105
  // https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications
5092
5106
  if(isNodeContext){
5093
5107
  if(typeof(WebSocket)==="undefined"){
5094
- WebSocket=require("ws");
5095
5108
  // TRACE
5096
5109
  console.log("«ws» SERVER library not called yet, calling it now.");
5110
+ WebSocket=require("ws");
5111
+ if(typeof(WebSocket)==="undefined"){
5112
+ // TRACE
5113
+ console.log("ERROR : «ws» CONSOLE/BROWSER CLIENT/SERVER library not found. Cannot launch nodejs server. Aborting.");
5114
+ }
5097
5115
  return WebsocketImplementation;
5098
5116
  }
5099
- if(typeof(WebSocket)==="undefined"){
5100
- // TRACE
5101
- console.log("ERROR : «ws» CONSOLE/BROWSER CLIENT/SERVER library not found. Cannot launch nodejs server. Aborting.");
5102
- return WebsocketImplementation;
5103
- }
5104
5117
  }
5105
5118
 
5106
5119
  }
@@ -5446,7 +5459,7 @@ WebsocketImplementation={
5446
5459
  connectToServer:(serverURL, port, isSecure=false, timeout)=>{
5447
5460
 
5448
5461
  // TRACE
5449
- lognow("INFO : Using websocket implementation : "+(WebsocketImplementation.isNodeContext?"node (server-side)":"browser (client-side)"));
5462
+ lognow("INFO : Using socket library flavor : "+(WebsocketImplementation.isNodeContext?"node (client/server-side)":"browser (client-side only)"));
5450
5463
 
5451
5464
  if(WebsocketImplementation.isNodeContext)
5452
5465
  return WebsocketImplementation.connectToServerFromNode(serverURL, port, isSecure, timeout);
@@ -5462,29 +5475,31 @@ WebsocketImplementation={
5462
5475
  /*private*/connectToServerFromNode:(serverURL, port, isSecure, timeout)=>{
5463
5476
 
5464
5477
 
5465
- // NEW : ws :
5466
- if(typeof(WebSocket)==="undefined"){
5467
- // TRACE
5468
- lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
5469
- return null;
5470
- }
5471
-
5472
5478
  // NODE CLIENT MODE ONLY :
5473
5479
  let clientSocket;
5474
5480
  if(!WebsocketImplementation.useSocketIOImplementation){
5481
+
5482
+ // NEW : ws :
5483
+ if(typeof(WebSocket)==="undefined"){
5484
+ // TRACE
5485
+ lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
5486
+ return null;
5487
+ }
5488
+
5489
+
5475
5490
  clientSocket=new WebSocket(serverURL+":"+port,/*WORKAROUND:*/{ rejectUnauthorized:false, secure: isSecure });
5476
5491
  }else{
5477
5492
  // NOW : socket.io :
5478
5493
  //client on server-side:
5479
5494
 
5480
- if(WebsocketImplementation.isNodeContext && typeof(Socket)!=="undefined"){
5495
+ if(WebsocketImplementation.isNodeContext && typeof(io)!=="undefined"){
5481
5496
  // // Node client :
5482
5497
  // connectToServer=function (serverURL, port, isSecure, timeout=10000){
5483
5498
  // return Socket.connect(serverURL + ":" + port,{timeout: timeout});
5484
5499
  // }
5485
5500
 
5486
5501
  // OLD SYNTAX: clientSocket=Socket.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5487
- // clientSocket=new Socket.Client???(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5502
+ // NO : clientSocket=new Socket.Client(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5488
5503
  clientSocket=io(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5489
5504
 
5490
5505
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.222",
3
+ "version": "0.0.225",
4
4
  "main": "aotrautils-srv.build.js",
5
5
  "description": "A library for vanilla javascript utils (server-side) used in aotra javascript CMS",
6
6
  "author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",
@@ -24,6 +24,7 @@
24
24
  "fs": "^0.0.1-security",
25
25
  "sjcl": "^1.0.8",
26
26
  "socket.io": "^4.5.1",
27
+ "socket.io-client": "^4.5.1",
27
28
  "ws": "^8.1.0"
28
29
  }
29
30
  }