@netless/window-manager 1.0.0-canary.38 → 1.0.0-canary.39

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.
@@ -19,7 +19,7 @@ export declare class BoxNotCreatedError extends Error {
19
19
  export declare class InvalidScenePath extends Error {
20
20
  message: string;
21
21
  }
22
- export declare class BoxManagerNotFoundError extends Error {
22
+ export declare class BoxManagerNotInitializeError extends Error {
23
23
  message: string;
24
24
  }
25
25
  export declare class BindContainerRoomPhaseInvalidError extends Error {
@@ -1,9 +1,9 @@
1
1
  import Emittery from "emittery";
2
- import type { TeleBoxColorScheme, TELE_BOX_STATE } from "@netless/telebox-insider";
2
+ import type { TeleBoxColorScheme, TeleBoxFullscreen, TELE_BOX_STATE } from "@netless/telebox-insider";
3
3
  import type { CameraState, SceneState, ViewVisionMode } from "white-web-sdk";
4
4
  import type { LoadAppEvent } from "./Register";
5
5
  import type { PageState } from "./Page";
6
- import { ICamera, ISize } from "./AttributesDelegate";
6
+ import type { ICamera, ISize } from "./AttributesDelegate";
7
7
  export declare type PublicEvent = {
8
8
  mainViewModeChange: ViewVisionMode;
9
9
  boxStateChange: `${TELE_BOX_STATE}`;
@@ -27,6 +27,7 @@ export declare type PublicEvent = {
27
27
  };
28
28
  baseCameraChange: ICamera;
29
29
  baseSizeChange: ISize;
30
+ fullscreenChange: TeleBoxFullscreen;
30
31
  };
31
32
  export declare type CallbacksType = Emittery<PublicEvent>;
32
33
  export declare const callbacks: CallbacksType;
@@ -8,7 +8,7 @@ import type { Apps, Position, ICamera, ISize } from "./AttributesDelegate";
8
8
  import type { Displayer, SceneDefinition, View, Room, InvisiblePluginContext, Camera, CameraBound, Point, CameraState, Player, ImageInformation, SceneState, Size } from "white-web-sdk";
9
9
  import type { AppListeners } from "./AppListener";
10
10
  import type { ApplianceIcons, NetlessApp, RegisterParams } from "./typings";
11
- import type { TeleBoxColorScheme, TeleBoxFullscreen, TeleBoxManagerThemeConfig, TeleBoxState } from "@netless/telebox-insider";
11
+ import type { TeleBoxColorScheme, TeleBoxFullscreen, TeleBoxManager, TeleBoxManagerThemeConfig, TeleBoxState } from "@netless/telebox-insider";
12
12
  import type { AppProxy } from "./App";
13
13
  import type { PublicEvent } from "./callback";
14
14
  import type Emittery from "emittery";
@@ -218,6 +218,7 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
218
218
  get canUndoSteps(): number;
219
219
  get sceneState(): SceneState;
220
220
  get pageState(): PageState;
221
+ get teleboxManager(): TeleBoxManager;
221
222
  /**
222
223
  * 查询所有的 App
223
224
  */
@@ -230,9 +231,9 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
230
231
  * 关闭 APP
231
232
  */
232
233
  closeApp(appId: string): Promise<void>;
233
- moveCamera(camera: Partial<Camera> & {
234
+ moveCamera: import("lodash").DebouncedFunc<(camera: Partial<Camera> & {
234
235
  animationMode?: AnimationMode;
235
- }): void;
236
+ }) => void>;
236
237
  convertToPointInWorld(point: Point): Point;
237
238
  setCameraBound(cameraBound: CameraBound): void;
238
239
  onDestroy(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "1.0.0-canary.38",
3
+ "version": "1.0.0-canary.39",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@juggle/resize-observer": "^3.3.1",
28
- "@netless/telebox-insider": "1.0.0-alpha.33",
28
+ "@netless/telebox-insider": "1.0.0-alpha.34",
29
29
  "emittery": "^0.11.0",
30
30
  "lodash": "^4.17.21",
31
31
  "p-retry": "^4.6.2",
@@ -6,7 +6,7 @@ import { appRegister } from "../Register";
6
6
  import { ViewSync } from "../View/ViewSync"
7
7
  import { autorun, reaction, toJS } from "white-web-sdk";
8
8
  import { boxEmitter } from "../BoxEmitter";
9
- import { BoxManagerNotFoundError } from "../Utils/error";
9
+ import { BoxManagerNotInitializeError } from "../Utils/error";
10
10
  import { calculateNextIndex } from "../Page";
11
11
  import { combine, Val, ValManager } from "value-enhancer";
12
12
  import { debounce, get, isEqual, isUndefined, omitBy } from "lodash";
@@ -312,7 +312,7 @@ export class AppProxy implements PageRemoveService {
312
312
  ) {
313
313
  log("setupApp", appId, app, options);
314
314
  if (!this.boxManager) {
315
- throw new BoxManagerNotFoundError();
315
+ throw new BoxManagerNotInitializeError();
316
316
  }
317
317
  const context = new AppContext(this.manager, appId, this, appOptions);
318
318
  this.appContext = context;
package/src/BoxManager.ts CHANGED
@@ -14,8 +14,9 @@ import type {
14
14
  TeleBoxColorScheme,
15
15
  TeleBoxRect,
16
16
  TeleBoxConfig,
17
- TeleBoxFullscreen
18
- , TeleBoxManagerThemeConfig } from "@netless/telebox-insider";
17
+ TeleBoxFullscreen,
18
+ TeleBoxManagerThemeConfig,
19
+ } from "@netless/telebox-insider";
19
20
  import type Emittery from "emittery";
20
21
  import type { NetlessApp } from "./typings";
21
22
  import type { View } from "white-web-sdk";
@@ -179,6 +180,9 @@ export class BoxManager {
179
180
  emitter.on("containerSizeRatioUpdate", ratio => {
180
181
  this.teleBoxManager._stageRatio$.setValue(ratio);
181
182
  }),
183
+ this.teleBoxManager._fullscreen$.reaction(fullscreen => {
184
+ callbacks.emit("fullscreenChange", fullscreen);
185
+ }),
182
186
  ]);
183
187
  }
184
188
 
@@ -31,8 +31,8 @@ export class InvalidScenePath extends Error {
31
31
  override message = `[WindowManager]: ScenePath should start with "/"`;
32
32
  }
33
33
 
34
- export class BoxManagerNotFoundError extends Error {
35
- override message = "[WindowManager]: boxManager not found";
34
+ export class BoxManagerNotInitializeError extends Error {
35
+ override message = "[WindowManager]: boxManager need initialize";
36
36
  }
37
37
 
38
38
  export class BindContainerRoomPhaseInvalidError extends Error {
package/src/callback.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import Emittery from "emittery";
2
- import type { TeleBoxColorScheme, TELE_BOX_STATE } from "@netless/telebox-insider";
3
- import type { Camera, CameraState, SceneState, Size, ViewVisionMode } from "white-web-sdk";
2
+ import type { TeleBoxColorScheme, TeleBoxFullscreen, TELE_BOX_STATE } from "@netless/telebox-insider";
3
+ import type { CameraState, SceneState, ViewVisionMode } from "white-web-sdk";
4
4
  import type { LoadAppEvent } from "./Register";
5
5
  import type { PageState } from "./Page";
6
- import { ICamera, ISize } from "./AttributesDelegate";
6
+ import type { ICamera, ISize } from "./AttributesDelegate";
7
7
 
8
8
  export type PublicEvent = {
9
9
  mainViewModeChange: ViewVisionMode;
@@ -24,6 +24,7 @@ export type PublicEvent = {
24
24
  appClose: { appId: string; kind: string, error?: Error };
25
25
  baseCameraChange: ICamera;
26
26
  baseSizeChange: ISize;
27
+ fullscreenChange: TeleBoxFullscreen;
27
28
  };
28
29
 
29
30
  export type CallbacksType = Emittery<PublicEvent>;
package/src/index.ts CHANGED
@@ -10,7 +10,7 @@ import { emitter } from "./InternalEmitter";
10
10
  import { Fields } from "./AttributesDelegate";
11
11
  import { initDb } from "./Register/storage";
12
12
  import { AnimationMode, InvisiblePlugin, isPlayer, isRoom, RoomPhase, ViewMode } from "white-web-sdk";
13
- import { isEqual, isNull, isObject, isNumber } from "lodash";
13
+ import { isEqual, isNull, isObject, isNumber, debounce } from "lodash";
14
14
  import { log } from "./Utils/log";
15
15
  import { PageStateImpl } from "./PageState";
16
16
  import { ReconnectRefresher } from "./ReconnectRefresher";
@@ -48,7 +48,7 @@ import type {
48
48
  } from "white-web-sdk";
49
49
  import type { AppListeners } from "./AppListener";
50
50
  import type { ApplianceIcons, NetlessApp, RegisterParams } from "./typings";
51
- import type { TeleBoxColorScheme, TeleBoxFullscreen, TeleBoxManagerThemeConfig, TeleBoxState } from "@netless/telebox-insider";
51
+ import type { TeleBoxColorScheme, TeleBoxFullscreen, TeleBoxManager, TeleBoxManagerThemeConfig, TeleBoxState } from "@netless/telebox-insider";
52
52
  import type { AppProxy } from "./App";
53
53
  import type { PublicEvent } from "./callback";
54
54
  import type Emittery from "emittery";
@@ -777,6 +777,13 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
777
777
  }
778
778
  }
779
779
 
780
+ public get teleboxManager(): TeleBoxManager {
781
+ if (!this.boxManager) {
782
+ throw new Errors.BoxManagerNotInitializeError();
783
+ }
784
+ return this.boxManager.teleBoxManager;
785
+ }
786
+
780
787
  /**
781
788
  * 查询所有的 App
782
789
  */
@@ -798,7 +805,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
798
805
  return this.appManager?.closeApp(appId);
799
806
  }
800
807
 
801
- public moveCamera(camera: Partial<Camera> & { animationMode?: AnimationMode } ): void {
808
+ public moveCamera = debounce((camera: Partial<Camera> & { animationMode?: AnimationMode } ): void => {
802
809
  const mainViewCamera = { ...this.mainView.camera };
803
810
  const nextCamera = { ...mainViewCamera, ...camera };
804
811
  if (isEqual(nextCamera, mainViewCamera)) return;
@@ -832,66 +839,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
832
839
  });
833
840
  }, 200);
834
841
  }
