aotrautils 0.0.122 → 0.0.125

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:00:17)»*/
3
+ /*utils COMMONS library associated with aotra version : «1.0.0.000 (16/07/2022-16:26:34)»*/
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:00:17)»*/
4831
+ /*utils CLIENT library associated with aotra version : «1.0.0.000 (16/07/2022-16:26:34)»*/
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:00:17)»*/
11681
+ /*utils GEOMETRY library associated with aotra version : «1.0.0.000 (16/07/2022-16:26:34)»*/
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:00:17)»*/
12887
+ /*utils SERVER library associated with aotra version : «1.0.0.000 (16/07/2022-16:26:34)»*/
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,32 +13120,52 @@ 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
  },
13154
13166
 
13155
13167
 
13156
- getServer:(listenableServer, port)=>{
13168
+ getServer:(listenableServer)=>{
13157
13169
 
13158
13170
  if(!WebsocketImplementation.isNodeContext){
13159
13171
  // TRACE
@@ -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
@@ -13184,8 +13192,6 @@ WebsocketImplementation={
13184
13192
  serverSocket.disconnect();
13185
13193
  });
13186
13194
 
13187
- // ////
13188
- serverSocket.listen(port);
13189
13195
 
13190
13196
  }
13191
13197
 
@@ -13649,7 +13655,9 @@ WebsocketImplementation={
13649
13655
  // }else{
13650
13656
  // // TRACE
13651
13657
  // console.log("ERROR : Could not initialize socket !");
13652
- clientSocket=io.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
13658
+ // OLD SYNTAX :clientSocket=io.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
13659
+ clientSocket=Socket(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
13660
+
13653
13661
  }
13654
13662
 
13655
13663
 
@@ -13852,12 +13860,12 @@ launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=null, /
13852
13860
 
13853
13861
  let listenableServer;
13854
13862
  if(sslOptions){
13855
- let httpsServer=https.createServer(sslOptions, handler); // OLD : .listen(port);
13863
+ let httpsServer=https.createServer(sslOptions, handler).listen(port);
13856
13864
  // TRACE
13857
13865
  console.log("INFO : SERVER : HTTPS Server launched and listening on port " + port + "!");
13858
13866
  listenableServer=httpsServer;
13859
13867
  }else{
13860
- let httpServer=http.createServer(handler);// OLD : .listen(port);
13868
+ let httpServer=http.createServer(handler).listen(port);
13861
13869
  // TRACE
13862
13870
  console.log("INFO : SERVER : HTTP Server launched and listening on port " + port + "!");
13863
13871
  listenableServer=httpServer;
aotrautils/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.122",
3
+ "version": "0.0.125",
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)",