aotrautils 0.0.1493 → 0.0.1495

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_29072022-2359 (28/04/2025-03:09:22)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (29/04/2025-00:10:59)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -4894,7 +4894,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4894
4894
 
4895
4895
 
4896
4896
 
4897
- /*utils CLIENT library associated with aotra version : «1_29072022-2359 (28/04/2025-03:09:22)»*/
4897
+ /*utils CLIENT library associated with aotra version : «1_29072022-2359 (29/04/2025-00:10:59)»*/
4898
4898
  /*-----------------------------------------------------------------------------*/
4899
4899
  /* ## Utility global methods in a browser (htmljs) client environment.
4900
4900
  *
@@ -13466,7 +13466,7 @@ getAORTACClient=function(clientId=getUUID(), serverNodeOrigin="ws://127.0.0.1:40
13466
13466
 
13467
13467
 
13468
13468
 
13469
- /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (28/04/2025-03:09:22)»*/
13469
+ /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (29/04/2025-00:10:59)»*/
13470
13470
  /*-----------------------------------------------------------------------------*/
13471
13471
 
13472
13472
 
@@ -14705,7 +14705,7 @@ function rayVsUnitSphereClosestPoint(p, r) {
14705
14705
  // MUST REMAIN AT THE END OF THIS LIBRARY FILE !
14706
14706
 
14707
14707
  AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
14708
- /*utils AI library associated with aotra version : «1_29072022-2359 (28/04/2025-03:09:22)»*/
14708
+ /*utils AI library associated with aotra version : «1_29072022-2359 (29/04/2025-00:10:59)»*/
14709
14709
  /*-----------------------------------------------------------------------------*/
14710
14710
 
14711
14711
 
@@ -14851,7 +14851,7 @@ getOpenAIAPIClient=(modelName, apiURL, agentRole, defaultPrompt)=>{
14851
14851
 
14852
14852
 
14853
14853
 
14854
- /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (28/04/2025-03:09:22)»*/
14854
+ /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (29/04/2025-00:10:59)»*/
14855
14855
  /*-----------------------------------------------------------------------------*/
14856
14856
 
14857
14857
 
@@ -16997,7 +16997,14 @@ class NodeServerInstance{
16997
16997
  this.listenableServer.close(doOnCloseServer);
16998
16998
  });
16999
16999
  }
