@netless/window-manager 0.3.8-canary.0 → 0.3.8

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.8-canary.0",
3
+ "version": "0.3.8",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
@@ -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.6"
59
+ "white-web-sdk": "^2.15.8"
60
60
  }
61
61
  }
@@ -3,6 +3,7 @@ import { Events, MagixEventName } from './constants';
3
3
  import type { Event } from "white-web-sdk";
4
4
  import type { AppManager } from "./AppManager";
5
5
  import type { TeleBoxState } from "@netless/telebox-insider";
6
+ import { setViewFocusScenePath } from './Utils/Common';
6
7
 
7
8
  export class AppListeners {
8
9
  private displayer = this.manager.displayer;
@@ -38,6 +39,10 @@ export class AppListeners {
38
39
  this.boxStateChangeHandler(data.payload);
39
40
  break;
40
41
  }
42
+ case Events.SetMainViewScenePath: {
43
+ this.setMainViewScenePathHandler(data.payload);
44
+ break;
45
+ }
41
46
  default:
42
47
  break;
43
48
  }
@@ -60,4 +65,8 @@ export class AppListeners {
60
65
  private boxStateChangeHandler = (state: TeleBoxState) => {
61
66
  callbacks.emit("boxStateChange", state);
62
67
  }
68
+
69
+ private setMainViewScenePathHandler = ({ nextScenePath }: { nextScenePath: string }) => {
70
+ setViewFocusScenePath(this.manager.mainView, nextScenePath);
71
+ }
63
72
  }
package/src/AppManager.ts CHANGED
@@ -1,12 +1,24 @@
1
- import { AppAttributes, AppStatus, Events, MagixEventName } from "./constants";
1
+ import pRetry from "p-retry";
2
+ import {
3
+ AppAttributes,
4
+ AppStatus,
5
+ Events,
6
+ MagixEventName
7
+ } from "./constants";
2
8
  import { AppListeners } from "./AppListener";
3
9
  import { AppProxy } from "./AppProxy";
4
10
  import { AttributesDelegate } from "./AttributesDelegate";
11
+ import {
12
+ autorun,
13
+ isPlayer,
14
+ isRoom,
15
+ ScenePathType,
16
+ ViewVisionMode
17
+ } from "white-web-sdk";
5
18
  import { BoxManager } from "./BoxManager";
6
19
  import { callbacks, emitter } from "./index";
7
20
  import { CameraStore } from "./Utils/CameraStore";
8
21
  import { genAppId, makeValidScenePath, setScenePath } from "./Utils/Common";
9
- import { autorun, isPlayer, isRoom, ScenePathType, ViewVisionMode } from "white-web-sdk";
10
22
  import { log } from "./Utils/log";
11
23
  import { MainViewProxy } from "./MainView";
12
24
  import { onObjectRemoved, safeListenPropsUpdated } from "./Utils/Reactive";
@@ -117,16 +129,28 @@ export class AppManager {
117
129
  for (const id in apps) {
118
130
  if (!this.appProxies.has(id) && !this.appStatus.has(id)) {
119
131
  const app = apps[id];
120
- await this.baseInsertApp(
121
- {
122
- kind: app.kind,
123
- options: app.options,
124
- isDynamicPPT: app.isDynamicPPT,
125
- },
126
- id,
127
- false
128
- );
129
- this.focusByAttributes(apps);
132
+
133
+ pRetry(async () => {
134
+ this.appStatus.set(id, AppStatus.StartCreate);
135
+ // 防御 appAttributes 有可能为 undefined 的情况,这里做一个重试
136
+ const appAttributes = this.attributes[id];
137
+ if (!appAttributes) {
138
+ throw new Error("appAttributes is undefined");
139
+ }
140
+ await this.baseInsertApp(
141
+ {
142
+ kind: app.kind,
143
+ options: app.options,
144
+ isDynamicPPT: app.isDynamicPPT,
145
+ },
146
+ id,
147
+ false
148
+ );
149
+ this.focusByAttributes(apps);
150
+ }, { retries: 3 }).catch(err => {
151
+ console.warn(`[WindowManager]: Insert App Error`, err);
152
+ this.appStatus.delete(id);
153
+ });
130
154
  }
131
155
  }
132
156
  }
