@netless/window-manager 1.0.0-canary.20 → 1.0.0-canary.23
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 +5 -1
- package/dist/App/AppProxy.d.ts +5 -2
- package/dist/App/index.d.ts +1 -0
- package/dist/App/type.d.ts +21 -0
- package/dist/BoxManager.d.ts +4 -3
- package/dist/Cursor/index.d.ts +0 -1
- package/dist/InternalEmitter.d.ts +1 -2
- package/dist/Utils/Reactive.d.ts +0 -2
- package/dist/View/CameraSynchronizer.d.ts +1 -1
- package/dist/constants.d.ts +0 -1
- package/dist/index.cjs.js +12 -12
- package/dist/index.es.js +164 -205
- package/dist/index.umd.js +12 -12
- package/docs/app-context.md +89 -3
- package/package.json +1 -1
- package/src/App/AppContext.ts +14 -3
- package/src/App/AppProxy.ts +88 -132
- package/src/App/index.ts +1 -0
- package/src/App/type.ts +22 -0
- package/src/AppManager.ts +5 -1
- package/src/BoxManager.ts +8 -7
- package/src/Cursor/index.ts +0 -2
- package/src/InternalEmitter.ts +1 -2
- package/src/ReconnectRefresher.ts +5 -1
- package/src/Utils/Reactive.ts +0 -16
- package/src/View/CameraSynchronizer.ts +17 -26
- package/src/View/ViewSync.ts +6 -12
- package/src/constants.ts +0 -1
package/docs/app-context.md
CHANGED
@@ -75,7 +75,7 @@
|
|
75
75
|
```
|
76
76
|
|
77
77
|
```ts
|
78
|
-
const view = context.createWhiteBoardView(10); // 生成带有 10 页的白板
|
78
|
+
const view = context.createWhiteBoardView({ size: 10 }); // 生成带有 10 页的白板
|
79
79
|
```
|
80
80
|
|
81
81
|
- **WhiteBoardView**
|
@@ -148,6 +148,18 @@
|
|
148
148
|
console.log("pageStateChange", pageState)
|
149
149
|
})
|
150
150
|
```
|
151
|
+
- **setRect**
|
152
|
+
|
153
|
+
设置白板的显示的宽高\
|
154
|
+
在不同分辨率下会保证所有打开的窗口都能完整显示这个区域
|
155
|
+
|
156
|
+
```ts
|
157
|
+
const view = context.createWhiteBoardView();
|
158
|
+
// 此方法建议只在插入时设置一次
|
159
|
+
if (context.isAddApp) {
|
160
|
+
view.setRect({ width: 500, height: 500 })
|
161
|
+
}
|
162
|
+
```
|
151
163
|
|
152
164
|
<h3 id="storage">storage</h3>
|
153
165
|
|
@@ -301,6 +313,44 @@
|
|
301
313
|
|
302
314
|
类型: `ReadonlyTeleBox`
|
303
315
|
|
316
|
+
- **mountStyles()**
|
317
|
+
|
318
|
+
挂载样式到 `box` 上
|
319
|
+
|
320
|
+
参数: `string | HTMLStyleElement`
|
321
|
+
|
322
|
+
```ts
|
323
|
+
box.mountStyles(`
|
324
|
+
.hello-world-app span {
|
325
|
+
color: red;
|
326
|
+
}
|
327
|
+
`);
|
328
|
+
```
|
329
|
+
|
330
|
+
- **mountContent()**
|
331
|
+
|
332
|
+
挂载元素到 `box` 中\
|
333
|
+
推荐使用 `mountStage` 方法挂载元素到 `stage` 中
|
334
|
+
|
335
|
+
参数: `HTMLElement`
|
336
|
+
|
337
|
+
```ts
|
338
|
+
const app = document.createElement("div");
|
339
|
+
box.mountContent(app);
|
340
|
+
```
|
341
|
+
|
342
|
+
- **mountStage()**
|
343
|
+
|
344
|
+
挂载元素到 `box` 的 `contentStage` 中\
|
345
|
+
如无特殊情况, 推荐把所有内容挂载到 `stage` 中
|
346
|
+
|
347
|
+
参数: `HTMLElement`
|
348
|
+
|
349
|
+
```ts
|
350
|
+
const app = document.createElement("div");
|
351
|
+
box.mountStage(app);
|
352
|
+
```
|
353
|
+
|
304
354
|
- **contentStageRect**
|
305
355
|
|
306
356
|
可同步区域\
|
@@ -324,7 +374,43 @@
|
|
324
374
|
订阅 `contextStateRect` 的变化
|
325
375
|
|
326
376
|
```ts
|
327
|
-
box.
|
377
|
+
box.onValChanged("contentStageRect", rect => {
|
328
378
|
console.log("contentStageRect changed", rect);
|
329
379
|
});
|
330
|
-
```
|
380
|
+
```
|
381
|
+
|
382
|
+
- **highlightStage**
|
383
|
+
|
384
|
+
是否高亮 `stage` 区域\
|
385
|
+
默认为 `true`
|
386
|
+
|
387
|
+
类型: `boolean`
|
388
|
+
|
389
|
+
- **setHighlightStage()**
|
390
|
+
|
391
|
+
参数: `boolean`
|
392
|
+
|
393
|
+
|
394
|
+
- **$content**
|
395
|
+
|
396
|
+
应用窗口的内容区域
|
397
|
+
|
398
|
+
类型: `HTMLElement`
|
399
|
+
|
400
|
+
- **$footer**
|
401
|
+
|
402
|
+
应用窗口的底部区域
|
403
|
+
|
404
|
+
类型: `HTMLElement`
|
405
|
+
|
406
|
+
- **resizable**
|
407
|
+
|
408
|
+
是否可以改变窗口大小
|
409
|
+
|
410
|
+
类型: `boolean`
|
411
|
+
|
412
|
+
- **draggable**
|
413
|
+
|
414
|
+
窗口是否可以拖动
|
415
|
+
|
416
|
+
类型: `boolean`
|
package/package.json
CHANGED
package/src/App/AppContext.ts
CHANGED
@@ -28,7 +28,12 @@ import type {
|
|
28
28
|
import { WhiteBoardView } from "./WhiteboardView";
|
29
29
|
import { findMemberByUid } from "../Helper";
|
30
30
|
import { MAX_PAGE_SIZE } from "../constants";
|
31
|
-
import { isNumber } from "lodash";
|
31
|
+
import { isBoolean, isNumber } from "lodash";
|
32
|
+
|
33
|
+
export type CreateWhiteBoardViewParams = {
|
34
|
+
size?: number;
|
35
|
+
syncCamera?: boolean;
|
36
|
+
}
|
32
37
|
|
33
38
|
export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOptions = any> {
|
34
39
|
public readonly emitter: Emittery<AppEmitterEvent<TAttributes>>;
|
@@ -86,7 +91,7 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
|
|
86
91
|
return this.appProxy.view;
|
87
92
|
};
|
88
93
|
|
89
|
-
public createWhiteBoardView = (
|
94
|
+
public createWhiteBoardView = (params?: CreateWhiteBoardViewParams): WhiteBoardView => {
|
90
95
|
if (this.whiteBoardView) {
|
91
96
|
return this.whiteBoardView;
|
92
97
|
}
|
@@ -94,6 +99,11 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
|
|
94
99
|
if (!view) {
|
95
100
|
view = this.appProxy.createAppDir();
|
96
101
|
}
|
102
|
+
if (params) {
|
103
|
+
if (isBoolean(params.syncCamera)) {
|
104
|
+
this.appProxy.syncCamera$.setValue(params.syncCamera);
|
105
|
+
}
|
106
|
+
}
|
97
107
|
const viewWrapper = document.createElement("div");
|
98
108
|
this._viewWrapper = viewWrapper;
|
99
109
|
viewWrapper.className = "window-manager-view-wrapper";
|
@@ -101,7 +111,7 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
|
|
101
111
|
view.divElement = viewWrapper;
|
102
112
|
this.appProxy.fireMemberStateChange();
|
103
113
|
if (this.isAddApp) {
|
104
|
-
this.ensurePageSize(size);
|
114
|
+
this.ensurePageSize(params?.size);
|
105
115
|
}
|
106
116
|
this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy, this.ensurePageSize);
|
107
117
|
this.appProxy.sideEffectManager.add(() => {
|
@@ -109,6 +119,7 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
|
|
109
119
|
this.whiteBoardView = undefined;
|
110
120
|
}
|
111
121
|
});
|
122
|
+
this.appProxy.whiteBoardViewCreated$.setValue(true);
|
112
123
|
return this.whiteBoardView;
|
113
124
|
}
|
114
125
|
|
package/src/App/AppProxy.ts
CHANGED
@@ -9,7 +9,7 @@ import { boxEmitter } from "../BoxEmitter";
|
|
9
9
|
import { BoxManagerNotFoundError } from "../Utils/error";
|
10
10
|
import { calculateNextIndex } from "../Page";
|
11
11
|
import { combine, Val, ValManager } from "value-enhancer";
|
12
|
-
import { debounce, get, isEqual } from "lodash";
|
12
|
+
import { debounce, get, isEqual, isUndefined, omitBy } from "lodash";
|
13
13
|
import { emitter } from "../InternalEmitter";
|
14
14
|
import { Fields } from "../AttributesDelegate";
|
15
15
|
import { log } from "../Utils/log";
|
@@ -25,7 +25,6 @@ import {
|
|
25
25
|
} from "../Utils/Common";
|
26
26
|
import type {
|
27
27
|
AppEmitterEvent,
|
28
|
-
AppInitState,
|
29
28
|
BaseInsertParams,
|
30
29
|
setAppOptions,
|
31
30
|
AppListenerKeys,
|
@@ -35,7 +34,7 @@ import type { AppManager } from "../AppManager";
|
|
35
34
|
import type { NetlessApp } from "../typings";
|
36
35
|
import type { ReadonlyTeleBox, TeleBoxRect } from "@netless/telebox-insider";
|
37
36
|
import type { PageRemoveService, PageState } from "../Page";
|
38
|
-
import {
|
37
|
+
import type { AppState } from "./type";
|
39
38
|
|
40
39
|
export type AppEmitter = Emittery<AppEmitterEvent>;
|
41
40
|
|
@@ -72,6 +71,8 @@ export class AppProxy implements PageRemoveService {
|
|
72
71
|
public size$ = this.valManager.attach(new Val<ISize | undefined>(undefined));
|
73
72
|
public box$ = this.valManager.attach(new Val<ReadonlyTeleBox | undefined>(undefined));
|
74
73
|
public view$ = this.valManager.attach(new Val<View | undefined>(undefined));
|
74
|
+
public syncCamera$ = this.valManager.attach(new Val<boolean>(true));
|
75
|
+
public whiteBoardViewCreated$ = this.valManager.attach(new Val<boolean>(false));
|
75
76
|
|
76
77
|
constructor(
|
77
78
|
private params: BaseInsertParams,
|
@@ -114,90 +115,60 @@ export class AppProxy implements PageRemoveService {
|
|
114
115
|
this.addCameraReaction();
|
115
116
|
this.addSizeReaction();
|
116
117
|
this.sideEffectManager.add(() =>
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
this.
|
127
|
-
}
|
128
|
-
if (!this.size$.value && box.contentStageRect) {
|
129
|
-
const initialRect = this.computedInitialRect(box.contentStageRect);
|
130
|
-
const width = initialRect?.width || box.contentStageRect.width;
|
131
|
-
const height = initialRect?.height || box.contentStageRect.height;
|
132
|
-
this.storeSize({
|
133
|
-
id: this.uid,
|
134
|
-
width,
|
135
|
-
height,
|
136
|
-
});
|
137
|
-
this.size$.setValue(toJS(this.appAttributes.size));
|
118
|
+
emitter.on("memberStateChange", this.onMemberStateChange)
|
119
|
+
);
|
120
|
+
this.sideEffectManager.add(() => [
|
121
|
+
this.syncCamera$.reaction(syncCamera => {
|
122
|
+
if (!syncCamera) {
|
123
|
+
if (this.viewSync) {
|
124
|
+
this.viewSync.destroy();
|
125
|
+
this.viewSync = undefined;
|
126
|
+
this.sideEffectManager.flush("camera");
|
127
|
+
this.sideEffectManager.flush("size");
|
138
128
|
}
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
129
|
+
}
|
130
|
+
}),
|
131
|
+
this.whiteBoardViewCreated$.reaction(created => {
|
132
|
+
if (created && this.box) {
|
133
|
+
if (!this.syncCamera$.value) return;
|
134
|
+
combine([this.box$, this.view$]).subscribe(([box, view]) => {
|
135
|
+
if (box && view) {
|
136
|
+
if (!this.camera$.value) {
|
137
|
+
this.storeCamera({
|
138
|
+
centerX: null,
|
139
|
+
centerY: null,
|
140
|
+
scale: 1,
|
141
|
+
id: this.uid,
|
142
|
+
});
|
143
|
+
this.camera$.setValue(toJS(this.appAttributes.camera));
|
144
|
+
}
|
145
|
+
if (!this.size$.value && box.contentStageRect) {
|
146
|
+
const initialRect = this.computedInitialRect(box.contentStageRect);
|
147
|
+
const width = initialRect?.width || box.contentStageRect.width;
|
148
|
+
const height = initialRect?.height || box.contentStageRect.height;
|
149
|
+
this.storeSize({
|
150
|
+
id: this.uid,
|
151
|
+
width,
|
152
|
+
height,
|
153
|
+
});
|
154
|
+
this.size$.setValue(toJS(this.appAttributes.size));
|
155
|
+
}
|
156
|
+
this.viewSync = new ViewSync({
|
157
|
+
uid: this.uid,
|
158
|
+
view$: this.view$,
|
159
|
+
camera$: this.camera$,
|
160
|
+
size$: this.size$,
|
161
|
+
stageRect$: box._contentStageRect$,
|
162
|
+
storeCamera: this.storeCamera,
|
163
|
+
storeSize: this.storeSize
|
164
|
+
});
|
165
|
+
this.sideEffectManager.add(() => () => this.viewSync?.destroy());
|
166
|
+
this.whiteBoardViewCreated$.destroy();
|
167
|
+
}
|
168
|
+
})
|
149
169
|
}
|
150
170
|
})
|
151
|
-
);
|
152
|
-
this.sideEffectManager.add(() =>
|
153
|
-
emitter.on("memberStateChange", this.onMemberStateChange)
|
154
|
-
);
|
155
|
-
this.box$.subscribe(box => {
|
156
|
-
if (!box) return;
|
157
|
-
this.sideEffectManager.add(() => [
|
158
|
-
createValSync(
|
159
|
-
() => this.appAttributes?.state.visible,
|
160
|
-
box._visible$,
|
161
|
-
this.isAddApp,
|
162
|
-
),
|
163
|
-
createValSync(
|
164
|
-
() => this.appAttributes?.state.ratio,
|
165
|
-
box._ratio$,
|
166
|
-
this.isAddApp,
|
167
|
-
),
|
168
|
-
createValSync(
|
169
|
-
() => this.appAttributes?.state.stageRatio,
|
170
|
-
box._stageRatio$,
|
171
|
-
this.isAddApp,
|
172
|
-
),
|
173
|
-
createValSync(
|
174
|
-
() => this.appAttributes?.state.draggable,
|
175
|
-
box._draggable$,
|
176
|
-
this.isAddApp,
|
177
|
-
),
|
178
|
-
createValSync(
|
179
|
-
() => this.appAttributes?.state.resizable,
|
180
|
-
box._resizable$,
|
181
|
-
this.isAddApp,
|
182
|
-
),
|
183
|
-
box._visible$.subscribe(visible => {
|
184
|
-
this.store.updateAppState(this.id, AppAttributes.Visible, visible);
|
185
|
-
}),
|
186
|
-
box._ratio$.subscribe(ratio => {
|
187
|
-
this.store.updateAppState(this.id, AppAttributes.Ratio, ratio);
|
188
|
-
}),
|
189
|
-
box._stageRatio$.subscribe(stageRatio => {
|
190
|
-
this.store.updateAppState(this.id, AppAttributes.StageRatio, stageRatio);
|
191
|
-
}),
|
192
|
-
box._draggable$.subscribe(draggable => {
|
193
|
-
this.store.updateAppState(this.id, AppAttributes.Draggable, draggable);
|
194
|
-
}),
|
195
|
-
box._resizable$.subscribe(resizable => {
|
196
|
-
console.log("resizable change", resizable);
|
197
|
-
this.store.updateAppState(this.id, AppAttributes.Resizable, resizable);
|
198
|
-
}),
|
199
|
-
])
|
200
|
-
});
|
171
|
+
]);
|
201
172
|
}
|
202
173
|
|
203
174
|
public fireMemberStateChange = () => {
|
@@ -348,7 +319,7 @@ export class AppProxy implements PageRemoveService {
|
|
348
319
|
this.appContext = context;
|
349
320
|
try {
|
350
321
|
emitter.once(`${appId}${Events.WindowCreated}` as any).then(async () => {
|
351
|
-
let boxInitState:
|
322
|
+
let boxInitState: AppState | undefined;
|
352
323
|
if (!skipUpdate) {
|
353
324
|
boxInitState = this.getAppInitState(appId);
|
354
325
|
this.boxManager?.updateBoxState(boxInitState);
|
@@ -438,30 +409,18 @@ export class AppProxy implements PageRemoveService {
|
|
438
409
|
}
|
439
410
|
}
|
440
411
|
|
441
|
-
public getAppInitState = (id: string) => {
|
412
|
+
public getAppInitState = (id: string): AppState | undefined => {
|
442
413
|
const attrs = this.store.getAppState(id);
|
443
414
|
if (!attrs) return;
|
444
|
-
const position = attrs?.[AppAttributes.Position];
|
445
415
|
const focus = this.store.focus;
|
446
|
-
const size = attrs?.[AppAttributes.Size];
|
447
|
-
const sceneIndex = attrs?.[AppAttributes.SceneIndex];
|
448
416
|
const maximized = this.attributes?.["maximized"];
|
449
417
|
const minimized = this.attributes?.["minimized"];
|
450
|
-
|
451
|
-
|
452
|
-
if (position) {
|
453
|
-
payload = { ...payload, id: id, x: position.x, y: position.y };
|
454
|
-
}
|
418
|
+
let payload = { maximized, minimized, id } as AppState;
|
419
|
+
const state = omitBy(attrs, isUndefined);
|
455
420
|
if (focus === id) {
|
456
421
|
payload = { ...payload, focus: true };
|
457
422
|
}
|
458
|
-
|
459
|
-
payload = { ...payload, width: size.width, height: size.height };
|
460
|
-
}
|
461
|
-
if (sceneIndex) {
|
462
|
-
payload = { ...payload, sceneIndex };
|
463
|
-
}
|
464
|
-
return payload;
|
423
|
+
return Object.assign(payload, state);;
|
465
424
|
};
|
466
425
|
|
467
426
|
public emitAppSceneStateChange(sceneState: SceneState) {
|
@@ -518,32 +477,34 @@ export class AppProxy implements PageRemoveService {
|
|
518
477
|
}
|
519
478
|
|
520
479
|
private appAttributesUpdateListener = (appId: string) => {
|
521
|
-
this.
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
this.
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
480
|
+
this.sideEffectManager.add(() => [
|
481
|
+
this.manager.refresher.add(appId, () => {
|
482
|
+
return autorun(() => {
|
483
|
+
const attrs = this.manager.attributes[appId];
|
484
|
+
if (attrs) {
|
485
|
+
this.appEmitter.emit("attributesUpdate", attrs);
|
486
|
+
}
|
487
|
+
});
|
488
|
+
}),
|
489
|
+
this.manager.refresher.add(this.stateKey, () => {
|
490
|
+
return autorun(() => {
|
491
|
+
const appState = this.appAttributes?.state;
|
492
|
+
if (appState?.zIndex > 0 && appState.zIndex !== this.box?.zIndex) {
|
493
|
+
this.boxManager?.setZIndex(appId, appState.zIndex);
|
494
|
+
}
|
495
|
+
});
|
496
|
+
}),
|
497
|
+
this.manager.refresher.add(`${appId}-fullPath`, () => {
|
498
|
+
return autorun(() => {
|
499
|
+
const fullPath = this.appAttributes?.fullPath;
|
500
|
+
this.setFocusScenePathHandler(fullPath);
|
501
|
+
if (this.fullPath$.value !== fullPath) {
|
502
|
+
this.notifyPageStateChange();
|
503
|
+
this.fullPath$.setValue(fullPath);
|
504
|
+
}
|
505
|
+
});
|
506
|
+
}),
|
507
|
+
]);
|
547
508
|
};
|
548
509
|
|
549
510
|
private setFocusScenePathHandler = debounce((fullPath: string | undefined) => {
|
@@ -681,11 +642,6 @@ export class AppProxy implements PageRemoveService {
|
|
681
642
|
|
682
643
|
this.viewManager.destroyView(this.id);
|
683
644
|
this.manager.appStatus.delete(this.id);
|
684
|
-
this.manager.refresher.remove(this.id);
|
685
|
-
this.manager.refresher.remove(this.stateKey);
|
686
|
-
this.manager.refresher.remove(`${this.id}-fullPath`);
|
687
|
-
this.manager.refresher.remove(`${this.id}-camera`);
|
688
|
-
this.manager.refresher.remove(`${this.id}-size`);
|
689
645
|
this.valManager.destroy();
|
690
646
|
}
|
691
647
|
|
package/src/App/index.ts
CHANGED
package/src/App/type.ts
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
export type AppState = {
|
3
|
+
id: string;
|
4
|
+
focus?: boolean;
|
5
|
+
SceneIndex?: number;
|
6
|
+
draggable?: boolean;
|
7
|
+
position?: {
|
8
|
+
x: number;
|
9
|
+
y: number;
|
10
|
+
}
|
11
|
+
ratio?: number;
|
12
|
+
resizable?: boolean;
|
13
|
+
size?: {
|
14
|
+
width: number;
|
15
|
+
height: number;
|
16
|
+
}
|
17
|
+
stageRatio?: number;
|
18
|
+
visible?: boolean;
|
19
|
+
zIndex?: number;
|
20
|
+
maximized: boolean | null;
|
21
|
+
minimized: boolean | null;
|
22
|
+
}
|
package/src/AppManager.ts
CHANGED
@@ -30,6 +30,7 @@ import {
|
|
30
30
|
removeScenes,
|
31
31
|
setScenePath,
|
32
32
|
setViewFocusScenePath,
|
33
|
+
wait,
|
33
34
|
} from "./Utils/Common";
|
34
35
|
import type { ReconnectRefresher } from "./ReconnectRefresher";
|
35
36
|
import type { BoxManager } from "./BoxManager";
|
@@ -568,7 +569,10 @@ export class AppManager {
|
|
568
569
|
public bindMainView(divElement: HTMLDivElement, disableCameraTransform: boolean) {
|
569
570
|
const mainView = this.mainViewProxy.view;
|
570
571
|
mainView.disableCameraTransform = disableCameraTransform;
|
571
|
-
mainView
|
572
|
+
// 延迟挂载 mainView 的 dom, 避免因为同步 camera 的闪动
|
573
|
+
wait(30).then(() => {
|
574
|
+
mainView.divElement = divElement;
|
575
|
+
});
|
572
576
|
if (!mainView.focusScenePath) {
|
573
577
|
this.setMainViewFocusPath();
|
574
578
|
}
|
package/src/BoxManager.ts
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
import { AppAttributes, Events, MIN_HEIGHT, MIN_WIDTH } from "./constants";
|
2
2
|
import { debounce } from "lodash";
|
3
|
+
import { SideEffectManager } from "side-effect-manager";
|
3
4
|
import { TELE_BOX_STATE, TeleBoxManager } from "@netless/telebox-insider";
|
4
5
|
import { WindowManager } from "./index";
|
5
6
|
import type { BoxEmitterType } from "./BoxEmitter";
|
6
|
-
import type { AddAppOptions
|
7
|
+
import type { AddAppOptions } from "./index";
|
7
8
|
import type {
|
8
9
|
TeleBoxManagerUpdateConfig,
|
9
10
|
TeleBoxManagerCreateConfig,
|
@@ -18,7 +19,7 @@ import type { NetlessApp } from "./typings";
|
|
18
19
|
import type { View } from "white-web-sdk";
|
19
20
|
import type { CallbacksType } from "./callback";
|
20
21
|
import type { EmitterType } from "./InternalEmitter";
|
21
|
-
import {
|
22
|
+
import type { AppState } from "./App/type";
|
22
23
|
|
23
24
|
export { TELE_BOX_STATE };
|
24
25
|
|
@@ -294,17 +295,17 @@ export class BoxManager {
|
|
294
295
|
return this.teleBoxManager.topBox;
|
295
296
|
}
|
296
297
|
|
297
|
-
public updateBoxState(state?:
|
298
|
+
public updateBoxState(state?: AppState): void {
|
298
299
|
if (!state) return;
|
299
300
|
const box = this.getBox(state.id);
|
300
301
|
if (box) {
|
301
302
|
this.teleBoxManager.update(
|
302
303
|
box.id,
|
303
304
|
{
|
304
|
-
x: state.x,
|
305
|
-
y: state.y,
|
306
|
-
width: state.width || 0.5,
|
307
|
-
height: state.height || 0.5,
|
305
|
+
x: state.position?.x,
|
306
|
+
y: state.position?.y,
|
307
|
+
width: state.size?.width || 0.5,
|
308
|
+
height: state.size?.height || 0.5,
|
308
309
|
zIndex: state.zIndex,
|
309
310
|
},
|
310
311
|
true
|
package/src/Cursor/index.ts
CHANGED
@@ -23,7 +23,6 @@ export type MoveCursorParams = {
|
|
23
23
|
};
|
24
24
|
|
25
25
|
export class CursorManager {
|
26
|
-
public containerRect?: DOMRect;
|
27
26
|
public wrapperRect?: DOMRect;
|
28
27
|
public cursorInstances: Map<string, Cursor> = new Map();
|
29
28
|
public roomMembers?: readonly RoomMember[];
|
@@ -168,7 +167,6 @@ export class CursorManager {
|
|
168
167
|
};
|
169
168
|
|
170
169
|
public updateContainerRect() {
|
171
|
-
this.containerRect = WindowManager.container?.getBoundingClientRect();
|
172
170
|
this.wrapperRect = WindowManager.playground?.getBoundingClientRect();
|
173
171
|
}
|
174
172
|
|
package/src/InternalEmitter.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import Emittery from "emittery";
|
2
2
|
import type { TeleBoxRect } from "@netless/telebox-insider";
|
3
|
-
import type {
|
3
|
+
import type { CursorMovePayload } from "./index";
|
4
4
|
import type { Member } from "./Helper";
|
5
5
|
import type { MemberState } from "white-web-sdk";
|
6
6
|
|
@@ -11,7 +11,6 @@ export type RemoveSceneParams = {
|
|
11
11
|
|
12
12
|
export type EmitterEvent = {
|
13
13
|
onCreated: undefined;
|
14
|
-
InitReplay: AppInitState;
|
15
14
|
error: Error;
|
16
15
|
seekStart: undefined;
|
17
16
|
seek: number;
|
@@ -46,7 +46,11 @@ export class ReconnectRefresher {
|
|
46
46
|
this.ctx.emitter.emit("startReconnect");
|
47
47
|
}
|
48
48
|
if (phase === RoomPhase.Connected && this.phase === RoomPhase.Reconnecting) {
|
49
|
-
this.room?.
|
49
|
+
if (this.room?.isWritable) {
|
50
|
+
this.room?.dispatchMagixEvent(EnsureReconnectEvent, {});
|
51
|
+
} else {
|
52
|
+
this.onReconnected();
|
53
|
+
}
|
50
54
|
}
|
51
55
|
this.phase = phase;
|
52
56
|
};
|
package/src/Utils/Reactive.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import { isObject } from "lodash";
|
2
2
|
import { listenUpdated, reaction, unlistenUpdated, UpdateEventKind } from "white-web-sdk";
|
3
3
|
import type { AkkoObjectUpdatedProperty, AkkoObjectUpdatedListener } from "white-web-sdk";
|
4
|
-
import type { Val } from "value-enhancer";
|
5
4
|
|
6
5
|
// 兼容 13 和 14 版本 SDK
|
7
6
|
export const onObjectByEvent = (event: UpdateEventKind) => {
|
@@ -63,18 +62,3 @@ export const safeListenPropsUpdated = <T>(
|
|
63
62
|
|
64
63
|
export const onObjectRemoved = onObjectByEvent(UpdateEventKind.Removed);
|
65
64
|
export const onObjectInserted = onObjectByEvent(UpdateEventKind.Inserted);
|
66
|
-
|
67
|
-
export const createValSync = <T>(expr: any, Val: Val<T, boolean>, isAddApp: boolean): (() => void) => {
|
68
|
-
let skipUpdate = false;
|
69
|
-
return reaction(
|
70
|
-
expr,
|
71
|
-
val => {
|
72
|
-
if (isAddApp && !skipUpdate) {
|
73
|
-
skipUpdate = true;
|
74
|
-
} else {
|
75
|
-
Val.setValue(val as T);
|
76
|
-
}
|
77
|
-
},
|
78
|
-
{ fireImmediately: true }
|
79
|
-
);
|
80
|
-
};
|