@netless/window-manager 1.0.0-canary.5 → 1.0.0-canary.6

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": "1.0.0-canary.5",
3
+ "version": "1.0.0-canary.6",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
@@ -50,6 +50,7 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
50
50
  public readonly isAddApp: boolean;
51
51
  public readonly isReplay = this.manager.isReplay;
52
52
  private whiteBoardView?: WhiteBoardView;
53
+ public _viewWrapper?: HTMLElement;
53
54
 
54
55
  constructor(
55
56
  private manager: AppManager,
@@ -93,10 +94,12 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
93
94
  view = this.appProxy.createAppDir();
94
95
  }
95
96
  const viewWrapper = document.createElement("div");
97
+ this._viewWrapper = viewWrapper;
96
98
  viewWrapper.className = "window-manager-view-wrapper";
97
99
  this.box.$content.parentElement?.appendChild(viewWrapper);
98
100
  const removeViewWrapper = () => {
99
101
  this.box.$content.parentElement?.removeChild(viewWrapper);
102
+ this._viewWrapper = undefined;
100
103
  }
101
104
  view.divElement = viewWrapper;
102
105
  if (this.isAddApp) {
@@ -136,11 +136,35 @@ export class AppProxy implements PageRemoveService {
136
136
  });
137
137
  combine([this.box$, this.view$]).subscribe(([box, view]) => {
138
138
  if (box && view) {
139
- const appViewSync = new AppViewSync(this);
140
- this.appViewSync = appViewSync;
141
- this.sideEffectManager.add(() => () => appViewSync.destroy());
139
+ if (!this.camera$.value) {
140
+ this.storeCamera({
141
+ centerX: 0, centerY: 0, scale: 1, id: this.uid,
142
+ });
143
+ }
144
+ if (!this.size$.value && box.contentStageRect) {
145
+ this.storeSize({
146
+ id: this.uid,
147
+ width: box.contentStageRect?.width,
148
+ height: box.contentStageRect?.height,
149
+ });
150
+ }
151
+ this.appViewSync = new AppViewSync(this);
152
+ this.sideEffectManager.add(() => () => this.appViewSync?.destroy());
142
153
  }
143
154
  });
155
+ this.sideEffectManager.add(() => emitter.on("memberStateChange", memberState => {
156
+ // clicker 教具把事件穿透给下层
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
+ }
166
+ }
167
+ }));
144
168
  }
145
169
 
146
170
  public createAppDir() {
@@ -3,6 +3,7 @@ import { SideEffectManager } from "side-effect-manager";
3
3
  import type { Camera, View } from "white-web-sdk";
4
4
  import type { AppProxy } from "./AppProxy";
5
5
  import { isEqual } from "lodash";
6
+ import { combine } from "value-enhancer";
6
7
 
7
8
  export class AppViewSync {
8
9
  private sem = new SideEffectManager();
@@ -32,14 +33,12 @@ export class AppViewSync {
32
33
  }
33
34
  }),
34
35
  );
35
- if (!this.appProxy.size$.value) {
36
- this.appProxy.storeSize({
37
- id: this.appProxy.uid,
38
- width: box.contentStageRect.width,
39
- height: box.contentStageRect.height,
40
- });
41
- }
42
36
  }
37
+ combine([this.appProxy.camera$, this.appProxy.size$]).subscribe(([camera, size]) => {
38
+ if (camera && size) {
39
+ this.synchronizer.onRemoteUpdate(camera, size);
40
+ }
41
+ });
43
42
  }
44
43
 
45
44
  public bindView = (view?: View) => {
package/src/AppManager.ts CHANGED
@@ -3,7 +3,7 @@ import { AppCreateQueue } from "./Utils/AppCreateQueue";
3
3
  import { AppListeners } from "./AppListener";
4
4
  import { AppProxy } from "./App";
5
5
  import { appRegister } from "./Register";
6
- import { autorun, isPlayer, isRoom, ScenePathType } from "white-web-sdk";
6
+ import { autorun, isPlayer, isRoom, ScenePathType, toJS } from "white-web-sdk";
7
7
  import { boxEmitter } from "./BoxEmitter";
8
8
  import { calculateNextIndex } from "./Page";
9
9
  import { callbacks } from "./callback";
@@ -34,10 +34,10 @@ import type { ReconnectRefresher } from "./ReconnectRefresher";
34
34
  import type { BoxManager } from "./BoxManager";
35
35
  import type {
36
36
  Displayer,
37
- DisplayerState,
38
37
  Room,
39
38
  ScenesCallbacksNode,
40
39
  SceneState,
40
+ RoomState,
41
41
  } from "white-web-sdk";
42
42
  import type { AddAppParams, BaseInsertParams, TeleBoxRect } from "./index";
43
43
  import type {
@@ -651,7 +651,7 @@ export class AppManager {
651
651
  }
652
652
  }
653
653
 
654
- private displayerStateListener = (state: Partial<DisplayerState>) => {
654
+ private displayerStateListener = (state: Partial<RoomState>) => {
655
655
  const sceneState = state.sceneState;
656
656
  if (sceneState) {
657
657
  const scenePath = sceneState.scenePath;
@@ -669,6 +669,9 @@ export class AppManager {
669
669
  emitter.emit("roomMembersChange", this.members);
670
670
  }
671
671
  emitter.emit("observerIdChange", this.displayer.observerId);
672
+ if (state.memberState) {
673
+ emitter.emit("memberStateChange", toJS(state.memberState));
674
+ }
672
675
  };
673
676
 
674
677
  public displayerWritableListener = (isReadonly: boolean) => {
@@ -2,6 +2,7 @@ import Emittery from "emittery";
2
2
  import type { TeleBoxRect } from "@netless/telebox-insider";
3
3
  import type { AppInitState, CursorMovePayload } from "./index";
4
4
  import type { Member } from "./Helper";
5
+ import type { MemberState } from "white-web-sdk";
5
6
 
6
7
  export type RemoveSceneParams = {
7
8
  scenePath: string;
@@ -31,6 +32,7 @@ export type EmitterEvent = {
31
32
  writableChange: boolean;
32
33
  containerSizeRatioUpdate: number;
33
34
  roomMembersChange: Member[];
35
+ memberStateChange: MemberState;
34
36
  };
35
37
 
36
38
  export type EmitterType = Emittery<EmitterEvent>;