@netless/window-manager 0.4.70 → 0.4.71-beta.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/dist/typings.d.ts CHANGED
@@ -78,3 +78,7 @@ export type { SceneState, SceneDefinition, View, AnimationMode, Displayer, Room,
78
78
  export type { Storage, StorageStateChangedEvent, StorageStateChangedListener } from "./App/Storage";
79
79
  export * from "./Page";
80
80
  export * from "./Utils/error";
81
+ export declare type AppPayload = {
82
+ appId: string;
83
+ view: View;
84
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "0.4.70",
3
+ "version": "0.4.71-beta.0",
4
4
  "description": "Multi-window mode for Netless Whiteboard",
5
5
  "author": "l1shen <lishen1635@gmail.com> (https://github.com/l1shen)",
6
6
  "license": "MIT",
@@ -29,6 +29,8 @@ import type {
29
29
  } from "./MagixEvent";
30
30
  import type { AddPageParams, PageController, PageState } from "../Page";
31
31
  import { internalEmitter } from "../InternalEmitter";
32
+ import { WindowManager } from "../index";
33
+ import { callbacks } from "../callback";
32
34
 
33
35
  export class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any, TAppOptions = any>
34
36
  implements PageController
@@ -90,6 +92,9 @@ export class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any,
90
92
  setTimeout(() => {
91
93
  // 渲染需要时间,延迟 refresh
92
94
  this.getRoom()?.refreshViewSize();
95
+ if (WindowManager.supportTeachingAidsPlugin) {
96
+ callbacks.emit("onAppViewMounted", {appId: this.appId, view});
97
+ }
93
98
  }, 1000);
94
99
  }
95
100
  };
@@ -30,6 +30,8 @@ import type { ReadonlyTeleBox } from "@netless/telebox-insider";
30
30
  import type { PageRemoveService, PageState } from "../Page";
31
31
  import { calculateNextIndex } from "../Page";
32
32
  import { boxEmitter } from "../BoxEmitter";
33
+ import { WindowManager } from "../index";
34
+ import { callbacks } from "../callback";
33
35
 
34
36
  export type AppEmitter = Emittery<AppEmitterEvent>;
35
37
 
@@ -194,6 +196,9 @@ export class AppProxy implements PageRemoveService {
194
196
  appRegister.notifyApp(this.kind, "created", { appId, result });
195
197
  this.afterSetupApp(boxInitState);
196
198
  this.fixMobileSize();
199
+ if (WindowManager.supportTeachingAidsPlugin) {
200
+ callbacks.emit("onAppSetup", appId);
201
+ }
197
202
  }, SETUP_APP_DELAY);
198
203
  });
199
204
  this.boxManager?.createBox({
@@ -391,6 +396,9 @@ export class AppProxy implements PageRemoveService {
391
396
  private setFocusScenePathHandler = debounce((fullPath: string | undefined) => {
392
397
  if (this.view && fullPath && fullPath !== this.view?.focusScenePath) {
393
398
  setViewFocusScenePath(this.view, fullPath);
399
+ if (WindowManager.supportTeachingAidsPlugin) {
400
+ callbacks.emit("onAppScenePathChange", {appId: this.id, view:this.view});
401
+ }
394
402
  }
395
403
  }, 50);
396
404
 
package/src/AppManager.ts CHANGED
@@ -373,6 +373,9 @@ export class AppManager {
373
373
  x: payload.x,
374
374
  y: payload.y,
375
375
  });
376
+ if (WindowManager.supportTeachingAidsPlugin) {
377
+ callbacks.emit("onBoxMove", payload);
378
+ }
376
379
  };
377
380
 
378
381
  private onBoxResize = (payload: BoxResizePayload) => {
@@ -382,11 +385,18 @@ export class AppManager {
382
385
  width: payload.width,
383
386
  height: payload.height,
384
387
  });
388
+ if (WindowManager.supportTeachingAidsPlugin) {
389
+ callbacks.emit("onBoxResize", payload);
390
+ }
385
391
  }
