@netless/window-manager 1.0.0-canary.32 → 1.0.0-canary.35
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/index.cjs.js +12 -39
- package/dist/index.es.js +5141 -8860
- package/dist/index.umd.js +12 -39
- package/dist/src/App/AppContext.d.ts +1 -0
- package/dist/src/View/CameraSynchronizer.d.ts +2 -1
- package/dist/src/index.d.ts +5 -6
- package/dist/style.css +1 -1
- package/docs/mirgrate-to-1.0.md +12 -1
- package/package.json +17 -18
- package/pnpm-lock.yaml +3089 -4905
- package/src/App/AppContext.ts +12 -2
- package/src/BuiltinApps.ts +5 -9
- package/src/View/CameraSynchronizer.ts +10 -7
- package/src/View/ViewSync.ts +7 -10
- package/src/index.ts +9 -8
- package/vite.config.js +3 -1
package/src/App/AppContext.ts
CHANGED
@@ -7,13 +7,14 @@ import {
|
|
7
7
|
reaction,
|
8
8
|
unlistenDisposed,
|
9
9
|
unlistenUpdated,
|
10
|
-
toJS
|
10
|
+
toJS
|
11
11
|
} from "white-web-sdk";
|
12
12
|
import type {
|
13
13
|
Room,
|
14
14
|
SceneDefinition,
|
15
15
|
View,
|
16
|
-
EventListener as WhiteEventListener
|
16
|
+
EventListener as WhiteEventListener,
|
17
|
+
Player
|
17
18
|
} from "white-web-sdk";
|
18
19
|
import type { ReadonlyTeleBox } from "@netless/telebox-insider";
|
19
20
|
import type Emittery from "emittery";
|
@@ -91,6 +92,15 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
|
|
91
92
|
return this.appProxy.view;
|
92
93
|
};
|
93
94
|
|
95
|
+
public get now(): number {
|
96
|
+
if (this.isReplay) {
|
97
|
+
const player = this.displayer as Player;
|
98
|
+
return player.beginTimestamp + player.progressTime;
|
99
|
+
} else {
|
100
|
+
return (this.displayer as Room).calibrationTimestamp;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
94
104
|
public createWhiteBoardView = (params?: CreateWhiteBoardViewParams): WhiteBoardView => {
|
95
105
|
if (this.whiteBoardView) {
|
96
106
|
return this.whiteBoardView;
|
package/src/BuiltinApps.ts
CHANGED
@@ -1,28 +1,24 @@
|
|
1
1
|
import AppDocsViewer from "@netless/app-docs-viewer";
|
2
|
-
import
|
2
|
+
import Plyr from "@netless/app-plyr";
|
3
3
|
import { WindowManager } from "./index";
|
4
4
|
|
5
5
|
export const setupBuiltin = () => {
|
6
|
-
if (WindowManager.debug) {
|
7
|
-
setOptions({ verbose: true });
|
8
|
-
}
|
9
|
-
|
10
6
|
WindowManager.register({
|
11
7
|
kind: AppDocsViewer.kind,
|
12
8
|
src: AppDocsViewer,
|
13
9
|
});
|
14
10
|
WindowManager.register({
|
15
|
-
kind:
|
16
|
-
src:
|
11
|
+
kind: Plyr.kind,
|
12
|
+
src: Plyr,
|
17
13
|
});
|
18
14
|
};
|
19
15
|
|
20
16
|
export const BuiltinApps = {
|
21
17
|
DocsViewer: AppDocsViewer.kind as string,
|
22
|
-
MediaPlayer:
|
18
|
+
MediaPlayer: Plyr.kind as string,
|
23
19
|
};
|
24
20
|
|
25
21
|
export const BuiltinAppsMap = {
|
26
22
|
[BuiltinApps.DocsViewer]: AppDocsViewer,
|
27
|
-
[BuiltinApps.MediaPlayer]:
|
23
|
+
[BuiltinApps.MediaPlayer]: Plyr,
|
28
24
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { AnimationMode } from "white-web-sdk";
|
2
2
|
import { isEqual, pick, throttle } from "lodash";
|
3
3
|
import type { TeleBoxRect } from "@netless/telebox-insider";
|
4
|
-
import type { Camera, View } from "white-web-sdk";
|
4
|
+
import type { Camera, View, Size } from "white-web-sdk";
|
5
5
|
import type { ICamera, ISize } from "../AttributesDelegate";
|
6
6
|
|
7
7
|
export type SaveCamera = (camera: ICamera) => void;
|
@@ -30,12 +30,9 @@ export class CameraSynchronizer {
|
|
30
30
|
this.remoteCamera = camera;
|
31
31
|
this.remoteSize = size;
|
32
32
|
if (this.remoteSize && this.rect) {
|
33
|
-
const
|
34
|
-
const
|
35
|
-
const nextScale = camera.scale * Math.min(wScale, hScale);
|
36
|
-
const config: Partial<Camera> & { animationMode: AnimationMode } = {
|
33
|
+
const nextScale = camera.scale * computedMinScale(size, this.rect);
|
34
|
+
const config: Partial<Camera> = {
|
37
35
|
scale: nextScale,
|
38
|
-
animationMode: AnimationMode.Continuous,
|
39
36
|
}
|
40
37
|
if (camera.centerX !== null) {
|
41
38
|
config.centerX = camera.centerX;
|
@@ -65,6 +62,12 @@ export class CameraSynchronizer {
|
|
65
62
|
}
|
66
63
|
|
67
64
|
private moveCamera(camera: Partial<Camera>) {
|
68
|
-
this.view?.moveCamera({ ...camera, animationMode: AnimationMode.
|
65
|
+
this.view?.moveCamera({ ...camera, animationMode: AnimationMode.Immediately });
|
69
66
|
}
|
70
67
|
}
|
68
|
+
|
69
|
+
export const computedMinScale = (remoteSize: Size, currentSize: Size) => {
|
70
|
+
const wScale = currentSize.width / remoteSize.width;
|
71
|
+
const hScale = currentSize.height / remoteSize.height;
|
72
|
+
return Math.min(wScale, hScale);
|
73
|
+
}
|
package/src/View/ViewSync.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { ViewMode, AnimationMode } from "white-web-sdk";
|
2
|
-
import { CameraSynchronizer } from "./CameraSynchronizer";
|
1
|
+
import { ViewMode, AnimationMode, Size } from "white-web-sdk";
|
2
|
+
import { CameraSynchronizer, computedMinScale } from "./CameraSynchronizer";
|
3
3
|
import { combine } from "value-enhancer";
|
4
|
-
import { isEqual } from "lodash";
|
5
4
|
import { SideEffectManager } from "side-effect-manager";
|
6
5
|
import type { Camera, View } from "white-web-sdk";
|
7
6
|
import type { Val, ReadonlyVal } from "value-enhancer";
|
@@ -94,13 +93,11 @@ export class ViewSync {
|
|
94
93
|
|
95
94
|
private onCameraUpdatedByDevice = (camera: Camera) => {
|
96
95
|
if (!camera) return;
|
97
|
-
this.
|
98
|
-
|
99
|
-
|
100
|
-
const
|
101
|
-
|
102
|
-
this.context.storeSize(size);
|
103
|
-
}
|
96
|
+
if (this.context.size$.value && this.context.stageRect$.value) {
|
97
|
+
// 始终以远端的 size 为标准, 设置到 attributes 时根据尺寸的大小还原回去
|
98
|
+
const diffScale = computedMinScale(this.context.size$.value, this.context.stageRect$.value);
|
99
|
+
const remoteScale = camera.scale / diffScale;
|
100
|
+
this.synchronizer.onLocalCameraUpdate({ ...camera, scale: remoteScale, id: this.context.uid });
|
104
101
|
}
|
105
102
|
};
|
106
103
|
|
package/src/index.ts
CHANGED
@@ -9,14 +9,13 @@ import { DEFAULT_CONTAINER_RATIO, Events, INIT_DIR, ROOT_DIR } from "./constants
|
|
9
9
|
import { emitter } from "./InternalEmitter";
|
10
10
|
import { Fields } from "./AttributesDelegate";
|
11
11
|
import { initDb } from "./Register/storage";
|
12
|
-
import { InvisiblePlugin, isPlayer, isRoom, RoomPhase, ViewMode } from "white-web-sdk";
|
12
|
+
import { InvisiblePlugin, isPlayer, isRoom, RoomPhase, Size, ViewMode } from "white-web-sdk";
|
13
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";
|
17
17
|
import { replaceRoomFunction } from "./Utils/RoomHacker";
|
18
18
|
import { setupBuiltin } from "./BuiltinApps";
|
19
|
-
import "video.js/dist/video-js.css";
|
20
19
|
import "./style.css";
|
21
20
|
import "@netless/telebox-insider/dist/style.css";
|
22
21
|
import {
|
@@ -136,8 +135,6 @@ export type MountParams = {
|
|
136
135
|
containerSizeRatio?: number;
|
137
136
|
/** @deprecated */
|
138
137
|
chessboard?: boolean;
|
139
|
-
/** 是否高亮显示同步区域, 默认为 true */
|
140
|
-
highlightStage?: boolean;
|
141
138
|
collectorContainer?: HTMLElement;
|
142
139
|
collectorStyles?: Partial<CSSStyleDeclaration>;
|
143
140
|
overwriteStyles?: string;
|
@@ -663,17 +660,17 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
663
660
|
}
|
664
661
|
}
|
665
662
|
|
666
|
-
public get baseCamera
|
663
|
+
public get baseCamera() {
|
667
664
|
if (this.appManager) {
|
668
|
-
return this.appManager.mainViewProxy.camera
|
665
|
+
return this.appManager.mainViewProxy.camera$.value;
|
669
666
|
} else {
|
670
667
|
throw new Errors.AppManagerNotInitError();
|
671
668
|
}
|
672
669
|
}
|
673
670
|
|
674
|
-
public get baseSize
|
671
|
+
public get baseSize() {
|
675
672
|
if (this.appManager) {
|
676
|
-
return this.appManager.mainViewProxy.size
|
673
|
+
return this.appManager.mainViewProxy.size$.value;
|
677
674
|
} else {
|
678
675
|
throw new Errors.AppManagerNotInitError();
|
679
676
|
}
|
@@ -969,6 +966,10 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
969
966
|
this.boxManager?.teleBoxManager.setStageStyle(style);
|
970
967
|
}
|
971
968
|
|
969
|
+
public setBaseSize(size: Size) {
|
970
|
+
this.appManager?.mainViewProxy.setMainViewSize(size);
|
971
|
+
}
|
972
|
+
|
972
973
|
public createPPTHandler() {
|
973
974
|
return {
|
974
975
|
onPageJumpTo: (_pptUUID: string, index: number) => {
|
package/vite.config.js
CHANGED