@netless/window-manager 0.4.73-beta.1 → 0.4.73

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.4.73-beta.1",
3
+ "version": "0.4.73",
4
4
  "description": "Multi-window mode for Netless Whiteboard",
5
5
  "author": "l1shen <lishen1635@gmail.com> (https://github.com/l1shen)",
6
6
  "license": "MIT",
@@ -13,6 +13,14 @@
13
13
  "docs",
14
14
  "src"
15
15
  ],
16
+ "scripts": {
17
+ "build": "vite build && npm run type-gen",
18
+ "lint": "eslint --ext .ts,.tsx,.svelte . && prettier --check .",
19
+ "predev": "npm run type-gen",
20
+ "prettier": "prettier --write .",
21
+ "test": "vitest",
22
+ "type-gen": "dts src/index.ts -o dist/index.d.ts"
23
+ },
16
24
  "peerDependencies": {
17
25
  "jspdf": "2.5.1",
18
26
  "white-web-sdk": "^2.16.0"
@@ -65,13 +73,5 @@
65
73
  "vite": "^2.9.9",
66
74
  "vitest": "^0.14.1",
67
75
  "white-web-sdk": "2.16.43"
68
- },
69
- "scripts": {
70
- "build": "vite build && npm run type-gen",
71
- "lint": "eslint --ext .ts,.tsx,.svelte . && prettier --check .",
72
- "predev": "npm run type-gen",
73
- "prettier": "prettier --write .",
74
- "test": "vitest",
75
- "type-gen": "dts src/index.ts -o dist/index.d.ts"
76
76
  }
77
- }
77
+ }
@@ -29,7 +29,6 @@ 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
32
  import { callbacks } from "../callback";
34
33
 
35
34
  export class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any, TAppOptions = any>
@@ -92,9 +91,7 @@ export class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any,
92
91
  setTimeout(() => {
93
92
  // 渲染需要时间,延迟 refresh
94
93
  this.getRoom()?.refreshViewSize();
95
- if (WindowManager.supportTeachingAidsPlugin) {
96
- callbacks.emit("onAppViewMounted", { appId: this.appId, view });
97
- }
94
+ callbacks.emit("onAppViewMounted", { appId: this.appId, view });
98
95
  }, 1000);
99
96
  }
100
97
  };
@@ -30,7 +30,6 @@ 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
33
  import { callbacks } from "../callback";
35
34
 
36
35
  export type AppEmitter = Emittery<AppEmitterEvent>;
@@ -196,9 +195,7 @@ export class AppProxy implements PageRemoveService {
196
195
  appRegister.notifyApp(this.kind, "created", { appId, result });
197
196
  this.afterSetupApp(boxInitState);
198
197
  this.fixMobileSize();
199
- if (WindowManager.supportTeachingAidsPlugin) {
200
- callbacks.emit("onAppSetup", appId);
201
- }
198
+ callbacks.emit("onAppSetup", appId);
202
199
  }, SETUP_APP_DELAY);
203
200
  });
204
201
  this.boxManager?.createBox({
@@ -396,9 +393,7 @@ export class AppProxy implements PageRemoveService {
396
393
  private setFocusScenePathHandler = debounce((fullPath: string | undefined) => {
397
394
  if (this.view && fullPath && fullPath !== this.view?.focusScenePath) {
398
395
  setViewFocusScenePath(this.view, fullPath);
399
- if (WindowManager.supportTeachingAidsPlugin) {
400
- callbacks.emit("onAppScenePathChange", { appId: this.id, view: this.view });
401
- }
396
+ callbacks.emit("onAppScenePathChange", { appId: this.id, view: this.view });
402
397
  }
403
398
  }, 50);
404
399
 
package/src/AppManager.ts CHANGED
@@ -384,9 +384,7 @@ export class AppManager {
384
384
  x: payload.x,
385
385
  y: payload.y,
386
386
  });
387
- if (WindowManager.supportTeachingAidsPlugin) {
388
- callbacks.emit("onBoxMove", payload);
389
- }
387
+ callbacks.emit("onBoxMove", payload);
390
388
  };
391
389
 
392
390
  private onBoxResize = (payload: BoxResizePayload) => {
@@ -396,18 +394,13 @@ export class AppManager {
396
394
  width: payload.width,
397
395
  height: payload.height,
398
396
  });
399
- if (WindowManager.supportTeachingAidsPlugin) {
400
- callbacks.emit("onBoxResize", payload);
401
- }
397
+ callbacks.emit("onBoxResize", payload);
402
398
  }
