@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.d.ts CHANGED
@@ -1355,6 +1355,7 @@ declare class FlexContainer extends Container {
1355
1355
  /** @internal */ _rawHeight: number | string;
1356
1356
  private _layoutChildren;
1357
1357
  private _layoutDirty;
1358
+ private _layoutSuspended;
1358
1359
  constructor(config?: FlexContainerConfig);
1359
1360
  /** Add a child with optional flex config. Also registers in flex layout. */
1360
1361
  addFlexChild(child: Container, flexConfig?: FlexItemConfig): this;
@@ -1367,9 +1368,14 @@ declare class FlexContainer extends Container {
1367
1368
  * This enables declarative usage from React JSX.
1368
1369
  */
1369
1370
  addChild<T extends Container>(...children: T[]): T;
1371
+ addChildAt<T extends Container>(child: T, index: number): T;
1370
1372
  removeChild<T extends Container>(...children: T[]): T;
1371
1373
  /** Get all flex layout children (read-only) */
1372
1374
  get flexChildren(): readonly Container[];
1375
+ /** Suspend automatic layout recalculation. Call resumeLayout() to flush. */
1376
+ suspendLayout(): void;
1377
+ /** Resume automatic layout and flush if dirty. */
1378
+ resumeLayout(): void;
1373
1379
  /** Update the container size and recalculate layout */
1374
1380
  resize(width: number, height: number): void;
1375
1381
  /** Update layout direction */
@@ -1687,6 +1693,10 @@ declare class Panel extends Container {
1687
1693
  constructor(config?: PanelConfig);
1688
1694
  /** Access the content flex container — add children here for layout */
1689
1695
  get content(): FlexContainer;
1696
+ /** Suspend content layout recalculation. Call resumeLayout() to flush. */
1697
+ suspendLayout(): void;
1698
+ /** Resume content layout and flush if dirty. */
1699
+ resumeLayout(): void;
1690
1700
  /** Convenience: add a child to the content layout */
1691
1701
  addContent(child: Container): this;
1692
1702
  /** Resize the panel */
package/dist/index.esm.js CHANGED
@@ -3150,6 +3150,7 @@ class FlexContainer extends Container {
3150
3150
  /** @internal */ _rawHeight;
3151
3151
  _layoutChildren = [];
3152
3152
  _layoutDirty = true;
3153
+ _layoutSuspended = false;
3153
3154
  constructor(config = {}) {
3154
3155
  super();
3155
3156
  this._config = {
@@ -3211,7 +3212,19 @@ class FlexContainer extends Container {
3211
3212
  }
3212
3213
  }
3213
3214
  const result = super.addChild(...children);
3214
- if (this._layoutDirty)
3215
+ if (this._layoutDirty && !this._layoutSuspended)
3216
+ this.updateLayout();
3217
+ return result;
3218
+ }
3219
+ addChildAt(child, index) {
3220
+ if (!this._layoutChildren.includes(child)) {
3221
+ // Insert into layout children at matching position
3222
+ const layoutIndex = Math.min(index, this._layoutChildren.length);
3223
+ this._layoutChildren.splice(layoutIndex, 0, child);
3224
+ this._layoutDirty = true;
3225
+ }
3226
+ const result = super.addChildAt(child, index);
3227
+ if (this._layoutDirty && !this._layoutSuspended)
3215
3228
  this.updateLayout();
3216
3229
  return result;
3217
3230
  }
@@ -3229,12 +3242,23 @@ class FlexContainer extends Container {
3229
3242
  get flexChildren() {
3230
3243
  return this._layoutChildren;
3231
3244
  }
3245
+ /** Suspend automatic layout recalculation. Call resumeLayout() to flush. */
3246
+ suspendLayout() {
3247
+ this._layoutSuspended = true;
3248
+ }
3249
+ /** Resume automatic layout and flush if dirty. */
3250
+ resumeLayout() {
3251
+ this._layoutSuspended = false;
3252
+ if (this._layoutDirty)
3253
+ this.updateLayout();
3254
+ }
3232
3255
  /** Update the container size and recalculate layout */
3233
3256
  resize(width, height) {
3234
3257
  this._explicitWidth = width;
3235
3258
  this._explicitHeight = height;
3236
3259
  this._layoutDirty = true;
3237
- this.updateLayout();
3260
+ if (!this._layoutSuspended)
3261
+ this.updateLayout();
3238
3262
  }
3239
3263
  /** Update layout direction */
3240
3264
  setDirection(direction) {
@@ -3267,6 +3291,10 @@ class FlexContainer extends Container {
3267
3291
  * adding/removing children without resize.
3268
3292
  */
3269
3293
  updateLayout() {
3294
+ if (this._layoutSuspended) {
3295
+ this._layoutDirty = true;
3296
+ return;
3297
+ }
3270
3298
  this._layoutDirty = false;
3271
3299
  const { direction, justifyContent, alignItems, gap, flexWrap, alignContent } = this._config;
3272
3300
  const [pt, pr, pb, pl] = this._padding;
@@ -3475,11 +3503,12 @@ class FlexContainer extends Container {
3475
3503
  this._explicitWidth = typeof w === 'number' ? w : 0;
3476
3504
  this._explicitHeight = typeof h === 'number' ? h : 0;
3477
3505
  this._layoutDirty = true;
3478
- this.updateLayout();
3506
+ if (!this._layoutSuspended)
3507
+ this.updateLayout();
3479
3508
  }
3480
3509
  return;
3481
3510
  }
3482
- if (this._layoutDirty)
3511
+ if (this._layoutDirty && !this._layoutSuspended)
3483
3512
  this.updateLayout();
3484
3513
  }
3485
3514
  destroy(options) {
@@ -4062,6 +4091,14 @@ class Panel extends Container {
4062
4091
  get content() {
4063
4092
  return this._content;
4064
4093
  }
4094
+ /** Suspend content layout recalculation. Call resumeLayout() to flush. */
4095
+ suspendLayout() {
4096
+ this._content.suspendLayout();
4097
+ }
4098
+ /** Resume content layout and flush if dirty. */
4099
+ resumeLayout() {
4100
+ this._content.resumeLayout();
4101
+ }
4065
4102
  /** Convenience: add a child to the content layout */
4066
4103
  addContent(child) {
4067
4104
  this._content.addFlexChild(child);