@netless/window-manager 1.0.0-canary.36 → 1.0.0-canary.39
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.cjs.js +8 -8
- package/dist/index.es.js +78 -93
- package/dist/index.umd.js +8 -8
- package/dist/src/Utils/error.d.ts +1 -1
- package/dist/src/callback.d.ts +3 -2
- package/dist/src/index.d.ts +5 -7
- package/package.json +2 -2
- package/src/App/AppProxy.ts +2 -2
- package/src/AppManager.ts +11 -2
- package/src/BoxManager.ts +6 -2
- package/src/Utils/error.ts +2 -2
- package/src/View/CameraSynchronizer.ts +8 -5
- package/src/View/ViewSync.ts +1 -1
- package/src/callback.ts +4 -3
- package/src/index.ts +19 -52
@@ -19,7 +19,7 @@ export declare class BoxNotCreatedError extends Error {
|
|
19
19
|
export declare class InvalidScenePath extends Error {
|
20
20
|
message: string;
|
21
21
|
}
|
22
|
-
export declare class
|
22
|
+
export declare class BoxManagerNotInitializeError extends Error {
|
23
23
|
message: string;
|
24
24
|
}
|
25
25
|
export declare class BindContainerRoomPhaseInvalidError extends Error {
|
package/dist/src/callback.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import Emittery from "emittery";
|
2
|
-
import type { TeleBoxColorScheme, TELE_BOX_STATE } from "@netless/telebox-insider";
|
2
|
+
import type { TeleBoxColorScheme, TeleBoxFullscreen, TELE_BOX_STATE } from "@netless/telebox-insider";
|
3
3
|
import type { CameraState, SceneState, ViewVisionMode } from "white-web-sdk";
|
4
4
|
import type { LoadAppEvent } from "./Register";
|
5
5
|
import type { PageState } from "./Page";
|
6
|
-
import { ICamera, ISize } from "./AttributesDelegate";
|
6
|
+
import type { ICamera, ISize } from "./AttributesDelegate";
|
7
7
|
export declare type PublicEvent = {
|
8
8
|
mainViewModeChange: ViewVisionMode;
|
9
9
|
boxStateChange: `${TELE_BOX_STATE}`;
|
@@ -27,6 +27,7 @@ export declare type PublicEvent = {
|
|
27
27
|
};
|
28
28
|
baseCameraChange: ICamera;
|
29
29
|
baseSizeChange: ISize;
|
30
|
+
fullscreenChange: TeleBoxFullscreen;
|
30
31
|
};
|
31
32
|
export declare type CallbacksType = Emittery<PublicEvent>;
|
32
33
|
export declare const callbacks: CallbacksType;
|
package/dist/src/index.d.ts
CHANGED
@@ -5,10 +5,10 @@ import { ReconnectRefresher } from "./ReconnectRefresher";
|
|
5
5
|
import { Val } from "value-enhancer";
|
6
6
|
import type { TELE_BOX_STATE } from "./BoxManager";
|
7
7
|
import type { Apps, Position, ICamera, ISize } from "./AttributesDelegate";
|
8
|
-
import type { Displayer, SceneDefinition, View, Room, InvisiblePluginContext, Camera, CameraBound, Point, CameraState, Player, ImageInformation, SceneState,
|
8
|
+
import type { Displayer, SceneDefinition, View, Room, InvisiblePluginContext, Camera, CameraBound, Point, CameraState, Player, ImageInformation, SceneState, Size } from "white-web-sdk";
|
9
9
|
import type { AppListeners } from "./AppListener";
|
10
10
|
import type { ApplianceIcons, NetlessApp, RegisterParams } from "./typings";
|
11
|
-
import type { TeleBoxColorScheme, TeleBoxFullscreen, TeleBoxManagerThemeConfig, TeleBoxState } from "@netless/telebox-insider";
|
11
|
+
import type { TeleBoxColorScheme, TeleBoxFullscreen, TeleBoxManager, TeleBoxManagerThemeConfig, TeleBoxState } from "@netless/telebox-insider";
|
12
12
|
import type { AppProxy } from "./App";
|
13
13
|
import type { PublicEvent } from "./callback";
|
14
14
|
import type Emittery from "emittery";
|
@@ -218,6 +218,7 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
|
|
218
218
|
get canUndoSteps(): number;
|
219
219
|
get sceneState(): SceneState;
|
220
220
|
get pageState(): PageState;
|
221
|
+
get teleboxManager(): TeleBoxManager;
|
221
222
|
/**
|
222
223
|
* 查询所有的 App
|
223
224
|
*/
|
@@ -230,12 +231,9 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
|
|
230
231
|
* 关闭 APP
|
231
232
|
*/
|
232
233
|
closeApp(appId: string): Promise<void>;
|
233
|
-
moveCamera(camera: Partial<Camera> & {
|
234
|
+
moveCamera: import("lodash").DebouncedFunc<(camera: Partial<Camera> & {
|
234
235
|
animationMode?: AnimationMode;
|
235
|
-
})
|
236
|
-
moveCameraToContain(rectangle: Rectangle & {
|
237
|
-
animationMode?: AnimationMode;
|
238
|
-
}): void;
|
236
|
+
}) => void>;
|
239
237
|
convertToPointInWorld(point: Point): Point;
|
240
238
|
setCameraBound(cameraBound: CameraBound): void;
|
241
239
|
onDestroy(): void;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@netless/window-manager",
|
3
|
-
"version": "1.0.0-canary.
|
3
|
+
"version": "1.0.0-canary.39",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/index.cjs.js",
|
6
6
|
"module": "dist/index.es.js",
|
@@ -25,7 +25,7 @@
|
|
25
25
|
},
|
26
26
|
"dependencies": {
|
27
27
|
"@juggle/resize-observer": "^3.3.1",
|
28
|
-
"@netless/telebox-insider": "1.0.0-alpha.
|
28
|
+
"@netless/telebox-insider": "1.0.0-alpha.34",
|
29
29
|
"emittery": "^0.11.0",
|
30
30
|
"lodash": "^4.17.21",
|
31
31
|
"p-retry": "^4.6.2",
|
package/src/App/AppProxy.ts
CHANGED
@@ -6,7 +6,7 @@ import { appRegister } from "../Register";
|
|
6
6
|
import { ViewSync } from "../View/ViewSync"
|
7
7
|
import { autorun, reaction, toJS } from "white-web-sdk";
|
8
8
|
import { boxEmitter } from "../BoxEmitter";
|
9
|
-
import {
|
9
|
+
import { BoxManagerNotInitializeError } from "../Utils/error";
|
10
10
|
import { calculateNextIndex } from "../Page";
|
11
11
|
import { combine, Val, ValManager } from "value-enhancer";
|
12
12
|
import { debounce, get, isEqual, isUndefined, omitBy } from "lodash";
|
@@ -312,7 +312,7 @@ export class AppProxy implements PageRemoveService {
|
|
312
312
|
) {
|
313
313
|
log("setupApp", appId, app, options);
|
314
314
|
if (!this.boxManager) {
|
315
|
-
throw new
|
315
|
+
throw new BoxManagerNotInitializeError();
|
316
316
|
}
|
317
317
|
const context = new AppContext(this.manager, appId, this, appOptions);
|
318
318
|
this.appContext = context;
|
package/src/AppManager.ts
CHANGED
@@ -472,16 +472,25 @@ export class AppManager {
|
|
472
472
|
if (appIds.length === 0) {
|
473
473
|
this.appCreateQueue.emitReady();
|
474
474
|
}
|
475
|
-
|
475
|
+
let appsWithCreatedAt = appIds.map(appId => {
|
476
476
|
if (apps[appId].setup) {
|
477
477
|
return {
|
478
478
|
id: appId,
|
479
479
|
createdAt: apps[appId].createdAt,
|
480
480
|
};
|
481
481
|
} else {
|
482
|
-
return {}
|
482
|
+
return {};
|
483
483
|
}
|
484
484
|
});
|
485
|
+
// 兼容 1.0 之前版本的回放, 回放时直接过判断 setup 直接创建 app
|
486
|
+
if (this.isReplay) {
|
487
|
+
appsWithCreatedAt = appIds.map(appId => {
|
488
|
+
return {
|
489
|
+
id: appId,
|
490
|
+
createdAt: apps[appId].createdAt,
|
491
|
+
};
|
492
|
+
});
|
493
|
+
}
|
485
494
|
for (const { id } of orderBy(appsWithCreatedAt, "createdAt", "asc")) {
|
486
495
|
if (id && !this.appProxies.has(id) && !this.appStatus.has(id)) {
|
487
496
|
const app = apps[id];
|
package/src/BoxManager.ts
CHANGED
@@ -14,8 +14,9 @@ import type {
|
|
14
14
|
TeleBoxColorScheme,
|
15
15
|
TeleBoxRect,
|
16
16
|
TeleBoxConfig,
|
17
|
-
TeleBoxFullscreen
|
18
|
-
,
|
17
|
+
TeleBoxFullscreen,
|
18
|
+
TeleBoxManagerThemeConfig,
|
19
|
+
} from "@netless/telebox-insider";
|
19
20
|
import type Emittery from "emittery";
|
20
21
|
import type { NetlessApp } from "./typings";
|
21
22
|
import type { View } from "white-web-sdk";
|
@@ -179,6 +180,9 @@ export class BoxManager {
|
|
179
180
|
emitter.on("containerSizeRatioUpdate", ratio => {
|
180
181
|
this.teleBoxManager._stageRatio$.setValue(ratio);
|
181
182
|
}),
|
183
|
+
this.teleBoxManager._fullscreen$.reaction(fullscreen => {
|
184
|
+
callbacks.emit("fullscreenChange", fullscreen);
|
185
|
+
}),
|
182
186
|
]);
|
183
187
|
}
|
184
188
|
|
package/src/Utils/error.ts
CHANGED
@@ -31,8 +31,8 @@ export class InvalidScenePath extends Error {
|
|
31
31
|
override message = `[WindowManager]: ScenePath should start with "/"`;
|
32
32
|
}
|
33
33
|
|
34
|
-
export class
|
35
|
-
override message = "[WindowManager]: boxManager
|
34
|
+
export class BoxManagerNotInitializeError extends Error {
|
35
|
+
override message = "[WindowManager]: boxManager need initialize";
|
36
36
|
}
|
37
37
|
|
38
38
|
export class BindContainerRoomPhaseInvalidError extends Error {
|
@@ -48,11 +48,14 @@ export class CameraSynchronizer {
|
|
48
48
|
this.remoteSize = size;
|
49
49
|
const needMoveCamera = !isEqual(pick(this.rect, ["width", "height"]), pick(size, ["width", "height"]));
|
50
50
|
if (this.rect && this.remoteCamera && needMoveCamera) {
|
51
|
-
|
52
|
-
const
|
53
|
-
this.
|
54
|
-
|
55
|
-
|
51
|
+
if (!this.view) return;
|
52
|
+
const currentCamera = this.view.camera;
|
53
|
+
this.view?.moveCameraToContain({
|
54
|
+
width: size.width,
|
55
|
+
height: size.height,
|
56
|
+
originX: currentCamera.centerX - (size.width / 2),
|
57
|
+
originY: currentCamera.centerY - (size.height / 2),
|
58
|
+
});
|
56
59
|
}
|
57
60
|
}
|
58
61
|
|
package/src/View/ViewSync.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ViewMode, AnimationMode
|
1
|
+
import { ViewMode, AnimationMode } from "white-web-sdk";
|
2
2
|
import { CameraSynchronizer, computedMinScale } from "./CameraSynchronizer";
|
3
3
|
import { combine } from "value-enhancer";
|
4
4
|
import { SideEffectManager } from "side-effect-manager";
|
package/src/callback.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import Emittery from "emittery";
|
2
|
-
import type { TeleBoxColorScheme, TELE_BOX_STATE } from "@netless/telebox-insider";
|
3
|
-
import type {
|
2
|
+
import type { TeleBoxColorScheme, TeleBoxFullscreen, TELE_BOX_STATE } from "@netless/telebox-insider";
|
3
|
+
import type { CameraState, SceneState, ViewVisionMode } from "white-web-sdk";
|
4
4
|
import type { LoadAppEvent } from "./Register";
|
5
5
|
import type { PageState } from "./Page";
|
6
|
-
import { ICamera, ISize } from "./AttributesDelegate";
|
6
|
+
import type { ICamera, ISize } from "./AttributesDelegate";
|
7
7
|
|
8
8
|
export type PublicEvent = {
|
9
9
|
mainViewModeChange: ViewVisionMode;
|
@@ -24,6 +24,7 @@ export type PublicEvent = {
|
|
24
24
|
appClose: { appId: string; kind: string, error?: Error };
|
25
25
|
baseCameraChange: ICamera;
|
26
26
|
baseSizeChange: ISize;
|
27
|
+
fullscreenChange: TeleBoxFullscreen;
|
27
28
|
};
|
28
29
|
|
29
30
|
export type CallbacksType = Emittery<PublicEvent>;
|
package/src/index.ts
CHANGED
@@ -10,7 +10,7 @@ import { emitter } from "./InternalEmitter";
|
|
10
10
|
import { Fields } from "./AttributesDelegate";
|
11
11
|
import { initDb } from "./Register/storage";
|
12
12
|
import { AnimationMode, InvisiblePlugin, isPlayer, isRoom, RoomPhase, ViewMode } from "white-web-sdk";
|
13
|
-
import { isEqual, isNull, isObject, isNumber,
|
13
|
+
import { isEqual, isNull, isObject, isNumber, debounce } from "lodash";
|
14
14
|
import { log } from "./Utils/log";
|
15
15
|
import { PageStateImpl } from "./PageState";
|
16
16
|
import { ReconnectRefresher } from "./ReconnectRefresher";
|
@@ -44,12 +44,11 @@ import type {
|
|
44
44
|
Player,
|
45
45
|
ImageInformation,
|
46
46
|
SceneState,
|
47
|
-
Rectangle,
|
48
47
|
Size
|
49
48
|
} from "white-web-sdk";
|
50
49
|
import type { AppListeners } from "./AppListener";
|
51
50
|
import type { ApplianceIcons, NetlessApp, RegisterParams } from "./typings";
|
52
|
-
import type { TeleBoxColorScheme, TeleBoxFullscreen, TeleBoxManagerThemeConfig, TeleBoxState } from "@netless/telebox-insider";
|
51
|
+
import type { TeleBoxColorScheme, TeleBoxFullscreen, TeleBoxManager, TeleBoxManagerThemeConfig, TeleBoxState } from "@netless/telebox-insider";
|
53
52
|
import type { AppProxy } from "./App";
|
54
53
|
import type { PublicEvent } from "./callback";
|
55
54
|
import type Emittery from "emittery";
|
@@ -778,6 +777,13 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
778
777
|
}
|
779
778
|
}
|
780
779
|
|
780
|
+
public get teleboxManager(): TeleBoxManager {
|
781
|
+
if (!this.boxManager) {
|
782
|
+
throw new Errors.BoxManagerNotInitializeError();
|
783
|
+
}
|
784
|
+
return this.boxManager.teleBoxManager;
|
785
|
+
}
|
786
|
+
|
781
787
|
/**
|
782
788
|
* 查询所有的 App
|
783
789
|
*/
|
@@ -799,7 +805,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
799
805
|
return this.appManager?.closeApp(appId);
|
800
806
|
}
|
801
807
|
|
802
|
-
public moveCamera(camera: Partial<Camera> & { animationMode?: AnimationMode } ): void {
|
808
|
+
public moveCamera = debounce((camera: Partial<Camera> & { animationMode?: AnimationMode } ): void => {
|
803
809
|
const mainViewCamera = { ...this.mainView.camera };
|
804
810
|
const nextCamera = { ...mainViewCamera, ...camera };
|
805
811
|
if (isEqual(nextCamera, mainViewCamera)) return;
|
@@ -833,54 +839,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
833
839
|
});
|
834
840
|
}, 200);
|
835
841
|
}
|
836
|
-
}
|
837
|
-
|
838
|
-
public moveCameraToContain(rectangle: Rectangle & { animationMode?: AnimationMode }): void {
|
839
|
-
if (!this.appManager) return;
|
840
|
-
const camera: Partial<Camera> = {};
|
841
|
-
if (isNumber(rectangle.originX)) {
|
842
|
-
camera.centerX = rectangle.originX;
|
843
|
-
}
|
844
|
-
if (isNumber(rectangle.originY)) {
|
845
|
-
camera.centerY = rectangle.originY;
|
846
|
-
}
|
847
|
-
if (rectangle.animationMode === AnimationMode.Immediately) {
|
848
|
-
this.appManager.mainViewProxy.storeSize({
|
849
|
-
id: this.appManager.uid,
|
850
|
-
width: rectangle.width,
|
851
|
-
height: rectangle.height,
|
852
|
-
});
|
853
|
-
this.mainView.moveCameraToContain(rectangle);
|
854
|
-
if (!isEmpty(camera) && this.appManager.mainViewProxy.camera$.value) {
|
855
|
-
this.appManager.mainViewProxy.storeCamera({
|
856
|
-
...this.appManager.mainViewProxy.camera$.value,
|
857
|
-
id: this.appManager.uid,
|
858
|
-
centerX: this.mainView.camera.centerX,
|
859
|
-
centerY: this.mainView.camera.centerY
|
860
|
-
});
|
861
|
-
}
|
862
|
-
} else {
|
863
|
-
this.appManager.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
|
864
|
-
this.mainView.moveCameraToContain(rectangle);
|
865
|
-
setTimeout(() => {
|
866
|
-
if (!this.appManager) return;
|
867
|
-
this.appManager.mainViewProxy.storeSize({
|
868
|
-
id: this.appManager.uid,
|
869
|
-
width: rectangle.width,
|
870
|
-
height: rectangle.height,
|
871
|
-
});
|
872
|
-
|
873
|
-
if (!isEmpty(camera) && this.appManager.mainViewProxy.camera$.value) {
|
874
|
-
this.appManager.mainViewProxy.storeCamera({
|
875
|
-
...this.appManager.mainViewProxy.camera$.value,
|
876
|
-
id: this.appManager.uid,
|
877
|
-
centerX: this.mainView.camera.centerX,
|
878
|
-
centerY: this.mainView.camera.centerY
|
879
|
-
});
|
880
|
-
}
|
881
|
-
}, 200);
|
882
|
-
}
|
883
|
-
}
|
842
|
+
}, 200);
|
884
843
|
|
885
844
|
public convertToPointInWorld(point: Point): Point {
|
886
845
|
return this.mainView.convertToPointInWorld(point);
|
@@ -1033,6 +992,14 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
1033
992
|
|
1034
993
|
public setBaseSize(size: Size) {
|
1035
994
|
this.appManager?.mainViewProxy.setMainViewSize(size);
|
995
|
+
setTimeout(() => {
|
996
|
+
if (!this.appManager || !this.appManager.mainViewProxy.camera$.value) return;
|
997
|
+
this.appManager.mainViewProxy.storeCamera({
|
998
|
+
...this.appManager.mainViewProxy.camera$.value,
|
999
|
+
id: this.appManager.uid,
|
1000
|
+
scale: 1
|
1001
|
+
});
|
1002
|
+
}, 500);
|
1036
1003
|
}
|
1037
1004
|
|
1038
1005
|
public createPPTHandler() {
|