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