@netless/window-manager 1.0.0-canary.64 → 1.0.0-canary.66
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.js +248 -222
- package/dist/index.mjs +248 -222
- package/dist/index.umd.js +248 -222
- package/dist/src/View/CameraSynchronizer.d.ts +1 -0
- package/dist/src/View/MainView.d.ts +6 -0
- package/dist/src/index.d.ts +2 -6
- package/dist/src/typings.d.ts +4 -1
- package/package.json +2 -2
- package/pnpm-lock.yaml +4 -4
- package/src/View/CameraSynchronizer.ts +1 -0
- package/src/View/MainView.ts +44 -2
- package/src/View/ScrollMode.ts +1 -0
- package/src/index.ts +6 -21
- package/src/typings.ts +3 -0
@@ -9,6 +9,7 @@ export declare class CameraSynchronizer {
|
|
9
9
|
protected rect?: TeleBoxRect;
|
10
10
|
protected view?: View;
|
11
11
|
protected scale: number;
|
12
|
+
protected cameraUpdating: boolean;
|
12
13
|
constructor(saveCamera: SaveCamera);
|
13
14
|
setRect: (rect: TeleBoxRect, updateCamera?: boolean) => void;
|
14
15
|
setView(view: View): void;
|
@@ -3,6 +3,7 @@ import { ViewSync } from "./ViewSync";
|
|
3
3
|
import type { ICamera, ISize } from "../AttributesDelegate";
|
4
4
|
import type { Size, View } from "white-web-sdk";
|
5
5
|
import type { AppManager } from "../AppManager";
|
6
|
+
import type { MoveCameraParams } from "../typings";
|
6
7
|
export declare class MainViewProxy {
|
7
8
|
private manager;
|
8
9
|
private started;
|
@@ -18,11 +19,16 @@ export declare class MainViewProxy {
|
|
18
19
|
} | undefined, any>;
|
19
20
|
size$: Val<ISize | undefined, any>;
|
20
21
|
view$: Val<View | undefined, any>;
|
22
|
+
private cameraUpdatePromise?;
|
21
23
|
viewSync?: ViewSync;
|
22
24
|
constructor(manager: AppManager);
|
23
25
|
createViewSync: () => void;
|
24
26
|
private startListenWritableChange;
|
25
27
|
ensureCameraAndSize(): void;
|
28
|
+
moveCamera: (camera: MoveCameraParams) => void;
|
29
|
+
moveCameraToPromise: (camera: MoveCameraParams) => Promise<boolean>;
|
30
|
+
private debouncedStoreCamera;
|
31
|
+
private storeCurrentCameraSize;
|
26
32
|
private get mainViewCamera();
|
27
33
|
private get mainViewSize();
|
28
34
|
private get didRelease();
|
package/dist/src/index.d.ts
CHANGED
@@ -7,7 +7,7 @@ import type { TELE_BOX_STATE } from "./BoxManager";
|
|
7
7
|
import type { Apps, Position, ICamera, ISize } from "./AttributesDelegate";
|
8
8
|
import type { Displayer, SceneDefinition, View, Room, InvisiblePluginContext, Camera, CameraBound, Point, CameraState, Player, ImageInformation, SceneState, Size, AnimationMode, Rectangle } from "white-web-sdk";
|
9
9
|
import type { AppListeners } from "./AppListener";
|
10
|
-
import type { ApplianceIcons, ManagerViewMode, NetlessApp, RegisterParams } from "./typings";
|
10
|
+
import type { ApplianceIcons, ManagerViewMode, MoveCameraParams, NetlessApp, RegisterParams } from "./typings";
|
11
11
|
import type { TeleBoxColorScheme, TeleBoxFullscreen, TeleBoxManager, TeleBoxManagerThemeConfig, TeleBoxState } from "@netless/telebox-insider";
|
12
12
|
import type { AppProxy } from "./App";
|
13
13
|
import type { PublicEvent } from "./callback";
|
@@ -241,14 +241,10 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
|
|
241
241
|
* 关闭 APP
|
242
242
|
*/
|
243
243
|
closeApp(appId: string): Promise<void>;
|
244
|
-
moveCamera: (camera:
|
245
|
-
animationMode?: AnimationMode;
|
246
|
-
}) => void;
|
244
|
+
moveCamera: (camera: MoveCameraParams) => void;
|
247
245
|
moveCameraToContain(rectangle: Rectangle & Readonly<{
|
248
246
|
animationMode?: AnimationMode;
|
249
247
|
}>): void;
|
250
|
-
private debouncedStoreCamera;
|
251
|
-
private storeCamera;
|
252
248
|
convertToPointInWorld(point: Point): Point;
|
253
249
|
setCameraBound(cameraBound: CameraBound): void;
|
254
250
|
onDestroy(): void;
|
package/dist/src/typings.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type Emittery from "emittery";
|
2
|
-
import type { AnimationMode, ApplianceNames, Displayer, DisplayerState, Player, Room, SceneDefinition, SceneState, View, ViewMode } from "white-web-sdk";
|
2
|
+
import type { AnimationMode, ApplianceNames, Camera, Displayer, DisplayerState, Player, Room, SceneDefinition, SceneState, View, ViewMode } from "white-web-sdk";
|
3
3
|
import type { AppContext } from "./App";
|
4
4
|
import type { ReadonlyTeleBox, TeleBoxRect, TeleBoxFullscreen } from "@netless/telebox-insider";
|
5
5
|
import type { PageState } from "./Page";
|
@@ -81,6 +81,9 @@ export declare type Writeable<T> = {
|
|
81
81
|
-readonly [P in keyof T]: T[P];
|
82
82
|
};
|
83
83
|
export declare type ManagerViewMode = `${ViewMode}` | "scroll";
|
84
|
+
export declare type MoveCameraParams = Partial<Camera> & {
|
85
|
+
animationMode?: AnimationMode;
|
86
|
+
};
|
84
87
|
export type { AppContext } from "./App/AppContext";
|
85
88
|
export type { WhiteBoardView } from "./App";
|
86
89
|
export type { ReadonlyTeleBox, TeleBoxRect, TeleBoxFullscreen };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@netless/window-manager",
|
3
|
-
"version": "1.0.0-canary.
|
3
|
+
"version": "1.0.0-canary.66",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"module": "dist/index.mjs",
|
@@ -36,7 +36,7 @@
|
|
36
36
|
},
|
37
37
|
"devDependencies": {
|
38
38
|
"@netless/app-docs-viewer": "^1.0.0-canary.3",
|
39
|
-
"@netless/app-plyr": "^0.2.
|
39
|
+
"@netless/app-plyr": "^0.2.4",
|
40
40
|
"@playwright/test": "^1.23.2",
|
41
41
|
"@rollup/plugin-commonjs": "^20.0.0",
|
42
42
|
"@rollup/plugin-node-resolve": "^13.0.4",
|
package/pnpm-lock.yaml
CHANGED
@@ -3,7 +3,7 @@ lockfileVersion: 5.4
|
|
3
3
|
specifiers:
|
4
4
|
'@juggle/resize-observer': ^3.3.1
|
5
5
|
'@netless/app-docs-viewer': ^1.0.0-canary.3
|
6
|
-
'@netless/app-plyr': ^0.2.
|
6
|
+
'@netless/app-plyr': ^0.2.4
|
7
7
|
'@netless/synced-store': ^2.0.7
|
8
8
|
'@netless/telebox-insider': 1.0.0-alpha.37
|
9
9
|
'@playwright/test': ^1.23.2
|
@@ -57,7 +57,7 @@ dependencies:
|
|
57
57
|
|
58
58
|
devDependencies:
|
59
59
|
'@netless/app-docs-viewer': 1.0.0-canary.3
|
60
|
-
'@netless/app-plyr': 0.2.
|
60
|
+
'@netless/app-plyr': 0.2.4
|
61
61
|
'@playwright/test': 1.23.2
|
62
62
|
'@rollup/plugin-commonjs': 20.0.0
|
63
63
|
'@rollup/plugin-node-resolve': 13.1.3
|
@@ -259,8 +259,8 @@ packages:
|
|
259
259
|
vanilla-lazyload: 17.8.3
|
260
260
|
dev: true
|
261
261
|
|
262
|
-
/@netless/app-plyr/0.2.
|
263
|
-
resolution: {integrity: sha512-
|
262
|
+
/@netless/app-plyr/0.2.4:
|
263
|
+
resolution: {integrity: sha512-PR2Os9ZoD2Q3K8aQYEsp8oupaYCNfEe6qQCIj2Fi80Mb8RINI1rxtkgZ1cToI9puePs00n7unu1leLO2c4M+HA==}
|
264
264
|
dev: true
|
265
265
|
|
266
266
|
/@netless/canvas-polyfill/0.0.4:
|
package/src/View/MainView.ts
CHANGED
@@ -12,6 +12,7 @@ import { ViewSync } from "./ViewSync";
|
|
12
12
|
import type { ICamera, ISize } from "../AttributesDelegate";
|
13
13
|
import type { Size, View } from "white-web-sdk";
|
14
14
|
import type { AppManager } from "../AppManager";
|
15
|
+
import type { MoveCameraParams } from "../typings";
|
15
16
|
|
16
17
|
export class MainViewProxy {
|
17
18
|
private started = false;
|
@@ -24,6 +25,7 @@ export class MainViewProxy {
|
|
24
25
|
public camera$ = new Val<ICamera | undefined>(undefined);
|
25
26
|
public size$ = new Val<ISize | undefined>(undefined);
|
26
27
|
public view$ = new Val<View | undefined>(undefined);
|
28
|
+
private cameraUpdatePromise?: Promise<boolean>;
|
27
29
|
|
28
30
|
public viewSync?: ViewSync;
|
29
31
|
|
@@ -100,6 +102,43 @@ export class MainViewProxy {
|
|
100
102
|
}
|
101
103
|
}
|
102
104
|
|
105
|
+
public moveCamera = (camera: MoveCameraParams) => {
|
106
|
+
this.debouncedStoreCamera();
|
107
|
+
this.moveCameraToPromise(camera);
|
108
|
+
};
|
109
|
+
|
110
|
+
public moveCameraToPromise = (camera: MoveCameraParams) => {
|
111
|
+
const promise = new Promise<boolean>((resolve) => {
|
112
|
+
const cameraListener = debounce(() => {
|
113
|
+
this.mainView.callbacks.off("onCameraUpdated", cameraListener);
|
114
|
+
this.cameraUpdatePromise = undefined;
|
115
|
+
resolve(true);
|
116
|
+
}, 50);
|
117
|
+
this.mainView.callbacks.on("onCameraUpdated", cameraListener);
|
118
|
+
this.mainView.moveCamera(camera);
|
119
|
+
});
|
120
|
+
this.cameraUpdatePromise = promise;
|
121
|
+
return promise;
|
122
|
+
}
|
123
|
+
|
124
|
+
private debouncedStoreCamera = () => {
|
125
|
+
this.storeCurrentSize();
|
126
|
+
const cameraListener = debounce(() => {
|
127
|
+
this.saveToCamera$();
|
128
|
+
this.storeCurrentCameraSize();
|
129
|
+
this.mainView.callbacks.off("onCameraUpdated", cameraListener);
|
130
|
+
}, 50);
|
131
|
+
this.mainView.callbacks.on("onCameraUpdated", cameraListener);
|
132
|
+
}
|
133
|
+
|
134
|
+
private storeCurrentCameraSize = debounce(async () => {
|
135
|
+
if (this.cameraUpdatePromise) {
|
136
|
+
await this.cameraUpdatePromise;
|
137
|
+
}
|
138
|
+
this.storeCurrentCamera();
|
139
|
+
this.storeCurrentSize();
|
140
|
+
}, 500);
|
141
|
+
|
103
142
|
private get mainViewCamera() {
|
104
143
|
return this.store.getMainViewCamera();
|
105
144
|
}
|
@@ -141,11 +180,14 @@ export class MainViewProxy {
|
|
141
180
|
public storeCurrentSize = () => {
|
142
181
|
const rect = this.manager.boxManager?.stageRect;
|
143
182
|
if (rect) {
|
144
|
-
|
183
|
+
const size = {
|
145
184
|
id: this.manager.uid,
|
146
185
|
width: rect.width,
|
147
186
|
height: rect.height
|
148
|
-
}
|
187
|
+
}
|
188
|
+
if (!isEqual(size, this.mainViewSize)) {
|
189
|
+
this.storeSize(size);
|
190
|
+
}
|
149
191
|
}
|
150
192
|
}
|
151
193
|
|
package/src/View/ScrollMode.ts
CHANGED
@@ -76,6 +76,7 @@ export class ScrollMode {
|
|
76
76
|
|
77
77
|
this.sideEffect.add(() => {
|
78
78
|
const onCameraUpdated = (camera: Camera): void => {
|
79
|
+
if (!this.manager.canOperate) return;
|
79
80
|
const halfWbHeight = size$.value.height / 2 / scale$.value;
|
80
81
|
const scrollTop = camera.centerY;
|
81
82
|
this.scrollStorage.setState({
|
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 { InvisiblePlugin, isPlayer, isRoom, RoomPhase, ViewMode } from "white-web-sdk";
|
13
|
-
import { isEqual, isNull, isObject, isNumber, omit
|
13
|
+
import { isEqual, isNull, isObject, isNumber, omit } from "lodash";
|
14
14
|
import { log } from "./Utils/log";
|
15
15
|
import { PageStateImpl } from "./PageState";
|
16
16
|
import { ReconnectRefresher } from "./ReconnectRefresher";
|
@@ -49,7 +49,7 @@ import type {
|
|
49
49
|
Rectangle,
|
50
50
|
} from "white-web-sdk";
|
51
51
|
import type { AppListeners } from "./AppListener";
|
52
|
-
import type { ApplianceIcons, ManagerViewMode, NetlessApp, RegisterParams } from "./typings";
|
52
|
+
import type { ApplianceIcons, ManagerViewMode, MoveCameraParams, NetlessApp, RegisterParams } from "./typings";
|
53
53
|
import type { TeleBoxColorScheme, TeleBoxFullscreen, TeleBoxManager, TeleBoxManagerThemeConfig, TeleBoxState } from "@netless/telebox-insider";
|
54
54
|
import type { AppProxy } from "./App";
|
55
55
|
import type { PublicEvent } from "./callback";
|
@@ -830,14 +830,13 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
830
830
|
return this.appManager?.closeApp(appId);
|
831
831
|
}
|
832
832
|
|
833
|
-
public moveCamera = (camera:
|
833
|
+
public moveCamera = (camera: MoveCameraParams): void => {
|
834
834
|
const pureCamera = omit(camera, ["animationMode"]);
|
835
835
|
const mainViewCamera = { ...this.mainView.camera };
|
836
836
|
if (isEqual({ ...mainViewCamera, ...pureCamera }, mainViewCamera)) return;
|
837
|
-
this.
|
838
|
-
this.mainView.moveCamera(camera);
|
837
|
+
this.appManager?.mainViewProxy.moveCamera(camera);
|
839
838
|
this.appManager?.dispatchInternalEvent(Events.MoveCamera, camera);
|
840
|
-
}
|
839
|
+
}
|
841
840
|
|
842
841
|
public moveCameraToContain(
|
843
842
|
rectangle: Rectangle &
|
@@ -845,25 +844,11 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
845
844
|
animationMode?: AnimationMode;
|
846
845
|
}>
|
847
846
|
): void {
|
848
|
-
this.debouncedStoreCamera();
|
847
|
+
// this.debouncedStoreCamera();
|
849
848
|
this.mainView.moveCameraToContain(rectangle);
|
850
849
|
this.appManager?.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
|
851
850
|
}
|
852
851
|
|
853
|
-
private debouncedStoreCamera = () => {
|
854
|
-
const cameraListener = debounce(() => {
|
855
|
-
this.appManager?.mainViewProxy.saveToCamera$();
|
856
|
-
this.storeCamera();
|
857
|
-
this.mainView.callbacks.off("onCameraUpdated", cameraListener);
|
858
|
-
}, 50);
|
859
|
-
this.mainView.callbacks.on("onCameraUpdated", cameraListener);
|
860
|
-
}
|
861
|
-
|
862
|
-
private storeCamera = debounce(() => {
|
863
|
-
this.appManager?.mainViewProxy.storeCurrentCamera();
|
864
|
-
this.appManager?.mainViewProxy.storeCurrentSize();
|
865
|
-
}, 300);
|
866
|
-
|
867
852
|
public convertToPointInWorld(point: Point): Point {
|
868
853
|
return this.mainView.convertToPointInWorld(point);
|
869
854
|
}
|
package/src/typings.ts
CHANGED
@@ -2,6 +2,7 @@ import type Emittery from "emittery";
|
|
2
2
|
import type {
|
3
3
|
AnimationMode,
|
4
4
|
ApplianceNames,
|
5
|
+
Camera,
|
5
6
|
Displayer,
|
6
7
|
DisplayerState,
|
7
8
|
Player,
|
@@ -93,6 +94,8 @@ export type Writeable<T> = { -readonly [P in keyof T]: T[P] };
|
|
93
94
|
|
94
95
|
export type ManagerViewMode = `${ViewMode}` | "scroll";
|
95
96
|
|
97
|
+
export type MoveCameraParams = Partial<Camera> & { animationMode?: AnimationMode };
|
98
|
+
|
96
99
|
export type { AppContext } from "./App/AppContext";
|
97
100
|
export type { WhiteBoardView } from "./App";
|
98
101
|
export type { ReadonlyTeleBox, TeleBoxRect, TeleBoxFullscreen };
|