@netless/window-manager 0.3.7 → 0.3.8-canary.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "0.3.7",
3
+ "version": "0.3.8-canary.0",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
package/src/AppContext.ts CHANGED
@@ -32,6 +32,7 @@ export class AppContext<TAttrs extends Record<string, any>, AppOptions = any> {
32
32
  private boxManager: BoxManager;
33
33
  private store = this.manager.store;
34
34
  public readonly isAddApp: boolean;
35
+ public readonly isReplay = this.manager.isReplay;
35
36
 
36
37
  constructor(
37
38
  private manager: AppManager,
package/src/AppManager.ts CHANGED
@@ -9,7 +9,7 @@ import { genAppId, makeValidScenePath, setScenePath } from "./Utils/Common";
9
9
  import { autorun, isPlayer, isRoom, ScenePathType, ViewVisionMode } from "white-web-sdk";
10
10
  import { log } from "./Utils/log";
11
11
  import { MainViewProxy } from "./MainView";
12
- import { onObjectInserted, onObjectRemoved } from "./Utils/Reactive";
12
+ import { onObjectRemoved, safeListenPropsUpdated } from "./Utils/Reactive";
13
13
  import { ReconnectRefresher } from "./ReconnectRefresher";
14
14
  import { ViewManager } from "./ViewManager";
15
15
  import type { Displayer, DisplayerState, Room } from "white-web-sdk";
@@ -31,6 +31,7 @@ export class AppManager {
31
31
  public store = new AttributesDelegate(this);
32
32
  public mainViewProxy: MainViewProxy;
33
33
  public refresher?: ReconnectRefresher;
34
+ public isReplay = this.windowManger.isReplay;
34
35
 
35
36
  private appListeners: AppListeners;
36
37
 
@@ -54,15 +55,17 @@ export class AppManager {
54
55
  appProxy.onSeek(time);
55
56
  });
56
57
  this.attributesUpdateCallback(this.attributes.apps);
58
+ this.onAppDelete(this.attributes.apps);
57
59
  });
58
60
  }
59
61
  }
60
62
 
61
63
  private async onCreated() {
62
64
  await this.attributesUpdateCallback(this.attributes.apps);
65
+ this.boxManager.updateManagerRect();
63
66
  emitter.onAny(this.boxEventListener);
64
67
  this.refresher?.add("apps", () => {
65
- return onObjectInserted(this.attributes.apps, () => {
68
+ return safeListenPropsUpdated(() => this.attributes.apps, () => {
66
69
  this.attributesUpdateCallback(this.attributes.apps);
67
70
  });
68
71
  });
@@ -29,7 +29,7 @@ export const setScenePath = (room: Room | undefined, scenePath: string) => {
29
29
  }
30
30
 
31
31
  export const setViewMode = (view: View, mode: ViewVisionMode) => {
32
- if (view.mode !== mode) {
32
+ if (!(view as any).didRelease && view.mode !== mode) {
33
33
  view.mode = mode;
34
34
  }
35
35
  };
@@ -1,5 +1,5 @@
1
1
  import { listenUpdated, unlistenUpdated, reaction, UpdateEventKind } from "white-web-sdk";
2
- import type { AkkoObjectUpdatedProperty } from "white-web-sdk";
2
+ import type { AkkoObjectUpdatedProperty , AkkoObjectUpdatedListener } from "white-web-sdk";
3
3
 
4
4
  // 兼容 13 和 14 版本 SDK
5
5
  export const onObjectByEvent = (event: UpdateEventKind) => {
@@ -28,5 +28,30 @@ export const onObjectByEvent = (event: UpdateEventKind) => {
28
28
  }
29
29
  }
30
30
 
31
+ export const safeListenPropsUpdated = <T>(
32
+ getProps: () => T,
33
+ callback: AkkoObjectUpdatedListener<T>
34
+ ) => {
35
+ let disposeListenUpdated: (() => void) | null = null;
36
+ const disposeReaction = reaction(
37
+ getProps,
38
+ () => {
39
+ if (disposeListenUpdated) {
40
+ disposeListenUpdated();
41
+ disposeListenUpdated = null;
42
+ }
43
+ const props = getProps();
44
+ disposeListenUpdated = () => unlistenUpdated(props, callback);
45
+ listenUpdated(props, callback);
46
+ },
47
+ { fireImmediately: true }
48
+ );
49
+
50
+ return () => {
51
+ disposeListenUpdated?.();
52
+ disposeReaction();
53
+ };
54
+ }
55
+
31
56
  export const onObjectRemoved = onObjectByEvent(UpdateEventKind.Removed);
32
57
  export const onObjectInserted = onObjectByEvent(UpdateEventKind.Inserted);
package/src/index.ts CHANGED
@@ -33,6 +33,7 @@ import {
33
33
  import type { Apps } from "./AttributesDelegate";
34
34
  import {
35
35
  InvisiblePlugin,
36
+ isPlayer,
36
37
  isRoom,
37
38
  RoomPhase,
38
39
  ViewMode,
@@ -168,7 +169,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
168
169
  public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
169
170
  private static isCreated = false;
170
171
 
171
- public version = "0.3.7";
172
+ public version = "0.3.8-canary.0";
172
173
 
173
174
  public appListeners?: AppListeners;
174
175
 
@@ -177,7 +178,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
177
178
  public appManager?: AppManager;
178
179
  public cursorManager?: CursorManager;
179
180
  public viewMode = ViewMode.Broadcaster;
180
-
181
+ public isReplay = isPlayer(this.displayer);
182
+
181
183
  constructor(context: InvisiblePluginContext) {
182
184
  super(context);
183
185
  }