@netless/telebox-insider 0.3.0-beta.1 → 0.3.0-beta.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.
@@ -2416,20 +2416,26 @@ class MaxTitleBar extends DefaultTitleBar {
2416
2416
  this.focusedBox = config.focusedBox;
2417
2417
  this.containerRect = config.containerRect;
2418
2418
  this.darkMode = config.darkMode;
2419
- this.boxesStatus = config.boxesStatus;
2419
+ this.getBoxesStatus = config.getBoxesStatus;
2420
2420
  }
2421
2421
  hasMaximizedBoxInStatus() {
2422
- if (!this.boxesStatus || this.boxesStatus.size === 0) {
2423
- return false;
2422
+ if (this.getBoxesStatus) {
2423
+ const boxesStatus = this.getBoxesStatus();
2424
+ if (boxesStatus.size) {
2425
+ const hasMaximizedBox = [...boxesStatus.values()].find((state) => state === TELE_BOX_STATE.Maximized);
2426
+ return !!hasMaximizedBox;
2427
+ }
2424
2428
  }
2425
- const hasMaximizedBox = [...this.boxesStatus.values()].find((state) => state === TELE_BOX_STATE.Maximized);
2426
- return !!hasMaximizedBox;
2429
+ return false;
2427
2430
  }
2428
2431
  get MaximizedBoxes() {
2429
- if (!this.boxesStatus || this.boxesStatus.size === 0) {
2430
- return [];
2432
+ if (this.getBoxesStatus) {
2433
+ const boxesStatus = this.getBoxesStatus();
2434
+ if (boxesStatus) {
2435
+ return this.boxes.filter((box) => boxesStatus && boxesStatus.get(box.id) === TELE_BOX_STATE.Maximized);
2436
+ }
2431
2437
  }
2432
- return this.boxes.filter((box) => this.boxesStatus && this.boxesStatus.get(box.id) === TELE_BOX_STATE.Maximized);
2438
+ return [];
2433
2439
  }
2434
2440
  focusBox(box) {
2435
2441
  var _a, _b;
@@ -2474,8 +2480,7 @@ class MaxTitleBar extends DefaultTitleBar {
2474
2480
  this.$titleBar.style.width = width + "px";
2475
2481
  }
2476
2482
  }
2477
- setBoxesStatus(boxesStatus) {
2478
- this.boxesStatus = boxesStatus;
2483
+ updateBoxesStatus() {
2479
2484
  if (this.hasMaximizedBoxInStatus()) {
2480
2485
  this.setBoxStatus(TELE_BOX_STATE.Maximized);
2481
2486
  }
@@ -2768,7 +2773,9 @@ class TeleBoxManager {
2768
2773
  state: state$.value,
2769
2774
  boxes: this.boxes$.value,
2770
2775
  containerRect: containerRect$.value,
2771
- boxesStatus: this.boxesStatus$,
2776
+ getBoxesStatus: () => {
2777
+ return this.boxesStatus$;
2778
+ },
2772
2779
  onEvent: (event) => {
2773
2780
  var _a, _b, _c;
2774
2781
  switch (event.type) {
@@ -2877,6 +2884,7 @@ class TeleBoxManager {
2877
2884
  }
2878
2885
  setBoxesStatus(boxesStatus, skipUpdate = false) {
2879
2886
  var _a, _b, _c, _d;
2887
+ this.boxesStatus$ = boxesStatus;
2880
2888
  let topBox;
2881
2889
  const topBoxId = (_a = this.topBox) == null ? void 0 : _a.id;
2882
2890
  let hasMinimizedBox = false;
@@ -2903,11 +2911,11 @@ class TeleBoxManager {
2903
2911
  }
2904
2912
  if (topBox && topBoxId !== topBox.id) {
2905
2913
  this.makeBoxTop(topBox, skipUpdate);
2906
- this.focusTopBox();
2907
2914
  this.topBox$.setValue(topBox);
2915
+ this.focusTopBox();
2908
2916
  }
2909
2917
  if (this.maxTitleBar) {
2910
- this.maxTitleBar.setBoxesStatus(boxesStatus);
2918
+ this.maxTitleBar.updateBoxesStatus();
2911
2919
  }
2912
2920
  }
2913
2921
  hasBoxesStatus() {
@@ -2929,6 +2937,7 @@ class TeleBoxManager {
2929
2937
  }
2930
2938
  }
2931
2939
  setLastNotMinimizedBoxesStatus(lastNotMinimizedBoxesStatus, skipUpdate = false) {
2940
+ this.lastNotMinimizedBoxesStatus$ = lastNotMinimizedBoxesStatus;
2932
2941
  this.boxes.forEach((box) => {
2933
2942
  const boxStatus = lastNotMinimizedBoxesStatus.get(box.id);
2934
2943
  if (boxStatus) {
@@ -3069,6 +3078,10 @@ class TeleBoxManager {
3069
3078
  const deletedBoxes = boxes.splice(index2, 1);
3070
3079
  this.boxes$.setValue(boxes);
3071
3080
  deletedBoxes.forEach((box2) => box2.destroy());
3081
+ if (box) {
3082
+ this.boxesStatus$.delete(box.id);
3083
+ this.lastNotMinimizedBoxesStatus$.delete(box.id);
3084
+ }
3072
3085
  if (!skipUpdate) {
3073
3086
  if (this.boxes.length <= 0) {
3074
3087
  this.setMaximized(false);