@netless/window-manager 1.0.0-canary.18 → 1.0.0-canary.19
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/AppProxy.d.ts +8 -3
- package/dist/App/WhiteboardView.d.ts +3 -2
- package/dist/AttributesDelegate.d.ts +5 -2
- package/dist/View/CameraSynchronizer.d.ts +6 -6
- package/dist/View/MainView.d.ts +6 -1
- package/dist/index.cjs.js +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +16 -14
- package/dist/index.umd.js +2 -2
- package/docs/mirgrate-to-1.0.md +28 -0
- package/package.json +1 -1
- package/src/App/AppContext.ts +1 -1
- package/src/App/AppProxy.ts +4 -4
- package/src/App/WhiteboardView.ts +3 -2
- package/src/AttributesDelegate.ts +5 -2
- package/src/View/CameraSynchronizer.ts +14 -9
- package/src/View/ViewSync.ts +4 -8
- package/src/index.ts +2 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
## 迁移至 `@netless/window-manager@1.0`
|
2
|
+
|
3
|
+
### 样式
|
4
|
+
|
5
|
+
1.0 之前
|
6
|
+
|
7
|
+
```html
|
8
|
+
<div class="netless-window-manager-playground">
|
9
|
+
<div class="netless-window-manager-sizer">
|
10
|
+
<div class="netless-window-manager-wrapper">
|
11
|
+
<div class="netless-window-manager-main-view"></div>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
```
|
16
|
+
|
17
|
+
1.0 之后
|
18
|
+
|
19
|
+
```html
|
20
|
+
<div class="netless-window-manager-playground">
|
21
|
+
<div class="netless-window-manager-main-view"></div>
|
22
|
+
</div>
|
23
|
+
```
|
24
|
+
|
25
|
+
|
26
|
+
### `APP` 迁移
|
27
|
+
|
28
|
+
|
package/package.json
CHANGED
package/src/App/AppContext.ts
CHANGED
@@ -125,7 +125,7 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
|
|
125
125
|
}
|
126
126
|
|
127
127
|
public getInitScenePath = () => {
|
128
|
-
return this.
|
128
|
+
return this.appProxy.scenePath;
|
129
129
|
};
|
130
130
|
|
131
131
|
/** Get App writable status. */
|
package/src/App/AppProxy.ts
CHANGED
@@ -30,7 +30,7 @@ import type {
|
|
30
30
|
setAppOptions,
|
31
31
|
AppListenerKeys,
|
32
32
|
} from "../index";
|
33
|
-
import type { SceneState, View, SceneDefinition,
|
33
|
+
import type { SceneState, View, SceneDefinition, MemberState} from "white-web-sdk";
|
34
34
|
import type { AppManager } from "../AppManager";
|
35
35
|
import type { NetlessApp } from "../typings";
|
36
36
|
import type { ReadonlyTeleBox, TeleBoxRect } from "@netless/telebox-insider";
|
@@ -117,8 +117,8 @@ export class AppProxy implements PageRemoveService {
|
|
117
117
|
if (box && view) {
|
118
118
|
if (!this.camera$.value) {
|
119
119
|
this.storeCamera({
|
120
|
-
centerX:
|
121
|
-
centerY:
|
120
|
+
centerX: null,
|
121
|
+
centerY: null,
|
122
122
|
scale: 1,
|
123
123
|
id: this.uid,
|
124
124
|
});
|
@@ -595,7 +595,7 @@ export class AppProxy implements PageRemoveService {
|
|
595
595
|
this.size$.setValue(iSize);
|
596
596
|
}
|
597
597
|
|
598
|
-
public moveCamera = (camera: Partial<
|
598
|
+
public moveCamera = (camera: Partial<ICamera>) => {
|
599
599
|
if (!this.camera$.value) {
|
600
600
|
return;
|
601
601
|
}
|
@@ -6,10 +6,11 @@ import type { ReadonlyVal } from "value-enhancer";
|
|
6
6
|
import type { AddPageParams, PageController, PageState } from "../Page";
|
7
7
|
import type { AppProxy } from "./AppProxy";
|
8
8
|
import type { AppContext } from "./AppContext";
|
9
|
-
import type {
|
9
|
+
import type { View } from "white-web-sdk";
|
10
10
|
import type { TeleBoxRect } from "@netless/telebox-insider";
|
11
|
+
import type { ICamera } from "../AttributesDelegate";
|
11
12
|
|
12
|
-
export type WhiteBoardViewCamera = Omit<
|
13
|
+
export type WhiteBoardViewCamera = Omit<ICamera, "scale" | "id">;
|
13
14
|
|
14
15
|
export class WhiteBoardView implements PageController {
|
15
16
|
public readonly pageState$: ReadonlyVal<PageState>;
|
@@ -2,7 +2,7 @@ import { AppAttributes } from "./constants";
|
|
2
2
|
import { get, pick } from "lodash";
|
3
3
|
import { setViewFocusScenePath } from "./Utils/Common";
|
4
4
|
import type { AddAppParams, AppSyncAttributes } from "./index";
|
5
|
-
import type {
|
5
|
+
import type { Size, View } from "white-web-sdk";
|
6
6
|
import type { Cursor } from "./Cursor/Cursor";
|
7
7
|
|
8
8
|
export enum Fields {
|
@@ -41,8 +41,11 @@ export type StoreContext = {
|
|
41
41
|
safeSetAttributes: (attributes: any) => void;
|
42
42
|
}
|
43
43
|
|
44
|
-
export type ICamera =
|
44
|
+
export type ICamera = & {
|
45
45
|
id: string; // room uid
|
46
|
+
centerX: number | null,
|
47
|
+
centerY: number | null,
|
48
|
+
scale: number
|
46
49
|
};
|
47
50
|
|
48
51
|
export type ISize = Size & {
|
@@ -2,12 +2,12 @@ import { AnimationMode } from "white-web-sdk";
|
|
2
2
|
import { debounce, delay, 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
|
-
import type { ISize } from "../AttributesDelegate";
|
5
|
+
import type { ICamera, ISize } from "../AttributesDelegate";
|
6
6
|
|
7
|
-
export type SaveCamera = (camera:
|
7
|
+
export type SaveCamera = (camera: ICamera) => void;
|
8
8
|
|
9
9
|
export class CameraSynchronizer {
|
10
|
-
public remoteCamera?:
|
10
|
+
public remoteCamera?: ICamera;
|
11
11
|
public remoteSize?: ISize;
|
12
12
|
protected rect?: TeleBoxRect;
|
13
13
|
protected view?: View;
|
@@ -26,7 +26,7 @@ export class CameraSynchronizer {
|
|
26
26
|
}
|
27
27
|
|
28
28
|
// 远端 Camera 或者 size 更新
|
29
|
-
public onRemoteUpdate = throttle((camera:
|
29
|
+
public onRemoteUpdate = throttle((camera: ICamera, size: ISize) => {
|
30
30
|
this.remoteCamera = camera;
|
31
31
|
this.remoteSize = size;
|
32
32
|
if (this.remoteSize && this.rect) {
|
@@ -38,12 +38,17 @@ export class CameraSynchronizer {
|
|
38
38
|
}
|
39
39
|
const nextScale = camera.scale * scale;
|
40
40
|
const moveCamera = () => {
|
41
|
-
|
42
|
-
centerX: camera.centerX,
|
43
|
-
centerY: camera.centerY,
|
41
|
+
const config: Partial<Camera> & { animationMode: AnimationMode } = {
|
44
42
|
scale: nextScale,
|
45
43
|
animationMode: AnimationMode.Immediately,
|
46
|
-
}
|
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);
|
47
52
|
}
|
48
53
|
moveCamera();
|
49
54
|
// TODO 直接调用 moveCamera 依然会出现 camera 错误的情况,这里暂时加一个 delay 保证 camera 是对的, 后续需要 SDK 进行修改
|
@@ -68,7 +73,7 @@ export class CameraSynchronizer {
|
|
68
73
|
}
|
69
74
|
}
|
70
75
|
|
71
|
-
public onLocalCameraUpdate(camera:
|
76
|
+
public onLocalCameraUpdate(camera: ICamera) {
|
72
77
|
this.saveCamera(camera);
|
73
78
|
this.remoteCamera = camera;
|
74
79
|
}
|
package/src/View/ViewSync.ts
CHANGED
@@ -31,18 +31,14 @@ export class ViewSync {
|
|
31
31
|
private synchronizer: CameraSynchronizer;
|
32
32
|
|
33
33
|
constructor(private context: ViewSyncContext) {
|
34
|
-
this.synchronizer = new CameraSynchronizer((camera:
|
35
|
-
|
36
|
-
id: this.context.uid,
|
37
|
-
...camera,
|
38
|
-
};
|
39
|
-
this.context.camera$.setValue(iCamera, true);
|
34
|
+
this.synchronizer = new CameraSynchronizer((camera: ICamera) => {
|
35
|
+
this.context.camera$.setValue(camera, true);
|
40
36
|
const notStoreCamera =
|
41
37
|
this.context.viewMode$ && this.context.viewMode$.value === ViewMode.Freedom;
|
42
38
|
if (notStoreCamera) {
|
43
39
|
return;
|
44
40
|
} else {
|
45
|
-
this.context.storeCamera(
|
41
|
+
this.context.storeCamera(camera);
|
46
42
|
}
|
47
43
|
});
|
48
44
|
this.bindView(this.context.view$.value);
|
@@ -103,7 +99,7 @@ export class ViewSync {
|
|
103
99
|
};
|
104
100
|
|
105
101
|
private onCameraUpdatedByDevice = (camera: Camera) => {
|
106
|
-
this.synchronizer.onLocalCameraUpdate(camera);
|
102
|
+
this.synchronizer.onLocalCameraUpdate(Object.assign(camera, { id: this.context.uid }));
|
107
103
|
const stage = this.context.stageRect$.value;
|
108
104
|
if (stage) {
|
109
105
|
const size = { width: stage.width, height: stage.height, id: this.context.uid };
|
package/src/index.ts
CHANGED
@@ -130,6 +130,8 @@ export type MountParams = {
|
|
130
130
|
container?: HTMLElement;
|
131
131
|
/** 白板高宽比例, 默认为 9 / 16 */
|
132
132
|
containerSizeRatio?: number;
|
133
|
+
/** @deprecated */
|
134
|
+
chessboard?: boolean;
|
133
135
|
/** 是否高亮显示同步区域, 默认为 true */
|
134
136
|
highlightStage?: boolean;
|
135
137
|
collectorContainer?: HTMLElement;
|