@netless/window-manager 1.0.0-canary.20 → 1.0.0-canary.23

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.
@@ -1,5 +1,5 @@
1
1
  import { AnimationMode } from "white-web-sdk";
2
- import { debounce, delay, isEqual, pick, throttle } from "lodash";
2
+ import { isEqual, pick, throttle } from "lodash";
3
3
  import type { TeleBoxRect } from "@netless/telebox-insider";
4
4
  import type { Camera, View } from "white-web-sdk";
5
5
  import type { ICamera, ISize } from "../AttributesDelegate";
@@ -14,12 +14,12 @@ export class CameraSynchronizer {
14
14
 
15
15
  constructor(protected saveCamera: SaveCamera) {}
16
16
 
17
- public setRect = debounce((rect: TeleBoxRect) => {
17
+ public setRect = (rect: TeleBoxRect) => {
18
18
  this.rect = rect;
19
19
  if (this.remoteCamera && this.remoteSize) {
20
20
  this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
21
21
  }
22
- }, 10);
22
+ }
23
23
 
24
24
  public setView(view: View) {
25
25
  this.view = view;
@@ -37,22 +37,17 @@ export class CameraSynchronizer {
37
37
  scale = this.rect.height / size.height;
38
38
  }
39
39
  const nextScale = camera.scale * scale;
40
- const moveCamera = () => {
41
- const config: Partial<Camera> & { animationMode: AnimationMode } = {
42
- scale: nextScale,
43
- animationMode: AnimationMode.Immediately,
44
- }
45
- if (camera.centerX !== null) {
46
- config.centerX = camera.centerX;
47
- }
48
- if (camera.centerY !== null) {
49
- config.centerY = camera.centerY;
50
- }
51
- this.view?.moveCamera(config);
40
+ const config: Partial<Camera> & { animationMode: AnimationMode } = {
41
+ scale: nextScale,
42
+ animationMode: AnimationMode.Immediately,
43
+ }
44
+ if (camera.centerX !== null) {
45
+ config.centerX = camera.centerX;
46
+ }
47
+ if (camera.centerY !== null) {
48
+ config.centerY = camera.centerY;
52
49
  }
53
- moveCamera();
54
- // TODO 直接调用 moveCamera 依然会出现 camera 错误的情况,这里暂时加一个 delay 保证 camera 是对的, 后续需要 SDK 进行修改
55
- delay(moveCamera, 50);
50
+ this.view?.moveCamera(config);
56
51
  }
57
52
  }, 10);
58
53
 
@@ -62,14 +57,10 @@ export class CameraSynchronizer {
62
57
  if (this.rect && this.remoteCamera && needMoveCamera) {
63
58
  const scale = this.rect.width / size.width;
64
59
  const nextScale = this.remoteCamera.scale * scale;
65
- const moveCamera = () => {
66
- this.view?.moveCamera({
67
- scale: nextScale,
68
- animationMode: AnimationMode.Immediately,
69
- })
70
- };
71
- moveCamera();
72
- delay(moveCamera, 50);
60
+ this.view?.moveCamera({
61
+ scale: nextScale,
62
+ animationMode: AnimationMode.Immediately,
63
+ })
73
64
  }
74
65
  }
75
66
 
@@ -42,7 +42,7 @@ export class ViewSync {
42
42
  }
43
43
  });
44
44
  this.bindView(this.context.view$.value);
45
- this.sem.add(() =>
45
+ this.sem.add(() => [
46
46
  this.context.view$.subscribe(view => {
47
47
  const currentCamera = this.context.camera$.value;
48
48
  if (currentCamera && this.context.size$.value) {
@@ -54,30 +54,24 @@ export class ViewSync {
54
54
  }
55
55
 
56
56
  this.bindView(view);
57
- })
58
- );
59
- this.sem.add(() =>
57
+ }),
60
58
  this.context.camera$.subscribe((camera, skipUpdate) => {
61
59
  const size = this.context.size$.value;
62
60
  if (camera && size && !skipUpdate) {
63
61
  this.synchronizer.onRemoteUpdate(camera, size);
64
62
  }
65
- })
66
- );
67
- this.sem.add(() =>
63
+ }),
68
64
  this.context.size$.subscribe(size => {
69
65
  if (size) {
70
66
  this.synchronizer.onRemoteSizeUpdate(size);
71
67
  }
72
- })
73
- );
74
- this.sem.add(() =>
68
+ }),
75
69
  this.context.stageRect$.reaction(rect => {
76
70
  if (rect) {
77
71
  this.synchronizer.setRect(rect);
78
72
  }
79
73
  })
80
- );
74
+ ]);
81
75
  const camera$size$ = combine([this.context.camera$, this.context.size$]);
82
76
  camera$size$.reaction(([camera, size]) => {
83
77
  if (camera && size) {
@@ -100,7 +94,7 @@ export class ViewSync {
100
94
 
101
95
  private onCameraUpdatedByDevice = (camera: Camera) => {
102
96
  if (!camera) return;
103
- this.synchronizer.onLocalCameraUpdate(Object.assign(camera, { id: this.context.uid }));
97
+ this.synchronizer.onLocalCameraUpdate({ ...camera, id: this.context.uid });
104
98
  const stage = this.context.stageRect$.value;
105
99
  if (stage) {
106
100
  const size = { width: stage.width, height: stage.height, id: this.context.uid };
package/src/constants.ts CHANGED
@@ -5,7 +5,6 @@ export enum Events {
5
5
  AppBoxStateChange = "AppBoxStateChange",
6
6
  GetAttributes = "GetAttributes",
7
7
  UpdateWindowManagerWrapper = "UpdateWindowManagerWrapper",
8
- InitReplay = "InitReplay",
9
8
  WindowCreated = "WindowCreated",
10
9
  SetMainViewScenePath = "SetMainViewScenePath",
11
10
  SetMainViewSceneIndex = "SetMainViewSceneIndex",