835
- }
836
-
837
- // public moveCameraToContain(rectangle: Rectangle & { animationMode?: AnimationMode }): void {
838
- // this.setBaseSize(rectangle);
839
- // const centerX = rectangle.originX + (rectangle.width / 2);
840
- // const centerY = rectangle.originY + (rectangle.height / 2);
841
- // setTimeout(() => {
842
- // this.moveCamera({ centerX, centerY, animationMode: rectangle.animationMode });
843
- // }, 500);
844
- // // if (!this.appManager) return;
845
- // // const camera: Partial<Camera> = {};
846
- // // if (isNumber(rectangle.originX)) {
847
- // // camera.centerX = rectangle.originX;
848
- // // }
849
- // // if (isNumber(rectangle.originY)) {
850
- // // camera.centerY = rectangle.originY;
851
- // // }
852
- // // if (rectangle.animationMode === AnimationMode.Immediately) {
853
- // // this.appManager.mainViewProxy.storeSize({
854
- // // id: this.appManager.uid,
855
- // // width: rectangle.width,
856
- // // height: rectangle.height,
857
- // // });
858
- // // this.mainView.moveCameraToContain(rectangle);
859
- // // if (!isEmpty(camera) && this.appManager.mainViewProxy.camera$.value) {
860
- // // this.appManager.mainViewProxy.storeCamera({
861
- // // ...this.appManager.mainViewProxy.camera$.value,
862
- // // id: this.appManager.uid,
863
- // // centerX: this.mainView.camera.centerX,
864
- // // centerY: this.mainView.camera.centerY
865
- // // });
866
- // // }
867
- // // } else {
868
- // // this.appManager.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
869
- // // this.mainView.moveCameraToContain(rectangle);
870
- // // if (!this.baseCamera) return;
871
- // // const remoteSize = rectangle;
872
- // // const currentSize = this.boxManager?.stageRect;
873
- // // if (!currentSize) return;
874
- // // const nextScale = this.baseCamera.scale * computedMinScale(remoteSize, currentSize);
875
- // // setTimeout(() => {
876
- // // if (!this.appManager) return;
877
- // // this.appManager.mainViewProxy.storeSize({
878
- // // id: this.appManager.uid,
879
- // // width: rectangle.width,
880
- // // height: rectangle.height,
881
- // // });
882
-
883
- // // if (!isEmpty(camera) && this.appManager.mainViewProxy.camera$.value) {
884
- // // this.appManager.mainViewProxy.storeCamera({
885
- // // ...this.appManager.mainViewProxy.camera$.value,
886
- // // id: this.appManager.uid,
887
- // // centerX: this.mainView.camera.centerX,
888
- // // centerY: this.mainView.camera.centerY,
889
- // // scale: nextScale
890
- // // });
891
- // // }
892
- // // }, 500);
893
- // // }
894
- // }
842
+ }, 200);
895
843
 
896
844
  public convertToPointInWorld(point: Point): Point {
897
845
  return this.mainView.convertToPointInWorld(point);
@@ -1044,6 +992,14 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
1044
992
 
1045
993
  public setBaseSize(size: Size) {
1046
994
  this.appManager?.mainViewProxy.setMainViewSize(size);
995
+ setTimeout(() => {
996
+ if (!this.appManager || !this.appManager.mainViewProxy.camera$.value) return;
997
+ this.appManager.mainViewProxy.storeCamera({
998
+ ...this.appManager.mainViewProxy.camera$.value,
999
+ id: this.appManager.uid,
1000
+ scale: 1
1001
+ });
1002
+ }, 500);
1047
1003
  }
1048
1004
 
1049
1005
  public createPPTHandler() {