@netless/window-manager 1.0.0-canary.2 → 1.0.0-canary.22
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/__mocks__/white-web-sdk.ts +10 -1
- package/dist/App/AppContext.d.ts +11 -7
- package/dist/App/AppProxy.d.ts +35 -7
- package/dist/App/{WhiteBoardView.d.ts → WhiteboardView.d.ts} +10 -1
- package/dist/App/index.d.ts +2 -1
- package/dist/App/type.d.ts +21 -0
- package/dist/AppManager.d.ts +5 -5
- package/dist/AttributesDelegate.d.ts +11 -16
- package/dist/BoxManager.d.ts +7 -6
- package/dist/Cursor/index.d.ts +0 -1
- package/dist/InternalEmitter.d.ts +3 -2
- package/dist/Page/PageController.d.ts +1 -0
- package/dist/ReconnectRefresher.d.ts +1 -1
- package/dist/Utils/Common.d.ts +1 -0
- package/dist/View/CameraSynchronizer.d.ts +9 -9
- package/dist/View/MainView.d.ts +18 -7
- package/dist/View/ViewSync.d.ts +24 -0
- package/dist/constants.d.ts +6 -2
- package/dist/index.cjs.js +12 -12
- package/dist/index.d.ts +19 -2
- package/dist/index.es.js +803 -425
- package/dist/index.umd.js +12 -12
- package/dist/style.css +1 -1
- package/docs/app-context.md +98 -64
- package/docs/develop-app.md +2 -5
- package/docs/mirgrate-to-1.0.md +28 -0
- package/package.json +3 -3
- package/pnpm-lock.yaml +9 -9
- package/src/App/AppContext.ts +43 -21
- package/src/App/AppProxy.ts +247 -79
- package/src/App/{WhiteBoardView.ts → WhiteboardView.ts} +38 -4
- package/src/App/index.ts +2 -1
- package/src/App/type.ts +22 -0
- package/src/AppManager.ts +38 -31
- package/src/AttributesDelegate.ts +18 -18
- package/src/BoxManager.ts +28 -22
- package/src/Cursor/index.ts +0 -2
- package/src/InternalEmitter.ts +3 -2
- package/src/Page/PageController.ts +1 -0
- package/src/PageState.ts +1 -1
- package/src/ReconnectRefresher.ts +7 -2
- package/src/Utils/Common.ts +6 -0
- package/src/Utils/Reactive.ts +27 -26
- package/src/Utils/RoomHacker.ts +3 -0
- package/src/View/CameraSynchronizer.ts +43 -30
- package/src/View/MainView.ts +106 -81
- package/src/View/ViewSync.ts +110 -0
- package/src/constants.ts +5 -1
- package/src/index.ts +59 -15
- package/src/style.css +8 -0
package/src/index.ts
CHANGED
@@ -29,7 +29,7 @@ import {
|
|
29
29
|
} from "./Utils/Common";
|
30
30
|
import type { TELE_BOX_STATE, BoxManager } from "./BoxManager";
|
31
31
|
import * as Errors from "./Utils/error";
|
32
|
-
import type { Apps, Position } from "./AttributesDelegate";
|
32
|
+
import type { Apps, Position , ICamera, ISize } from "./AttributesDelegate";
|
33
33
|
import type {
|
34
34
|
Displayer,
|
35
35
|
SceneDefinition,
|
@@ -54,6 +54,7 @@ import type { PublicEvent } from "./callback";
|
|
54
54
|
import type Emittery from "emittery";
|
55
55
|
import type { PageController, AddPageParams, PageState } from "./Page";
|
56
56
|
import { boxEmitter } from "./BoxEmitter";
|
57
|
+
import { Val } from "value-enhancer";
|
57
58
|
|
58
59
|
export type WindowMangerAttributes = {
|
59
60
|
modelValue?: string;
|
@@ -104,6 +105,8 @@ export type AppSyncAttributes = {
|
|
104
105
|
isDynamicPPT?: boolean;
|
105
106
|
fullPath?: string;
|
106
107
|
createdAt?: number;
|
108
|
+
camera?: ICamera;
|
109
|
+
size?: ISize;
|
107
110
|
};
|
108
111
|
|
109
112
|
export type AppInitState = {
|
@@ -118,6 +121,11 @@ export type AppInitState = {
|
|
118
121
|
sceneIndex?: number;
|
119
122
|
boxState?: TeleBoxState; // 兼容旧版 telebox
|
120
123
|
zIndex?: number;
|
124
|
+
visible?: boolean;
|
125
|
+
stageRatio?: number;
|
126
|
+
resizable?: boolean;
|
127
|
+
draggable?: boolean;
|
128
|
+
ratio?: number;
|
121
129
|
};
|
122
130
|
|
123
131
|
export type CursorMovePayload = { uid: string; state?: "leave"; position: Position };
|
@@ -127,8 +135,10 @@ export type MountParams = {
|
|
127
135
|
container?: HTMLElement;
|
128
136
|
/** 白板高宽比例, 默认为 9 / 16 */
|
129
137
|
containerSizeRatio?: number;
|
130
|
-
/**
|
138
|
+
/** @deprecated */
|
131
139
|
chessboard?: boolean;
|
140
|
+
/** 是否高亮显示同步区域, 默认为 true */
|
141
|
+
highlightStage?: boolean;
|
132
142
|
collectorContainer?: HTMLElement;
|
133
143
|
collectorStyles?: Partial<CSSStyleDeclaration>;
|
134
144
|
overwriteStyles?: string;
|
@@ -160,6 +170,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
160
170
|
public appManager?: AppManager;
|
161
171
|
public cursorManager?: CursorManager;
|
162
172
|
public viewMode = ViewMode.Broadcaster;
|
173
|
+
public viewMode$ = new Val<ViewMode>(ViewMode.Broadcaster);
|
163
174
|
public isReplay = isPlayer(this.displayer);
|
164
175
|
private _pageState?: PageStateImpl;
|
165
176
|
|
@@ -177,7 +188,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
177
188
|
public static async mount(params: MountParams): Promise<WindowManager> {
|
178
189
|
const room = params.room;
|
179
190
|
WindowManager.container = params.container;
|
180
|
-
|
191
|
+
|
181
192
|
const debug = params.debug;
|
182
193
|
|
183
194
|
const cursor = params.cursor;
|
@@ -223,22 +234,22 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
223
234
|
throw new Error("[WindowManager]: create manager failed");
|
224
235
|
}
|
225
236
|
|
226
|
-
if (containerSizeRatio) {
|
227
|
-
WindowManager.containerSizeRatio = containerSizeRatio;
|
237
|
+
if (params.containerSizeRatio) {
|
238
|
+
WindowManager.containerSizeRatio = params.containerSizeRatio;
|
228
239
|
}
|
240
|
+
manager.containerSizeRatio = WindowManager.containerSizeRatio;
|
229
241
|
await manager.ensureAttributes();
|
230
242
|
|
231
243
|
manager.appManager = new AppManager(manager);
|
232
244
|
manager._pageState = new PageStateImpl(manager.appManager);
|
233
245
|
manager.cursorManager = new CursorManager(manager.appManager, Boolean(cursor), params.applianceIcons);
|
234
|
-
|
235
|
-
manager.containerSizeRatio = containerSizeRatio;
|
236
|
-
}
|
246
|
+
|
237
247
|
manager.boxManager = createBoxManager(manager, callbacks, emitter, boxEmitter, {
|
238
248
|
collectorContainer: params.collectorContainer,
|
239
249
|
collectorStyles: params.collectorStyles,
|
240
250
|
prefersColorScheme: params.prefersColorScheme,
|
241
|
-
stageRatio:
|
251
|
+
stageRatio: WindowManager.containerSizeRatio,
|
252
|
+
highlightStage: params.highlightStage
|
242
253
|
});
|
243
254
|
manager.appManager?.setBoxManager(manager.boxManager);
|
244
255
|
if (params.container) {
|
@@ -502,6 +513,18 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
502
513
|
}
|
503
514
|
}
|
504
515
|
|
516
|
+
public async jumpPage(index: number): Promise<boolean> {
|
517
|
+
if (!this.appManager) {
|
518
|
+
return false;
|
519
|
+
}
|
520
|
+
if (index < 0 || index >= this.pageState.length) {
|
521
|
+
console.warn(`[WindowManager]: index ${index} out of range`);
|
522
|
+
return false;
|
523
|
+
}
|
524
|
+
await this.appManager.setMainViewSceneIndex(index);
|
525
|
+
return true;
|
526
|
+
}
|
527
|
+
|
505
528
|
public async addPage(params?: AddPageParams): Promise<void> {
|
506
529
|
if (this.appManager) {
|
507
530
|
const after = params?.after;
|
@@ -578,16 +601,19 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
578
601
|
* 设置 ViewMode
|
579
602
|
*/
|
580
603
|
public setViewMode(mode: ViewMode): void {
|
604
|
+
log("setViewMode", mode);
|
605
|
+
const mainViewProxy = this.appManager?.mainViewProxy;
|
581
606
|
if (mode === ViewMode.Broadcaster) {
|
582
607
|
if (this.canOperate) {
|
583
|
-
|
608
|
+
mainViewProxy?.storeCurrentCamera();
|
584
609
|
}
|
585
|
-
|
610
|
+
mainViewProxy?.start();
|
586
611
|
}
|
587
612
|
if (mode === ViewMode.Freedom) {
|
588
|
-
|
613
|
+
mainViewProxy?.stop();
|
589
614
|
}
|
590
615
|
this.viewMode = mode;
|
616
|
+
this.viewMode$.setValue(mode);
|
591
617
|
}
|
592
618
|
|
593
619
|
public setBoxState(boxState: TeleBoxState): void {
|
@@ -750,7 +776,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
750
776
|
this.mainView.moveCamera(camera);
|
751
777
|
this.appManager?.dispatchInternalEvent(Events.MoveCamera, camera);
|
752
778
|
setTimeout(() => {
|
753
|
-
this.appManager?.mainViewProxy.
|
779
|
+
this.appManager?.mainViewProxy.storeCurrentCamera();
|
754
780
|
}, 500);
|
755
781
|
}
|
756
782
|
|
@@ -763,7 +789,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
763
789
|
this.mainView.moveCameraToContain(rectangle);
|
764
790
|
this.appManager?.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
|
765
791
|
setTimeout(() => {
|
766
|
-
this.appManager?.mainViewProxy.
|
792
|
+
this.appManager?.mainViewProxy.storeCurrentCamera();
|
767
793
|
}, 500);
|
768
794
|
}
|
769
795
|
|
@@ -892,7 +918,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
892
918
|
if (WindowManager.container) {
|
893
919
|
this.bindContainer(WindowManager.container);
|
894
920
|
}
|
895
|
-
this.appManager?.refresher
|
921
|
+
this.appManager?.refresher.refresh();
|
896
922
|
}
|
897
923
|
|
898
924
|
public setContainerSizeRatio(ratio: number) {
|
@@ -904,6 +930,24 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
904
930
|
emitter.emit("containerSizeRatioUpdate", ratio);
|
905
931
|
}
|
906
932
|
|
933
|
+
public createPPTHandler() {
|
934
|
+
return {
|
935
|
+
onPageJumpTo: (_pptUUID: string, index: number) => {
|
936
|
+
this.appManager?.focusApp?.appContext?.whiteBoardView?.jumpPage(index);
|
937
|
+
},
|
938
|
+
onPageToNext: () => {
|
939
|
+
if (this.focused) {
|
940
|
+
this.appManager?.focusApp?.appContext?.whiteBoardView?.nextPage();
|
941
|
+
}
|
942
|
+
},
|
943
|
+
onPageToPrev: () => {
|
944
|
+
if (this.focused) {
|
945
|
+
this.appManager?.focusApp?.appContext?.whiteBoardView?.prevPage();
|
946
|
+
}
|
947
|
+
}
|
948
|
+
}
|
949
|
+
}
|
950
|
+
|
907
951
|
private isDynamicPPT(scenes: SceneDefinition[]) {
|
908
952
|
const sceneSrc = scenes[0]?.ppt?.src;
|
909
953
|
return sceneSrc?.startsWith("pptx://");
|