@netless/window-manager 1.0.0-canary.3 → 1.0.0-canary.32
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/index.cjs.js +120 -12
- package/dist/index.es.js +2284 -954
- package/dist/index.umd.js +120 -12
- package/dist/{App → src/App}/AppContext.d.ts +12 -8
- package/dist/{App → src/App}/AppPageStateImpl.d.ts +0 -0
- package/dist/{App → src/App}/AppProxy.d.ts +36 -7
- package/dist/{App → src/App}/MagixEvent/index.d.ts +0 -0
- package/dist/{App → src/App}/Storage/StorageEvent.d.ts +0 -0
- package/dist/{App → src/App}/Storage/index.d.ts +0 -0
- package/dist/{App → src/App}/Storage/typings.d.ts +0 -0
- package/dist/{App → src/App}/Storage/utils.d.ts +0 -0
- package/dist/src/App/WhiteboardView.d.ts +27 -0
- package/dist/{App → src/App}/index.d.ts +2 -1
- package/dist/src/App/type.d.ts +21 -0
- package/dist/{AppListener.d.ts → src/AppListener.d.ts} +0 -2
- package/dist/{AppManager.d.ts → src/AppManager.d.ts} +7 -6
- package/dist/{AttributesDelegate.d.ts → src/AttributesDelegate.d.ts} +11 -16
- package/dist/{BoxEmitter.d.ts → src/BoxEmitter.d.ts} +0 -0
- package/dist/{BoxManager.d.ts → src/BoxManager.d.ts} +10 -7
- package/dist/{BuiltinApps.d.ts → src/BuiltinApps.d.ts} +3 -0
- package/dist/{Cursor → src/Cursor}/Cursor.d.ts +0 -0
- package/dist/{Cursor → src/Cursor}/icons.d.ts +0 -0
- package/dist/{Cursor → src/Cursor}/index.d.ts +3 -3
- package/dist/{Helper.d.ts → src/Helper.d.ts} +4 -8
- package/dist/{InternalEmitter.d.ts → src/InternalEmitter.d.ts} +3 -4
- package/dist/{Page → src/Page}/PageController.d.ts +1 -0
- package/dist/{Page → src/Page}/index.d.ts +0 -0
- package/dist/{PageState.d.ts → src/PageState.d.ts} +0 -0
- package/dist/{ReconnectRefresher.d.ts → src/ReconnectRefresher.d.ts} +1 -1
- package/dist/{RedoUndo.d.ts → src/RedoUndo.d.ts} +0 -0
- package/dist/{Register → src/Register}/index.d.ts +0 -0
- package/dist/{Register → src/Register}/loader.d.ts +0 -0
- package/dist/{Register → src/Register}/storage.d.ts +0 -0
- package/dist/{Utils → src/Utils}/AppCreateQueue.d.ts +0 -0
- package/dist/{Utils → src/Utils}/Common.d.ts +1 -0
- package/dist/{Utils → src/Utils}/Reactive.d.ts +0 -0
- package/dist/{Utils → src/Utils}/RoomHacker.d.ts +0 -0
- package/dist/{Utils → src/Utils}/error.d.ts +0 -0
- package/dist/{Utils → src/Utils}/log.d.ts +0 -0
- package/dist/src/View/CameraSynchronizer.d.ts +18 -0
- package/dist/{View → src/View}/MainView.d.ts +18 -7
- package/dist/{View → src/View}/ViewManager.d.ts +0 -0
- package/dist/src/View/ViewSync.d.ts +24 -0
- package/dist/{callback.d.ts → src/callback.d.ts} +5 -0
- package/dist/{constants.d.ts → src/constants.d.ts} +8 -5
- package/dist/src/image.d.ts +19 -0
- package/dist/{index.d.ts → src/index.d.ts} +40 -14
- package/dist/src/shim.d.ts +11 -0
- package/dist/{typings.d.ts → src/typings.d.ts} +8 -2
- package/dist/style.css +1 -1
- package/docs/app-context.md +157 -25
- package/docs/mirgrate-to-1.0.md +28 -0
- package/package.json +12 -7
- package/playwright.config.ts +29 -0
- package/pnpm-lock.yaml +517 -35
- package/src/App/AppContext.ts +50 -28
- package/src/App/AppProxy.ts +266 -80
- package/src/App/{WhiteBoardView.ts → WhiteboardView.ts} +38 -7
- package/src/App/index.ts +2 -1
- package/src/App/type.ts +22 -0
- package/src/AppListener.ts +5 -21
- package/src/AppManager.ts +56 -43
- package/src/AttributesDelegate.ts +19 -19
- package/src/BoxManager.ts +60 -40
- package/src/BuiltinApps.ts +5 -0
- package/src/Cursor/Cursor.ts +7 -3
- package/src/Cursor/index.ts +7 -8
- package/src/Helper.ts +25 -7
- package/src/InternalEmitter.ts +3 -4
- package/src/Page/PageController.ts +1 -0
- package/src/PageState.ts +1 -1
- package/src/ReconnectRefresher.ts +7 -2
- package/src/Utils/Common.ts +9 -0
- package/src/Utils/Reactive.ts +27 -26
- package/src/Utils/RoomHacker.ts +3 -0
- package/src/View/CameraSynchronizer.ts +37 -34
- package/src/View/MainView.ts +108 -81
- package/src/View/ViewSync.ts +110 -0
- package/src/callback.ts +1 -0
- package/src/constants.ts +6 -3
- package/src/index.ts +141 -57
- package/src/style.css +3 -46
- package/src/typings.ts +8 -2
- package/vite.config.js +5 -3
- package/dist/App/WhiteBoardView.d.ts +0 -18
- package/dist/View/CameraSynchronizer.d.ts +0 -17
package/src/index.ts
CHANGED
@@ -2,7 +2,7 @@ import pRetry from "p-retry";
|
|
2
2
|
import { AppManager } from "./AppManager";
|
3
3
|
import { appRegister } from "./Register";
|
4
4
|
import { callbacks } from "./callback";
|
5
|
-
import { checkVersion, setupWrapper } from "./Helper";
|
5
|
+
import { checkVersion, createInvisiblePlugin, setupWrapper } from "./Helper";
|
6
6
|
import { createBoxManager } from "./BoxManager";
|
7
7
|
import { CursorManager } from "./Cursor";
|
8
8
|
import { DEFAULT_CONTAINER_RATIO, Events, INIT_DIR, ROOT_DIR } from "./constants";
|
@@ -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,
|
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";
|
@@ -27,9 +27,11 @@ import {
|
|
27
27
|
putScenes,
|
28
28
|
wait,
|
29
29
|
} from "./Utils/Common";
|
30
|
+
import { boxEmitter } from "./BoxEmitter";
|
31
|
+
import { Val } from "value-enhancer";
|
30
32
|
import type { TELE_BOX_STATE, BoxManager } from "./BoxManager";
|
31
33
|
import * as Errors from "./Utils/error";
|
32
|
-
import type { Apps, Position } from "./AttributesDelegate";
|
34
|
+
import type { Apps, Position , ICamera, ISize } from "./AttributesDelegate";
|
33
35
|
import type {
|
34
36
|
Displayer,
|
35
37
|
SceneDefinition,
|
@@ -37,23 +39,20 @@ import type {
|
|
37
39
|
Room,
|
38
40
|
InvisiblePluginContext,
|
39
41
|
Camera,
|
40
|
-
AnimationMode,
|
41
42
|
CameraBound,
|
42
43
|
Point,
|
43
|
-
Rectangle,
|
44
44
|
CameraState,
|
45
45
|
Player,
|
46
46
|
ImageInformation,
|
47
47
|
SceneState,
|
48
|
-
} from "white-web-sdk";
|
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";
|
55
55
|
import type { PageController, AddPageParams, PageState } from "./Page";
|
56
|
-
import { boxEmitter } from "./BoxEmitter";
|
57
56
|
|
58
57
|
export type WindowMangerAttributes = {
|
59
58
|
modelValue?: string;
|
@@ -104,6 +103,9 @@ export type AppSyncAttributes = {
|
|
104
103
|
isDynamicPPT?: boolean;
|
105
104
|
fullPath?: string;
|
106
105
|
createdAt?: number;
|
106
|
+
camera?: ICamera;
|
107
|
+
size?: ISize;
|
108
|
+
setup: boolean;
|
107
109
|
};
|
108
110
|
|
109
111
|
export type AppInitState = {
|
@@ -118,6 +120,11 @@ export type AppInitState = {
|
|
118
120
|
sceneIndex?: number;
|
119
121
|
boxState?: TeleBoxState; // 兼容旧版 telebox
|
120
122
|
zIndex?: number;
|
123
|
+
visible?: boolean;
|
124
|
+
stageRatio?: number;
|
125
|
+
resizable?: boolean;
|
126
|
+
draggable?: boolean;
|
127
|
+
ratio?: number;
|
121
128
|
};
|
122
129
|
|
123
130
|
export type CursorMovePayload = { uid: string; state?: "leave"; position: Position };
|
@@ -127,16 +134,21 @@ export type MountParams = {
|
|
127
134
|
container?: HTMLElement;
|
128
135
|
/** 白板高宽比例, 默认为 9 / 16 */
|
129
136
|
containerSizeRatio?: number;
|
130
|
-
/**
|
137
|
+
/** @deprecated */
|
131
138
|
chessboard?: boolean;
|
139
|
+
/** 是否高亮显示同步区域, 默认为 true */
|
140
|
+
highlightStage?: boolean;
|
132
141
|
collectorContainer?: HTMLElement;
|
133
142
|
collectorStyles?: Partial<CSSStyleDeclaration>;
|
134
143
|
overwriteStyles?: string;
|
144
|
+
containerStyle?: string;
|
145
|
+
stageStyle?: string;
|
135
146
|
cursor?: boolean;
|
136
147
|
debug?: boolean;
|
137
148
|
disableCameraTransform?: boolean;
|
138
149
|
prefersColorScheme?: TeleBoxColorScheme;
|
139
150
|
applianceIcons?: ApplianceIcons;
|
151
|
+
fullscreen?: TeleBoxFullscreen;
|
140
152
|
};
|
141
153
|
|
142
154
|
export const reconnectRefresher = new ReconnectRefresher({ emitter });
|
@@ -160,6 +172,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
160
172
|
public appManager?: AppManager;
|
161
173
|
public cursorManager?: CursorManager;
|
162
174
|
public viewMode = ViewMode.Broadcaster;
|
175
|
+
public viewMode$ = new Val<ViewMode>(ViewMode.Broadcaster);
|
163
176
|
public isReplay = isPlayer(this.displayer);
|
164
177
|
private _pageState?: PageStateImpl;
|
165
178
|
|
@@ -177,7 +190,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
177
190
|
public static async mount(params: MountParams): Promise<WindowManager> {
|
178
191
|
const room = params.room;
|
179
192
|
WindowManager.container = params.container;
|
180
|
-
|
193
|
+
|
181
194
|
const debug = params.debug;
|
182
195
|
|
183
196
|
const cursor = params.cursor;
|
@@ -223,22 +236,24 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
223
236
|
throw new Error("[WindowManager]: create manager failed");
|
224
237
|
}
|
225
238
|
|
226
|
-
if (containerSizeRatio) {
|
227
|
-
WindowManager.containerSizeRatio = containerSizeRatio;
|
239
|
+
if (params.containerSizeRatio) {
|
240
|
+
WindowManager.containerSizeRatio = params.containerSizeRatio;
|
228
241
|
}
|
242
|
+
manager.containerSizeRatio = WindowManager.containerSizeRatio;
|
229
243
|
await manager.ensureAttributes();
|
230
244
|
|
231
245
|
manager.appManager = new AppManager(manager);
|
232
246
|
manager._pageState = new PageStateImpl(manager.appManager);
|
233
247
|
manager.cursorManager = new CursorManager(manager.appManager, Boolean(cursor), params.applianceIcons);
|
234
|
-
|
235
|
-
manager.containerSizeRatio = containerSizeRatio;
|
236
|
-
}
|
248
|
+
|
237
249
|
manager.boxManager = createBoxManager(manager, callbacks, emitter, boxEmitter, {
|
238
250
|
collectorContainer: params.collectorContainer,
|
239
251
|
collectorStyles: params.collectorStyles,
|
240
252
|
prefersColorScheme: params.prefersColorScheme,
|
241
|
-
stageRatio:
|
253
|
+
stageRatio: WindowManager.containerSizeRatio,
|
254
|
+
containerStyle: params.containerStyle,
|
255
|
+
stageStyle: params.stageStyle,
|
256
|
+
fullscreen: params.fullscreen,
|
242
257
|
});
|
243
258
|
manager.appManager?.setBoxManager(manager.boxManager);
|
244
259
|
if (params.container) {
|
@@ -257,8 +272,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
257
272
|
return manager;
|
258
273
|
}
|
259
274
|
|
260
|
-
private static async initManager(room: Room): Promise<WindowManager> {
|
261
|
-
let manager = room.getInvisiblePlugin(WindowManager.kind) as WindowManager;
|
275
|
+
private static async initManager(room: Room): Promise<WindowManager | undefined> {
|
276
|
+
let manager = room.getInvisiblePlugin(WindowManager.kind) as WindowManager | undefined;
|
262
277
|
if (!manager) {
|
263
278
|
if (isRoom(room)) {
|
264
279
|
if (room.isWritable === false) {
|
@@ -267,18 +282,12 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
267
282
|
} catch (error) {
|
268
283
|
throw new Error("[WindowManger]: room must be switched to be writable");
|
269
284
|
}
|
270
|
-
manager =
|
271
|
-
|
272
|
-
{}
|
273
|
-
)) as WindowManager;
|
274
|
-
manager.ensureAttributes();
|
285
|
+
manager = await createInvisiblePlugin(room);
|
286
|
+
manager?.ensureAttributes();
|
275
287
|
await wait(500);
|
276
288
|
await room.setWritable(false);
|
277
289
|
} else {
|
278
|
-
manager =
|
279
|
-
WindowManager,
|
280
|
-
{}
|
281
|
-
)) as WindowManager;
|
290
|
+
manager = await createInvisiblePlugin(room);
|
282
291
|
}
|
283
292
|
}
|
284
293
|
}
|
@@ -287,12 +296,13 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
287
296
|
|
288
297
|
private static initContainer(
|
289
298
|
container: HTMLElement,
|
299
|
+
target: HTMLElement,
|
290
300
|
overwriteStyles: string | undefined
|
291
301
|
) {
|
292
302
|
if (!WindowManager.container) {
|
293
303
|
WindowManager.container = container;
|
294
304
|
}
|
295
|
-
const { playground, mainViewElement } = setupWrapper(container);
|
305
|
+
const { playground, mainViewElement } = setupWrapper(container, target);
|
296
306
|
WindowManager.playground = playground;
|
297
307
|
if (overwriteStyles) {
|
298
308
|
const style = document.createElement("style");
|
@@ -315,10 +325,12 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
315
325
|
container.appendChild(WindowManager.container.firstChild);
|
316
326
|
}
|
317
327
|
} else {
|
318
|
-
|
328
|
+
const teleboxContainer = this.boxManager?.teleBoxManager.$stage;
|
329
|
+
if (WindowManager.params && teleboxContainer) {
|
319
330
|
const params = WindowManager.params;
|
320
331
|
const mainViewElement = WindowManager.initContainer(
|
321
332
|
container,
|
333
|
+
teleboxContainer,
|
322
334
|
params.overwriteStyles
|
323
335
|
);
|
324
336
|
if (this.boxManager && WindowManager.playground) {
|
@@ -328,6 +340,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
328
340
|
if (WindowManager.playground) {
|
329
341
|
this.cursorManager?.setupWrapper(WindowManager.playground);
|
330
342
|
}
|
343
|
+
|
331
344
|
}
|
332
345
|
}
|
333
346
|
emitter.emit("updateManagerRect");
|
@@ -502,6 +515,18 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
502
515
|
}
|
503
516
|
}
|
504
517
|
|
518
|
+
public async jumpPage(index: number): Promise<boolean> {
|
519
|
+
if (!this.appManager) {
|
520
|
+
return false;
|
521
|
+
}
|
522
|
+
if (index < 0 || index >= this.pageState.length) {
|
523
|
+
console.warn(`[WindowManager]: index ${index} out of range`);
|
524
|
+
return false;
|
525
|
+
}
|
526
|
+
await this.appManager.setMainViewSceneIndex(index);
|
527
|
+
return true;
|
528
|
+
}
|
529
|
+
|
505
530
|
public async addPage(params?: AddPageParams): Promise<void> {
|
506
531
|
if (this.appManager) {
|
507
532
|
const after = params?.after;
|
@@ -578,16 +603,19 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
578
603
|
* 设置 ViewMode
|
579
604
|
*/
|
580
605
|
public setViewMode(mode: ViewMode): void {
|
606
|
+
log("setViewMode", mode);
|
607
|
+
const mainViewProxy = this.appManager?.mainViewProxy;
|
581
608
|
if (mode === ViewMode.Broadcaster) {
|
582
609
|
if (this.canOperate) {
|
583
|
-
|
610
|
+
mainViewProxy?.storeCurrentCamera();
|
584
611
|
}
|
585
|
-
|
612
|
+
mainViewProxy?.start();
|
586
613
|
}
|
587
614
|
if (mode === ViewMode.Freedom) {
|
588
|
-
|
615
|
+
mainViewProxy?.stop();
|
589
616
|
}
|
590
617
|
this.viewMode = mode;
|
618
|
+
this.viewMode$.setValue(mode);
|
591
619
|
}
|
592
620
|
|
593
621
|
public setBoxState(boxState: TeleBoxState): void {
|
@@ -635,6 +663,22 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
635
663
|
}
|
636
664
|
}
|
637
665
|
|
666
|
+
public get baseCamera$() {
|
667
|
+
if (this.appManager) {
|
668
|
+
return this.appManager.mainViewProxy.camera$;
|
669
|
+
} else {
|
670
|
+
throw new Errors.AppManagerNotInitError();
|
671
|
+
}
|
672
|
+
}
|
673
|
+
|
674
|
+
public get baseSize$() {
|
675
|
+
if (this.appManager) {
|
676
|
+
return this.appManager.mainViewProxy.size$;
|
677
|
+
} else {
|
678
|
+
throw new Errors.AppManagerNotInitError();
|
679
|
+
}
|
680
|
+
}
|
681
|
+
|
638
682
|
public get cameraState(): CameraState {
|
639
683
|
if (this.appManager) {
|
640
684
|
return this.appManager.mainViewProxy.cameraState;
|
@@ -667,6 +711,14 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
667
711
|
}
|
668
712
|
}
|
669
713
|
|
714
|
+
public get fullscreen(): TeleBoxFullscreen | undefined {
|
715
|
+
if (this.appManager) {
|
716
|
+
return this.appManager.boxManager?.teleBoxManager.fullscreen;
|
717
|
+
} else {
|
718
|
+
throw new Errors.AppManagerNotInitError();
|
719
|
+
}
|
720
|
+
}
|
721
|
+
|
670
722
|
public get focused(): string | undefined {
|
671
723
|
return this.attributes.focus;
|
672
724
|
}
|
@@ -741,30 +793,31 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
741
793
|
return this.appManager?.closeApp(appId);
|
742
794
|
}
|
743
795
|
|
744
|
-
public moveCamera(
|
745
|
-
camera: Partial<Camera> & { animationMode?: AnimationMode | undefined }
|
746
|
-
): void {
|
747
|
-
const pureCamera = omit(camera, ["animationMode"]);
|
796
|
+
public moveCamera(camera: Partial<Camera> ): void {
|
748
797
|
const mainViewCamera = { ...this.mainView.camera };
|
749
|
-
|
750
|
-
|
751
|
-
this.appManager
|
752
|
-
|
753
|
-
this.appManager
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
798
|
+
const nextCamera = { ...mainViewCamera, ...camera };
|
799
|
+
if (isEqual(nextCamera, mainViewCamera)) return;
|
800
|
+
if (!this.appManager) return;
|
801
|
+
this.appManager.mainViewProxy.storeCamera({
|
802
|
+
id: this.appManager.uid,
|
803
|
+
...nextCamera
|
804
|
+
});
|
805
|
+
}
|
806
|
+
|
807
|
+
public moveCameraToContain(rectangle: Rectangle): void {
|
808
|
+
if (!this.appManager) return;
|
809
|
+
const mainViewSize = this.appManager.mainViewProxy.size$.value;
|
810
|
+
if (mainViewSize) {
|
811
|
+
const wScale = mainViewSize.width / rectangle.width;
|
812
|
+
const hScale = mainViewSize.height / rectangle.height;
|
813
|
+
const nextScale = Math.min(wScale, hScale);
|
814
|
+
this.appManager.mainViewProxy.storeCamera({
|
815
|
+
id: this.appManager.uid,
|
816
|
+
scale: nextScale,
|
817
|
+
centerX: rectangle.originX,
|
818
|
+
centerY: rectangle.originY,
|
819
|
+
});
|
820
|
+
}
|
768
821
|
}
|
769
822
|
|
770
823
|
public convertToPointInWorld(point: Point): Point {
|
@@ -833,6 +886,10 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
833
886
|
this.appManager?.boxManager?.setPrefersColorScheme(scheme);
|
834
887
|
}
|
835
888
|
|
889
|
+
public setFullscreen(fullscreen: TeleBoxFullscreen): void {
|
890
|
+
this.appManager?.boxManager?.teleBoxManager.setFullscreen(fullscreen);
|
891
|
+
}
|
892
|
+
|
836
893
|
public cleanCurrentScene(): void {
|
837
894
|
this.focusedView?.cleanCurrentScene();
|
838
895
|
}
|
@@ -892,7 +949,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
892
949
|
if (WindowManager.container) {
|
893
950
|
this.bindContainer(WindowManager.container);
|
894
951
|
}
|
895
|
-
this.appManager?.refresher
|
952
|
+
this.appManager?.refresher.refresh();
|
896
953
|
}
|
897
954
|
|
898
955
|
public setContainerSizeRatio(ratio: number) {
|
@@ -904,6 +961,32 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
904
961
|
emitter.emit("containerSizeRatioUpdate", ratio);
|
905
962
|
}
|
906
963
|
|
964
|
+
public setContainerStyle(style: string) {
|
965
|
+
this.boxManager?.teleBoxManager.setContainerStyle(style);
|
966
|
+
}
|
967
|
+
|
968
|
+
public setStageStyle(style: string) {
|
969
|
+
this.boxManager?.teleBoxManager.setStageStyle(style);
|
970
|
+
}
|
971
|
+
|
972
|
+
public createPPTHandler() {
|
973
|
+
return {
|
974
|
+
onPageJumpTo: (_pptUUID: string, index: number) => {
|
975
|
+
this.appManager?.focusApp?.appContext?.whiteBoardView?.jumpPage(index);
|
976
|
+
},
|
977
|
+
onPageToNext: () => {
|
978
|
+
if (this.focused) {
|
979
|
+
this.appManager?.focusApp?.appContext?.whiteBoardView?.nextPage();
|
980
|
+
}
|
981
|
+
},
|
982
|
+
onPageToPrev: () => {
|
983
|
+
if (this.focused) {
|
984
|
+
this.appManager?.focusApp?.appContext?.whiteBoardView?.prevPage();
|
985
|
+
}
|
986
|
+
}
|
987
|
+
}
|
988
|
+
}
|
989
|
+
|
907
990
|
private isDynamicPPT(scenes: SceneDefinition[]) {
|
908
991
|
const sceneSrc = scenes[0]?.ppt?.src;
|
909
992
|
return sceneSrc?.startsWith("pptx://");
|
@@ -937,5 +1020,6 @@ setupBuiltin();
|
|
937
1020
|
|
938
1021
|
export * from "./typings";
|
939
1022
|
|
940
|
-
export { BuiltinApps } from "./BuiltinApps";
|
1023
|
+
export { BuiltinApps, BuiltinAppsMap } from "./BuiltinApps";
|
941
1024
|
export type { PublicEvent } from "./callback";
|
1025
|
+
export type { Member } from "./Helper";
|
package/src/style.css
CHANGED
@@ -7,48 +7,9 @@
|
|
7
7
|
user-select: none;
|
8
8
|
}
|
9
9
|
|
10
|
-
.netless-window-manager-sizer {
|
11
|
-
position: absolute;
|
12
|
-
top: 0;
|
13
|
-
left: 0;
|
14
|
-
width: 100%;
|
15
|
-
height: 100%;
|
16
|
-
z-index: 1;
|
17
|
-
overflow: hidden;
|
18
|
-
display: flex;
|
19
|
-
}
|
20
|
-
|
21
|
-
.netless-window-manager-sizer-horizontal {
|
22
|
-
flex-direction: column;
|
23
|
-
}
|
24
|
-
|
25
|
-
.netless-window-manager-sizer::before,
|
26
|
-
.netless-window-manager-sizer::after {
|
27
|
-
flex: 1;
|
28
|
-
content: "";
|
29
|
-
display: block;
|
30
|
-
}
|
31
|
-
|
32
|
-
.netless-window-manager-chess-sizer::before,
|
33
|
-
.netless-window-manager-chess-sizer::after {
|
34
|
-
background-image: linear-gradient(45deg, #b0b0b0 25%, transparent 25%),
|
35
|
-
linear-gradient(-45deg, #b0b0b0 25%, transparent 25%),
|
36
|
-
linear-gradient(45deg, transparent 75%, #b0b0b0 75%),
|
37
|
-
linear-gradient(-45deg, transparent 75%, #b0b0b0 75%);
|
38
|
-
background-color: #fff;
|
39
|
-
background-size: 20px 20px;
|
40
|
-
background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
|
41
|
-
}
|
42
|
-
|
43
|
-
.netless-window-manager-wrapper {
|
44
|
-
position: relative;
|
45
|
-
z-index: 1;
|
46
|
-
width: 100%;
|
47
|
-
height: 100%;
|
48
|
-
overflow: hidden;
|
49
|
-
}
|
50
10
|
|
51
11
|
.netless-window-manager-main-view {
|
12
|
+
position: absolute;
|
52
13
|
width: 100%;
|
53
14
|
height: 100%;
|
54
15
|
}
|
@@ -122,7 +83,7 @@
|
|
122
83
|
left: 0;
|
123
84
|
top: 0;
|
124
85
|
will-change: transform;
|
125
|
-
transition: transform 0.
|
86
|
+
transition: transform 0.12s;
|
126
87
|
transform-origin: 0 0;
|
127
88
|
user-select: none;
|
128
89
|
}
|
@@ -180,10 +141,6 @@
|
|
180
141
|
}
|
181
142
|
|
182
143
|
.window-manager-view-wrapper {
|
183
|
-
z-index: 5000;
|
184
|
-
width: 100%;
|
185
|
-
height: 100%;
|
186
144
|
position: absolute;
|
187
|
-
|
188
|
-
top: 0;
|
145
|
+
z-index: 10;
|
189
146
|
}
|
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
|
|
@@ -30,6 +30,9 @@ export interface NetlessApp<Attributes = any, MagixEventPayloads = any, AppOptio
|
|
30
30
|
|
31
31
|
/** App only single instance. */
|
32
32
|
singleton?: boolean;
|
33
|
+
|
34
|
+
/** App box enableShadowDom. Default true */
|
35
|
+
enableShadowDOM?: boolean;
|
33
36
|
};
|
34
37
|
setup: (context: AppContext<Attributes, MagixEventPayloads, AppOptions>) => SetupResult;
|
35
38
|
}
|
@@ -74,15 +77,18 @@ export type RegisterParams<AppOptions = any, SetupResult = any, Attributes = any
|
|
74
77
|
addHooks?: (emitter: Emittery<RegisterEvents<SetupResult>>) => void;
|
75
78
|
/** dynamic load app package name */
|
76
79
|
name?: string;
|
80
|
+
contentStyles?: string;
|
77
81
|
};
|
78
82
|
|
79
83
|
export type AppListenerKeys = keyof AppEmitterEvent;
|
80
84
|
|
81
85
|
export type ApplianceIcons = Partial<Record<ApplianceNames, string>>;
|
82
86
|
|
87
|
+
export type Writeable<T> = { -readonly [P in keyof T]: T[P] };
|
88
|
+
|
83
89
|
export type { AppContext } from "./App/AppContext";
|
84
90
|
export type { WhiteBoardView } from "./App";
|
85
|
-
export type { ReadonlyTeleBox, TeleBoxRect };
|
91
|
+
export type { ReadonlyTeleBox, TeleBoxRect, TeleBoxFullscreen };
|
86
92
|
export type { SceneState, SceneDefinition, View, AnimationMode, Displayer, Room, Player };
|
87
93
|
export type { Storage, StorageStateChangedEvent, StorageStateChangedListener } from "./App/Storage";
|
88
94
|
export * from "./Page";
|
package/vite.config.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import path from "path";
|
2
|
+
import dts from 'vite-plugin-dts'
|
2
3
|
import { defineConfig } from 'vitest/config'
|
3
4
|
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
4
5
|
import { dependencies, peerDependencies, version, devDependencies } from "./package.json"
|
@@ -28,7 +29,8 @@ export default defineConfig(({ mode }) => {
|
|
28
29
|
experimental: {
|
29
30
|
useVitePreprocess: true,
|
30
31
|
},
|
31
|
-
})
|
32
|
+
}),
|
33
|
+
dts()
|
32
34
|
],
|
33
35
|
build: {
|
34
36
|
lib: {
|
@@ -45,7 +47,7 @@ export default defineConfig(({ mode }) => {
|
|
45
47
|
...peerDependencies,
|
46
48
|
}),
|
47
49
|
},
|
48
|
-
minify: isProd
|
50
|
+
minify: isProd
|
49
51
|
},
|
50
52
|
};
|
51
|
-
})
|
53
|
+
})
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import type { ReadonlyVal } from "value-enhancer";
|
2
|
-
import type { AddPageParams, PageController, PageState } from "../Page";
|
3
|
-
import type { AppProxy } from "./AppProxy";
|
4
|
-
import type { AppContext } from "./AppContext";
|
5
|
-
export declare class WhiteBoardView implements PageController {
|
6
|
-
protected appContext: AppContext;
|
7
|
-
protected appProxy: AppProxy;
|
8
|
-
private removeViewWrapper;
|
9
|
-
readonly pageState$: ReadonlyVal<PageState>;
|
10
|
-
constructor(appContext: AppContext, appProxy: AppProxy, removeViewWrapper: () => void);
|
11
|
-
get pageState(): PageState;
|
12
|
-
nextPage: () => Promise<boolean>;
|
13
|
-
prevPage: () => Promise<boolean>;
|
14
|
-
jumpPage: (index: number) => Promise<boolean>;
|
15
|
-
addPage: (params?: AddPageParams | undefined) => Promise<void>;
|
16
|
-
removePage: (index?: number | undefined) => Promise<boolean>;
|
17
|
-
destroy(): void;
|
18
|
-
}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import type { TeleBoxRect } from "@netless/telebox-insider";
|
2
|
-
import type { Camera, View, Size } from "white-web-sdk";
|
3
|
-
import type { MainViewSize } from "../AttributesDelegate";
|
4
|
-
export declare type SaveCamera = (camera: Camera) => void;
|
5
|
-
export declare class CameraSynchronizer {
|
6
|
-
protected saveCamera: SaveCamera;
|
7
|
-
protected remoteCamera?: Camera;
|
8
|
-
protected remoteSize?: MainViewSize;
|
9
|
-
protected rect?: TeleBoxRect;
|
10
|
-
protected view?: View;
|
11
|
-
constructor(saveCamera: SaveCamera);
|
12
|
-
setRect(rect: TeleBoxRect): void;
|
13
|
-
setView(view: View): void;
|
14
|
-
onRemoteUpdate: import("lodash").DebouncedFunc<(camera: Camera, size: MainViewSize) => void>;
|
15
|
-
onLocalCameraUpdate(camera: Camera): void;
|
16
|
-
onLocalSizeUpdate(size: Size): void;
|
17
|
-
}
|