aotrautils 0.0.2035 → 0.0.2037

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 (12/10/2026-22:30:09)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (13/10/2026-01:15:36)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -5485,7 +5485,7 @@ window.AOTRAUTILS_LIB_IS_LOADED=true;
5485
5485
 
5486
5486
 
5487
5487
 
5488
- /*utils CLIENT library associated with aotra version : «1_29072022-2359 (12/10/2026-22:30:09)»*/
5488
+ /*utils CLIENT library associated with aotra version : «1_29072022-2359 (13/10/2026-01:15:36)»*/
5489
5489
  /*-----------------------------------------------------------------------------*/
5490
5490
  /* ## Utility global methods in a browser (htmljs) client environment.
5491
5491
  *
@@ -13041,7 +13041,7 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
13041
13041
 
13042
13042
 
13043
13043
 
13044
- /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (12/10/2026-22:30:09)»*/
13044
+ /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (13/10/2026-01:15:36)»*/
13045
13045
  /*-----------------------------------------------------------------------------*/
13046
13046
 
13047
13047
 
@@ -14130,10 +14130,10 @@ function rayVsUnitSphereClosestPoint(p, r) {
14130
14130
  // MUST REMAIN AT THE END OF THIS LIBRARY FILE !
14131
14131
 
14132
14132
  window.AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
14133
- /*utils 3D library associated with aotra version : «1_29072022-2359 (12/10/2026-22:30:09)»*/
14133
+ /*utils 3D library associated with aotra version : «1_29072022-2359 (13/10/2026-01:15:36)»*/
14134
14134
  /*-----------------------------------------------------------------------------*/
14135
14135
 
14136
- /*utils AI library associated with aotra version : «1_29072022-2359 (12/10/2026-22:30:09)»*/
14136
+ /*utils AI library associated with aotra version : «1_29072022-2359 (13/10/2026-01:15:36)»*/
14137
14137
  /*-----------------------------------------------------------------------------*/
14138
14138
 
14139
14139
 
@@ -14397,7 +14397,7 @@ window.getLLMAPIClient=(modelName, apiURL, agentRole, defaultPrompt, llmProvider
14397
14397
 
14398
14398
 
14399
14399
 
14400
- /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (12/10/2026-22:30:09)»*/
14400
+ /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (13/10/2026-01:15:36)»*/
14401
14401
  /*-----------------------------------------------------------------------------*/
14402
14402
 
14403
14403
 
@@ -16810,11 +16810,11 @@ window.WebsocketImplementation={
16810
16810
  || contains(clientsRoomsTag, clientSocket.clientRoomTag));
16811
16811
  },
16812
16812
 
16813
- /*public static*/isInRightChannel(eventOrMessage, channelName){
16814
- return (!eventOrMessage || empty(eventOrMessage)
16815
- || !eventOrMessage.channelName || empty(eventOrMessage.channelName)
16813
+ /*public static*/isInRightChannel(dataWrapped, channelName){
16814
+ return (!dataWrapped || empty(dataWrapped)
16815
+ || !dataWrapped.channelName || empty(dataWrapped.channelName)
16816
16816
  || !channelName || empty(channelName)
16817
- || eventOrMessage.channelName==channelName);
16817
+ || dataWrapped.channelName==channelName);
16818
16818
  },
16819
16819
 
16820
16820
  //
@@ -17217,15 +17217,10 @@ window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=
17217
17217
  };
17218
17218
 
17219
17219
 
17220
- /*private static*/handleHTTPEndpoints=async function(request, response){
17220
+ const /*private static*/HANDLE_HTTP_ENDPOINTS=async function(request, response){
17221
17221
  const url=new URL(request.url, `https://${request.headers.host}`);
17222
17222
 
17223
17223
 
17224
- // DBG
17225
- lognow(" DEBUG : handler.httpEndpoints:",handler.httpEndpoints);
17226
-
17227
-
17228
-
17229
17224
  for(const httpEndpoint of handler.httpEndpoints){
17230
17225
 
17231
17226
 
@@ -17241,7 +17236,6 @@ window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=
17241
17236
 
17242
17237
  messageIn={...getRequestURLParameters(request)};
17243
17238
 
17244
- return true;
17245
17239
  }else if(requestHttpMethod=="POST"
17246
17240
  && contains(["POST","PUT","PATCH","DELETE"],httpEndpoint.httpMethod.toUpperCase())){
17247
17241
 
@@ -17257,6 +17251,8 @@ window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=
17257
17251
 
17258
17252
  response.writeHead(httpEndpointResultObject.httpStatus, { "Content-Type": "application/json" });
17259
17253
  response.end(JSON.stringify(httpEndpointResultObject.body));
17254
+
17255
+ return true;
17260
17256
  }
17261
17257
 
17262
17258
 
@@ -17271,13 +17267,13 @@ window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=
17271
17267
  return false;
17272
17268
  };
17273
17269
 
17274
- const handler=function(request, response){
17270
+ const handler=nonull(httpHandlerParam, function(request, response){
17275
17271
 
17276
17272
  try{
17277
17273
  EXCLUSION_HANDLER(request, response);
17278
- handleHTTPEndpoints(request, response).then(httpEndpointHasInterceptedRequest=>{
17274
+ HANDLE_HTTP_ENDPOINTS(request, response).then(httpEndpointHasInterceptedRequest=>{
17279
17275
  if(!httpEndpointHasInterceptedRequest){
17280
- nonull(httpHandlerParam, DEFAULT_HANDLER_HTTP_FILE_RETRIEVAL)(request, response);
17276
+ DEFAULT_HANDLER_HTTP_FILE_RETRIEVAL(request, response);
17281
17277
  }
17282
17278
  }).catch(error=>{
17283
17279
  // TRACE
@@ -17288,7 +17284,7 @@ window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=
17288
17284
  lognow("ERROR : An error occurred when trying to process request :error:",error);
17289
17285
  }
17290
17286
 
17291
- };
17287
+ });
17292
17288
 
17293
17289
 
17294
17290
  let listenableServer;
@@ -18132,10 +18128,8 @@ window.ClientReceptionEntryPoint=class ClientReceptionEntryPoint{
18132
18128
  const dataWrapped=window.WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
18133
18129
 
18134
18130
  // We check if the message is in the right channel (channel information is stored in exchanged wrapped data) :
18135
- const channelName=this.channelName;
18136
- if(dataWrapped.channelName && dataWrapped.channelName!==this.channelName){
18137
- return;
18138
- }
18131
+ // Channel information is stored in wrapped exchanged data :
18132
+ if(!window.WebsocketImplementation.isInRightChannel(dataWrapped, this.channelName)) return;
18139
18133
 
18140
18134
  // We check if the message is in the right room (r)oom information is stored in client socket object) :
18141
18135
  if(!window.WebsocketImplementation.isInRoom(clientSocket, this.clientsRoomsTag)) return;
@@ -18404,24 +18398,30 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
18404
18398
  // Executed whenever any message is received on any channel :
18405
18399
  executeAll(eventOrMessage, clientSocket=null){ // FOR REAL-TIME ONLY :
18406
18400
 
18407
-
18408
18401
  const clientsRoomsTag=this.clientsRoomsTag;
18409
18402
  if(!window.WebsocketImplementation.isInRoom(clientSocket, clientsRoomsTag)) return;
18410
18403
 
18411
18404
  const channelName=this.channelName;
18412
- if(!window.WebsocketImplementation.isInRightChannel(eventOrMessage, channelName)) return;
18405
+
18406
+ const dataWrapped=window.WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
18407
+
18408
+ // Channel information is stored in wrapped exchanged data :
18409
+ if(!window.WebsocketImplementation.isInRightChannel(dataWrapped, channelName)) return;
18413
18410
 
18414
- executeAllPrerequisites(eventOrMessage).then(prequisiteResult=>{
18415
- const messageModifiedByPrerequisites=prequisiteResult;
18411
+ this.executeAllPrerequisites(dataWrapped, eventOrMessage, clientSocket).then(eventOrMessageParam=>{
18412
+
18413
+ //DBG
18414
+ lognow("DEBUG : Prerequisite passed, executing server reception points...");
18415
+
18416
18416
  foreach(this.serverReceptionEntryPoints, (serverReceptionEntryPoint,i)=>{
18417
18417
 
18418
18418
  // All listeners are executed IN PARALLEL !
18419
- serverReceptionEntryPoint.execute(messageModifiedByPrerequisites, clientSocket).then((message)=>{
18419
+ const p=serverReceptionEntryPoint.execute(eventOrMessageParam, clientSocket);
18420
+ p.then((message)=>{
18420
18421
  /*DO NOTHING*/
18421
18422
  lognow("SERVER : DEBUG : Server sent message:",message);
18422
18423
  }).catch(treatmentsChannelError=>{
18423
-
18424
- const errorMessage="INFO : An error has occured during the processing of a client message on channel treatments.";
18424
+ const errorMessage="ERROR : An error has occured during the processing of a client message on channel treatments.";
18425
18425
 
18426
18426
  // TRACE
18427
18427
  lognow(errorMessage, treatmentsChannelError);
@@ -18435,11 +18435,9 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
18435
18435
 
18436
18436
  }).catch(error=>{
18437
18437
  // TRACE
18438
- lognow("ERROR : (.executeAll()) A prerequisite encountered an error :", error);
18438
+ lognow("ERROR : (.executeAllPrerequisites()) A prerequisite encountered an error :", error);
18439
18439
  });
18440
18440
 
18441
-
18442
-
18443
18441
  }
18444
18442
 
18445
18443
  addReceiveListenerPrerequisite(asyncPrerequisiteMethod){
@@ -18449,21 +18447,24 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
18449
18447
  return this;
18450
18448
  }
18451
18449
 
18452
- async executeAllPrerequisites(eventOrMessage){
18453
- let prequisiteResult=eventOrMessage;
18450
+ async executeAllPrerequisites(dataWrapped, originalEventOrMessage, clientSocket){
18451
+
18452
+ const message=dataWrapped.data
18454
18453
  let i=1;
18455
18454
  try {
18456
- for(const asyncPrerequisiteMethod of this.asyncPrerequisiteMethods) {
18457
- prequisiteResult=await asyncPrerequisiteMethod(prequisiteResult, clientSocket);
18455
+ for(const asyncPrerequisiteMethod of this.asyncPrerequisiteMethods){
18456
+ await asyncPrerequisiteMethod(message, clientSocket);
18458
18457
  i++;
18459
18458
  }
18460
18459
  }catch(error){
18461
18460
  // TRACE
18462
18461
  lognow("ERROR : (.executeAllPrerequisites()) Prerequisite #"+i+" encountered an error :", error);
18462
+ throw error;
18463
18463
  }
18464
- return prequisiteResult;
18464
+ return originalEventOrMessage;
18465
18465
  }
18466
18466
 
18467
+ // I-
18467
18468
  // ASYNC
18468
18469
  addReceiveListener(messageType, asyncDoOnIncomingMessage, httpEndpointDefinition=null){
18469
18470
  const channelNameParam=this.channelNameParam;
@@ -18472,7 +18473,8 @@ window.ServerReceptionEntryPointsBag=class ServerReceptionEntryPointsBag{
18472
18473
  (isArray(messageType) ? messageType : [messageType])
18473
18474
  );
18474
18475
  const listenerConfig={listenerMessageTypes:messageTypes, httpEndpointDefinition:httpEndpointDefinition};
18475
- const serverReceptionEntryPoint=new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig, asyncDoOnIncomingMessage);
18476
+ const serverReceptionEntryPoint=
18477
+ new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig, asyncDoOnIncomingMessage);
18476
18478
  this.serverReceptionEntryPoints.push(serverReceptionEntryPoint);
18477
18479
 
18478
18480
  if(httpEndpointDefinition){
@@ -18498,7 +18500,11 @@ window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
18498
18500
  this.asyncDoOnIncomingMessage=asyncDoOnIncomingMessage;
18499
18501
  }
18500
18502
 
18501
- execute(eventOrMessage, clientSocketParam=null){
18503
+ async execute(eventOrMessage, clientSocketParam=null){
18504
+
18505
+ // DBG
18506
+ lognow("DEBUG : ServerReceptionEntryPoint.execute()");
18507
+
18502
18508
 
18503
18509
  if(!eventOrMessage){
18504
18510
  // TRACE
@@ -18517,9 +18523,9 @@ window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
18517
18523
 
18518
18524
  const dataWrapped=window.WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
18519
18525
 
18520
- // Channel information is stored in exchanged data :
18521
- if(dataWrapped.channelName!==this.channelName) return;
18522
-
18526
+ // Channel information is stored in wrapped exchanged data :
18527
+ if(!window.WebsocketImplementation.isInRightChannel(dataWrapped, this.channelName)) return;
18528
+
18523
18529
  // Room information is stored in client socket object :
18524
18530
  const isClientInRoom=window.WebsocketImplementation.isInRoom(clientSocketParam, this.clientsRoomsTag);
18525
18531
  if(!isClientInRoom) return;
@@ -18591,15 +18597,16 @@ window.NodeServerInstance=class NodeServerInstance{
18591
18597
  //sendChainable(channelNameParam, data, clientsRoomsTag=null){
18592
18598
  //}
18593
18599
 
18594
- // I- (NOT ASYNC)
18600
+ // I-
18601
+ // NOT ASYNC
18595
18602
  // DEPRECATED, USE THE NEW API INSTEAD :
18596
18603
  receive(channelNameParam, doOnIncomingMessage, listenerConfig=null, clientsRoomsTag=null){
18597
18604
 
18598
18605
  // DBG
18599
18606
  lognow("(SERVER) Registering receive (OLD API) for channel «"+channelNameParam+"»...");
18600
18607
 
18601
- const serverReceptionEntryPoint=new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig
18602
- ,doOnIncomingMessage);
18608
+ const serverReceptionEntryPoint=
18609
+ new window.ServerReceptionEntryPoint(channelNameParam, clientsRoomsTag, listenerConfig, doOnIncomingMessage);
18603
18610
  this.serverReceptionEntryPoints.push(serverReceptionEntryPoint);
18604
18611
 
18605
18612
  //OLD: // SPECIAL FOR THE SOCKETIO IMPLEMENTATION :
@@ -18757,7 +18764,9 @@ window.NodeServerInstance=class NodeServerInstance{
18757
18764
  // We execute the events registration listeners entry points:
18758
18765
  // DEPRECATED : OLD API :
18759
18766
  foreach(self.serverReceptionEntryPoints, (serverReceptionEntryPoint,i)=>{
18760
- serverReceptionEntryPoint.execute(eventOrMessage, clientSocket, true);
18767
+ serverReceptionEntryPoint.execute(eventOrMessage, clientSocket, true).then(()=>{
18768
+ /*DO NOTHING*/
18769
+ });
18761
18770
  });
18762
18771
 
18763
18772
  // NEW API :
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.2035",
3
+ "version": "0.0.2037",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "aotrautils",
9
- "version": "0.0.2035",
9
+ "version": "0.0.2037",
10
10
  "license": "HGPL-1.0",
11
11
  "dependencies": {
12
12
  "atob": "^2.1.2",
aotrautils/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.2035",
3
+ "version": "0.0.2037",
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)",