@@ -169,9 +193,6 @@ export class AppManager {
169
193
  const attrs = params.attributes ?? {};
170
194
  this.safeUpdateAttributes([appId], attrs);
171
195
  this.store.setupAppAttributes(params, appId, isDynamicPPT);
172
- if (this.boxManager.minimized) {
173
- this.boxManager.setMinimized(false);
174
- }
175
196
  const needFocus = !this.boxManager.minimized;
176
197
  if (needFocus) {
177
198
  this.store.setAppFocus(appId, true);
@@ -187,6 +208,9 @@ export class AppManager {
187
208
  y: appProxy.box?.y,
188
209
  });
189
210
  }
211
+ if (this.boxManager.minimized) {
212
+ this.boxManager.setMinimized(false, false);
213
+ }
190
214
  }
191
215
 
192
216
  public async closeApp(appId: string) {
@@ -202,7 +226,6 @@ export class AppManager {
202
226
  isAddApp: boolean,
203
227
  focus?: boolean
204
228
  ) {
205
- this.appStatus.set(appId, AppStatus.StartCreate);
206
229
  if (this.appProxies.has(appId)) {
207
230
  console.warn("[WindowManager]: app duplicate exists and cannot be created again");
208
231
  return;
@@ -314,6 +337,7 @@ export class AppManager {
314
337
  await this.viewManager.switchMainViewToWriter();
315
338
  setScenePath(this.room, scenePath);
316
339
  this.store.setMainViewFocusPath();
340
+ this.dispatchInternalEvent(Events.SetMainViewScenePath, { nextScenePath: scenePath });
317
341
  }
318
342
 
319
343
  public async setMainViewSceneIndex(index: number) {
@@ -321,8 +345,10 @@ export class AppManager {
321
345
  this.safeSetAttributes({ _mainSceneIndex: index });
322
346
  await this.viewManager.switchMainViewToWriter();
323
347
  this.room.setSceneIndex(index);
324
- this.store.setMainViewScenePath(this.room.state.sceneState.scenePath);
348
+ const nextScenePath = this.room.state.sceneState.scenePath;
349
+ this.store.setMainViewScenePath(nextScenePath);
325
350
  this.store.setMainViewFocusPath();
351
+ this.dispatchInternalEvent(Events.SetMainViewScenePath, { nextScenePath });
326
352
  }
327
353
  }
328
354
 
package/src/BoxManager.ts CHANGED
@@ -290,8 +290,8 @@ export class BoxManager {
290
290
  this.teleBoxManager.setMaximized(maximized, true);
291
291
  }
292
292
 
293
- public setMinimized(minimized: boolean) {
294
- this.teleBoxManager.setMinimized(minimized, true);
293
+ public setMinimized(minimized: boolean, skipUpdate = true) {
294
+ this.teleBoxManager.setMinimized(minimized, skipUpdate);
295
295
  }
296
296
 
297
297
  public setReadonly(readonly: boolean) {
package/src/index.ts CHANGED
@@ -169,7 +169,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
169
169
  public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
170
170
  private static isCreated = false;
171
171
 
172
- public version = "0.3.8-canary.0";
172
+ public version = "0.3.8";
173
173
 
174
174
  public appListeners?: AppListeners;
175
175
 
@@ -2,11 +2,7 @@ import { Base } from "./Base";
2
2
  import { callbacks, WindowManager } from "./index";
3
3
  import { reaction, ViewVisionMode } from "white-web-sdk";
4
4
  import { SET_SCENEPATH_DELAY } from "./constants";
5
- import {
6
- notifyMainViewModeChange,
7
- setScenePath,
8
- setViewMode,
9
- } from "./Utils/Common";
5
+ import { notifyMainViewModeChange, setScenePath, setViewMode } from "./Utils/Common";
10
6
  import type { View } from "white-web-sdk";
11
7
  import type { AppManager } from "./AppManager";
12
8