403
399
  };
404
400
 
405
401
  private onBoxFocus = (payload: BoxFocusPayload) => {
406
402
  this.windowManger.safeSetAttributes({ focus: payload.appId });
407
- if (WindowManager.supportTeachingAidsPlugin) {
408
- // (WindowManager.externalNotifyManager as any).emit('onBoxFocus', payload)
409
- callbacks.emit("onBoxFocus", payload);
410
- }
403
+ callbacks.emit("onBoxFocus", payload);
411
404
  };
412
405
 
413
406
  private onBoxClose = (payload: BoxClosePayload) => {
@@ -415,16 +408,12 @@ export class AppManager {
415
408
  if (appProxy) {
416
409
  appProxy.destroy(false, true, true, payload.error);
417
410
  }
418
- if (WindowManager.supportTeachingAidsPlugin) {
419
- callbacks.emit("onBoxClose", payload);
420
- }
411
+ callbacks.emit("onBoxClose", payload);
421
412
  };
422
413
 
423
414
  private onBoxStateChange = (payload: BoxStateChangePayload) => {
424
415
  this.dispatchInternalEvent(Events.AppBoxStateChange, payload);
425
- if (WindowManager.supportTeachingAidsPlugin) {
426
- callbacks.emit("onBoxStateChange", payload);
427
- }
416
+ callbacks.emit("onBoxStateChange", payload);
428
417
  };
429
418
 
430
419
  public addAppsChangeListener = () => {
@@ -608,9 +597,7 @@ export class AppManager {
608
597
  this.setMainViewFocusPath();
609
598
  }
610
599
  internalEmitter.emit("mainViewMounted");
611
- if (WindowManager.supportTeachingAidsPlugin) {
612
- callbacks.emit("onMainViewMounted", mainView);
613
- }
600
+ callbacks.emit("onMainViewMounted", mainView);
614
601
  }
615
602
 
616
603
  public setMainViewFocusPath(scenePath?: string) {
@@ -2,6 +2,7 @@
2
2
  import { isEmpty } from "lodash";
3
3
  import { ApplianceNames } from "white-web-sdk";
4
4
 
5
+ export let uid: string;
5
6
  export let cursorName: string;
6
7
  export let tagName: string | undefined;
7
8
  export let backgroundColor: string;
@@ -21,7 +22,7 @@
21
22
  $: hasName = !isEmpty(cursorName);
22
23
  $: hasTagName = !isEmpty(tagName);
23
24
  $: hasAvatar = !isEmpty(avatar);
24
- $: display = visible ? "initial" : "none";
25
+ $: display = visible ? "" : "none";
25
26
  $: isLaserPointer = appliance === ApplianceNames.laserPointer;
26
27
  $: isLaserPointerPencilEraser = isLaserPointer || appliance === ApplianceNames.pencilEraser;
27
28
  $: offset = isLaserPointerPencilEraser ? "netless-window-manager-laserPointer-pencilEraser-offset" : "";
@@ -43,6 +44,7 @@
43
44
  <div
44
45
  class={"netless-window-manager-cursor-mid" + (custom ? " netless-window-manager-cursor-custom" : "")}
45
46
  style="transform: translateX({x}px) translateY({y}px);display: {display}"
47
+ data-cursor-uid={uid}
46
48
  >
47
49
  {#if !isLaserPointer}
48
50
  <div class="netless-window-manager-cursor-name {offset} {pencilEraserSize3ImageOffset}">
@@ -164,6 +164,7 @@ export class Cursor {
164
164
 
165
165
  private initProps() {
166
166
  return {
167
+ uid: this.memberId,
167
168
  x: 0,
168
169
  y: 0,
169
170
  appliance: this.memberApplianceName as string,
@@ -169,7 +169,7 @@ export class CursorManager {
169
169
  if (now - this.mouseMoveTimer > 48) {
170
170
  this.mouseMoveTimer = now;
171
171
  if (
172
- WindowManager.supportTeachingAidsPlugin &&
172
+ WindowManager.supportAppliancePlugin &&
173
173
  isRoom(WindowManager.displayer) &&
174
174
  (WindowManager.displayer as Room).disableDeviceInputs
175
175
  ) {
@@ -9,7 +9,6 @@ import { SideEffectManager } from "side-effect-manager";
9
9
  import type { Camera, Room, Size, View } from "white-web-sdk";
10
10
  import type { AppManager } from "../AppManager";
11
11
  import { Events } from "../constants";
12
- import { WindowManager } from "..";
13
12
 
14
13
  export class MainViewProxy {
15
14
  /** Refresh the view's camera in an interval of 1.5s. */
@@ -187,9 +186,7 @@ export class MainViewProxy {
187
186
  this.mainView.divElement = divElement;
188
187
  this.addMainViewListener();
189
188
  this.start();
190
- if (WindowManager.supportTeachingAidsPlugin) {
191
- callbacks.emit("onMainViewRebind", this.mainView);
192
- }
189
+ callbacks.emit("onMainViewRebind", this.mainView);
193
190
  }
194
191
 
195
192
  private onCameraUpdatedByDevice = (camera: Camera) => {
package/src/index.ts CHANGED
@@ -153,7 +153,7 @@ export type MountParams = {
153
153
  applianceIcons?: ApplianceIcons;
154
154
  fullscreen?: boolean;
155
155
  polling?: boolean;
156
- supportTeachingAidsPlugin?: boolean;
156
+ supportAppliancePlugin?: boolean;
157
157
  };
158
158
 
159
159
  export const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
@@ -170,7 +170,7 @@ export class WindowManager
170
170
  public static container?: HTMLElement;
171
171
  public static debug = false;
172
172
  public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
173
- public static supportTeachingAidsPlugin?: boolean;
173
+ public static supportAppliancePlugin?: boolean;
174
174
  private static isCreated = false;
175
175
  private static _resolve = (_manager: WindowManager) => void 0;
176
176
 
@@ -187,6 +187,8 @@ export class WindowManager
187
187
  public isReplay = isPlayer(this.displayer);
188
188
  private _pageState?: PageStateImpl;
189
189
  private _fullscreen?: boolean;
190
+ private _cursorUIDs: string[] = [];
191
+ private _cursorUIDsStyleDOM?: HTMLStyleElement;
190
192
 
191
193
  private boxManager?: BoxManager;
192
194
  private static params?: MountParams;
@@ -207,7 +209,7 @@ export class WindowManager
207
209
  public static async mount(params: MountParams): Promise<WindowManager> {
208
210
  const room = params.room;
209
211
  WindowManager.container = params.container;
210
- WindowManager.supportTeachingAidsPlugin = params.supportTeachingAidsPlugin;
212
+ WindowManager.supportAppliancePlugin = params.supportAppliancePlugin;
211
213
  const containerSizeRatio = params.containerSizeRatio;
212
214
  const debug = params.debug;
213
215
 
@@ -691,6 +693,27 @@ export class WindowManager
691
693
  }
692
694
  }
693
695
 
696
+ public get cursorUIDs(): string[] {
697
+ return this._cursorUIDs;
698
+ }
699
+
700
+ public setCursorUIDs(cursorUIDs?: string[] | null): void {
701
+ this._cursorUIDs = cursorUIDs || [];
702
+ if (this._cursorUIDs.length === 0) {
703
+ this._cursorUIDsStyleDOM?.remove();
704
+ } else {
705
+ if (!this._cursorUIDsStyleDOM) {
706
+ this._cursorUIDsStyleDOM = document.createElement("style");
707
+ }
708
+ WindowManager.playground?.appendChild(this._cursorUIDsStyleDOM);
709
+ let style = "[data-cursor-uid] { display: none }";
710
+ for (const uid of this._cursorUIDs) {
711
+ style += `\n[data-cursor-uid="${uid}"] { display: flex }`;
712
+ }
713
+ this._cursorUIDsStyleDOM.textContent = style;
714
+ }
715
+ }
716
+
694
717
  public get mainView(): View {
695
718
  if (this.appManager) {
696
719
  return this.appManager.mainViewProxy.view;