aotrautils 0.0.1931 → 0.0.1933

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 (26/07/2026-17:25:00)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (02/08/2026-00:10:30)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -5195,7 +5195,7 @@ window.getPathFileName=(path, fileSeparator="/", removeExtension=false)=>{
5195
5195
  // ======================== Timeout ========================
5196
5196
 
5197
5197
  // CAUTION : This is not a routine, but a single-use timeout !
5198
- window.MonoThreadedTimeout=class {
5198
+ window.MonoThreadedTimeout=class MonoThreadedTimeout{
5199
5199
  constructor(actuator, delayMillis){
5200
5200
  this.actuator=actuator;
5201
5201
  }
@@ -5309,7 +5309,7 @@ window.getMonoThreadedRoutine=function(actuator, refreshMillis=null, startDepend
5309
5309
  }
5310
5310
 
5311
5311
 
5312
- window.MonoThreadedGoToGoal=class {
5312
+ window.MonoThreadedGoToGoal=class MonoThreadedGoToGoal{
5313
5313
  constructor(actuator,actualValue,goalValue,refreshMillis=null,totalTimeMillis=1000,mode="linear"){
5314
5314
 
5315
5315
  this.actuator=actuator;
@@ -5470,7 +5470,7 @@ window.AOTRAUTILS_LIB_IS_LOADED=true;
5470
5470
 
5471
5471
 
5472
5472
 
5473
- /*utils CLIENT library associated with aotra version : «1_29072022-2359 (26/07/2026-17:25:00)»*/
5473
+ /*utils CLIENT library associated with aotra version : «1_29072022-2359 (02/08/2026-00:10:30)»*/
5474
5474
  /*-----------------------------------------------------------------------------*/
5475
5475
  /* ## Utility global methods in a browser (htmljs) client environment.
5476
5476
  *
@@ -8982,7 +8982,7 @@ window.playAudioData=function(audioData,audioCtxParam=null,audioBufferSizeParam=
8982
8982
  }
8983
8983
 
8984
8984
 
8985
- window.SoundsLoop=class {
8985
+ window.SoundsLoop=class SoundsLoop{
8986
8986
  constructor(doOnEnded=null){
8987
8987
 
8988
8988
  this.doOnEnded=doOnEnded;
@@ -9097,7 +9097,7 @@ window.loadSoundsLoop=function(filesPaths,doOnLoaded=null,doOnEnded=null){
9097
9097
 
9098
9098
  const SOUND_FADE_REFRESH_MILLIS=500;
9099
9099
 
9100
- window.Sound=class{
9100
+ window.Sound=class Sound{
9101
9101
  constructor(filePath,doOnEnded=null){
9102
9102
 
9103
9103
  this.doOnEnded=doOnEnded;
@@ -9440,7 +9440,7 @@ window.drawImageAndCenterWithZooms=function(ctx,image,xParam=0,yParam=0,zooms={z
9440
9440
  // ====================================================== SPRITES ======================================================
9441
9441
 
9442
9442
 
9443
- window.SpriteMonoThreaded=class{
9443
+ window.SpriteMonoThreaded=class SpriteMonoThreaded{
9444
9444
 
9445
9445
  constructor(imagesPool,/*OPTIONAL*/refreshMillis=null,
9446
9446
  clipSize={w:100,h:100},scaleFactorW=1,scaleFactorH=1,
@@ -11450,7 +11450,7 @@ window.getPointsFromSVGDString=function(str){
11450
11450
 
11451
11451
  // ========================= FUSRODA CLIENT : =========================
11452
11452
 
11453
- window.VNCFrame2D=class{
11453
+ window.VNCFrame2D=class VNCFrame2D{
11454
11454
 
11455
11455
  constructor(url, port=4000, htmlConfig={parentElement:null,imageMode:"CSSBackground"}, mouseEventsRefreshMillis=100){
11456
11456
 
@@ -12985,7 +12985,7 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
12985
12985
 
12986
12986
 
12987
12987
 
12988
- /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (26/07/2026-17:25:00)»*/
12988
+ /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (02/08/2026-00:10:30)»*/
12989
12989
  /*-----------------------------------------------------------------------------*/
12990
12990
 
12991
12991
 
@@ -14047,10 +14047,10 @@ function rayVsUnitSphereClosestPoint(p, r) {
14047
14047
  // MUST REMAIN AT THE END OF THIS LIBRARY FILE !
14048
14048
 
14049
14049
  window.AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
14050
- /*utils 3D library associated with aotra version : «1_29072022-2359 (26/07/2026-17:25:00)»*/
14050
+ /*utils 3D library associated with aotra version : «1_29072022-2359 (02/08/2026-00:10:30)»*/
14051
14051
  /*-----------------------------------------------------------------------------*/
14052
14052
 
14053
- /*utils AI library associated with aotra version : «1_29072022-2359 (26/07/2026-17:25:00)»*/
14053
+ /*utils AI library associated with aotra version : «1_29072022-2359 (02/08/2026-00:10:30)»*/
14054
14054
  /*-----------------------------------------------------------------------------*/
14055
14055
 
14056
14056
 
@@ -14153,7 +14153,7 @@ window.LLMAPIClient=class LLMAPIClient{
14153
14153
  const parameters=getAPIRequestParameters(messages);
14154
14154
 
14155
14155
  return new Promise((resolve,reject)=>{
14156
- window.performHTTPRequest(this.apiURL, "POST", headers, parameters, true).then((responseObj)=>{
14156
+ performHTTPRequest(this.apiURL, "POST", headers, parameters, true).then((responseObj)=>{
14157
14157
  const responseData=responseObj.responseData;
14158
14158
  const data=responseData;
14159
14159
 
@@ -14310,7 +14310,7 @@ window.getLLMAPIClient=(modelName, apiURL, agentRole, defaultPrompt, llmProvider
14310
14310
 
14311
14311
 
14312
14312
 
14313
- /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (26/07/2026-17:25:00)»*/
14313
+ /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (02/08/2026-00:10:30)»*/
14314
14314
  /*-----------------------------------------------------------------------------*/
14315
14315
 
14316
14316
 
@@ -14351,7 +14351,7 @@ if(typeof(window)==="undefined") window=global;
14351
14351
 
14352
14352
  // New implementation :
14353
14353
 
14354
- window.AORTACClientCell=class{
14354
+ window.AORTACClientCell=class AORTACClientCell{
14355
14355
 
14356
14356
  constructor(serverCellOrigin, model, view, isNodeContext=true){
14357
14357
 
@@ -14722,7 +14722,7 @@ window.AORTAC_OUTCOMING_SERVERS_CONNECTION_GLOBAL_TIMEOUT=30000;
14722
14722
  window.AORTAC_SERVER_CELL_PERIODICAL_CONNECTIVITY_CHECK_MILLIS=2000;
14723
14723
 
14724
14724
 
14725
- window.AORTACServerCell=class{
14725
+ window.AORTACServerCell=class AORTACServerCell{
14726
14726
 
14727
14727
  constructor(quorumNumber=1, selfOrigin, outcomingCellsOrigins, model, controller, sslConfig={/*OPTIONAL*/certPath:null,/*OPTIONAL*/keyPath:null}){
14728
14728
 
@@ -16308,7 +16308,7 @@ window.crypto=require("node:crypto");
16308
16308
 
16309
16309
  const FILE_ENCODING="utf8";
16310
16310
 
16311
- const ADD_CORS_HEADER=true;
16311
+ const ADD_CORS_HEADER_BY_DEFAULT=true;
16312
16312
 
16313
16313
 
16314
16314
  // DEBUG
@@ -16320,99 +16320,122 @@ if(typeof(require)!=="undefined" && typeof(window.fs)==="undefined" ){
16320
16320
  }
16321
16321
 
16322
16322
 
16323
- // Nodejs filesystem utils :
16324
- if(typeof(window.fs)==="undefined"){
16325
- // TRACE
16326
- console.log("WARN : Could not find the nodejs dependency «fs», aborting persister setup.");
16327
- window.getPersister=()=>{ return null; };
16328
-
16329
- }else{
16330
-
16323
+
16324
+ window.Persister=class Persister{
16331
16325
 
16332
- window.getPersister=function(dataDirPath,prefix=""){
16326
+ constructor(dataDirPath="./", prefix="", createDirectoryIfNotExists=false){
16327
+ this.dataDirPath=dataDirPath;
16328
+ this.prefix=prefix;
16329
+ this.createDirectoryIfNotExists=createDirectoryIfNotExists;
16333
16330
 
16334
- let self={
16331
+ }
16332
+
16333
+ //FILE_NAME_PATTERN:"data.clientId.repositoryName.json",
16334
+ /*private*/getPath(clientId="noclient", repositoryName="norepository"){
16335
16335
 
16336
- dataDirPath:dataDirPath,
16337
- prefix:prefix,
16338
-
16339
- //FILE_NAME_PATTERN:"data.clientId.repositoryName.json",
16340
- /*private*/getPath:function(clientId="noclient", repositoryName="norepository"){
16341
- // let path=self.FILE_NAME_PATTERN.replace(new RegExp("@clientId@","g"),clientId);
16342
- let path=`${self.dataDirPath}`
16343
- + (blank(self.prefix)?"":(self.prefix+"."))
16344
- +`${clientId}.${repositoryName}.json`;
16345
- return path;
16346
- },
16347
-
16348
- readTreeObjectFromFile:function(clientId="noclient", repositoryName="norepository", keepClassName=false){
16349
-
16350
- let path=self.getPath(clientId,repositoryName);
16351
- let resultFlat=null;
16336
+ const self=this;
16352
16337
 
16353
- try{
16338
+ // let path=self.FILE_NAME_PATTERN.replace(new RegExp("@clientId@","g"),clientId);
16339
+ let path=`${self.dataDirPath}`
16340
+ + (blank(self.prefix)?"":(self.prefix+"."))
16341
+ +`${clientId}.${repositoryName}.json`;
16342
+ return path;
16343
+ }
16354
16344
 
16355
- resultFlat=window.fs.readFileSync(path, FILE_ENCODING);
16356
-
16357
- }catch(error){
16358
- // TRACE
16359
- console.log("ERROR : Could not read file «"+path+"».");
16345
+ /*private*/createDirectoryIfNecessary(path){
16346
+ if(!fileExists(path) && this.createDirectoryIfNotExists){
16347
+ // TRACE
16348
+ lognow(`WARN : Directory «${path}» does not exist. We will create it.`);
16349
+ createDirectory(path);
16350
+ }
16351
+ }
16352
+
16353
+ readTreeObjectFromFile(clientId="noclient", repositoryName="norepository", keepClassName=false){
16354
+ const self=this;
16355
+
16356
+ let resultFlat=null;
16357
+ let path=self.getPath(clientId, repositoryName);
16358
+ this.createDirectoryIfNecessary(path);
16360
16359
 
16361
- return null;
16362
- }
16363
-
16364
-
16365
- let resultData={};
16366
-
16367
- // 1)
16368
- if(!empty(resultFlat)) resultData=parseJSON(resultFlat);
16369
-
16370
- // 2)
16371
- if(!empty(resultData) && isFlatMap(resultData)){
16372
- // CAUTION : We have to keep the type information, here too ! (in the sub-objects)
16373
- resultData=getAsTreeStructure(resultData, keepClassName);
16374
- }
16375
-
16376
- return resultData;
16377
- },
16360
+
16361
+ try{
16378
16362
 
16363
+ resultFlat=window.fs.readFileSync(path, FILE_ENCODING);
16379
16364
 
16380
- saveDataToFileForClient:function(clientId,repositoryName,dataFlatForClient,forceKeepUnflatten=false,doOnSuccess=null){
16381
-
16382
- if(!empty(dataFlatForClient) && !isFlatMap(dataFlatForClient) && !forceKeepUnflatten){
16383
- dataFlatForClient=getAsFlatStructure(dataFlatForClient);
16384
- }
16385
-
16386
- // reserved characters : -/\^$*+?.()|[]{}
16387
- // CANNOT USE stringifyObject(...) function because we are in a common, lower-level library !
16388
- let dataFlatStr=stringifyObject(dataFlatForClient)
16389
- // We «aerate» the produced JSON :
16390
- .replace(/":[\w]*\{/gim,"\":{\n").replace(/,"/gim,",\n\"")
16391
- // ...except for inline, escaped JSON string representations :
16392
- .replace(/\\\":[\w]*\{\n/gim,"\\\":{");
16393
- // NO : .replace(/}/gim,"}\n");
16394
-
16395
-
16396
- let path=self.getPath(clientId,repositoryName);
16397
- window.fs.writeFile(path, dataFlatStr, FILE_ENCODING, (error) => {
16398
- if(error){
16399
- // TRACE
16400
- console.log("ERROR : Could not write file «"+path+"»:",error);
16401
- throw error;
16402
- }
16403
- if(doOnSuccess) doOnSuccess(dataFlatForClient);
16404
- });
16405
- }
16406
-
16407
- };
16365
+ }catch(error){
16366
+ // TRACE
16367
+ console.log("ERROR : Could not read file «"+path+"».");
16368
+
16369
+ return null;
16370
+ }
16408
16371
 
16409
16372
 
16410
- return self;
16411
- };
16373
+ let resultData={};
16374
+
16375
+ // 1)
16376
+ if(!empty(resultFlat)) resultData=parseJSON(resultFlat);
16377
+
16378
+ // 2)
16379
+ if(!empty(resultData) && isFlatMap(resultData)){
16380
+ // CAUTION : We have to keep the type information, here too ! (in the sub-objects)
16381
+ resultData=getAsTreeStructure(resultData, keepClassName);
16382
+ }
16383
+
16384
+ return resultData;
16385
+ }
16386
+
16412
16387
 
16388
+ saveDataToFileForClient(clientId, repositoryName, dataFlatForClient, forceKeepUnflatten=false, doOnSuccess=null){
16389
+ const self=this;
16390
+
16391
+ if(!empty(dataFlatForClient) && !isFlatMap(dataFlatForClient) && !forceKeepUnflatten){
16392
+ dataFlatForClient=getAsFlatStructure(dataFlatForClient);
16393
+ }
16394
+
16395
+ // reserved characters : -/\^$*+?.()|[]{}
16396
+ // CANNOT USE stringifyObject(...) function because we are in a common, lower-level library !
16397
+ let dataFlatStr=stringifyObject(dataFlatForClient)
16398
+ // We «aerate» the produced JSON :
16399
+ .replace(/":[\w]*\{/gim,"\":{\n").replace(/,"/gim,",\n\"")
16400
+ // ...except for inline, escaped JSON string representations :
16401
+ .replace(/\\\":[\w]*\{\n/gim,"\\\":{");
16402
+ // NO : .replace(/}/gim,"}\n");
16403
+
16404
+
16405
+ let path=self.getPath(clientId, repositoryName);
16406
+ this.createDirectoryIfNecessary(path);
16407
+
16408
+ window.fs.writeFile(path, dataFlatStr, FILE_ENCODING, (error) => {
16409
+ if(error){
16410
+ // TRACE
16411
+ console.log("ERROR : Could not write file «"+path+"»:",error);
16412
+ throw error;
16413
+ }
16414
+ if(doOnSuccess) doOnSuccess(dataFlatForClient);
16415
+ });
16416
+ }
16417
+
16418
+
16413
16419
  }
16414
16420
 
16415
16421
 
16422
+
16423
+
16424
+
16425
+
16426
+
16427
+ // Nodejs filesystem utils :
16428
+ if(typeof(window.fs)==="undefined"){
16429
+ // TRACE
16430
+ console.log("WARN : Could not find the nodejs dependency «fs», aborting persister setup.");
16431
+ window.getPersister=()=>{ return null; };
16432
+ }else{
16433
+ window.getPersister=function(dataDirPath, prefix="", createDirectoryIfNotExists=false){
16434
+ return new Persister(dataDirPath, prefix, createDirectoryIfNotExists);
16435
+ };
16436
+ }
16437
+
16438
+ // Also handles directories !
16416
16439
  window.fileExists=(filePath)=>{
16417
16440
  if(typeof(window.fs)=="undefined"){
16418
16441
  // TRACE
@@ -16422,7 +16445,18 @@ window.fileExists=(filePath)=>{
16422
16445
  return window.fs.existsSync(filePath);
16423
16446
  };
16424
16447
 
16425
-
16448
+ window.createDirectory=(dirPath)=>{
16449
+ if(typeof(window.fs)=="undefined"){
16450
+ // TRACE
16451
+ lognow("ERROR : «fs» node dependency is not available ! Cannot create directory at path «"+dirPath+"».");
16452
+ return;
16453
+ }
16454
+ try {
16455
+ fs.mkdirSync(dirPath, { recursive: true });
16456
+ } catch (err) {
16457
+ console.error("Error creating directory:", err);
16458
+ }
16459
+ }
16426
16460
 
16427
16461
  // Nodejs server launching helper functions :
16428
16462
  //Networking management :
@@ -16870,7 +16904,8 @@ window.WebsocketImplementation={
16870
16904
  };
16871
16905
 
16872
16906
 
16873
- window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=null, doOnConnectionLost=null, /*OPTIONAL*/sslOptions=null, httpHandlerParam=null, addCORSHeader=ADD_CORS_HEADER){
16907
+ window.launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=null, doOnConnectionLost=null, /*OPTIONAL*/sslOptions=null, httpHandlerParam=null,
16908
+ addCORSHeader=ADD_CORS_HEADER_BY_DEFAULT){
16874
16909
 
16875
16910
  const EXCLUDED_FILENAMES_PARTS=[".keyHash.",".pem"];
16876
16911
 
@@ -17216,7 +17251,7 @@ window.initNodeServerInfrastructureWrapper=function(doOnClientConnection=null, d
17216
17251
 
17217
17252
  // ========================= UTILITY SERVERSIDE METHODS : =========================
17218
17253
 
17219
- window.ListManager=class{
17254
+ window.ListManager=class ListManager{
17220
17255
 
17221
17256
  constructor(config){
17222
17257
  this.config=config;
@@ -17386,7 +17421,9 @@ window.getListManager=function(config){
17386
17421
  // NO : IN A NODE CONTEXT WITH require("...") WILL RESULT IN AN UNDEFINED FUNCTION ERROR !!!
17387
17422
  // function performHTTPRequest(...){...
17388
17423
  // USE THIS INSTEAD :
17389
- window.performHTTPRequest=function(completeURL, httpMethod="GET", headers={}, requestBodyOrNamedArgs=null, isNodeContext=false, addCORSHeader=ADD_CORS_HEADER){
17424
+ window.performHTTPRequest=function(completeURL, httpMethod="GET", headers={}, requestBodyOrNamedArgs=null, isNodeContext=false,
17425
+ addCORSHeader=ADD_CORS_HEADER_BY_DEFAULT,
17426
+ allowSelfSignedCerts=false/*RECOMMENDED VALUE, TRY NOT TO SET IT TO «true» !!!*/){
17390
17427
 
17391
17428
  // Body
17392
17429
  let requestBodyOrNamedArgsStr=null;
@@ -17436,12 +17473,19 @@ window.performHTTPRequest=function(completeURL, httpMethod="GET", headers={}, re
17436
17473
  // TRACE
17437
17474
  lognow("INFO : We are not running in a browser context (isNodeContext:"+isNodeContext+";typeof(require):"+(typeof(require))+"). Using browser library.");
17438
17475
 
17476
+ const options={
17477
+ method: httpMethod,
17478
+ headers: headers,
17479
+ body: body,
17480
+ };
17481
+
17482
+
17483
+ if(allowSelfSignedCerts)
17484
+ options.rejectUnauthorized=true;
17485
+
17486
+
17439
17487
  return new Promise((resolve,reject)=>{
17440
- fetch(completeURL, {
17441
- method: httpMethod,
17442
- headers: headers,
17443
- body: body,
17444
- })
17488
+ fetch(completeURL, options)
17445
17489
  // STRANGE : DOES NOT WORK !!:
17446
17490
  //.then(response => response.json())
17447
17491
  // STRANGE : DOES WORK :
@@ -17497,7 +17541,12 @@ window.performHTTPRequest=function(completeURL, httpMethod="GET", headers={}, re
17497
17541
  }
17498
17542
 
17499
17543
  options.headers=headers;
17500
-
17544
+
17545
+
17546
+ if(allowSelfSignedCerts)
17547
+ options.rejectUnauthorized=true;
17548
+
17549
+
17501
17550
  return new Promise((resolve,reject)=>{
17502
17551
 
17503
17552
  // Create the HTTP request
@@ -17777,7 +17826,7 @@ window.initClient=function(isNodeContext=true
17777
17826
 
17778
17827
 
17779
17828
 
17780
- window.ClientReceptionEntryPoint=class{
17829
+ window.ClientReceptionEntryPoint=class ClientReceptionEntryPoint{
17781
17830
 
17782
17831
  constructor(channelNameParam, entryPointId, clientsRoomsTag, listenerConfig, doOnIncomingMessage){
17783
17832
  this.channelName=channelNameParam;
@@ -17856,7 +17905,7 @@ window.ClientReceptionEntryPoint=class{
17856
17905
  //
17857
17906
  // CLIENT INSTANCE :
17858
17907
  //
17859
- window.ClientInstance=class{
17908
+ window.ClientInstance=class ClientInstance{
17860
17909
 
17861
17910
  constructor(clientSocket){
17862
17911
 
@@ -18064,7 +18113,7 @@ window.ClientInstance=class{
18064
18113
 
18065
18114
  // ==================================================================================================================
18066
18115
 
18067
- window.ServerReceptionEntryPoint=class{
18116
+ window.ServerReceptionEntryPoint=class ServerReceptionEntryPoint{
18068
18117
 
18069
18118
  constructor(channelNameParam, clientsRoomsTag, listenerConfig=null, doOnIncomingMessage){
18070
18119
  this.channelName=channelNameParam;
@@ -18126,7 +18175,7 @@ window.ServerReceptionEntryPoint=class{
18126
18175
 
18127
18176
 
18128
18177
 
18129
- window.NodeServerInstance=class{
18178
+ window.NodeServerInstance=class NodeServerInstance{
18130
18179
 
18131
18180
  constructor(serverSocket, listenableServer){
18132
18181
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.1931",
3
+ "version": "0.0.1933",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "aotrautils",
9
- "version": "0.0.1931",
9
+ "version": "0.0.1933",
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.1931",
3
+ "version": "0.0.1933",
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)",