@netless/window-manager 1.0.0-canary.7 → 1.0.0-canary.8

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.0-canary.7",
3
+ "version": "1.0.0-canary.8",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
@@ -29,7 +29,6 @@ import type {
29
29
  import { WhiteBoardView } from "./WhiteboardView";
30
30
  import { findMemberByUid } from "../Helper";
31
31
  import { MAX_PAGE_SIZE } from "../constants";
32
- import { putScenes } from "../Utils/Common";
33
32
  import { isNumber } from "lodash";
34
33
 
35
34
  export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOptions = any> {
@@ -63,9 +62,13 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
63
62
  this.isAddApp = appProxy.isAddApp;
64
63
  }
65
64
 
66
- public get displayer(){
65
+ public get displayer() {
67
66
  return this.manager.displayer;
68
- };
67
+ }
68
+
69
+ public get destroyed() {
70
+ return this.appProxy.status === "destroyed";
71
+ }
69
72
 
70
73
  /** @deprecated Use context.storage.state instead. */
71
74
  public getAttributes = (): TAttributes | undefined => {
@@ -103,13 +106,13 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
103
106
  }
104
107
  view.divElement = viewWrapper;
105
108
  if (this.isAddApp) {
106
- this.initPageSize(size);
109
+ this.ensurePageSize(size);
107
110
  }
108
- this.whiteBoardView = new WhiteBoardView(this, this.appProxy, removeViewWrapper);
111
+ this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy, removeViewWrapper, this.ensurePageSize);
109
112
  return this.whiteBoardView;
110
113
  }
111
114
 
112
- private initPageSize = (size?: number) => {
115
+ private ensurePageSize = (size?: number) => {
113
116
  if (!isNumber(size)) return;
114
117
  if (!this.appProxy.scenePath) return;
115
118
  if (this.appProxy.pageState.length >= size) return;
@@ -117,11 +120,8 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
117
120
  throw Error(`[WindowManager]: size ${size} muse be in range [1, ${MAX_PAGE_SIZE}]`);
118
121
  }
119
122
  const needInsert = size - this.appProxy.pageState.length;
120
- const startPageNumber = this.appProxy.pageState.length;
121
- const scenes = new Array(needInsert).fill({}).map((_, index) => {
122
- return { name: `${startPageNumber + index + 1}` };
123
- });
124
- putScenes(this.room, this.appProxy.scenePath, scenes);
123
+ const scenes = new Array(needInsert).fill({});
124
+ this.room?.putScenes(this.appProxy.scenePath, scenes);
125
125
  }
126
126
 
127
127
  public getInitScenePath = () => {
@@ -54,7 +54,7 @@ export class AppProxy implements PageRemoveService {
54
54
  public uid = this.manager.uid;
55
55
 
56
56
  public isAddApp: boolean;
57
- private status: "normal" | "destroyed" = "normal";
57
+ public status: "normal" | "destroyed" = "normal";
58
58
  private stateKey: string;
59
59
  public _pageState: AppPageStateImpl;
60
60
  private _prevFullPath: string | undefined;
@@ -5,15 +5,17 @@ import type { ReadonlyVal } from "value-enhancer";
5
5
  import type { AddPageParams, PageController, PageState } from "../Page";
6
6
  import type { AppProxy } from "./AppProxy";
7
7
  import type { AppContext } from "./AppContext";
8
- import type { Camera } from "white-web-sdk";
8
+ import type { Camera, View } from "white-web-sdk";
9
9
 
10
10
  export class WhiteBoardView implements PageController {
11
11
  public readonly pageState$: ReadonlyVal<PageState>;
12
12
 
13
13
  constructor(
14
+ public view: View,
14
15
  protected appContext: AppContext,
15
16
  protected appProxy: AppProxy,
16
- private removeViewWrapper: () => void
17
+ private removeViewWrapper: () => void,
18
+ public ensureSize: (size: number) => void
17
19
  ) {
18
20
  const pageState$ = new Val<PageState>(appProxy.pageState);
19
21
  this.pageState$ = pageState$;
@@ -22,10 +24,6 @@ export class WhiteBoardView implements PageController {
22
24
  });
23
25
  }
24
26
 
25
- public get view() {
26
- return this.appContext.view;
27
- }
28
-
29
27
  public get pageState() {
30
28
  return this.pageState$.value;
31
29
  }