aotrautils 0.0.1838 → 0.0.1840
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 +304 -319
- 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 (05/04/2026-
|
|
3
|
+
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (05/04/2026-12:42:00)»*/
|
|
4
4
|
/*-----------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
6
|
|
|
@@ -4116,72 +4116,53 @@ window.instanciate=function(className=null){
|
|
|
4116
4116
|
// If class name is a simple array, a simple «[]» is enough :
|
|
4117
4117
|
if(className==="Array") return [];
|
|
4118
4118
|
|
|
4119
|
+
|
|
4119
4120
|
const classInWindow=window[className];
|
|
4120
|
-
|
|
4121
4121
|
if(!classInWindow){
|
|
4122
4122
|
// TRACE
|
|
4123
4123
|
lognow(`WARN : CAUTION : «${className}» class does not seem to be registered in the global window object. This can lead to problems instanciating it in a pure nodejs context.`);
|
|
4124
4124
|
}
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
try{
|
|
4128
|
-
try{
|
|
4129
|
-
newObj=Reflect.construct(classInWindow);
|
|
4130
|
-
}catch(e1){
|
|
4131
|
-
|
|
4132
|
-
// // TRACE
|
|
4133
|
-
// console.log("WARN : Could not instanciate class «"+className+"». (Maybe class is undefined or default constructor doesn't exist !)");
|
|
4134
|
-
|
|
4135
|
-
// TODO : FIXME : I don't like that at all, to use eval(...), but on today I know of no other solution... :
|
|
4136
|
-
newObj=eval("new "+className+"();");
|
|
4137
|
-
|
|
4138
|
-
}
|
|
4139
|
-
}catch(e2){
|
|
4140
|
-
|
|
4141
|
-
// // TRACE
|
|
4142
|
-
// console.log("ERROR : Could not instanciate class «"+className+"» with eval. (Maybe class is undefined or default constructor doesn't exist !)");
|
|
4143
|
-
|
|
4144
|
-
try{
|
|
4145
4125
|
|
|
4146
|
-
// // TODO : FIXME : I don't like that at all, to use eval(...), but on today I know of no other solution... :
|
|
4147
|
-
// newObj=eval("new window."+className+"();");
|
|
4148
|
-
|
|
4149
|
-
newObj=Reflect.construct(classInWindow);
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
}catch(e3){
|
|
4153
|
-
|
|
4154
|
-
// // TRACE
|
|
4155
|
-
// console.log("ERROR : Could not instanciate class «"+className+"» with eval and «window.». (Maybe class is undefined or default constructor doesn't exist !)");
|
|
4156
|
-
// // TRACE
|
|
4157
|
-
// console.log("ERROR : Could not instanciate class «"+className+"» with Reflect and «window.». (Maybe class is undefined or default constructor doesn't exist !)");
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
// TODO : FIXME : This is the most performance-costing fallback :
|
|
4161
|
-
try{
|
|
4162
|
-
|
|
4163
|
-
if(classInWindow){
|
|
4164
|
-
|
|
4165
|
-
newObj.__proto__=classInWindow.prototype;
|
|
4166
|
-
|
|
4167
|
-
}else{
|
|
4168
|
-
|
|
4169
|
-
// TODO : FIXME : I don't like that at all, to use eval(...), but on today I know of no other solution... :
|
|
4170
|
-
newObj.__proto__=eval(className+".prototype");
|
|
4171
|
-
}
|
|
4172
|
-
|
|
4173
|
-
}catch(e4){
|
|
4174
|
-
|
|
4175
|
-
// // TRACE
|
|
4176
|
-
// console.log("ERROR : Could not instanciate class «"+className+"» with prototype affectation.");
|
|
4177
|
-
// console.log("ERROR : Returning plain object since all instantiation methods have failed for class «"+className+"».");
|
|
4178
|
-
|
|
4179
|
-
}
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
}
|
|
4183
|
-
}
|
|
4184
4126
|
|
|
4127
|
+
// OLD :
|
|
4128
|
+
// try{
|
|
4129
|
+
// try{
|
|
4130
|
+
// newObj=Reflect.construct(classInWindow);
|
|
4131
|
+
// }catch(e1){
|
|
4132
|
+
//// // TRACE
|
|
4133
|
+
//// console.log("WARN : Could not instanciate class «"+className+"». (Maybe class is undefined or default constructor doesn't exist !)");
|
|
4134
|
+
// // TODO : FIXME : I don't like that at all, to use eval(...), but on today I know of no other solution... :
|
|
4135
|
+
// newObj=eval("new "+className+"();");
|
|
4136
|
+
// }
|
|
4137
|
+
// }catch(e2){
|
|
4138
|
+
//// // TRACE
|
|
4139
|
+
//// console.log("ERROR : Could not instanciate class «"+className+"» with eval. (Maybe class is undefined or default constructor doesn't exist !)");
|
|
4140
|
+
// try{
|
|
4141
|
+
//// // TODO : FIXME : I don't like that at all, to use eval(...), but on today I know of no other solution... :
|
|
4142
|
+
//// newObj=eval("new window."+className+"();");
|
|
4143
|
+
// newObj=Reflect.construct(classInWindow);
|
|
4144
|
+
// }catch(e3){
|
|
4145
|
+
//// // TRACE
|
|
4146
|
+
//// console.log("ERROR : Could not instanciate class «"+className+"» with eval and «window.». (Maybe class is undefined or default constructor doesn't exist !)");
|
|
4147
|
+
//// console.log("ERROR : Could not instanciate class «"+className+"» with Reflect and «window.». (Maybe class is undefined or default constructor doesn't exist !)");
|
|
4148
|
+
// // TODO : FIXME : This is the most performance-costing fallback :
|
|
4149
|
+
// try{
|
|
4150
|
+
// if(classInWindow){
|
|
4151
|
+
// newObj.__proto__=classInWindow.prototype;
|
|
4152
|
+
// }else{
|
|
4153
|
+
//
|
|
4154
|
+
// // TODO : FIXME : I don't like that at all, to use eval(...), but on today I know of no other solution... :
|
|
4155
|
+
// newObj.__proto__=eval(className+".prototype");
|
|
4156
|
+
// }
|
|
4157
|
+
// }catch(e4){
|
|
4158
|
+
//// // TRACE
|
|
4159
|
+
//// console.log("ERROR : Could not instanciate class «"+className+"» with prototype affectation.");
|
|
4160
|
+
//// console.log("ERROR : Returning plain object since all instantiation methods have failed for class «"+className+"».");
|
|
4161
|
+
// }
|
|
4162
|
+
// }
|
|
4163
|
+
// }
|
|
4164
|
+
|
|
4165
|
+
newObj=new classInWindow();
|
|
4185
4166
|
return newObj;
|
|
4186
4167
|
};
|
|
4187
4168
|
|
|
@@ -5136,6 +5117,264 @@ window.getPathFileName=(path, fileSeparator="/", removeExtension=false)=>{
|
|
|
5136
5117
|
}
|
|
5137
5118
|
|
|
5138
5119
|
|
|
5120
|
+
// -------------------------------------------------------------------------
|
|
5121
|
+
// ====================================================== ROUTINES ======================================================
|
|
5122
|
+
|
|
5123
|
+
|
|
5124
|
+
// ======================== Timeout ========================
|
|
5125
|
+
|
|
5126
|
+
// CAUTION : This is not a routine, but a single-use timeout !
|
|
5127
|
+
window.MonoThreadedTimeout=class {
|
|
5128
|
+
constructor(actuator, delayMillis){
|
|
5129
|
+
this.actuator=actuator;
|
|
5130
|
+
}
|
|
5131
|
+
start(delayMillis=null){
|
|
5132
|
+
this.started=true;
|
|
5133
|
+
this.time=getNow();
|
|
5134
|
+
this.delayMillis=delayMillis;
|
|
5135
|
+
}
|
|
5136
|
+
doStep(args=null){
|
|
5137
|
+
if(!this.started) return;
|
|
5138
|
+
if(!hasDelayPassed(this.time, this.delayMillis)) return;
|
|
5139
|
+
return this.stop(args);
|
|
5140
|
+
}
|
|
5141
|
+
stop(args=null){
|
|
5142
|
+
if(!this.started) return;
|
|
5143
|
+
this.started=false;
|
|
5144
|
+
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
5145
|
+
return this;
|
|
5146
|
+
}
|
|
5147
|
+
}
|
|
5148
|
+
|
|
5149
|
+
window.getMonoThreadedTimeout=function(actuator=null){
|
|
5150
|
+
return new MonoThreadedTimeout(actuator);
|
|
5151
|
+
}
|
|
5152
|
+
|
|
5153
|
+
|
|
5154
|
+
// ======================== Routine ========================
|
|
5155
|
+
|
|
5156
|
+
window.MonoThreadedRoutine=class {
|
|
5157
|
+
constructor(actuator,refreshMillis=null,startDependsOnParentOnly=false){
|
|
5158
|
+
|
|
5159
|
+
this.actuator=actuator;
|
|
5160
|
+
this.startDependsOnParentOnly=startDependsOnParentOnly;
|
|
5161
|
+
this.started=false;
|
|
5162
|
+
this.paused=false;
|
|
5163
|
+
this.time=getNow();
|
|
5164
|
+
this.refreshMillis=refreshMillis;
|
|
5165
|
+
|
|
5166
|
+
this.durationTimeFactorHolder={durationTimeFactor:1};
|
|
5167
|
+
// Three-states : started, paused, stopped.
|
|
5168
|
+
|
|
5169
|
+
}
|
|
5170
|
+
|
|
5171
|
+
setDurationTimeFactorHolder(durationTimeFactorHolder){
|
|
5172
|
+
this.durationTimeFactorHolder=durationTimeFactorHolder;
|
|
5173
|
+
return this;
|
|
5174
|
+
}
|
|
5175
|
+
isStarted(){
|
|
5176
|
+
return this.started || this.startDependsOnParentOnly;
|
|
5177
|
+
}
|
|
5178
|
+
start(args=null){
|
|
5179
|
+
// if(this.isStarted()) return;
|
|
5180
|
+
if(this.actuator.terminateFunction && this.actuator.terminateFunction(args)){
|
|
5181
|
+
// CAUTION : Even if the routine is «pre-terminated» before even starting
|
|
5182
|
+
// (ie. its stop conditions are fullfilled even before it has started)
|
|
5183
|
+
// we all the same have to trigger its stop treatments :
|
|
5184
|
+
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
5185
|
+
return;
|
|
5186
|
+
}
|
|
5187
|
+
this.started=true;
|
|
5188
|
+
this.paused=false;
|
|
5189
|
+
return this;
|
|
5190
|
+
}
|
|
5191
|
+
stop(args=null){
|
|
5192
|
+
if(!this.isStarted()) return;
|
|
5193
|
+
this.started=false;
|
|
5194
|
+
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
5195
|
+
}
|
|
5196
|
+
pause(args=null){
|
|
5197
|
+
this.paused=true;
|
|
5198
|
+
if(this.actuator.doOnSuspend) this.actuator.doOnSuspend(args);
|
|
5199
|
+
}
|
|
5200
|
+
resume(args=null){
|
|
5201
|
+
this.paused=false;
|
|
5202
|
+
if(this.actuator.doOnResume) this.actuator.doOnResume(args);
|
|
5203
|
+
}
|
|
5204
|
+
isPaused(){
|
|
5205
|
+
return this.paused;
|
|
5206
|
+
}
|
|
5207
|
+
doStep(args=null){
|
|
5208
|
+
if(!this.isStarted() || this.paused) return;
|
|
5209
|
+
// Looping index with a delay :
|
|
5210
|
+
|
|
5211
|
+
const delayHasPassed=hasDelayPassed(this.time, this.refreshMillis*this.durationTimeFactorHolder.getDurationTimeFactor());
|
|
5212
|
+
if(!this.refreshMillis || delayHasPassed){
|
|
5213
|
+
if(this.refreshMillis && delayHasPassed){
|
|
5214
|
+
this.time=getNow();
|
|
5215
|
+
}
|
|
5216
|
+
// We perform the step :
|
|
5217
|
+
if(this.actuator.terminateFunction && this.actuator.terminateFunction(args)){
|
|
5218
|
+
this.stop(args);
|
|
5219
|
+
return;
|
|
5220
|
+
}
|
|
5221
|
+
if(this.actuator.doOnEachStep) this.actuator.doOnEachStep(args);
|
|
5222
|
+
}
|
|
5223
|
+
|
|
5224
|
+
}
|
|
5225
|
+
|
|
5226
|
+
}
|
|
5227
|
+
|
|
5228
|
+
|
|
5229
|
+
window.getMonoThreadedRoutine=function(actuator, refreshMillis=null, startDependsOnParentOnly=false){
|
|
5230
|
+
return new MonoThreadedRoutine(actuator, refreshMillis, startDependsOnParentOnly);
|
|
5231
|
+
}
|
|
5232
|
+
|
|
5233
|
+
|
|
5234
|
+
window.MonoThreadedGoToGoal=class {
|
|
5235
|
+
constructor(actuator,actualValue,goalValue,refreshMillis=null,totalTimeMillis=1000,mode="linear"){
|
|
5236
|
+
|
|
5237
|
+
this.actuator=actuator;
|
|
5238
|
+
|
|
5239
|
+
this.actualValue=actualValue;
|
|
5240
|
+
this.mode=mode;
|
|
5241
|
+
this.totalTimeMillis=totalTimeMillis;
|
|
5242
|
+
this.stepValue=((refreshMillis*(goalValue-actualValue))/totalTimeMillis);
|
|
5243
|
+
this.value=actualValue;
|
|
5244
|
+
this.goalValue=goalValue;
|
|
5245
|
+
this.started=false;
|
|
5246
|
+
this.paused=false;
|
|
5247
|
+
this.time=getNow();
|
|
5248
|
+
this.refreshMillis=refreshMillis;
|
|
5249
|
+
|
|
5250
|
+
this.durationTimeFactorHolder={durationTimeFactor:1};
|
|
5251
|
+
|
|
5252
|
+
// Three-states : started, paused, stopped.
|
|
5253
|
+
}
|
|
5254
|
+
setDurationTimeFactorHolder(durationTimeFactorHolder){
|
|
5255
|
+
this.durationTimeFactorHolder=durationTimeFactorHolder;
|
|
5256
|
+
|
|
5257
|
+
// We recalculate total time-dependent values :
|
|
5258
|
+
this.totalTimeMillis=this.totalTimeMillis*this.durationTimeFactorHolder.getDurationTimeFactor();
|
|
5259
|
+
this.stepValue=((this.refreshMillis*(this.goalValue-this.actualValue))/this.totalTimeMillis);
|
|
5260
|
+
|
|
5261
|
+
return this;
|
|
5262
|
+
}
|
|
5263
|
+
isStarted(){
|
|
5264
|
+
return this.started || this.startDependsOnParentOnly;
|
|
5265
|
+
}
|
|
5266
|
+
resetValueAndGoalTo(resetValue){
|
|
5267
|
+
this.value=resetValue;
|
|
5268
|
+
this.goalValue=resetValue;
|
|
5269
|
+
return this;
|
|
5270
|
+
}
|
|
5271
|
+
setNewGoal(goalValue, refreshMillisParam=null, totalTimeMillis=null){
|
|
5272
|
+
if(Math.round(this.value)===Math.round(goalValue)) return;
|
|
5273
|
+
if(refreshMillisParam) this.refreshMillis=refreshMillisParam;
|
|
5274
|
+
if(totalTimeMillis) this.totalTimeMillis=totalTimeMillis*this.durationTimeFactorHolder.getDurationTimeFactor();
|
|
5275
|
+
|
|
5276
|
+
this.goalValue=goalValue;
|
|
5277
|
+
this.stepValue=((this.refreshMillis*(this.goalValue-this.value))/this.totalTimeMillis);
|
|
5278
|
+
|
|
5279
|
+
if(!this.isStarted()) this.start();
|
|
5280
|
+
|
|
5281
|
+
return this;
|
|
5282
|
+
}
|
|
5283
|
+
start(args=null){
|
|
5284
|
+
|
|
5285
|
+
if( this.value===this.goalValue
|
|
5286
|
+
// || this.isStarted();
|
|
5287
|
+
|| (this.actuator.terminateFunction && this.actuator.terminateFunction())
|
|
5288
|
+
|| this.hasReachedGoal()){
|
|
5289
|
+
|
|
5290
|
+
// CAUTION : Even if the routine is «pre-terminated» before even starting
|
|
5291
|
+
// (ie. its stop conditions are fullfilled even before it has started)
|
|
5292
|
+
// we all the same have to trigger its stop treatments :
|
|
5293
|
+
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
5294
|
+
|
|
5295
|
+
return;
|
|
5296
|
+
}
|
|
5297
|
+
this.started=true;
|
|
5298
|
+
this.paused=false;
|
|
5299
|
+
|
|
5300
|
+
return this;
|
|
5301
|
+
}
|
|
5302
|
+
stop(args=null){
|
|
5303
|
+
if(!this.isStarted()) return;
|
|
5304
|
+
this.started=false;
|
|
5305
|
+
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
5306
|
+
}
|
|
5307
|
+
pause(){
|
|
5308
|
+
this.paused=true;
|
|
5309
|
+
}
|
|
5310
|
+
resume(){
|
|
5311
|
+
this.paused=false;
|
|
5312
|
+
}
|
|
5313
|
+
hasReachedGoal(){
|
|
5314
|
+
if(this.stepValue<0){
|
|
5315
|
+
if(this.value<=this.goalValue) return true;
|
|
5316
|
+
}else{
|
|
5317
|
+
if(this.goalValue<=this.value) return true;
|
|
5318
|
+
}
|
|
5319
|
+
return false;
|
|
5320
|
+
}
|
|
5321
|
+
|
|
5322
|
+
doStep(args=null){
|
|
5323
|
+
if(!this.isStarted() || this.paused) return this.value;
|
|
5324
|
+
|
|
5325
|
+
// Looping index with a delay :
|
|
5326
|
+
|
|
5327
|
+
if(!this.refreshMillis || this.hasDelayPassed()){
|
|
5328
|
+
if(this.refreshMillis && this.hasDelayPassed()){
|
|
5329
|
+
this.time=getNow();
|
|
5330
|
+
}
|
|
5331
|
+
|
|
5332
|
+
// We check if we must stop :
|
|
5333
|
+
if(this.actuator.terminateFunction){
|
|
5334
|
+
if(this.actuator.terminateFunction()){
|
|
5335
|
+
this.stop();
|
|
5336
|
+
this.value=this.goalValue;
|
|
5337
|
+
return this.value;
|
|
5338
|
+
}
|
|
5339
|
+
}else{
|
|
5340
|
+
if(this.hasReachedGoal()){
|
|
5341
|
+
this.stop();
|
|
5342
|
+
this.value=this.goalValue;
|
|
5343
|
+
return this.value;
|
|
5344
|
+
}
|
|
5345
|
+
}
|
|
5346
|
+
|
|
5347
|
+
// We perform the step :
|
|
5348
|
+
if(this.mode==="exponential"){
|
|
5349
|
+
this.value+=Math.pow(this.stepValue,2);
|
|
5350
|
+
}else{ // default is "linear"
|
|
5351
|
+
this.value+=this.stepValue;
|
|
5352
|
+
}
|
|
5353
|
+
|
|
5354
|
+
if(this.actuator.doOnEachStep) this.actuator.doOnEachStep(args);
|
|
5355
|
+
}
|
|
5356
|
+
|
|
5357
|
+
return this.value;
|
|
5358
|
+
}
|
|
5359
|
+
|
|
5360
|
+
hasDelayPassed(){
|
|
5361
|
+
return (!this.time || hasDelayPassed(this.time, this.refreshMillis*this.durationTimeFactorHolder.getDurationTimeFactor()));
|
|
5362
|
+
}
|
|
5363
|
+
|
|
5364
|
+
|
|
5365
|
+
}
|
|
5366
|
+
|
|
5367
|
+
|
|
5368
|
+
window.getMonoThreadedGoToGoal=function(actuator,actualValue,goalValue,refreshMillis=null,totalTimeMillis=1000,mode="linear"){
|
|
5369
|
+
return new MonoThreadedGoToGoal(actuator,actualValue,goalValue,refreshMillis,totalTimeMillis,mode);
|
|
5370
|
+
}
|
|
5371
|
+
|
|
5372
|
+
|
|
5373
|
+
// =====================================================================================================================
|
|
5374
|
+
|
|
5375
|
+
// -------------------------------------------------------------------------
|
|
5376
|
+
|
|
5377
|
+
|
|
5139
5378
|
|
|
5140
5379
|
// MUST REMAIN AT THE END OF THIS LIBRARY FILE !
|
|
5141
5380
|
|
|
@@ -5145,7 +5384,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
|
|
|
5145
5384
|
|
|
5146
5385
|
|
|
5147
5386
|
|
|
5148
|
-
/*utils CLIENT library associated with aotra version : «1_29072022-2359 (05/04/2026-
|
|
5387
|
+
/*utils CLIENT library associated with aotra version : «1_29072022-2359 (05/04/2026-12:42:00)»*/
|
|
5149
5388
|
/*-----------------------------------------------------------------------------*/
|
|
5150
5389
|
/* ## Utility global methods in a browser (htmljs) client environment.
|
|
5151
5390
|
*
|
|
@@ -9339,260 +9578,6 @@ function getSpriteMonoThreaded(imagesPool,/*OPTIONAL*/refreshMillis=null,
|
|
|
9339
9578
|
zoomsParam);
|
|
9340
9579
|
}
|
|
9341
9580
|
|
|
9342
|
-
// ====================================================== ROUTINES ======================================================
|
|
9343
|
-
|
|
9344
|
-
|
|
9345
|
-
// ======================== Timeout ========================
|
|
9346
|
-
|
|
9347
|
-
// CAUTION : This is not a routine, but a single-use timeout !
|
|
9348
|
-
class MonoThreadedTimeout{
|
|
9349
|
-
constructor(actuator, delayMillis){
|
|
9350
|
-
this.actuator=actuator;
|
|
9351
|
-
}
|
|
9352
|
-
start(delayMillis=null){
|
|
9353
|
-
this.started=true;
|
|
9354
|
-
this.time=getNow();
|
|
9355
|
-
this.delayMillis=delayMillis;
|
|
9356
|
-
}
|
|
9357
|
-
doStep(args=null){
|
|
9358
|
-
if(!this.started) return;
|
|
9359
|
-
if(!hasDelayPassed(this.time, this.delayMillis)) return;
|
|
9360
|
-
return this.stop(args);
|
|
9361
|
-
}
|
|
9362
|
-
stop(args=null){
|
|
9363
|
-
if(!this.started) return;
|
|
9364
|
-
this.started=false;
|
|
9365
|
-
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
9366
|
-
return this;
|
|
9367
|
-
}
|
|
9368
|
-
}
|
|
9369
|
-
|
|
9370
|
-
function getMonoThreadedTimeout(actuator=null){
|
|
9371
|
-
return new MonoThreadedTimeout(actuator);
|
|
9372
|
-
}
|
|
9373
|
-
|
|
9374
|
-
|
|
9375
|
-
// ======================== Routine ========================
|
|
9376
|
-
|
|
9377
|
-
class MonoThreadedRoutine{
|
|
9378
|
-
constructor(actuator,refreshMillis=null,startDependsOnParentOnly=false){
|
|
9379
|
-
|
|
9380
|
-
this.actuator=actuator;
|
|
9381
|
-
this.startDependsOnParentOnly=startDependsOnParentOnly;
|
|
9382
|
-
this.started=false;
|
|
9383
|
-
this.paused=false;
|
|
9384
|
-
this.time=getNow();
|
|
9385
|
-
this.refreshMillis=refreshMillis;
|
|
9386
|
-
|
|
9387
|
-
this.durationTimeFactorHolder={durationTimeFactor:1};
|
|
9388
|
-
// Three-states : started, paused, stopped.
|
|
9389
|
-
|
|
9390
|
-
}
|
|
9391
|
-
|
|
9392
|
-
setDurationTimeFactorHolder(durationTimeFactorHolder){
|
|
9393
|
-
this.durationTimeFactorHolder=durationTimeFactorHolder;
|
|
9394
|
-
return this;
|
|
9395
|
-
}
|
|
9396
|
-
isStarted(){
|
|
9397
|
-
return this.started || this.startDependsOnParentOnly;
|
|
9398
|
-
}
|
|
9399
|
-
start(args=null){
|
|
9400
|
-
// if(this.isStarted()) return;
|
|
9401
|
-
if(this.actuator.terminateFunction && this.actuator.terminateFunction(args)){
|
|
9402
|
-
// CAUTION : Even if the routine is «pre-terminated» before even starting
|
|
9403
|
-
// (ie. its stop conditions are fullfilled even before it has started)
|
|
9404
|
-
// we all the same have to trigger its stop treatments :
|
|
9405
|
-
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
9406
|
-
return;
|
|
9407
|
-
}
|
|
9408
|
-
this.started=true;
|
|
9409
|
-
this.paused=false;
|
|
9410
|
-
return this;
|
|
9411
|
-
}
|
|
9412
|
-
stop(args=null){
|
|
9413
|
-
if(!this.isStarted()) return;
|
|
9414
|
-
this.started=false;
|
|
9415
|
-
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
9416
|
-
}
|
|
9417
|
-
pause(args=null){
|
|
9418
|
-
this.paused=true;
|
|
9419
|
-
if(this.actuator.doOnSuspend) this.actuator.doOnSuspend(args);
|
|
9420
|
-
}
|
|
9421
|
-
resume(args=null){
|
|
9422
|
-
this.paused=false;
|
|
9423
|
-
if(this.actuator.doOnResume) this.actuator.doOnResume(args);
|
|
9424
|
-
}
|
|
9425
|
-
isPaused(){
|
|
9426
|
-
return this.paused;
|
|
9427
|
-
}
|
|
9428
|
-
doStep(args=null){
|
|
9429
|
-
if(!this.isStarted() || this.paused) return;
|
|
9430
|
-
// Looping index with a delay :
|
|
9431
|
-
|
|
9432
|
-
const delayHasPassed=hasDelayPassed(this.time, this.refreshMillis*this.durationTimeFactorHolder.getDurationTimeFactor());
|
|
9433
|
-
if(!this.refreshMillis || delayHasPassed){
|
|
9434
|
-
if(this.refreshMillis && delayHasPassed){
|
|
9435
|
-
this.time=getNow();
|
|
9436
|
-
}
|
|
9437
|
-
// We perform the step :
|
|
9438
|
-
if(this.actuator.terminateFunction && this.actuator.terminateFunction(args)){
|
|
9439
|
-
this.stop(args);
|
|
9440
|
-
return;
|
|
9441
|
-
}
|
|
9442
|
-
if(this.actuator.doOnEachStep) this.actuator.doOnEachStep(args);
|
|
9443
|
-
}
|
|
9444
|
-
|
|
9445
|
-
}
|
|
9446
|
-
|
|
9447
|
-
}
|
|
9448
|
-
|
|
9449
|
-
|
|
9450
|
-
function getMonoThreadedRoutine(actuator, refreshMillis=null, startDependsOnParentOnly=false){
|
|
9451
|
-
return new MonoThreadedRoutine(actuator, refreshMillis, startDependsOnParentOnly);
|
|
9452
|
-
}
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
class MonoThreadedGoToGoal{
|
|
9456
|
-
constructor(actuator,actualValue,goalValue,refreshMillis=null,totalTimeMillis=1000,mode="linear"){
|
|
9457
|
-
|
|
9458
|
-
this.actuator=actuator;
|
|
9459
|
-
|
|
9460
|
-
this.actualValue=actualValue;
|
|
9461
|
-
this.mode=mode;
|
|
9462
|
-
this.totalTimeMillis=totalTimeMillis;
|
|
9463
|
-
this.stepValue=((refreshMillis*(goalValue-actualValue))/totalTimeMillis);
|
|
9464
|
-
this.value=actualValue;
|
|
9465
|
-
this.goalValue=goalValue;
|
|
9466
|
-
this.started=false;
|
|
9467
|
-
this.paused=false;
|
|
9468
|
-
this.time=getNow();
|
|
9469
|
-
this.refreshMillis=refreshMillis;
|
|
9470
|
-
|
|
9471
|
-
this.durationTimeFactorHolder={durationTimeFactor:1};
|
|
9472
|
-
|
|
9473
|
-
// Three-states : started, paused, stopped.
|
|
9474
|
-
}
|
|
9475
|
-
setDurationTimeFactorHolder(durationTimeFactorHolder){
|
|
9476
|
-
this.durationTimeFactorHolder=durationTimeFactorHolder;
|
|
9477
|
-
|
|
9478
|
-
// We recalculate total time-dependent values :
|
|
9479
|
-
this.totalTimeMillis=this.totalTimeMillis*this.durationTimeFactorHolder.getDurationTimeFactor();
|
|
9480
|
-
this.stepValue=((this.refreshMillis*(this.goalValue-this.actualValue))/this.totalTimeMillis);
|
|
9481
|
-
|
|
9482
|
-
return this;
|
|
9483
|
-
}
|
|
9484
|
-
isStarted(){
|
|
9485
|
-
return this.started || this.startDependsOnParentOnly;
|
|
9486
|
-
}
|
|
9487
|
-
resetValueAndGoalTo(resetValue){
|
|
9488
|
-
this.value=resetValue;
|
|
9489
|
-
this.goalValue=resetValue;
|
|
9490
|
-
return this;
|
|
9491
|
-
}
|
|
9492
|
-
setNewGoal(goalValue, refreshMillisParam=null, totalTimeMillis=null){
|
|
9493
|
-
if(Math.round(this.value)===Math.round(goalValue)) return;
|
|
9494
|
-
if(refreshMillisParam) this.refreshMillis=refreshMillisParam;
|
|
9495
|
-
if(totalTimeMillis) this.totalTimeMillis=totalTimeMillis*this.durationTimeFactorHolder.getDurationTimeFactor();
|
|
9496
|
-
|
|
9497
|
-
this.goalValue=goalValue;
|
|
9498
|
-
this.stepValue=((this.refreshMillis*(this.goalValue-this.value))/this.totalTimeMillis);
|
|
9499
|
-
|
|
9500
|
-
if(!this.isStarted()) this.start();
|
|
9501
|
-
|
|
9502
|
-
return this;
|
|
9503
|
-
}
|
|
9504
|
-
start(args=null){
|
|
9505
|
-
|
|
9506
|
-
if( this.value===this.goalValue
|
|
9507
|
-
// || this.isStarted();
|
|
9508
|
-
|| (this.actuator.terminateFunction && this.actuator.terminateFunction())
|
|
9509
|
-
|| this.hasReachedGoal()){
|
|
9510
|
-
|
|
9511
|
-
// CAUTION : Even if the routine is «pre-terminated» before even starting
|
|
9512
|
-
// (ie. its stop conditions are fullfilled even before it has started)
|
|
9513
|
-
// we all the same have to trigger its stop treatments :
|
|
9514
|
-
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
9515
|
-
|
|
9516
|
-
return;
|
|
9517
|
-
}
|
|
9518
|
-
this.started=true;
|
|
9519
|
-
this.paused=false;
|
|
9520
|
-
|
|
9521
|
-
return this;
|
|
9522
|
-
}
|
|
9523
|
-
stop(args=null){
|
|
9524
|
-
if(!this.isStarted()) return;
|
|
9525
|
-
this.started=false;
|
|
9526
|
-
if(this.actuator.doOnStop) this.actuator.doOnStop(args);
|
|
9527
|
-
}
|
|
9528
|
-
pause(){
|
|
9529
|
-
this.paused=true;
|
|
9530
|
-
}
|
|
9531
|
-
resume(){
|
|
9532
|
-
this.paused=false;
|
|
9533
|
-
}
|
|
9534
|
-
hasReachedGoal(){
|
|
9535
|
-
if(this.stepValue<0){
|
|
9536
|
-
if(this.value<=this.goalValue) return true;
|
|
9537
|
-
}else{
|
|
9538
|
-
if(this.goalValue<=this.value) return true;
|
|
9539
|
-
}
|
|
9540
|
-
return false;
|
|
9541
|
-
}
|
|
9542
|
-
|
|
9543
|
-
doStep(args=null){
|
|
9544
|
-
if(!this.isStarted() || this.paused) return this.value;
|
|
9545
|
-
|
|
9546
|
-
// Looping index with a delay :
|
|
9547
|
-
|
|
9548
|
-
if(!this.refreshMillis || this.hasDelayPassed()){
|
|
9549
|
-
if(this.refreshMillis && this.hasDelayPassed()){
|
|
9550
|
-
this.time=getNow();
|
|
9551
|
-
}
|
|
9552
|
-
|
|
9553
|
-
// We check if we must stop :
|
|
9554
|
-
if(this.actuator.terminateFunction){
|
|
9555
|
-
if(this.actuator.terminateFunction()){
|
|
9556
|
-
this.stop();
|
|
9557
|
-
this.value=this.goalValue;
|
|
9558
|
-
return this.value;
|
|
9559
|
-
}
|
|
9560
|
-
}else{
|
|
9561
|
-
if(this.hasReachedGoal()){
|
|
9562
|
-
this.stop();
|
|
9563
|
-
this.value=this.goalValue;
|
|
9564
|
-
return this.value;
|
|
9565
|
-
}
|
|
9566
|
-
}
|
|
9567
|
-
|
|
9568
|
-
// We perform the step :
|
|
9569
|
-
if(this.mode==="exponential"){
|
|
9570
|
-
this.value+=Math.pow(this.stepValue,2);
|
|
9571
|
-
}else{ // default is "linear"
|
|
9572
|
-
this.value+=this.stepValue;
|
|
9573
|
-
}
|
|
9574
|
-
|
|
9575
|
-
if(this.actuator.doOnEachStep) this.actuator.doOnEachStep(args);
|
|
9576
|
-
}
|
|
9577
|
-
|
|
9578
|
-
return this.value;
|
|
9579
|
-
}
|
|
9580
|
-
|
|
9581
|
-
hasDelayPassed(){
|
|
9582
|
-
return (!this.time || hasDelayPassed(this.time, this.refreshMillis*this.durationTimeFactorHolder.getDurationTimeFactor()));
|
|
9583
|
-
}
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
}
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
function getMonoThreadedGoToGoal(actuator,actualValue,goalValue,refreshMillis=null,totalTimeMillis=1000,mode="linear"){
|
|
9590
|
-
return new MonoThreadedGoToGoal(actuator,actualValue,goalValue,refreshMillis,totalTimeMillis,mode);
|
|
9591
|
-
}
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
// =====================================================================================================================
|
|
9595
|
-
|
|
9596
9581
|
|
|
9597
9582
|
//if signed :
|
|
9598
9583
|
//when precision==1/10000, range is -3.2766 to 3.2766
|
|
@@ -13225,7 +13210,7 @@ createOritaMicroClient=function(url, port, isNode=false, staticMicroClientIdPara
|
|
|
13225
13210
|
|
|
13226
13211
|
|
|
13227
13212
|
|
|
13228
|
-
/*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (05/04/2026-
|
|
13213
|
+
/*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (05/04/2026-12:42:00)»*/
|
|
13229
13214
|
/*-----------------------------------------------------------------------------*/
|
|
13230
13215
|
|
|
13231
13216
|
|
|
@@ -14554,10 +14539,10 @@ function rayVsUnitSphereClosestPoint(p, r) {
|
|
|
14554
14539
|
// MUST REMAIN AT THE END OF THIS LIBRARY FILE !
|
|
14555
14540
|
|
|
14556
14541
|
AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
|
|
14557
|
-
/*utils 3D library associated with aotra version : «1_29072022-2359 (05/04/2026-
|
|
14542
|
+
/*utils 3D library associated with aotra version : «1_29072022-2359 (05/04/2026-12:42:00)»*/
|
|
14558
14543
|
/*-----------------------------------------------------------------------------*/
|
|
14559
14544
|
|
|
14560
|
-
/*utils AI library associated with aotra version : «1_29072022-2359 (05/04/2026-
|
|
14545
|
+
/*utils AI library associated with aotra version : «1_29072022-2359 (05/04/2026-12:42:00)»*/
|
|
14561
14546
|
/*-----------------------------------------------------------------------------*/
|
|
14562
14547
|
|
|
14563
14548
|
|
|
@@ -14703,7 +14688,7 @@ getOpenAIAPIClient=(modelName, apiURL, agentRole, defaultPrompt)=>{
|
|
|
14703
14688
|
|
|
14704
14689
|
|
|
14705
14690
|
|
|
14706
|
-
/*utils CONSOLE library associated with aotra version : «1_29072022-2359 (05/04/2026-
|
|
14691
|
+
/*utils CONSOLE library associated with aotra version : «1_29072022-2359 (05/04/2026-12:42:00)»*/
|
|
14707
14692
|
/*-----------------------------------------------------------------------------*/
|
|
14708
14693
|
|
|
14709
14694
|
|
aotrautils/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1840",
|
|
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)",
|