@netless/window-manager 0.3.4 → 0.3.6-canary.0
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/AppListener.d.ts +0 -1
- package/dist/AppManager.d.ts +8 -8
- package/dist/Base/Context.d.ts +0 -2
- package/dist/BoxManager.d.ts +0 -1
- package/dist/Cursor/Cursor.d.ts +1 -0
- package/dist/Cursor/index.d.ts +2 -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/dist/typings.d.ts +1 -0
- package/package.json +3 -3
- package/src/AppContext.ts +1 -1
- package/src/AppListener.ts +0 -8
- package/src/AppManager.ts +37 -94
- package/src/AppProxy.ts +1 -0
- package/src/Base/Context.ts +1 -6
- package/src/BoxManager.ts +0 -8
- package/src/Cursor/Cursor.ts +7 -3
- package/src/Cursor/index.ts +15 -14
- package/src/index.ts +3 -2
- package/src/typings.ts +1 -0
- package/src/viewManager.ts +1 -1
package/dist/typings.d.ts
CHANGED
@@ -56,6 +56,7 @@ export declare type RegisterEvents<SetupResult = any> = {
|
|
56
56
|
result: SetupResult;
|
57
57
|
};
|
58
58
|
destroy: RegisterEventData;
|
59
|
+
focus: RegisterEventData;
|
59
60
|
};
|
60
61
|
export declare type RegisterParams<AppOptions = any, SetupResult = any, Attributes = any> = {
|
61
62
|
kind: string;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@netless/window-manager",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.6-canary.0",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/index.es.js",
|
6
6
|
"module": "dist/index.es.js",
|
@@ -24,7 +24,7 @@
|
|
24
24
|
"@juggle/resize-observer": "^3.3.1",
|
25
25
|
"@netless/app-docs-viewer": "^0.1.21",
|
26
26
|
"@netless/app-media-player": "0.1.0-beta.5",
|
27
|
-
"@netless/telebox-insider": "0.2.
|
27
|
+
"@netless/telebox-insider": "0.2.6",
|
28
28
|
"emittery": "^0.9.2",
|
29
29
|
"lodash": "^4.17.21",
|
30
30
|
"p-retry": "^4.6.1",
|
@@ -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": "
|
59
|
+
"white-web-sdk": "2.15.6"
|
60
60
|
}
|
61
61
|
}
|
package/src/AppContext.ts
CHANGED
@@ -102,7 +102,7 @@ export class AppContext<TAttrs extends Record<string, any>, AppOptions = any> {
|
|
102
102
|
public async setScenePath(scenePath: string): Promise<void> {
|
103
103
|
if (!this.appProxy.box) return;
|
104
104
|
this.appProxy.setFullPath(scenePath);
|
105
|
-
this.
|
105
|
+
this.appProxy.context.switchAppToWriter(this.appId);
|
106
106
|
}
|
107
107
|
|
108
108
|
public mountView(dom: HTMLDivElement): void {
|
package/src/AppListener.ts
CHANGED
@@ -28,10 +28,6 @@ export class AppListeners {
|
|
28
28
|
this.appResizeHandler(data.payload);
|
29
29
|
break;
|
30
30
|
}
|
31
|
-
case Events.AppBoxStateChange: {
|
32
|
-
this.appBoxStateHandler(data.payload);
|
33
|
-
break;
|
34
|
-
}
|
35
31
|
case Events.SwitchViewsToFreedom: {
|
36
32
|
this.switchViewsToFreedomHandler();
|
37
33
|
break;
|
@@ -51,10 +47,6 @@ export class AppListeners {
|
|
51
47
|
this.manager.room?.refreshViewSize();
|
52
48
|
};
|
53
49
|
|
54
|
-
private appBoxStateHandler = (payload: any) => {
|
55
|
-
this.boxManager.setBoxState(payload.state);
|
56
|
-
};
|
57
|
-
|
58
50
|
private switchViewsToFreedomHandler = () => {
|
59
51
|
this.manager.viewManager.freedomAllViews();
|
60
52
|
};
|
package/src/AppManager.ts
CHANGED
@@ -1,31 +1,20 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
import {
|
8
|
-
import {
|
9
|
-
import {
|
10
|
-
import {
|
11
|
-
import {
|
12
|
-
import {
|
13
|
-
import {
|
14
|
-
import {
|
15
|
-
autorun,
|
16
|
-
isPlayer,
|
17
|
-
isRoom,
|
18
|
-
ScenePathType,
|
19
|
-
ViewVisionMode
|
20
|
-
} from 'white-web-sdk';
|
21
|
-
import { log } from './Utils/log';
|
22
|
-
import { MainViewProxy } from './MainView';
|
23
|
-
import { onObjectInserted, onObjectRemoved } from './Utils/Reactive';
|
24
|
-
import { ReconnectRefresher } from './ReconnectRefresher';
|
25
|
-
import { ViewManager } from './ViewManager';
|
1
|
+
import { AppAttributes, AppStatus, Events, MagixEventName } from "./constants";
|
2
|
+
import { AppListeners } from "./AppListener";
|
3
|
+
import { AppProxy } from "./AppProxy";
|
4
|
+
import { AttributesDelegate } from "./AttributesDelegate";
|
5
|
+
import { BoxManager } from "./BoxManager";
|
6
|
+
import { callbacks, emitter } from "./index";
|
7
|
+
import { CameraStore } from "./Utils/CameraStore";
|
8
|
+
import { genAppId, makeValidScenePath, setScenePath } from "./Utils/Common";
|
9
|
+
import { autorun, isPlayer, isRoom, ScenePathType, ViewVisionMode } from "white-web-sdk";
|
10
|
+
import { log } from "./Utils/log";
|
11
|
+
import { MainViewProxy } from "./MainView";
|
12
|
+
import { onObjectInserted, onObjectRemoved } from "./Utils/Reactive";
|
13
|
+
import { ReconnectRefresher } from "./ReconnectRefresher";
|
14
|
+
import { ViewManager } from "./ViewManager";
|
26
15
|
import type { Displayer, DisplayerState, Room } from "white-web-sdk";
|
27
16
|
import type { CreateCollectorConfig } from "./BoxManager";
|
28
|
-
import type { AddAppParams, BaseInsertParams, WindowManager
|
17
|
+
import type { AddAppParams, BaseInsertParams, WindowManager, TeleBoxRect } from "./index";
|
29
18
|
export class AppManager {
|
30
19
|
public displayer: Displayer;
|
31
20
|
public boxManager: BoxManager;
|
@@ -39,7 +28,6 @@ export class AppManager {
|
|
39
28
|
|
40
29
|
private appListeners: AppListeners;
|
41
30
|
|
42
|
-
|
43
31
|
constructor(public windowManger: WindowManager, options: CreateCollectorConfig) {
|
44
32
|
this.displayer = windowManger.displayer;
|
45
33
|
this.cameraStore = new CameraStore();
|
@@ -78,24 +66,24 @@ export class AppManager {
|
|
78
66
|
});
|
79
67
|
});
|
80
68
|
this.refresher?.add("maximized", () => {
|
81
|
-
return autorun(
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
this.boxManager.setMaximized(Boolean(maximized));
|
86
|
-
}
|
69
|
+
return autorun(() => {
|
70
|
+
const maximized = this.attributes.maximized;
|
71
|
+
if (this.boxManager.maximized !== maximized) {
|
72
|
+
this.boxManager.setMaximized(Boolean(maximized));
|
87
73
|
}
|
88
|
-
)
|
74
|
+
});
|
89
75
|
});
|
90
76
|
this.refresher?.add("minimized", () => {
|
91
|
-
return autorun(
|
92
|
-
|
93
|
-
|
94
|
-
if (this.
|
95
|
-
this.
|
77
|
+
return autorun(() => {
|
78
|
+
const minimized = this.attributes.minimized;
|
79
|
+
if (this.boxManager.minimized !== minimized) {
|
80
|
+
if (minimized === true && this.store.focus !== undefined) {
|
81
|
+
this.store.cleanFocus();
|
82
|
+
this.boxManager.blurFocusBox();
|
96
83
|
}
|
84
|
+
this.boxManager.setMinimized(Boolean(minimized));
|
97
85
|
}
|
98
|
-
)
|
86
|
+
});
|
99
87
|
});
|
100
88
|
if (!this.attributes.apps || Object.keys(this.attributes.apps).length === 0) {
|
101
89
|
const mainScenePath = this.store.getMainViewScenePath();
|
@@ -142,7 +130,7 @@ export class AppManager {
|
|
142
130
|
appProxy.destroy(true, false);
|
143
131
|
}
|
144
132
|
});
|
145
|
-
}
|
133
|
+
};
|
146
134
|
|
147
135
|
public bindMainView(divElement: HTMLDivElement, disableCameraTransform: boolean) {
|
148
136
|
const mainView = this.mainViewProxy.view;
|
@@ -151,10 +139,7 @@ export class AppManager {
|
|
151
139
|
if (!mainView.focusScenePath) {
|
152
140
|
this.store.setMainViewFocusPath();
|
153
141
|
}
|
154
|
-
if (
|
155
|
-
this.store.focus === undefined &&
|
156
|
-
mainView.mode !== ViewVisionMode.Writable
|
157
|
-
) {
|
142
|
+
if (this.store.focus === undefined && mainView.mode !== ViewVisionMode.Writable) {
|
158
143
|
this.viewManager.switchMainViewToWriter();
|
159
144
|
}
|
160
145
|
this.mainViewProxy.addMainViewListener();
|
@@ -172,16 +157,16 @@ export class AppManager {
|
|
172
157
|
private async beforeAddApp(params: AddAppParams, isDynamicPPT: boolean) {
|
173
158
|
const appId = await genAppId(params.kind);
|
174
159
|
this.appStatus.set(appId, AppStatus.StartCreate);
|
160
|
+
const attrs = params.attributes ?? {};
|
161
|
+
this.safeUpdateAttributes([appId], attrs);
|
175
162
|
this.store.setupAppAttributes(params, appId, isDynamicPPT);
|
176
|
-
if (this.boxManager.
|
177
|
-
this.boxManager.
|
163
|
+
if (this.boxManager.minimized) {
|
164
|
+
this.boxManager.setMinimized(false);
|
178
165
|
}
|
179
|
-
const needFocus = this.boxManager.
|
166
|
+
const needFocus = !this.boxManager.minimized;
|
180
167
|
if (needFocus) {
|
181
168
|
this.store.setAppFocus(appId, true);
|
182
169
|
}
|
183
|
-
const attrs = params.attributes ?? {};
|
184
|
-
this.safeUpdateAttributes([appId], attrs);
|
185
170
|
return { appId, needFocus };
|
186
171
|
}
|
187
172
|
|
@@ -243,7 +228,7 @@ export class AppManager {
|
|
243
228
|
appProxy.appEmitter.emit("roomStateChange", state);
|
244
229
|
});
|
245
230
|
emitter.emit("observerIdChange", this.displayer.observerId);
|
246
|
-
}
|
231
|
+
};
|
247
232
|
|
248
233
|
private displayerWritableListener = (isReadonly: boolean) => {
|
249
234
|
const isWritable = !isReadonly;
|
@@ -265,7 +250,7 @@ export class AppManager {
|
|
265
250
|
} else {
|
266
251
|
this.mainView.disableCameraTransform = true;
|
267
252
|
}
|
268
|
-
}
|
253
|
+
};
|
269
254
|
|
270
255
|
private get eventName() {
|
271
256
|
return isRoom(this.displayer) ? "onRoomStateChanged" : "onPlayerStateChanged";
|
@@ -359,10 +344,6 @@ export class AppManager {
|
|
359
344
|
this.windowManger.safeSetAttributes({ focus: payload.appId });
|
360
345
|
break;
|
361
346
|
}
|
362
|
-
case "blur": {
|
363
|
-
this.dispatchInternalEvent(Events.AppBlur, payload);
|
364
|
-
break;
|
365
|
-
}
|
366
347
|
case "resize": {
|
367
348
|
if (payload.width && payload.height) {
|
368
349
|
this.dispatchInternalEvent(Events.AppResize, payload);
|
@@ -373,44 +354,6 @@ export class AppManager {
|
|
373
354
|
}
|
374
355
|
break;
|
375
356
|
}
|
376
|
-
case TELE_BOX_STATE.Minimized: {
|
377
|
-
this.safeDispatchMagixEvent(MagixEventName, {
|
378
|
-
eventName: Events.AppBoxStateChange,
|
379
|
-
payload: {
|
380
|
-
...payload,
|
381
|
-
state: eventName,
|
382
|
-
},
|
383
|
-
});
|
384
|
-
|
385
|
-
this.store.cleanFocus();
|
386
|
-
this.boxManager.blurFocusBox();
|
387
|
-
break;
|
388
|
-
}
|
389
|
-
case TELE_BOX_STATE.Maximized: {
|
390
|
-
this.safeDispatchMagixEvent(MagixEventName, {
|
391
|
-
eventName: Events.AppBoxStateChange,
|
392
|
-
payload: {
|
393
|
-
...payload,
|
394
|
-
state: eventName,
|
395
|
-
},
|
396
|
-
});
|
397
|
-
const topBox = this.boxManager.getTopBox();
|
398
|
-
if (topBox) {
|
399
|
-
emitter.emit("focus", { appId: topBox.id });
|
400
|
-
}
|
401
|
-
break;
|
402
|
-
}
|
403
|
-
case TELE_BOX_STATE.Normal: {
|
404
|
-
this.safeDispatchMagixEvent(MagixEventName, {
|
405
|
-
eventName: Events.AppBoxStateChange,
|
406
|
-
payload: {
|
407
|
-
...payload,
|
408
|
-
state: eventName,
|
409
|
-
},
|
410
|
-
});
|
411
|
-
this.safeSetAttributes({ boxState: eventName });
|
412
|
-
break;
|
413
|
-
}
|
414
357
|
case "close": {
|
415
358
|
const appProxy = this.appProxies.get(payload.appId);
|
416
359
|
if (appProxy) {
|
package/src/AppProxy.ts
CHANGED
@@ -211,6 +211,7 @@ export class AppProxy extends Base {
|
|
211
211
|
}
|
212
212
|
|
213
213
|
public switchToWritable() {
|
214
|
+
appRegister.notifyApp(this.kind, "focus", { appId: this.id });
|
214
215
|
this.cameraStore.switchView(this.id, this.view, () => {
|
215
216
|
if (this.view) {
|
216
217
|
if (this.view.mode === ViewVisionMode.Writable) return;
|
package/src/Base/Context.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { memoize } from "lodash";
|
2
1
|
import { emitter } from "../index";
|
3
2
|
import type { AppManager } from "../AppManager";
|
4
3
|
|
@@ -14,7 +13,7 @@ export class Context {
|
|
14
13
|
};
|
15
14
|
|
16
15
|
public get uid() {
|
17
|
-
return this.
|
16
|
+
return this.manager.room?.uid || "";
|
18
17
|
}
|
19
18
|
|
20
19
|
public findMember = (memberId: number) => {
|
@@ -27,10 +26,6 @@ export class Context {
|
|
27
26
|
return roomMembers?.find(member => member.payload?.uid === uid);
|
28
27
|
}
|
29
28
|
|
30
|
-
public memoizeFindMember = memoize(this.findMember);
|
31
|
-
|
32
|
-
public memoizeFindMemberByUid = memoize(this.findMemberByUid);
|
33
|
-
|
34
29
|
public updateManagerRect() {
|
35
30
|
this.manager.boxManager.updateManagerRect();
|
36
31
|
}
|
package/src/BoxManager.ts
CHANGED
@@ -225,9 +225,6 @@ export class BoxManager {
|
|
225
225
|
this.teleBoxManager.setMaximized(Boolean(state.maximized), true);
|
226
226
|
this.teleBoxManager.setMinimized(Boolean(state.minimized), true);
|
227
227
|
}
|
228
|
-
if (state.boxState) {
|
229
|
-
this.teleBoxManager.setState(state.boxState, true);
|
230
|
-
}
|
231
228
|
setTimeout(() => {
|
232
229
|
if (state.focus) {
|
233
230
|
this.teleBoxManager.update(box.id, { focus: true }, true);
|
@@ -289,11 +286,6 @@ export class BoxManager {
|
|
289
286
|
this.teleBoxManager.updateAll(config);
|
290
287
|
}
|
291
288
|
|
292
|
-
public setBoxState(state: TELE_BOX_STATE): void {
|
293
|
-
this.teleBoxManager.setState(state, true);
|
294
|
-
callbacks.emit("boxStateChange", state);
|
295
|
-
}
|
296
|
-
|
297
289
|
public setMaximized(maximized: boolean) {
|
298
290
|
this.teleBoxManager.setMaximized(maximized, true);
|
299
291
|
}
|
package/src/Cursor/Cursor.ts
CHANGED
@@ -36,7 +36,7 @@ export class Cursor extends Base {
|
|
36
36
|
pRetry(() => {
|
37
37
|
this.disposer && this.disposer();
|
38
38
|
if (!this.cursorPosition) {
|
39
|
-
|
39
|
+
console.warn(`${memberId} not exist`);
|
40
40
|
}
|
41
41
|
this.startReaction();
|
42
42
|
}, { retries: 3 });
|
@@ -180,8 +180,12 @@ export class Cursor extends Base {
|
|
180
180
|
}
|
181
181
|
|
182
182
|
public setMember() {
|
183
|
-
this.member = this.context.
|
184
|
-
this.
|
183
|
+
this.member = this.context.findMemberByUid(this.memberId);
|
184
|
+
this.updateComponent();
|
185
|
+
}
|
186
|
+
|
187
|
+
private updateComponent() {
|
188
|
+
this.component?.$set(omit(this.initProps(), ["x", "y"]));
|
185
189
|
}
|
186
190
|
|
187
191
|
public destroy() {
|
package/src/Cursor/index.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Base } from '../Base';
|
2
2
|
import { Cursor } from './Cursor';
|
3
3
|
import { CursorState } from '../constants';
|
4
|
-
import { debounce } from 'lodash';
|
4
|
+
import { compact, debounce, uniq } from 'lodash';
|
5
5
|
import { Fields } from '../AttributesDelegate';
|
6
6
|
import { onObjectInserted } from '../Utils/Reactive';
|
7
7
|
import { WindowManager } from '../index';
|
@@ -54,8 +54,12 @@ export class CursorManager extends Base {
|
|
54
54
|
})
|
55
55
|
}
|
56
56
|
|
57
|
+
private getUids = (members: readonly RoomMember[] | undefined) => {
|
58
|
+
return compact(uniq(members?.map(member => member.payload?.uid)));
|
59
|
+
}
|
60
|
+
|
57
61
|
private handleRoomMembersChange = debounce((wrapper: HTMLElement) => {
|
58
|
-
const uids = this.
|
62
|
+
const uids = this.getUids(this.roomMembers);
|
59
63
|
const cursors = Object.keys(this.cursors);
|
60
64
|
if (uids?.length) {
|
61
65
|
cursors.map(uid => {
|
@@ -183,7 +187,7 @@ export class CursorManager extends Base {
|
|
183
187
|
}
|
184
188
|
}
|
185
189
|
|
186
|
-
public
|
190
|
+
public deleteCursor(uid: string) {
|
187
191
|
this.store.cleanCursor(uid);
|
188
192
|
const cursor = this.cursorInstances.get(uid);
|
189
193
|
if (cursor) {
|
@@ -199,20 +203,17 @@ export class CursorManager extends Base {
|
|
199
203
|
}
|
200
204
|
|
201
205
|
public cleanMemberAttributes(members: readonly RoomMember[]) {
|
202
|
-
const uids =
|
203
|
-
const needDeleteIds = [];
|
204
|
-
|
205
|
-
|
206
|
+
const uids = this.getUids(members);
|
207
|
+
const needDeleteIds: string[] = [];
|
208
|
+
const cursors = Object.keys(this.cursors);
|
209
|
+
cursors.map(cursorId => {
|
210
|
+
const index = uids.findIndex(id => id === cursorId);
|
206
211
|
if (index === -1) {
|
207
|
-
needDeleteIds.push(
|
212
|
+
needDeleteIds.push(cursorId);
|
208
213
|
}
|
209
|
-
}
|
214
|
+
});
|
210
215
|
needDeleteIds.forEach(uid => {
|
211
|
-
|
212
|
-
if (instance) {
|
213
|
-
instance.destroy();
|
214
|
-
}
|
215
|
-
this.store.cleanCursor(uid);
|
216
|
+
this.deleteCursor(uid);
|
216
217
|
});
|
217
218
|
}
|
218
219
|
|
package/src/index.ts
CHANGED
@@ -170,7 +170,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
170
170
|
public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
|
171
171
|
private static isCreated = false;
|
172
172
|
|
173
|
-
public version = "0.3.
|
173
|
+
public version = "0.3.6-canary.0";
|
174
174
|
|
175
175
|
public appListeners?: AppListeners;
|
176
176
|
|
@@ -384,7 +384,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
384
384
|
if (!isValidScenePath(scenePath)) {
|
385
385
|
throw new InvalidScenePath();
|
386
386
|
}
|
387
|
-
|
387
|
+
const apps = Object.keys(this.apps || {});
|
388
|
+
for (const appId of apps) {
|
388
389
|
const appScenePath = appManager.store.getAppScenePath(appId);
|
389
390
|
if (appScenePath && appScenePath === scenePath) {
|
390
391
|
console.warn(`[WindowManager]: ScenePath ${scenePath} Already opened`);
|
package/src/typings.ts
CHANGED
@@ -59,6 +59,7 @@ export type RegisterEventData = {
|
|
59
59
|
export type RegisterEvents<SetupResult = any> = {
|
60
60
|
created: RegisterEventData & { result: SetupResult; };
|
61
61
|
destroy: RegisterEventData;
|
62
|
+
focus: RegisterEventData;
|
62
63
|
};
|
63
64
|
|
64
65
|
export type RegisterParams<AppOptions = any, SetupResult = any, Attributes = any> = {
|
package/src/viewManager.ts
CHANGED
@@ -104,7 +104,7 @@ export class ViewManager extends Base {
|
|
104
104
|
});
|
105
105
|
if (this.mainView.mode === ViewVisionMode.Writable) {
|
106
106
|
notifyMainViewModeChange(callbacks, ViewVisionMode.Freedom);
|
107
|
-
this.mainView
|
107
|
+
setViewMode(this.mainView, ViewVisionMode.Freedom);
|
108
108
|
}
|
109
109
|
if (!this.mainView.focusScenePath) {
|
110
110
|
this.store.setMainViewFocusPath();
|