@netless/window-manager 1.0.0-canary.29 → 1.0.0-canary.31
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 +26 -26
- package/dist/index.es.js +107 -67
- package/dist/index.umd.js +26 -26
- package/dist/src/App/AppProxy.d.ts +1 -0
- package/dist/src/AppManager.d.ts +2 -1
- package/dist/src/BoxManager.d.ts +2 -1
- package/dist/src/Helper.d.ts +1 -7
- package/dist/src/InternalEmitter.d.ts +0 -2
- package/dist/src/View/CameraSynchronizer.d.ts +1 -0
- package/dist/src/constants.d.ts +2 -1
- package/dist/src/index.d.ts +4 -1
- package/dist/src/typings.d.ts +2 -2
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/playwright.config.ts +1 -0
- package/pnpm-lock.yaml +4 -4
- package/src/App/AppContext.ts +2 -2
- package/src/App/AppProxy.ts +13 -6
- package/src/AppListener.ts +4 -0
- package/src/AppManager.ts +16 -11
- package/src/AttributesDelegate.ts +1 -1
- package/src/BoxManager.ts +6 -0
- package/src/Cursor/Cursor.ts +1 -1
- package/src/Cursor/index.ts +3 -2
- package/src/Helper.ts +2 -2
- package/src/InternalEmitter.ts +0 -2
- package/src/View/CameraSynchronizer.ts +6 -3
- package/src/View/ViewSync.ts +1 -1
- package/src/constants.ts +1 -0
- package/src/index.ts +5 -1
- package/src/style.css +1 -1
- package/src/typings.ts +2 -2
package/src/AppManager.ts
CHANGED
@@ -69,6 +69,7 @@ export class AppManager {
|
|
69
69
|
private appCreateQueue = new AppCreateQueue();
|
70
70
|
private sceneIndex$ = new Val<number | undefined>(undefined);
|
71
71
|
private focused$ = new Val<string | undefined>(undefined);
|
72
|
+
public members$ = new Val<Member[]>([]);
|
72
73
|
|
73
74
|
private sideEffectManager = new SideEffectManager();
|
74
75
|
|
@@ -121,6 +122,7 @@ export class AppManager {
|
|
121
122
|
appRegister.setSyncRegisterApp(payload => {
|
122
123
|
this.safeUpdateAttributes([Fields.Registered, payload.kind], payload);
|
123
124
|
});
|
125
|
+
this.members$.setValue(serializeRoomMembers(this.displayer.state.roomMembers));
|
124
126
|
}
|
125
127
|
|
126
128
|
private onRemoveScenes = async (params: RemoveSceneParams) => {
|
@@ -302,10 +304,6 @@ export class AppManager {
|
|
302
304
|
return this.room?.uid || "";
|
303
305
|
}
|
304
306
|
|
305
|
-
public get members(): Member[] {
|
306
|
-
return serializeRoomMembers(this.displayer.state.roomMembers);
|
307
|
-
}
|
308
|
-
|
309
307
|
public getMainViewSceneDir() {
|
310
308
|
const scenePath = this.store.getMainViewScenePath();
|
311
309
|
if (scenePath) {
|
@@ -475,13 +473,17 @@ export class AppManager {
|
|
475
473
|
this.appCreateQueue.emitReady();
|
476
474
|
}
|
477
475
|
const appsWithCreatedAt = appIds.map(appId => {
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
476
|
+
if (apps[appId].setup) {
|
477
|
+
return {
|
478
|
+
id: appId,
|
479
|
+
createdAt: apps[appId].createdAt,
|
480
|
+
};
|
481
|
+
} else {
|
482
|
+
return {}
|
483
|
+
}
|
482
484
|
});
|
483
485
|
for (const { id } of orderBy(appsWithCreatedAt, "createdAt", "asc")) {
|
484
|
-
if (!this.appProxies.has(id) && !this.appStatus.has(id)) {
|
486
|
+
if (id && !this.appProxies.has(id) && !this.appStatus.has(id)) {
|
485
487
|
const app = apps[id];
|
486
488
|
try {
|
487
489
|
const appAttributes = this.attributes[id];
|
@@ -572,11 +574,11 @@ export class AppManager {
|
|
572
574
|
// 延迟挂载 mainView 的 dom, 避免因为同步 camera 的闪动
|
573
575
|
wait(30).then(() => {
|
574
576
|
mainView.divElement = divElement;
|
577
|
+
emitter.emit("mainViewMounted");
|
575
578
|
});
|
576
579
|
if (!mainView.focusScenePath) {
|
577
580
|
this.setMainViewFocusPath();
|
578
581
|
}
|
579
|
-
emitter.emit("mainViewMounted");
|
580
582
|
}
|
581
583
|
|
582
584
|
public setMainViewFocusPath(scenePath?: string) {
|
@@ -596,6 +598,7 @@ export class AppManager {
|
|
596
598
|
|
597
599
|
public async addApp(params: AddAppParams, isDynamicPPT: boolean): Promise<string | undefined> {
|
598
600
|
log("addApp", params);
|
601
|
+
// 初始化 app 的属性创建
|
599
602
|
const { appId, needFocus } = await this.beforeAddApp(params, isDynamicPPT);
|
600
603
|
const appProxy = await this.baseInsertApp(params, appId, true, needFocus);
|
601
604
|
this.afterAddApp(appProxy);
|
@@ -607,6 +610,7 @@ export class AppManager {
|
|
607
610
|
this.appStatus.set(appId, AppStatus.StartCreate);
|
608
611
|
const attrs = params.attributes ?? {};
|
609
612
|
this.safeUpdateAttributes([appId], attrs);
|
613
|
+
// 初始化的时候时需要一些异步的工作, 完成后其他端才可以创建
|
610
614
|
this.store.setupAppAttributes(params, appId, isDynamicPPT);
|
611
615
|
const needFocus = !this.boxManager?.minimized;
|
612
616
|
if (needFocus) {
|
@@ -673,7 +677,7 @@ export class AppManager {
|
|
673
677
|
appProxy.appEmitter.emit("roomStateChange", state);
|
674
678
|
});
|
675
679
|
if (state.roomMembers) {
|
676
|
-
|
680
|
+
this.members$.setValue(serializeRoomMembers(state.roomMembers));
|
677
681
|
}
|
678
682
|
emitter.emit("observerIdChange", this.displayer.observerId);
|
679
683
|
if (state.memberState) {
|
@@ -841,5 +845,6 @@ export class AppManager {
|
|
841
845
|
this.sideEffectManager.flushAll();
|
842
846
|
this.sceneIndex$.destroy();
|
843
847
|
this.focused$.destroy();
|
848
|
+
this.members$.destroy();
|
844
849
|
}
|
845
850
|
}
|
@@ -98,7 +98,7 @@ export class AttributesDelegate {
|
|
98
98
|
attrNames.push("scenes");
|
99
99
|
}
|
100
100
|
const options = pick(params.options, attrNames);
|
101
|
-
const attrs: AppSyncAttributes = { kind: params.kind, options, isDynamicPPT };
|
101
|
+
const attrs: AppSyncAttributes = { kind: params.kind, options, isDynamicPPT, setup: false };
|
102
102
|
if (typeof params.src === "string") {
|
103
103
|
attrs.src = params.src;
|
104
104
|
}
|
package/src/BoxManager.ts
CHANGED
@@ -14,6 +14,7 @@ import type {
|
|
14
14
|
TeleBoxColorScheme,
|
15
15
|
TeleBoxRect,
|
16
16
|
TeleBoxConfig,
|
17
|
+
TeleBoxFullscreen
|
17
18
|
} from "@netless/telebox-insider";
|
18
19
|
import type Emittery from "emittery";
|
19
20
|
import type { NetlessApp } from "./typings";
|
@@ -51,6 +52,7 @@ export type CreateTeleBoxManagerConfig = {
|
|
51
52
|
stageRatio?: number;
|
52
53
|
containerStyle?: string;
|
53
54
|
stageStyle?: string;
|
55
|
+
fullscreen?: TeleBoxFullscreen;
|
54
56
|
};
|
55
57
|
|
56
58
|
export type BoxManagerContext = {
|
@@ -262,6 +264,10 @@ export class BoxManager {
|
|
262
264
|
initManagerState.stageStyle = createTeleBoxManagerConfig.stageStyle;
|
263
265
|
}
|
264
266
|
|
267
|
+
if (createTeleBoxManagerConfig?.fullscreen) {
|
268
|
+
initManagerState.fullscreen = createTeleBoxManagerConfig.fullscreen;
|
269
|
+
}
|
270
|
+
|
265
271
|
const manager = new TeleBoxManager(initManagerState);
|
266
272
|
if (this.teleBoxManager) {
|
267
273
|
this.teleBoxManager.destroy();
|
package/src/Cursor/Cursor.ts
CHANGED
@@ -31,7 +31,7 @@ export class Cursor {
|
|
31
31
|
|
32
32
|
public move = (position: Position) => {
|
33
33
|
if (position.type === "main") {
|
34
|
-
const rect = this.
|
34
|
+
const rect = this.manager.boxManager?.stageRect;
|
35
35
|
if (this.component && rect) {
|
36
36
|
this.autoHidden();
|
37
37
|
this.moveCursor(position, rect, this.manager.mainView);
|
package/src/Cursor/index.ts
CHANGED
@@ -89,6 +89,7 @@ export class CursorManager {
|
|
89
89
|
wrapper.removeEventListener("pointerleave", this.mouseLeaveListener);
|
90
90
|
};
|
91
91
|
});
|
92
|
+
this.updateContainerRect();
|
92
93
|
}
|
93
94
|
|
94
95
|
public setMainViewDivElement(div: HTMLDivElement) {
|
@@ -108,7 +109,7 @@ export class CursorManager {
|
|
108
109
|
if (!event.isPrimary) return;
|
109
110
|
}
|
110
111
|
this.updateCursor(this.getType(event), event.clientX, event.clientY);
|
111
|
-
},
|
112
|
+
}, 48);
|
112
113
|
|
113
114
|
private updateCursor(event: EventType, clientX: number, clientY: number) {
|
114
115
|
if (this.wrapperRect && this.manager.canOperate) {
|
@@ -166,7 +167,7 @@ export class CursorManager {
|
|
166
167
|
};
|
167
168
|
|
168
169
|
public updateContainerRect() {
|
169
|
-
this.wrapperRect = this.manager.boxManager?.
|
170
|
+
this.wrapperRect = this.manager.boxManager?.stageRect;
|
170
171
|
this.playgroundRect = WindowManager.playground?.getBoundingClientRect();
|
171
172
|
}
|
172
173
|
|
package/src/Helper.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { getVersionNumber, wait } from "./Utils/Common";
|
2
2
|
import { log } from "./Utils/log";
|
3
3
|
import { REQUIRE_VERSION } from "./constants";
|
4
|
-
import { WhiteVersion } from "white-web-sdk";
|
4
|
+
import { toJS, WhiteVersion } from "white-web-sdk";
|
5
5
|
import { WhiteWebSDKInvalidError } from "./Utils/error";
|
6
6
|
import { WindowManager } from "./index";
|
7
7
|
import type { Room, RoomMember } from "white-web-sdk";
|
@@ -41,7 +41,7 @@ export type Member = RoomMember & { uid: string };
|
|
41
41
|
export const serializeRoomMembers = (members: readonly RoomMember[]) => {
|
42
42
|
return members.map(member => ({
|
43
43
|
uid: member.payload?.uid || "",
|
44
|
-
...member,
|
44
|
+
...toJS(member),
|
45
45
|
}));
|
46
46
|
};
|
47
47
|
|
package/src/InternalEmitter.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import Emittery from "emittery";
|
2
2
|
import type { TeleBoxRect } from "@netless/telebox-insider";
|
3
3
|
import type { CursorMovePayload } from "./index";
|
4
|
-
import type { Member } from "./Helper";
|
5
4
|
import type { MemberState } from "white-web-sdk";
|
6
5
|
|
7
6
|
export type RemoveSceneParams = {
|
@@ -30,7 +29,6 @@ export type EmitterEvent = {
|
|
30
29
|
changePageState: undefined;
|
31
30
|
writableChange: boolean;
|
32
31
|
containerSizeRatioUpdate: number;
|
33
|
-
roomMembersChange: Member[];
|
34
32
|
memberStateChange: MemberState;
|
35
33
|
};
|
36
34
|
|
@@ -43,7 +43,7 @@ export class CameraSynchronizer {
|
|
43
43
|
if (camera.centerY !== null) {
|
44
44
|
config.centerY = camera.centerY;
|
45
45
|
}
|
46
|
-
this.
|
46
|
+
this.moveCamera(config);
|
47
47
|
}
|
48
48
|
}, 10);
|
49
49
|
|
@@ -53,9 +53,8 @@ export class CameraSynchronizer {
|
|
53
53
|
if (this.rect && this.remoteCamera && needMoveCamera) {
|
54
54
|
const scale = this.rect.width / size.width;
|
55
55
|
const nextScale = this.remoteCamera.scale * scale;
|
56
|
-
this.
|
56
|
+
this.moveCamera({
|
57
57
|
scale: nextScale,
|
58
|
-
animationMode: AnimationMode.Continuous,
|
59
58
|
})
|
60
59
|
}
|
61
60
|
}
|
@@ -64,4 +63,8 @@ export class CameraSynchronizer {
|
|
64
63
|
this.saveCamera(camera);
|
65
64
|
this.remoteCamera = camera;
|
66
65
|
}
|
66
|
+
|
67
|
+
private moveCamera(camera: Partial<Camera>) {
|
68
|
+
this.view?.moveCamera({ ...camera, animationMode: AnimationMode.Continuous });
|
69
|
+
}
|
67
70
|
}
|
package/src/View/ViewSync.ts
CHANGED
package/src/constants.ts
CHANGED
package/src/index.ts
CHANGED
@@ -48,7 +48,7 @@ import type {
|
|
48
48
|
Rectangle} from "white-web-sdk";
|
49
49
|
import type { AppListeners } from "./AppListener";
|
50
50
|
import type { ApplianceIcons, NetlessApp, RegisterParams } from "./typings";
|
51
|
-
import type { TeleBoxColorScheme, TeleBoxState } from "@netless/telebox-insider";
|
51
|
+
import type { TeleBoxColorScheme, TeleBoxFullscreen, TeleBoxState } from "@netless/telebox-insider";
|
52
52
|
import type { AppProxy } from "./App";
|
53
53
|
import type { PublicEvent } from "./callback";
|
54
54
|
import type Emittery from "emittery";
|
@@ -105,6 +105,7 @@ export type AppSyncAttributes = {
|
|
105
105
|
createdAt?: number;
|
106
106
|
camera?: ICamera;
|
107
107
|
size?: ISize;
|
108
|
+
setup: boolean;
|
108
109
|
};
|
109
110
|
|
110
111
|
export type AppInitState = {
|
@@ -147,6 +148,7 @@ export type MountParams = {
|
|
147
148
|
disableCameraTransform?: boolean;
|
148
149
|
prefersColorScheme?: TeleBoxColorScheme;
|
149
150
|
applianceIcons?: ApplianceIcons;
|
151
|
+
fullscreen?: TeleBoxFullscreen;
|
150
152
|
};
|
151
153
|
|
152
154
|
export const reconnectRefresher = new ReconnectRefresher({ emitter });
|
@@ -251,6 +253,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
251
253
|
stageRatio: WindowManager.containerSizeRatio,
|
252
254
|
containerStyle: params.containerStyle,
|
253
255
|
stageStyle: params.stageStyle,
|
256
|
+
fullscreen: params.fullscreen,
|
254
257
|
});
|
255
258
|
manager.appManager?.setBoxManager(manager.boxManager);
|
256
259
|
if (params.container) {
|
@@ -1007,3 +1010,4 @@ export * from "./typings";
|
|
1007
1010
|
|
1008
1011
|
export { BuiltinApps, BuiltinAppsMap } from "./BuiltinApps";
|
1009
1012
|
export type { PublicEvent } from "./callback";
|
1013
|
+
export type { Member } from "./Helper";
|
package/src/style.css
CHANGED
package/src/typings.ts
CHANGED
@@ -11,7 +11,7 @@ import type {
|
|
11
11
|
View,
|
12
12
|
} from "white-web-sdk";
|
13
13
|
import type { AppContext } from "./App";
|
14
|
-
import type { ReadonlyTeleBox, TeleBoxRect } from "@netless/telebox-insider";
|
14
|
+
import type { ReadonlyTeleBox, TeleBoxRect, TeleBoxFullscreen } from "@netless/telebox-insider";
|
15
15
|
import type { PageState } from "./Page";
|
16
16
|
import type { Member } from "./Helper";
|
17
17
|
|
@@ -88,7 +88,7 @@ export type Writeable<T> = { -readonly [P in keyof T]: T[P] };
|
|
88
88
|
|
89
89
|
export type { AppContext } from "./App/AppContext";
|
90
90
|
export type { WhiteBoardView } from "./App";
|
91
|
-
export type { ReadonlyTeleBox, TeleBoxRect };
|
91
|
+
export type { ReadonlyTeleBox, TeleBoxRect, TeleBoxFullscreen };
|
92
92
|
export type { SceneState, SceneDefinition, View, AnimationMode, Displayer, Room, Player };
|
93
93
|
export type { Storage, StorageStateChangedEvent, StorageStateChangedListener } from "./App/Storage";
|
94
94
|
export * from "./Page";
|