@energy8platform/game-engine 0.14.2 → 0.14.4

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/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.
@@ -551,7 +551,8 @@ class FlexContainer extends Container {
551
551
  this._explicitWidth = width;
552
552
  this._explicitHeight = height;
553
553
  this._layoutDirty = true;
554
- this.updateLayout();
554
+ if (!this._layoutSuspended)
555
+ this.updateLayout();
555
556
  }
556
557
  /** Update layout direction */
557
558
  setDirection(direction) {
@@ -584,6 +585,10 @@ class FlexContainer extends Container {
584
585
  * adding/removing children without resize.
585
586
  */
586
587
  updateLayout() {
588
+ if (this._layoutSuspended) {
589
+ this._layoutDirty = true;
590
+ return;
591
+ }
587
592
  this._layoutDirty = false;
588
593
  const { direction, justifyContent, alignItems, gap, flexWrap, alignContent } = this._config;
589
594
  const [pt, pr, pb, pl] = this._padding;
@@ -792,11 +797,12 @@ class FlexContainer extends Container {
792
797
  this._explicitWidth = typeof w === 'number' ? w : 0;
793
798
  this._explicitHeight = typeof h === 'number' ? h : 0;
794
799
  this._layoutDirty = true;
795
- this.updateLayout();
800
+ if (!this._layoutSuspended)
801
+ this.updateLayout();
796
802
  }
797
803
  return;
798
804
  }
799
- if (this._layoutDirty)
805
+ if (this._layoutDirty && !this._layoutSuspended)
800
806
  this.updateLayout();
801
807
  }
802
808
  destroy(options) {
@@ -807,7 +813,10 @@ class FlexContainer extends Container {
807
813
 
808
814
  /** Flex item prop names that should be forwarded to _flexConfig on the child */
809
815
  const FLEX_ITEM_PROPS = ['flexGrow', 'flexShrink', 'layoutWidth', 'layoutHeight', 'alignSelf', 'flexExclude', 'top', 'right', 'bottom', 'left'];
810
- /** FlexContainers that need layout flush after commit phase */
816
+ function isSuspendable(obj) {
817
+ return typeof obj?.suspendLayout === 'function' && typeof obj?.resumeLayout === 'function';
818
+ }
819
+ /** Layout containers that need flush after commit phase */
811
820
  const pendingLayoutFlush = new Set();
812
821
  /** Extract FlexItemConfig from props if any flex item props are present */
813
822
  function extractFlexItemConfig(props) {
@@ -873,8 +882,9 @@ const hostConfig = {
873
882
  },
874
883
  appendInitialChild(parent, child) {
875
884
  if (child instanceof Container) {
876
- if (parent instanceof FlexContainer) {
885
+ if (isSuspendable(parent))
877
886
  parent.suspendLayout();
887
+ if (parent instanceof FlexContainer) {
878
888
  addChildToFlex(parent, child);
879
889
  }
880
890
  else {
@@ -884,9 +894,11 @@ const hostConfig = {
884
894
  },
885
895
  appendChild(parent, child) {
886
896
  if (child instanceof Container) {
887
- if (parent instanceof FlexContainer) {
897
+ if (isSuspendable(parent)) {
888
898
  parent.suspendLayout();
889
899
  pendingLayoutFlush.add(parent);
900
+ }
901
+ if (parent instanceof FlexContainer) {
890
902
  addChildToFlex(parent, child);
891
903
  }
892
904
  else {
@@ -900,7 +912,7 @@ const hostConfig = {
900
912
  },
901
913
  removeChild(parent, child) {
902
914
  if (child instanceof Container) {
903
- if (parent instanceof FlexContainer) {
915
+ if (isSuspendable(parent)) {
904
916
  parent.suspendLayout();
905
917
  pendingLayoutFlush.add(parent);
906
918
  }
@@ -918,7 +930,7 @@ const hostConfig = {
918
930
  if (child instanceof Container && beforeChild instanceof Container) {
919
931
  if (child.parent)
920
932
  child.parent.removeChild(child);
921
- if (parent instanceof FlexContainer) {
933
+ if (isSuspendable(parent)) {
922
934
  parent.suspendLayout();
923
935
  pendingLayoutFlush.add(parent);
924
936
  }
@@ -961,7 +973,7 @@ const hostConfig = {
961
973
  },
962
974
  finalizeInitialChildren(instance) {
963
975
  // Resume layout after all initial children have been appended
964
- if (instance instanceof FlexContainer) {
976
+ if (isSuspendable(instance)) {
965
977
  instance.resumeLayout();
966
978
  }
967
979
  return false;
@@ -1818,6 +1830,14 @@ class Panel extends Container {
1818
1830
  get content() {
1819
1831
  return this._content;
1820
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
+ }
1821
1841
  /** Convenience: add a child to the content layout */
1822
1842
  addContent(child) {
1823
1843
  this._content.addFlexChild(child);
@@ -2121,6 +2141,7 @@ class Modal extends Container {
2121
2141
  _contentContainer;
2122
2142
  _config;
2123
2143
  _showing = false;
2144
+ _internalSetup = true;
2124
2145
  /** Called when the modal is closed */
2125
2146
  onClose;
2126
2147
  constructor(config = {}) {
@@ -2142,11 +2163,34 @@ class Modal extends Container {
2142
2163
  this._contentContainer = new Container();
2143
2164
  this.addChild(this._contentContainer);
2144
2165
  this.visible = false;
2166
+ this._internalSetup = false;
2145
2167
  }
2146
2168
  /** Content container — add your UI here */
2147
2169
  get content() {
2148
2170
  return this._contentContainer;
2149
2171
  }
2172
+ /**
2173
+ * Override addChild so external children are routed to _contentContainer.
2174
+ * Enables `<modal><flexContainer>...</flexContainer></modal>` in React JSX.
2175
+ */
2176
+ addChild(...children) {
2177
+ if (this._internalSetup) {
2178
+ return super.addChild(...children);
2179
+ }
2180
+ for (const child of children) {
2181
+ this._contentContainer.addChild(child);
2182
+ }
2183
+ return children[0];
2184
+ }
2185
+ removeChild(...children) {
2186
+ if (this._internalSetup) {
2187
+ return super.removeChild(...children);
2188
+ }
2189
+ for (const child of children) {
2190
+ this._contentContainer.removeChild(child);
2191
+ }
2192
+ return children[0];
2193
+ }
2150
2194
  /** Whether the modal is currently showing */
2151
2195
  get isShowing() {
2152
2196
  return this._showing;