@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.
- package/dist/App/AppContext.d.ts +5 -1
- package/dist/App/AppProxy.d.ts +5 -2
- package/dist/App/index.d.ts +1 -0
- package/dist/App/type.d.ts +21 -0
- package/dist/BoxManager.d.ts +4 -3
- package/dist/Cursor/index.d.ts +0 -1
- package/dist/InternalEmitter.d.ts +1 -2
- package/dist/Utils/Reactive.d.ts +0 -2
- package/dist/View/CameraSynchronizer.d.ts +1 -1
- package/dist/constants.d.ts +0 -1
- package/dist/index.cjs.js +12 -12
- package/dist/index.es.js +164 -205
- package/dist/index.umd.js +12 -12
- package/docs/app-context.md +89 -3
- package/package.json +1 -1
- package/src/App/AppContext.ts +14 -3
- package/src/App/AppProxy.ts +88 -132
- package/src/App/index.ts +1 -0
- package/src/App/type.ts +22 -0
- package/src/AppManager.ts +5 -1
- package/src/BoxManager.ts +8 -7
- package/src/Cursor/index.ts +0 -2
- package/src/InternalEmitter.ts +1 -2
- package/src/ReconnectRefresher.ts +5 -1
- package/src/Utils/Reactive.ts +0 -16
- package/src/View/CameraSynchronizer.ts +17 -26
- package/src/View/ViewSync.ts +6 -12
- package/src/constants.ts +0 -1
@@ -1,5 +1,5 @@
|
|
1
1
|
import { AnimationMode } from "white-web-sdk";
|
2
|
-
import {
|
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 =
|
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
|
-
}
|
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
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
|
package/src/View/ViewSync.ts
CHANGED
@@ -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(
|
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",
|