@energy8platform/game-engine 0.14.1 → 0.14.3
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.
- package/dist/index.cjs.js +41 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.esm.js +41 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/react.cjs.js +73 -7
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.esm.js +73 -7
- package/dist/react.esm.js.map +1 -1
- package/dist/ui.cjs.js +41 -4
- package/dist/ui.cjs.js.map +1 -1
- package/dist/ui.d.ts +10 -0
- package/dist/ui.esm.js +41 -4
- package/dist/ui.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/react/applyProps.ts +1 -1
- package/src/react/reconciler.ts +38 -2
- package/src/ui/FlexContainer.ts +32 -4
- package/src/ui/Panel.ts +10 -0
package/dist/react.esm.js
CHANGED
|
@@ -22,7 +22,7 @@ function extend(components) {
|
|
|
22
22
|
|
|
23
23
|
const RESERVED = new Set(['children', 'key', 'ref']);
|
|
24
24
|
/** Props handled by the reconciler as flex item config, not forwarded to components */
|
|
25
|
-
const FLEX_ITEM_PROPS$1 = new Set(['flexGrow', 'flexShrink', 'layoutWidth', 'layoutHeight', 'alignSelf', 'flexExclude']);
|
|
25
|
+
const FLEX_ITEM_PROPS$1 = new Set(['flexGrow', 'flexShrink', 'layoutWidth', 'layoutHeight', 'alignSelf', 'flexExclude', 'top', 'right', 'bottom', 'left']);
|
|
26
26
|
// ─── UI Component helpers ────────────────────────────────
|
|
27
27
|
/**
|
|
28
28
|
* Extract a config object from React props.
|
|
@@ -444,6 +444,7 @@ class FlexContainer extends Container {
|
|
|
444
444
|
/** @internal */ _rawHeight;
|
|
445
445
|
_layoutChildren = [];
|
|
446
446
|
_layoutDirty = true;
|
|
447
|
+
_layoutSuspended = false;
|
|
447
448
|
constructor(config = {}) {
|
|
448
449
|
super();
|
|
449
450
|
this._config = {
|
|
@@ -505,7 +506,19 @@ class FlexContainer extends Container {
|
|
|
505
506
|
}
|
|
506
507
|
}
|
|
507
508
|
const result = super.addChild(...children);
|
|
508
|
-
if (this._layoutDirty)
|
|
509
|
+
if (this._layoutDirty && !this._layoutSuspended)
|
|
510
|
+
this.updateLayout();
|
|
511
|
+
return result;
|
|
512
|
+
}
|
|
513
|
+
addChildAt(child, index) {
|
|
514
|
+
if (!this._layoutChildren.includes(child)) {
|
|
515
|
+
// Insert into layout children at matching position
|
|
516
|
+
const layoutIndex = Math.min(index, this._layoutChildren.length);
|
|
517
|
+
this._layoutChildren.splice(layoutIndex, 0, child);
|
|
518
|
+
this._layoutDirty = true;
|
|
519
|
+
}
|
|
520
|
+
const result = super.addChildAt(child, index);
|
|
521
|
+
if (this._layoutDirty && !this._layoutSuspended)
|
|
509
522
|
this.updateLayout();
|
|
510
523
|
return result;
|
|
511
524
|
}
|
|
@@ -523,12 +536,23 @@ class FlexContainer extends Container {
|
|
|
523
536
|
get flexChildren() {
|
|
524
537
|
return this._layoutChildren;
|
|
525
538
|
}
|
|
539
|
+
/** Suspend automatic layout recalculation. Call resumeLayout() to flush. */
|
|
540
|
+
suspendLayout() {
|
|
541
|
+
this._layoutSuspended = true;
|
|
542
|
+
}
|
|
543
|
+
/** Resume automatic layout and flush if dirty. */
|
|
544
|
+
resumeLayout() {
|
|
545
|
+
this._layoutSuspended = false;
|
|
546
|
+
if (this._layoutDirty)
|
|
547
|
+
this.updateLayout();
|
|
548
|
+
}
|
|
526
549
|
/** Update the container size and recalculate layout */
|
|
527
550
|
resize(width, height) {
|
|
528
551
|
this._explicitWidth = width;
|
|
529
552
|
this._explicitHeight = height;
|
|
530
553
|
this._layoutDirty = true;
|
|
531
|
-
this.
|
|
554
|
+
if (!this._layoutSuspended)
|
|
555
|
+
this.updateLayout();
|
|
532
556
|
}
|
|
533
557
|
/** Update layout direction */
|
|
534
558
|
setDirection(direction) {
|
|
@@ -561,6 +585,10 @@ class FlexContainer extends Container {
|
|
|
561
585
|
* adding/removing children without resize.
|
|
562
586
|
*/
|
|
563
587
|
updateLayout() {
|
|
588
|
+
if (this._layoutSuspended) {
|
|
589
|
+
this._layoutDirty = true;
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
564
592
|
this._layoutDirty = false;
|
|
565
593
|
const { direction, justifyContent, alignItems, gap, flexWrap, alignContent } = this._config;
|
|
566
594
|
const [pt, pr, pb, pl] = this._padding;
|
|
@@ -769,11 +797,12 @@ class FlexContainer extends Container {
|
|
|
769
797
|
this._explicitWidth = typeof w === 'number' ? w : 0;
|
|
770
798
|
this._explicitHeight = typeof h === 'number' ? h : 0;
|
|
771
799
|
this._layoutDirty = true;
|
|
772
|
-
this.
|
|
800
|
+
if (!this._layoutSuspended)
|
|
801
|
+
this.updateLayout();
|
|
773
802
|
}
|
|
774
803
|
return;
|
|
775
804
|
}
|
|
776
|
-
if (this._layoutDirty)
|
|
805
|
+
if (this._layoutDirty && !this._layoutSuspended)
|
|
777
806
|
this.updateLayout();
|
|
778
807
|
}
|
|
779
808
|
destroy(options) {
|
|
@@ -784,6 +813,11 @@ class FlexContainer extends Container {
|
|
|
784
813
|
|
|
785
814
|
/** Flex item prop names that should be forwarded to _flexConfig on the child */
|
|
786
815
|
const FLEX_ITEM_PROPS = ['flexGrow', 'flexShrink', 'layoutWidth', 'layoutHeight', 'alignSelf', 'flexExclude', 'top', 'right', 'bottom', 'left'];
|
|
816
|
+
function isSuspendable(obj) {
|
|
817
|
+
return typeof obj?.suspendLayout === 'function' && typeof obj?.resumeLayout === 'function';
|
|
818
|
+
}
|
|
819
|
+
/** Layout containers that need flush after commit phase */
|
|
820
|
+
const pendingLayoutFlush = new Set();
|
|
787
821
|
/** Extract FlexItemConfig from props if any flex item props are present */
|
|
788
822
|
function extractFlexItemConfig(props) {
|
|
789
823
|
let config;
|
|
@@ -848,6 +882,8 @@ const hostConfig = {
|
|
|
848
882
|
},
|
|
849
883
|
appendInitialChild(parent, child) {
|
|
850
884
|
if (child instanceof Container) {
|
|
885
|
+
if (isSuspendable(parent))
|
|
886
|
+
parent.suspendLayout();
|
|
851
887
|
if (parent instanceof FlexContainer) {
|
|
852
888
|
addChildToFlex(parent, child);
|
|
853
889
|
}
|
|
@@ -858,6 +894,10 @@ const hostConfig = {
|
|
|
858
894
|
},
|
|
859
895
|
appendChild(parent, child) {
|
|
860
896
|
if (child instanceof Container) {
|
|
897
|
+
if (isSuspendable(parent)) {
|
|
898
|
+
parent.suspendLayout();
|
|
899
|
+
pendingLayoutFlush.add(parent);
|
|
900
|
+
}
|
|
861
901
|
if (parent instanceof FlexContainer) {
|
|
862
902
|
addChildToFlex(parent, child);
|
|
863
903
|
}
|
|
@@ -872,6 +912,10 @@ const hostConfig = {
|
|
|
872
912
|
},
|
|
873
913
|
removeChild(parent, child) {
|
|
874
914
|
if (child instanceof Container) {
|
|
915
|
+
if (isSuspendable(parent)) {
|
|
916
|
+
parent.suspendLayout();
|
|
917
|
+
pendingLayoutFlush.add(parent);
|
|
918
|
+
}
|
|
875
919
|
parent.removeChild(child);
|
|
876
920
|
child.destroy({ children: true });
|
|
877
921
|
}
|
|
@@ -886,6 +930,10 @@ const hostConfig = {
|
|
|
886
930
|
if (child instanceof Container && beforeChild instanceof Container) {
|
|
887
931
|
if (child.parent)
|
|
888
932
|
child.parent.removeChild(child);
|
|
933
|
+
if (isSuspendable(parent)) {
|
|
934
|
+
parent.suspendLayout();
|
|
935
|
+
pendingLayoutFlush.add(parent);
|
|
936
|
+
}
|
|
889
937
|
const index = parent.getChildIndex(beforeChild);
|
|
890
938
|
parent.addChildAt(child, index);
|
|
891
939
|
}
|
|
@@ -923,7 +971,11 @@ const hostConfig = {
|
|
|
923
971
|
instance.eventMode = 'static';
|
|
924
972
|
}
|
|
925
973
|
},
|
|
926
|
-
finalizeInitialChildren() {
|
|
974
|
+
finalizeInitialChildren(instance) {
|
|
975
|
+
// Resume layout after all initial children have been appended
|
|
976
|
+
if (isSuspendable(instance)) {
|
|
977
|
+
instance.resumeLayout();
|
|
978
|
+
}
|
|
927
979
|
return false;
|
|
928
980
|
},
|
|
929
981
|
prepareUpdate() {
|
|
@@ -944,7 +996,13 @@ const hostConfig = {
|
|
|
944
996
|
prepareForCommit() {
|
|
945
997
|
return null;
|
|
946
998
|
},
|
|
947
|
-
resetAfterCommit() {
|
|
999
|
+
resetAfterCommit() {
|
|
1000
|
+
// Flush deferred layout for all FlexContainers modified during this commit
|
|
1001
|
+
for (const fc of pendingLayoutFlush) {
|
|
1002
|
+
fc.resumeLayout();
|
|
1003
|
+
}
|
|
1004
|
+
pendingLayoutFlush.clear();
|
|
1005
|
+
},
|
|
948
1006
|
preparePortalMount() { },
|
|
949
1007
|
scheduleTimeout: setTimeout,
|
|
950
1008
|
cancelTimeout: clearTimeout,
|
|
@@ -1772,6 +1830,14 @@ class Panel extends Container {
|
|
|
1772
1830
|
get content() {
|
|
1773
1831
|
return this._content;
|
|
1774
1832
|
}
|
|
1833
|
+
/** Suspend content layout recalculation. Call resumeLayout() to flush. */
|
|
1834
|
+
suspendLayout() {
|
|
1835
|
+
this._content.suspendLayout();
|
|
1836
|
+
}
|
|
1837
|
+
/** Resume content layout and flush if dirty. */
|
|
1838
|
+
resumeLayout() {
|
|
1839
|
+
this._content.resumeLayout();
|
|
1840
|
+
}
|
|
1775
1841
|
/** Convenience: add a child to the content layout */
|
|
1776
1842
|
addContent(child) {
|
|
1777
1843
|
this._content.addFlexChild(child);
|