@netless/window-manager 0.3.5-canary.0 → 0.3.6-canary.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "0.3.5-canary.0",
3
+ "version": "0.3.6-canary.1",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
@@ -24,7 +24,7 @@
24
24
  "@juggle/resize-observer": "^3.3.1",
25
25
  "@netless/app-docs-viewer": "^0.1.21",
26
26
  "@netless/app-media-player": "0.1.0-beta.5",
27
- "@netless/telebox-insider": "0.2.5",
27
+ "@netless/telebox-insider": "0.2.6",
28
28
  "emittery": "^0.9.2",
29
29
  "lodash": "^4.17.21",
30
30
  "p-retry": "^4.6.1",
@@ -56,6 +56,6 @@
56
56
  "typescript": "^4.3.5",
57
57
  "video.js": "^7.14.3",
58
58
  "vite": "^2.5.3",
59
- "white-web-sdk": "^2.15.1"
59
+ "white-web-sdk": "2.15.6"
60
60
  }
61
61
  }
@@ -1,6 +1,8 @@
1
- import { Events, MagixEventName } from "./constants";
1
+ import { callbacks } from './index';
2
+ import { Events, MagixEventName } from './constants';
2
3
  import type { Event } from "white-web-sdk";
3
4
  import type { AppManager } from "./AppManager";
5
+ import type { TeleBoxState } from "@netless/telebox-insider";
4
6
 
5
7
  export class AppListeners {
6
8
  private displayer = this.manager.displayer;
@@ -32,6 +34,10 @@ export class AppListeners {
32
34
  this.switchViewsToFreedomHandler();
33
35
  break;
34
36
  }
37
+ case Events.AppBoxStateChange: {
38
+ this.boxStateChangeHandler(data.payload);
39
+ break;
40
+ }
35
41
  default:
36
42
  break;
37
43
  }
@@ -50,4 +56,8 @@ export class AppListeners {
50
56
  private switchViewsToFreedomHandler = () => {
51
57
  this.manager.viewManager.freedomAllViews();
52
58
  };
59
+
60
+ private boxStateChangeHandler = (state: TeleBoxState) => {
61
+ callbacks.emit("boxStateChange", state);
62
+ }
53
63
  }
package/src/AppManager.ts CHANGED
@@ -2,7 +2,7 @@ import { AppAttributes, AppStatus, Events, MagixEventName } from "./constants";
2
2
  import { AppListeners } from "./AppListener";
3
3
  import { AppProxy } from "./AppProxy";
4
4
  import { AttributesDelegate } from "./AttributesDelegate";
5
- import { BoxManager, TELE_BOX_STATE } from "./BoxManager";
5
+ import { BoxManager } from "./BoxManager";
6
6
  import { callbacks, emitter } from "./index";
7
7
  import { CameraStore } from "./Utils/CameraStore";
8
8
  import { genAppId, makeValidScenePath, setScenePath } from "./Utils/Common";
@@ -14,7 +14,13 @@ import { ReconnectRefresher } from "./ReconnectRefresher";
14
14
  import { ViewManager } from "./ViewManager";
15
15
  import type { Displayer, DisplayerState, Room } from "white-web-sdk";
16
16
  import type { CreateCollectorConfig } from "./BoxManager";
