@netless/window-manager 1.0.7-beta.1 → 1.0.7-beta.10
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.d.ts +258 -162
- package/dist/index.js +14 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8490 -6806
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +3 -3
- package/src/App/AppContext.ts +27 -2
- package/src/App/AppProxy.ts +49 -6
- package/src/App/Storage/index.ts +1 -0
- package/src/AppListener.ts +17 -17
- package/src/AppManager.ts +88 -8
- package/src/AttributesDelegate.ts +82 -12
- package/src/BoxEmitter.ts +2 -0
- package/src/BoxManager.ts +82 -4
- package/src/Cursor/index.ts +1 -0
- package/src/InternalEmitter.ts +3 -0
- package/src/Utils/extendClass.ts +62 -0
- package/src/callback.ts +10 -1
- package/src/index.ts +92 -11
- package/src/shim.d.ts +4 -0
- package/src/typings.ts +2 -1
package/src/index.ts
CHANGED
|
@@ -28,7 +28,8 @@ import {
|
|
|
28
28
|
putScenes,
|
|
29
29
|
wait,
|
|
30
30
|
} from "./Utils/Common";
|
|
31
|
-
import type {
|
|
31
|
+
import type { BoxManager } from "./BoxManager";
|
|
32
|
+
import type { TELE_BOX_STATE } from "./BoxManager";
|
|
32
33
|
import * as Errors from "./Utils/error";
|
|
33
34
|
import type { Apps, Position } from "./AttributesDelegate";
|
|
34
35
|
import type {
|
|
@@ -49,7 +50,11 @@ import type {
|
|
|
49
50
|
} from "white-web-sdk";
|
|
50
51
|
import type { AppListeners } from "./AppListener";
|
|
51
52
|
import type { ApplianceIcons, NetlessApp, RegisterParams } from "./typings";
|
|
52
|
-
import type {
|
|
53
|
+
import type {
|
|
54
|
+
NotMinimizedBoxState,
|
|
55
|
+
TeleBoxColorScheme,
|
|
56
|
+
TeleBoxState,
|
|
57
|
+
} from "@netless/telebox-insider";
|
|
53
58
|
import type { AppProxy } from "./App";
|
|
54
59
|
import type { PublicEvent } from "./callback";
|
|
55
60
|
import type Emittery from "emittery";
|
|
@@ -59,7 +64,10 @@ import { IframeBridge } from "./View/IframeBridge";
|
|
|
59
64
|
import { setOptions } from "@netless/app-media-player";
|
|
60
65
|
import type { ExtendPluginInstance } from "./ExtendPluginManager";
|
|
61
66
|
import { ExtendPluginManager } from "./ExtendPluginManager";
|
|
62
|
-
|
|
67
|
+
import { getExtendClass } from "./Utils/extendClass";
|
|
68
|
+
import type { ExtendClass } from "./Utils/extendClass";
|
|
69
|
+
|
|
70
|
+
export * from "./utils/extendClass";
|
|
63
71
|
|
|
64
72
|
export type WindowMangerAttributes = {
|
|
65
73
|
modelValue?: string;
|
|
@@ -89,6 +97,12 @@ export type AddAppParams<TAttributes = any> = {
|
|
|
89
97
|
options?: AddAppOptions;
|
|
90
98
|
// 初始化 attributes
|
|
91
99
|
attributes?: TAttributes;
|
|
100
|
+
// 强制置顶
|
|
101
|
+
forceTop?: boolean;
|
|
102
|
+
// 强制正常窗口
|
|
103
|
+
forceNormal?: boolean;
|
|
104
|
+
// 是否可以在内容区域拖动
|
|
105
|
+
isDragContent?: boolean;
|
|
92
106
|
};
|
|
93
107
|
|
|
94
108
|
export type BaseInsertParams = {
|
|
@@ -100,6 +114,12 @@ export type BaseInsertParams = {
|
|
|
100
114
|
// 初始化 attributes
|
|
101
115
|
attributes?: any;
|
|
102
116
|
isDynamicPPT?: boolean;
|
|
117
|
+
// 强制置顶
|
|
118
|
+
forceTop?: boolean;
|
|
119
|
+
// 强制正常窗口
|
|
120
|
+
forceNormal?: boolean;
|
|
121
|
+
// 是否可以在内容区域拖动
|
|
122
|
+
isDragContent?: boolean;
|
|
103
123
|
};
|
|
104
124
|
|
|
105
125
|
export type AppSyncAttributes = {
|
|
@@ -110,6 +130,12 @@ export type AppSyncAttributes = {
|
|
|
110
130
|
isDynamicPPT?: boolean;
|
|
111
131
|
fullPath?: string;
|
|
112
132
|
createdAt?: number;
|
|
133
|
+
// 强制置顶
|
|
134
|
+
forceTop?: boolean;
|
|
135
|
+
// 强制正常窗口
|
|
136
|
+
forceNormal?: boolean;
|
|
137
|
+
// 是否可以在内容区域拖动
|
|
138
|
+
isDragContent?: boolean;
|
|
113
139
|
};
|
|
114
140
|
|
|
115
141
|
export type AppInitState = {
|
|
@@ -122,8 +148,19 @@ export type AppInitState = {
|
|
|
122
148
|
maximized?: boolean;
|
|
123
149
|
minimized?: boolean;
|
|
124
150
|
sceneIndex?: number;
|
|
151
|
+
/** 所有box的基本状态 */
|
|
125
152
|
boxState?: TeleBoxState; // 兼容旧版 telebox
|
|
126
153
|
zIndex?: number;
|
|
154
|
+
/** 扩展版本,单个box的状态 */
|
|
155
|
+
boxStatus?: TeleBoxState;
|
|
156
|
+
/** 上次非最小化窗口状态 */
|
|
157
|
+
lastNotMinimizedBoxStatus?: NotMinimizedBoxState;
|
|
158
|
+
// 强制置顶
|
|
159
|
+
forceTop?: boolean;
|
|
160
|
+
// 强制正常窗口
|
|
161
|
+
forceNormal?: boolean;
|
|
162
|
+
// 是否可以在内容区域拖动
|
|
163
|
+
isDragContent?: boolean;
|
|
127
164
|
};
|
|
128
165
|
|
|
129
166
|
export type CursorMovePayload = { uid: string; state?: "leave"; position: Position };
|
|
@@ -156,15 +193,16 @@ export type MountParams = {
|
|
|
156
193
|
fullscreen?: boolean;
|
|
157
194
|
polling?: boolean;
|
|
158
195
|
supportAppliancePlugin?: boolean;
|
|
196
|
+
/** 是否使用 boxesStatus 状态管理窗口 */
|
|
197
|
+
useBoxesStatus?: boolean;
|
|
159
198
|
};
|
|
160
199
|
|
|
161
200
|
export const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
|
|
162
|
-
|
|
163
201
|
export class WindowManager
|
|
164
202
|
extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
165
203
|
implements PageController
|
|
166
204
|
{
|
|
167
|
-
public static kind = "WindowManager";
|
|
205
|
+
public static readonly kind = "WindowManager";
|
|
168
206
|
public static displayer: Displayer;
|
|
169
207
|
public static wrapper?: HTMLElement;
|
|
170
208
|
public static sizer?: HTMLElement;
|
|
@@ -194,6 +232,7 @@ export class WindowManager
|
|
|
194
232
|
|
|
195
233
|
private boxManager?: BoxManager;
|
|
196
234
|
private static params?: MountParams;
|
|
235
|
+
static extendClass?: ExtendClass;
|
|
197
236
|
|
|
198
237
|
private containerResizeObserver?: ContainerResizeObserver;
|
|
199
238
|
public containerSizeRatio = WindowManager.containerSizeRatio;
|
|
@@ -210,7 +249,10 @@ export class WindowManager
|
|
|
210
249
|
WindowManager._resolve(manager);
|
|
211
250
|
}
|
|
212
251
|
|
|
213
|
-
public static async mount(
|
|
252
|
+
public static async mount(
|
|
253
|
+
params: MountParams,
|
|
254
|
+
extendClass?: ExtendClass
|
|
255
|
+
): Promise<WindowManager> {
|
|
214
256
|
const room = params.room;
|
|
215
257
|
WindowManager.container = params.container;
|
|
216
258
|
WindowManager.supportAppliancePlugin = params.supportAppliancePlugin;
|
|
@@ -219,6 +261,7 @@ export class WindowManager
|
|
|
219
261
|
|
|
220
262
|
const cursor = params.cursor;
|
|
221
263
|
WindowManager.params = params;
|
|
264
|
+
WindowManager.extendClass = extendClass;
|
|
222
265
|
WindowManager.displayer = params.room;
|
|
223
266
|
checkVersion();
|
|
224
267
|
let manager: WindowManager | undefined = undefined;
|
|
@@ -269,11 +312,14 @@ export class WindowManager
|
|
|
269
312
|
}
|
|
270
313
|
await manager.ensureAttributes();
|
|
271
314
|
|
|
315
|
+
const AppManagerClass = getExtendClass(AppManager, WindowManager.extendClass);
|
|
316
|
+
const CursorManagerClass = getExtendClass(CursorManager, WindowManager.extendClass);
|
|
317
|
+
|
|
272
318
|
manager._fullscreen = params.fullscreen;
|
|
273
|
-
manager.appManager = new
|
|
319
|
+
manager.appManager = new AppManagerClass(manager);
|
|
274
320
|
manager.appManager.polling = params.polling || false;
|
|
275
321
|
manager._pageState = new PageStateImpl(manager.appManager);
|
|
276
|
-
manager.cursorManager = new
|
|
322
|
+
manager.cursorManager = new CursorManagerClass(
|
|
277
323
|
manager.appManager,
|
|
278
324
|
Boolean(cursor),
|
|
279
325
|
params.cursorOptions,
|
|
@@ -369,9 +415,13 @@ export class WindowManager
|
|
|
369
415
|
collectorContainer: params.collectorContainer,
|
|
370
416
|
collectorStyles: params.collectorStyles,
|
|
371
417
|
prefersColorScheme: params.prefersColorScheme,
|
|
418
|
+
useBoxesStatus: params.useBoxesStatus,
|
|
372
419
|
});
|
|
373
420
|
this.boxManager = boxManager;
|
|
374
|
-
this.appManager
|
|
421
|
+
if (this.appManager) {
|
|
422
|
+
this.appManager.useBoxesStatus = params.useBoxesStatus || false;
|
|
423
|
+
this.appManager.setBoxManager(boxManager);
|
|
424
|
+
}
|
|
375
425
|
this.bindMainView(mainViewElement, params.disableCameraTransform);
|
|
376
426
|
if (WindowManager.wrapper) {
|
|
377
427
|
this.cursorManager?.setupWrapper(WindowManager.wrapper);
|
|
@@ -696,6 +746,21 @@ export class WindowManager
|
|
|
696
746
|
this.boxManager?.setMinimized(minimized, false);
|
|
697
747
|
}
|
|
698
748
|
|
|
749
|
+
/** 设置指定 box 的状态, 如果为 undefined, 则移除状态*/
|
|
750
|
+
public setBoxStatus(boxId: string, boxStatus?: TELE_BOX_STATE): void {
|
|
751
|
+
if (!this.canOperate) return;
|
|
752
|
+
this.appManager?.store.setBoxStatus(boxId, boxStatus);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/** 设置指定 box 的非最小化状态, 如果为 undefined, 则移除状态 */
|
|
756
|
+
public setLastNotMinimizedBoxStatus(
|
|
757
|
+
boxId: string,
|
|
758
|
+
lastNotMinimizedBoxStatus?: NotMinimizedBoxState
|
|
759
|
+
): void {
|
|
760
|
+
if (!this.canOperate) return;
|
|
761
|
+
this.appManager?.store.setLastNotMinimizedBoxStatus(boxId, lastNotMinimizedBoxStatus);
|
|
762
|
+
}
|
|
763
|
+
|
|
699
764
|
public setFullscreen(fullscreen: boolean): void {
|
|
700
765
|
if (this._fullscreen !== fullscreen) {
|
|
701
766
|
this._fullscreen = fullscreen;
|
|
@@ -761,6 +826,22 @@ export class WindowManager
|
|
|
761
826
|
}
|
|
762
827
|
}
|
|
763
828
|
|
|
829
|
+
public get boxStatus(): Record<string, TeleBoxState> | undefined {
|
|
830
|
+
if (this.appManager) {
|
|
831
|
+
return this.appManager.store.getBoxesStatus();
|
|
832
|
+
} else {
|
|
833
|
+
throw new Errors.AppManagerNotInitError();
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
public get lastNotMinimizedBoxStatus(): Record<string, NotMinimizedBoxState> | undefined {
|
|
838
|
+
if (this.appManager) {
|
|
839
|
+
return this.appManager.store.getLastNotMinimizedBoxesStatus();
|
|
840
|
+
} else {
|
|
841
|
+
throw new Errors.AppManagerNotInitError();
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
|
|
764
845
|
public get darkMode(): boolean {
|
|
765
846
|
return Boolean(this.appManager?.boxManager?.darkMode);
|
|
766
847
|
}
|
|
@@ -891,7 +972,7 @@ export class WindowManager
|
|
|
891
972
|
const mainViewCamera = { ...this.mainView.camera };
|
|
892
973
|
if (isEqual({ ...mainViewCamera, ...pureCamera }, mainViewCamera)) return;
|
|
893
974
|
this.mainView.moveCamera(camera);
|
|
894
|
-
this.appManager?.dispatchInternalEvent(Events.MoveCamera, camera);
|
|
975
|
+
// this.appManager?.dispatchInternalEvent(Events.MoveCamera, camera);
|
|
895
976
|
setTimeout(() => {
|
|
896
977
|
this.appManager?.mainViewProxy.setCameraAndSize();
|
|
897
978
|
}, 500);
|
|
@@ -904,7 +985,7 @@ export class WindowManager
|
|
|
904
985
|
}>
|
|
905
986
|
): void {
|
|
906
987
|
this.mainView.moveCameraToContain(rectangle);
|
|
907
|
-
this.appManager?.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
|
|
988
|
+
// this.appManager?.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
|
|
908
989
|
setTimeout(() => {
|
|
909
990
|
this.appManager?.mainViewProxy.setCameraAndSize();
|
|
910
991
|
}, 500);
|
package/src/shim.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ declare module "*.svelte" {
|
|
|
5
5
|
export default app;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
declare module "@netless/telebox-insider" {
|
|
9
|
+
export * from "@netless/telebox-insider/dist/index.d.ts";
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
declare global {
|
|
9
13
|
const __APP_VERSION__: string;
|
|
10
14
|
const __APP_DEPENDENCIES__: Record<string, string>;
|
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, TeleBoxState } from "@netless/telebox-insider";
|
|
15
15
|
import type { PageState } from "./Page";
|
|
16
16
|
|
|
17
17
|
export interface NetlessApp<
|
|
@@ -58,6 +58,7 @@ export type AppEmitterEvent<T = any> = {
|
|
|
58
58
|
reconnected: void;
|
|
59
59
|
seek: number;
|
|
60
60
|
pageStateChange: PageState;
|
|
61
|
+
boxStatusChange: { appId: string; status: TeleBoxState };
|
|
61
62
|
};
|
|
62
63
|
|
|
63
64
|
export type RegisterEventData = {
|