@netless/window-manager 1.0.0-canary.6 → 1.0.0-canary.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/App/AppContext.d.ts +2 -1
- package/dist/App/AppProxy.d.ts +8 -3
- package/dist/App/WhiteboardView.d.ts +4 -3
- package/dist/AppManager.d.ts +2 -2
- package/dist/BoxManager.d.ts +1 -2
- package/dist/Page/PageController.d.ts +1 -0
- package/dist/View/CameraSynchronizer.d.ts +3 -4
- package/dist/View/MainView.d.ts +0 -1
- package/dist/index.cjs.js +10 -10
- package/dist/index.d.ts +3 -2
- package/dist/index.es.js +147 -161
- package/dist/index.umd.js +10 -10
- package/package.json +2 -2
- package/pnpm-lock.yaml +4 -4
- package/src/App/AppContext.ts +13 -12
- package/src/App/AppProxy.ts +94 -72
- package/src/App/AppViewSync.ts +2 -2
- package/src/App/WhiteboardView.ts +4 -6
- package/src/AppManager.ts +16 -18
- package/src/BoxManager.ts +2 -6
- package/src/Page/PageController.ts +1 -0
- package/src/View/CameraSynchronizer.ts +3 -20
- package/src/View/MainView.ts +15 -28
- package/src/index.ts +15 -2
- package/dist/View/ViewSync.d.ts +0 -7
- package/src/View/ViewSync.ts +0 -10
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@netless/window-manager",
|
3
|
-
"version": "1.0.0-canary.
|
3
|
+
"version": "1.0.0-canary.9",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/index.cjs.js",
|
6
6
|
"module": "dist/index.es.js",
|
@@ -23,7 +23,7 @@
|
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
25
|
"@juggle/resize-observer": "^3.3.1",
|
26
|
-
"@netless/telebox-insider": "1.0.0-alpha.
|
26
|
+
"@netless/telebox-insider": "1.0.0-alpha.14",
|
27
27
|
"emittery": "^0.9.2",
|
28
28
|
"lodash": "^4.17.21",
|
29
29
|
"p-retry": "^4.6.1",
|
package/pnpm-lock.yaml
CHANGED
@@ -4,7 +4,7 @@ specifiers:
|
|
4
4
|
'@juggle/resize-observer': ^3.3.1
|
5
5
|
'@netless/app-docs-viewer': ^0.2.9
|
6
6
|
'@netless/app-media-player': 0.1.0-beta.5
|
7
|
-
'@netless/telebox-insider': 1.0.0-alpha.
|
7
|
+
'@netless/telebox-insider': 1.0.0-alpha.14
|
8
8
|
'@rollup/plugin-commonjs': ^20.0.0
|
9
9
|
'@rollup/plugin-node-resolve': ^13.0.4
|
10
10
|
'@rollup/plugin-url': ^6.1.0
|
@@ -43,7 +43,7 @@ specifiers:
|
|
43
43
|
|
44
44
|
dependencies:
|
45
45
|
'@juggle/resize-observer': registry.npmmirror.com/@juggle/resize-observer/3.3.1
|
46
|
-
'@netless/telebox-insider': 1.0.0-alpha.
|
46
|
+
'@netless/telebox-insider': 1.0.0-alpha.14
|
47
47
|
emittery: registry.npmmirror.com/emittery/0.9.2
|
48
48
|
lodash: registry.npmmirror.com/lodash/4.17.21
|
49
49
|
p-retry: registry.npmmirror.com/p-retry/4.6.1
|
@@ -97,8 +97,8 @@ packages:
|
|
97
97
|
vanilla-lazyload: 17.6.1
|
98
98
|
dev: true
|
99
99
|
|
100
|
-
/@netless/telebox-insider/1.0.0-alpha.
|
101
|
-
resolution: {integrity: sha512-
|
100
|
+
/@netless/telebox-insider/1.0.0-alpha.14:
|
101
|
+
resolution: {integrity: sha512-kDhoxnEZUOCjQDf/lDgHVBb/TaKywlnUXhSlSbyVDWefcVXcaXi6/zEPwDR0gMYWCqQQoEPFz9Jr8hd8hcEkyQ==}
|
102
102
|
dependencies:
|
103
103
|
'@juggle/resize-observer': 3.3.1
|
104
104
|
'@types/shallowequal': 1.1.1
|
package/src/App/AppContext.ts
CHANGED
@@ -29,7 +29,6 @@ import type {
|
|
29
29
|
import { WhiteBoardView } from "./WhiteboardView";
|
30
30
|
import { findMemberByUid } from "../Helper";
|
31
31
|
import { MAX_PAGE_SIZE } from "../constants";
|
32
|
-
import { putScenes } from "../Utils/Common";
|
33
32
|
import { isNumber } from "lodash";
|
34
33
|
|
35
34
|
export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOptions = any> {
|
@@ -63,9 +62,13 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
|
|
63
62
|
this.isAddApp = appProxy.isAddApp;
|
64
63
|
}
|
65
64
|
|
66
|
-
public get displayer(){
|
65
|
+
public get displayer() {
|
67
66
|
return this.manager.displayer;
|
68
|
-
}
|
67
|
+
}
|
68
|
+
|
69
|
+
public get destroyed() {
|
70
|
+
return this.appProxy.status === "destroyed";
|
71
|
+
}
|
69
72
|
|
70
73
|
/** @deprecated Use context.storage.state instead. */
|
71
74
|
public getAttributes = (): TAttributes | undefined => {
|
@@ -102,14 +105,15 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
|
|
102
105
|
this._viewWrapper = undefined;
|
103
106
|
}
|
104
107
|
view.divElement = viewWrapper;
|
108
|
+
this.appProxy.fireMemberStateChange();
|
105
109
|
if (this.isAddApp) {
|
106
|
-
this.
|
110
|
+
this.ensurePageSize(size);
|
107
111
|
}
|
108
|
-
this.whiteBoardView = new WhiteBoardView(this, this.appProxy, removeViewWrapper);
|
112
|
+
this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy, removeViewWrapper, this.ensurePageSize);
|
109
113
|
return this.whiteBoardView;
|
110
114
|
}
|
111
115
|
|
112
|
-
private
|
116
|
+
private ensurePageSize = (size?: number) => {
|
113
117
|
if (!isNumber(size)) return;
|
114
118
|
if (!this.appProxy.scenePath) return;
|
115
119
|
if (this.appProxy.pageState.length >= size) return;
|
@@ -117,11 +121,8 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
|
|
117
121
|
throw Error(`[WindowManager]: size ${size} muse be in range [1, ${MAX_PAGE_SIZE}]`);
|
118
122
|
}
|
119
123
|
const needInsert = size - this.appProxy.pageState.length;
|
120
|
-
const
|
121
|
-
|
122
|
-
return { name: `${startPageNumber + index + 1}` };
|
123
|
-
});
|
124
|
-
putScenes(this.room, this.appProxy.scenePath, scenes);
|
124
|
+
const scenes = new Array(needInsert).fill({});
|
125
|
+
this.room?.putScenes(this.appProxy.scenePath, scenes);
|
125
126
|
}
|
126
127
|
|
127
128
|
public getInitScenePath = () => {
|
@@ -130,7 +131,7 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
|
|
130
131
|
|
131
132
|
/** Get App writable status. */
|
132
133
|
public get isWritable(): boolean {
|
133
|
-
return this.manager.canOperate;
|
134
|
+
return this.manager.canOperate && !this.destroyed;
|
134
135
|
};
|
135
136
|
|
136
137
|
/** Get the App Window UI box. */
|
package/src/App/AppProxy.ts
CHANGED
@@ -8,7 +8,7 @@ import { autorun, reaction, toJS } from "white-web-sdk";
|
|
8
8
|
import { boxEmitter } from "../BoxEmitter";
|
9
9
|
import { BoxManagerNotFoundError } from "../Utils/error";
|
10
10
|
import { calculateNextIndex } from "../Page";
|
11
|
-
import { combine, Val } from "value-enhancer";
|
11
|
+
import { combine, Val, ValManager } from "value-enhancer";
|
12
12
|
import { debounce, get } from "lodash";
|
13
13
|
import { emitter } from "../InternalEmitter";
|
14
14
|
import { Fields } from "../AttributesDelegate";
|
@@ -30,7 +30,7 @@ import type {
|
|
30
30
|
setAppOptions,
|
31
31
|
AppListenerKeys,
|
32
32
|
} from "../index";
|
33
|
-
import type { SceneState, View, SceneDefinition, Camera } from "white-web-sdk";
|
33
|
+
import type { SceneState, View, SceneDefinition, Camera , MemberState} from "white-web-sdk";
|
34
34
|
import type { AppManager } from "../AppManager";
|
35
35
|
import type { NetlessApp } from "../typings";
|
36
36
|
import type { ReadonlyTeleBox } from "@netless/telebox-insider";
|
@@ -54,23 +54,23 @@ export class AppProxy implements PageRemoveService {
|
|
54
54
|
public uid = this.manager.uid;
|
55
55
|
|
56
56
|
public isAddApp: boolean;
|
57
|
-
|
57
|
+
public status: "normal" | "destroyed" = "normal";
|
58
58
|
private stateKey: string;
|
59
59
|
public _pageState: AppPageStateImpl;
|
60
|
-
private _prevFullPath: string | undefined;
|
61
60
|
|
62
61
|
public appResult?: NetlessApp<any>;
|
63
62
|
public appContext?: AppContext<any, any>;
|
64
63
|
|
65
64
|
private sideEffectManager = new SideEffectManager();
|
65
|
+
private valManager = new ValManager();
|
66
66
|
|
67
|
-
|
68
|
-
public size$ = new Val<ISize | undefined>(undefined);
|
69
|
-
|
67
|
+
private fullPath$ = this.valManager.attach(new Val<string | undefined>(undefined));
|
70
68
|
private appViewSync?: AppViewSync;
|
71
69
|
|
72
|
-
public
|
73
|
-
public
|
70
|
+
public camera$ = this.valManager.attach(new Val<ICamera | undefined>(undefined));
|
71
|
+
public size$ = this.valManager.attach(new Val<ISize | undefined>(undefined));
|
72
|
+
public box$ = this.valManager.attach(new Val<ReadonlyTeleBox | undefined>(undefined));
|
73
|
+
public view$ = this.valManager.attach(new Val<View | undefined>(undefined));
|
74
74
|
|
75
75
|
constructor(
|
76
76
|
private params: BaseInsertParams,
|
@@ -110,61 +110,56 @@ export class AppProxy implements PageRemoveService {
|
|
110
110
|
);
|
111
111
|
this.camera$.setValue(toJS(this.appAttributes.camera));
|
112
112
|
this.size$.setValue(toJS(this.appAttributes.size));
|
113
|
-
this.
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
113
|
+
this.addCameraReaction();
|
114
|
+
this.addSizeReaction();
|
115
|
+
this.sideEffectManager.add(() =>
|
116
|
+
combine([this.box$, this.view$]).subscribe(([box, view]) => {
|
117
|
+
if (box && view) {
|
118
|
+
if (!this.camera$.value) {
|
119
|
+
this.storeCamera({
|
120
|
+
centerX: 0,
|
121
|
+
centerY: 0,
|
122
|
+
scale: 1,
|
123
|
+
id: this.uid,
|
124
|
+
});
|
125
|
+
this.camera$.setValue(toJS(this.appAttributes.camera));
|
121
126
|
}
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
size => {
|
130
|
-
if (size && size.id !== this.uid) {
|
131
|
-
this.size$.setValue(toJS(size));
|
132
|
-
}
|
127
|
+
if (!this.size$.value && box.contentStageRect) {
|
128
|
+
this.storeSize({
|
129
|
+
id: this.uid,
|
130
|
+
width: box.contentStageRect?.width,
|
131
|
+
height: box.contentStageRect?.height,
|
132
|
+
});
|
133
|
+
this.size$.setValue(toJS(this.appAttributes.size));
|
133
134
|
}
|
134
|
-
|
135
|
-
|
136
|
-
});
|
137
|
-
combine([this.box$, this.view$]).subscribe(([box, view]) => {
|
138
|
-
if (box && view) {
|
139
|
-
if (!this.camera$.value) {
|
140
|
-
this.storeCamera({
|
141
|
-
centerX: 0, centerY: 0, scale: 1, id: this.uid,
|
142
|
-
});
|
135
|
+
this.appViewSync = new AppViewSync(this);
|
136
|
+
this.sideEffectManager.add(() => () => this.appViewSync?.destroy());
|
143
137
|
}
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
138
|
+
})
|
139
|
+
);
|
140
|
+
this.sideEffectManager.add(() =>
|
141
|
+
emitter.on("memberStateChange", this.onMemberStateChange)
|
142
|
+
);
|
143
|
+
}
|
144
|
+
|
145
|
+
public fireMemberStateChange = () => {
|
146
|
+
if (this.manager.room) {
|
147
|
+
this.onMemberStateChange(this.manager.room.state.memberState);
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
private onMemberStateChange = (memberState: MemberState) => {
|
152
|
+
// clicker 教具把事件穿透给下层
|
153
|
+
const needPointerEventsNone = memberState.currentApplianceName === "clicker";
|
154
|
+
if (needPointerEventsNone) {
|
155
|
+
if (this.appContext?._viewWrapper) {
|
156
|
+
this.appContext._viewWrapper.style.pointerEvents = "none";
|
153
157
|
}
|
154
|
-
}
|
155
|
-
|
156
|
-
|
157
|
-
const needPointerEventsNone = memberState.currentApplianceName === "clicker";
|
158
|
-
if (needPointerEventsNone) {
|
159
|
-
if (this.appContext?._viewWrapper) {
|
160
|
-
this.appContext._viewWrapper.style.pointerEvents = "none";
|
161
|
-
}
|
162
|
-
} else {
|
163
|
-
if (this.appContext?._viewWrapper) {
|
164
|
-
this.appContext._viewWrapper.style.pointerEvents = "auto";
|
165
|
-
}
|
158
|
+
} else {
|
159
|
+
if (this.appContext?._viewWrapper) {
|
160
|
+
this.appContext._viewWrapper.style.pointerEvents = "auto";
|
166
161
|
}
|
167
|
-
}
|
162
|
+
}
|
168
163
|
}
|
169
164
|
|
170
165
|
public createAppDir() {
|
@@ -194,7 +189,7 @@ export class AppProxy implements PageRemoveService {
|
|
194
189
|
}
|
195
190
|
|
196
191
|
public get view(): View | undefined {
|
197
|
-
return this.
|
192
|
+
return this.view$.value;
|
198
193
|
}
|
199
194
|
|
200
195
|
public get viewIndex(): number | undefined {
|
@@ -444,7 +439,7 @@ export class AppProxy implements PageRemoveService {
|
|
444
439
|
}
|
445
440
|
|
446
441
|
private appAttributesUpdateListener = (appId: string) => {
|
447
|
-
this.manager.refresher
|
442
|
+
this.manager.refresher.add(appId, () => {
|
448
443
|
return autorun(() => {
|
449
444
|
const attrs = this.manager.attributes[appId];
|
450
445
|
if (attrs) {
|
@@ -452,7 +447,7 @@ export class AppProxy implements PageRemoveService {
|
|
452
447
|
}
|
453
448
|
});
|
454
449
|
});
|
455
|
-
this.manager.refresher
|
450
|
+
this.manager.refresher.add(this.stateKey, () => {
|
456
451
|
return autorun(() => {
|
457
452
|
const appState = this.appAttributes?.state;
|
458
453
|
if (appState?.zIndex > 0 && appState.zIndex !== this.box?.zIndex) {
|
@@ -460,13 +455,13 @@ export class AppProxy implements PageRemoveService {
|
|
460
455
|
}
|
461
456
|
});
|
462
457
|
});
|
463
|
-
this.manager.refresher
|
458
|
+
this.manager.refresher.add(`${appId}-fullPath`, () => {
|
464
459
|
return autorun(() => {
|
465
460
|
const fullPath = this.appAttributes?.fullPath;
|
466
461
|
this.setFocusScenePathHandler(fullPath);
|
467
|
-
if (this.
|
462
|
+
if (this.fullPath$.value !== fullPath) {
|
468
463
|
this.notifyPageStateChange();
|
469
|
-
this.
|
464
|
+
this.fullPath$.setValue(fullPath);
|
470
465
|
}
|
471
466
|
});
|
472
467
|
});
|
@@ -596,13 +591,40 @@ export class AppProxy implements PageRemoveService {
|
|
596
591
|
|
597
592
|
this.viewManager.destroyView(this.id);
|
598
593
|
this.manager.appStatus.delete(this.id);
|
599
|
-
this.manager.refresher
|
600
|
-
this.manager.refresher
|
601
|
-
this.manager.refresher
|
602
|
-
this.
|
603
|
-
|
604
|
-
|
605
|
-
|
594
|
+
this.manager.refresher.remove(this.id);
|
595
|
+
this.manager.refresher.remove(this.stateKey);
|
596
|
+
this.manager.refresher.remove(`${this.id}-fullPath`);
|
597
|
+
this.valManager.destroy();
|
598
|
+
}
|
599
|
+
|
600
|
+
private addCameraReaction = () => {
|
601
|
+
this.sideEffectManager.add(() =>
|
602
|
+
this.manager.refresher.add(`${this.id}-camera`, () =>
|
603
|
+
reaction(
|
604
|
+
() => this.appAttributes?.camera,
|
605
|
+
camera => {
|
606
|
+
if (camera && camera.id !== this.uid) {
|
607
|
+
this.camera$.setValue(toJS(camera));
|
608
|
+
}
|
609
|
+
}
|
610
|
+
)
|
611
|
+
)
|
612
|
+
, "camera");
|
613
|
+
}
|
614
|
+
|
615
|
+
private addSizeReaction = () => {
|
616
|
+
this.sideEffectManager.add(() =>
|
617
|
+
this.manager.refresher.add(`${this.id}-size`, () =>
|
618
|
+
reaction(
|
619
|
+
() => this.appAttributes?.size,
|
620
|
+
size => {
|
621
|
+
if (size && size.id !== this.uid) {
|
622
|
+
this.size$.setValue(toJS(size));
|
623
|
+
}
|
624
|
+
}
|
625
|
+
)
|
626
|
+
)
|
627
|
+
, "size");
|
606
628
|
}
|
607
629
|
|
608
630
|
public close(): Promise<void> {
|
package/src/App/AppViewSync.ts
CHANGED
@@ -34,11 +34,11 @@ export class AppViewSync {
|
|
34
34
|
}),
|
35
35
|
);
|
36
36
|
}
|
37
|
-
combine([this.appProxy.camera$, this.appProxy.size$]).subscribe(([camera, size]) => {
|
37
|
+
this.sem.add(() => combine([this.appProxy.camera$, this.appProxy.size$]).subscribe(([camera, size]) => {
|
38
38
|
if (camera && size) {
|
39
39
|
this.synchronizer.onRemoteUpdate(camera, size);
|
40
40
|
}
|
41
|
-
});
|
41
|
+
}));
|
42
42
|
}
|
43
43
|
|
44
44
|
public bindView = (view?: View) => {
|
@@ -5,15 +5,17 @@ import type { ReadonlyVal } from "value-enhancer";
|
|
5
5
|
import type { AddPageParams, PageController, PageState } from "../Page";
|
6
6
|
import type { AppProxy } from "./AppProxy";
|
7
7
|
import type { AppContext } from "./AppContext";
|
8
|
-
import type { Camera } from "white-web-sdk";
|
8
|
+
import type { Camera, View } from "white-web-sdk";
|
9
9
|
|
10
10
|
export class WhiteBoardView implements PageController {
|
11
11
|
public readonly pageState$: ReadonlyVal<PageState>;
|
12
12
|
|
13
13
|
constructor(
|
14
|
+
public view: View,
|
14
15
|
protected appContext: AppContext,
|
15
16
|
protected appProxy: AppProxy,
|
16
|
-
private removeViewWrapper: () => void
|
17
|
+
private removeViewWrapper: () => void,
|
18
|
+
public ensureSize: (size: number) => void
|
17
19
|
) {
|
18
20
|
const pageState$ = new Val<PageState>(appProxy.pageState);
|
19
21
|
this.pageState$ = pageState$;
|
@@ -22,10 +24,6 @@ export class WhiteBoardView implements PageController {
|
|
22
24
|
});
|
23
25
|
}
|
24
26
|
|
25
|
-
public get view() {
|
26
|
-
return this.appContext.view;
|
27
|
-
}
|
28
|
-
|
29
27
|
public get pageState() {
|
30
28
|
return this.pageState$.value;
|
31
29
|
}
|
package/src/AppManager.ts
CHANGED
@@ -18,6 +18,7 @@ import { RedoUndo } from "./RedoUndo";
|
|
18
18
|
import { serializeRoomMembers } from "./Helper";
|
19
19
|
import { SideEffectManager } from "side-effect-manager";
|
20
20
|
import { ViewManager } from "./View/ViewManager";
|
21
|
+
import { Val } from "value-enhancer";
|
21
22
|
import type { SyncRegisterAppPayload } from "./Register";
|
22
23
|
import type { RemoveSceneParams } from "./InternalEmitter";
|
23
24
|
import {
|
@@ -63,10 +64,10 @@ export class AppManager {
|
|
63
64
|
private appListeners: AppListeners;
|
64
65
|
public boxManager?: BoxManager;
|
65
66
|
|
66
|
-
private _prevSceneIndex: number | undefined;
|
67
|
-
private _prevFocused: string | undefined;
|
68
67
|
private callbacksNode: ScenesCallbacksNode | null = null;
|
69
68
|
private appCreateQueue = new AppCreateQueue();
|
69
|
+
private sceneIndex$ = new Val<number | undefined>(undefined);
|
70
|
+
private focused$ = new Val<string | undefined>(undefined);
|
70
71
|
|
71
72
|
private sideEffectManager = new SideEffectManager();
|
72
73
|
|
@@ -324,31 +325,31 @@ export class AppManager {
|
|
324
325
|
|
325
326
|
this.addAppsChangeListener();
|
326
327
|
this.addAppCloseListener();
|
327
|
-
this.refresher
|
328
|
+
this.refresher.add("maximized", () => {
|
328
329
|
return autorun(() => {
|
329
330
|
const maximized = this.attributes.maximized;
|
330
331
|
this.boxManager?.setMaximized(Boolean(maximized));
|
331
332
|
});
|
332
333
|
});
|
333
|
-
this.refresher
|
334
|
+
this.refresher.add("minimized", () => {
|
334
335
|
return autorun(() => {
|
335
336
|
const minimized = this.attributes.minimized;
|
336
337
|
this.onMinimized(minimized);
|
337
338
|
});
|
338
339
|
});
|
339
|
-
this.refresher
|
340
|
+
this.refresher.add("mainViewIndex", () => {
|
340
341
|
return autorun(() => {
|
341
342
|
const mainSceneIndex = get(this.attributes, "_mainSceneIndex");
|
342
343
|
this.onMainViewIndexChange(mainSceneIndex);
|
343
344
|
});
|
344
345
|
});
|
345
|
-
this.refresher
|
346
|
+
this.refresher.add("focusedChange", () => {
|
346
347
|
return autorun(() => {
|
347
348
|
const focused = get(this.attributes, "focus");
|
348
349
|
this.onFocusChange(focused);
|
349
350
|
});
|
350
351
|
});
|
351
|
-
this.refresher
|
352
|
+
this.refresher.add("registeredChange", () => {
|
352
353
|
return autorun(() => {
|
353
354
|
const registered = get(this.attributes, Fields.Registered);
|
354
355
|
this.onRegisteredChange(registered);
|
@@ -361,7 +362,7 @@ export class AppManager {
|
|
361
362
|
}
|
362
363
|
this.displayerWritableListener(!this.room?.isWritable);
|
363
364
|
this.displayer.callbacks.on("onEnableWriteNowChanged", this.displayerWritableListener);
|
364
|
-
this.
|
365
|
+
this.focused$.setValue(this.attributes.focus);
|
365
366
|
|
366
367
|
this.sideEffectManager.add(() => {
|
367
368
|
const redoUndo = new RedoUndo({
|
@@ -426,21 +427,21 @@ export class AppManager {
|
|
426
427
|
};
|
427
428
|
|
428
429
|
private onMainViewIndexChange = (index: number) => {
|
429
|
-
if (index !== undefined && this.
|
430
|
+
if (index !== undefined && this.sceneIndex$.value !== index) {
|
430
431
|
callbacks.emit("mainViewSceneIndexChange", index);
|
431
432
|
emitter.emit("changePageState");
|
432
433
|
if (this.callbacksNode) {
|
433
434
|
this.updateSceneState(this.callbacksNode);
|
434
435
|
}
|
435
|
-
this.
|
436
|
+
this.sceneIndex$.setValue(index);
|
436
437
|
}
|
437
438
|
};
|
438
439
|
|
439
440
|
private onFocusChange = (focused: string | undefined) => {
|
440
|
-
if (this.
|
441
|
+
if (this.focused$.value !== focused) {
|
441
442
|
callbacks.emit("focusedChange", focused);
|
442
|
-
emitter.emit("focusedChange", { focused, prev: this.
|
443
|
-
this.
|
443
|
+
emitter.emit("focusedChange", { focused, prev: this.focused$.value });
|
444
|
+
this.focused$.setValue(focused);
|
444
445
|
if (focused !== undefined) {
|
445
446
|
this.boxManager?.focusBox({ appId: focused });
|
446
447
|
// 确保 focus 修改的时候, appProxy 已经创建
|
@@ -687,12 +688,9 @@ export class AppManager {
|
|
687
688
|
appProxy.emitAppIsWritableChange();
|
688
689
|
});
|
689
690
|
if (isWritable === true) {
|
690
|
-
this.mainView.disableCameraTransform = false;
|
691
691
|
if (this.room && this.room.disableSerialization === true) {
|
692
692
|
this.room.disableSerialization = false;
|
693
693
|
}
|
694
|
-
} else {
|
695
|
-
this.mainView.disableCameraTransform = true;
|
696
694
|
}
|
697
695
|
emitter.emit("writableChange", isWritable);
|
698
696
|
};
|
@@ -834,7 +832,7 @@ export class AppManager {
|
|
834
832
|
}
|
835
833
|
callbacks.clearListeners();
|
836
834
|
this.sideEffectManager.flushAll();
|
837
|
-
this.
|
838
|
-
this.
|
835
|
+
this.sceneIndex$.destroy();
|
836
|
+
this.focused$.destroy();
|
839
837
|
}
|
840
838
|
}
|
package/src/BoxManager.ts
CHANGED
@@ -47,11 +47,11 @@ export type CreateTeleBoxManagerConfig = {
|
|
47
47
|
collectorStyles?: Partial<CSSStyleDeclaration>;
|
48
48
|
prefersColorScheme?: TeleBoxColorScheme;
|
49
49
|
stageRatio?: number;
|
50
|
+
highlightStage?: boolean;
|
50
51
|
};
|
51
52
|
|
52
53
|
export type BoxManagerContext = {
|
53
54
|
safeSetAttributes: (attributes: any) => void;
|
54
|
-
getMainView: () => View;
|
55
55
|
updateAppState: (appId: string, field: AppAttributes, value: any) => void;
|
56
56
|
emitter: EmitterType;
|
57
57
|
boxEmitter: BoxEmitterType;
|
@@ -72,7 +72,6 @@ export const createBoxManager = (
|
|
72
72
|
return new BoxManager(
|
73
73
|
{
|
74
74
|
safeSetAttributes: (attributes: any) => manager.safeSetAttributes(attributes),
|
75
|
-
getMainView: () => manager.mainView,
|
76
75
|
updateAppState: (...args) => manager.appManager?.store.updateAppState(...args),
|
77
76
|
canOperate: () => manager.canOperate,
|
78
77
|
notifyContainerRectUpdate: (rect: TeleBoxRect) =>
|
@@ -178,10 +177,6 @@ export class BoxManager {
|
|
178
177
|
]);
|
179
178
|
}
|
180
179
|
|
181
|
-
private get mainView() {
|
182
|
-
return this.context.getMainView();
|
183
|
-
}
|
184
|
-
|
185
180
|
private get canOperate() {
|
186
181
|
return this.context.canOperate();
|
187
182
|
}
|
@@ -251,6 +246,7 @@ export class BoxManager {
|
|
251
246
|
root: root,
|
252
247
|
fence: false,
|
253
248
|
prefersColorScheme: createTeleBoxManagerConfig?.prefersColorScheme,
|
249
|
+
highlightStage: createTeleBoxManagerConfig?.highlightStage,
|
254
250
|
};
|
255
251
|
|
256
252
|
const manager = new TeleBoxManager(initManagerState);
|
@@ -13,6 +13,7 @@ export type PageState = {
|
|
13
13
|
export interface PageController {
|
14
14
|
nextPage: () => Promise<boolean>;
|
15
15
|
prevPage: () => Promise<boolean>;
|
16
|
+
jumpPage: (index: number) => Promise<boolean>;
|
16
17
|
addPage: (params?: AddPageParams) => Promise<void>;
|
17
18
|
removePage: (index: number) => Promise<boolean>;
|
18
19
|
pageState: PageState;
|
@@ -1,14 +1,14 @@
|
|
1
1
|
import { AnimationMode } from "white-web-sdk";
|
2
2
|
import { delay, throttle } from "lodash";
|
3
3
|
import type { TeleBoxRect } from "@netless/telebox-insider";
|
4
|
-
import type { Camera, View
|
4
|
+
import type { Camera, View } from "white-web-sdk";
|
5
5
|
import type { ISize } from "../AttributesDelegate";
|
6
6
|
|
7
7
|
export type SaveCamera = (camera: Camera) => void;
|
8
8
|
|
9
9
|
export class CameraSynchronizer {
|
10
|
-
|
11
|
-
|
10
|
+
public remoteCamera?: Camera;
|
11
|
+
public remoteSize?: ISize;
|
12
12
|
protected rect?: TeleBoxRect;
|
13
13
|
protected view?: View;
|
14
14
|
|
@@ -53,21 +53,4 @@ export class CameraSynchronizer {
|
|
53
53
|
this.saveCamera(camera);
|
54
54
|
this.remoteCamera = camera;
|
55
55
|
}
|
56
|
-
|
57
|
-
// 本地 Size 更新, 先匹配 camera 到新的 size 然后再发送 camera 数据到远端
|
58
|
-
public onLocalSizeUpdate = (size: Size) => {
|
59
|
-
if (this.rect && this.view) {
|
60
|
-
let scale: number;
|
61
|
-
if (size.width < size.height) {
|
62
|
-
scale = this.rect.width / size.width;
|
63
|
-
} else {
|
64
|
-
scale = this.rect.height / size.height;
|
65
|
-
}
|
66
|
-
const nextScale = this.view.camera.scale / scale;
|
67
|
-
this.view.moveCamera({
|
68
|
-
scale: nextScale,
|
69
|
-
animationMode: AnimationMode.Immediately
|
70
|
-
});
|
71
|
-
}
|
72
|
-
}
|
73
56
|
}
|