@netless/window-manager 0.3.12-canary.1 → 0.3.16-canary.0

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/docs/api.md ADDED
@@ -0,0 +1,113 @@
1
+ # API
2
+
3
+ ## 目录
4
+ - [静态方法](#static-methods)
5
+ - [`mount`](#mount)
6
+ - [`register`](#register)
7
+ - [实例方法](#instance-methods)
8
+ - [`addApp`](#addApp)
9
+ - [`closeApp`](#closeApp)
10
+ - [实例属性](#prototypes)
11
+ - [事件回调](#events)
12
+
13
+ <h2 id="static-methods">静态方法</h2>
14
+
15
+ <h3 id="mount">WindowManager.mount</h3>
16
+
17
+ > 挂载 WindowManager
18
+
19
+ ```typescript
20
+ const manager = await WindowManager.mount(
21
+ room: room,
22
+ container: document.getElementById("container")
23
+ // 完整配置见下方
24
+ );
25
+ ```
26
+
27
+ 参数
28
+
29
+ | name | type | default | desc |
30
+ | ---------------------- | --------------------------------------- | ------- | ---------------------------- |
31
+ | room | [require] Room | | 房间实例 |
32
+ | container | [require] HTMLElement | | 房间挂载容器 |
33
+ | containerSizeRatio | [optional] number | 9 / 16 | 多窗口区域的高宽比,默认为 9 : 16 |
34
+ | chessboard | [optional] boolean | true | 多窗口区域以外的空间显示 PS 棋盘背景,默认 true |
35
+ | collectorContainer | [optional] HTMLElement | | 用于多窗口最小化图标挂载的 dom |
36
+ | collectorStyles | [optional] Partial{CSSStyleDeclaration} | | 配置 collector 的样式 |
37
+ | overwriteStyles | [optional] string | | 用于覆盖窗口的样式 |
38
+ | cursor | [optional] boolean | false | 开启光标同步 |
39
+ | disableCameraTransform | [optional] boolean | | 禁用主白板的相机移动 |
40
+ | prefersColorScheme | [optional] string | light | auto, light, dark |
41
+ | debug | [optional] boolean | false | 打印日志信息
42
+
43
+ <h3 id="register">WindowManager.register</h3>
44
+
45
+ > 注册 `APP` 到 `WindowManager`
46
+
47
+ ```typescript
48
+ WindowManager.register({
49
+ kind: "helloWorld",
50
+ src: NetlessApp,
51
+ appOptions: () => "appOptions",
52
+ addHooks: (emitter) => {
53
+ emitter.on("created", result => {
54
+ console.log("HelloWordResult", result);
55
+ });
56
+ emitter.on("focus", result => {
57
+ console.log("HelloWorld focus", result);
58
+ })
59
+ emitter.on("destroy", result => {
60
+ console.log("HelloWorld destroy", result);
61
+ })
62
+ }
63
+ })
64
+ ```
65
+
66
+
67
+ <h2 id="instance-methods">实例方法</h2>
68
+
69
+ <h3 id="addApp">addApp</h3>
70
+
71
+ > 添加 `app` 至白板
72
+
73
+ ```typescript
74
+ const appId = await manager.addApp({
75
+ kind: "helloWorld"
76
+ options: { // 可选配置
77
+ scenePath: "/hello-world"
78
+ }
79
+ })
80
+ ```
81
+ 具体参数请参考 `APP` 本身的要求
82
+
83
+ <h3 id="closeApp">closeApp</h3>
84
+
85
+ > 关闭已经打开的 `APP`
86
+
87
+ ```typescript
88
+ manager.closeApp(appId)
89
+ ```
90
+
91
+ <h2 id="prototypes">实例属性</h2>
92
+
93
+ | name | type | default | desc |
94
+ | ------------------ | ------- | ------- | ------ |
95
+ | mainView | View | | 主白板 |
96
+ | boxState | string | | 当前窗口状态 |
97
+ | darkMode | boolean | | 黑夜模式 |
98
+ | prefersColorScheme | string | | 颜色主题 |
99
+
100
+
101
+ <h2 id="events">事件回调</h2>
102
+
103
+ ```typescript
104
+ manager.callbacks.on(events, listener)
105
+ ```
106
+
107
+ | name | type | default | desc |
108
+ | ------------------------ | -------------- | ------- | -------------------------- |
109
+ | mainViewModeChange | ViewVisionMode | | |
110
+ | boxStateChange | string | | normal,minimized,maximized |
111
+ | darkModeChange | boolean | | |
112
+ | prefersColorSchemeChange | string | | auto,light,dark |
113
+ | cameraStateChange | CameraState | | |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "0.3.12-canary.1",
3
+ "version": "0.3.16-canary.0",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
@@ -22,9 +22,9 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@juggle/resize-observer": "^3.3.1",
25
- "@netless/app-docs-viewer": "0.1.22",
25
+ "@netless/app-docs-viewer": "0.1.24",
26
26
  "@netless/app-media-player": "0.1.0-beta.5",
27
- "@netless/telebox-insider": "0.2.9",
27
+ "@netless/telebox-insider": "0.2.10",
28
28
  "emittery": "^0.9.2",
29
29
  "lodash": "^4.17.21",
30
30
  "p-retry": "^4.6.1",
package/src/MainView.ts CHANGED
@@ -88,11 +88,12 @@ export class MainViewProxy extends Base {
88
88
  return this.mainView;
89
89
  }
90
90
 
91
+ public get cameraState() {
92
+ return { ...this.view.camera, ...this.view.size };
93
+ }
94
+
91
95
  public createMainView(): View {
92
96
  const mainView = createView(this.manager.displayer);
93
- mainView.callbacks.on("onSizeUpdated", () => {
94
- this.context.updateManagerRect();
95
- });
96
97
  const mainViewScenePath = this.store.getMainViewScenePath();
97
98
  if (mainViewScenePath) {
98
99
  setViewFocusScenePath(mainView, mainViewScenePath);
@@ -139,6 +140,7 @@ export class MainViewProxy extends Base {
139
140
 
140
141
  private sizeListener = (size: Size) => {
141
142
  this.setMainViewSize(size);
143
+ callbacks.emit("cameraStateChange", this.cameraState);
142
144
  };
143
145
 
144
146
  public setMainViewSize = debounce(size => {
@@ -147,10 +149,16 @@ export class MainViewProxy extends Base {
147
149
 
148
150
  private addCameraListener() {
149
151
  this.view.callbacks.on("onCameraUpdatedByDevice", this.cameraListener);
152
+ this.view.callbacks.on("onCameraUpdated", this.cameraStateChangeListener);
150
153
  }
151
154
 
152
155
  private removeCameraListener() {
153
156
  this.view.callbacks.off("onCameraUpdatedByDevice", this.cameraListener);
157
+ this.view.callbacks.off("onCameraUpdated", this.cameraStateChangeListener)
158
+ }
159
+
160
+ private cameraStateChangeListener = () => {
161
+ callbacks.emit("cameraStateChange", this.cameraState);
154
162
  }
155
163
 
156
164
  public switchViewModeToWriter(): void {
package/src/index.ts CHANGED
@@ -51,6 +51,7 @@ import type {
51
51
  Point,
52
52
  Rectangle,
53
53
  ViewVisionMode,
54
+ CameraState,
54
55
  } from "white-web-sdk";
55
56
  import type { AppListeners } from "./AppListener";
56
57
  import type { NetlessApp, RegisterParams } from "./typings";
@@ -143,6 +144,7 @@ export type PublicEvent = {
143
144
  boxStateChange: `${TELE_BOX_STATE}`;
144
145
  darkModeChange: boolean;
145
146
  prefersColorSchemeChange: TeleBoxColorScheme;
147
+ cameraStateChange: CameraState;
146
148
  };
147
149
 
148
150
  export type MountParams = {
@@ -173,7 +175,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
173
175
  public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
174
176
  private static isCreated = false;
175
177
 
176
- public version = "0.3.12-canary.1";
178
+ public version = "0.3.16-canary.0";
177
179
 
178
180
  public appListeners?: AppListeners;
179
181
 
@@ -515,6 +517,14 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
515
517
  }
516
518
  }
517
519
 
520
+ public get cameraState(): CameraState {
521
+ if (this.appManager) {
522
+ return this.appManager.mainViewProxy.cameraState;
523
+ } else {
524
+ throw new AppManagerNotInitError();
525
+ }
526
+ }
527
+
518
528
  public get apps(): Apps | undefined {
519
529
  return this.appManager?.store.apps();
520
530
  }
@@ -689,6 +699,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
689
699
  if (containerRect) {
690
700
  this.updateSizer(containerRect, sizer, wrapper);
691
701
  this.cursorManager?.updateContainerRect();
702
+ this.appManager?.boxManager.updateManagerRect();
692
703
  }
693
704
  });
694
705