aotrautils 0.0.783 → 0.0.785
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 +68 -4
- 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 (13/02/2024-23:56:28)»*/
|
|
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 (13/02/2024-23:56:28)»*/
|
|
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 (13/02/2024-23:56:28)»*/
|
|
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 (13/02/2024-23:56:28)»*/
|
|
14623
14623
|
/*-----------------------------------------------------------------------------*/
|
|
14624
14624
|
|
|
14625
14625
|
|
|
@@ -16295,7 +16295,71 @@ getListManager=function(config){
|
|
|
16295
16295
|
}
|
|
16296
16296
|
|
|
16297
16297
|
|
|
16298
|
+
function performHTTPRequestNode(url,httpMethod="GET",headers={},postRequestBodyOrNamedArgs=null){
|
|
16299
|
+
|
|
16300
|
+
|
|
16301
|
+
if(!require){
|
|
16302
|
+
// TODO : FIXME : Support also a browser context!!
|
|
16303
|
+
lognow("ERROR : 'require()' not found, this may need we are not running in a nodejs context. This is currently not supported. Aborting");
|
|
16304
|
+
throw new Error("Unsupported context non-nodejs for performHTTPRequestNode().");
|
|
16305
|
+
}
|
|
16306
|
+
|
|
16307
|
+
const isSecure=completeURL.includes("https://");
|
|
16308
|
+
const httpHandler = isSecure?require("https"):require("http");
|
|
16309
|
+
|
|
16310
|
+
// Options for the HTTP request
|
|
16311
|
+
const options = {
|
|
16312
|
+
url: completeURL,
|
|
16313
|
+
method: httpMethod,
|
|
16314
|
+
};
|
|
16315
|
+
|
|
16316
|
+
if(contains(["POST","PUT"],httpMethod)){
|
|
16317
|
+
options.json=true;
|
|
16318
|
+
headers["Content-Type"]="application/json";
|
|
16319
|
+
// 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)
|
|
16320
|
+
if(ADD_CORS_HEADER) headers["Access-Control-Allow-Origin"]="*";
|
|
16321
|
+
}
|
|
16322
|
+
|
|
16323
|
+
options.headers=headers;
|
|
16324
|
+
|
|
16325
|
+
return new Promise((accept,resolve)=>{
|
|
16326
|
+
|
|
16327
|
+
// Create the HTTP request
|
|
16328
|
+
const request = httpHandler.request(options, (response) => {
|
|
16329
|
+
|
|
16330
|
+
let responseData = "";
|
|
16298
16331
|
|
|
16332
|
+
// A chunk of data has been received.
|
|
16333
|
+
response.on('data', (chunk) => {
|
|
16334
|
+
responseData += chunk;
|
|
16335
|
+
});
|
|
16336
|
+
|
|
16337
|
+
// The whole response has been received.
|
|
16338
|
+
response.on('end', () => {
|
|
16339
|
+
resolve(responseData);
|
|
16340
|
+
});
|
|
16341
|
+
});
|
|
16342
|
+
|
|
16343
|
+
// Handle errors
|
|
16344
|
+
request.on('error', (error) => {
|
|
16345
|
+
reject(error);
|
|
16346
|
+
});
|
|
16347
|
+
|
|
16348
|
+
|
|
16349
|
+
// Not the same way to send parameters in POST http method :
|
|
16350
|
+
if(contains(["POST","PUT"],httpMethod)){
|
|
16351
|
+
// (We need to stringify parameters or else we'll have an error :)
|
|
16352
|
+
if(!empty(postRequestBodyOrNamedArgs)){
|
|
16353
|
+
request.write(stringifyObject(postRequestBodyOrNamedArgs));
|
|
16354
|
+
}
|
|
16355
|
+
}
|
|
16356
|
+
|
|
16357
|
+
// End the request
|
|
16358
|
+
request.end();
|
|
16359
|
+
|
|
16360
|
+
});
|
|
16361
|
+
|
|
16362
|
+
}
|
|
16299
16363
|
|
|
16300
16364
|
|
|
16301
16365
|
|
aotrautils/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.785",
|
|
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)",
|