@netless/window-manager 1.0.7-beta.8 → 1.0.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": "1.0.7-beta.8",
3
+ "version": "1.0.8",
4
4
  "description": "Multi-window mode for Netless Whiteboard",
5
5
  "author": "l1shen <lishen1635@gmail.com> (https://github.com/l1shen)",
6
6
  "license": "MIT",
@@ -50,14 +50,14 @@ export class AppListeners {
50
50
  this.setMainViewScenePathHandler(data.payload);
51
51
  break;
52
52
  }
53
- case Events.MoveCamera: {
54
- this.moveCameraHandler(data.payload);
55
- break;
56
- }
57
- case Events.MoveCameraToContain: {
58
- this.moveCameraToContainHandler(data.payload);
59
- break;
60
- }
53
+ // case Events.MoveCamera: {
54
+ // this.moveCameraHandler(data.payload);
55
+ // break;
56
+ // }
57
+ // case Events.MoveCameraToContain: {
58
+ // this.moveCameraToContainHandler(data.payload);
59
+ // break;
60
+ // }
61
61
  case Events.CursorMove: {
62
62
  this.cursorMoveHandler(data.payload);
63
63
  break;
@@ -102,16 +102,16 @@ export class AppListeners {
102
102
  callbacks.emit("mainViewScenePathChange", nextScenePath);
103
103
  };
104
104
 
105
- private moveCameraHandler = (
106
- payload: Camera & { animationMode?: AnimationMode | undefined }
107
- ) => {
108
- if (isEqual(omit(payload, ["animationMode"]), { ...this.manager.mainView.camera })) return;
109
- this.manager.mainView.moveCamera(payload);
110
- };
105
+ // private moveCameraHandler = (
106
+ // payload: Camera & { animationMode?: AnimationMode | undefined }
107
+ // ) => {
108
+ // if (isEqual(omit(payload, ["animationMode"]), { ...this.manager.mainView.camera })) return;
109
+ // this.manager.mainView.moveCamera(payload);
110
+ // };
111
111
 
112
- private moveCameraToContainHandler = (payload: any) => {
113
- this.manager.mainView.moveCameraToContain(payload);
114
- };
112
+ // private moveCameraToContainHandler = (payload: any) => {
113
+ // this.manager.mainView.moveCameraToContain(payload);
114
+ // };
115
115
 
116
116
  private cursorMoveHandler = (payload: any) => {
117
117
  internalEmitter.emit("cursorMove", payload);
package/src/AppManager.ts CHANGED
@@ -72,7 +72,9 @@ export class AppManager {
72
72
  private callbacksNode: ScenesCallbacksNode | null = null;
73
73
  private appCreateQueue = new AppCreateQueue();
74
74
 
75
- private _focusAppCreatedResolve?: (appProxy: AppProxy) => void;
75
+ private _focusAppCreatedResolve?: (appProxy?: AppProxy) => void;
76
+ private _focusAppId: string | undefined;
77
+ private _resolveTimer: number | undefined;
76
78
 
77
79
  private sideEffectManager = new SideEffectManager();
78
80
 
@@ -342,8 +344,12 @@ export class AppManager {
342
344
 
343
345
  private async onCreated() {
344
346
  if (Object.keys(this.attributes.apps).length && this.store.focus) {
345
- await new Promise<AppProxy>(resolve => {
347
+ this._focusAppId = this.store.focus;
348
+ await new Promise<AppProxy | undefined>(resolve => {
346
349
  this._focusAppCreatedResolve = resolve;
350
+ this._resolveTimer = setTimeout(() => {
351
+ resolve(this.appProxies.get(this._focusAppId || ''));
352
+ }, 500);
347
353
  }).then(() => {
348
354
  this.focusByAttributes(this.attributes.apps);
349
355
  });
@@ -595,7 +601,7 @@ export class AppManager {
595
601
  if (!appAttributes) {
596
602
  throw new Error("appAttributes is undefined");
597
603
  }
598
-
604
+
599
605
  this.appCreateQueue.push<AppProxy>(async () => {
600
606
  this.appStatus.set(id, AppStatus.StartCreate);
601
607
  const appProxy = await this.baseInsertApp(
@@ -612,9 +618,12 @@ export class AppManager {
612
618
  );
613
619
  if (
614
620
  appProxy &&
615
- this.store.focus === id &&
621
+ this._focusAppId === id &&
616
622
  this._focusAppCreatedResolve
617
623
  ) {
624
+ if (this._resolveTimer) {
625
+ clearTimeout(this._resolveTimer);
626
+ }
618
627
  this._focusAppCreatedResolve(appProxy);
619
628
  }
620
629
  return appProxy;
@@ -941,6 +950,10 @@ export class AppManager {
941
950
  this.sideEffectManager.flushAll();
942
951
  this._prevFocused = undefined;
943
952
  this._prevSceneIndex = undefined;
953
+ if (this._resolveTimer) {
954
+ clearTimeout(this._resolveTimer);
955
+ }
944
956
  this._focusAppCreatedResolve = undefined;
957
+ this._resolveTimer = undefined;
945
958
  }
946
959
  }
@@ -57,7 +57,6 @@ export function getExtendClass<T extends ExtendClassAble>(
57
57
  default:
58
58
  return baseClass;
59
59
  }
60
- } else {
61
- return baseClass;
62
60
  }
61
+ return baseClass;
63
62
  }
package/src/index.ts CHANGED
@@ -972,7 +972,7 @@ export class WindowManager
972
972
  const mainViewCamera = { ...this.mainView.camera };
973
973
  if (isEqual({ ...mainViewCamera, ...pureCamera }, mainViewCamera)) return;
974
974
  this.mainView.moveCamera(camera);
975
- this.appManager?.dispatchInternalEvent(Events.MoveCamera, camera);
975
+ // this.appManager?.dispatchInternalEvent(Events.MoveCamera, camera);
976
976
  setTimeout(() => {
977
977
  this.appManager?.mainViewProxy.setCameraAndSize();
978
978
  }, 500);
@@ -985,7 +985,7 @@ export class WindowManager
985
985
  }>
986
986
  ): void {
987
987
  this.mainView.moveCameraToContain(rectangle);
988
- this.appManager?.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
988
+ // this.appManager?.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
989
989
  setTimeout(() => {
990
990
  this.appManager?.mainViewProxy.setCameraAndSize();
991
991
  }, 500);