@netless/window-manager 1.0.15 → 1.0.16

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.15",
3
+ "version": "1.0.16",
4
4
  "description": "Multi-window mode for Netless Whiteboard",
5
5
  "author": "l1shen <lishen1635@gmail.com> (https://github.com/l1shen)",
6
6
  "license": "MIT",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "peerDependencies": {
25
25
  "jspdf": "2.5.1",
26
- "white-web-sdk": "^2.16.54"
26
+ "white-web-sdk": "^2.16.55"
27
27
  },
28
28
  "peerDependenciesMeta": {
29
29
  "jspdf": {
@@ -73,6 +73,6 @@
73
73
  "typescript": "^4.5.5",
74
74
  "vite": "^2.9.9",
75
75
  "vitest": "^0.14.1",
76
- "white-web-sdk": "^2.16.54"
76
+ "white-web-sdk": "^2.16.55"
77
77
  }
78
78
  }
@@ -154,13 +154,17 @@ export class AppProxy implements PageRemoveService {
154
154
  }
155
155
  const appImpl = await appRegister.appClasses.get(params.kind)?.();
156
156
  const appParams = appRegister.registered.get(params.kind);
157
+ const appOptions = this.manager.windowManger.resolveAppOptions(
158
+ params.kind,
159
+ appParams?.appOptions
160
+ );
157
161
  if (appImpl) {
158
162
  await this.setupApp(
159
163
  this.id,
160
164
  skipUpdate,
161
165
  appImpl,
162
166
  params.options,
163
- appParams?.appOptions,
167
+ appOptions,
164
168
  this.manager.useBoxesStatus ? boxStatus : undefined,
165
169
  params.forceTop,
166
170
  params.forceNormal,
@@ -1,4 +1,9 @@
1
1
  import { WindowManager } from "./index";
2
+ import type { PresentationAppOptions } from "@netless/app-presentation";
3
+
4
+ export interface BuiltinAppOptions {
5
+ Presentation?: PresentationAppOptions;
6
+ }
2
7
 
3
8
  const loadAppMediaPlayer = async () => {
4
9
  const mod = await import("@netless/app-media-player");
@@ -31,7 +36,6 @@ export const setupBuiltin = () => {
31
36
  kind: BuiltinApps.Presentation,
32
37
  src: loadAppPresentation,
33
38
  appOptions: {
34
- reScaleOnPageChange: true,
35
39
  debounceSync: true,
36
40
  useScrollbar: true,
37
41
  },
@@ -0,0 +1,12 @@
1
+ export function resolveAppOptions(
2
+ registeredOptions: any | (() => any),
3
+ override: any
4
+ ): any | (() => any) {
5
+ if (override === undefined) {
6
+ return registeredOptions;
7
+ }
8
+ return () => ({
9
+ ...(typeof registeredOptions === "function" ? registeredOptions() : registeredOptions),
10
+ ...override,
11
+ });
12
+ }
package/src/index.ts CHANGED
@@ -17,6 +17,7 @@ import { PageStateImpl } from "./PageState";
17
17
  import { ReconnectRefresher } from "./ReconnectRefresher";
18
18
  import { replaceRoomFunction } from "./Utils/RoomHacker";
19
19
  import { BuiltinApps, setupBuiltin } from "./BuiltinApps";
20
+ import type { BuiltinAppOptions } from "./BuiltinApps";
20
21
  import "video.js/dist/video-js.css";
21
22
  import "./style.css";
22
23
  import "@netless/telebox-insider/dist/style.css";
@@ -66,6 +67,7 @@ import type { ExtendPluginInstance } from "./ExtendPluginManager";
66
67
  import { ExtendPluginManager } from "./ExtendPluginManager";
67
68
  import { getExtendClass } from "./Utils/extendClass";
68
69
  import type { ExtendClass } from "./Utils/extendClass";
70
+ import { resolveAppOptions as mergeAppOptions } from "./Utils/resolveAppOptions";
69
71
 
70
72
  export * from "./utils/extendClass";
71
73
 
@@ -244,6 +246,8 @@ export type MountParams = {
244
246
  supportAppliancePlugin?: boolean;
245
247
  /** 是否使用 boxesStatus 状态管理窗口 */
246
248
  useBoxesStatus?: boolean;
249
+ /** Local Presentation options applied before restoring apps. Not synchronized. */
250
+ builtinAppOptions?: BuiltinAppOptions;
247
251
  };
248
252
 
249
253
  export const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
@@ -281,6 +285,8 @@ export class WindowManager
281
285
 
282
286
  public _appliancePlugin?: any;
283
287
 
288
+ public builtinAppOptions?: BuiltinAppOptions;
289
+
284
290
  private boxManager?: BoxManager;
285
291
  private static params?: MountParams;
286
292
  static extendClass?: ExtendClass;
@@ -385,6 +391,8 @@ export class WindowManager
385
391
  throw new Error("[WindowManager]: create manager failed");
386
392
  }
387
393
 
394
+ manager.builtinAppOptions = params.builtinAppOptions;
395
+
388
396
  if (containerSizeRatio) {
389
397
  WindowManager.containerSizeRatio = containerSizeRatio;
390
398
  }
@@ -586,6 +594,15 @@ export class WindowManager
586
594
  return appRegister.unregister(kind);
587
595
  }
588
596
 
597
+ public resolveAppOptions(
598
+ kind: string,
599
+ registeredOptions?: any | (() => any)
600
+ ): any | (() => any) {
601
+ const override =
602
+ kind === BuiltinApps.Presentation ? this.builtinAppOptions?.Presentation : undefined;
603
+ return mergeAppOptions(registeredOptions, override);
604
+ }
605
+
589
606
  /**
590
607
  * 创建一个 app 至白板
591
608
  */
@@ -1494,6 +1511,7 @@ setupBuiltin();
1494
1511
  export * from "./typings";
1495
1512
 
1496
1513
  export { BuiltinApps } from "./BuiltinApps";
1514
+ export type { BuiltinAppOptions } from "./BuiltinApps";
1497
1515
  export type { PublicEvent } from "./callback";
1498
1516
 
1499
1517
  export * from "./ExtendPluginManager";