aotrautils 0.0.123 → 0.0.126

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 (16/07/2022-16:02:20)»*/
3
+ /*utils COMMONS library associated with aotra version : «1.0.0.000 (16/07/2022-16:41:40)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -4828,7 +4828,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4828
4828
 
4829
4829
 
4830
4830
 
4831
- /*utils CLIENT library associated with aotra version : «1.0.0.000 (16/07/2022-16:02:20)»*/
4831
+ /*utils CLIENT library associated with aotra version : «1.0.0.000 (16/07/2022-16:41:40)»*/
4832
4832
  /*-----------------------------------------------------------------------------*/
4833
4833
  /* ## Utility global methods in a browser (htmljs) client environment.
4834
4834
  *
@@ -11678,7 +11678,7 @@ createFusrodaClient=function(doOnClientReady, doOnDataReception, urlParam=null,
11678
11678
 
11679
11679
 
11680
11680
 
11681
- /*utils GEOMETRY library associated with aotra version : «1.0.0.000 (16/07/2022-16:02:20)»*/
11681
+ /*utils GEOMETRY library associated with aotra version : «1.0.0.000 (16/07/2022-16:41:40)»*/
11682
11682
  /*-----------------------------------------------------------------------------*/
11683
11683
 
11684
11684
 
@@ -12884,7 +12884,7 @@ function rayVsUnitSphereClosestPoint(p, r) {
12884
12884
  // MUST REMAIN AT THE END OF THIS LIBRARY FILE !
12885
12885
 
12886
12886
  AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
12887
- /*utils SERVER library associated with aotra version : «1.0.0.000 (16/07/2022-16:02:20)»*/
12887
+ /*utils SERVER library associated with aotra version : «1.0.0.000 (16/07/2022-16:41:40)»*/
12888
12888
  /*-----------------------------------------------------------------------------*/
12889
12889
 
12890
12890
 
@@ -12928,17 +12928,11 @@ if(typeof(window)==="undefined") window=global;
12928
12928
  // https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications
12929
12929
 
12930
12930
  // We have to import both implementations, regardless of which one is chosen :
12931
- //const {Socket}=require("socket.io");
12932
- //const {WebSocket}=require("ws");
12933
- Socket=require("socket.io");
12934
- WebSocket=require("ws");
12931
+ //Socket=require("socket.io");
12932
+ //WebSocket=require("ws");
12935
12933
 
12936
12934
 
12937
12935
 
12938
- // DBG
12939
- console.log("Socket!!!!!!>>>>",Socket);
12940
- console.log("WebSocket!!!!!!>>>>",WebSocket);
12941
-
12942
12936
 
12943
12937
  // =================================================================================
12944
12938
  // NODEJS UTILS
@@ -13108,10 +13102,8 @@ if(typeof(fs)==="undefined"){
13108
13102
 
13109
13103
  // NODE ONLY SERVER / CLIENTS :
13110
13104
  WebsocketImplementation={
13111
-
13112
- // Socket:Socket,
13113
- // WebSocket:WebSocket,
13114
-
13105
+
13106
+
13115
13107
  isNodeContext:true,
13116
13108
  useSocketIOImplementation:false,
13117
13109
  useFlatStrings:false,
@@ -13128,26 +13120,46 @@ WebsocketImplementation={
13128
13120
  getStatic:(isNodeContext=true, useSocketIOImplementation=false)=>{
13129
13121
 
13130
13122
  WebsocketImplementation.isNodeContext=isNodeContext;
13131
-
13132
13123
  WebsocketImplementation.useSocketIOImplementation=useSocketIOImplementation;
13133
13124
 
13134
13125
  if(WebsocketImplementation.useSocketIOImplementation){
13135
13126
  // TRACE
13136
13127
  lognow("INFO : (SERVER/CLIENT) Using socket.io websocket implementation.");
13128
+
13129
+ if(isNodeContext && typeof(Socket)==="undefined"){
13130
+ // TRACE
13131
+ console.log("«socket.io» SERVER library not called yet, calling it now.");
13132
+ Socket=require("socket.io");
13133
+ return WebsocketImplementation;
13134
+ }
13135
+ if(typeof(Socket)==="undefined"){
13136
+ // TRACE
13137
+ console.log("ERROR : «socket.io» CONSOLE/BROWSER CLIENT/SERVER library not found. Cannot launch nodejs server. Aborting.");
13138
+ return WebsocketImplementation;
13139
+ }
13137
13140
 
13138
13141
  }else{
13139
13142
  // TRACE
13140
- lognow("INFO : (SERVER/CLIENT) Using native websocket implementation.");
13143
+ lognow("INFO : (SERVER/CLIENT) Using native WebSocket implementation.");
13144
+
13145
+ // https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications
13146
+ if(isNodeContext && typeof(WebSocket)==="undefined"){
13147
+ WebSocket=require("ws");
13148
+ // TRACE
13149
+ console.log("«ws» SERVER library not called yet, calling it now.");
13150
+ return WebsocketImplementation;
13151
+ }
13152
+ if(typeof(WebSocket)==="undefined"){
13153
+ // TRACE
13154
+ console.log("ERROR : «ws» CONSOLE/BROWSER CLIENT/SERVER library not found. Cannot launch nodejs server. Aborting.");
13155
+ return WebsocketImplementation;
13156
+ }
13141
13157
 
13142
13158
  }
13159
+
13143
13160
 
13144
13161
  // *********************************************************************************
13145
-
13146
- // DBG
13147
- console.log("11111 Socket:",Socket);
13148
- console.log("11111 WebSocket:",WebSocket);
13149
13162
 
13150
-
13151
13163
 
13152
13164
  return WebsocketImplementation;
13153
13165
  },
@@ -13169,10 +13181,6 @@ WebsocketImplementation={
13169
13181
  serverSocket=new WebSocket.Server({ "server":listenableServer });
13170
13182
  }else{
13171
13183
 
13172
-
13173
- // DBG
13174
- console.log(">>>>>>>Socket:",Socket);
13175
- console.log(">>>>>>>WebSocket:",WebSocket);
13176
13184
 
13177
13185
  // NOW : socket.io :
13178
13186
  // Loading socket.io
@@ -13465,7 +13473,6 @@ WebsocketImplementation={
13465
13473
  /*private*/connectToServerFromNode:(serverURL, port, isSecure, timeout)=>{
13466
13474
 
13467
13475
 
13468
-
13469
13476
  // NEW : ws :
13470
13477
  if(typeof(WebSocket)==="undefined"){
13471
13478
  // TRACE
@@ -13488,7 +13495,8 @@ WebsocketImplementation={
13488
13495
  // }
13489
13496
 
13490
13497
  // OLD SYNTAX: clientSocket=Socket.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
13491
- clientSocket=Socket(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
13498
+ // clientSocket=new Socket.Client???(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
13499
+ clientSocket=io(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
13492
13500
 
13493
13501
  }
13494
13502
  }
@@ -13647,7 +13655,9 @@ WebsocketImplementation={
13647
13655
  // }else{
13648
13656
  // // TRACE
13649
13657
  // console.log("ERROR : Could not initialize socket !");
13650
- clientSocket=io.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
13658
+ // OLD SYNTAX :clientSocket=io.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
13659
+ clientSocket=io(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
13660
+
13651
13661
  }
13652
13662
 
13653
13663
 
aotrautils/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.123",
3
+ "version": "0.0.126",
4
4
  "main": "aotrautils.build.js",
5
5
  "description": "A library for vanilla javascript utils (client-side) used in aotra javascript CMS",
6
6
  "author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",