@netless/window-manager 1.0.0-canary.4 → 1.0.0-canary.7

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.4",
3
+ "version": "1.0.0-canary.7",
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.12",
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.12
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.12
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.12:
101
- resolution: {integrity: sha512-ggNdnZLvSnqybl8vFRbKgp6qqN7oVJPsnTq3rkucGwPjQMimTpqIr26y4on1VIJEjbqCf/yf1irp08ghXCVJqQ==}
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
@@ -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,37 @@ 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
+ this.camera$.setValue(toJS(this.appAttributes.camera));
144
+ }
145
+ if (!this.size$.value && box.contentStageRect) {
146
+ this.storeSize({
147
+ id: this.uid,
148
+ width: box.contentStageRect?.width,
149
+ height: box.contentStageRect?.height,
150
+ });
151
+ this.size$.setValue(toJS(this.appAttributes.size));
152
+ }
153
+ this.appViewSync = new AppViewSync(this);
154
+ this.sideEffectManager.add(() => () => this.appViewSync?.destroy());
142
155
  }
143
156
  });
157
+ this.sideEffectManager.add(() => emitter.on("memberStateChange", memberState => {
158
+ // clicker 教具把事件穿透给下层
159
+ const needPointerEventsNone = memberState.currentApplianceName === "clicker";
160
+ if (needPointerEventsNone) {
161
+ if (this.appContext?._viewWrapper) {
162
+ this.appContext._viewWrapper.style.pointerEvents = "none";
163
+ }
164
+ } else {
165
+ if (this.appContext?._viewWrapper) {
166
+ this.appContext._viewWrapper.style.pointerEvents = "auto";
167
+ }
168
+ }
169
+ }));
144
170
  }
145
171
 
146
172
  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
+ this.sem.add(() => 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>;
@@ -7,8 +7,8 @@ import type { ISize } from "../AttributesDelegate";
7
7
  export type SaveCamera = (camera: Camera) => void;
8
8
 
9
9
  export class CameraSynchronizer {
10
- protected remoteCamera?: Camera;
11
- protected remoteSize?: ISize;
10
+ public remoteCamera?: Camera;
11
+ public remoteSize?: ISize;
12
12
  protected rect?: TeleBoxRect;
13
13
  protected view?: View;
14
14
 
@@ -64,7 +64,6 @@ export class CameraSynchronizer {
64
64
  scale = this.rect.height / size.height;
65
65
  }
66
66
  const nextScale = this.view.camera.scale / scale;
67
- console.log("onLocalSizeUpdate", nextScale.toFixed(3), scale.toFixed(3));
68
67
  this.view.moveCamera({
69
68
  scale: nextScale,
70
69
  animationMode: AnimationMode.Immediately