@netless/window-manager 0.3.8-canary.2 → 0.3.9
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/MainView.d.ts +1 -1
- package/dist/ViewManager.d.ts +3 -1
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/AppManager.ts +39 -15
- package/src/MainView.ts +17 -16
- package/src/index.ts +1 -1
- package/src/viewManager.ts +15 -2
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@netless/window-manager",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.9",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/index.es.js",
|
6
6
|
"module": "dist/index.es.js",
|
@@ -56,6 +56,6 @@
|
|
56
56
|
"typescript": "^4.3.5",
|
57
57
|
"video.js": "^7.14.3",
|
58
58
|
"vite": "^2.5.3",
|
59
|
-
"white-web-sdk": "^2.15.
|
59
|
+
"white-web-sdk": "^2.15.11"
|
60
60
|
}
|
61
61
|
}
|
package/src/AppManager.ts
CHANGED
@@ -1,12 +1,24 @@
|
|
1
|
-
import
|
1
|
+
import pRetry from "p-retry";
|
2
|
+
import {
|
3
|
+
AppAttributes,
|
4
|
+
AppStatus,
|
5
|
+
Events,
|
6
|
+
MagixEventName
|
7
|
+
} from "./constants";
|
2
8
|
import { AppListeners } from "./AppListener";
|
3
9
|
import { AppProxy } from "./AppProxy";
|
4
10
|
import { AttributesDelegate } from "./AttributesDelegate";
|
11
|
+
import {
|
12
|
+
autorun,
|
13
|
+
isPlayer,
|
14
|
+
isRoom,
|
15
|
+
ScenePathType,
|
16
|
+
ViewVisionMode
|
17
|
+
} from "white-web-sdk";
|
5
18
|
import { BoxManager } from "./BoxManager";
|
6
19
|
import { callbacks, emitter } from "./index";
|
7
20
|
import { CameraStore } from "./Utils/CameraStore";
|
8
21
|
import { genAppId, makeValidScenePath, setScenePath } from "./Utils/Common";
|
9
|
-
import { autorun, isPlayer, isRoom, ScenePathType, ViewVisionMode } from "white-web-sdk";
|
10
22
|
import { log } from "./Utils/log";
|
11
23
|
import { MainViewProxy } from "./MainView";
|
12
24
|
import { onObjectRemoved, safeListenPropsUpdated } from "./Utils/Reactive";
|
@@ -117,16 +129,28 @@ export class AppManager {
|
|
117
129
|
for (const id in apps) {
|
118
130
|
if (!this.appProxies.has(id) && !this.appStatus.has(id)) {
|
119
131
|
const app = apps[id];
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
132
|
+
|
133
|
+
pRetry(async () => {
|
134
|
+
this.appStatus.set(id, AppStatus.StartCreate);
|
135
|
+
// 防御 appAttributes 有可能为 undefined 的情况,这里做一个重试
|
136
|
+
const appAttributes = this.attributes[id];
|
137
|
+
if (!appAttributes) {
|
138
|
+
throw new Error("appAttributes is undefined");
|
139
|
+
}
|
140
|
+
await this.baseInsertApp(
|
141
|
+
{
|
142
|
+
kind: app.kind,
|
143
|
+
options: app.options,
|
144
|
+
isDynamicPPT: app.isDynamicPPT,
|
145
|
+
},
|
146
|
+
id,
|
147
|
+
false
|
148
|
+
);
|
149
|
+
this.focusByAttributes(apps);
|
150
|
+
}, { retries: 3 }).catch(err => {
|
151
|
+
console.warn(`[WindowManager]: Insert App Error`, err);
|
152
|
+
this.appStatus.delete(id);
|
153
|
+
});
|
130
154
|
}
|
131
155
|
}
|
132
156
|
}
|
@@ -178,10 +202,11 @@ export class AppManager {
|
|
178
202
|
|
179
203
|
private afterAddApp(appProxy: AppProxy | undefined) {
|
180
204
|
if (appProxy && appProxy.box) {
|
205
|
+
const box = appProxy.box;
|
181
206
|
emitter.emit("move", {
|
182
207
|
appId: appProxy.id,
|
183
|
-
x:
|
184
|
-
y:
|
208
|
+
x: box?.intrinsicX,
|
209
|
+
y: box?.intrinsicY,
|
185
210
|
});
|
186
211
|
}
|
187
212
|
if (this.boxManager.minimized) {
|
@@ -202,7 +227,6 @@ export class AppManager {
|
|
202
227
|
isAddApp: boolean,
|
203
228
|
focus?: boolean
|
204
229
|
) {
|
205
|
-
this.appStatus.set(appId, AppStatus.StartCreate);
|
206
230
|
if (this.appProxies.has(appId)) {
|
207
231
|
console.warn("[WindowManager]: app duplicate exists and cannot be created again");
|
208
232
|
return;
|
package/src/MainView.ts
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
import { AnimationMode, reaction, ViewVisionMode } from
|
2
|
-
import { Base } from
|
3
|
-
import { callbacks, emitter } from
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
1
|
+
import { AnimationMode, reaction, ViewVisionMode } from "white-web-sdk";
|
2
|
+
import { Base } from "./Base";
|
3
|
+
import { callbacks, emitter } from "./index";
|
4
|
+
import { createView } from "./ViewManager";
|
5
|
+
import { debounce, isEmpty, isEqual } from "lodash";
|
6
|
+
import { Fields } from "./AttributesDelegate";
|
7
|
+
import { notifyMainViewModeChange, setViewFocusScenePath, setViewMode } from "./Utils/Common";
|
7
8
|
import type { Camera, Size, View } from "white-web-sdk";
|
8
9
|
import type { AppManager } from "./AppManager";
|
9
10
|
|
@@ -24,7 +25,7 @@ export class MainViewProxy extends Base {
|
|
24
25
|
setTimeout(() => {
|
25
26
|
this.start();
|
26
27
|
}, 200); // 等待 mainView 挂载完毕再进行监听,否则会触发不必要的 onSizeUpdated
|
27
|
-
})
|
28
|
+
});
|
28
29
|
}
|
29
30
|
|
30
31
|
private get mainViewCamera() {
|
@@ -50,7 +51,7 @@ export class MainViewProxy extends Base {
|
|
50
51
|
}
|
51
52
|
|
52
53
|
public setCameraAndSize(): void {
|
53
|
-
this.store.setMainViewCamera({ ...this.mainView.camera, id: this.context.uid
|
54
|
+
this.store.setMainViewCamera({ ...this.mainView.camera, id: this.context.uid });
|
54
55
|
this.store.setMainViewSize({ ...this.mainView.size, id: this.context.uid });
|
55
56
|
}
|
56
57
|
|
@@ -65,8 +66,8 @@ export class MainViewProxy extends Base {
|
|
65
66
|
{
|
66
67
|
fireImmediately: true,
|
67
68
|
}
|
68
|
-
)
|
69
|
-
}
|
69
|
+
);
|
70
|
+
};
|
70
71
|
|
71
72
|
private sizeReaction = () => {
|
72
73
|
return reaction(
|
@@ -80,15 +81,15 @@ export class MainViewProxy extends Base {
|
|
80
81
|
{
|
81
82
|
fireImmediately: true,
|
82
83
|
}
|
83
|
-
)
|
84
|
-
}
|
84
|
+
);
|
85
|
+
};
|
85
86
|
|
86
87
|
public get view(): View {
|
87
88
|
return this.mainView;
|
88
89
|
}
|
89
90
|
|
90
91
|
public createMainView(): View {
|
91
|
-
const mainView = this.manager.displayer
|
92
|
+
const mainView = createView(this.manager.displayer);
|
92
93
|
mainView.callbacks.on("onSizeUpdated", () => {
|
93
94
|
this.context.updateManagerRect();
|
94
95
|
});
|
@@ -103,11 +104,11 @@ export class MainViewProxy extends Base {
|
|
103
104
|
}
|
104
105
|
|
105
106
|
private cameraListener = (camera: Camera) => {
|
106
|
-
this.store.setMainViewCamera({ ...camera, id: this.context.uid});
|
107
|
+
this.store.setMainViewCamera({ ...camera, id: this.context.uid });
|
107
108
|
if (this.store.getMainViewSize()?.id !== this.context.uid) {
|
108
109
|
this.setMainViewSize(this.view.size);
|
109
110
|
}
|
110
|
-
}
|
111
|
+
};
|
111
112
|
|
112
113
|
public addMainViewListener(): void {
|
113
114
|
if (this.mainViewIsAddListener) return;
|
@@ -138,7 +139,7 @@ export class MainViewProxy extends Base {
|
|
138
139
|
|
139
140
|
private sizeListener = (size: Size) => {
|
140
141
|
this.setMainViewSize(size);
|
141
|
-
}
|
142
|
+
};
|
142
143
|
|
143
144
|
public setMainViewSize = debounce(size => {
|
144
145
|
this.store.setMainViewSize({ ...size, id: this.context.uid });
|
package/src/index.ts
CHANGED
@@ -169,7 +169,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
169
169
|
public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
|
170
170
|
private static isCreated = false;
|
171
171
|
|
172
|
-
public version = "0.3.
|
172
|
+
public version = "0.3.9";
|
173
173
|
|
174
174
|
public appListeners?: AppListeners;
|
175
175
|
|
package/src/viewManager.ts
CHANGED
@@ -3,7 +3,7 @@ import { callbacks, WindowManager } from "./index";
|
|
3
3
|
import { reaction, ViewVisionMode } from "white-web-sdk";
|
4
4
|
import { SET_SCENEPATH_DELAY } from "./constants";
|
5
5
|
import { notifyMainViewModeChange, setScenePath, setViewMode } from "./Utils/Common";
|
6
|
-
import type { View } from "white-web-sdk";
|
6
|
+
import type { View, Displayer } from "white-web-sdk";
|
7
7
|
import type { AppManager } from "./AppManager";
|
8
8
|
|
9
9
|
export class ViewManager extends Base {
|
@@ -44,7 +44,7 @@ export class ViewManager extends Base {
|
|
44
44
|
}
|
45
45
|
|
46
46
|
public createView(appId: string): View {
|
47
|
-
const view = this.displayer
|
47
|
+
const view = createView(this.displayer);
|
48
48
|
setViewMode(view, ViewVisionMode.Freedom);
|
49
49
|
this.views.set(appId, view);
|
50
50
|
return view;
|
@@ -134,6 +134,19 @@ export class ViewManager extends Base {
|
|
134
134
|
}
|
135
135
|
}
|
136
136
|
|
137
|
+
export const createView = (displayer: Displayer): View => {
|
138
|
+
const view = displayer.views.createView();
|
139
|
+
setDefaultCameraBound(view);
|
140
|
+
return view;
|
141
|
+
};
|
142
|
+
|
143
|
+
export const setDefaultCameraBound = (view: View) => {
|
144
|
+
view.setCameraBound({
|
145
|
+
maxContentMode: () => 10,
|
146
|
+
minContentMode: () => 0.1,
|
147
|
+
});
|
148
|
+
};
|
149
|
+
|
137
150
|
export const setupWrapper = (
|
138
151
|
root: HTMLElement
|
139
152
|
): {
|