@netless/window-manager 0.3.2 → 0.3.5-canary.1
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 -2
- package/dist/AppManager.d.ts +8 -8
- package/dist/Base/Context.d.ts +2 -2
- package/dist/BoxManager.d.ts +6 -2
- package/dist/Cursor/Cursor.d.ts +1 -0
- package/dist/Cursor/index.d.ts +2 -1
- package/dist/ViewManager.d.ts +0 -2
- 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 -2
- package/src/AppListener.ts +0 -10
- package/src/AppManager.ts +44 -95
- package/src/AppProxy.ts +1 -0
- package/src/Base/Context.ts +6 -4
- package/src/BoxManager.ts +19 -7
- package/src/Cursor/Cursor.ts +8 -4
- package/src/Cursor/index.ts +15 -14
- package/src/index.ts +5 -4
- package/src/typings.ts +1 -0
- package/src/viewManager.ts +4 -23
- package/e2e/cypress/integration/index.spec.ts +0 -105
- package/e2e/cypress/integration/readonly.spec.ts +0 -26
- package/e2e/cypress/plugins/index.js +0 -22
- package/e2e/cypress/support/commands.js +0 -25
- package/e2e/cypress/support/index.js +0 -20
- package/e2e/cypress.json +0 -6
- package/e2e/package.json +0 -15
- package/example/.env +0 -4
- package/example/babel.config.js +0 -15
- package/example/dist/assets/css/chunk-vendors.d2fb6693.chunk.css +0 -1
- package/example/dist/assets/css/index.12f29b9a.chunk.css +0 -1
- package/example/dist/assets/js/chunk-vendors.d2fb6693.chunk.js +0 -2
- package/example/dist/assets/js/chunk-vendors.d2fb6693.chunk.js.LICENSE.txt +0 -136
- package/example/dist/assets/js/index.12f29b9a.chunk.js +0 -1
- package/example/dist/assets/js/runtime~index.d502de40.js +0 -1
- package/example/dist/index.html +0 -1
- package/example/index.html +0 -13
- package/example/index.tsx +0 -367
- package/example/package.json +0 -23
- package/example/poi.config.js +0 -12
- package/example/test.js +0 -114
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.5-canary.1",
|
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.5",
|
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
@@ -8,7 +8,6 @@ import {
|
|
8
8
|
toJS
|
9
9
|
} from 'white-web-sdk';
|
10
10
|
import { BoxNotCreatedError } from './Utils/error';
|
11
|
-
import { setScenePath, wait } from './Utils/Common';
|
12
11
|
import type { Room, SceneDefinition, View } from "white-web-sdk";
|
13
12
|
import type { ReadonlyTeleBox } from "@netless/telebox-insider";
|
14
13
|
import type Emittery from "emittery";
|
@@ -103,7 +102,7 @@ export class AppContext<TAttrs extends Record<string, any>, AppOptions = any> {
|
|
103
102
|
public async setScenePath(scenePath: string): Promise<void> {
|
104
103
|
if (!this.appProxy.box) return;
|
105
104
|
this.appProxy.setFullPath(scenePath);
|
106
|
-
this.
|
105
|
+
this.appProxy.context.switchAppToWriter(this.appId);
|
107
106
|
}
|
108
107
|
|
109
108
|
public mountView(dom: HTMLDivElement): void {
|
package/src/AppListener.ts
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
import { Events, MagixEventName } from "./constants";
|
2
|
-
import { ViewVisionMode } from "white-web-sdk";
|
3
2
|
import type { Event } from "white-web-sdk";
|
4
3
|
import type { AppManager } from "./AppManager";
|
5
4
|
|
6
5
|
export class AppListeners {
|
7
6
|
private displayer = this.manager.displayer;
|
8
7
|
private boxManager = this.manager.boxManager;
|
9
|
-
private appProxies = this.manager.appProxies;
|
10
8
|
|
11
9
|
constructor(private manager: AppManager) {}
|
12
10
|
|
@@ -30,10 +28,6 @@ export class AppListeners {
|
|
30
28
|
this.appResizeHandler(data.payload);
|
31
29
|
break;
|
32
30
|
}
|
33
|
-
case Events.AppBoxStateChange: {
|
34
|
-
this.appBoxStateHandler(data.payload);
|
35
|
-
break;
|
36
|
-
}
|
37
31
|
case Events.SwitchViewsToFreedom: {
|
38
32
|
this.switchViewsToFreedomHandler();
|
39
33
|
break;
|
@@ -53,10 +47,6 @@ export class AppListeners {
|
|
53
47
|
this.manager.room?.refreshViewSize();
|
54
48
|
};
|
55
49
|
|
56
|
-
private appBoxStateHandler = (payload: any) => {
|
57
|
-
this.boxManager.setBoxState(payload.state);
|
58
|
-
};
|
59
|
-
|
60
50
|
private switchViewsToFreedomHandler = () => {
|
61
51
|
this.manager.viewManager.freedomAllViews();
|
62
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, TELE_BOX_STATE } 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,30 @@ export class AppManager {
|
|
78
66
|
});
|
79
67
|
});
|
80
68
|
this.refresher?.add("maximized", () => {
|
81
|
-
return autorun(
|
82
|
-
|
83
|
-
|
84
|
-
if (this.boxManager.
|
85
|
-
this.boxManager.
|
69
|
+
return autorun(() => {
|
70
|
+
const maximized = this.attributes.maximized;
|
71
|
+
if (this.boxManager.maximized !== maximized) {
|
72
|
+
if (maximized === true && this.boxManager.minimized === false) {
|
73
|
+
const topBox = this.boxManager.getTopBox();
|
74
|
+
if (topBox) {
|
75
|
+
emitter.emit("focus", { appId: topBox.id });
|
76
|
+
}
|
86
77
|
}
|
78
|
+
this.boxManager.setMaximized(Boolean(maximized));
|
87
79
|
}
|
88
|
-
)
|
80
|
+
});
|
89
81
|
});
|
90
82
|
this.refresher?.add("minimized", () => {
|
91
|
-
return autorun(
|
92
|
-
|
93
|
-
|
94
|
-
if (this.
|
95
|
-
this.
|
83
|
+
return autorun(() => {
|
84
|
+
const minimized = this.attributes.minimized;
|
85
|
+
if (this.boxManager.minimized !== minimized) {
|
86
|
+
if (minimized === true && this.store.focus !== undefined) {
|
87
|
+
this.store.cleanFocus();
|
88
|
+
this.boxManager.blurFocusBox();
|
96
89
|
}
|
90
|
+
this.boxManager.setMinimized(Boolean(minimized));
|
97
91
|
}
|
98
|
-
)
|
92
|
+
});
|
99
93
|
});
|
100
94
|
if (!this.attributes.apps || Object.keys(this.attributes.apps).length === 0) {
|
101
95
|
const mainScenePath = this.store.getMainViewScenePath();
|
@@ -142,7 +136,7 @@ export class AppManager {
|
|
142
136
|
appProxy.destroy(true, false);
|
143
137
|
}
|
144
138
|
});
|
145
|
-
}
|
139
|
+
};
|
146
140
|
|
147
141
|
public bindMainView(divElement: HTMLDivElement, disableCameraTransform: boolean) {
|
148
142
|
const mainView = this.mainViewProxy.view;
|
@@ -151,10 +145,7 @@ export class AppManager {
|
|
151
145
|
if (!mainView.focusScenePath) {
|
152
146
|
this.store.setMainViewFocusPath();
|
153
147
|
}
|
154
|
-
if (
|
155
|
-
this.store.focus === undefined &&
|
156
|
-
mainView.mode !== ViewVisionMode.Writable
|
157
|
-
) {
|
148
|
+
if (this.store.focus === undefined && mainView.mode !== ViewVisionMode.Writable) {
|
158
149
|
this.viewManager.switchMainViewToWriter();
|
159
150
|
}
|
160
151
|
this.mainViewProxy.addMainViewListener();
|
@@ -172,16 +163,16 @@ export class AppManager {
|
|
172
163
|
private async beforeAddApp(params: AddAppParams, isDynamicPPT: boolean) {
|
173
164
|
const appId = await genAppId(params.kind);
|
174
165
|
this.appStatus.set(appId, AppStatus.StartCreate);
|
166
|
+
const attrs = params.attributes ?? {};
|
167
|
+
this.safeUpdateAttributes([appId], attrs);
|
175
168
|
this.store.setupAppAttributes(params, appId, isDynamicPPT);
|
176
|
-
if (this.boxManager.
|
177
|
-
this.boxManager.
|
169
|
+
if (this.boxManager.minimized) {
|
170
|
+
this.boxManager.setMinimized(false);
|
178
171
|
}
|
179
|
-
const needFocus = this.boxManager.
|
172
|
+
const needFocus = !this.boxManager.minimized;
|
180
173
|
if (needFocus) {
|
181
174
|
this.store.setAppFocus(appId, true);
|
182
175
|
}
|
183
|
-
const attrs = params.attributes ?? {};
|
184
|
-
this.safeUpdateAttributes([appId], attrs);
|
185
176
|
return { appId, needFocus };
|
186
177
|
}
|
187
178
|
|
@@ -243,16 +234,16 @@ export class AppManager {
|
|
243
234
|
appProxy.appEmitter.emit("roomStateChange", state);
|
244
235
|
});
|
245
236
|
emitter.emit("observerIdChange", this.displayer.observerId);
|
246
|
-
}
|
237
|
+
};
|
247
238
|
|
248
239
|
private displayerWritableListener = (isReadonly: boolean) => {
|
249
240
|
const isWritable = !isReadonly;
|
250
241
|
const isManualWritable =
|
251
242
|
this.windowManger.readonly === undefined || this.windowManger.readonly === false;
|
252
243
|
if (this.windowManger.readonly === undefined) {
|
253
|
-
this.boxManager.
|
244
|
+
this.boxManager.setReadonly(isReadonly);
|
254
245
|
} else {
|
255
|
-
this.boxManager.
|
246
|
+
this.boxManager.setReadonly(!(isWritable && isManualWritable));
|
256
247
|
}
|
257
248
|
this.appProxies.forEach(appProxy => {
|
258
249
|
appProxy.emitAppIsWritableChange();
|
@@ -265,7 +256,7 @@ export class AppManager {
|
|
265
256
|
} else {
|
266
257
|
this.mainView.disableCameraTransform = true;
|
267
258
|
}
|
268
|
-
}
|
259
|
+
};
|
269
260
|
|
270
261
|
private get eventName() {
|
271
262
|
return isRoom(this.displayer) ? "onRoomStateChanged" : "onPlayerStateChanged";
|
@@ -359,10 +350,6 @@ export class AppManager {
|
|
359
350
|
this.windowManger.safeSetAttributes({ focus: payload.appId });
|
360
351
|
break;
|
361
352
|
}
|
362
|
-
case "blur": {
|
363
|
-
this.dispatchInternalEvent(Events.AppBlur, payload);
|
364
|
-
break;
|
365
|
-
}
|
366
353
|
case "resize": {
|
367
354
|
if (payload.width && payload.height) {
|
368
355
|
this.dispatchInternalEvent(Events.AppResize, payload);
|
@@ -373,44 +360,6 @@ export class AppManager {
|
|
373
360
|
}
|
374
361
|
break;
|
375
362
|
}
|
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
363
|
case "close": {
|
415
364
|
const appProxy = this.appProxies.get(payload.appId);
|
416
365
|
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,15 +13,18 @@ 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) => {
|
21
20
|
const roomMembers = this.manager.room?.state.roomMembers;
|
22
21
|
return roomMembers?.find(member => member.memberId === memberId);
|
23
22
|
}
|
24
23
|
|
25
|
-
public
|
24
|
+
public findMemberByUid = (uid: string) => {
|
25
|
+
const roomMembers = this.manager.room?.state.roomMembers;
|
26
|
+
return roomMembers?.find(member => member.payload?.uid === uid);
|
27
|
+
}
|
26
28
|
|
27
29
|
public updateManagerRect() {
|
28
30
|
this.manager.boxManager.updateManagerRect();
|
package/src/BoxManager.ts
CHANGED
@@ -102,10 +102,18 @@ export class BoxManager {
|
|
102
102
|
});
|
103
103
|
}
|
104
104
|
|
105
|
-
public get boxState()
|
105
|
+
public get boxState() {
|
106
106
|
return this.teleBoxManager.state;
|
107
107
|
}
|
108
108
|
|
109
|
+
public get maximized() {
|
110
|
+
return this.teleBoxManager.maximized;
|
111
|
+
}
|
112
|
+
|
113
|
+
public get minimized() {
|
114
|
+
return this.teleBoxManager.minimized;
|
115
|
+
}
|
116
|
+
|
109
117
|
public createBox(params: CreateBoxParams): void {
|
110
118
|
if (!this.teleBoxManager) return;
|
111
119
|
let { minwidth = MIN_WIDTH, minheight = MIN_HEIGHT } = params.app.config ?? {};
|
@@ -217,9 +225,6 @@ export class BoxManager {
|
|
217
225
|
this.teleBoxManager.setMaximized(Boolean(state.maximized), true);
|
218
226
|
this.teleBoxManager.setMinimized(Boolean(state.minimized), true);
|
219
227
|
}
|
220
|
-
if (state.boxState) {
|
221
|
-
this.teleBoxManager.setState(state.boxState, true);
|
222
|
-
}
|
223
228
|
setTimeout(() => {
|
224
229
|
if (state.focus) {
|
225
230
|
this.teleBoxManager.update(box.id, { focus: true }, true);
|
@@ -281,9 +286,16 @@ export class BoxManager {
|
|
281
286
|
this.teleBoxManager.updateAll(config);
|
282
287
|
}
|
283
288
|
|
284
|
-
public
|
285
|
-
this.teleBoxManager.
|
286
|
-
|
289
|
+
public setMaximized(maximized: boolean) {
|
290
|
+
this.teleBoxManager.setMaximized(maximized, true);
|
291
|
+
}
|
292
|
+
|
293
|
+
public setMinimized(minimized: boolean) {
|
294
|
+
this.teleBoxManager.setMinimized(minimized, true);
|
295
|
+
}
|
296
|
+
|
297
|
+
public setReadonly(readonly: boolean) {
|
298
|
+
this.teleBoxManager.setReadonly(readonly);
|
287
299
|
}
|
288
300
|
|
289
301
|
public destroy() {
|
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 });
|
@@ -142,7 +142,7 @@ export class Cursor extends Base {
|
|
142
142
|
}
|
143
143
|
this.timer = window.setTimeout(() => {
|
144
144
|
this.hide();
|
145
|
-
this.store.updateCursorState(this.
|
145
|
+
this.store.updateCursorState(this.memberId, CursorState.Leave);
|
146
146
|
}, 1000 * 10); // 10 秒钟自动隐藏
|
147
147
|
}
|
148
148
|
|
@@ -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.5-canary.1";
|
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`);
|
@@ -449,7 +450,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
449
450
|
public setReadonly(readonly: boolean): void {
|
450
451
|
if (this.room?.isWritable) {
|
451
452
|
this.readonly = readonly;
|
452
|
-
this.appManager?.boxManager.
|
453
|
+
this.appManager?.boxManager.setReadonly(readonly);
|
453
454
|
}
|
454
455
|
}
|
455
456
|
|
@@ -504,7 +505,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
504
505
|
|
505
506
|
public get boxState(): TeleBoxState {
|
506
507
|
if (this.appManager) {
|
507
|
-
return this.appManager.boxManager.
|
508
|
+
return this.appManager.boxManager.boxState;
|
508
509
|
} else {
|
509
510
|
throw new AppManagerNotInitError();
|
510
511
|
}
|
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
@@ -5,7 +5,6 @@ import { SET_SCENEPATH_DELAY } from "./constants";
|
|
5
5
|
import {
|
6
6
|
notifyMainViewModeChange,
|
7
7
|
setScenePath,
|
8
|
-
setViewFocusScenePath,
|
9
8
|
setViewMode,
|
10
9
|
} from "./Utils/Common";
|
11
10
|
import type { View } from "white-web-sdk";
|
@@ -96,24 +95,6 @@ export class ViewManager extends Base {
|
|
96
95
|
});
|
97
96
|
}
|
98
97
|
|
99
|
-
public refreshViews(): void {
|
100
|
-
const focus = this.store.focus;
|
101
|
-
this.setMainViewFocusScenePath();
|
102
|
-
if (focus) {
|
103
|
-
const appProxy = this.manager.appProxies.get(focus);
|
104
|
-
appProxy?.switchToWritable();
|
105
|
-
} else {
|
106
|
-
this.switchMainViewToWriter();
|
107
|
-
}
|
108
|
-
}
|
109
|
-
|
110
|
-
public setMainViewFocusScenePath() {
|
111
|
-
const mainViewScenePath = this.store.getMainViewScenePath();
|
112
|
-
if (mainViewScenePath) {
|
113
|
-
setViewFocusScenePath(this.manager.mainView, mainViewScenePath);
|
114
|
-
}
|
115
|
-
}
|
116
|
-
|
117
98
|
public freedomAllViews(): void {
|
118
99
|
this.manager.appProxies.forEach(appProxy => {
|
119
100
|
appProxy.setViewFocusScenePath();
|
@@ -123,7 +104,7 @@ export class ViewManager extends Base {
|
|
123
104
|
});
|
124
105
|
if (this.mainView.mode === ViewVisionMode.Writable) {
|
125
106
|
notifyMainViewModeChange(callbacks, ViewVisionMode.Freedom);
|
126
|
-
this.mainView
|
107
|
+
setViewMode(this.mainView, ViewVisionMode.Freedom);
|
127
108
|
}
|
128
109
|
if (!this.mainView.focusScenePath) {
|
129
110
|
this.store.setMainViewFocusPath();
|
@@ -131,15 +112,15 @@ export class ViewManager extends Base {
|
|
131
112
|
}
|
132
113
|
|
133
114
|
public switchAppToWriter(id: string): void {
|
134
|
-
this.freedomAllViews();
|
135
|
-
// 为了同步端不闪烁, 需要给 room setScenePath 一个延迟
|
136
115
|
if (this.appTimer) {
|
137
116
|
clearTimeout(this.appTimer);
|
138
117
|
}
|
118
|
+
this.freedomAllViews();
|
119
|
+
// 为了同步端不闪烁, 需要给 room setScenePath 一个延迟
|
139
120
|
this.appTimer = setTimeout(() => {
|
140
121
|
const appProxy = this.manager.appProxies.get(id);
|
141
122
|
if (appProxy) {
|
142
|
-
if (this.manager.boxManager.
|
123
|
+
if (this.manager.boxManager.minimized) return;
|
143
124
|
appProxy.setScenePath();
|
144
125
|
appProxy.switchToWritable();
|
145
126
|
appProxy.focusBox();
|