@netless/window-manager 0.3.24 → 0.3.27

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.
@@ -0,0 +1,19 @@
1
+ ## 清除所有笔迹
2
+
3
+ ```ts
4
+ // 删除根目录所有 scenes
5
+ room.removeScenes("/")
6
+
7
+ // 关闭所有 App
8
+ manager.queryAll().map(app => manager.closeApp(app.id))
9
+
10
+ // 清除掉之前的 index 信息
11
+ manager.safeSetAttributes({ _mainSceneIndex: undefined, _mainScenePath: undefined });
12
+
13
+ // 如果当前主白板 index 在第一页则切换一下 index 才可以让第一页恢复可写
14
+ setTimeout(async () => {
15
+ room.putScenes("/", [{}]);
16
+ await manager.setMainViewSceneIndex(1);
17
+ await manager.setMainViewSceneIndex(0);
18
+ }, 50);
19
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "0.3.24",
3
+ "version": "0.3.27",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
@@ -8,6 +8,7 @@
8
8
  "scripts": {
9
9
  "prettier": "prettier --write .",
10
10
  "build": "vite build && yarn type-gen",
11
+ "build:dev": "vite build --mode development && yarn type-gen",
11
12
  "type-gen": "tsc --emitDeclarationOnly",
12
13
  "predev": "yarn type-gen",
13
14
  "build:lib:types": "tsc --emitDeclarationOnly",
@@ -29,6 +30,9 @@
29
30
  "video.js": ">=7"
30
31
  },
31
32
  "devDependencies": {
33
+ "@netless/app-docs-viewer": "0.2.5",
34
+ "@netless/app-media-player": "0.1.0-beta.5",
35
+ "@netless/telebox-insider": "0.2.21",
32
36
  "@rollup/plugin-commonjs": "^20.0.0",
33
37
  "@rollup/plugin-node-resolve": "^13.0.4",
34
38
  "@rollup/plugin-url": "^6.1.0",
@@ -53,9 +57,6 @@
53
57
  "typescript": "^4.3.5",
54
58
  "video.js": "^7.14.3",
55
59
  "vite": "^2.5.3",
56
- "white-web-sdk": "^2.15.16",
57
- "@netless/telebox-insider": "0.2.21",
58
- "@netless/app-docs-viewer": "0.2.5",
59
- "@netless/app-media-player": "0.1.0-beta.5"
60
+ "white-web-sdk": "^2.15.16"
60
61
  }
61
62
  }
package/src/AppManager.ts CHANGED
@@ -70,6 +70,11 @@ export class AppManager {
70
70
  this.onAppDelete(this.attributes.apps);
71
71
  });
72
72
  }
73
+ emitter.on("setReadonly", () => {
74
+ this.appProxies.forEach(appProxy => {
75
+ appProxy.emitAppIsWritableChange();
76
+ });
77
+ });
73
78
  }
74
79
 
75
80
  private async onCreated() {
package/src/AppProxy.ts CHANGED
@@ -175,6 +175,9 @@ export class AppProxy {
175
175
  canOperate: this.manager.canOperate,
176
176
  smartPosition: this.isAddApp,
177
177
  });
178
+ if (this.isAddApp && this.box) {
179
+ this.store.updateAppState(appId, AppAttributes.ZIndex, this.box.zIndex);
180
+ }
178
181
  } catch (error: any) {
179
182
  console.error(error);
180
183
  throw new Error(`[WindowManager]: app setup error: ${error.message}`);
package/src/BoxManager.ts CHANGED
@@ -1,11 +1,7 @@
1
- import { callbacks, emitter, WindowManager } from "./index";
2
- import { debounce, maxBy } from "lodash";
3
1
  import { AppAttributes, Events, MIN_HEIGHT, MIN_WIDTH } from "./constants";
4
- import {
5
- TELE_BOX_STATE,
6
- TeleBoxCollector,
7
- TeleBoxManager,
8
- } from "@netless/telebox-insider";
2
+ import { callbacks, emitter, WindowManager } from "./index";
3
+ import { debounce } from "lodash";
4
+ import { TELE_BOX_STATE, TeleBoxCollector, TeleBoxManager } from "@netless/telebox-insider";
9
5
  import type { AddAppOptions, AppInitState } from "./index";
10
6
  import type {
11
7
  TeleBoxManagerUpdateConfig,
@@ -233,8 +229,7 @@ export class BoxManager {
233
229
  }
234
230
 
235
231
  public getTopBox(): ReadonlyTeleBox | undefined {
236
- const boxes = this.teleBoxManager.query();
237
- return maxBy(boxes, "zIndex");
232
+ return this.teleBoxManager.topBox;
238
233
  }
239
234
 
240
235
  public updateBoxState(state?: AppInitState): void {
package/src/index.ts CHANGED
@@ -141,6 +141,7 @@ export type EmitterEvent = {
141
141
  playgroundSizeChange: DOMRect;
142
142
  onReconnected: undefined;
143
143
  cursorMove: CursorMovePayload;
144
+ setReadonly: boolean;
144
145
  };
145
146
 
146
147
  export const emitter: Emittery<EmitterEvent> = new Emittery();
@@ -401,6 +402,9 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
401
402
  params.options.scenePath = ensureValidScenePath(params.options.scenePath);
402
403
  }
403
404
  const appId = await this.appManager.addApp(params, Boolean(isDynamicPPT));
405
+ // 瞬间调用多个 addApp 可能会造成 view 的状态设置错误, 这里手动加一个延迟
406
+ // 在 0.4.x 的版本已经重构了这个行为, 这里只是 workaround
407
+ await wait(200);
404
408
  return appId;
405
409
  } else {
406
410
  throw new AppManagerNotInitError();
@@ -479,10 +483,9 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
479
483
  * 设置所有 app 的 readonly 模式
480
484
  */
481
485
  public setReadonly(readonly: boolean): void {
482
- if (this.room?.isWritable) {
483
- this.readonly = readonly;
484
- this.appManager?.boxManager.setReadonly(readonly);
485
- }
486
+ this.readonly = readonly;
487
+ this.appManager?.boxManager.setReadonly(readonly);
488
+ emitter.emit("setReadonly", readonly);
486
489
  }
487
490
 
488
491
  /**