@netless/window-manager 1.0.7-beta.2 → 1.0.7-beta.4

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.7-beta.2",
3
+ "version": "1.0.7-beta.4",
4
4
  "description": "Multi-window mode for Netless Whiteboard",
5
5
  "author": "l1shen <lishen1635@gmail.com> (https://github.com/l1shen)",
6
6
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@juggle/resize-observer": "^3.3.1",
35
- "@netless/telebox-insider": "0.3.0-beta.9",
35
+ "@netless/telebox-insider": "0.3.0-beta.10",
36
36
  "emittery": "^0.9.2",
37
37
  "lodash": "^4.17.21",
38
38
  "p-retry": "^4.6.1",
@@ -27,7 +27,8 @@ import { WindowManager } from "../index";
27
27
  import type { SceneState, View, SceneDefinition } from "white-web-sdk";
28
28
  import type { AppManager } from "../AppManager";
29
29
  import type { NetlessApp } from "../typings";
30
- import { TELE_BOX_STATE, type ReadonlyTeleBox, type TeleBoxState } from "@netless/telebox-insider";
30
+ import { TELE_BOX_STATE } from "@netless/telebox-insider";
31
+ import type { ReadonlyTeleBox, TeleBoxState } from "@netless/telebox-insider";
31
32
  import type { PageRemoveService, PageState } from "../Page";
32
33
  import { calculateNextIndex } from "../Page";
33
34
  import { boxEmitter } from "../BoxEmitter";
