@netless/app-slide 0.2.13 → 0.2.14

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.
@@ -1,4 +1,4 @@
1
- import type { RegisterParams } from "@netless/window-manager";
1
+ import type { ReadonlyTeleBox, RegisterParams } from "@netless/window-manager";
2
2
  export interface FreezableSlide {
3
3
  freeze: () => void;
4
4
  unfreeze: () => void;
@@ -7,9 +7,10 @@ export declare let useFreezer: boolean;
7
7
  export declare const FreezerLength = 2;
8
8
  export declare const apps: {
9
9
  map: Map<string, FreezableSlide>;
10
+ boxes: Map<string, ReadonlyTeleBox>;
10
11
  queue: string[];
11
12
  validateQueue(): void;
12
- set(appId: string, slide: FreezableSlide): void;
13
+ set(appId: string, slide: FreezableSlide, box: ReadonlyTeleBox): void;
13
14
  delete(appId: string): void;
14
15
  focus(appId: string): void;
15
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/app-slide",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "main": "dist/main.cjs.js",
5
5
  "module": "dist/main.es.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -126,7 +126,7 @@ const SlideApp: NetlessApp<Attributes, MagixEvents, AppOptions, Controller> = {
126
126
  ...options,
127
127
  onPageChanged,
128
128
  });
129
- if (useFreezer) apps.set(context.appId, slideController);
129
+ if (useFreezer) apps.set(context.appId, slideController, box);
130
130
  logger.setAppController(context.appId, slideController);
131
131
  if (import.meta.env.DEV) {
132
132
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1,4 +1,4 @@
1
- import type { RegisterParams } from "@netless/window-manager";
1
+ import type { ReadonlyTeleBox, RegisterParams } from "@netless/window-manager";
2
2
  import { log } from "./logger";
3
3
 
4
4
  export interface FreezableSlide {
@@ -15,8 +15,15 @@ const inspect = (arr: string[]) => {
15
15
 
16
16
  export const apps = {
17
17
  map: new Map<string, FreezableSlide>(),
18
+ boxes: new Map<string, ReadonlyTeleBox>(),
18
19
  queue: [] as string[],
19
20
  validateQueue() {
21
+ // queue = [5, 4, 3, 2, 1]
22
+ this.queue.sort((a, b) => {
23
+ const za = this.boxes.get(a)?.zIndex ?? 0;
24
+ const zb = this.boxes.get(b)?.zIndex ?? 0;
25
+ return -(za - zb);
26
+ });
20
27
  log("[Slide] freezer: validate", inspect(this.queue));
21
28
  while (this.queue.length > FreezerLength) {
22
29
  const appId = this.queue.pop() as string;
@@ -27,9 +34,10 @@ export const apps = {
27
34
  }
28
35
  }
29
36
  },
30
- set(appId: string, slide: FreezableSlide) {
37
+ set(appId: string, slide: FreezableSlide, box: ReadonlyTeleBox) {
31
38
  log("[Slide] freezer: add", appId, inspect(this.queue));
32
39
  this.map.set(appId, slide);
40
+ this.boxes.set(appId, box);
33
41
  if (!this.queue.includes(appId)) {
34
42
  this.queue.unshift(appId);
35
43
  }
@@ -37,6 +45,7 @@ export const apps = {
37
45
  },
38
46
  delete(appId: string) {
39
47
  this.map.delete(appId);
48
+ this.boxes.delete(appId);
40
49
  this.queue = this.queue.filter(id => id !== appId);
41
50
  log("[Slide] freezer: delete", appId, inspect(this.queue));
42
51
  },