17000
-
17000
+
17001
+
17002
+
17003
+ // TODO : DEVELOP...
17004
+ //sendChainable(channelNameParam, data, clientsRoomsTag=null){
17005
+ //}
17006
+
17007
+
17001
17008
  receive(channelNameParam, doOnIncomingMessage, clientsRoomsTag=null){
17002
17009
  const self=this;
17003
17010
 
@@ -17005,8 +17012,6 @@ class NodeServerInstance{
17005
17012
  lognow("(SERVER) Registering receive for «"+channelNameParam+"»...");
17006
17013
 
17007
17014
  const serverReceptionEntryPoint=new ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, doOnIncomingMessage);
17008
-
17009
- ///!!!
17010
17015
  this.serverReceptionEntryPoints.push(serverReceptionEntryPoint);
17011
17016
 
17012
17017
  // SPECIAL FOR THE SOCKETIO IMPLEMENTATION :
@@ -17020,11 +17025,6 @@ class NodeServerInstance{
17020
17025
  return this;
17021
17026
  }
17022
17027
 
17023
-
17024
- // TODO : DEVELOP...
17025
- //sendChainable(channelNameParam, data, clientsRoomsTag=null){
17026
- //}
17027
-
17028
17028
 
17029
17029
  send(channelName, data, clientsRoomsTag=null, clientSocketParam=null){
17030
17030
 
@@ -17257,11 +17257,11 @@ class ClientReceptionEntryPoint{
17257
17257
  this.doOnIncomingMessage=doOnIncomingMessage;
17258
17258
  }
17259
17259
 
17260
+ // III-
17260
17261
  execute(eventOrMessage, clientSocket, clientReceptionEntryPoints){
17261
17262
 
17262
17263
  const channelName=this.channelName;
17263
17264
 
17264
-
17265
17265
  const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
17266
17266
 
17267
17267
  // Channel information is stored in exchanged data :
@@ -17270,17 +17270,31 @@ class ClientReceptionEntryPoint{
17270
17270
  // Room information is stored in client socket object :
17271
17271
  if(!WebsocketImplementation.isInRoom(clientSocket, this.clientsRoomsTag)) return;
17272
17272
 
17273
-
17274
17273
  if( this.listenerConfig && this.listenerConfig.messageType && dataWrapped.type
17275
17274
  && this.listenerConfig.messageType===dataWrapped.type) return;
17276
17275
 
17276
+ const dataLocal=dataWrapped.data;
17277
+
17278
+ // We check if the message matches the condition :
17279
+ if(this.listenerConfig.condition && !lthis.istenerConfig.condition(dataLocal, clientSocket)) return ;
17280
+
17281
+ const messageIdLocal=this.listenerConfig.messageId;
17282
+ // We check if we have the same message id:
17283
+ if(messageIdLocal!==dataLocal.messageId){
17284
+ // DBG
17285
+ lognow("DEBUG : Message ignored : messageId:"+messageIdParam+"|dataLocal.messageId"+dataLocal.messageId);
17286
+ return;
17287
+ }
17288
+
17289
+ // --------------------------------
17290
+
17277
17291
  // We remove one-time usage listeners :
17278
17292
  // We remove BEFORE executing doOnIncomingMessage(), because in this reception entry point function we can have other listener registration UNDER THE SAME ID !
17279
17293
  if(this.listenerConfig && this.listenerConfig.destroyListenerAfterReceiving)
17280
17294
  remove(this, clientReceptionEntryPoints);
17281
17295
 
17282
17296
  if(this.doOnIncomingMessage)
17283
- this.doOnIncomingMessage(dataWrapped.data, clientSocket, this.listenerConfig.messageId);
17297
+ this.doOnIncomingMessage(dataLocal, clientSocket);
17284
17298
 
17285
17299
  }
17286
17300
 
@@ -17297,33 +17311,8 @@ class ClientInstance{
17297
17311
  this.clientReceptionEntryPoints=[];
17298
17312
 
17299
17313
  }
17300
-
17301
- receive(channelNameParam, doOnIncomingMessage, clientsRoomsTag=null, entryPointId=null, listenerConfig={destroyListenerAfterReceiving:false}){
17302
- const self=this;
17303
-
17304
- // DBG
17305
- lognow("INFO : (CLIENT) SETTING UP RECEIVE for :",channelNameParam);
17306
-
17307
- const clientReceptionEntryPoint=new ClientReceptionEntryPoint(channelNameParam, entryPointId, clientsRoomsTag, listenerConfig, doOnIncomingMessage);
17308
- if(!contains.filter((l)=>(
17309
- l.entryPointId && clientReceptionEntryPoint.entryPointId
17310
- && l.entryPointId===clientReceptionEntryPoint.entryPointId
17311
- ))(this.clientReceptionEntryPoints)){
17312
-
17313
- this.clientReceptionEntryPoints.push(clientReceptionEntryPoint);
17314
- }
17315
-
17316
- const clientSocket=this.clientSocket;
17317
- if(WebsocketImplementation.useSocketIOImplementation){
17318
- // FOR THE SOCKETIO IMPLEMENTATION :
17319
- clientSocket.on(channelNameParam, (eventOrMessage)=>{
17320
- clientReceptionEntryPoint.execute(eventOrMessage, clientSocket, this.clientReceptionEntryPoints);
17321
- });
17322
- }
17323
-
17324
- return this;
17325
- }
17326
-
17314
+
17315
+
17327
17316
  sendChainable(channelNameParam, data, clientsRoomsTag=null){
17328
17317
  const self=this;
17329
17318
 
@@ -17338,25 +17327,14 @@ class ClientInstance{
17338
17327
  const resultPromise={
17339
17328
  // CAUTION : CANNOT STORE ANYTHING IN THE resultPromise, FOR ASYNC CALLS MAKES ITS DATA INCONSISTENT IN TIME !
17340
17329
  thenWhenReceiveMessageType:(channelNameForResponse, listenerConfig={messageType:"",condition:()=>true}, doOnIncomingMessageForResponse)=>{
17330
+
17341
17331
  listenerConfig=nonull(listenerConfig,{messageType:"",condition:()=>true});
17342
17332
  const listenerId=nonull(listenerConfig.messageType,"");
17343
17333
 
17334
+ // I-
17344
17335
  //
17345
- self.receive(channelNameForResponse, (dataLocal, clientSocket, messageIdParam)=>{
17346
-
17347
- // We check if the message matches the condition :
17348
- if(listenerConfig.condition && !listenerConfig.condition(dataLocal, clientSocket)) return ;
17349
-
17350
- // We check if we have the same message id:
17351
- if(messageIdParam!==dataLocal.messageId){
17352
- // DBG
17353
- lognow("DEBUG : Message ignored : resultPromise.messageId:"+resultPromise.messageId+"|dataLocal.messageId"+dataLocal.messageId);
17354
- return;
17355
- }
17356
-
17357
- doOnIncomingMessageForResponse(dataLocal, clientSocket);
17358
-
17359
- }, clientsRoomsTag, listenerId, {messageId:messageId, destroyListenerAfterReceiving:true});
17336
+ self.receive(channelNameForResponse, doOnIncomingMessageForResponse
17337
+ , clientsRoomsTag, listenerId, {messageId:messageId, destroyListenerAfterReceiving:true});
17360
17338
  //
17361
17339
 
17362
17340
  return resultPromise;
@@ -17369,6 +17347,35 @@ class ClientInstance{
17369
17347
 
17370
17348
  return resultPromise;
17371
17349
  }
17350
+
17351
+ // II-
17352
+ receive(channelNameParam, doOnIncomingMessage, clientsRoomsTag=null, entryPointId=null, listenerConfig={destroyListenerAfterReceiving:false}){
17353
+ const self=this;
17354
+
17355
+ // DBG
17356
+ lognow("INFO : (CLIENT) SETTING UP RECEIVE for :",channelNameParam);
17357
+
17358
+ const clientReceptionEntryPoint=new ClientReceptionEntryPoint(channelNameParam, entryPointId, clientsRoomsTag, listenerConfig, doOnIncomingMessage);
17359
+ if(!contains.filter((l)=>(
17360
+ l.entryPointId && clientReceptionEntryPoint.entryPointId
17361
+ && l.entryPointId===clientReceptionEntryPoint.entryPointId
17362
+ ))(this.clientReceptionEntryPoints)){
17363
+
17364
+ this.clientReceptionEntryPoints.push(clientReceptionEntryPoint);
17365
+ }
17366
+
17367
+ const clientSocket=this.clientSocket;
17368
+ if(WebsocketImplementation.useSocketIOImplementation){
17369
+ // FOR THE SOCKETIO IMPLEMENTATION :
17370
+ clientSocket.on(channelNameParam, (eventOrMessage)=>{
17371
+ clientReceptionEntryPoint.execute(eventOrMessage, clientSocket, this.clientReceptionEntryPoints);
17372
+ });
17373
+ }
17374
+
17375
+ return this;
17376
+ }
17377
+
17378
+
17372
17379
 
17373
17380
 
17374
17381
  send(channelNameParam, data, clientsRoomsTag=null){
aotrautils/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.1493",
3
+ "version": "0.0.1495",
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)",