aotrautils 0.0.1997 → 0.0.2000

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 (14/09/2026-01:52:35)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (04/10/2026-00:30:31)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -5485,7 +5485,7 @@ window.AOTRAUTILS_LIB_IS_LOADED=true;
5485
5485
 
5486
5486
 
5487
5487
 
5488
- /*utils CLIENT library associated with aotra version : «1_29072022-2359 (14/09/2026-01:52:35)»*/
5488
+ /*utils CLIENT library associated with aotra version : «1_29072022-2359 (04/10/2026-00:30:31)»*/
5489
5489
  /*-----------------------------------------------------------------------------*/
5490
5490
  /* ## Utility global methods in a browser (htmljs) client environment.
5491
5491
  *
@@ -13000,7 +13000,7 @@ window.createOritaMicroClient=function(url, port, isNode=false, staticMicroClien
13000
13000
 
13001
13001
 
13002
13002
 
13003
- /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (14/09/2026-01:52:35)»*/
13003
+ /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (04/10/2026-00:30:31)»*/
13004
13004
  /*-----------------------------------------------------------------------------*/
13005
13005
 
13006
13006
 
@@ -13447,12 +13447,10 @@ Math.getAnglesDiffOnDemiCircle=(angleSourceParam, angleDestinationParam, isDegre
13447
13447
  }
13448
13448
 
13449
13449
 
13450
-
13451
-
13452
-
13453
-
13454
13450
  // Polygons
13455
13451
 
13452
+
13453
+ // NOT SURE :
13456
13454
  // polygon objects are an array of vertices forming the polygon
13457
13455
  // var polygon1=[{x:100,y:100},{x:150,y:150},{x:50,y:150},...];
13458
13456
  // The polygons can be both concave and convex
@@ -13499,7 +13497,7 @@ Math.polygonsCollide=function(p1,p2){
13499
13497
  }
13500
13498
 
13501
13499
 
