@netless/window-manager 0.3.2 → 0.3.3
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/Base/Context.d.ts +3 -1
- package/dist/BoxManager.d.ts +6 -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/example/index.tsx +3 -2
- package/package.json +2 -2
- package/src/AppContext.ts +0 -1
- package/src/AppListener.ts +0 -2
- package/src/AppManager.ts +7 -7
- package/src/Base/Context.ts +9 -2
- package/src/BoxManager.ts +21 -1
- package/src/Cursor/Cursor.ts +1 -1
- package/src/index.ts +3 -3
- package/src/viewManager.ts +3 -22
package/example/index.tsx
CHANGED
@@ -237,6 +237,7 @@ const replay = () => {
|
|
237
237
|
}
|
238
238
|
|
239
239
|
const onRef = (ref) => {
|
240
|
+
const uid = Math.random().toString().substr(3, 8)
|
240
241
|
sdk.joinRoom({
|
241
242
|
uuid: process.env.ROOM_UUID,
|
242
243
|
roomToken: process.env.ROOM_TOKEN,
|
@@ -244,12 +245,12 @@ const onRef = (ref) => {
|
|
244
245
|
useMultiViews: true,
|
245
246
|
userPayload: {
|
246
247
|
userId: "111",
|
247
|
-
cursorName:
|
248
|
+
cursorName: uid,
|
248
249
|
avatar: "https://avatars.githubusercontent.com/u/8299540?s=60&v=4",
|
249
250
|
},
|
250
251
|
isWritable: !(isWritable === "false"),
|
251
252
|
cursorAdapter: undefined,
|
252
|
-
uid:
|
253
|
+
uid: uid,
|
253
254
|
disableMagixEventDispatchLimit: true,
|
254
255
|
}).then(async room => {
|
255
256
|
if (room.isWritable) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@netless/window-manager",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.3",
|
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",
|
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";
|
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
|
|
package/src/AppManager.ts
CHANGED
@@ -81,8 +81,8 @@ export class AppManager {
|
|
81
81
|
return autorun(
|
82
82
|
() => {
|
83
83
|
const maximized = this.attributes.maximized;
|
84
|
-
if (this.boxManager.
|
85
|
-
this.boxManager.
|
84
|
+
if (this.boxManager.maximized !== maximized) {
|
85
|
+
this.boxManager.setMaximized(Boolean(maximized));
|
86
86
|
}
|
87
87
|
}
|
88
88
|
)
|
@@ -91,8 +91,8 @@ export class AppManager {
|
|
91
91
|
return autorun(
|
92
92
|
() => {
|
93
93
|
const minimized = this.attributes.minimized;
|
94
|
-
if (this.boxManager.
|
95
|
-
this.boxManager.
|
94
|
+
if (this.boxManager.minimized !== minimized) {
|
95
|
+
this.boxManager.setMinimized(Boolean(minimized));
|
96
96
|
}
|
97
97
|
}
|
98
98
|
)
|
@@ -174,7 +174,7 @@ export class AppManager {
|
|
174
174
|
this.appStatus.set(appId, AppStatus.StartCreate);
|
175
175
|
this.store.setupAppAttributes(params, appId, isDynamicPPT);
|
176
176
|
if (this.boxManager.boxState === TELE_BOX_STATE.Minimized) {
|
177
|
-
this.boxManager.
|
177
|
+
this.boxManager.setBoxState(TELE_BOX_STATE.Normal);
|
178
178
|
}
|
179
179
|
const needFocus = this.boxManager.boxState !== TELE_BOX_STATE.Minimized;
|
180
180
|
if (needFocus) {
|
@@ -250,9 +250,9 @@ export class AppManager {
|
|
250
250
|
const isManualWritable =
|
251
251
|
this.windowManger.readonly === undefined || this.windowManger.readonly === false;
|
252
252
|
if (this.windowManger.readonly === undefined) {
|
253
|
-
this.boxManager.
|
253
|
+
this.boxManager.setReadonly(isReadonly);
|
254
254
|
} else {
|
255
|
-
this.boxManager.
|
255
|
+
this.boxManager.setReadonly(!(isWritable && isManualWritable));
|
256
256
|
}
|
257
257
|
this.appProxies.forEach(appProxy => {
|
258
258
|
appProxy.emitAppIsWritableChange();
|
package/src/Base/Context.ts
CHANGED
@@ -14,16 +14,23 @@ export class Context {
|
|
14
14
|
};
|
15
15
|
|
16
16
|
public get uid() {
|
17
|
-
return this.
|
17
|
+
return this.findMember(this.observerId)?.payload?.uid || "";
|
18
18
|
}
|
19
19
|
|
20
|
-
|
20
|
+
public findMember = (memberId: number) => {
|
21
21
|
const roomMembers = this.manager.room?.state.roomMembers;
|
22
22
|
return roomMembers?.find(member => member.memberId === memberId);
|
23
23
|
}
|
24
24
|
|
25
|
+
public findMemberByUid = (uid: string) => {
|
26
|
+
const roomMembers = this.manager.room?.state.roomMembers;
|
27
|
+
return roomMembers?.find(member => member.payload?.uid === uid);
|
28
|
+
}
|
29
|
+
|
25
30
|
public memoizeFindMember = memoize(this.findMember);
|
26
31
|
|
32
|
+
public memoizeFindMemberByUid = memoize(this.findMemberByUid);
|
33
|
+
|
27
34
|
public updateManagerRect() {
|
28
35
|
this.manager.boxManager.updateManagerRect();
|
29
36
|
}
|
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 ?? {};
|
@@ -286,6 +294,18 @@ export class BoxManager {
|
|
286
294
|
callbacks.emit("boxStateChange", state);
|
287
295
|
}
|
288
296
|
|
297
|
+
public setMaximized(maximized: boolean) {
|
298
|
+
this.teleBoxManager.setMaximized(maximized, true);
|
299
|
+
}
|
300
|
+
|
301
|
+
public setMinimized(minimized: boolean) {
|
302
|
+
this.teleBoxManager.setMinimized(minimized, true);
|
303
|
+
}
|
304
|
+
|
305
|
+
public setReadonly(readonly: boolean) {
|
306
|
+
this.teleBoxManager.setReadonly(readonly);
|
307
|
+
}
|
308
|
+
|
289
309
|
public destroy() {
|
290
310
|
this.teleBoxManager.destroy();
|
291
311
|
}
|
package/src/Cursor/Cursor.ts
CHANGED
@@ -180,7 +180,7 @@ export class Cursor extends Base {
|
|
180
180
|
}
|
181
181
|
|
182
182
|
public setMember() {
|
183
|
-
this.member = this.context.
|
183
|
+
this.member = this.context.memoizeFindMemberByUid(this.memberId);
|
184
184
|
this.component?.$set(omit(this.initProps(), ["x", "y", "visible"]));
|
185
185
|
}
|
186
186
|
|
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.3";
|
174
174
|
|
175
175
|
public appListeners?: AppListeners;
|
176
176
|
|
@@ -449,7 +449,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
449
449
|
public setReadonly(readonly: boolean): void {
|
450
450
|
if (this.room?.isWritable) {
|
451
451
|
this.readonly = readonly;
|
452
|
-
this.appManager?.boxManager.
|
452
|
+
this.appManager?.boxManager.setReadonly(readonly);
|
453
453
|
}
|
454
454
|
}
|
455
455
|
|
@@ -504,7 +504,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
504
504
|
|
505
505
|
public get boxState(): TeleBoxState {
|
506
506
|
if (this.appManager) {
|
507
|
-
return this.appManager.boxManager.
|
507
|
+
return this.appManager.boxManager.boxState;
|
508
508
|
} else {
|
509
509
|
throw new AppManagerNotInitError();
|
510
510
|
}
|
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();
|
@@ -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();
|