@@ -179,7 +180,8 @@ export class AppProxy implements PageRemoveService {
179
180
  if (!this.boxManager) {
180
181
  throw new BoxManagerNotFoundError();
181
182
  }
182
- const context = new AppContext(this.manager, this.boxManager, appId, this, appOptions);
183
+ const AppContextClass = getExtendClass(AppContext, WindowManager.extendClass);
184
+ const context = new AppContextClass(this.manager, this.boxManager, appId, this, appOptions);
183
185
  this.appContext = context;
184
186
  try {
185
187
  internalEmitter.once(`${appId}${Events.WindowCreated}` as any).then(async () => {
@@ -216,7 +218,7 @@ export class AppProxy implements PageRemoveService {
216
218
  options,
217
219
  canOperate: this.manager.canOperate,
218
220
  smartPosition: this.isAddApp,
219
- boxStatus
221
+ boxStatus,
220
222
  });
221
223
  if (this.isAddApp && this.box) {
222
224
  if (boxStatus) {
@@ -308,8 +310,7 @@ export class AppProxy implements PageRemoveService {
308
310
  const maximized = this.attributes?.["maximized"];
309
311
  const minimized = this.attributes?.["minimized"];
310
312
  const boxStatus = this.store.getBoxStatus(id) ?? undefined;
311
- const lastNotMinimizedBoxStatus =
312
- this.store.getLastNotMinimizedBoxStatus(id) ?? undefined;
313
+ const lastNotMinimizedBoxStatus = this.store.getLastNotMinimizedBoxStatus(id) ?? undefined;
313
314
  const zIndex = attrs?.zIndex;
314
315
  let payload = { maximized, minimized, zIndex } as AppInitState;
315
316
  if (position) {
package/src/AppManager.ts CHANGED
@@ -7,9 +7,10 @@ import { autorun, isPlayer, isRoom, ScenePathType, UpdateEventKind } from "white
7
7
  import { boxEmitter } from "./BoxEmitter";
8
8
  import { calculateNextIndex } from "./Page";
9
9
  import { callbacks } from "./callback";
10
- import { debounce, get, isEqual, isInteger, orderBy } from "lodash";
10
+ import { debounce, get, isInteger, orderBy } from "lodash";
11
11
  import { internalEmitter } from "./InternalEmitter";
12
- import { AttributesDelegate, createAttributesDelegate, Fields } from "./AttributesDelegate";
12
+ import { createAttributesDelegate, Fields } from "./AttributesDelegate";
13
+ import type { AttributesDelegate } from "./AttributesDelegate";
13
14
  import { log } from "./Utils/log";
14
15
  import { MainViewProxy } from "./View/MainView";
15
16
  import { safeListenPropsUpdated } from "./Utils/Reactive";
@@ -434,7 +435,7 @@ export class AppManager {
434
435
 
435
436
  private onBoxBlurred = (payload: BoxBlurredPayload) => {
436
437
  const focus = this.attributes.focus;
437
- if (focus === payload.appId) {
438
+ if (focus === payload.appId) {
438
439
  this.windowManger.safeSetAttributes({ focus: undefined });
439
440
  callbacks.emit("onBoxBlurred", payload);
440
441
  }
@@ -458,8 +459,6 @@ export class AppManager {
458
459
  return safeListenPropsUpdated(
459
460
  () => this.attributes.boxesStatus,
460
461
  () => {
461
- const currentBoxesStatus = this.boxManager?.teleBoxManager.boxesStatus;
462
- console.log("boxesStatus===>autorun", isEqual(Object.entries(this.attributes.boxesStatus), [...(currentBoxesStatus?.entries() ?? [])]), Object.entries(this.attributes.boxesStatus), [...(currentBoxesStatus?.entries() ?? [])])
463
462
  this.boxManager?.setBoxesStatus(this.attributes.boxesStatus);
464
463
  }
465
464
  );
@@ -468,9 +467,9 @@ export class AppManager {
468
467
  return safeListenPropsUpdated(
469
468
  () => this.attributes.lastNotMinimizedBoxesStatus,
470
469
  () => {
471
- const currentLastNotMinimizedBoxesStatus = this.boxManager?.teleBoxManager.lastNotMinimizedBoxesStatus;
472
- console.log("lastNotMinimizedBoxesStatus===>autorun", isEqual(Object.entries(this.attributes.lastNotMinimizedBoxesStatus), [...(currentLastNotMinimizedBoxesStatus?.entries() ?? [])]), Object.entries(this.attributes.lastNotMinimizedBoxesStatus), [...(currentLastNotMinimizedBoxesStatus?.entries() ?? [])])
473
- this.boxManager?.setLastNotMinimizedBoxesStatus(this.attributes.lastNotMinimizedBoxesStatus);
470
+ this.boxManager?.setLastNotMinimizedBoxesStatus(
471
+ this.attributes.lastNotMinimizedBoxesStatus
472
+ );
474
473
  }
475
474
  );
476
475
  });
@@ -708,12 +707,6 @@ export class AppManager {
708
707
  const attrs = params.attributes ?? {};
709
708
  this.safeUpdateAttributes([appId], attrs);
710
709
  this.store.setupAppAttributes(params, appId, isDynamicPPT);
711
- // if (this.useBoxesStatus){
712
- // // todo: 这里需要优化
713
- // // if(!this.store.getLastNotMinimizedBoxesStatus()){
714
- // // this.store.setLastNotMinimizedBoxesStatus({});
715
- // // }
716
- // }
717
710
  const needFocus = !this.boxManager?.minimized;
718
711
  if (needFocus) {
719
712
  this.store.setAppFocus(appId, true);
@@ -4,8 +4,10 @@ import { setViewFocusScenePath } from "./Utils/Common";
4
4
  import type { AddAppParams, AppSyncAttributes } from "./index";
5
5
  import type { Camera, Size, View } from "white-web-sdk";
6
6
  import type { Cursor } from "./Cursor/Cursor";
7
- import { ExtendClass, getExtendClass } from "./Utils/extendClass";
8
- import { NotMinimizedBoxState, TELE_BOX_STATE, TeleBoxState } from "@netless/telebox-insider";
7
+ import { getExtendClass } from "./Utils/extendClass";
8
+ import type { TELE_BOX_STATE } from "@netless/telebox-insider";
9
+ import type { ExtendClass } from "./Utils/extendClass";
10
+ import type { NotMinimizedBoxState, TeleBoxState } from "@netless/telebox-insider";
9
11
 
10
12
  export enum Fields {
11
13
  Apps = "apps",
package/src/BoxManager.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AppAttributes, Events, MIN_HEIGHT, MIN_WIDTH } from "./constants";
2
2
  import { debounce } from "lodash";
3
- import { TELE_BOX_STATE, TeleBoxCollector, TeleBoxManager } from "@netless/telebox-insider";
3
+ import { TELE_BOX_STATE } from "@netless/telebox-insider";
4
4
  import { WindowManager } from "./index";
5
5
  import type { BoxEmitterType } from "./BoxEmitter";
6
6
  import type { AddAppOptions, AppInitState } from "./index";
@@ -20,7 +20,7 @@ import type { NetlessApp } from "./typings";
20
20
  import type { View } from "white-web-sdk";
21
21
  import type { CallbacksType } from "./callback";
22
22
  import type { EmitterType } from "./InternalEmitter";
23
- import { getExtendClass } from "./Utils/extendClass";
23
+ import { getExtendClass, TeleBoxManager, TeleBoxCollector } from "./Utils/extendClass";
24
24
 
25
25
  export { TELE_BOX_STATE };
26
26
 
@@ -179,7 +179,6 @@ export class BoxManager {
179
179
  this.teleBoxManager.events.on("focused", box => {
180
180
  if (box) {
181
181
  if (this.canOperate) {
182
- console.log("focused===>focused", box.id, box.zIndex)
183
182
  boxEmitter.emit("focus", { appId: box.id });
184
183
  } else {
185
184
  this.teleBoxManager.blurBox(box.id);
@@ -189,7 +188,6 @@ export class BoxManager {
189
188
  this.teleBoxManager.events.on("blurred", box => {
190
189
  if (box) {
191
190
  if (this.canOperate) {
192
- console.log("focused===>blurred", box.id, box.zIndex)
193
191
  boxEmitter.emit("blurred", { appId: box.id });
194
192
  }
195
193
  }
@@ -273,7 +271,6 @@ export class BoxManager {
273
271
  id: params.appId,
274
272
  boxStatus: params.boxStatus,
275
273
  };
276
- console.log("createBox===>", createBoxConfig.id, params.boxStatus)
277
274
  this.teleBoxManager.create(createBoxConfig, params.smartPosition);
278
275
  this.context.emitter.emit(`${params.appId}${Events.WindowCreated}` as any);
279
276
  }
@@ -301,7 +298,10 @@ export class BoxManager {
301
298
  }
302
299
 
303
300
  public setLastNotMinimizedBoxesStatus(status?: Record<string, NotMinimizedBoxState>): void {
304
- this.teleBoxManager.setLastNotMinimizedBoxesStatus(new Map(Object.entries(status ?? {})), true);
301
+ this.teleBoxManager.setLastNotMinimizedBoxesStatus(
302
+ new Map(Object.entries(status ?? {})),
303
+ true
304
+ );
305
305
  }
306
306
 
307
307
  public setLastNotMinimizedBoxStatus(appId: string, status?: NotMinimizedBoxState): void {
@@ -326,7 +326,8 @@ export class BoxManager {
326
326
  useBoxesStatus: createTeleBoxManagerConfig?.useBoxesStatus || false,
327
327
  };
328
328
 
329
- const manager = new TeleBoxManager(initManagerState);
329
+ const TeleBoxManagerClass = getExtendClass(TeleBoxManager, WindowManager.extendClass);
330
+ const manager = new TeleBoxManagerClass(initManagerState);
330
331
  if (this.teleBoxManager) {
331
332
  this.teleBoxManager.destroy();
332
333
  }
@@ -339,7 +340,8 @@ export class BoxManager {
339
340
  }
340
341
 
341
342
  public setCollectorContainer(container: HTMLElement) {
342
- const collector = new TeleBoxCollector({
343
+ const TeleBoxCollectorClass = getExtendClass(TeleBoxCollector, WindowManager.extendClass);
344
+ const collector = new TeleBoxCollectorClass({
343
345
  styles: this.createTeleBoxManagerConfig?.collectorStyles,
344
346
  }).mount(container);
345
347
  this.teleBoxManager.setCollector(collector);
@@ -1,15 +1,26 @@
1
- import { AppProxy } from "../App";
1
+ import { AppContext, AppProxy } from "../App";
2
2
  import { AppManager } from "../AppManager";
3
3
  import { AttributesDelegate } from "../AttributesDelegate";
4
4
  import { BoxManager } from "../BoxManager";
5
5
  import { CursorManager } from "../Cursor";
6
+ import { TeleBoxManager, TeleBoxCollector } from "@netless/telebox-insider";
7
+
8
+ export { AppManager } from "../AppManager";
9
+ export { AppContext, AppProxy } from "../App";
10
+ export { BoxManager } from "../BoxManager";
11
+ export { AttributesDelegate } from "../AttributesDelegate";
12
+ export { CursorManager } from "../Cursor";
13
+ export { TeleBoxManager, TeleBoxCollector } from "@netless/telebox-insider";
6
14
 
7
15
  export type ExtendClassAble =
8
16
  | typeof AppManager
17
+ | typeof AppProxy
18
+ | typeof AppContext
9
19
  | typeof BoxManager
10
20
  | typeof AttributesDelegate
11
21
  | typeof CursorManager
12
- | typeof AppProxy;
22
+ | typeof TeleBoxManager
23
+ | typeof TeleBoxCollector;
13
24
 
14
25
  export type ExtendClass = {
15
26
  AppManager?: typeof AppManager;
@@ -17,12 +28,15 @@ export type ExtendClass = {
17
28
  AttributesDelegate?: typeof AttributesDelegate;
18
29
  CursorManager?: typeof CursorManager;
19
30
  AppProxy?: typeof AppProxy;
31
+ AppContext?: typeof AppContext;
32
+ TeleBoxManager?: typeof TeleBoxManager;
33
+ TeleBoxCollector?: typeof TeleBoxCollector;
20
34
  };
21
35
  export function getExtendClass<T extends ExtendClassAble>(
22
36
  baseClass: T,
23
37
  extendClass?: ExtendClass
24
38
  ): T {
25
- switch (baseClass.constructor.name) {
39
+ switch (baseClass.name) {
26
40
  case "AppManager":
27
41
  return (extendClass?.AppManager || AppManager) as T;
28
42
  case "BoxManager":
@@ -33,6 +47,12 @@ export function getExtendClass<T extends ExtendClassAble>(
33
47
  return (extendClass?.CursorManager || CursorManager) as T;
34
48
  case "AppProxy":
35
49
  return (extendClass?.AppProxy || AppProxy) as T;
50
+ case "AppContext":
51
+ return (extendClass?.AppContext || AppContext) as T;
52
+ case "TeleBoxManager":
53
+ return (extendClass?.TeleBoxManager || TeleBoxManager) as T;
54
+ case "TeleBoxCollector":
55
+ return (extendClass?.TeleBoxCollector || TeleBoxCollector) as T;
36
56
  default:
37
57
  return baseClass;
38
58
  }
package/src/index.ts CHANGED
@@ -28,9 +28,10 @@ import {
28
28
  putScenes,
29
29
  wait,
30
30
  } from "./Utils/Common";
31
- import { TELE_BOX_STATE, BoxManager } from "./BoxManager";
31
+ import type { BoxManager } from "./BoxManager";
32
+ import type { TELE_BOX_STATE } from "./BoxManager";
32
33
  import * as Errors from "./Utils/error";
33
- import { Apps, Position } from "./AttributesDelegate";
34
+ import type { Apps, Position } from "./AttributesDelegate";
34
35
  import type {
35
36
  Displayer,
36
37
  SceneDefinition,
@@ -54,7 +55,7 @@ import type {
54
55
  TeleBoxColorScheme,
55
56
  TeleBoxState,
56
57
  } from "@netless/telebox-insider";
57
- import { AppProxy } from "./App";
58
+ import type { AppProxy } from "./App";
58
59
  import type { PublicEvent } from "./callback";
59
60
  import type Emittery from "emittery";
60
61
  import type { PageController, AddPageParams, PageState } from "./Page";
@@ -63,8 +64,10 @@ import { IframeBridge } from "./View/IframeBridge";
63
64
  import { setOptions } from "@netless/app-media-player";
64
65
  import type { ExtendPluginInstance } from "./ExtendPluginManager";
65
66
  import { ExtendPluginManager } from "./ExtendPluginManager";
66
- import { ExtendClass, getExtendClass } from "./Utils/extendClass";
67
- export * from "./View/IframeBridge";
67
+ import { getExtendClass } from "./Utils/extendClass";
68
+ import type { ExtendClass } from "./Utils/extendClass";
69
+
70
+ export * from "./utils/extendClass";
68
71
 
69
72
  export type WindowMangerAttributes = {
70
73
  modelValue?: string;
@@ -166,7 +169,7 @@ export type MountParams = {
166
169
  fullscreen?: boolean;
167
170
  polling?: boolean;
168
171
  supportAppliancePlugin?: boolean;
169
- /** 是否使用 boxesStatus 状态 */
172
+ /** 是否使用 boxesStatus 状态管理窗口 */
170
173
  useBoxesStatus?: boolean;
171
174
  };
172
175
 
@@ -394,7 +397,6 @@ export class WindowManager
394
397
  if (this.appManager) {
395
398
  this.appManager.useBoxesStatus = params.useBoxesStatus || false;
396
399
  this.appManager.setBoxManager(boxManager);
397
-
398
400
  }
399
401
  this.bindMainView(mainViewElement, params.disableCameraTransform);
400
402
  if (WindowManager.wrapper) {