13502
-
13500
+ // SURE :
13503
13501
  Math.isPointInPolygon=function(point,polygon){
13504
13502
 
13505
13503
  const yTarget=point.y;
@@ -13580,6 +13578,7 @@ window.isOriented=function(orientation, width, height){
13580
13578
 
13581
13579
  // Lines
13582
13580
 
13581
+ // NOT SURE :
13583
13582
  // helper: test line intersections
13584
13583
  // point object: {x:, y:}
13585
13584
  // p0 & p1 form one segment, p2 & p3 form the second segment
@@ -13621,40 +13620,68 @@ window.isOriented=function(orientation, width, height){
13621
13620
  return (numerator1>=0 && numerator1<=1 && numerator2>=0 && numerator2<=1);
13622
13621
  }
13623
13622
 
13624
-
13623
+ // NOT SURE :
13625
13624
  window.getIntersectionPointWithYHorizontalLineAndLineEquationParameters=function(slope,yOffset,yLineHeight){
13626
13625
  if(slope==0) return null;
13627
13626
  return {x:(yLineHeight-yOffset)/slope,y:yLineHeight};
13628
13627
  }
13629
13628
 
13630
- window.getIntersectionPointFrom2LinesEquationParameters=function(slope1,yOffset1,slope2,yOffset2){
13631
- const slopesDelta=slope1-slope2;
13632
- if(slopesDelta==0) return null;
13633
-
13634
- const yOffsetsInverseDelta=yOffset2-yOffset1;
13635
-
13636
- const intersectionX=yOffsetsInverseDelta/slopesDelta;
13637
- const intersectionY=(slope1*yOffset2-slope2*yOffset1)/slopesDelta;
13638
-
13639
- return {x:intersectionX,y:intersectionY};
13629
+
13630
+
13631
+ // Another method : (maybe the same !)
13632
+
13633
+ window.getIntersectionPointFromSegments=function(segment1, segment2, isSegment2Ray){
13634
+ const lineParameters1=getSegmentEquationParameters(segment1.point1, segment1.point2);
13635
+ const lineParameters2=getSegmentEquationParameters(segment2.point1, segment2.point2);
13636
+ if(lineParameters1.slope==lineParameters2.slope) // Case parallel lines :
13637
+ return null;
13638
+ const slopesDelta=(lineParameters2.slope-lineParameters1.slope);
13639
+ const inverseSlopesDelta=(lineParameters1.slope-lineParameters2.slope);
13640
+ const intersectionX=((lineParameters1.yOffset-lineParameters2.yOffset)/slopesDelta);
13641
+ const intersectionY=((lineParameters1.slope*lineParameters2.yOffset-lineParameters2.slope*lineParameters1.yOffset)/inverseSlopesDelta);
13642
+ const intersectionPoint={x:intersectionX,y:intersectionY};
13643
+ if(isPointWithinSegmentBounds(segment1, intersectionPoint) && (isSegment2Ray || isPointInSegment(segment2, intersectionPoint)))
13644
+ return intersectionPoint;
13645
+ return null;
13640
13646
  }
13641
13647
 
13648
+ // SURE :
13649
+ window.isPointWithinSegmentBounds=function(segment, point){
13650
+ return ((segment.point1.x<point.x && point.x<segment.point2.x && segment.point1.y<point.y && point.y<segment.point2.y)
13651
+ ||(segment.point2.x<point.x && point.x<segment.point1.x && segment.point2.y<point.y && point.y<segment.point1.y));
13652
+ }
13653
+
13654
+ // SURE :
13642
13655
  window.getSegmentEquationParameters=function(p1,p2){
13643
13656
  const deltaX=p2.x-p1.x;
13644
13657
  const deltaY=p2.y-p1.y;
13645
- if(deltaX==0) return null;
13646
- if(deltaY==0) return {slope:0, yOffset:p2.y};
13647
- const slope=(deltaX/deltaY);
13648
- const yOffset=-(slope*p1.x-p1.y);
13658
+ if(deltaX==0) return null; // |
13659
+ if(deltaY==0) return {slope:0, yOffset:p2.y}; // ---
13660
+ const slope=(deltaY/deltaX);
13661
+ const yOffset=(p2.y-slope*p2.x);
13649
13662
  return {slope:slope, yOffset:yOffset};
13650
13663
  }
13651
13664
 
13665
+ // SURE :
13666
+ window.getIntersectionPointFrom2LinesEquationParameters=function(slope1,yOffset1,slope2,yOffset2){
13667
+ const slopesDelta=slope1-slope2;
13668
+ if(slopesDelta==0) return null;
13669
+ const yOffsetsDelta=yOffset2-yOffset1;
13670
+ const intersectionX=yOffsetsDelta/slopesDelta;
13671
+ const intersectionY=(slope1*yOffset2-slope2*yOffset1)/slopesDelta;
13672
+ return {x:intersectionX,y:intersectionY};
13673
+ }
13674
+
13675
+
13676
+
13677
+
13652
13678
  // http://alienryderflex.com/polygon/
13653
13679
  // 1) We draw a line parallel to the X axis, at the Y coordinate of the tested point,
13654
13680
  // 2) And we collect all the intersection points (or nodes) with the polygon's sides.
13655
13681
  // (We exclude nodes that have the same coordinates as polygon vertices !)
13656
13682
  // 3) If there is an odd number (or 1) of nodes on each side (on the X axis) of the point, then the point is inside the polygon
13657
13683
 
13684
+ // SURE :
13658
13685
  window.getIntersectionPointOnSegmentAtY=function(p1,p2,yTarget){
13659
13686
  if((yTarget<p1.y && yTarget<p2.y) || (p1.y<yTarget && p2.y<yTarget)) return null;
13660
13687
  const equationParameters=getSegmentEquationParameters(p1,p2);
@@ -13668,7 +13695,7 @@ window.getIntersectionPointOnSegmentAtY=function(p1,p2,yTarget){
13668
13695
 
13669
13696
  // Perspective
13670
13697
 
13671
-
13698
+ // NOT SURE :
13672
13699
  // apparentCorner1----apparentCorner2
13673
13700
  // | |
13674
13701
  // | |
@@ -14062,10 +14089,10 @@ function rayVsUnitSphereClosestPoint(p, r) {
14062
14089
  // MUST REMAIN AT THE END OF THIS LIBRARY FILE !
14063
14090
 
14064
14091
  window.AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
14065
- /*utils 3D library associated with aotra version : «1_29072022-2359 (14/09/2026-01:52:35)»*/
14092
+ /*utils 3D library associated with aotra version : «1_29072022-2359 (04/10/2026-00:30:31)»*/
14066
14093
  /*-----------------------------------------------------------------------------*/
14067
14094
 
14068
- /*utils AI library associated with aotra version : «1_29072022-2359 (14/09/2026-01:52:35)»*/
14095
+ /*utils AI library associated with aotra version : «1_29072022-2359 (04/10/2026-00:30:31)»*/
14069
14096
  /*-----------------------------------------------------------------------------*/
14070
14097
 
14071
14098
 
@@ -14329,7 +14356,7 @@ window.getLLMAPIClient=(modelName, apiURL, agentRole, defaultPrompt, llmProvider
14329
14356
 
14330
14357
 
14331
14358
 
14332
- /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (14/09/2026-01:52:35)»*/
14359
+ /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (04/10/2026-00:30:31)»*/
14333
14360
  /*-----------------------------------------------------------------------------*/
14334
14361
 
14335
14362
 
@@ -14537,6 +14564,7 @@ window.AORTACClientCell=class AORTACClientCell{
14537
14564
  },{listenerMessageType:"clientHello.response"});
14538
14565
 
14539
14566
  }
14567
+
14540
14568
 
14541
14569
  // ----
14542
14570
  // RECONNECTED CLIENT HELLO SEQUENCE
@@ -14706,6 +14734,51 @@ window.getAORTACClient=function(serverCellOrigin="ws://127.0.0.1:40000", model,
14706
14734
 
14707
14735
 
14708
14736
 
14737
+ /* ## Utility methods in a javascript, for AORTAC subsystem (client)
14738
+ *
14739
+ * This set of methods gathers utility generic-purpose methods usable in any JS project.
14740
+ * Several authors of snippets published freely on the Internet contributed to this library.
14741
+ * Feel free to use/modify-enhance/publish them under the terms of its license.
14742
+ *
14743
+ * # Library name : «aotrautils»
14744
+ * # Library license : HGPL(Help Burma) (see aotra README information for details : https://alqemia.com/aotra.js )
14745
+ * # Author name : Jérémie Ratomposon (massively helped by his native country free education system)
14746
+ * # Author email : info@alqemia.com
14747
+ * # Organization name : Alqemia
14748
+ * # Organization email : admin@alqemia.com
14749
+ * # Organization website : https://alqemia.com
14750
+ *
14751
+ *
14752
+ */
14753
+
14754
+
14755
+
14756
+ // COMPATIBILITY browser javascript / nodejs environment :
14757
+ if(typeof(window)==="undefined") window=global;
14758
+
14759
+
14760
+ // ==================================================================================================================
14761
+
14762
+
14763
+ // AORTAC CLIENT CENTRALIZED PROTOCOL
14764
+
14765
+
14766
+ // CURRENT 1
14767
+ window.ModificationRequestSender=class ModificationRequestSender{
14768
+ constructor(serverCell){
14769
+ this.serverCell=serverCell;
14770
+ }
14771
+ }
14772
+
14773
+ window.ViewChangedRequestSender=class ViewChangedRequestSender{
14774
+ constructor(serverCell){
14775
+ this.serverCell=serverCell;
14776
+ }
14777
+ }
14778
+
14779
+
14780
+
14781
+
14709
14782
  /* ## Utility methods in a javascript, for AORTAC subsystem (server)
14710
14783
  *
14711
14784
  * This set of methods gathers utility generic-purpose methods usable in any JS project.
@@ -14792,6 +14865,11 @@ window.AORTACServerCell=class AORTACServerCell{
14792
14865
 
14793
14866
  this.clients={};
14794
14867
 
14868
+
14869
+ // OTHER PROTOCOL HANDLERS :
14870
+ this.modificationRequestHandler=new ModificationRequestHandler(this);
14871
+ this.viewChangedRequestHandler=new ViewChangedRequestHandler(this);
14872
+
14795
14873
  }
14796
14874
 
14797
14875
  start(){
@@ -14961,6 +15039,7 @@ window.AORTACServerCell=class AORTACServerCell{
14961
15039
  }
14962
15040
 
14963
15041
  /*private*/handleCommonListeners(){
15042
+
14964
15043
  // HANDLE CELL IS READY SEQUENCE
14965
15044
  this.handleCellIsReadySequence();
14966
15045
  // HANDLE PARTITION SEQUENCE
@@ -14975,6 +15054,10 @@ window.AORTACServerCell=class AORTACServerCell{
14975
15054
  // HANDLE RECONNECTED CLIENT HELLO SEQUENCE
14976
15055
  this.handleReconnectedClientHelloSequence();
14977
15056
 
15057
+
15058
+ this.modificationRequestHandler.handle();
15059
+ this.viewChangedRequestHandler.handle();
15060
+
14978
15061
  }
14979
15062
 
14980
15063
 
@@ -15662,12 +15745,6 @@ window.AORTACServerCell=class AORTACServerCell{
15662
15745
 
15663
15746
 
15664
15747
 
15665
-
15666
-
15667
-
15668
-
15669
-
15670
-
15671
15748
  /*private*/const ServerCellLobule=class{
15672
15749
 
15673
15750
  constructor(){
@@ -15735,7 +15812,6 @@ window.AORTACServerCell=class AORTACServerCell{
15735
15812
  }
15736
15813
 
15737
15814
 
15738
-
15739
15815
  window.getAORTACServerCell=function(quorumNumber=1, selfOrigin="ws://127.0.0.1:40000", outcomingCellsOrigins=[], model, controller){
15740
15816
  //return new AORTACServerNode("node_"+window.getUUID("short"), selfOrigin, outcomingCellsOrigins, model, controller);
15741
15817
  if(window.aortacCServerCellInstance){
@@ -15747,6 +15823,50 @@ window.getAORTACServerCell=function(quorumNumber=1, selfOrigin="ws://127.0.0.1:4
15747
15823
  }
15748
15824
 
15749
15825
 
15826
+ // ******************************************************************
15827
+
15828
+ window.getCurrentLevelConfigForAORTACServerCell=()=>{
15829
+ const allPrototypesConfig=PROTOTYPES_CONFIG.allPrototypes;
15830
+ const levelConfig=allPrototypesConfig.GameLevel;
15831
+
15832
+ const currentLevelPrototypeName=getCurrentLevelPrototypeNameForAORTACServerCell();
15833
+ if(nothing(currentLevelPrototypeName)){
15834
+ // TRACE
15835
+ lognow("WARN : No currentLevelPrototypeName found. Aborting.");
15836
+ return null;
15837
+ }
15838
+ const referenceCurrentLevelConfig=levelConfig[currentLevelPrototypeName];
15839
+ return referenceCurrentLevelConfig;
15840
+ };
15841
+
15842
+ window.getCurrentLevelPrototypeNameForAORTACServerCell=()=>{
15843
+
15844
+ const aortacConfig=GAME_CONFIG.aortac;
15845
+ if(nothing(aortacConfig)){
15846
+ // TRACE
15847
+ lognow("WARN : No AORTAC config, Aborting..");
15848
+ return null;
15849
+ }
15850
+
15851
+ const allPrototypesConfig=PROTOTYPES_CONFIG.allPrototypes;
15852
+ const levelConfig=allPrototypesConfig.GameLevel;
15853
+
15854
+ let currentLevelPrototypeName=aortacConfig.startingLevelPrototypeName;
15855
+ if(nothing(currentLevelPrototypeName)){
15856
+ currentLevelPrototypeName=getKeyAt(levelConfig,0);
15857
+ // TRACE
15858
+ lognow("WARN : No startingLevelPrototypeName specified in AORTAC config, using first level name as default «"+currentLevelPrototypeName+"».");
15859
+ }
15860
+
15861
+ return currentLevelPrototypeName;
15862
+ };
15863
+
15864
+
15865
+
15866
+
15867
+
15868
+
15869
+
15750
15870
 
15751
15871
 
15752
15872
  // ===============================================================================================================================
@@ -15863,46 +15983,6 @@ window.restoreNonProxiedClass=function(classToProxy){
15863
15983
 
15864
15984
 
15865
15985
 
15866
- // ******************************************************************
15867
-
15868
- window.getCurrentLevelConfigForAORTACServerCell=()=>{
15869
- const allPrototypesConfig=PROTOTYPES_CONFIG.allPrototypes;
15870
- const levelConfig=allPrototypesConfig.GameLevel;
15871
-
15872
- const currentLevelPrototypeName=getCurrentLevelPrototypeNameForAORTACServerCell();
15873
- if(nothing(currentLevelPrototypeName)){
15874
- // TRACE
15875
- lognow("WARN : No currentLevelPrototypeName found. Aborting.");
15876
- return null;
15877
- }
15878
- const referenceCurrentLevelConfig=levelConfig[currentLevelPrototypeName];
15879
- return referenceCurrentLevelConfig;
15880
- };
15881
-
15882
- window.getCurrentLevelPrototypeNameForAORTACServerCell=()=>{
15883
-
15884
- const aortacConfig=GAME_CONFIG.aortac;
15885
- if(nothing(aortacConfig)){
15886
- // TRACE
15887
- lognow("WARN : No AORTAC config, Aborting..");
15888
- return null;
15889
- }
15890
-
15891
- const allPrototypesConfig=PROTOTYPES_CONFIG.allPrototypes;
15892
- const levelConfig=allPrototypesConfig.GameLevel;
15893
-
15894
- let currentLevelPrototypeName=aortacConfig.startingLevelPrototypeName;
15895
- if(nothing(currentLevelPrototypeName)){
15896
- currentLevelPrototypeName=getKeyAt(levelConfig,0);
15897
- // TRACE
15898
- lognow("WARN : No startingLevelPrototypeName specified in AORTAC config, using first level name as default «"+currentLevelPrototypeName+"».");
15899
- }
15900
-
15901
- return currentLevelPrototypeName;
15902
- };
15903
-
15904
-
15905
-
15906
15986
 
15907
15987
 
15908
15988
  //
@@ -15955,6 +16035,56 @@ window.getCurrentLevelPrototypeNameForAORTACServerCell=()=>{
15955
16035
 
15956
16036
 
15957
16037
 
16038
+ /* ## Utility methods in a javascript, for AORTAC subsystem (server)
16039
+ *
16040
+ * This set of methods gathers utility generic-purpose methods usable in any JS project.
16041
+ * Several authors of snippets published freely on the Internet contributed to this library.
16042
+ * Feel free to use/modify-enhance/publish them under the terms of its license.
16043
+ *
16044
+ * # Library name : «aotrautils»
16045
+ * # Library license : HGPL(Help Burma) (see aotra README information for details : https://alqemia.com/aotra.js )
16046
+ * # Author name : Jérémie Ratomposon (massively helped by his native country free education system)
16047
+ * # Author email : info@alqemia.com
16048
+ * # Organization name : Alqemia
16049
+ * # Organization email : admin@alqemia.com
16050
+ * # Organization website : https://alqemia.com
16051
+ *
16052
+ *
16053
+ */
16054
+
16055
+
16056
+
16057
+ // COMPATIBILITY browser javascript / nodejs environment :
16058
+ if(typeof(window)==="undefined") window=global;
16059
+
16060
+
16061
+ // ==================================================================================================================
16062
+
16063
+
16064
+ // AORTAC SERVER CENTRALIZED PROTOCOL
16065
+
16066
+
16067
+ // CURRENT 2
16068
+ window.RelocateObjectHandler=class RelocateObjectHandler{
16069
+ constructor(serverCell){
16070
+ this.serverCell=serverCell;
16071
+ }
16072
+ }
16073
+
16074
+ window.ModificationRequestHandler=class ModificationRequestHandler{
16075
+ constructor(serverCell){
16076
+ this.serverCell=serverCell;
16077
+ this.relocateObjectHandler=new RelocateObjectHandler();
16078
+ }
16079
+ }
16080
+
16081
+ window.ViewChangedRequestHandler=class ViewChangedRequestHandler{
16082
+ constructor(serverCell){
16083
+ this.serverCell=serverCell;
16084
+ }
16085
+ }
16086
+
16087
+
15958
16088
  /* ## Utility methods in a javascript, for internationalzation (i18n) subsystem (server & client)
15959
16089
  *
15960
16090
  * This set of methods gathers utility generic-purpose methods usable in any JS project.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.1997",
3
+ "version": "0.0.2000",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "aotrautils",
9
- "version": "0.0.1997",
9
+ "version": "0.0.2000",
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.1997",
3
+ "version": "0.0.2000",
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)",