@netless/window-manager 0.4.0-canary.27 → 0.4.0-canary.28

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/docs/api.md CHANGED
@@ -11,6 +11,7 @@
11
11
  - [`closeApp`](#closeApp)
12
12
  - [`setMainViewSceneIndex`](#setMainViewSceneIndex)
13
13
  - [`setBoxState`](#setBoxState)
14
+ - [`cleanCurrentScene`](#cleanCurrentScene)
14
15
  - [实例属性](#prototypes)
15
16
  - [事件回调](#events)
16
17
 
@@ -128,6 +129,14 @@ manager.setMainViewSceneIndex(1)
128
129
  manager.setBoxState("normal") // boxState: normal | maximized | minimized
129
130
  ```
130
131
 
132
+ <h3 id="cleanCurrentScene">cleanCurrentScene</h3>
133
+
134
+ > 清除当前 focus 的 view 的笔迹
135
+
136
+ ```ts
137
+ manager.cleanCurrentScene()
138
+ ```
139
+
131
140
  <br>
132
141
 
133
142
  <h2 id="prototypes">实例属性</h2>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "0.4.0-canary.27",
3
+ "version": "0.4.0-canary.28",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
@@ -58,6 +58,6 @@
58
58
  "typescript": "^4.3.5",
59
59
  "video.js": "^7.14.3",
60
60
  "vite": "^2.5.3",
61
- "white-web-sdk": "^2.16.1"
61
+ "white-web-sdk": "^2.16.3"
62
62
  }
63
63
  }
package/src/AppManager.ts CHANGED
@@ -439,7 +439,7 @@ export class AppManager {
439
439
  this.safeSetAttributes({ _mainScenePath: scenePath });
440
440
  this.store.setMainViewFocusPath(this.mainView);
441
441
  this.updateSceneIndex();
442
- this.dispatchInternalEvent(Events.SetMainViewScenePath, { nextScenePath: scenePath });
442
+ this.dispatchSetMainViewScenePath(scenePath);
443
443
  }
444
444
  }
445
445
 
@@ -469,9 +469,7 @@ export class AppManager {
469
469
  if (success) {
470
470
  this.store.setMainViewScenePath(scenePath);
471
471
  this.safeSetAttributes({ _mainSceneIndex: index });
472
- this.dispatchInternalEvent(Events.SetMainViewScenePath, {
473
- nextScenePath: scenePath,
474
- });
472
+ this.dispatchSetMainViewScenePath(scenePath);
475
473
  }
476
474
  } else {
477
475
  throw new Error(`[WindowManager]: ${sceneDir}: ${index} not valid index`);
@@ -480,6 +478,12 @@ export class AppManager {
480
478
  }
481
479
  }
482
480
 
481
+ private dispatchSetMainViewScenePath(scenePath: string): void {
482
+ this.dispatchInternalEvent(Events.SetMainViewScenePath, { nextScenePath: scenePath });
483
+ // 兼容 15 的 SDK, 需要 room 的当前 ScenePath
484
+ setScenePath(this.room, scenePath);
485
+ }
486
+
483
487
  public getAppInitPath(appId: string): string | undefined {
484
488
  const attrs = this.store.getAppAttributes(appId);
485
489
  if (attrs) {
package/src/Helper.ts CHANGED
@@ -1,3 +1,7 @@
1
+ import { getVersionNumber } from "./Utils/Common";
2
+ import { REQUIRE_VERSION } from "./constants";
3
+ import { WhiteVersion } from "white-web-sdk";
4
+ import { WhiteWebSDKInvalidError } from "./Utils/error";
1
5
  import { WindowManager } from "./index";
2
6
 
3
7
  export const setupWrapper = (
@@ -27,4 +31,11 @@ export const setupWrapper = (
27
31
  WindowManager.wrapper = wrapper;
28
32
 
29
33
  return { playground, wrapper, sizer, mainViewElement };
30
- };
34
+ };
35
+
36
+ export const checkVersion = () => {
37
+ const version = getVersionNumber(WhiteVersion);
38
+ if (version < getVersionNumber(REQUIRE_VERSION)) {
39
+ throw new WhiteWebSDKInvalidError(REQUIRE_VERSION);
40
+ }
41
+ };
package/src/index.ts CHANGED
@@ -2,25 +2,25 @@ import Emittery from "emittery";
2
2
  import pRetry from "p-retry";
3
3
  import { AppManager } from "./AppManager";
4
4
  import { appRegister } from "./Register";
5
+ import { checkVersion, setupWrapper } from "./Helper";
5
6
  import { ContainerResizeObserver } from "./ContainerResizeObserver";
6
7
  import { createBoxManager } from "./BoxManager";
7
8
  import { CursorManager } from "./Cursor";
8
- import { DEFAULT_CONTAINER_RATIO, Events, REQUIRE_VERSION } from "./constants";
9
+ import { DEFAULT_CONTAINER_RATIO, Events } from "./constants";
9
10
  import { Fields } from "./AttributesDelegate";
10
11
  import { initDb } from "./Register/storage";
12
+ import { InvisiblePlugin, isPlayer, isRoom, RoomPhase, ViewMode } from "white-web-sdk";
11
13
  import { isNull, isObject } from "lodash";
12
14
  import { log } from "./Utils/log";
13
15
  import { ReconnectRefresher } from "./ReconnectRefresher";
14
16
  import { replaceRoomFunction } from "./Utils/RoomHacker";
15
17
  import { setupBuiltin } from "./BuiltinApps";
16
- import { setupWrapper } from "./Helper";
17
18
  import "./style.css";
18
19
  import "@netless/telebox-insider/dist/style.css";
19
20
  import {
20
21
  addEmitterOnceListener,
21
22
  ensureValidScenePath,
22
23
  entireScenes,
23
- getVersionNumber,
24
24
  isValidScenePath,
25
25
  wait,
26
26
  } from "./Utils/Common";
@@ -30,17 +30,8 @@ import {
30
30
  AppManagerNotInitError,
31
31
  InvalidScenePath,
32
32
  ParamsInvalidError,
33
- WhiteWebSDKInvalidError,
34
33
  } from "./Utils/error";
35
34
  import type { Apps, Position } from "./AttributesDelegate";
36
- import {
37
- InvisiblePlugin,
38
- isPlayer,
39
- isRoom,
40
- RoomPhase,
41
- ViewMode,
42
- WhiteVersion,
43
- } from "white-web-sdk";
44
35
  import type {
45
36
  Displayer,
46
37
  SceneDefinition,
@@ -224,7 +215,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
224
215
  const cursor = params.cursor;
225
216
  WindowManager.params = params;
226
217
 
227
- this.checkVersion();
218
+ checkVersion();
228
219
  let manager: WindowManager | undefined = undefined;
229
220
  if (isRoom(room)) {
230
221
  if (room.phase !== RoomPhase.Connected) {
@@ -749,18 +740,20 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
749
740
  this.appManager?.boxManager?.setPrefersColorScheme(scheme);
750
741
  }
751
742
 
743
+ public cleanCurrentScene(): void {
744
+ const focused = this.focused;
745
+ if (focused) {
746
+ this.appManager?.focusApp?.view?.cleanCurrentScene();
747
+ } else {
748
+ this.mainView.cleanCurrentScene();
749
+ }
750
+ }
751
+
752
752
  private isDynamicPPT(scenes: SceneDefinition[]) {
753
753
  const sceneSrc = scenes[0]?.ppt?.src;
754
754
  return sceneSrc?.startsWith("pptx://");
755
755
  }
756
756
 
757
- private static checkVersion() {
758
- const version = getVersionNumber(WhiteVersion);
759
- if (version < getVersionNumber(REQUIRE_VERSION)) {
760
- throw new WhiteWebSDKInvalidError(REQUIRE_VERSION);
761
- }
762
- }
763
-
764
757
  private async ensureAttributes() {
765
758
  if (isNull(this.attributes)) {
766
759
  await wait(50);