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

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.
@@ -5,7 +5,7 @@ import { ReconnectRefresher } from "./ReconnectRefresher";
5
5
  import { Val } from "value-enhancer";
6
6
  import type { TELE_BOX_STATE } from "./BoxManager";
7
7
  import type { Apps, Position, ICamera, ISize } from "./AttributesDelegate";
8
- import type { Displayer, SceneDefinition, View, Room, InvisiblePluginContext, Camera, CameraBound, Point, CameraState, Player, ImageInformation, SceneState, Rectangle, Size } from "white-web-sdk";
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
11
  import type { TeleBoxColorScheme, TeleBoxFullscreen, TeleBoxManagerThemeConfig, TeleBoxState } from "@netless/telebox-insider";
@@ -233,9 +233,6 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
233
233
  moveCamera(camera: Partial<Camera> & {
234
234
  animationMode?: AnimationMode;
235
235
  }): void;
236
- moveCameraToContain(rectangle: Rectangle & {
237
- animationMode?: AnimationMode;
238
- }): void;
239
236
  convertToPointInWorld(point: Point): Point;
240
237
  setCameraBound(cameraBound: CameraBound): void;
241
238
  onDestroy(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "1.0.0-canary.37",
3
+ "version": "1.0.0-canary.38",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
@@ -48,11 +48,14 @@ export class CameraSynchronizer {
48
48
  this.remoteSize = size;
49
49
  const needMoveCamera = !isEqual(pick(this.rect, ["width", "height"]), pick(size, ["width", "height"]));
50
50
  if (this.rect && this.remoteCamera && needMoveCamera) {
51
- const scale = this.rect.width / size.width;
52
- const nextScale = this.remoteCamera.scale * scale;
53
- this.moveCamera({
54
- scale: nextScale,
55
- })
51
+ if (!this.view) return;
52
+ const currentCamera = this.view.camera;
53
+ this.view?.moveCameraToContain({
54
+ width: size.width,
55
+ height: size.height,
56
+ originX: currentCamera.centerX - (size.width / 2),
57
+ originY: currentCamera.centerY - (size.height / 2),
58
+ });
56
59
  }
57
60
  }
58
61
 
@@ -1,4 +1,4 @@
1
- import { ViewMode, AnimationMode, Size } from "white-web-sdk";
1
+ import { ViewMode, AnimationMode } from "white-web-sdk";
2
2
  import { CameraSynchronizer, computedMinScale } from "./CameraSynchronizer";
3
3
  import { combine } from "value-enhancer";
4
4
  import { SideEffectManager } from "side-effect-manager";
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, isEmpty } from "lodash";
13
+ import { isEqual, isNull, isObject, isNumber } from "lodash";
14
14
  import { log } from "./Utils/log";
15
15
  import { PageStateImpl } from "./PageState";
16
16
  import { ReconnectRefresher } from "./ReconnectRefresher";
@@ -44,7 +44,6 @@ import type {
44
44
  Player,
45
45
  ImageInformation,
46
46
  SceneState,
47
- Rectangle,
48
47
  Size
49
48
  } from "white-web-sdk";
50
49
  import type { AppListeners } from "./AppListener";
@@ -835,52 +834,64 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
835
834
  }
836
835
  }
837
836
 
838
- public moveCameraToContain(rectangle: Rectangle & { animationMode?: AnimationMode }): void {
839
- if (!this.appManager) return;
840
- const camera: Partial<Camera> = {};
841
- if (isNumber(rectangle.originX)) {
842
- camera.centerX = rectangle.originX;
843
- }
844
- if (isNumber(rectangle.originY)) {
845
- camera.centerY = rectangle.originY;
846
- }
847
- if (rectangle.animationMode === AnimationMode.Immediately) {
848
- this.appManager.mainViewProxy.storeSize({
849
- id: this.appManager.uid,
850
- width: rectangle.width,
851
- height: rectangle.height,
852
- });
853
- this.mainView.moveCameraToContain(rectangle);
854
- if (!isEmpty(camera) && this.appManager.mainViewProxy.camera$.value) {
855
- this.appManager.mainViewProxy.storeCamera({
856
- ...this.appManager.mainViewProxy.camera$.value,
857
- id: this.appManager.uid,
858
- centerX: this.mainView.camera.centerX,
859
- centerY: this.mainView.camera.centerY
860
- });
861
- }
862
- } else {
863
- this.appManager.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
864
- this.mainView.moveCameraToContain(rectangle);
865
- setTimeout(() => {
866
- if (!this.appManager) return;
867
- this.appManager.mainViewProxy.storeSize({
868
- id: this.appManager.uid,
869
- width: rectangle.width,
870
- height: rectangle.height,
871
- });
872
-
873
- if (!isEmpty(camera) && this.appManager.mainViewProxy.camera$.value) {
874
- this.appManager.mainViewProxy.storeCamera({
875
- ...this.appManager.mainViewProxy.camera$.value,
876
- id: this.appManager.uid,
877
- centerX: this.mainView.camera.centerX,
878
- centerY: this.mainView.camera.centerY
879
- });
880
- }
881
- }, 200);
882
- }
883
- }
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
+ // }
884
895
 
885
896
  public convertToPointInWorld(point: Point): Point {
886
897
  return this.mainView.convertToPointInWorld(point);