@netless/telebox-insider 0.3.0-beta.5 → 0.3.0-beta.7

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.
@@ -30,6 +30,7 @@ import {
30
30
  ValEnhancedResult,
31
31
  withValueEnhancer,
32
32
  } from "value-enhancer";
33
+ import { AppMenu } from "../AppMenu";
33
34
 
34
35
  export * from "./typings";
35
36
  export * from "./constants";
@@ -49,13 +50,17 @@ export interface TeleBoxManager extends ValEnhancedResult<ValConfig> {}
49
50
  export class TeleBoxManager {
50
51
  private boxesStatus$: Map<string, TeleBoxState>;
51
52
  private lastNotMinimizedBoxesStatus$: Map<string, NotMinimizedBoxState>;
52
- private effectBoxStatusTimer?: {
53
+ private appMenu: AppMenu | undefined;
54
+ private useBoxesStatus: boolean;
55
+ private effectBoxesStatusTimer?: {
53
56
  skipUpdate: boolean;
54
57
  timer: number | undefined;
58
+ resolve?: (skipUpdate: boolean) => void;
55
59
  }
56
60
  private effectLastNotMinimizedBoxStatusTimer?: {
57
61
  skipUpdate: boolean;
58
62
  timer: number | undefined;
63
+ resolve?: (skipUpdate: boolean) => void;
59
64
  }
60
65
 
61
66
  public constructor({
@@ -73,8 +78,10 @@ export class TeleBoxManager {
73
78
  collector,
74
79
  namespace = "telebox",
75
80
  readonly = false,
81
+ useBoxesStatus = false,
76
82
  }: TeleBoxManagerConfig = {}) {
77
83
  this._sideEffect = new SideEffectManager();
84
+ this.useBoxesStatus = useBoxesStatus;
78
85
  const { combine, createVal } = createSideEffectBinder(this._sideEffect);
79
86
 
80
87
  this.root = root;
@@ -83,12 +90,19 @@ export class TeleBoxManager {
83
90
  this.boxes$ = createVal<TeleBox[]>([]);
84
91
  this.topBox$ = this.boxes$.derive((boxes) => {
85
92
  if (boxes.length > 0) {
86
- const topBox = boxes.reduce((topBox, box) => {
93
+ console.log("topBox===>topBox$===>000");
94
+ let currentTopBox: TeleBox | undefined = undefined;
95
+ const topBox = boxes.reduce((topBox, box) => {
87
96
  if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized) {
88
97
  return topBox;
89
98
  }
99
+ if (!topBox) {
100
+ topBox = box;
101
+ return topBox;
102
+ }
90
103
  return topBox.zIndex > box.zIndex ? topBox : box;
91
- });
104
+ }, currentTopBox as (TeleBox | undefined));
105
+ console.log("topBox===>topBox$===>end", topBox?.id);
92
106
  return topBox;
93
107
  }
94
108
  return;
@@ -189,7 +203,7 @@ export class TeleBoxManager {
189
203
  new TeleBoxCollector({
190
204
  visible: minimized,
191
205
  readonly: readonly,
192
- namespace,
206
+ namespace
193
207
  }).mount(root)
194
208
  );
195
209
  collector$.subscribe((collector) => {
@@ -198,20 +212,16 @@ export class TeleBoxManager {
198
212
  collector.setReadonly(readonly$.value);
199
213
  collector.setDarkMode(this._darkMode$.value);
200
214
  this._sideEffect.add(() => {
215
+ collector.getBoxesStatus = () => {
216
+ return this.boxesStatus$;
217
+ };
201
218
  collector.onClick = () => {
202
219
  if (!readonly$.value) {
203
- if (this.hasMinimizedBox()) {
204
- this.getAllMinimizedBoxes().forEach((box) => {
205
- const lastNotMinimizedBoxStatus = box.lastNotMinimizedBoxStatus;
206
- if (lastNotMinimizedBoxStatus) {
207
- this.setBoxStatus(box.id, lastNotMinimizedBoxStatus);
208
- } else {
209
- this.setBoxStatus(box.id, TELE_BOX_STATE.Normal);
210
- }
211
- });
212
- this.effectBoxStatusChange();
220
+ if (!this.useBoxesStatus) {
221
+ minimized$.setValue(false);
222
+ } else if (this.useBoxesStatus && this.appMenu) {
223
+ this.appMenu.containerClickHandler();
213
224
  }
214
- minimized$.setValue(false);
215
225
  }
216
226
  };
217
227
  return () => collector.destroy();
@@ -241,6 +251,14 @@ export class TeleBoxManager {
241
251
  return;
242
252
  };
243
253
 
254
+ this._setCollectorRect = (collectorRect: TeleBoxRect | undefined) => {
255
+ if (collector$.value?.$collector) {
256
+ collectorRect$.setValue(collectorRect);
257
+ } else if (import.meta.env.DEV) {
258
+ console.warn("No collector for minimized boxes.");
259
+ }
260
+ };
261
+
244
262
  const collectorRect$ = createVal(
245
263
  minimized$.value ? this._calcCollectorRect() : void 0
246
264
  );
@@ -254,11 +272,7 @@ export class TeleBoxManager {
254
272
  collector$.value?.setVisible(minimized);
255
273
 
256
274
  if (minimized) {
257
- if (collector$.value?.$collector) {
258
- collectorRect$.setValue(this._calcCollectorRect());
259
- } else if (import.meta.env.DEV) {
260
- console.warn("No collector for minimized boxes.");
261
- }
275
+ this._setCollectorRect(this._calcCollectorRect());
262
276
  }
263
277
 
264
278
  this.boxes.forEach((box) =>
@@ -294,10 +308,28 @@ export class TeleBoxManager {
294
308
  if (id) {
295
309
  const box = this.getBox(id);
296
310
  if (box) {
297
- this.focusBox(box);
298
- if ((box.boxStatus && box.boxStatus !== TELE_BOX_STATE.Maximized) || !box.boxStatus) {
311
+ if (!this.useBoxesStatus) {
299
312
  this.makeBoxTop(box);
300
- }
313
+ } else {
314
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal) {
315
+ const maxNormalBoxZIndex = this.getMaxNormalBoxZIndex();
316
+ if (maxNormalBoxZIndex > box.zIndex) {
317
+ this.setBox(box, {
318
+ zIndex: maxNormalBoxZIndex + 1
319
+ }, false);
320
+ }
321
+ } else if(box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized){
322
+ const maxMaximizedBoxZIndex = this.getMaxMaximizedBoxZIndex();
323
+ if (maxMaximizedBoxZIndex > box.zIndex) {
324
+ this.setBox(box, {
325
+ zIndex: maxMaximizedBoxZIndex + 1
326
+ }, false);
327
+ }
328
+ this.makeMaximizedTopBoxFocus();
329
+ }
330
+ }
331
+ console.log("checkFocusBox===>", box.id);
332
+ this.focusBox(box);
301
333
  return;
302
334
  }
303
335
  }
@@ -330,29 +362,79 @@ export class TeleBoxManager {
330
362
  onEvent: (event): void => {
331
363
  switch (event.type) {
332
364
  case TELE_BOX_DELEGATE_EVENT.Maximize: {
333
- if (this.hasBoxesStatus() && this.maxTitleBar.focusedBox?.id) {
334
- this.setBoxStatus(this.maxTitleBar.focusedBox.id, TELE_BOX_STATE.Normal);
335
- this.effectBoxStatusChange();
336
- this.makeMaximizedTopBoxFocus();
365
+ if (this.hasBoxesStatus()) {
366
+ let targetBox = this.maxTitleBar.focusedBox;
367
+ if (!targetBox) {
368
+ targetBox = this.getMaximizedTopBox();
369
+ }
370
+ if (targetBox?.id) {
371
+ const box = this.getBox(targetBox.id);
372
+ if (box) {
373
+ this.setBox(box, {
374
+ status: TELE_BOX_STATE.Normal,
375
+ zIndex: this.getMaxNormalBoxZIndex() + 1
376
+ }, false, ()=>{
377
+ this.makeMaximizedTopBoxFocus();
378
+ });
379
+ }
380
+ }
337
381
  } else {
338
382
  maximized$.setValue(!maximized$.value);
339
383
  }
340
384
  break;
341
385
  }
342
386
  case TELE_BOX_DELEGATE_EVENT.Minimize: {
343
- if (this.hasBoxesStatus() && this.maxTitleBar.focusedBox?.id) {
344
- this.setBoxStatus(this.maxTitleBar.focusedBox.id, TELE_BOX_STATE.Minimized);
345
- this.effectBoxStatusChange();
346
- this.makeMaximizedTopBoxFocus();
387
+ if (this.hasBoxesStatus()) {
388
+ let targetBox = this.maxTitleBar.focusedBox;
389
+ if (!targetBox) {
390
+ targetBox = this.getMaximizedTopBox();
391
+ }
392
+ if(targetBox?.id){
393
+ const box = this.getBox(targetBox.id);
394
+ if (box) {
395
+ let isFocusChanged = false;
396
+ if (this.topBox === box) {
397
+ this.blurBox(box);
398
+ isFocusChanged = true;
399
+ }
400
+ this.setBox(box, {
401
+ status: TELE_BOX_STATE.Minimized,
402
+ zIndex: -1
403
+ }, false);
404
+ if (isFocusChanged) {
405
+ this.focusTopBox();
406
+ } else {
407
+ this.makeMaximizedTopBoxFocus();
408
+ }
409
+ }
410
+ }
347
411
  } else {
348
412
  minimized$.setValue(true);
349
413
  }
350
414
  break;
351
415
  }
352
416
  case TELE_BOX_EVENT.Close: {
353
- if (this.hasBoxesStatus() && this.maxTitleBar.focusedBox?.id) {
354
- this.remove(this.maxTitleBar.focusedBox.id);
355
- this.makeMaximizedTopBoxFocus();
417
+ if (this.hasBoxesStatus()) {
418
+ let targetBox = this.maxTitleBar.focusedBox;
419
+ if (!targetBox) {
420
+ targetBox = this.getMaximizedTopBox();
421
+ }
422
+ if (targetBox?.id) {
423
+ const box = this.getBox(targetBox.id);
424
+ if (box) {
425
+ let isFocusChanged = false;
426
+ if (this.topBox === box) {
427
+ this.blurBox(box);
428
+ isFocusChanged = true;
429
+ }
430
+ this.remove(box, false);
431
+ if (isFocusChanged) {
432
+ this.focusTopBox();
433
+ } else {
434
+ this.makeMaximizedTopBoxFocus();
435
+ }
436
+ }
437
+ }
356
438
  } else {
357
439
  this.removeTopBox();
358
440
  this.focusTopBox();
@@ -391,6 +473,10 @@ export class TeleBoxManager {
391
473
  this._state$ = state$;
392
474
 
393
475
  this.root.appendChild(this.maxTitleBar.render());
476
+
477
+ if (useBoxesStatus) {
478
+ this.appMenu = this.createMinimizedAppMenu();
479
+ }
394
480
  }
395
481
 
396
482
  public get boxes(): ReadonlyArray<TeleBox> {
@@ -413,6 +499,8 @@ export class TeleBoxManager {
413
499
 
414
500
  public _calcCollectorRect: () => TeleBoxRect | undefined;
415
501
 
502
+ public _setCollectorRect: (collectorRect: TeleBoxRect | undefined) => void;
503
+
416
504
  public get darkMode(): boolean {
417
505
  return this._darkMode$.value;
418
506
  }
@@ -451,15 +539,12 @@ export class TeleBoxManager {
451
539
  this.boxesStatus$.set(boxId, boxStatus);
452
540
  if (boxStatus === TELE_BOX_STATE.Minimized && oldBoxStatus !== TELE_BOX_STATE.Minimized) {
453
541
  this.setLastNotMinimizedBoxStatus(boxId, oldBoxStatus, skipUpdate);
454
- this.effectLastNotMinimizedBoxStatusChange();
455
542
  } else if (oldBoxStatus === TELE_BOX_STATE.Minimized && boxStatus !== TELE_BOX_STATE.Minimized) {
456
543
  this.setLastNotMinimizedBoxStatus(boxId, undefined, skipUpdate);
457
- this.effectLastNotMinimizedBoxStatusChange();
458
544
  }
459
545
  } else {
460
546
  this.boxesStatus$.delete(boxId);
461
547
  this.setLastNotMinimizedBoxStatus(boxId, undefined, skipUpdate);
462
- this.effectLastNotMinimizedBoxStatusChange();
463
548
  }
464
549
  if (!skipUpdate) {
465
550
  this.events.emit(TELE_BOX_MANAGER_EVENT.BoxStatus, { id: boxId, boxStatus});
@@ -470,10 +555,6 @@ export class TeleBoxManager {
470
555
  return this.boxesStatus$.get(boxId);
471
556
  }
472
557
 
473
- public getLastNotMinimizedBoxStatus(boxId: string): NotMinimizedBoxState | undefined {
474
- return this.lastNotMinimizedBoxesStatus$.get(boxId);
475
- }
476
-
477
558
  public get boxesStatus(): ReadonlyMap<string, TeleBoxState> {
478
559
  return this.boxesStatus$;
479
560
  }
@@ -482,82 +563,168 @@ export class TeleBoxManager {
482
563
  return this.lastNotMinimizedBoxesStatus$;
483
564
  }
484
565
 
485
- public setBoxesStatus(boxesStatus: Map<string, TeleBoxState>, skipUpdate = false): void {
566
+ public setBoxesStatus(boxesStatus: Map<string, TeleBoxState>, skipUpdate = false) {
486
567
  this.boxesStatus$ = boxesStatus;
487
- this.effectBoxStatusChange(skipUpdate);
568
+ this.effectBoxesStatusChange(skipUpdate);
569
+ }
570
+
571
+ public getBoxesStatus(): Map<string, TeleBoxState> {
572
+ return this.boxesStatus$;
488
573
  }
489
574
 
575
+ private effectBoxStatusChange(){
576
+ if (!this.useBoxesStatus) {
577
+ return;
578
+ }
579
+ if(this.collector){
580
+ this.collector.updateBoxesStatus();
581
+ if(this.hasMinimizedBox()){
582
+ this._setCollectorRect(this._calcCollectorRect());
583
+ }
584
+ }
585
+ if (this.appMenu) {
586
+ this.appMenu.appMenuChange();
587
+ }
588
+ if (this.maxTitleBar) {
589
+ this.maxTitleBar.updateBoxesStatus();
590
+ }
591
+ }
490
592
 
491
- private effectBoxStatusTimerFunc(skipUpdate: boolean){
492
- this.effectBoxStatusTimer = undefined;
493
- let topBox:TeleBox | undefined;
494
- const topBoxId = this.topBox?.id;
495
- let hasMinimizedBox = false;
593
+ private effectBoxesStatusTimerFunc(skipUpdate: boolean){
594
+ if (!this.useBoxesStatus) {
595
+ return;
596
+ }
597
+ let newTopBox:TeleBox | undefined;
598
+ const curTopBox = this.topBox;
496
599
  this.boxes.forEach((box) => {
497
600
  const boxStatus = this.boxesStatus$.get(box.id);
498
601
  if (boxStatus) {
499
- if (boxStatus !== TELE_BOX_STATE.Minimized && box.zIndex > (topBox?.zIndex ?? 0)) {
500
- topBox = box;
602
+ if (boxStatus !== TELE_BOX_STATE.Minimized && box.zIndex > (newTopBox?.zIndex ?? 0)) {
603
+ newTopBox = box;
501
604
  }
502
605
  box.setBoxStatus(boxStatus, skipUpdate);
503
- if (boxStatus === TELE_BOX_STATE.Minimized) {
504
- hasMinimizedBox = true;
505
- }
506
606
  }
507
607
  });
508
- if (hasMinimizedBox) {
509
- this.collector?.setVisible(true);
510
- if (this.collector?.$collector) {
511
- this.setCollectorRect(this._calcCollectorRect());
512
- } else if (import.meta.env.DEV) {
513
- console.warn("No collector for minimized boxes.");
514
- }
515
- } else {
516
- this.collector?.setVisible(false);
517
- }
518
- if (topBox && topBoxId !== topBox.id) {
519
- this.makeBoxTop(topBox, skipUpdate);
520
- this.topBox$.setValue(topBox);
521
- this.focusTopBox();
608
+ this.effectBoxStatusChange();
609
+ if (newTopBox && curTopBox !== newTopBox) {
610
+ this.topBox$.setValue(newTopBox);
611
+ this.focusBox(newTopBox, skipUpdate);
522
612
  }
523
- if (this.maxTitleBar) {
524
- this.maxTitleBar.updateBoxesStatus();
613
+ if (!newTopBox && curTopBox) {
614
+ this.topBox$.setValue(undefined);
615
+ this.blurBox(curTopBox, skipUpdate);
525
616
  }
526
- console.log("effectBoxStatusTimerFunc===>end", skipUpdate, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
527
617
  }
528
618
 
529
- private effectBoxStatusChange(skipUpdate = false){
530
- if (this.effectBoxStatusTimer && this.effectBoxStatusTimer.timer) {
531
- clearTimeout(this.effectBoxStatusTimer.timer);
532
- if (this.effectBoxStatusTimer.skipUpdate !== skipUpdate) {
533
- this.effectBoxStatusTimer.skipUpdate = skipUpdate;
534
- console.log("effectBoxStatusTimerFunc===>1111", skipUpdate);
535
- this.effectBoxStatusTimerFunc(this.effectBoxStatusTimer.skipUpdate)
619
+ public async effectBoxesStatusChange(skipUpdate = false): Promise<void> {
620
+ if (!this.useBoxesStatus) {
621
+ if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.timer) {
622
+ clearTimeout(this.effectBoxesStatusTimer.timer);
623
+ if (this.effectBoxesStatusTimer.resolve) {
624
+ this.effectBoxesStatusTimer.resolve(!!this.effectBoxesStatusTimer?.skipUpdate);
625
+ }
626
+ }
627
+ this.effectBoxesStatusTimer=undefined;
628
+ return;
629
+ }
630
+ if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.timer) {
631
+ if (this.effectBoxesStatusTimer.skipUpdate !== skipUpdate) {
632
+ clearTimeout(this.effectBoxesStatusTimer.timer);
633
+ if (this.effectBoxesStatusTimer.resolve) {
634
+ console.log("effectBoxStatusTimerFunc===>1111", skipUpdate);
635
+ this.effectBoxesStatusTimer.resolve(!!this.effectBoxesStatusTimer?.skipUpdate);
636
+ }
637
+ this.effectBoxesStatusTimer.skipUpdate = skipUpdate;
638
+ console.log("effectBoxStatusTimerFunc===>2222", skipUpdate);
639
+ } else {
640
+ return;
536
641
  }
537
642
  }
538
- if (!this.effectBoxStatusTimer) {
539
- this.effectBoxStatusTimer = {
643
+ if (!this.effectBoxesStatusTimer) {
644
+ this.effectBoxesStatusTimer = {
540
645
  skipUpdate,
541
646
  timer: undefined,
647
+ resolve: undefined,
542
648
  } as {
543
649
  skipUpdate: boolean;
544
650
  timer: number | undefined;
545
651
  }
546
652
  }
547
- console.log("effectBoxStatusTimerFunc===>000", skipUpdate, {id:this.topBox$.value?.id, zIndex:this.topBox$.value?.zIndex}, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
548
- this.effectBoxStatusTimer.timer = setTimeout(()=>{
549
- this.effectBoxStatusTimerFunc(skipUpdate)
550
- }, 100) as unknown as number;
653
+ if (this.effectBoxesStatusTimer) {
654
+ const _skipUpdate = await new Promise<boolean>((resolve)=>{
655
+ this.effectBoxesStatusTimer!.resolve = resolve;
656
+ this.effectBoxesStatusTimer!.timer = setTimeout(()=>{
657
+ if (this.effectBoxesStatusTimer && this.effectBoxesStatusTimer.resolve) {
658
+ console.log("effectBoxStatusTimerFunc===>000", skipUpdate, {id:this.topBox$.value?.id, zIndex:this.topBox$.value?.zIndex}, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
659
+ this.effectBoxesStatusTimer.resolve(this.effectBoxesStatusTimer!.skipUpdate);
660
+ }
661
+ }, 100) as unknown as number;
662
+ })
663
+ console.log("effectBoxStatusTimerFunc===>000==>00", skipUpdate, {id:this.topBox$.value?.id, zIndex:this.topBox$.value?.zIndex}, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
664
+ this.effectBoxesStatusTimerFunc(_skipUpdate)
665
+ this.effectBoxesStatusTimer = undefined;
666
+ console.log("effectBoxStatusTimerFunc===>000==>11", skipUpdate, {id:this.topBox$.value?.id, zIndex:this.topBox$.value?.zIndex}, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
667
+ }
551
668
  }
552
669
 
553
670
  public hasBoxesStatus(): boolean {
671
+ if (!this.useBoxesStatus) {
672
+ return false;
673
+ }
554
674
  return this.boxesStatus$.size > 0;
555
675
  }
556
676
 
557
677
  public hasMinimizedBox(): boolean {
678
+ if (!this.useBoxesStatus) {
679
+ return false;
680
+ }
558
681
  return this.boxes.some((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized);
559
682
  }
560
683
 
684
+ public getMinimizedBoxesStatus(): Map<string, TELE_BOX_STATE.Minimized> {
685
+ const minimizedBoxes = new Map<string, TELE_BOX_STATE.Minimized>();
686
+ this.boxesStatus$.forEach((boxStatus, boxId) => {
687
+ if (boxStatus === TELE_BOX_STATE.Minimized) {
688
+ minimizedBoxes.set(boxId, boxStatus as TELE_BOX_STATE.Minimized);
689
+ }
690
+ });
691
+ return minimizedBoxes;
692
+ }
693
+
694
+ public getNotMinimizedBoxesStatus(): Map<string, NotMinimizedBoxState> {
695
+ const notMinimizedBoxes = new Map<string, NotMinimizedBoxState>();
696
+ this.boxesStatus$.forEach((boxStatus, boxId) => {
697
+ if (boxStatus !== TELE_BOX_STATE.Minimized) {
698
+ notMinimizedBoxes.set(boxId, boxStatus as NotMinimizedBoxState);
699
+ }
700
+ });
701
+ return notMinimizedBoxes;
702
+ }
703
+
704
+ public getAllMaximizedBoxesStatus(): Map<string, TELE_BOX_STATE.Maximized> {
705
+ const maximizedBoxes = new Map<string, TELE_BOX_STATE.Maximized>();
706
+ this.boxesStatus$.forEach((boxStatus, boxId) => {
707
+ if (boxStatus === TELE_BOX_STATE.Maximized) {
708
+ maximizedBoxes.set(boxId, boxStatus as TELE_BOX_STATE.Maximized);
709
+ }
710
+ });
711
+ return maximizedBoxes;
712
+ }
713
+
714
+ public getAllNormalBoxesStatus(): Map<string, TELE_BOX_STATE.Normal> {
715
+ const normalBoxes = new Map<string, TELE_BOX_STATE.Normal>();
716
+ this.boxesStatus$.forEach((boxStatus, boxId) => {
717
+ if (boxStatus === TELE_BOX_STATE.Normal) {
718
+ normalBoxes.set(boxId, boxStatus as TELE_BOX_STATE.Normal);
719
+ }
720
+ });
721
+ return normalBoxes;
722
+ }
723
+
724
+ public getLastNotMinimizedBoxStatus(boxId: string): NotMinimizedBoxState | undefined {
725
+ return this.lastNotMinimizedBoxesStatus$.get(boxId);
726
+ }
727
+
561
728
  public setLastNotMinimizedBoxStatus(boxId: string, lastNotMinimizedBoxStatus?: NotMinimizedBoxState, skipUpdate = false): void {
562
729
  if (lastNotMinimizedBoxStatus) {
563
730
  this.lastNotMinimizedBoxesStatus$.set(boxId, lastNotMinimizedBoxStatus);
@@ -574,23 +741,117 @@ export class TeleBoxManager {
574
741
  this.effectLastNotMinimizedBoxStatusChange(skipUpdate);
575
742
  }
576
743
 
577
- private effectLastNotMinimizedBoxStatusChange(skipUpdate = false){
744
+ private async effectLastNotMinimizedBoxStatusChange(skipUpdate = false): Promise<void> {
745
+ if (!this.useBoxesStatus) {
746
+ if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.timer) {
747
+ clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
748
+ if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
749
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(!!this.effectLastNotMinimizedBoxStatusTimer?.skipUpdate);
750
+ }
751
+ }
752
+ this.effectLastNotMinimizedBoxStatusTimer=undefined;
753
+ return;
754
+ }
755
+ if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.timer) {
756
+ clearTimeout(this.effectLastNotMinimizedBoxStatusTimer.timer);
757
+ if (this.effectLastNotMinimizedBoxStatusTimer.skipUpdate !== skipUpdate) {
758
+ // this.effectLastNotMinimizedBoxStatusFunc(this.effectLastNotMinimizedBoxStatusTimer.skipUpdate)
759
+ if (this.effectLastNotMinimizedBoxStatusTimer.resolve) {
760
+ console.log("effectLastNotMinimizedBoxStatusFunc===>1111", skipUpdate);
761
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(!!this.effectLastNotMinimizedBoxStatusTimer?.skipUpdate);
762
+ }
763
+ this.effectLastNotMinimizedBoxStatusTimer.skipUpdate = skipUpdate;
764
+ console.log("effectLastNotMinimizedBoxStatusFunc===>2222", skipUpdate);
765
+ } else {
766
+ return;
767
+ }
768
+ }
769
+ if (!this.effectLastNotMinimizedBoxStatusTimer) {
770
+ this.effectLastNotMinimizedBoxStatusTimer = {
771
+ skipUpdate,
772
+ timer: undefined,
773
+ resolve: undefined,
774
+ } as {
775
+ skipUpdate: boolean;
776
+ timer: number | undefined;
777
+ }
778
+ }
779
+ if (this.effectLastNotMinimizedBoxStatusTimer) {
780
+ const _skipUpdate = await new Promise<boolean>((resolve)=>{
781
+ this.effectLastNotMinimizedBoxStatusTimer!.resolve = resolve;
782
+ this.effectLastNotMinimizedBoxStatusTimer!.timer = setTimeout(()=>{
783
+ if (this.effectLastNotMinimizedBoxStatusTimer && this.effectLastNotMinimizedBoxStatusTimer.resolve) {
784
+ console.log("effectLastNotMinimizedBoxStatusTimer===>000", skipUpdate);
785
+ this.effectLastNotMinimizedBoxStatusTimer.resolve(this.effectLastNotMinimizedBoxStatusTimer!.skipUpdate);
786
+ }
787
+ }, 100) as unknown as number;
788
+ })
789
+ console.log("effectLastNotMinimizedBoxStatusFunc===>000==>00", skipUpdate, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex, lastNotMinimizedBoxStatus:b._lastNotMinimizedBoxStatus$.value})));
790
+ this.effectLastNotMinimizedBoxStatusFunc(_skipUpdate)
791
+ this.effectLastNotMinimizedBoxStatusTimer = undefined;
792
+ console.log("effectLastNotMinimizedBoxStatusFunc===>000==>11", skipUpdate, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex, lastNotMinimizedBoxStatus:b._lastNotMinimizedBoxStatus$.value})));
793
+ }
794
+ }
795
+
796
+ private effectLastNotMinimizedBoxStatusFunc(skipUpdate = false){
797
+ if (!this.useBoxesStatus) {
798
+ return;
799
+ }
800
+ console.log("effectLastNotMinimizedBoxStatusFunc===>end", skipUpdate);
578
801
  this.boxes.forEach((box) => {
579
802
  const boxStatus = this.lastNotMinimizedBoxesStatus$.get(box.id);
580
- box.setLastNotMinimizedBoxStatus(boxStatus, skipUpdate);
803
+ if(boxStatus){
804
+ box.setLastNotMinimizedBoxStatus(boxStatus, skipUpdate);
805
+ }
581
806
  });
582
807
  }
583
808
 
584
- private getAllMinimizedBoxes(): ReadonlyArray<TeleBox> {
585
- return this.boxes.filter((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized);
809
+ private getUnabledBoxesStatusZIndex(): number {
810
+ return this.topBox ? this.topBox.zIndex : 99;
811
+ }
812
+
813
+ // private getTopBoxZIndex(): number {
814
+ // if (!this.useBoxesStatus) {
815
+ // return this.getUnabledBoxesStatusZIndex();
816
+ // }
817
+ // return [...this.boxes].filter((box) => box.boxStatus !== TELE_BOX_STATE.Minimized).reduce((maxZIndex, box) => {
818
+ // return Math.max(maxZIndex, box.zIndex);
819
+ // }, 100);
820
+ // }
821
+
822
+ /** Maximized box zIndex range: 100-299 */
823
+ public getMaxMaximizedBoxZIndex(): number {
824
+ if (!this.useBoxesStatus) {
825
+ return this.getUnabledBoxesStatusZIndex();
826
+ }
827
+ return this.boxes.reduce((maxZIndex, box) => {
828
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Maximized) {
829
+ return Math.max(maxZIndex, box.zIndex);
830
+ }
831
+ return maxZIndex;
832
+ }, 99);
833
+ }
834
+
835
+ /** normal box zIndex range: 300-499 */
836
+ public getMaxNormalBoxZIndex(): number {
837
+ if (!this.useBoxesStatus) {
838
+ return this.getUnabledBoxesStatusZIndex();
839
+ }
840
+ return this.boxes.reduce((maxZIndex, box) => {
841
+ if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Normal) {
842
+ return Math.max(maxZIndex, box.zIndex);
843
+ }
844
+ return maxZIndex;
845
+ }, 299);
586
846
  }
587
847
 
588
848
  public create(
589
849
  config: TeleBoxManagerCreateConfig = {},
590
850
  smartPosition = true
591
851
  ): ReadonlyTeleBox {
852
+ console.log("create===>", config, this.topBox?.zIndex);
592
853
  const box = new TeleBox({
593
- zIndex: this.topBox ? this.topBox.zIndex + 1 : 100,
854
+ zIndex: this.getMaxNormalBoxZIndex() + 1,
594
855
  ...(smartPosition ? this.smartPosition(config) : config),
595
856
  darkMode: this.darkMode,
596
857
  prefersColorScheme: this.prefersColorScheme,
@@ -605,6 +866,15 @@ export class TeleBoxManager {
605
866
 
606
867
  box.mount(this.root);
607
868
 
869
+ this.boxes$.setValue([...this.boxes, box]);
870
+
871
+ if (box.boxStatus && this.useBoxesStatus) {
872
+ this.setBox(box, {
873
+ status: box.boxStatus,
874
+ lastNotMinimizedBoxStatus: box._lastNotMinimizedBoxStatus$.value
875
+ }, true);
876
+ }
877
+
608
878
  if (box.focus) {
609
879
  this.focusBox(box);
610
880
  if (smartPosition) {
@@ -612,44 +882,45 @@ export class TeleBoxManager {
612
882
  }
613
883
  }
614
884
 
615
- this.boxes$.setValue([...this.boxes, box]);
616
-
617
- if (box.boxStatus) {
618
- this.setBoxStatus(box.id, box.boxStatus, true);
619
- this.effectBoxStatusChange(true);
620
- }
621
-
622
- if (box._lastNotMinimizedBoxStatus$.value) {
623
- this.setLastNotMinimizedBoxStatus(box.id, box._lastNotMinimizedBoxStatus$.value, true);
624
- this.effectLastNotMinimizedBoxStatusChange();
625
- }
626
-
627
885
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Maximize, () => {
628
- if (box.boxStatus) {
886
+ if (this.useBoxesStatus && box.boxStatus) {
629
887
  if (box.boxStatus === TELE_BOX_STATE.Maximized) {
630
- this.setBoxStatus(box.id, TELE_BOX_STATE.Normal);
888
+ this.setBox(box.id, {
889
+ status: TELE_BOX_STATE.Normal,
890
+ zIndex: this.getMaxNormalBoxZIndex() + 1
891
+ }, false);
631
892
  } else {
632
- this.boxes.forEach((box) => {
893
+ // 所有normal box都最大化
894
+ [...this.boxes].filter((box) => box.boxStatus === TELE_BOX_STATE.Normal).sort((a, b) => a.zIndex - b.zIndex).forEach((box) => {
633
895
  if (box.boxStatus === TELE_BOX_STATE.Normal) {
634
- this.setBoxStatus(box.id, TELE_BOX_STATE.Maximized);
896
+ console.log("maximized===>", box.id);
897
+ this.setBox(box.id, {
898
+ status: TELE_BOX_STATE.Maximized,
899
+ zIndex: this.getMaxMaximizedBoxZIndex() + 1
900
+ }, false);
635
901
  }
636
902
  });
903
+ this.makeMaximizedTopBoxFocus();
637
904
  }
638
- this.effectBoxStatusChange();
639
- this.makeMaximizedTopBoxFocus();
640
905
  } else {
641
906
  this.setMaximized(!this.maximized);
642
907
  }
643
908
 
644
909
  });
645
910
  box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Minimize, () => {
646
- if (box.boxStatus) {
647
- const oldBoxStatus = box.boxStatus;
648
- this.setBoxStatus(box.id, TELE_BOX_STATE.Minimized);
649
- this.effectBoxStatusChange();
650
- if (oldBoxStatus === TELE_BOX_STATE.Maximized) {
651
- this.makeMaximizedTopBoxFocus();
911
+ if (box.boxStatus && this.useBoxesStatus) {
912
+ if (this.topBox === box) {
913
+ if (this.topBox?.focus) {
914
+ this.blurBox(this.topBox);
915
+ }
652
916
  }
917
+ this.setBox(box, {
918
+ status: TELE_BOX_STATE.Minimized,
919
+ zIndex: -1
920
+ }, false, ()=>{
921
+ this.focusTopBox();
922
+ });
923
+
653
924
  } else{
654
925
  this.setMinimized(true);
655
926
  }
@@ -685,12 +956,19 @@ export class TeleBoxManager {
685
956
  });
686
957
  box._zIndex$.reaction((_, __, skipUpdate) => {
687
958
  if (this.boxes.length > 0) {
959
+ console.log("topBox===>_zIndex", this.boxes.map((box) => ({id: box.id, zIndex: box.zIndex, boxStatus: box.boxStatus})));
960
+ let currentTopBox: TeleBox | undefined = undefined;
688
961
  const topBox = this.boxes.reduce((topBox, box) => {
689
962
  if (box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized) {
690
963
  return topBox;
691
964
  }
965
+ if (!topBox) {
966
+ topBox = box;
967
+ return topBox;
968
+ }
692
969
  return topBox.zIndex > box.zIndex ? topBox : box;
693
- });
970
+ }, currentTopBox as (TeleBox | undefined));
971
+ console.log("topBox===>_zIndex===>end", topBox?.id);
694
972
  this.topBox$.setValue(topBox);
695
973
  }
696
974
  if (!skipUpdate) {
@@ -736,9 +1014,34 @@ export class TeleBoxManager {
736
1014
  });
737
1015
  }
738
1016
 
1017
+ public setBox(boxOrID: string | TeleBox, options: {
1018
+ status?: TeleBoxState;
1019
+ lastNotMinimizedBoxStatus?: NotMinimizedBoxState;
1020
+ zIndex?: number;
1021
+ }, skipUpdate = false, effectFunc?: () => void){
1022
+ const box = this.getBox(boxOrID)
1023
+ if (box) {
1024
+ const {status, zIndex, lastNotMinimizedBoxStatus} = options;
1025
+ if (status) {
1026
+ this.setBoxStatus(box.id, status, skipUpdate);
1027
+ box.setBoxStatus(status, skipUpdate);
1028
+ this.effectBoxStatusChange();
1029
+ }
1030
+ if (zIndex) {
1031
+ box.setZIndex(zIndex, skipUpdate);
1032
+ }
1033
+ if (lastNotMinimizedBoxStatus) {
1034
+ this.setLastNotMinimizedBoxStatus(box.id, lastNotMinimizedBoxStatus, skipUpdate);
1035
+ box.setLastNotMinimizedBoxStatus(lastNotMinimizedBoxStatus, skipUpdate);
1036
+ }
1037
+ effectFunc && effectFunc();
1038
+ }
1039
+ }
1040
+
739
1041
  public remove(
740
1042
  boxOrID: string | TeleBox,
741
- skipUpdate = false
1043
+ skipUpdate = false,
1044
+ effectFunc?: () => void
742
1045
  ): ReadonlyTeleBox | undefined {
743
1046
  const box = this.getBox(boxOrID);
744
1047
  const index = this.getBoxIndex(boxOrID);
@@ -747,13 +1050,11 @@ export class TeleBoxManager {
747
1050
  const deletedBoxes = boxes.splice(index, 1);
748
1051
  this.boxes$.setValue(boxes);
749
1052
  deletedBoxes.forEach((box) => box.destroy());
750
- if (box) {
1053
+ if (box && this.useBoxesStatus) {
751
1054
  this.setBoxStatus(box.id, undefined, skipUpdate);
752
- this.boxesStatus$.delete(box.id);
753
- this.effectBoxStatusChange(skipUpdate);
754
1055
  this.setLastNotMinimizedBoxStatus(box.id, undefined, skipUpdate);
755
- this.lastNotMinimizedBoxesStatus$.delete(box.id);
756
- this.effectLastNotMinimizedBoxStatusChange();
1056
+ this.effectBoxStatusChange();
1057
+ effectFunc && effectFunc();
757
1058
  }
758
1059
  if (!skipUpdate) {
759
1060
  if (this.boxes.length <= 0) {
@@ -827,10 +1128,10 @@ export class TeleBoxManager {
827
1128
  this.blurBox(box, skipUpdate);
828
1129
  }
829
1130
  });
830
- if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
831
- this.makeMaximizedBoxFocus(targetBox);
832
- } else {
1131
+ if (!this.useBoxesStatus) {
833
1132
  this.maxTitleBar.focusBox(targetBox);
1133
+ } else if (this.useBoxesStatus && this.maxTitleBar.hasMaximizedBoxInStatus()) {
1134
+ this.makeMaximizedTopBoxFocus();
834
1135
  }
835
1136
  }
836
1137
  }
@@ -851,11 +1152,7 @@ export class TeleBoxManager {
851
1152
  }
852
1153
  }
853
1154
  if (this.maxTitleBar.focusedBox === targetBox) {
854
- if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
855
- this.makeMaximizedTopBoxFocus();
856
- } else {
857
- this.maxTitleBar.focusBox();
858
- }
1155
+ this.maxTitleBar.focusBox();
859
1156
  }
860
1157
  }
861
1158
  }
@@ -870,11 +1167,7 @@ export class TeleBoxManager {
870
1167
  }
871
1168
  });
872
1169
  if (this.maxTitleBar.focusedBox) {
873
- if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
874
- this.makeMaximizedBoxBlur();
875
- } else {
876
- this.maxTitleBar.focusBox();
877
- }
1170
+ this.maxTitleBar.focusBox();
878
1171
  }
879
1172
  }
880
1173
 
@@ -882,6 +1175,7 @@ export class TeleBoxManager {
882
1175
 
883
1176
  protected boxes$: Val<TeleBox[]>;
884
1177
  protected topBox$: Val<TeleBox | undefined>;
1178
+ // protected maximizedTopBox$: Val<MaxTitleBarTeleBox | undefined>;
885
1179
 
886
1180
  protected teleBoxMatcher(
887
1181
  config: TeleBoxManagerQueryConfig
@@ -943,13 +1237,11 @@ export class TeleBoxManager {
943
1237
  if (config.footer != null) {
944
1238
  box.mountFooter(config.footer);
945
1239
  }
946
- if (config.boxStatus) {
947
- this.setBoxStatus(box.id, config.boxStatus, skipUpdate);
948
- this.effectBoxStatusChange(skipUpdate);
949
- }
950
- if (config.lastNotMinimizedBoxStatus) {
951
- this.setLastNotMinimizedBoxStatus(box.id, config.lastNotMinimizedBoxStatus, skipUpdate);
952
- this.effectLastNotMinimizedBoxStatusChange();
1240
+ if (this.useBoxesStatus && (config.boxStatus || config.lastNotMinimizedBoxStatus)) {
1241
+ this.setBox(box, {
1242
+ status: config.boxStatus,
1243
+ lastNotMinimizedBoxStatus: config.lastNotMinimizedBoxStatus
1244
+ }, skipUpdate);
953
1245
  }
954
1246
  }
955
1247
 
@@ -961,13 +1253,17 @@ export class TeleBoxManager {
961
1253
  let vx = 20;
962
1254
  if (this.topBox) {
963
1255
  vx = this.topBox.intrinsicX * this.containerRect.width + 20;
964
-
965
1256
  if (
966
1257
  vx >
967
1258
  this.containerRect.width - width * this.containerRect.width
968
1259
  ) {
969
1260
  vx = 20;
970
1261
  }
1262
+ } else if (this.hasMinimizedBox()) {
1263
+ // 如果都最小化,则获取lastNotMinimizedBoxesStatus中normal box的最大x
1264
+ vx = [...this.boxes].filter((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal).reduce((maxX, box) => {
1265
+ return Math.max(maxX, box.intrinsicX * this.containerRect.width + 20);
1266
+ }, vx);
971
1267
  }
972
1268
  x = vx / this.containerRect.width;
973
1269
  }
@@ -985,6 +1281,11 @@ export class TeleBoxManager {
985
1281
  ) {
986
1282
  vy = 20;
987
1283
  }
1284
+ } else if (this.hasMinimizedBox()) {
1285
+ // 如果都最小化,则获取lastNotMinimizedBoxesStatus中normal box的最大y
1286
+ vy = [...this.boxes].filter((box) => box.boxStatus && box.boxStatus === TELE_BOX_STATE.Minimized && box.lastNotMinimizedBoxStatus && box.lastNotMinimizedBoxStatus === TELE_BOX_STATE.Normal).reduce((maxY, box) => {
1287
+ return Math.max(maxY, box.intrinsicY * this.containerRect.height + 20);
1288
+ }, vy);
988
1289
  }
989
1290
 
990
1291
  y = vy / this.containerRect.height;
@@ -994,32 +1295,19 @@ export class TeleBoxManager {
994
1295
  }
995
1296
 
996
1297
  protected makeBoxTop(box: TeleBox, skipUpdate = false): void {
997
- if (this.topBox) {
1298
+ if (!this.useBoxesStatus && this.topBox) {
998
1299
  if (box !== this.topBox) {
999
- if (!this.hasBoxesStatus()) {
1000
- box.setZIndex(this.topBox.zIndex + 1, skipUpdate);
1001
- return;
1002
- }
1003
- const maxZIndex = this.boxes.reduce((maxZIndex, box) => {
1004
- return Math.max(maxZIndex, box.zIndex);
1005
- }, 0);
1006
- const currentTopBoxZIndex = Math.min(this.topBox.zIndex, box.zIndex);
1007
- const addZIndex = maxZIndex + 1 - currentTopBoxZIndex;
1008
- box.setZIndex(maxZIndex + 1, skipUpdate);
1009
- console.log("makeBoxTop===>", box.id, maxZIndex + 1, addZIndex, this.topBox.id, currentTopBoxZIndex);
1010
- if (box.boxStatus !== TELE_BOX_STATE.Minimized) {
1011
- this.boxes.forEach((b) => {
1012
- if (b.boxStatus === TELE_BOX_STATE.Minimized && b.zIndex >= currentTopBoxZIndex) {
1013
- console.log("makeBoxTop===>111", b.id, b.zIndex + addZIndex);
1014
- b.setZIndex(b.zIndex + addZIndex, skipUpdate);
1015
- }
1016
- });
1017
- }
1300
+ box.setZIndex(this.topBox.zIndex + 1, skipUpdate);
1018
1301
  }
1302
+ } else if (this.useBoxesStatus) {
1303
+ // todo
1019
1304
  }
1020
1305
  }
1021
1306
 
1022
- protected makeMaximizedTopBoxFocus(): void {
1307
+ private getMaximizedTopBox(): MaxTitleBarTeleBox | undefined {
1308
+ if (!this.useBoxesStatus) {
1309
+ return undefined;
1310
+ }
1023
1311
  let maximizedBox: MaxTitleBarTeleBox | undefined;
1024
1312
  if (this.maxTitleBar.hasMaximizedBoxInStatus()) {
1025
1313
  maximizedBox = this.maxTitleBar.MaximizedBoxes.reduce((topBox, currentBox) => {
@@ -1028,38 +1316,18 @@ export class TeleBoxManager {
1028
1316
  }
1029
1317
  return topBox.zIndex > currentBox.zIndex ? topBox : currentBox;
1030
1318
  }, );
1031
- if (maximizedBox) {
1032
- this.maxTitleBar.focusBox(maximizedBox);
1033
- }
1034
1319
  }
1320
+ return maximizedBox;
1035
1321
  }
1036
1322
 
1037
- protected makeMaximizedBoxFocus(maximizedBox: MaxTitleBarTeleBox, skipUpdate = false): void {
1038
- if (this.maxTitleBar.hasMaximizedBoxInStatus() && this.maxTitleBar.MaximizedBoxes.find((box) => box.id === maximizedBox.id)) {
1039
- const currentZIndex = maximizedBox.zIndex;
1040
- const currentMaximizedTopBox = this.maxTitleBar.MaximizedBoxes.reduce((topBox, box) => {
1041
- if (!topBox) {
1042
- return box;
1043
- }
1044
- return topBox.zIndex > box.zIndex ? topBox : box;
1045
- });
1046
- if (currentMaximizedTopBox !== maximizedBox) {
1047
- const addZIndex = currentMaximizedTopBox.zIndex - currentZIndex + 1;
1048
- this.boxes.forEach((box) => {
1049
- if (this.maxTitleBar.MaximizedBoxes.find((b) => b.id === box.id && b.id !== maximizedBox.id)) {
1050
- return;
1051
- }
1052
- if (box.zIndex >= currentZIndex) {
1053
- box.setZIndex(box.zIndex + addZIndex, skipUpdate);
1054
- }
1055
- });
1056
- }
1057
- this.maxTitleBar.focusBox(maximizedBox);
1323
+ protected makeMaximizedTopBoxFocus(): void {
1324
+ if (!this.useBoxesStatus) {
1325
+ return;
1058
1326
  }
1059
- }
1060
-
1061
- protected makeMaximizedBoxBlur(): void {
1062
- this.maxTitleBar.focusBox();
1327
+ const maximizedBox: MaxTitleBarTeleBox | undefined = this.getMaximizedTopBox();
1328
+ console.log("makeMaximizedTopBoxFocus===>", maximizedBox?.id);
1329
+ this.maxTitleBar.focusBox(maximizedBox);
1330
+ console.log("makeMaximizedTopBoxFocus===>end", maximizedBox?.id);
1063
1331
  }
1064
1332
 
1065
1333
  protected getBoxIndex(boxOrID: TeleBox | string): number {
@@ -1068,9 +1336,23 @@ export class TeleBoxManager {
1068
1336
  : this.boxes.findIndex((box) => box === boxOrID);
1069
1337
  }
1070
1338
 
1071
- protected getBox(boxOrID: TeleBox | string): TeleBox | undefined {
1339
+ public getBox(boxOrID: TeleBox | string): TeleBox | undefined {
1072
1340
  return typeof boxOrID === "string"
1073
1341
  ? this.boxes.find((box) => box.id === boxOrID)
1074
1342
  : boxOrID;
1075
1343
  }
1344
+
1345
+ public createMinimizedAppMenu():AppMenu | undefined {
1346
+ if (this.collector?.$appMenuContainer) {
1347
+ return new AppMenu({
1348
+ manager: this,
1349
+ container: this.collector?.$appMenuContainer,
1350
+ theme: this.prefersColorScheme ? 'dark' : 'light',
1351
+ getBoxesStatus: () => {
1352
+ return this.boxesStatus$;
1353
+ }
1354
+ });
1355
+ }
1356
+ return;
1357
+ }
1076
1358
  }