@netless/window-manager 1.0.7-beta.4 → 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 +16 -4
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/App/AppContext.ts +9 -1
- package/src/App/AppProxy.ts +4 -0
- package/src/AppManager.ts +14 -1
- package/src/AttributesDelegate.ts +2 -3
- package/src/BoxManager.ts +8 -5
- package/src/InternalEmitter.ts +3 -0
- package/src/callback.ts +8 -1
- package/src/index.ts +1 -1
- 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
|
@@ -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
|
@@ -50,6 +50,7 @@ import type {
|
|
|
50
50
|
BoxStateChangePayload,
|
|
51
51
|
} from "./BoxEmitter";
|
|
52
52
|
import { getExtendClass } from "./Utils/extendClass";
|
|
53
|
+
import type { TeleBoxState } from "@netless/telebox-insider";
|
|
53
54
|
|
|
54
55
|
export class AppManager {
|
|
55
56
|
public displayer: Displayer;
|
|
@@ -454,12 +455,25 @@ export class AppManager {
|
|
|
454
455
|
callbacks.emit("onBoxStateChange", payload);
|
|
455
456
|
};
|
|
456
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
|
+
|
|
457
470
|
public addBoxesStatusChangeListener = () => {
|
|
458
471
|
this.refresher.add("boxesStatus", () => {
|
|
459
472
|
return safeListenPropsUpdated(
|
|
460
473
|
() => this.attributes.boxesStatus,
|
|
461
474
|
() => {
|
|
462
475
|
this.boxManager?.setBoxesStatus(this.attributes.boxesStatus);
|
|
476
|
+
this.notifyBoxesStatusChange();
|
|
463
477
|
}
|
|
464
478
|
);
|
|
465
479
|
});
|
|
@@ -474,7 +488,6 @@ export class AppManager {
|
|
|
474
488
|
);
|
|
475
489
|
});
|
|
476
490
|
};
|
|
477
|
-
|
|
478
491
|
public addAppsChangeListener = () => {
|
|
479
492
|
this.refresher.add("apps", () => {
|
|
480
493
|
return safeListenPropsUpdated(
|
|
@@ -5,7 +5,6 @@ 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
7
|
import { getExtendClass } from "./Utils/extendClass";
|
|
8
|
-
import type { TELE_BOX_STATE } from "@netless/telebox-insider";
|
|
9
8
|
import type { ExtendClass } from "./Utils/extendClass";
|
|
10
9
|
import type { NotMinimizedBoxState, TeleBoxState } from "@netless/telebox-insider";
|
|
11
10
|
|
|
@@ -88,11 +87,11 @@ export class AttributesDelegate {
|
|
|
88
87
|
return get(this.attributes, ["minimized"]);
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
public getBoxesStatus(): Record<string,
|
|
90
|
+
public getBoxesStatus(): Record<string, TeleBoxState> | undefined {
|
|
92
91
|
return get(this.attributes, [Fields.BoxesStatus]);
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
public getBoxStatus(id: string):
|
|
94
|
+
public getBoxStatus(id: string): TeleBoxState | undefined {
|
|
96
95
|
return get(this.attributes, [Fields.BoxesStatus, id]);
|
|
97
96
|
}
|
|
98
97
|
|
package/src/BoxManager.ts
CHANGED
|
@@ -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,10 +301,10 @@ export class BoxManager {
|
|
|
298
301
|
}
|
|
299
302
|
|
|
300
303
|
public setLastNotMinimizedBoxesStatus(status?: Record<string, NotMinimizedBoxState>): void {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
);
|
|
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);
|
|
305
308
|
}
|
|
306
309
|
|
|
307
310
|
public setLastNotMinimizedBoxStatus(appId: string, status?: NotMinimizedBoxState): void {
|
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/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
|
@@ -802,7 +802,7 @@ export class WindowManager
|
|
|
802
802
|
}
|
|
803
803
|
}
|
|
804
804
|
|
|
805
|
-
public get boxStatus(): Record<string,
|
|
805
|
+
public get boxStatus(): Record<string, TeleBoxState> | undefined {
|
|
806
806
|
if (this.appManager) {
|
|
807
807
|
return this.appManager.store.getBoxesStatus();
|
|
808
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 = {
|