386
392
  };
387
393
 
388
394
  private onBoxFocus = (payload: BoxFocusPayload) => {
389
395
  this.windowManger.safeSetAttributes({ focus: payload.appId });
396
+ if (WindowManager.supportTeachingAidsPlugin) {
397
+ // (WindowManager.externalNotifyManager as any).emit('onBoxFocus', payload)
398
+ callbacks.emit("onBoxFocus", payload);
399
+ }
390
400
  };
391
401
 
392
402
  private onBoxClose = (payload: BoxClosePayload) => {
@@ -394,10 +404,16 @@ export class AppManager {
394
404
  if (appProxy) {
395
405
  appProxy.destroy(false, true, true, payload.error);
396
406
  }
407
+ if (WindowManager.supportTeachingAidsPlugin) {
408
+ callbacks.emit("onBoxClose", payload);
409
+ }
397
410
  };
398
411
 
399
412
  private onBoxStateChange = (payload: BoxStateChangePayload) => {
400
413
  this.dispatchInternalEvent(Events.AppBoxStateChange, payload);
414
+ if (WindowManager.supportTeachingAidsPlugin) {
415
+ callbacks.emit("onBoxStateChange", payload);
416
+ }
401
417
  };
402
418
 
403
419
  public addAppsChangeListener = () => {
@@ -581,6 +597,9 @@ export class AppManager {
581
597
  this.setMainViewFocusPath();
582
598
  }
583
599
  internalEmitter.emit("mainViewMounted");
600
+ if (WindowManager.supportTeachingAidsPlugin) {
601
+ callbacks.emit("onMainViewMounted", mainView);
602
+ }
584
603
  }
585
604
 
586
605
  public setMainViewFocusPath(scenePath?: string) {
@@ -1,4 +1,4 @@
1
- import { ApplianceNames } from "white-web-sdk";
1
+ import { ApplianceNames, isRoom } from "white-web-sdk";
2
2
  import { Cursor } from "./Cursor";
3
3
  import { CursorState, Events } from "../constants";
4
4
  import { internalEmitter } from "../InternalEmitter";
@@ -6,7 +6,7 @@ import { SideEffectManager } from "side-effect-manager";
6
6
  import { WindowManager } from "../index";
7
7
  import type { CursorMovePayload, ApplianceIcons } from "../index";
8
8
  import type { PositionType } from "../AttributesDelegate";
9
- import type { Point, RoomMember, View } from "white-web-sdk";
9
+ import type { Point, Room, RoomMember, View } from "white-web-sdk";
10
10
  import type { AppManager } from "../AppManager";
11
11
  import { ApplianceMap } from "./icons";
12
12
  import { findMemberByUid } from "../Helper";
@@ -31,6 +31,8 @@ export class CursorManager {
31
31
  private sideEffectManager = new SideEffectManager();
32
32
  private store = this.manager.store;
33
33
  public applianceIcons: ApplianceIcons = ApplianceMap;
34
+ private onceCount = true;
35
+
34
36
 
35
37
  constructor(private manager: AppManager, private enableCursor: boolean, applianceIcons?: ApplianceIcons) {
36
38
  this.roomMembers = this.manager.room?.state.roomMembers;
@@ -115,14 +117,24 @@ export class CursorManager {
115
117
  private mouseMoveListener = (event: PointerEvent) => {
116
118
  const isTouch = event.pointerType === "touch";
117
119
  if (isTouch && !event.isPrimary) return;
118
-
119
120
  const now = Date.now()
120
121
  if (now - this.mouseMoveTimer > 48) {
121
122
  this.mouseMoveTimer = now;
123
+ if (WindowManager.supportTeachingAidsPlugin && isRoom(WindowManager.displayer) && (WindowManager.displayer as Room).disableDeviceInputs) {
124
+ if(this.onceCount){
125
+ this.manager.dispatchInternalEvent(Events.CursorMove, {
126
+ uid: this.manager.uid,
127
+ state: CursorState.Leave
128
+ } as CursorMovePayload);
129
+ this.onceCount = false;
130
+ }
131
+ return ;
132
+ }
122
133
  this.mouseMoveListener_(event, isTouch);
134
+ this.onceCount = true;
123
135
  }
124
136
  }
125
-
137
+
126
138
  private mouseLeaveListener = () => {
127
139
  this.hideCursor(this.manager.uid);
128
140
  }
package/src/callback.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import Emittery from "emittery";
2
2
  import type { TeleBoxColorScheme, TELE_BOX_STATE } from "@netless/telebox-insider";
3
- import type { CameraState, SceneState, ViewVisionMode } from "white-web-sdk";
3
+ import type { CameraState, SceneState, View, ViewVisionMode } from "white-web-sdk";
4
4
  import type { LoadAppEvent } from "./Register";
5
5
  import type { PageState } from "./Page";
6
+ import type { BoxClosePayload, BoxFocusPayload, BoxMovePayload, BoxResizePayload, BoxStateChangePayload } from "./BoxEmitter";
7
+ import type { AppPayload } from "./typings";
6
8
 
7
9
  export type PublicEvent = {
8
10
  mainViewModeChange: ViewVisionMode;
@@ -22,6 +24,15 @@ export type PublicEvent = {
22
24
  pageStateChange: PageState;
23
25
  fullscreenChange: boolean;
24
26
  appsChange: string[]; // APP 列表变化时触发
27
+ onBoxMove: BoxMovePayload;
28
+ onBoxResize: BoxResizePayload;
29
+ onBoxFocus: BoxFocusPayload;
30
+ onBoxClose: BoxClosePayload;
31
+ onBoxStateChange: BoxStateChangePayload;
32
+ onMainViewMounted: View;
33
+ onAppViewMounted: AppPayload;
34
+ onAppSetup: string;
35
+ onAppScenePathChange: AppPayload;
25
36
  };
26
37
 
27
38
  export type CallbacksType = Emittery<PublicEvent>;
package/src/index.ts CHANGED
@@ -143,6 +143,7 @@ export type MountParams = {
143
143
  applianceIcons?: ApplianceIcons;
144
144
  fullscreen?: boolean;
145
145
  polling?: boolean;
146
+ supportTeachingAidsPlugin?: boolean;
146
147
  };
147
148
 
148
149
  export const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
@@ -156,6 +157,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
156
157
  public static container?: HTMLElement;
157
158
  public static debug = false;
158
159
  public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
160
+ public static supportTeachingAidsPlugin?: boolean;
159
161
  private static isCreated = false;
160
162
 
161
163
  public version = __APP_VERSION__;
@@ -187,6 +189,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
187
189
  public static async mount(params: MountParams): Promise<WindowManager> {
188
190
  const room = params.room;
189
191
  WindowManager.container = params.container;
192
+ WindowManager.supportTeachingAidsPlugin = params.supportTeachingAidsPlugin;
190
193
  const containerSizeRatio = params.containerSizeRatio;
191
194
  const debug = params.debug;
192
195
 
@@ -367,7 +370,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
367
370
  this.appManager?.resetMaximized();
368
371
  this.appManager?.resetMinimized();
369
372
  this.appManager?.displayerWritableListener(!this.room.isWritable);
370
- WindowManager.container = container;
373
+ WindowManager.container = container;
371
374
  }
372
375
 
373
376
  public bindCollectorContainer(container: HTMLElement) {
package/src/typings.ts CHANGED
@@ -88,3 +88,8 @@ export type { SceneState, SceneDefinition, View, AnimationMode, Displayer, Room,
88
88
  export type { Storage, StorageStateChangedEvent, StorageStateChangedListener } from "./App/Storage";
89
89
  export * from "./Page";
90
90
  export * from "./Utils/error";
91
+
92
+ export type AppPayload = {
93
+ appId: string,
94
+ view: View
95
+ }