@netless/window-manager 0.4.20 → 0.4.21
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/CHANGELOG.md +3 -0
- package/dist/AppListener.d.ts +1 -0
- package/dist/AppManager.d.ts +4 -1
- package/dist/ReconnectRefresher.d.ts +2 -0
- package/dist/constants.d.ts +2 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +63 -20
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +10 -10
- package/dist/index.umd.js.map +1 -1
- package/docs/api.md +8 -0
- package/package.json +1 -1
- package/src/AppListener.ts +8 -0
- package/src/AppManager.ts +26 -15
- package/src/ReconnectRefresher.ts +13 -1
- package/src/constants.ts +1 -0
- package/src/index.ts +17 -0
package/docs/api.md
CHANGED
@@ -27,6 +27,7 @@
|
|
27
27
|
- [`nextPage`](#nextPage)
|
28
28
|
- [`prevPage`](#prevPage)
|
29
29
|
- [`addPage`](#addPage)
|
30
|
+
- [`refresh`](#refresh)
|
30
31
|
- [实例属性](#prototypes)
|
31
32
|
- [事件回调](#events)
|
32
33
|
|
@@ -212,6 +213,13 @@ manager.addPage({ after: true }) // 在当前页后添加一页
|
|
212
213
|
manager.addPage({ scene: { name: "page2" } }) // 传入 page 信息
|
213
214
|
```
|
214
215
|
|
216
|
+
<h3 id="refresh">refresh</h3>
|
217
|
+
|
218
|
+
> 刷新 `manager` 的内部状态, 用于从其他房间 `copy` `attributes`
|
219
|
+
|
220
|
+
```ts
|
221
|
+
manager.refresh()
|
222
|
+
```
|
215
223
|
|
216
224
|
<br>
|
217
225
|
|
package/package.json
CHANGED
package/src/AppListener.ts
CHANGED
@@ -59,6 +59,10 @@ export class AppListeners {
|
|
59
59
|
this.rootDirRemovedHandler();
|
60
60
|
break;
|
61
61
|
}
|
62
|
+
case Events.Refresh: {
|
63
|
+
this.refreshHandler();
|
64
|
+
break;
|
65
|
+
}
|
62
66
|
default:
|
63
67
|
break;
|
64
68
|
}
|
@@ -103,4 +107,8 @@ export class AppListeners {
|
|
103
107
|
this.manager.mainViewProxy.rebind();
|
104
108
|
emitter.emit("rootDirRemoved");
|
105
109
|
}
|
110
|
+
|
111
|
+
private refreshHandler = () => {
|
112
|
+
this.manager.windowManger._refresh();
|
113
|
+
}
|
106
114
|
}
|
package/src/AppManager.ts
CHANGED
@@ -7,7 +7,7 @@ import { autorun, isPlayer, isRoom, ScenePathType } from "white-web-sdk";
|
|
7
7
|
import { callbacks } from "./callback";
|
8
8
|
import { emitter } from "./InternalEmitter";
|
9
9
|
import { Fields, store } from "./AttributesDelegate";
|
10
|
-
import { get, isInteger, orderBy } from "lodash";
|
10
|
+
import { debounce, get, isInteger, orderBy } from "lodash";
|
11
11
|
import { log } from "./Utils/log";
|
12
12
|
import { MainViewProxy } from "./View/MainView";
|
13
13
|
import { onObjectRemoved, safeListenPropsUpdated } from "./Utils/Reactive";
|
@@ -251,19 +251,9 @@ export class AppManager {
|
|
251
251
|
await this.attributesUpdateCallback(this.attributes.apps);
|
252
252
|
emitter.emit("updateManagerRect");
|
253
253
|
emitter.onAny(this.boxEventListener);
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
() => {
|
258
|
-
this.attributesUpdateCallback(this.attributes.apps);
|
259
|
-
}
|
260
|
-
);
|
261
|
-
});
|
262
|
-
this.refresher?.add("appsClose", () => {
|
263
|
-
return onObjectRemoved(this.attributes.apps, () => {
|
264
|
-
this.onAppDelete(this.attributes.apps);
|
265
|
-
});
|
266
|
-
});
|
254
|
+
|
255
|
+
this.addAppsChangeListener();
|
256
|
+
this.addAppCloseListener();
|
267
257
|
this.refresher?.add("maximized", () => {
|
268
258
|
return autorun(() => {
|
269
259
|
const maximized = this.attributes.maximized;
|
@@ -313,6 +303,25 @@ export class AppManager {
|
|
313
303
|
});
|
314
304
|
}
|
315
305
|
|
306
|
+
public addAppsChangeListener = () => {
|
307
|
+
this.refresher?.add("apps", () => {
|
308
|
+
return safeListenPropsUpdated(
|
309
|
+
() => this.attributes.apps,
|
310
|
+
() => {
|
311
|
+
this.attributesUpdateCallback(this.attributes.apps);
|
312
|
+
}
|
313
|
+
);
|
314
|
+
});
|
315
|
+
}
|
316
|
+
|
317
|
+
public addAppCloseListener = () => {
|
318
|
+
this.refresher?.add("appsClose", () => {
|
319
|
+
return onObjectRemoved(this.attributes.apps, () => {
|
320
|
+
this.onAppDelete(this.attributes.apps);
|
321
|
+
});
|
322
|
+
});
|
323
|
+
}
|
324
|
+
|
316
325
|
private onMainViewIndexChange = (index: number) => {
|
317
326
|
if (index !== undefined && this._prevSceneIndex !== index) {
|
318
327
|
callbacks.emit("mainViewSceneIndexChange", index);
|
@@ -342,13 +351,15 @@ export class AppManager {
|
|
342
351
|
}
|
343
352
|
}
|
344
353
|
|
354
|
+
public attributesUpdateCallback = debounce((apps: any) => this._attributesUpdateCallback(apps), 100);
|
355
|
+
|
345
356
|
/**
|
346
357
|
* 插件更新 attributes 时的回调
|
347
358
|
*
|
348
359
|
* @param {*} attributes
|
349
360
|
* @memberof WindowManager
|
350
361
|
*/
|
351
|
-
public async
|
362
|
+
public async _attributesUpdateCallback(apps: any) {
|
352
363
|
if (apps && WindowManager.container) {
|
353
364
|
const appIds = Object.keys(apps);
|
354
365
|
if (appIds.length === 0) {
|
@@ -36,6 +36,10 @@ export class ReconnectRefresher {
|
|
36
36
|
};
|
37
37
|
|
38
38
|
private onReconnected = debounce(() => {
|
39
|
+
this._onReconnected();
|
40
|
+
}, 3000);
|
41
|
+
|
42
|
+
private _onReconnected = () => {
|
39
43
|
log("onReconnected refresh reactors");
|
40
44
|
this.releaseDisposers();
|
41
45
|
this.reactors.forEach((func, id) => {
|
@@ -44,7 +48,7 @@ export class ReconnectRefresher {
|
|
44
48
|
}
|
45
49
|
});
|
46
50
|
this.ctx.emitter.emit("onReconnected", undefined);
|
47
|
-
}
|
51
|
+
}
|
48
52
|
|
49
53
|
private releaseDisposers() {
|
50
54
|
this.disposers.forEach(disposer => {
|
@@ -55,7 +59,15 @@ export class ReconnectRefresher {
|
|
55
59
|
this.disposers.clear();
|
56
60
|
}
|
57
61
|
|
62
|
+
public refresh() {
|
63
|
+
this._onReconnected();
|
64
|
+
}
|
65
|
+
|
58
66
|
public add(id: string, func: any) {
|
67
|
+
const disposer = this.disposers.get(id);
|
68
|
+
if (disposer && isFunction(disposer)) {
|
69
|
+
disposer();
|
70
|
+
}
|
59
71
|
if (isFunction(func)) {
|
60
72
|
this.reactors.set(id, func);
|
61
73
|
this.disposers.set(id, func());
|
package/src/constants.ts
CHANGED
package/src/index.ts
CHANGED
@@ -332,6 +332,9 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
332
332
|
params.chessboard,
|
333
333
|
params.overwriteStyles
|
334
334
|
);
|
335
|
+
if (this.boxManager) {
|
336
|
+
this.boxManager.destroy();
|
337
|
+
}
|
335
338
|
const boxManager = createBoxManager(this, callbacks, emitter, {
|
336
339
|
collectorContainer: params.collectorContainer,
|
337
340
|
collectorStyles: params.collectorStyles,
|
@@ -876,6 +879,20 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
876
879
|
return this.focusedView?.lockImages(locked);
|
877
880
|
}
|
878
881
|
|
882
|
+
public refresh() {
|
883
|
+
this._refresh();
|
884
|
+
this.appManager?.dispatchInternalEvent(Events.Refresh);
|
885
|
+
}
|
886
|
+
|
887
|
+
/** @inner */
|
888
|
+
public _refresh() {
|
889
|
+
this.appManager?.mainViewProxy.rebind();
|
890
|
+
if (WindowManager.container) {
|
891
|
+
this.bindContainer(WindowManager.container);
|
892
|
+
}
|
893
|
+
this.appManager?.refresher?.refresh();
|
894
|
+
}
|
895
|
+
|
879
896
|
private isDynamicPPT(scenes: SceneDefinition[]) {
|
880
897
|
const sceneSrc = scenes[0]?.ppt?.src;
|
881
898
|
return sceneSrc?.startsWith("pptx://");
|