@netless/window-manager 1.0.6 → 1.0.7-beta.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": "1.0.6",
3
+ "version": "1.0.7-beta.1",
4
4
  "description": "Multi-window mode for Netless Whiteboard",
5
5
  "author": "l1shen <lishen1635@gmail.com> (https://github.com/l1shen)",
6
6
  "license": "MIT",
@@ -187,6 +187,11 @@ export class AppProxy implements PageRemoveService {
187
187
  this.appEmitter.onAny(this.appListener);
188
188
  this.appAttributesUpdateListener(appId);
189
189
  this.setViewFocusScenePath();
190
+ // 如果当前是回放模式, 则需要记录当前主视图的场景路径, 以便在 app 创建后恢复
191
+ let currentMainViewScenePath: string | undefined;
192
+ if (this.manager.isReplay) {
193
+ currentMainViewScenePath = (this.manager.mainView as any).scenePath as string;
194
+ }
190
195
  setTimeout(async () => {
191
196
  // 延迟执行 setup, 防止初始化的属性没有更新成功
192
197
  console.log("setup app", app);
@@ -195,6 +200,9 @@ export class AppProxy implements PageRemoveService {
195
200
  appRegister.notifyApp(this.kind, "created", { appId, result });
196
201
  this.afterSetupApp(boxInitState);
197
202
  this.fixMobileSize();
203
+ if (currentMainViewScenePath) {
204
+ this.manager.mainViewProxy.setFocusScenePath(currentMainViewScenePath);
205
+ }
198
206
  callbacks.emit("onAppSetup", appId);
199
207
  }, SETUP_APP_DELAY);
200
208
  });
package/src/AppManager.ts CHANGED
@@ -3,7 +3,7 @@ import { AppCreateQueue } from "./Utils/AppCreateQueue";
3
3
  import { AppListeners } from "./AppListener";
4
4
  import { AppProxy } from "./App";
5
5
  import { appRegister } from "./Register";
6
- import { autorun, isPlayer, isRoom, ScenePathType } from "white-web-sdk";
6
+ import { autorun, isPlayer, isRoom, ScenePathType, UpdateEventKind } from "white-web-sdk";
7
7
  import { boxEmitter } from "./BoxEmitter";
8
8
  import { calculateNextIndex } from "./Page";
9
9
  import { callbacks } from "./callback";
@@ -12,7 +12,7 @@ import { internalEmitter } from "./InternalEmitter";
12
12
  import { Fields, store } from "./AttributesDelegate";
13
13
  import { log } from "./Utils/log";
14
14
  import { MainViewProxy } from "./View/MainView";
15
- import { onObjectRemoved, safeListenPropsUpdated } from "./Utils/Reactive";
15
+ import { safeListenPropsUpdated } from "./Utils/Reactive";
16
16
  import { reconnectRefresher, WindowManager } from "./index";
17
17
  import { RedoUndo } from "./RedoUndo";
18
18
  import { SideEffectManager } from "side-effect-manager";
@@ -438,10 +438,20 @@ export class AppManager {
438
438
  };
439
439
 
440
440
  public addAppCloseListener = () => {
441
+ // this.refresher.add("appsClose", () => {
442
+ // return onObjectRemoved(this.attributes.apps, () => {
443
+ // this.onAppDelete(this.attributes.apps);
444
+ // });
445
+ // });
441
446
  this.refresher.add("appsClose", () => {
442
- return onObjectRemoved(this.attributes.apps, () => {
443
- this.onAppDelete(this.attributes.apps);
444
- });
447
+ return safeListenPropsUpdated(
448
+ () => this.attributes.apps,
449
+ events => {
450
+ if (events.some(e => e.kind === UpdateEventKind.Removed)) {
451
+ this.onAppDelete(this.attributes.apps);
452
+ }
453
+ }
454
+ );
445
455
  });
446
456
  };
447
457