@netless/window-manager 0.4.62 → 0.4.64

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.
@@ -1,4 +1,4 @@
1
- import { emitter } from "../InternalEmitter";
1
+ import { internalEmitter } from "../InternalEmitter";
2
2
  import { isPlayer } from "white-web-sdk";
3
3
  import type { WindowManager } from "../index";
4
4
  import type { Camera, Room, Player, PlayerSeekingResult } from "white-web-sdk";
@@ -66,7 +66,7 @@ const delegateRemoveScenes = (room: Room, manager: WindowManager) => {
66
66
  manager.appManager?.updateRootDirRemoving(true);
67
67
  }
68
68
  const result = originRemoveScenes.call(room, scenePath);
69
- emitter.emit("removeScenes", { scenePath, index });
69
+ internalEmitter.emit("removeScenes", { scenePath, index });
70
70
  return result;
71
71
  };
72
72
  };
@@ -76,9 +76,9 @@ const delegateSeekToProgressTime = (player: Player) => {
76
76
  // eslint-disable-next-line no-inner-declarations
77
77
  async function newSeek(time: number): Promise<PlayerSeekingResult> {
78
78
  // seek 时需要先关闭所有的 app 防止内部使用的 mobx 出现错误
79
- await emitter.emit("seekStart");
79
+ await internalEmitter.emit("seekStart");
80
80
  const seekResult = await originSeek.call(player, time);
81
- emitter.emit("seek", time);
81
+ internalEmitter.emit("seek", time);
82
82
  return seekResult;
83
83
  }
84
84
  player.seekToProgressTime = newSeek;
@@ -2,7 +2,7 @@ import { AnimationMode, reaction, ViewMode } from "white-web-sdk";
2
2
  import { callbacks } from "../callback";
3
3
  import { createView } from "./ViewManager";
4
4
  import { debounce, get, isEmpty, isEqual } from "lodash";
5
- import { emitter } from "../InternalEmitter";
5
+ import { internalEmitter } from "../InternalEmitter";
6
6
  import { Fields } from "../AttributesDelegate";
7
7
  import { setViewFocusScenePath } from "../Utils/Common";
8
8
  import { SideEffectManager } from "side-effect-manager";
@@ -23,7 +23,7 @@ export class MainViewProxy {
23
23
  constructor(private manager: AppManager) {
24
24
  this.mainView = this.createMainView();
25
25
  this.moveCameraSizeByAttributes();
26
- emitter.once("mainViewMounted").then(() => {
26
+ internalEmitter.once("mainViewMounted").then(() => {
27
27
  this.addMainViewListener();
28
28
  this.start();
29
29
  this.ensureCameraAndSize();
@@ -33,13 +33,13 @@ export class MainViewProxy {
33
33
  this.sizeChangeHandler(this.mainViewSize);
34
34
  };
35
35
  this.sideEffectManager.add(() => {
36
- return emitter.on("playgroundSizeChange", playgroundSizeChangeListener);
36
+ return internalEmitter.on("playgroundSizeChange", playgroundSizeChangeListener);
37
37
  });
38
38
  this.sideEffectManager.add(() => {
39
- return emitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio);
39
+ return internalEmitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio);
40
40
  });
41
41
  this.sideEffectManager.add(() => {
42
- return emitter.on("startReconnect", () => {
42
+ return internalEmitter.on("startReconnect", () => {
43
43
  if (!this.didRelease) {
44
44
  this.mainView.release();
45
45
  }
@@ -49,7 +49,7 @@ export class MainViewProxy {
49
49
 
50
50
  private startListenWritableChange = () => {
51
51
  this.sideEffectManager.add(() => {
52
- return emitter.on("writableChange", isWritable => {
52
+ return internalEmitter.on("writableChange", isWritable => {
53
53
  if (isWritable) {
54
54
  this.ensureCameraAndSize();
55
55
  }
@@ -87,6 +87,7 @@ export class MainViewProxy {
87
87
  if (this.started) return;
88
88
  this.addCameraListener();
89
89
  this.addCameraReaction();
90
+ if (this.manager.room) this.syncMainView(this.manager.room);
90
91
  this.started = true;
91
92
  }
92
93
 
package/src/callback.ts CHANGED
@@ -20,6 +20,8 @@ export type PublicEvent = {
20
20
  ready: undefined; // 所有 APP 创建完毕时触发
21
21
  sceneStateChange: SceneState;
22
22
  pageStateChange: PageState;
23
+ fullscreenChange: boolean;
24
+ appsChange: string[]; // APP 列表变化时触发
23
25
  };
24
26
 
25
27
  export type CallbacksType = Emittery<PublicEvent>;
package/src/index.ts CHANGED
@@ -7,7 +7,7 @@ import { ContainerResizeObserver } from "./ContainerResizeObserver";
7
7
  import { createBoxManager } from "./BoxManager";
8
8
  import { CursorManager } from "./Cursor";
9
9
  import { DEFAULT_CONTAINER_RATIO, Events, INIT_DIR, ROOT_DIR } from "./constants";
10
- import { emitter } from "./InternalEmitter";
10
+ import { internalEmitter } from "./InternalEmitter";
11
11
  import { Fields } from "./AttributesDelegate";
12
12
  import { initDb } from "./Register/storage";
13
13
  import { InvisiblePlugin, isPlayer, isRoom, RoomPhase, ViewMode } from "white-web-sdk";
@@ -130,7 +130,7 @@ export type MountParams = {
130
130
  container?: HTMLElement;
131
131
  /** 白板高宽比例, 默认为 9 / 16 */
132
132
  containerSizeRatio?: number;
133
- /** 显示 PS 透明背景,默认 true */
133
+ /** @deprecated 显示 PS 透明背景,默认 true */
134
134
  chessboard?: boolean;
135
135
  collectorContainer?: HTMLElement;
136
136
  collectorStyles?: Partial<CSSStyleDeclaration>;
@@ -140,14 +140,16 @@ export type MountParams = {
140
140
  disableCameraTransform?: boolean;
141
141
  prefersColorScheme?: TeleBoxColorScheme;
142
142
  applianceIcons?: ApplianceIcons;
143
+ fullscreen?: boolean;
143
144
  };
144
145
 
145
- export const reconnectRefresher = new ReconnectRefresher({ emitter });
146
+ export const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
146
147
 
147
148
  export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any> implements PageController {
148
149
  public static kind = "WindowManager";
149
150
  public static displayer: Displayer;
150
151
  public static wrapper?: HTMLElement;
152
+ public static sizer?: HTMLElement;
151
153
  public static playground?: HTMLElement;
152
154
  public static container?: HTMLElement;
153
155
  public static debug = false;
@@ -166,6 +168,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
166
168
  public viewMode = ViewMode.Broadcaster;
167
169
  public isReplay = isPlayer(this.displayer);
168
170
  private _pageState?: PageStateImpl;
171
+ private _fullscreen?: boolean;
169
172
 
170
173
  private boxManager?: BoxManager;
171
174
  private static params?: MountParams;
@@ -234,6 +237,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
234
237
  }
235
238
  await manager.ensureAttributes();
236
239
 
240
+ manager._fullscreen = params.fullscreen;
237
241
  manager.appManager = new AppManager(manager);
238
242
  manager._pageState = new PageStateImpl(manager.appManager);
239
243
  manager.cursorManager = new CursorManager(manager.appManager, Boolean(cursor), params.applianceIcons);
@@ -246,7 +250,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
246
250
  }
247
251
 
248
252
  replaceRoomFunction(room, manager);
249
- emitter.emit("onCreated");
253
+ internalEmitter.emit("onCreated");
250
254
  WindowManager.isCreated = true;
251
255
  try {
252
256
  await initDb();
@@ -282,9 +286,17 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
282
286
  private static initContainer(
283
287
  manager: WindowManager,
284
288
  container: HTMLElement,
285
- chessboard: boolean | undefined,
286
- overwriteStyles: string | undefined
289
+ params: {
290
+ chessboard?: boolean,
291
+ overwriteStyles?: string,
292
+ fullscreen?: boolean,
293
+ }
287
294
  ) {
295
+ const {
296
+ chessboard,
297
+ overwriteStyles,
298
+ fullscreen,
299
+ } = params;
288
300
  if (!WindowManager.container) {
289
301
  WindowManager.container = container;
290
302
  }
@@ -293,6 +305,9 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
293
305
  if (chessboard) {
294
306
  sizer.classList.add("netless-window-manager-chess-sizer");
295
307
  }
308
+ if (fullscreen) {
309
+ sizer.classList.add("netless-window-manager-fullscreen");
310
+ }
296
311
  if (overwriteStyles) {
297
312
  const style = document.createElement("style");
298
313
  style.textContent = overwriteStyles;
@@ -302,9 +317,10 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
302
317
  playground,
303
318
  sizer,
304
319
  wrapper,
305
- emitter
320
+ internalEmitter
306
321
  );
307
322
  WindowManager.wrapper = wrapper;
323
+ WindowManager.sizer = sizer;
308
324
  return mainViewElement;
309
325
  }
310
326
 
@@ -323,16 +339,11 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
323
339
  } else {
324
340
  if (WindowManager.params) {
325
341
  const params = WindowManager.params;
326
- const mainViewElement = WindowManager.initContainer(
327
- this,
328
- container,
329
- params.chessboard,
330
- params.overwriteStyles
331
- );
342
+ const mainViewElement = WindowManager.initContainer(this, container, params);
332
343
  if (this.boxManager) {
333
344
  this.boxManager.destroy();
334
345
  }
335
- const boxManager = createBoxManager(this, callbacks, emitter, boxEmitter, {
346
+ const boxManager = createBoxManager(this, callbacks, internalEmitter, boxEmitter, {
336
347
  collectorContainer: params.collectorContainer,
337
348
  collectorStyles: params.collectorStyles,
338
349
  prefersColorScheme: params.prefersColorScheme,
@@ -345,7 +356,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
345
356
  }
346
357
  }
347
358
  }
348
- emitter.emit("updateManagerRect");
359
+ internalEmitter.emit("updateManagerRect");
349
360
  this.appManager?.refresh();
350
361
  this.appManager?.resetMaximized();
351
362
  this.appManager?.resetMinimized();
@@ -385,7 +396,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
385
396
  // 移除根目录时需要做一些异步的释放操作 addApp 需要等待释放完成才可以继续添加
386
397
  if (this.appManager.rootDirRemoving) {
387
398
  return new Promise((resolve, reject) => {
388
- emitter.once("rootDirRemoved").then(async () => {
399
+ internalEmitter.once("rootDirRemoved").then(async () => {
389
400
  try {
390
401
  const appId = await this._addApp(params);
391
402
  resolve(appId);
@@ -583,7 +594,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
583
594
  public setReadonly(readonly: boolean): void {
584
595
  this.readonly = readonly;
585
596
  this.boxManager?.setReadonly(readonly);
586
- emitter.emit("setReadonly", readonly);
597
+ internalEmitter.emit("setReadonly", readonly);
587
598
  }
588
599
 
589
600
  /**
@@ -646,6 +657,14 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
646
657
  this.boxManager?.setMinimized(minimized, false);
647
658
  }
648
659
 
660
+ public setFullscreen(fullscreen: boolean): void {
661
+ if (this._fullscreen !== fullscreen) {
662
+ this._fullscreen = fullscreen;
663
+ WindowManager.sizer?.classList.toggle("netless-window-manager-fullscreen", fullscreen);
664
+ callbacks.emit("fullscreenChange", fullscreen);
665
+ }
666
+ }
667
+
649
668
  public get mainView(): View {
650
669
  if (this.appManager) {
651
670
  return this.appManager.mainViewProxy.view;
@@ -747,6 +766,10 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
747
766
  }
748
767
  }
749
768
 
769
+ public get fullscreen(): boolean {
770
+ return Boolean(this._fullscreen);
771
+ }
772
+
750
773
  /**
751
774
  * 查询所有的 App
752
775
  */
@@ -828,6 +851,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
828
851
  this.cursorManager?.destroy();
829
852
  WindowManager.container = undefined;
830
853
  WindowManager.wrapper = undefined;
854
+ WindowManager.sizer = undefined;
831
855
  WindowManager.isCreated = false;
832
856
  if (WindowManager.playground) {
833
857
  WindowManager.playground.parentNode?.removeChild(WindowManager.playground);
@@ -945,7 +969,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
945
969
  }
946
970
  WindowManager.containerSizeRatio = ratio;
947
971
  this.containerSizeRatio = ratio;
948
- emitter.emit("containerSizeRatioUpdate", ratio);
972
+ internalEmitter.emit("containerSizeRatioUpdate", ratio);
949
973
  }
950
974
 
951
975
  private isDynamicPPT(scenes: SceneDefinition[]) {
package/src/style.css CHANGED
@@ -197,3 +197,11 @@
197
197
  .netless-iframe-brdige-hidden {
198
198
  display: none;
199
199
  }
200
+
201
+ .netless-window-manager-fullscreen .telebox-titlebar,
202
+ .netless-window-manager-fullscreen .telebox-max-titlebar-maximized,
203
+ .netless-window-manager-fullscreen .netless-app-slide-footer,
204
+ .netless-window-manager-fullscreen .telebox-footer-wrap,
205
+ .netless-window-manager-fullscreen .telebox-titlebar-wrap {
206
+ display: none;
207
+ }