@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.cjs.js
CHANGED
|
@@ -24,7 +24,7 @@ function extend(components) {
|
|
|
24
24
|
|
|
25
25
|
const RESERVED = new Set(['children', 'key', 'ref']);
|
|
26
26
|
/** Props handled by the reconciler as flex item config, not forwarded to components */
|
|
27
|
-
const FLEX_ITEM_PROPS$1 = new Set(['flexGrow', 'flexShrink', 'layoutWidth', 'layoutHeight', 'alignSelf', 'flexExclude']);
|
|
27
|
+
const FLEX_ITEM_PROPS$1 = new Set(['flexGrow', 'flexShrink', 'layoutWidth', 'layoutHeight', 'alignSelf', 'flexExclude', 'top', 'right', 'bottom', 'left']);
|
|
28
28
|
// ─── UI Component helpers ────────────────────────────────
|
|
29
29
|
/**
|
|
30
30
|
* Extract a config object from React props.
|
|
@@ -446,6 +446,7 @@ class FlexContainer extends pixi_js.Container {
|
|
|
446
446
|
/** @internal */ _rawHeight;
|
|
447
447
|
_layoutChildren = [];
|
|
448
448
|
_layoutDirty = true;
|
|
449
|
+
_layoutSuspended = false;
|
|
449
450
|
constructor(config = {}) {
|
|
450
451
|
super();
|
|
451
452
|
this._config = {
|
|
@@ -507,7 +508,19 @@ class FlexContainer extends pixi_js.Container {
|
|
|
507
508
|
}
|
|
508
509
|
}
|
|
509
510
|
const result = super.addChild(...children);
|
|
510
|
-
if (this._layoutDirty)
|
|
511
|
+
if (this._layoutDirty && !this._layoutSuspended)
|
|
512
|
+
this.updateLayout();
|
|
513
|
+
return result;
|
|
514
|
+
}
|
|
515
|
+
addChildAt(child, index) {
|
|
516
|
+
if (!this._layoutChildren.includes(child)) {
|
|
517
|
+
// Insert into layout children at matching position
|
|
518
|
+
const layoutIndex = Math.min(index, this._layoutChildren.length);
|
|
519
|
+
this._layoutChildren.splice(layoutIndex, 0, child);
|
|
520
|
+
this._layoutDirty = true;
|
|
521
|
+
}
|
|
522
|
+
const result = super.addChildAt(child, index);
|
|
523
|
+
if (this._layoutDirty && !this._layoutSuspended)
|
|
511
524
|
this.updateLayout();
|
|
512
525
|
return result;
|
|
513
526
|
}
|
|
@@ -525,12 +538,23 @@ class FlexContainer extends pixi_js.Container {
|
|
|
525
538
|
get flexChildren() {
|
|
526
539
|
return this._layoutChildren;
|
|
527
540
|
}
|
|
541
|
+
/** Suspend automatic layout recalculation. Call resumeLayout() to flush. */
|
|
542
|
+
suspendLayout() {
|
|
543
|
+
this._layoutSuspended = true;
|
|
544
|
+
}
|
|
545
|
+
/** Resume automatic layout and flush if dirty. */
|
|
546
|
+
resumeLayout() {
|
|
547
|
+
this._layoutSuspended = false;
|
|
548
|
+
if (this._layoutDirty)
|
|
549
|
+
this.updateLayout();
|
|
550
|
+
}
|
|
528
551
|
/** Update the container size and recalculate layout */
|
|
529
552
|
resize(width, height) {
|
|
530
553
|
this._explicitWidth = width;
|
|
531
554
|
this._explicitHeight = height;
|
|
532
555
|
this._layoutDirty = true;
|
|
533
|
-
this.
|
|
556
|
+
if (!this._layoutSuspended)
|
|
557
|
+
this.updateLayout();
|
|
534
558
|
}
|
|
535
559
|
/** Update layout direction */
|
|
536
560
|
setDirection(direction) {
|
|
@@ -563,6 +587,10 @@ class FlexContainer extends pixi_js.Container {
|
|
|
563
587
|
* adding/removing children without resize.
|
|
564
588
|
*/
|
|
565
589
|
updateLayout() {
|
|
590
|
+
if (this._layoutSuspended) {
|
|
591
|
+
this._layoutDirty = true;
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
566
594
|
this._layoutDirty = false;
|
|
567
595
|
const { direction, justifyContent, alignItems, gap, flexWrap, alignContent } = this._config;
|
|
568
596
|
const [pt, pr, pb, pl] = this._padding;
|
|
@@ -771,11 +799,12 @@ class FlexContainer extends pixi_js.Container {
|
|
|
771
799
|
this._explicitWidth = typeof w === 'number' ? w : 0;
|
|
772
800
|
this._explicitHeight = typeof h === 'number' ? h : 0;
|
|
773
801
|
this._layoutDirty = true;
|
|
774
|
-
this.
|
|
802
|
+
if (!this._layoutSuspended)
|
|
803
|
+
this.updateLayout();
|
|
775
804
|
}
|
|
776
805
|
return;
|
|
777
806
|
}
|
|
778
|
-
if (this._layoutDirty)
|
|
807
|
+
if (this._layoutDirty && !this._layoutSuspended)
|
|
779
808
|
this.updateLayout();
|
|
780
809
|
}
|
|
781
810
|
destroy(options) {
|
|
@@ -786,6 +815,11 @@ class FlexContainer extends pixi_js.Container {
|
|
|
786
815
|
|
|
787
816
|
/** Flex item prop names that should be forwarded to _flexConfig on the child */
|
|
788
817
|
const FLEX_ITEM_PROPS = ['flexGrow', 'flexShrink', 'layoutWidth', 'layoutHeight', 'alignSelf', 'flexExclude', 'top', 'right', 'bottom', 'left'];
|
|
818
|
+
function isSuspendable(obj) {
|
|
819
|
+
return typeof obj?.suspendLayout === 'function' && typeof obj?.resumeLayout === 'function';
|
|
820
|
+
}
|
|
821
|
+
/** Layout containers that need flush after commit phase */
|
|
822
|
+
const pendingLayoutFlush = new Set();
|
|
789
823
|
/** Extract FlexItemConfig from props if any flex item props are present */
|
|
790
824
|
function extractFlexItemConfig(props) {
|
|
791
825
|
let config;
|
|
@@ -850,6 +884,8 @@ const hostConfig = {
|
|
|
850
884
|
},
|
|
851
885
|
appendInitialChild(parent, child) {
|
|
852
886
|
if (child instanceof pixi_js.Container) {
|
|
887
|
+
if (isSuspendable(parent))
|
|
888
|
+
parent.suspendLayout();
|
|
853
889
|
if (parent instanceof FlexContainer) {
|
|
854
890
|
addChildToFlex(parent, child);
|
|
855
891
|
}
|
|
@@ -860,6 +896,10 @@ const hostConfig = {
|
|
|
860
896
|
},
|
|
861
897
|
appendChild(parent, child) {
|
|
862
898
|
if (child instanceof pixi_js.Container) {
|
|
899
|
+
if (isSuspendable(parent)) {
|
|
900
|
+
parent.suspendLayout();
|
|
901
|
+
pendingLayoutFlush.add(parent);
|
|
902
|
+
}
|
|
863
903
|
if (parent instanceof FlexContainer) {
|
|
864
904
|
addChildToFlex(parent, child);
|
|
865
905
|
}
|
|
@@ -874,6 +914,10 @@ const hostConfig = {
|
|
|
874
914
|
},
|
|
875
915
|
removeChild(parent, child) {
|
|
876
916
|
if (child instanceof pixi_js.Container) {
|
|
917
|
+
if (isSuspendable(parent)) {
|
|
918
|
+
parent.suspendLayout();
|
|
919
|
+
pendingLayoutFlush.add(parent);
|
|
920
|
+
}
|
|
877
921
|
parent.removeChild(child);
|
|
878
922
|
child.destroy({ children: true });
|
|
879
923
|
}
|
|
@@ -888,6 +932,10 @@ const hostConfig = {
|
|
|
888
932
|
if (child instanceof pixi_js.Container && beforeChild instanceof pixi_js.Container) {
|
|
889
933
|
if (child.parent)
|
|
890
934
|
child.parent.removeChild(child);
|
|
935
|
+
if (isSuspendable(parent)) {
|
|
936
|
+
parent.suspendLayout();
|
|
937
|
+
pendingLayoutFlush.add(parent);
|
|
938
|
+
}
|
|
891
939
|
const index = parent.getChildIndex(beforeChild);
|
|
892
940
|
parent.addChildAt(child, index);
|
|
893
941
|
}
|
|
@@ -925,7 +973,11 @@ const hostConfig = {
|
|
|
925
973
|
instance.eventMode = 'static';
|
|
926
974
|
}
|
|
927
975
|
},
|
|
928
|
-
finalizeInitialChildren() {
|
|
976
|
+
finalizeInitialChildren(instance) {
|
|
977
|
+
// Resume layout after all initial children have been appended
|
|
978
|
+
if (isSuspendable(instance)) {
|
|
979
|
+
instance.resumeLayout();
|
|
980
|
+
}
|
|
929
981
|
return false;
|
|
930
982
|
},
|
|
931
983
|
prepareUpdate() {
|
|
@@ -946,7 +998,13 @@ const hostConfig = {
|
|
|
946
998
|
prepareForCommit() {
|
|
947
999
|
return null;
|
|
948
1000
|
},
|
|
949
|
-
resetAfterCommit() {
|
|
1001
|
+
resetAfterCommit() {
|
|
1002
|
+
// Flush deferred layout for all FlexContainers modified during this commit
|
|
1003
|
+
for (const fc of pendingLayoutFlush) {
|
|
1004
|
+
fc.resumeLayout();
|
|
1005
|
+
}
|
|
1006
|
+
pendingLayoutFlush.clear();
|
|
1007
|
+
},
|
|
950
1008
|
preparePortalMount() { },
|
|
951
1009
|
scheduleTimeout: setTimeout,
|
|
952
1010
|
cancelTimeout: clearTimeout,
|
|
@@ -1774,6 +1832,14 @@ class Panel extends pixi_js.Container {
|
|
|
1774
1832
|
get content() {
|
|
1775
1833
|
return this._content;
|
|
1776
1834
|
}
|
|
1835
|
+
/** Suspend content layout recalculation. Call resumeLayout() to flush. */
|
|
1836
|
+
suspendLayout() {
|
|
1837
|
+
this._content.suspendLayout();
|
|
1838
|
+
}
|
|
1839
|
+
/** Resume content layout and flush if dirty. */
|
|
1840
|
+
resumeLayout() {
|
|
1841
|
+
this._content.resumeLayout();
|
|
1842
|
+
}
|
|
1777
1843
|
/** Convenience: add a child to the content layout */
|
|
1778
1844
|
addContent(child) {
|
|
1779
1845
|
this._content.addFlexChild(child);
|