@netless/window-manager 1.0.7-beta.3 → 1.0.7-beta.5
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 +183 -167
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/App/AppContext.ts +9 -1
- package/src/App/AppProxy.ts +8 -4
- package/src/AppManager.ts +21 -5
- package/src/AttributesDelegate.ts +5 -4
- package/src/BoxManager.ts +14 -6
- package/src/InternalEmitter.ts +3 -0
- package/src/Utils/extendClass.ts +10 -0
- package/src/callback.ts +8 -1
- package/src/index.ts +7 -6
- package/src/typings.ts +2 -1
package/package.json
CHANGED
package/src/App/AppContext.ts
CHANGED
|
@@ -16,7 +16,7 @@ import type {
|
|
|
16
16
|
View,
|
|
17
17
|
EventListener as WhiteEventListener,
|
|
18
18
|
} from "white-web-sdk";
|
|
19
|
-
import type { ReadonlyTeleBox } from "@netless/telebox-insider";
|
|
19
|
+
import type { NotMinimizedBoxState, ReadonlyTeleBox, TeleBoxState } from "@netless/telebox-insider";
|
|
20
20
|
import type Emittery from "emittery";
|
|
21
21
|
import type { BoxManager } from "../BoxManager";
|
|
22
22
|
import type { AppEmitterEvent, WindowManager } from "../index";
|
|
@@ -74,6 +74,14 @@ export class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any,
|
|
|
74
74
|
return this.manager.windowManger;
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
+
public getBoxStatus = (): TeleBoxState | undefined => {
|
|
78
|
+
return this.manager.store.getBoxStatus(this.appId);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
public getLastNotMinimizedBoxStatus = (): NotMinimizedBoxState | undefined => {
|
|
82
|
+
return this.manager.store.getLastNotMinimizedBoxStatus(this.appId);
|
|
83
|
+
};
|
|
84
|
+
|
|
77
85
|
public getDisplayer = () => {
|
|
78
86
|
return this.manager.displayer;
|
|
79
87
|
};
|
package/src/App/AppProxy.ts
CHANGED
|
@@ -27,7 +27,8 @@ import { WindowManager } from "../index";
|
|
|
27
27
|
import type { SceneState, View, SceneDefinition } from "white-web-sdk";
|
|
28
28
|
import type { AppManager } from "../AppManager";
|
|
29
29
|
import type { NetlessApp } from "../typings";
|
|
30
|
-
import { TELE_BOX_STATE
|
|
30
|
+
import { TELE_BOX_STATE } from "@netless/telebox-insider";
|
|
31
|
+
import type { ReadonlyTeleBox, TeleBoxState } from "@netless/telebox-insider";
|
|
31
32
|
import type { PageRemoveService, PageState } from "../Page";
|
|
32
33
|
import { calculateNextIndex } from "../Page";
|
|
33
34
|
import { boxEmitter } from "../BoxEmitter";
|
|
@@ -217,7 +218,7 @@ export class AppProxy implements PageRemoveService {
|
|
|
217
218
|
options,
|
|
218
219
|
canOperate: this.manager.canOperate,
|
|
219
220
|
smartPosition: this.isAddApp,
|
|
220
|
-
boxStatus
|
|
221
|
+
boxStatus,
|
|
221
222
|
});
|
|
222
223
|
if (this.isAddApp && this.box) {
|
|
223
224
|
if (boxStatus) {
|
|
@@ -309,8 +310,7 @@ export class AppProxy implements PageRemoveService {
|
|
|
309
310
|
const maximized = this.attributes?.["maximized"];
|
|
310
311
|
const minimized = this.attributes?.["minimized"];
|
|
311
312
|
const boxStatus = this.store.getBoxStatus(id) ?? undefined;
|
|
312
|
-
const lastNotMinimizedBoxStatus =
|
|
313
|
-
this.store.getLastNotMinimizedBoxStatus(id) ?? undefined;
|
|
313
|
+
const lastNotMinimizedBoxStatus = this.store.getLastNotMinimizedBoxStatus(id) ?? undefined;
|
|
314
314
|
const zIndex = attrs?.zIndex;
|
|
315
315
|
let payload = { maximized, minimized, zIndex } as AppInitState;
|
|
316
316
|
if (position) {
|
|
@@ -450,6 +450,10 @@ export class AppProxy implements PageRemoveService {
|
|
|
450
450
|
this.appEmitter.emit("pageStateChange", this.pageState);
|
|
451
451
|
}, 50);
|
|
452
452
|
|
|
453
|
+
public notifyBoxStatusChange = (status: TeleBoxState) => {
|
|
454
|
+
this.appEmitter.emit("boxStatusChange", { appId: this.id, status });
|
|
455
|
+
};
|
|
456
|
+
|
|
453
457
|
public get pageState(): PageState {
|
|
454
458
|
return this._pageState.toObject();
|
|
455
459
|
}
|
package/src/AppManager.ts
CHANGED
|
@@ -7,9 +7,10 @@ import { autorun, isPlayer, isRoom, ScenePathType, UpdateEventKind } from "white
|
|
|
7
7
|
import { boxEmitter } from "./BoxEmitter";
|
|
8
8
|
import { calculateNextIndex } from "./Page";
|
|
9
9
|
import { callbacks } from "./callback";
|
|
10
|
-
import { debounce, get,
|
|
10
|
+
import { debounce, get, isInteger, orderBy } from "lodash";
|
|
11
11
|
import { internalEmitter } from "./InternalEmitter";
|
|
12
|
-
import {
|
|
12
|
+
import { createAttributesDelegate, Fields } from "./AttributesDelegate";
|
|
13
|
+
import type { AttributesDelegate } from "./AttributesDelegate";
|
|
13
14
|
import { log } from "./Utils/log";
|
|
14
15
|
import { MainViewProxy } from "./View/MainView";
|
|
15
16
|
import { safeListenPropsUpdated } from "./Utils/Reactive";
|
|
@@ -49,6 +50,7 @@ import type {
|
|
|
49
50
|
BoxStateChangePayload,
|
|
50
51
|
} from "./BoxEmitter";
|
|
51
52
|
import { getExtendClass } from "./Utils/extendClass";
|
|
53
|
+
import type { TeleBoxState } from "@netless/telebox-insider";
|
|
52
54
|
|
|
53
55
|
export class AppManager {
|
|
54
56
|
public displayer: Displayer;
|
|
@@ -434,7 +436,7 @@ export class AppManager {
|
|
|
434
436
|
|
|
435
437
|
private onBoxBlurred = (payload: BoxBlurredPayload) => {
|
|
436
438
|
const focus = this.attributes.focus;
|
|
437
|
-
if (focus === payload.appId) {
|
|
439
|
+
if (focus === payload.appId) {
|
|
438
440
|
this.windowManger.safeSetAttributes({ focus: undefined });
|
|
439
441
|
callbacks.emit("onBoxBlurred", payload);
|
|
440
442
|
}
|
|
@@ -453,12 +455,25 @@ export class AppManager {
|
|
|
453
455
|
callbacks.emit("onBoxStateChange", payload);
|
|
454
456
|
};
|
|
455
457
|
|
|
458
|
+
private notifyBoxesStatusChange = debounce(() => {
|
|
459
|
+
const entries = Object.entries(this.attributes.boxesStatus);
|
|
460
|
+
if (entries.length > 0) {
|
|
461
|
+
entries.forEach(([appId, status]) => {
|
|
462
|
+
const appProxy = this.appProxies.get(appId);
|
|
463
|
+
if (appProxy) {
|
|
464
|
+
appProxy.notifyBoxStatusChange(status as TeleBoxState);
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}, 50);
|
|
469
|
+
|
|
456
470
|
public addBoxesStatusChangeListener = () => {
|
|
457
471
|
this.refresher.add("boxesStatus", () => {
|
|
458
472
|
return safeListenPropsUpdated(
|
|
459
473
|
() => this.attributes.boxesStatus,
|
|
460
474
|
() => {
|
|
461
475
|
this.boxManager?.setBoxesStatus(this.attributes.boxesStatus);
|
|
476
|
+
this.notifyBoxesStatusChange();
|
|
462
477
|
}
|
|
463
478
|
);
|
|
464
479
|
});
|
|
@@ -466,12 +481,13 @@ export class AppManager {
|
|
|
466
481
|
return safeListenPropsUpdated(
|
|
467
482
|
() => this.attributes.lastNotMinimizedBoxesStatus,
|
|
468
483
|
() => {
|
|
469
|
-
this.boxManager?.setLastNotMinimizedBoxesStatus(
|
|
484
|
+
this.boxManager?.setLastNotMinimizedBoxesStatus(
|
|
485
|
+
this.attributes.lastNotMinimizedBoxesStatus
|
|
486
|
+
);
|
|
470
487
|
}
|
|
471
488
|
);
|
|
472
489
|
});
|
|
473
490
|
};
|
|
474
|
-
|
|
475
491
|
public addAppsChangeListener = () => {
|
|
476
492
|
this.refresher.add("apps", () => {
|
|
477
493
|
return safeListenPropsUpdated(
|
|
@@ -4,8 +4,9 @@ import { setViewFocusScenePath } from "./Utils/Common";
|
|
|
4
4
|
import type { AddAppParams, AppSyncAttributes } from "./index";
|
|
5
5
|
import type { Camera, Size, View } from "white-web-sdk";
|
|
6
6
|
import type { Cursor } from "./Cursor/Cursor";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { getExtendClass } from "./Utils/extendClass";
|
|
8
|
+
import type { ExtendClass } from "./Utils/extendClass";
|
|
9
|
+
import type { NotMinimizedBoxState, TeleBoxState } from "@netless/telebox-insider";
|
|
9
10
|
|
|
10
11
|
export enum Fields {
|
|
11
12
|
Apps = "apps",
|
|
@@ -86,11 +87,11 @@ export class AttributesDelegate {
|
|
|
86
87
|
return get(this.attributes, ["minimized"]);
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
public getBoxesStatus(): Record<string,
|
|
90
|
+
public getBoxesStatus(): Record<string, TeleBoxState> | undefined {
|
|
90
91
|
return get(this.attributes, [Fields.BoxesStatus]);
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
public getBoxStatus(id: string):
|
|
94
|
+
public getBoxStatus(id: string): TeleBoxState | undefined {
|
|
94
95
|
return get(this.attributes, [Fields.BoxesStatus, id]);
|
|
95
96
|
}
|
|
96
97
|
|
package/src/BoxManager.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AppAttributes, Events, MIN_HEIGHT, MIN_WIDTH } from "./constants";
|
|
2
2
|
import { debounce } from "lodash";
|
|
3
|
-
import { TELE_BOX_STATE
|
|
3
|
+
import { TELE_BOX_STATE } from "@netless/telebox-insider";
|
|
4
4
|
import { WindowManager } from "./index";
|
|
5
5
|
import type { BoxEmitterType } from "./BoxEmitter";
|
|
6
6
|
import type { AddAppOptions, AppInitState } from "./index";
|
|
@@ -20,7 +20,7 @@ import type { NetlessApp } from "./typings";
|
|
|
20
20
|
import type { View } from "white-web-sdk";
|
|
21
21
|
import type { CallbacksType } from "./callback";
|
|
22
22
|
import type { EmitterType } from "./InternalEmitter";
|
|
23
|
-
import { getExtendClass } from "./Utils/extendClass";
|
|
23
|
+
import { getExtendClass, TeleBoxManager, TeleBoxCollector } from "./Utils/extendClass";
|
|
24
24
|
|
|
25
25
|
export { TELE_BOX_STATE };
|
|
26
26
|
|
|
@@ -290,7 +290,10 @@ export class BoxManager {
|
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
public setBoxesStatus(status?: Record<string, TeleBoxState>): void {
|
|
293
|
-
|
|
293
|
+
const map = new Map(Object.entries(status ?? {}));
|
|
294
|
+
this.teleBoxManager.setBoxesStatus(map, true);
|
|
295
|
+
this.context.callbacks.emit("onBoxesStatusChange", map);
|
|
296
|
+
this.context.emitter.emit("boxesStatusChange", map);
|
|
294
297
|
}
|
|
295
298
|
|
|
296
299
|
public setBoxStatus(appId: string, status?: TeleBoxState): void {
|
|
@@ -298,7 +301,10 @@ export class BoxManager {
|
|
|
298
301
|
}
|
|
299
302
|
|
|
300
303
|
public setLastNotMinimizedBoxesStatus(status?: Record<string, NotMinimizedBoxState>): void {
|
|
301
|
-
|
|
304
|
+
const map = new Map(Object.entries(status ?? {}));
|
|
305
|
+
this.teleBoxManager.setLastNotMinimizedBoxesStatus(map, true);
|
|
306
|
+
this.context.callbacks.emit("onLastNotMinimizedBoxesStatusChange", map);
|
|
307
|
+
this.context.emitter.emit("lastNotMinimizedBoxesStatusChange", map);
|
|
302
308
|
}
|
|
303
309
|
|
|
304
310
|
public setLastNotMinimizedBoxStatus(appId: string, status?: NotMinimizedBoxState): void {
|
|
@@ -323,7 +329,8 @@ export class BoxManager {
|
|
|
323
329
|
useBoxesStatus: createTeleBoxManagerConfig?.useBoxesStatus || false,
|
|
324
330
|
};
|
|
325
331
|
|
|
326
|
-
const
|
|
332
|
+
const TeleBoxManagerClass = getExtendClass(TeleBoxManager, WindowManager.extendClass);
|
|
333
|
+
const manager = new TeleBoxManagerClass(initManagerState);
|
|
327
334
|
if (this.teleBoxManager) {
|
|
328
335
|
this.teleBoxManager.destroy();
|
|
329
336
|
}
|
|
@@ -336,7 +343,8 @@ export class BoxManager {
|
|
|
336
343
|
}
|
|
337
344
|
|
|
338
345
|
public setCollectorContainer(container: HTMLElement) {
|
|
339
|
-
const
|
|
346
|
+
const TeleBoxCollectorClass = getExtendClass(TeleBoxCollector, WindowManager.extendClass);
|
|
347
|
+
const collector = new TeleBoxCollectorClass({
|
|
340
348
|
styles: this.createTeleBoxManagerConfig?.collectorStyles,
|
|
341
349
|
}).mount(container);
|
|
342
350
|
this.teleBoxManager.setCollector(collector);
|
package/src/InternalEmitter.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Emittery from "emittery";
|
|
2
2
|
import type { AppInitState, CursorMovePayload } from "./index";
|
|
3
|
+
import type { NotMinimizedBoxState, TeleBoxState } from "@netless/telebox-insider";
|
|
3
4
|
|
|
4
5
|
export type RemoveSceneParams = {
|
|
5
6
|
scenePath: string;
|
|
@@ -28,6 +29,8 @@ export type EmitterEvent = {
|
|
|
28
29
|
changePageState: undefined;
|
|
29
30
|
writableChange: boolean;
|
|
30
31
|
containerSizeRatioUpdate: number;
|
|
32
|
+
boxesStatusChange: Map<string, TeleBoxState>;
|
|
33
|
+
lastNotMinimizedBoxesStatusChange: Map<string, NotMinimizedBoxState>;
|
|
31
34
|
};
|
|
32
35
|
|
|
33
36
|
export type EmitterType = Emittery<EmitterEvent>;
|
package/src/Utils/extendClass.ts
CHANGED
|
@@ -3,12 +3,14 @@ import { AppManager } from "../AppManager";
|
|
|
3
3
|
import { AttributesDelegate } from "../AttributesDelegate";
|
|
4
4
|
import { BoxManager } from "../BoxManager";
|
|
5
5
|
import { CursorManager } from "../Cursor";
|
|
6
|
+
import { TeleBoxManager, TeleBoxCollector } from "@netless/telebox-insider";
|
|
6
7
|
|
|
7
8
|
export { AppManager } from "../AppManager";
|
|
8
9
|
export { AppContext, AppProxy } from "../App";
|
|
9
10
|
export { BoxManager } from "../BoxManager";
|
|
10
11
|
export { AttributesDelegate } from "../AttributesDelegate";
|
|
11
12
|
export { CursorManager } from "../Cursor";
|
|
13
|
+
export { TeleBoxManager, TeleBoxCollector } from "@netless/telebox-insider";
|
|
12
14
|
|
|
13
15
|
export type ExtendClassAble =
|
|
14
16
|
| typeof AppManager
|
|
@@ -17,6 +19,8 @@ export type ExtendClassAble =
|
|
|
17
19
|
| typeof BoxManager
|
|
18
20
|
| typeof AttributesDelegate
|
|
19
21
|
| typeof CursorManager
|
|
22
|
+
| typeof TeleBoxManager
|
|
23
|
+
| typeof TeleBoxCollector;
|
|
20
24
|
|
|
21
25
|
export type ExtendClass = {
|
|
22
26
|
AppManager?: typeof AppManager;
|
|
@@ -25,6 +29,8 @@ export type ExtendClass = {
|
|
|
25
29
|
CursorManager?: typeof CursorManager;
|
|
26
30
|
AppProxy?: typeof AppProxy;
|
|
27
31
|
AppContext?: typeof AppContext;
|
|
32
|
+
TeleBoxManager?: typeof TeleBoxManager;
|
|
33
|
+
TeleBoxCollector?: typeof TeleBoxCollector;
|
|
28
34
|
};
|
|
29
35
|
export function getExtendClass<T extends ExtendClassAble>(
|
|
30
36
|
baseClass: T,
|
|
@@ -43,6 +49,10 @@ export function getExtendClass<T extends ExtendClassAble>(
|
|
|
43
49
|
return (extendClass?.AppProxy || AppProxy) as T;
|
|
44
50
|
case "AppContext":
|
|
45
51
|
return (extendClass?.AppContext || AppContext) as T;
|
|
52
|
+
case "TeleBoxManager":
|
|
53
|
+
return (extendClass?.TeleBoxManager || TeleBoxManager) as T;
|
|
54
|
+
case "TeleBoxCollector":
|
|
55
|
+
return (extendClass?.TeleBoxCollector || TeleBoxCollector) as T;
|
|
46
56
|
default:
|
|
47
57
|
return baseClass;
|
|
48
58
|
}
|
package/src/callback.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import Emittery from "emittery";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
TeleBoxColorScheme,
|
|
4
|
+
TELE_BOX_STATE,
|
|
5
|
+
TeleBoxState,
|
|
6
|
+
NotMinimizedBoxState,
|
|
7
|
+
} from "@netless/telebox-insider";
|
|
3
8
|
import type { CameraState, SceneState, View, ViewVisionMode } from "white-web-sdk";
|
|
4
9
|
import type { LoadAppEvent } from "./Register";
|
|
5
10
|
import type { PageState } from "./Page";
|
|
@@ -42,6 +47,8 @@ export type PublicEvent = {
|
|
|
42
47
|
onAppViewMounted: AppPayload;
|
|
43
48
|
onAppSetup: string;
|
|
44
49
|
onAppScenePathChange: AppPayload;
|
|
50
|
+
onBoxesStatusChange: Map<string, TeleBoxState>;
|
|
51
|
+
onLastNotMinimizedBoxesStatusChange: Map<string, NotMinimizedBoxState>;
|
|
45
52
|
};
|
|
46
53
|
|
|
47
54
|
export type CallbacksType = Emittery<PublicEvent>;
|
package/src/index.ts
CHANGED
|
@@ -28,9 +28,10 @@ import {
|
|
|
28
28
|
putScenes,
|
|
29
29
|
wait,
|
|
30
30
|
} from "./Utils/Common";
|
|
31
|
-
import {
|
|
31
|
+
import type { BoxManager } from "./BoxManager";
|
|
32
|
+
import type { TELE_BOX_STATE } from "./BoxManager";
|
|
32
33
|
import * as Errors from "./Utils/error";
|
|
33
|
-
import { Apps, Position } from "./AttributesDelegate";
|
|
34
|
+
import type { Apps, Position } from "./AttributesDelegate";
|
|
34
35
|
import type {
|
|
35
36
|
Displayer,
|
|
36
37
|
SceneDefinition,
|
|
@@ -54,7 +55,7 @@ import type {
|
|
|
54
55
|
TeleBoxColorScheme,
|
|
55
56
|
TeleBoxState,
|
|
56
57
|
} from "@netless/telebox-insider";
|
|
57
|
-
import { AppProxy } from "./App";
|
|
58
|
+
import type { AppProxy } from "./App";
|
|
58
59
|
import type { PublicEvent } from "./callback";
|
|
59
60
|
import type Emittery from "emittery";
|
|
60
61
|
import type { PageController, AddPageParams, PageState } from "./Page";
|
|
@@ -63,7 +64,8 @@ import { IframeBridge } from "./View/IframeBridge";
|
|
|
63
64
|
import { setOptions } from "@netless/app-media-player";
|
|
64
65
|
import type { ExtendPluginInstance } from "./ExtendPluginManager";
|
|
65
66
|
import { ExtendPluginManager } from "./ExtendPluginManager";
|
|
66
|
-
import {
|
|
67
|
+
import { getExtendClass } from "./Utils/extendClass";
|
|
68
|
+
import type { ExtendClass } from "./Utils/extendClass";
|
|
67
69
|
|
|
68
70
|
export * from "./utils/extendClass";
|
|
69
71
|
|
|
@@ -395,7 +397,6 @@ export class WindowManager
|
|
|
395
397
|
if (this.appManager) {
|
|
396
398
|
this.appManager.useBoxesStatus = params.useBoxesStatus || false;
|
|
397
399
|
this.appManager.setBoxManager(boxManager);
|
|
398
|
-
|
|
399
400
|
}
|
|
400
401
|
this.bindMainView(mainViewElement, params.disableCameraTransform);
|
|
401
402
|
if (WindowManager.wrapper) {
|
|
@@ -801,7 +802,7 @@ export class WindowManager
|
|
|
801
802
|
}
|
|
802
803
|
}
|
|
803
804
|
|
|
804
|
-
public get boxStatus(): Record<string,
|
|
805
|
+
public get boxStatus(): Record<string, TeleBoxState> | undefined {
|
|
805
806
|
if (this.appManager) {
|
|
806
807
|
return this.appManager.store.getBoxesStatus();
|
|
807
808
|
} else {
|
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 = {
|