aotrautils 0.0.809 → 0.0.810
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.
- aotrautils/aotrautils.build.js +57 -18
- aotrautils/package.json +1 -1
aotrautils/aotrautils.build.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (
|
|
3
|
+
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (16/02/2024-00:55:27)»*/
|
|
4
4
|
/*-----------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
6
|
|
|
@@ -5167,7 +5167,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
|
|
|
5167
5167
|
|
|
5168
5168
|
|
|
5169
5169
|
|
|
5170
|
-
/*utils CLIENT library associated with aotra version : «1_29072022-2359 (
|
|
5170
|
+
/*utils CLIENT library associated with aotra version : «1_29072022-2359 (16/02/2024-00:55:27)»*/
|
|
5171
5171
|
/*-----------------------------------------------------------------------------*/
|
|
5172
5172
|
/* ## Utility global methods in a browser (htmljs) client environment.
|
|
5173
5173
|
*
|
|
@@ -13380,7 +13380,7 @@ createOritaMicroClient=function(url, port, isNode=false, staticMicroClientIdPara
|
|
|
13380
13380
|
|
|
13381
13381
|
|
|
13382
13382
|
|
|
13383
|
-
/*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (
|
|
13383
|
+
/*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (16/02/2024-00:55:27)»*/
|
|
13384
13384
|
/*-----------------------------------------------------------------------------*/
|
|
13385
13385
|
|
|
13386
13386
|
|
|
@@ -14619,7 +14619,7 @@ function rayVsUnitSphereClosestPoint(p, r) {
|
|
|
14619
14619
|
// MUST REMAIN AT THE END OF THIS LIBRARY FILE !
|
|
14620
14620
|
|
|
14621
14621
|
AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
|
|
14622
|
-
/*utils SERVER library associated with aotra version : «1_29072022-2359 (
|
|
14622
|
+
/*utils SERVER library associated with aotra version : «1_29072022-2359 (16/02/2024-00:55:27)»*/
|
|
14623
14623
|
/*-----------------------------------------------------------------------------*/
|
|
14624
14624
|
|
|
14625
14625
|
|
|
@@ -15766,7 +15766,7 @@ WebsocketImplementation={
|
|
|
15766
15766
|
|
|
15767
15767
|
|
|
15768
15768
|
|
|
15769
|
-
launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=null, /*OPTIONAL*/sslOptions=null, httpHandlerParam=null){
|
|
15769
|
+
launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=null, /*OPTIONAL*/sslOptions=null, httpHandlerParam=null, addCORSHeader=ADD_CORS_HEADER){
|
|
15770
15770
|
|
|
15771
15771
|
const EXCLUDED_FILENAMES_PARTS=[".keyHash."];
|
|
15772
15772
|
|
|
@@ -15817,7 +15817,7 @@ launchNodeHTTPServer=function(port, doOnConnect=null, doOnFinalizeServer=null, /
|
|
|
15817
15817
|
const headers={ "Content-Type": contentType };
|
|
15818
15818
|
|
|
15819
15819
|
// To remove the CORS error message (cf. https://medium.com/@dtkatz/3-ways-to-fix-the-cors-error-and-how-access-control-allow-origin-works-d97d55946d9)
|
|
15820
|
-
if(
|
|
15820
|
+
if(addCORSHeader) headers["Access-Control-Allow-Origin"]="*";
|
|
15821
15821
|
|
|
15822
15822
|
|
|
15823
15823
|
fs.readFile(filePath, function(error, fileContent){
|
|
@@ -16288,18 +16288,18 @@ class ListManager{
|
|
|
16288
16288
|
return getArraySize(this.itemsInfos);
|
|
16289
16289
|
}
|
|
16290
16290
|
|
|
16291
|
-
}
|
|
16291
|
+
};
|
|
16292
16292
|
|
|
16293
16293
|
getListManager=function(config){
|
|
16294
16294
|
return new ListManager(config);
|
|
16295
|
-
}
|
|
16295
|
+
};
|
|
16296
|
+
|
|
16296
16297
|
|
|
16297
16298
|
|
|
16298
16299
|
// NO : IN A NODE CONTEXT WITH requre("") WILL RESULT IN AN UNDEFINED FUNCTION ERROR !!!
|
|
16299
|
-
// function performHTTPRequestNode(
|
|
16300
|
+
// function performHTTPRequestNode(...){...
|
|
16300
16301
|
// USE THIS INSTEAD :
|
|
16301
|
-
performHTTPRequestNode=function(completeURL,httpMethod="GET",headers={},
|
|
16302
|
-
|
|
16302
|
+
performHTTPRequestNode=function(completeURL,httpMethod="GET",headers={},requestBodyOrNamedArgs=null,addCORSHeader=ADD_CORS_HEADER){
|
|
16303
16303
|
|
|
16304
16304
|
if(!require){
|
|
16305
16305
|
// TODO : FIXME : Support also a browser context!!
|
|
@@ -16307,7 +16307,7 @@ performHTTPRequestNode=function(completeURL,httpMethod="GET",headers={},postRequ
|
|
|
16307
16307
|
throw new Error("Unsupported context non-nodejs for performHTTPRequestNode().");
|
|
16308
16308
|
}
|
|
16309
16309
|
|
|
16310
|
-
const isSecure=completeURL.
|
|
16310
|
+
const isSecure=(!empty(completeURL) && contains(completeURL.toLowerCase(),"https://"));
|
|
16311
16311
|
const httpHandler = isSecure?require("https"):require("http");
|
|
16312
16312
|
|
|
16313
16313
|
// Options for the HTTP request
|
|
@@ -16320,9 +16320,19 @@ performHTTPRequestNode=function(completeURL,httpMethod="GET",headers={},postRequ
|
|
|
16320
16320
|
options.json=true;
|
|
16321
16321
|
headers["Content-Type"]="application/json";
|
|
16322
16322
|
// To remove the CORS error message (cf. https://medium.com/@dtkatz/3-ways-to-fix-the-cors-error-and-how-access-control-allow-origin-works-d97d55946d9)
|
|
16323
|
-
if(
|
|
16323
|
+
if(addCORSHeader) headers["Access-Control-Allow-Origin"]="*";
|
|
16324
|
+
} else if(httpMethod==="GET" && requestBodyOrNamedArgs){
|
|
16325
|
+
// Not the same way to send parameters in GET http method :
|
|
16326
|
+
// DBG
|
|
16327
|
+
lognow("unformatted API URL : "+completeURL);
|
|
16328
|
+
|
|
16329
|
+
completeURL=appendGetParameters(completeURL, requestBodyOrNamedArgs);
|
|
16330
|
+
|
|
16331
|
+
// DBG
|
|
16332
|
+
lognow("formatted API URL : "+completeURL);
|
|
16324
16333
|
}
|
|
16325
16334
|
|
|
16335
|
+
|
|
16326
16336
|
options.headers=headers;
|
|
16327
16337
|
|
|
16328
16338
|
return new Promise((resolve,reject)=>{
|
|
@@ -16341,8 +16351,17 @@ performHTTPRequestNode=function(completeURL,httpMethod="GET",headers={},postRequ
|
|
|
16341
16351
|
|
|
16342
16352
|
// The whole response has been received.
|
|
16343
16353
|
response.on("end", () => {
|
|
16344
|
-
|
|
16345
|
-
|
|
16354
|
+
|
|
16355
|
+
try{
|
|
16356
|
+
const responseData=parseJSON(responseDataStr);
|
|
16357
|
+
resolve(responseData, response, responseDataStr);
|
|
16358
|
+
}catch(error){
|
|
16359
|
+
// DBG
|
|
16360
|
+
lognow("WARN : Could not JSON parse the response data ! Must deal with the string:«"+responseDataStr+"»", error);
|
|
16361
|
+
resolve(responseDataStr, response, responseDataStr);
|
|
16362
|
+
return;
|
|
16363
|
+
}
|
|
16364
|
+
|
|
16346
16365
|
});
|
|
16347
16366
|
});
|
|
16348
16367
|
|
|
@@ -16355,8 +16374,8 @@ performHTTPRequestNode=function(completeURL,httpMethod="GET",headers={},postRequ
|
|
|
16355
16374
|
// Not the same way to send parameters in POST http method :
|
|
16356
16375
|
if(contains(["POST","PUT"],httpMethod)){
|
|
16357
16376
|
// (We need to stringify parameters or else we'll have an error :)
|
|
16358
|
-
if(!empty(
|
|
16359
|
-
request.write(stringifyObject(
|
|
16377
|
+
if(!empty(requestBodyOrNamedArgs)){
|
|
16378
|
+
request.write(stringifyObject(requestBodyOrNamedArgs));
|
|
16360
16379
|
}
|
|
16361
16380
|
}
|
|
16362
16381
|
|
|
@@ -16365,11 +16384,31 @@ performHTTPRequestNode=function(completeURL,httpMethod="GET",headers={},postRequ
|
|
|
16365
16384
|
|
|
16366
16385
|
});
|
|
16367
16386
|
|
|
16368
|
-
}
|
|
16387
|
+
};
|
|
16369
16388
|
|
|
16370
16389
|
|
|
16371
16390
|
|
|
16372
16391
|
|
|
16392
|
+
replacePathVariablesNamesWithValuesIfPossible=function(apiURL, namedArgs){
|
|
16393
|
+
let result=apiURL;
|
|
16394
|
+
foreach(namedArgs,(namedArgValue, namedArgKey)=>{
|
|
16395
|
+
result=result.replace("{"+namedArgKey+"}",namedArgValue);
|
|
16396
|
+
});
|
|
16397
|
+
return result;
|
|
16398
|
+
};
|
|
16399
|
+
|
|
16400
|
+
appendGetParameters=function(apiURL, namedArgs){
|
|
16401
|
+
let result=apiURL;
|
|
16402
|
+
|
|
16403
|
+
const paramCouples=[];
|
|
16404
|
+
foreach(namedArgs,(value,key)=>{paramCouples.push(key+"="+value);});
|
|
16405
|
+
|
|
16406
|
+
if(!empty(paramCouples)) result+=("?"+paramCouples.join("&"));
|
|
16407
|
+
|
|
16408
|
+
return result;
|
|
16409
|
+
};
|
|
16410
|
+
|
|
16411
|
+
|
|
16373
16412
|
/* INCLUDED EXTERNAL LIBRAIRIES
|
|
16374
16413
|
*/
|
|
16375
16414
|
"use strict";var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}};
|
aotrautils/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.810",
|
|
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)",
|