aotrautils 0.0.439 → 0.0.440
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 +121 -53
- 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 (23/01/2023-21:41:07)»*/
|
|
4
4
|
/*-----------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
6
|
|
|
@@ -2858,32 +2858,40 @@ window.contains=function(container, objectToFind,/*OPTIONAL*/useRegexp=false,sea
|
|
|
2858
2858
|
// console.log("WARN : Container is empty ! Cannot search for «"+objectToFind+"».");
|
|
2859
2859
|
return false;
|
|
2860
2860
|
}
|
|
2861
|
-
if(
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
if(
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2861
|
+
if(!isString(container) && objectToFind && isFunction(objectToFind)){
|
|
2862
|
+
return !!foreach(container, (item, keyOrIndex)=>{
|
|
2863
|
+
if(objectToFind(item, keyOrIndex)) return true;
|
|
2864
|
+
});
|
|
2865
|
+
}else{
|
|
2866
|
+
// Note : We also allow the search of null plain items in a container !
|
|
2867
|
+
|
|
2868
|
+
if(isArray(container)){
|
|
2869
|
+
// for (var i=0; i<container.length; i++){
|
|
2870
|
+
// if(container[i] === objectToFind) return true;
|
|
2871
|
+
// }
|
|
2872
|
+
// return false;
|
|
2873
|
+
return container.indexOf(objectToFind) >= 0;
|
|
2874
|
+
} else if((container instanceof Object) && (typeof container !== "string")){
|
|
2875
|
+
for (key in container){
|
|
2876
|
+
if(!container.hasOwnProperty(key)) continue;
|
|
2877
|
+
if(!searchInKeysOnly){
|
|
2878
|
+
if(container[key] === objectToFind)
|
|
2879
|
+
return true;
|
|
2880
|
+
}else{
|
|
2881
|
+
if(key === (typeof(objectToFind)!=="string"?(""+objectToFind):objectToFind)) // CAUTION : Associative arrays keys are always strings !
|
|
2882
|
+
return true;
|
|
2883
|
+
}
|
|
2876
2884
|
}
|
|
2885
|
+
return false;
|
|
2877
2886
|
}
|
|
2878
|
-
|
|
2887
|
+
|
|
2888
|
+
// Container is a string case :
|
|
2889
|
+
var str=container;
|
|
2890
|
+
var chunk=objectToFind;
|
|
2891
|
+
if(!useRegexp)
|
|
2892
|
+
return str.indexOf(chunk) !== -1;
|
|
2893
|
+
return new RegExp(chunk, "gm").test(str);
|
|
2879
2894
|
}
|
|
2880
|
-
|
|
2881
|
-
// Container is a string case :
|
|
2882
|
-
var str=container;
|
|
2883
|
-
var chunk=objectToFind;
|
|
2884
|
-
if(!useRegexp)
|
|
2885
|
-
return str.indexOf(chunk) !== -1;
|
|
2886
|
-
return new RegExp(chunk, "gm").test(str);
|
|
2887
2895
|
};
|
|
2888
2896
|
|
|
2889
2897
|
window.hasKey=function(container, keyToFind){
|
|
@@ -4856,7 +4864,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
|
|
|
4856
4864
|
|
|
4857
4865
|
|
|
4858
4866
|
|
|
4859
|
-
/*utils CLIENT library associated with aotra version : «1_29072022-2359 (
|
|
4867
|
+
/*utils CLIENT library associated with aotra version : «1_29072022-2359 (23/01/2023-21:41:07)»*/
|
|
4860
4868
|
/*-----------------------------------------------------------------------------*/
|
|
4861
4869
|
/* ## Utility global methods in a browser (htmljs) client environment.
|
|
4862
4870
|
*
|
|
@@ -12978,7 +12986,7 @@ createOritaMicroClient=function(url, port, isNode=false){
|
|
|
12978
12986
|
};
|
|
12979
12987
|
|
|
12980
12988
|
|
|
12981
|
-
/*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (
|
|
12989
|
+
/*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (23/01/2023-21:41:07)»*/
|
|
12982
12990
|
/*-----------------------------------------------------------------------------*/
|
|
12983
12991
|
|
|
12984
12992
|
|
|
@@ -14206,7 +14214,7 @@ function rayVsUnitSphereClosestPoint(p, r) {
|
|
|
14206
14214
|
// MUST REMAIN AT THE END OF THIS LIBRARY FILE !
|
|
14207
14215
|
|
|
14208
14216
|
AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
|
|
14209
|
-
/*utils SERVER library associated with aotra version : «1_29072022-2359 (
|
|
14217
|
+
/*utils SERVER library associated with aotra version : «1_29072022-2359 (23/01/2023-21:41:07)»*/
|
|
14210
14218
|
/*-----------------------------------------------------------------------------*/
|
|
14211
14219
|
|
|
14212
14220
|
|
|
@@ -14958,6 +14966,11 @@ WebsocketImplementation={
|
|
|
14958
14966
|
|
|
14959
14967
|
send:(channelNameParam, data, clientsRoomsTag=null)=>{
|
|
14960
14968
|
|
|
14969
|
+
// DBG
|
|
14970
|
+
lognow("(CLIENT) (NODEJS) CLIENT TRIES TO SEND !");
|
|
14971
|
+
|
|
14972
|
+
|
|
14973
|
+
|
|
14961
14974
|
const clientSocket=nodeClientInstance.clientSocket;
|
|
14962
14975
|
|
|
14963
14976
|
|
|
@@ -15012,7 +15025,7 @@ WebsocketImplementation={
|
|
|
15012
15025
|
nodeClientInstance.hasConnectEventFired=true;
|
|
15013
15026
|
|
|
15014
15027
|
// DBG
|
|
15015
|
-
lognow("DEBUG : CLIENT : doOnConnection !");
|
|
15028
|
+
lognow("DEBUG : CLIENT (NODEJS) : doOnConnection !");
|
|
15016
15029
|
|
|
15017
15030
|
const doOnMessage=(eventOrMessage)=>{
|
|
15018
15031
|
|
|
@@ -15029,7 +15042,6 @@ WebsocketImplementation={
|
|
|
15029
15042
|
|
|
15030
15043
|
doOnConnection(nodeClientInstance, clientSocket);
|
|
15031
15044
|
|
|
15032
|
-
|
|
15033
15045
|
};
|
|
15034
15046
|
|
|
15035
15047
|
|
|
@@ -15091,43 +15103,84 @@ WebsocketImplementation={
|
|
|
15091
15103
|
const browserInstance={
|
|
15092
15104
|
clientSocket:clientSocket,
|
|
15093
15105
|
|
|
15094
|
-
|
|
15106
|
+
receptionEntryPoints:[],
|
|
15107
|
+
|
|
15108
|
+
receive:(channelNameParam, doOnIncomingMessage, clientsRoomsTag=null, receptionEntryPointId=null)=>{
|
|
15109
|
+
|
|
15095
15110
|
|
|
15096
15111
|
// DBG
|
|
15097
15112
|
lognow("INFO : (CLIENT-BROWSER) SETTING UP RECEIVE for :",channelNameParam);
|
|
15113
|
+
|
|
15114
|
+
|
|
15115
|
+
const receptionEntryPoint={
|
|
15116
|
+
channelName:channelNameParam,
|
|
15117
|
+
clientsRoomsTag:clientsRoomsTag,
|
|
15118
|
+
// TODO : ADD TO ALL OTHER SUBSYSTEMS !
|
|
15119
|
+
id:receptionEntryPointId,
|
|
15120
|
+
|
|
15121
|
+
execute:(eventOrMessage)=>{
|
|
15122
|
+
|
|
15123
|
+
const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
|
|
15124
|
+
|
|
15125
|
+
// // DBG
|
|
15126
|
+
// lognow("(CLIENT) (DEBUG) CLIENT RECEIVED SOMETHING FROM SERVER :",dataWrapped);
|
|
15127
|
+
|
|
15128
|
+
// Channel information is stored in exchanged data :
|
|
15129
|
+
if(dataWrapped.channelName && dataWrapped.channelName!==channelNameParam) return;
|
|
15130
|
+
|
|
15131
|
+
const clientSocket=browserInstance.clientSocket;
|
|
15132
|
+
|
|
15133
|
+
// Room information is stored in client socket object :
|
|
15134
|
+
if(!WebsocketImplementation.isInRoom(clientSocket,clientsRoomsTag)) return;
|
|
15135
|
+
|
|
15136
|
+
if(doOnIncomingMessage) doOnIncomingMessage(dataWrapped.data, clientSocket);
|
|
15137
|
+
|
|
15138
|
+
|
|
15139
|
+
}
|
|
15140
|
+
};
|
|
15098
15141
|
|
|
15142
|
+
// TODO : ADD TO ALL OTHER SUBSYSTEMS !
|
|
15143
|
+
if(!contains(browserInstance.receptionEntryPoints,(l)=>(l.id && receptionEntryPoint.id && l.id===receptionEntryPoint.id)))
|
|
15144
|
+
browserInstance.receptionEntryPoints.push(receptionEntryPoint);
|
|
15099
15145
|
|
|
15100
|
-
|
|
15101
|
-
|
|
15102
|
-
|
|
15103
|
-
|
|
15104
|
-
|
|
15105
|
-
|
|
15106
|
-
|
|
15107
|
-
|
|
15108
|
-
// Channel information is stored in exchanged data :
|
|
15109
|
-
if(dataWrapped.channelName && dataWrapped.channelName!==channelNameParam) return;
|
|
15110
|
-
|
|
15111
|
-
const clientSocket=browserInstance.clientSocket;
|
|
15146
|
+
|
|
15147
|
+
return browserInstance;
|
|
15148
|
+
},
|
|
15149
|
+
|
|
15150
|
+
|
|
15151
|
+
|
|
15112
15152
|
|
|
15113
|
-
// Room information is stored in client socket object :
|
|
15114
|
-
if(!WebsocketImplementation.isInRoom(clientSocket, clientsRoomsTag)) return;
|
|
15115
15153
|
|
|
15116
|
-
doOnIncomingMessage(dataWrapped.data, clientSocket);
|
|
15117
|
-
|
|
15118
|
-
};
|
|
15119
|
-
|
|
15120
|
-
|
|
15121
|
-
if(!WebsocketImplementation.useSocketIOImplementation) browserInstance.clientSocket.addEventListener("message", doOnMessage);
|
|
15122
|
-
else browserInstance.clientSocket.on(channelNameParam, doOnMessage);
|
|
15123
15154
|
|
|
15155
|
+
|
|
15156
|
+
// CURRENT
|
|
15157
|
+
sendChainable:(channelNameParam, data, clientsRoomsTag=null)=>{
|
|
15124
15158
|
|
|
15125
|
-
|
|
15159
|
+
browserInstance.send(channelNameParam, data, clientsRoomsTag);
|
|
15160
|
+
|
|
15161
|
+
const resultPromise={
|
|
15162
|
+
clientsRoomsTag:clientsRoomsTag,
|
|
15163
|
+
thenWhenReceiveMessageType:(channelNameForResponse, messageTypeForResponse, doOnIncomingMessageForResponse)=>{
|
|
15164
|
+
const listenerId=messageTypeForResponse;
|
|
15165
|
+
browserInstance.receive(channelNameForResponse, doOnIncomingMessageForResponse, this.clientsRoomsTag, listenerId);
|
|
15166
|
+
return this;
|
|
15167
|
+
}
|
|
15168
|
+
};
|
|
15169
|
+
|
|
15170
|
+
|
|
15171
|
+
return resultPromise;
|
|
15126
15172
|
},
|
|
15127
15173
|
|
|
15128
15174
|
|
|
15175
|
+
|
|
15176
|
+
|
|
15177
|
+
|
|
15178
|
+
|
|
15129
15179
|
send:(channelNameParam, data, clientsRoomsTag=null)=>{
|
|
15130
15180
|
|
|
15181
|
+
// DBG
|
|
15182
|
+
lognow("(CLIENT) (BROWSER) CLIENT TRIES TO SEND !");
|
|
15183
|
+
|
|
15131
15184
|
const clientSocket=browserInstance.clientSocket;
|
|
15132
15185
|
|
|
15133
15186
|
|
|
@@ -15175,8 +15228,23 @@ WebsocketImplementation={
|
|
|
15175
15228
|
if(browserInstance.hasConnectEventFired) return;
|
|
15176
15229
|
browserInstance.hasConnectEventFired=true;
|
|
15177
15230
|
|
|
15178
|
-
|
|
15231
|
+
|
|
15232
|
+
|
|
15233
|
+
// DBG
|
|
15234
|
+
lognow("DEBUG : CLIENT (BROWSER) : doOnConnection !");
|
|
15235
|
+
|
|
15236
|
+
const doOnMessage=(eventOrMessage)=>{
|
|
15237
|
+
|
|
15238
|
+
// We execute the listeners entry points registration :
|
|
15239
|
+
foreach(browserInstance.receptionEntryPoints,(receptionEntryPoint)=>{
|
|
15240
|
+
receptionEntryPoint.execute(eventOrMessage);
|
|
15241
|
+
});
|
|
15179
15242
|
|
|
15243
|
+
};
|
|
15244
|
+
|
|
15245
|
+
const clientSocket=browserInstance.clientSocket;
|
|
15246
|
+
if(!WebsocketImplementation.useSocketIOImplementation) clientSocket.addEventListener("message", doOnMessage);
|
|
15247
|
+
else clientSocket.on(channelNameParam, doOnMessage);
|
|
15180
15248
|
|
|
15181
15249
|
doOnConnection(browserInstance, clientSocket);
|
|
15182
15250
|
|
aotrautils/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.440",
|
|
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)",
|