@netless/window-manager 0.4.11-canary.1 → 0.4.11-canary.2

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.4.11-canary.1",
3
+ "version": "0.4.11-canary.2",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
package/src/AppManager.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AppAttributes, AppStatus, Events, MagixEventName, ROOT_DIR } from "./constants";
1
+ import { AppAttributes, AppStatus, Events, INIT_DIR, MagixEventName, ROOT_DIR } from "./constants";
2
2
  import { AppCreateQueue } from "./Utils/AppCreateQueue";
3
3
  import { AppListeners } from "./AppListener";
4
4
  import { AppProxy } from "./AppProxy";
@@ -106,17 +106,20 @@ export class AppManager {
106
106
  }
107
107
 
108
108
  private onRemoveScenes = (scenePath: string) => {
109
+ // 如果移除根目录就把 scenePath 设置为初始值
109
110
  if (scenePath === ROOT_DIR) {
110
- this.setMainViewScenePath("");
111
+ this.setMainViewScenePath(INIT_DIR);
111
112
  this.createRootDirScenesCallback();
112
113
  this.onRootDirRemoved();
113
114
  emitter.emit("rootDirRemoved");
114
115
  return;
115
116
  }
117
+ // 如果移除的 path 跟 MainViewScenePath 相同就取当前目录的当前 index
116
118
  const mainViewScenePath = this.store.getMainViewScenePath();
117
119
  if (this.room && mainViewScenePath) {
118
120
  if (mainViewScenePath === scenePath) {
119
- this.setMainViewScenePath("");
121
+ const nextPath = this.callbacksNode?.scenes[this.store.getMainViewSceneIndex()];
122
+ this.setMainViewScenePath(`/${nextPath}` || INIT_DIR);
120
123
  }
121
124
  }
122
125
  };
package/src/constants.ts CHANGED
@@ -49,3 +49,4 @@ export const SET_SCENEPATH_DELAY = 100; // 设置 scenePath 的延迟事件
49
49
  export const DEFAULT_CONTAINER_RATIO = 9 / 16;
50
50
 
51
51
  export const ROOT_DIR = "/";
52
+ export const INIT_DIR = "/init";
package/src/index.ts CHANGED
@@ -6,7 +6,7 @@ import { checkVersion, setupWrapper } from "./Helper";
6
6
  import { ContainerResizeObserver } from "./ContainerResizeObserver";
7
7
  import { createBoxManager } from "./BoxManager";
8
8
  import { CursorManager } from "./Cursor";
9
- import { DEFAULT_CONTAINER_RATIO, Events, ROOT_DIR } from "./constants";
9
+ import { DEFAULT_CONTAINER_RATIO, Events, INIT_DIR, ROOT_DIR } from "./constants";
10
10
  import { emitter } from "./InternalEmitter";
11
11
  import { Fields } from "./AttributesDelegate";
12
12
  import { initDb } from "./Register/storage";
@@ -870,7 +870,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
870
870
  this.safeSetAttributes({ [Fields.Cursors]: {} });
871
871
  }
872
872
  if (!this.attributes["_mainScenePath"]) {
873
- this.safeSetAttributes({ _mainScenePath: ROOT_DIR });
873
+ this.safeSetAttributes({ _mainScenePath: INIT_DIR });
874
874
  }
875
875
  if (!this.attributes["_mainSceneIndex"]) {
876
876
  this.safeSetAttributes({ _mainSceneIndex: 0 });