@netless/window-manager 0.3.0-canary.0 → 0.3.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/AttributesDelegate.d.ts +1 -0
- package/dist/BoxManager.d.ts +1 -0
- package/dist/Cursor/index.d.ts +0 -1
- package/dist/index.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/example/.env +4 -0
- package/example/babel.config.js +15 -0
- package/example/dist/assets/css/chunk-vendors.d2fb6693.chunk.css +1 -0
- package/example/dist/assets/css/index.12f29b9a.chunk.css +1 -0
- package/example/dist/assets/js/chunk-vendors.d2fb6693.chunk.js +2 -0
- package/example/dist/assets/js/chunk-vendors.d2fb6693.chunk.js.LICENSE.txt +136 -0
- package/example/dist/assets/js/index.12f29b9a.chunk.js +1 -0
- package/example/dist/assets/js/runtime~index.d502de40.js +1 -0
- package/example/dist/index.html +1 -0
- package/example/index.html +13 -0
- package/example/index.tsx +367 -0
- package/example/package.json +23 -0
- package/example/poi.config.js +12 -0
- package/example/test.js +114 -0
- package/package.json +2 -2
- package/src/AppListener.ts +0 -1
- package/src/AppManager.ts +18 -0
- package/src/AppProxy.ts +1 -1
- package/src/AttributesDelegate.ts +4 -0
- package/src/Base/Context.ts +0 -1
- package/src/BoxManager.ts +12 -4
- package/src/Cursor/Cursor.ts +1 -0
- package/src/Cursor/index.ts +15 -11
- package/src/Utils/Common.ts +4 -4
- package/src/index.ts +5 -4
- package/e2e/cypress/screenshots/reconnect.spec.ts//351/207/215/350/277/236 -- /346/226/255/347/275/221/351/207/215/350/277/236 (failed).png +0 -0
package/src/Cursor/index.ts
CHANGED
@@ -22,7 +22,6 @@ export type MoveCursorParams = {
|
|
22
22
|
export class CursorManager extends Base {
|
23
23
|
public containerRect?: DOMRect;
|
24
24
|
public wrapperRect?: DOMRect;
|
25
|
-
private disposer: any;
|
26
25
|
public cursorInstances: Map<string, Cursor> = new Map();
|
27
26
|
public roomMembers?: readonly RoomMember[];
|
28
27
|
private mainViewElement?: HTMLDivElement;
|
@@ -48,20 +47,25 @@ export class CursorManager extends Base {
|
|
48
47
|
}
|
49
48
|
|
50
49
|
private startReaction(wrapper: HTMLElement) {
|
51
|
-
this.
|
52
|
-
this.
|
53
|
-
|
50
|
+
this.manager.refresher?.add("cursors", () => {
|
51
|
+
return onObjectInserted(this.cursors, () => {
|
52
|
+
this.handleRoomMembersChange(wrapper);
|
53
|
+
});
|
54
|
+
})
|
54
55
|
}
|
55
56
|
|
56
|
-
private handleRoomMembersChange(wrapper: HTMLElement) {
|
57
|
+
private handleRoomMembersChange = debounce((wrapper: HTMLElement) => {
|
57
58
|
const uids = this.roomMembers?.map(member => member.payload?.uid);
|
59
|
+
const cursors = Object.keys(this.cursors);
|
58
60
|
if (uids?.length) {
|
59
|
-
|
61
|
+
cursors.map(uid => {
|
60
62
|
if (
|
61
63
|
uids.includes(uid) &&
|
62
|
-
!this.cursorInstances.has(uid)
|
63
|
-
uid !== this.context.uid
|
64
|
+
!this.cursorInstances.has(uid)
|
64
65
|
) {
|
66
|
+
if (uid === this.context.uid) {
|
67
|
+
return;
|
68
|
+
}
|
65
69
|
const component = new Cursor(
|
66
70
|
this.appManager,
|
67
71
|
this.cursors,
|
@@ -71,9 +75,9 @@ export class CursorManager extends Base {
|
|
71
75
|
);
|
72
76
|
this.cursorInstances.set(uid, component);
|
73
77
|
}
|
74
|
-
}
|
78
|
+
})
|
75
79
|
}
|
76
|
-
}
|
80
|
+
}, 100);
|
77
81
|
|
78
82
|
public get cursors() {
|
79
83
|
return this.manager.attributes?.[Fields.Cursors];
|
@@ -221,10 +225,10 @@ export class CursorManager extends Base {
|
|
221
225
|
wrapper.removeEventListener("mouseleave", this.mouseLeaveListener);
|
222
226
|
wrapper.removeEventListener("touchend", this.mouseLeaveListener);
|
223
227
|
}
|
224
|
-
this.disposer && this.disposer();
|
225
228
|
if (this.cursorInstances.size) {
|
226
229
|
this.cursorInstances.forEach(cursor => cursor.destroy());
|
227
230
|
this.cursorInstances.clear();
|
228
231
|
}
|
232
|
+
this.manager.refresher?.remove("cursors");
|
229
233
|
}
|
230
234
|
}
|
package/src/Utils/Common.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
import {
|
1
|
+
import { appRegister } from '../Register';
|
2
|
+
import { debounce } from 'lodash';
|
3
|
+
import { emitter } from '../index';
|
4
|
+
import { v4 } from 'uuid';
|
2
5
|
import type { PublicEvent } from "../index";
|
3
|
-
import { v4 } from "uuid";
|
4
6
|
import type { Displayer, ViewVisionMode, Room, View } from "white-web-sdk";
|
5
|
-
import { debounce } from "lodash";
|
6
7
|
import type Emittery from "emittery";
|
7
|
-
import { appRegister } from "../Register";
|
8
8
|
|
9
9
|
export const genAppId = async (kind: string) => {
|
10
10
|
const impl = await appRegister.appClasses.get(kind)?.();
|
package/src/index.ts
CHANGED
@@ -20,9 +20,9 @@ import { log } from './Utils/log';
|
|
20
20
|
import { replaceRoomFunction } from './Utils/RoomHacker';
|
21
21
|
import { ResizeObserver as ResizeObserverPolyfill } from '@juggle/resize-observer';
|
22
22
|
import { setupWrapper } from './ViewManager';
|
23
|
-
import { TELE_BOX_STATE } from './BoxManager';
|
24
23
|
import './style.css';
|
25
24
|
import '@netless/telebox-insider/dist/style.css';
|
25
|
+
import type { TELE_BOX_STATE } from './BoxManager';
|
26
26
|
import {
|
27
27
|
AppCreateError,
|
28
28
|
AppManagerNotInitError,
|
@@ -45,7 +45,6 @@ import type {
|
|
45
45
|
Room,
|
46
46
|
InvisiblePluginContext,
|
47
47
|
Camera,
|
48
|
-
|
49
48
|
AnimationMode,
|
50
49
|
CameraBound,
|
51
50
|
Point,
|
@@ -61,6 +60,8 @@ const ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill;
|
|
61
60
|
export type WindowMangerAttributes = {
|
62
61
|
modelValue?: string;
|
63
62
|
boxState: TELE_BOX_STATE;
|
63
|
+
maximized?: boolean;
|
64
|
+
minimized?: boolean;
|
64
65
|
[key: string]: any;
|
65
66
|
};
|
66
67
|
|
@@ -169,7 +170,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
169
170
|
public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
|
170
171
|
private static isCreated = false;
|
171
172
|
|
172
|
-
public version = "0.3.0
|
173
|
+
public version = "0.3.0";
|
173
174
|
|
174
175
|
public appListeners?: AppListeners;
|
175
176
|
|
@@ -503,7 +504,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
503
504
|
|
504
505
|
public get boxState(): TeleBoxState {
|
505
506
|
if (this.appManager) {
|
506
|
-
return this.appManager.
|
507
|
+
return this.appManager.boxManager.teleBoxManager.state;
|
507
508
|
} else {
|
508
509
|
throw new AppManagerNotInitError();
|
509
510
|
}
|