17
- import type { AddAppParams, BaseInsertParams, WindowManager, TeleBoxRect } from "./index";
17
+ import type {
18
+ AddAppParams,
19
+ BaseInsertParams,
20
+ WindowManager,
21
+ TeleBoxRect,
22
+ EmitterEvent,
23
+ } from "./index";
18
24
  export class AppManager {
19
25
  public displayer: Displayer;
20
26
  public boxManager: BoxManager;
@@ -69,12 +75,6 @@ export class AppManager {
69
75
  return autorun(() => {
70
76
  const maximized = this.attributes.maximized;
71
77
  if (this.boxManager.maximized !== maximized) {
72
- if (maximized === true && this.boxManager.minimized === false) {
73
- const topBox = this.boxManager.getTopBox();
74
- if (topBox) {
75
- emitter.emit("focus", { appId: topBox.id });
76
- }
77
- }
78
78
  this.boxManager.setMaximized(Boolean(maximized));
79
79
  }
80
80
  });
@@ -83,7 +83,7 @@ export class AppManager {
83
83
  return autorun(() => {
84
84
  const minimized = this.attributes.minimized;
85
85
  if (this.boxManager.minimized !== minimized) {
86
- if (minimized === true) {
86
+ if (minimized === true && this.store.focus !== undefined) {
87
87
  this.store.cleanFocus();
88
88
  this.boxManager.blurFocusBox();
89
89
  }
@@ -336,7 +336,7 @@ export class AppManager {
336
336
  }
337
337
  }
338
338
 
339
- private boxEventListener = (eventName: string | number, payload: any) => {
339
+ private boxEventListener = (eventName: keyof EmitterEvent, payload: any) => {
340
340
  switch (eventName) {
341
341
  case "move": {
342
342
  this.dispatchInternalEvent(Events.AppMove, payload);
@@ -367,6 +367,10 @@ export class AppManager {
367
367
  }
368
368
  break;
369
369
  }
370
+ case "boxStateChange": {
371
+ this.dispatchInternalEvent(Events.AppBoxStateChange, payload);
372
+ break;
373
+ }
370
374
  default:
371
375
  break;
372
376
  }
@@ -13,7 +13,7 @@ export class Context {
13
13
  };
14
14
 
15
15
  public get uid() {
16
- return this.findMember(this.observerId)?.payload?.uid || "";
16
+ return this.manager.room?.uid || "";
17
17
  }
18
18
 
19
19
  public findMember = (memberId: number) => {
package/src/BoxManager.ts CHANGED
@@ -63,7 +63,7 @@ export class BoxManager {
63
63
  this.teleBoxManager.events.on(TELE_BOX_MANAGER_EVENT.State, state => {
64
64
  if (state) {
65
65
  callbacks.emit("boxStateChange", state);
66
- emitter.emit(state as TELE_BOX_STATE, undefined);
66
+ emitter.emit("boxStateChange", state);
67
67
  }
68
68
  });
69
69
  this.teleBoxManager.events.on("minimized", minimized => {
@@ -181,6 +181,10 @@ export class Cursor extends Base {
181
181
 
182
182
  public setMember() {
183
183
  this.member = this.context.findMemberByUid(this.memberId);
184
+ this.updateComponent();
185
+ }
186
+
187
+ private updateComponent() {
184
188
  this.component?.$set(omit(this.initProps(), ["x", "y"]));
185
189
  }
186
190
 
@@ -187,7 +187,7 @@ export class CursorManager extends Base {
187
187
  }
188
188
  }
189
189
 
190
- public cleanMemberCursor(uid: string) {
190
+ public deleteCursor(uid: string) {
191
191
  this.store.cleanCursor(uid);
192
192
  const cursor = this.cursorInstances.get(uid);
193
193
  if (cursor) {
@@ -213,11 +213,7 @@ export class CursorManager extends Base {
213
213
  }
214
214
  });
215
215
  needDeleteIds.forEach(uid => {
216
- const instance = this.cursorInstances.get(uid);
217
- if (instance) {
218
- instance.destroy();
219
- }
220
- this.store.cleanCursor(uid);
216
+ this.deleteCursor(uid);
221
217
  });
222
218
  }
223
219
 
package/src/constants.ts CHANGED
@@ -2,9 +2,7 @@ export enum Events {
2
2
  AppMove = "AppMove",
3
3
  AppFocus = "AppFocus",
4
4
  AppResize = "AppResize",
5
- AppBlur = "AppBlur",
6
5
  AppBoxStateChange = "AppBoxStateChange",
7
- AppSnapshot = "AppSnapshot",
8
6
  GetAttributes = "GetAttributes",
9
7
  UpdateWindowManagerWrapper = "UpdateWindowManagerWrapper",
10
8
  InitReplay = "InitReplay",
package/src/index.ts CHANGED
@@ -120,7 +120,7 @@ export type AppInitState = {
120
120
  boxState?: TeleBoxState; // 兼容旧版 telebox
121
121
  };
122
122
 
123
- type EmitterEvent = {
123
+ export type EmitterEvent = {
124
124
  onCreated: undefined,
125
125
  InitReplay: AppInitState,
126
126
  move: { appId: string, x: number, y: number },
@@ -131,9 +131,7 @@ type EmitterEvent = {
131
131
  seek: number,
132
132
  mainViewMounted: undefined,
133
133
  observerIdChange: number;
134
- [TELE_BOX_STATE.Normal]: undefined,
135
- [TELE_BOX_STATE.Maximized]: undefined,
136
- [TELE_BOX_STATE.Minimized]: undefined,
134
+ boxStateChange: string;
137
135
  }
138
136
 
139
137
  export const emitter: Emittery<EmitterEvent> = new Emittery();
@@ -170,7 +168,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
170
168
  public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
171
169
  private static isCreated = false;
172
170
 
173
- public version = "0.3.5-canary.0";
171
+ public version = "0.3.6-canary.1";
174
172
 
175
173
  public appListeners?: AppListeners;
176
174