@netless/window-manager 0.4.54 → 0.4.56

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.
@@ -0,0 +1,60 @@
1
+
2
+ ### 注意事项
3
+
4
+ 多窗口模式必须开启白板的 `useMultiViews` 和 `useMobXState` 选项
5
+
6
+ 会造成原本以下 `room` 上的一些方法和 `state` 失效
7
+
8
+ `方法`
9
+
10
+ - `room.bindHtmlElement()` 用 `WindowManager.mount()` 代替
11
+ - `room.scalePptToFit()` 暂无代替,不再推荐调用 `scalePptToFit`
12
+ - `room.setScenePath()` 用 `manager.setMainViewScenePath()` 代替
13
+ - `room.setSceneIndex()` 用 `manager.setMainViewSceneIndex()` 代替
14
+
15
+ > 为了方便使用 `manager` 替换了 `room` 上的一些方法可以直接对 `mainView` 生效
16
+
17
+ - `room.disableCameraTransform`
18
+ - `room.moveCamera`
19
+ - `room.moveCameraToContain`
20
+ - `room.convertToPointInWorld`
21
+ - `room.setCameraBound`
22
+
23
+ `camera`
24
+
25
+ - `room.state.cameraState` 用 `manager.mainView.camera` 和 `manager.mainView.size` 代替
26
+
27
+ 想要监听主白板 `camera` 的变化, 请使用如下方式代替
28
+
29
+ ```javascript
30
+ manager.mainView.callbacks.on("onCameraUpdated", camera => {
31
+ console.log(camera);
32
+ });
33
+ ```
34
+
35
+ 监听主白板 `size` 变化
36
+
37
+ ```javascript
38
+ manager.mainView.callbacks.on("onSizeUpdated", size => {
39
+ console.log(size);
40
+ });
41
+ ```
42
+
43
+ <br>
44
+
45
+ ## `white-web-sdk` 从 `2.15.x` 迁移至 `2.16.x`
46
+
47
+ ### `room.setMemberState`
48
+
49
+ 此方法在开启多窗口时要等待 `WindowManager` 挂载完成后才可以直接调用。
50
+
51
+ 或者使用 `manager.mainView.setMemberState` 代替
52
+
53
+ <br>
54
+
55
+ ### `room.pptPreviousStep` `room.pptNextStep` 切换上下页
56
+
57
+ 因为窗口实现机制的改变, `pptPreviousStep` 和 `pptNextStep` 不再生效
58
+
59
+ 如果需要切换主白板的上下页, 请使用 `manager.nextPage` 和 `manager.prevPage`
60
+
@@ -0,0 +1,40 @@
1
+ ## 回放
2
+
3
+ > 注意: 多窗口的回放只支持从创建房间开始就是多窗口的房间
4
+
5
+ > 如果是一开始作为单窗口模式使用,又转变成多窗口模式使用, 则会造成回放渲染空白
6
+
7
+ <br>
8
+
9
+
10
+ ```typescript
11
+ import { WhiteWebSdk } from "white-web-sdk";
12
+ import { WindowManager, BuiltinApps } from "@netless/window-manager";
13
+ import "@netless/window-manager/dist/style.css";
14
+
15
+ const sdk = new WhiteWebSdk({
16
+ appIdentifier: "appIdentifier",
17
+ useMobXState: true // 请确保打开这个选项
18
+ });
19
+
20
+ let manager: WindowManager;
21
+
22
+ sdk.replayRoom({
23
+ uuid: "room uuid",
24
+ roomToken: "room token",
25
+ invisiblePlugins: [WindowManager],
26
+ useMultiViews: true, // 多窗口必须用开启 useMultiViews
27
+ }).then(player => {
28
+ player.callbacks.on("onPhaseChanged", async (phase) => {
29
+ if (phase === PlayerPhase.Playing) {
30
+ if (manager) return;
31
+ manager = await WindowManager.mount({
32
+ room: player,
33
+ container: document.getElementById("container")
34
+ });
35
+ }
36
+ })
37
+ });
38
+
39
+ player.play(); // WindowManager 只有在播放之后才能挂载
40
+ ```
package/docs/concept.md CHANGED
@@ -1,9 +1,10 @@
1
- # 概念
1
+ # Concept
2
2
 
3
- ## 同步区域
3
+ ## Sync Zone
4
4
 
5
- 在不同分辨率的设备上,想要看到相同的区域和窗口,我们就需要在所有设备保持一个相同的比例。
5
+ On devices with different resolutions, if we want to see the same area and window, we need to maintain the same ratio on all devices.
6
6
 
7
- 所以 `WindowManager` 有一个 `containerSizeRatio` 的选项来配置白板的宽高比,默认为 `9 / 16`
7
+ So `WindowManager` has a `containerSizeRatio` option to configure the aspect ratio of the whiteboard, the default is `9 / 16`
8
+
9
+ If the width and height given to WindowManager by the outer layer do not perfectly fit this aspect ratio, WindowManger will automatically calculate a maximum width and height that fits this ratio internally, and then fill it in. At this time, there will be some internal areas that cannot be operated
8
10
 
9
- 如果外层给到 `WindowManager` 宽高并不是完美适配这个宽高比的话, `WindowManger` 会自动在内部算出一个适配这个比例的最大宽高,然后填充上去,这时在内部就会有一些区域不能操作
@@ -1,30 +1,30 @@
1
- ## 如何自定义最大化 `titleBar`
1
+ ## How to customize maximized `titleBar`
2
2
 
3
- 获取并订阅所有的 `box`
3
+ Get and subscribe to all `box`
4
4
 
5
5
  ```js
6
6
  manager.boxManager.teleboxManager.boxes$.subscribe(boxes => {
7
- // boxes 为所有的窗口,当窗口添加和删除时都会触发
7
+ // boxes are all windows, trigger when windows are added and deleted
8
8
  })
9
9
  ```
10
10
 
11
- 切换 `box` `focus`
11
+ Toggle `focus` of `box`
12
12
  ```js
13
13
  manager.boxManager.teleBoxManager.focusBox(box)
14
14
  ```
15
15
 
16
- 关闭某个 `box`
16
+ close a `box`
17
17
  ```js
18
18
  manager.boxManager.teleBoxManager.remove(box)
19
19
  ```
20
20
 
21
- 切换最大化状态
21
+ Toggle maximized state
22
22
  ```js
23
23
  manager.boxManager.teleBoxManager.setMaximized(false)
24
24
  manager.boxManager.teleBoxManager.setMaximized(true)
25
25
  ```
26
26
 
27
- 切换最小化状态
27
+ Toggle minimized state
28
28
  ```js
29
29
  manager.boxManager.teleBoxManager.setMinimized(true)
30
30
  manager.boxManager.teleBoxManager.setMaximized(false)
@@ -1,12 +1,12 @@
1
- # 开发自定义 APP
1
+ # Develop custom APP
2
2
 
3
- - [AppContext](./app-context.md)
3
+ - [AppContext](./app-context.md)
4
4
 
5
5
  ## official apps https://github.com/netless-io/netless-app
6
6
 
7
7
  ## app-with-whiteboard
8
8
 
9
- 如果需要 app 中挂载白板请参考 [board.tsx](https://github.com/netless-io/window-manager/blob/master/example/app/board.tsx)
9
+ If you need to mount a whiteboard in the app, please refer to [board.tsx](https://github.com/netless-io/window-manager/blob/master/example/app/board.tsx)
10
10
 
11
11
  <br>
12
12
 
@@ -14,9 +14,9 @@
14
14
  import type { NetlessApp, AppContext } from "@netless/window-manager";
15
15
 
16
16
  const HelloWorld: NetlessApp = {
17
- kind: "HelloWorld",
17
+ kind: "Hello World",
18
18
  setup: (context: AppContext) => {
19
- context.mountView(context.getBox().$content); // 可选: 挂载 View box
19
+ context.mountView(context.getBox().$content); // optional: mount the View to the box
20
20
  },
21
21
  };
22
22
 
@@ -26,9 +26,9 @@ WindowManager.register({
26
26
  });
27
27
 
28
28
  manager.addApp({
29
- kind: "HelloWorld",
29
+ kind: "Hello World",
30
30
  options: {
31
- scenePath: "/hello-world", // 如果需要在 App 中使用白板则必须声明 scenePath
31
+ scenePath: "/hello-world", // If you need to use the whiteboard in the app, you must declare scenePath
32
32
  },
33
33
  });
34
34
  ```
@@ -38,21 +38,21 @@ manager.addApp({
38
38
  ```ts
39
39
  const Counter: NetlessApp<{ count: number }> = {
40
40
  kind: "Counter",
41
- setup: (context) => {
41
+ setup: context => {
42
42
  const storage = context.storage;
43
43
  storage.ensureState({ count: 0 });
44
44
 
45
- const box = context.getBox(); // box 为这个应用打开的窗口
46
- const $content = box.$content // 获取窗口的 content
45
+ const box = context.getBox(); // box is the window opened for this application
46
+ const $content = box.$content; // Get the content of the window
47
47
 
48
48
  const countDom = document.createElement("div");
49
49
  countDom.innerText = storage.state.count.toString();
50
50
  $content.appendChild(countDom);
51
51
 
52
- // 监听 state 变化回调
52
+ // Listen for state change callbacks
53
53
  storage.addStateChangedListener(diff => {
54
54
  if (diff.count) {
55
- // diff 会给出 newValue oldValue
55
+ // diff will give newValue and oldValue
56
56
  console.log(diff.count.newValue);
57
57
  console.log(diff.count.oldValue);
58
58
  countDom.innerText = diff.count.newValue.toString();
@@ -63,7 +63,7 @@ const Counter: NetlessApp<{ count: number }> = {
63
63
  incButton.innerText = "Inc";
64
64
  const incButtonOnClick = () => {
65
65
  storage.setState({ count: storage.state.count + 1 });
66
- }
66
+ };
67
67
  incButton.addEventListener("click", incButtonOnClick);
68
68
  $content.appendChild(incButton);
69
69
 
@@ -71,24 +71,24 @@ const Counter: NetlessApp<{ count: number }> = {
71
71
  decButton.innerText = "Dec";
72
72
  const decButtonOnClick = () => {
73
73
  storage.setState({ count: storage.state.count - 1 });
74
- }
74
+ };
75
75
  decButton.addEventListener("click", decButtonOnClick);
76
76
  $content.appendChild(decButton);
77
77
 
78
- // 监听事件
78
+ // listen for events
79
79
  const event1Disposer = context.addMagixEventListener("event1", msg => {
80
80
  console.log("event1", msg);
81
81
  });
82
82
 
83
- // 向打开 app 的其他人发送消息
83
+ // Send a message to other people who have the app open
84
84
  context.dispatchMagixEvent("event1", { count: 10 });
85
85
 
86
- // 应用销毁时, 注意清理掉监听器
86
+ // When the application is destroyed, pay attention to clean up the listener
87
87
  context.emitter.on("destroy", () => {
88
88
  incButton.removeEventListener("click", incButtonOnClick);
89
89
  decButton.removeEventListener("click", decButtonOnClick);
90
90
  event1Disposer();
91
91
  });
92
- }
93
- }
94
- ```
92
+ },
93
+ };
94
+ ```
@@ -1,48 +1,48 @@
1
- # 导出 PDF
1
+ # Export PDF
2
2
 
3
- 此功能需要额外安装 `jspdf` 依赖才能使用
3
+ This feature requires additional installation of the `jspdf` dependency to use
4
4
 
5
5
  ```
6
6
  npm install jspdf@2.5.1
7
7
  ```
8
8
 
9
- ### 支持的 app 及版本
9
+ ### Supported apps and versions
10
10
 
11
- 1. @netless/app-slide `0.2.23` 及以上版本支持保存动态 ppt 板书
11
+ 1. @netless/app-slide `0.2.23` and above support saving dynamic ppt board writing
12
12
 
13
- 2. @netless/app-docs-viewer `0.2.10` 及以上版本支持保存 pdf 板书, **注意** app-docs-viewer 中可以展示静态 ppt, pdf, 动态 ppt. 其中只有 pdf 文件支持保存板书
13
+ 2. @netless/app-docs-viewer `0.2.10` and above support saving pdf board writing, **Note** app-docs-viewer can show static ppt, pdf, dynamic ppt. Only pdf files support saving board writing
14
14
 
15
- 对应 @netless/window-manager `0.4.50` 及以上
15
+ Only pdf files can be saved in the app-docs-viewer, which is compatible with @netless/window-manager `0.4.50` and above.
16
16
 
17
- 3. white-web-sdk `2.16.37` 及以上
17
+ 3. white-web-sdk `2.16.37` and above
18
18
 
19
- ### 发起保存板书任务
19
+ ### Initiate a save board writing task
20
20
 
21
- 通过 `window.postMessage` 发事件来发起保存板书任务, 注意不要在任务尚未完成之前重复发送该事件.
21
+ Launch the save board writing task with a `window.postMessage` event, and be careful not to repeat the event before the task is completed.
22
22
 
23
23
  ```js
24
24
  window.postMessage({
25
25
  type: "@netless/_request_save_pdf_",
26
- appId: /* windowManager.addApp 返回的值, 指定要保存哪个窗口的板书, */
26
+ appId: /* windowManager.addApp return value, specify which window to save the board writing, */
27
27
  })
28
28
  ```
29
29
 
30
- ### 获取任务进度
30
+ ### Get task progress
31
31
 
32
- 任务进度也通过 message 事件传递, 你需要在发起任务之前监听任务进度事件, 实例代码如下所示.
33
- 其中 data.result 只有在任务成功时候才有值, 任务失败或者任务进行中都为 Null.
34
- **如果下载任务失败, progress 100 但是 result Null.**
32
+ Task progress is also passed through the message event, you need to listen to the task progress event before launching the task, the example code is shown below.
33
+ The data.result will only have a value if the task succeeds, and will be null if the task fails or is in progress.
34
+ **If the download task fails, then progress is 100 but result is null.**
35
35
 
36
36
  ```js
37
37
  window.addEventListener("message", evt => {
38
38
  if (evt.data.type === "@netless/_result_save_pdf_") {
39
39
  console.log(evt.data);
40
- // data 包含如下属性
41
- // data.type: 固定值 "@netless/_result_save_pdf_"
42
- // data.appId: 指明是哪次下载任务, 与发起保存板书时候传递的 appId 值一致
43
- // data.progress: 下载进度, 0 ~ 100
44
- // data.result: ArrayBuffer 或者 Null, 值为板书的 pdf 文件内容, 仅当下载进度 100 时才有值.
45
- // 获取到 ArrayBuffer 后需要自行完成下载到本地的逻辑.
40
+ // data contains the following properties
41
+ // data.type: fixed value "@netless/_result_save_pdf_"
42
+ // data.appId: specifies which download task, same as the appId value passed when the board writing was saved
43
+ // data.progress: progress of the download, 0 ~ 100
44
+ // data.result: { pdf: ArrayBuffer {}, title: "a.pptx" } or null, the contents of the pdf file for the board writing.
45
+ // value only when the download progresses to 100. After getting the ArrayBuffer you need to complete the logic of downloading to local.
46
46
  }
47
47
  });
48
48
  ```
package/docs/migrate.md CHANGED
@@ -1,60 +1,58 @@
1
+ ### Precautions
1
2
 
2
- ### 注意事项
3
+ Multi-window mode must enable whiteboard `useMultiViews` and `useMobXState` options
3
4
 
4
- 多窗口模式必须开启白板的 `useMultiViews` `useMobXState` 选项
5
+ It will cause some methods and `state` on the following `room` to fail
5
6
 
6
- 会造成原本以下 `room` 上的一些方法和 `state` 失效
7
+ `method`
7
8
 
8
- `方法`
9
+ - `room.bindHtmlElement()` is replaced by `WindowManager.mount()`
10
+ - There is no replacement for `room.scalePptToFit()`, calling `scalePptToFit` is no longer recommended
11
+ - `room.setScenePath()` is replaced by `manager.setMainViewScenePath()`
12
+ - `room.setSceneIndex()` is replaced by `manager.setMainViewSceneIndex()`
9
13
 
10
- - `room.bindHtmlElement()` `WindowManager.mount()` 代替
11
- - `room.scalePptToFit()` 暂无代替,不再推荐调用 `scalePptToFit`
12
- - `room.setScenePath()` 用 `manager.setMainViewScenePath()` 代替
13
- - `room.setSceneIndex()` 用 `manager.setMainViewSceneIndex()` 代替
14
+ > In order to use `manager` to replace some methods on `room`, it can directly take effect on `mainView`
14
15
 
15
- > 为了方便使用 `manager` 替换了 `room` 上的一些方法可以直接对 `mainView` 生效
16
-
17
- - `room.disableCameraTransform`
18
- - `room.moveCamera`
19
- - `room.moveCameraToContain`
20
- - `room.convertToPointInWorld`
21
- - `room.setCameraBound`
16
+ - `room.disableCameraTransform`
17
+ - `room.moveCamera`
18
+ - `room.moveCameraToContain`
19
+ - `room.convertToPointInWorld`
20
+ - `room.setCameraBound`
22
21
 
23
22
  `camera`
24
23
 
25
- - `room.state.cameraState` `manager.mainView.camera` `manager.mainView.size` 代替
24
+ - `room.state.cameraState` is replaced by `manager.mainView.camera` and `manager.mainView.size`
26
25
 
27
- 想要监听主白板 `camera` 的变化, 请使用如下方式代替
26
+ If you want to monitor the main whiteboard `camera` changes, please use the following method instead
28
27
 
29
28
  ```javascript
30
29
  manager.mainView.callbacks.on("onCameraUpdated", camera => {
31
- console.log(camera);
30
+ console.log(camera);
32
31
  });
33
32
  ```
34
33
 
35
- 监听主白板 `size` 变化
34
+ Monitor main whiteboard `size` changes
36
35
 
37
36
  ```javascript
38
37
  manager.mainView.callbacks.on("onSizeUpdated", size => {
39
- console.log(size);
38
+ console.log(size);
40
39
  });
41
40
  ```
42
41
 
43
42
  <br>
44
43
 
45
- ## `white-web-sdk` `2.15.x` 迁移至 `2.16.x`
44
+ ## `white-web-sdk` migrated from `2.15.x` to `2.16.x`
46
45
 
47
46
  ### `room.setMemberState`
48
47
 
49
- 此方法在开启多窗口时要等待 `WindowManager` 挂载完成后才可以直接调用。
48
+ This method can be called directly after waiting for `WindowManager` to be mounted when multi-window is enabled.
50
49
 
51
- 或者使用 `manager.mainView.setMemberState` 代替
50
+ Or use `manager.mainView.setMemberState` instead
52
51
 
53
52
  <br>
54
53
 
55
- ### `room.pptPreviousStep` `room.pptNextStep` 切换上下页
56
-
57
- 因为窗口实现机制的改变, `pptPreviousStep` 和 `pptNextStep` 不再生效
54
+ ### `room.pptPreviousStep` `room.pptNextStep` Switch to the next page
58
55
 
59
- 如果需要切换主白板的上下页, 请使用 `manager.nextPage` `manager.prevPage`
56
+ `pptPreviousStep` and `pptNextStep` no longer work due to changes in window implementation
60
57
 
58
+ If you need to switch the top and bottom pages of the main whiteboard, please use `manager.nextPage` and `manager.prevPage`
@@ -0,0 +1,50 @@
1
+ # Get started quickly
2
+
3
+ ## Install
4
+ Install `WindowManager` via `npm` or `yarn`.
5
+ ```bash
6
+ # npm
7
+ $ npm install @netless/window-manager
8
+
9
+ # yarn
10
+ $ yarn add @netless/window-manager
11
+ ```
12
+
13
+ Import:
14
+ ```typescript
15
+ import { WhiteWindowSDK } from "@netless/window-manager";
16
+ import "@netless/window-manager/dist/style.css";
17
+ ```
18
+
19
+ ## Start using
20
+
21
+ ### Prepare container
22
+ Create a container for mounting in the page
23
+ ```html
24
+ <div id="container"></div>
25
+ ```
26
+
27
+ ### Initialize the SDK
28
+ ```typescript
29
+ const sdk = new WhiteWindowSDK({
30
+ appIdentifier: "appIdentifier"
31
+ })
32
+ ```
33
+
34
+ ### Join the room and mount the container
35
+ ```typescript
36
+ const manager = await sdk.mount({
37
+ joinRoomParams: {
38
+ uuid: "room uuid",
39
+ roomToken: "room token",
40
+ },
41
+ mountParams: {
42
+ container: document.getElementById("container")
43
+ }
44
+ })
45
+ ```
46
+
47
+ ### Uninstall
48
+ ```typescript
49
+ manager.destroy();
50
+ ```
package/docs/replay.md CHANGED
@@ -1,8 +1,8 @@
1
- ## 回放
1
+ ## playback
2
2
 
3
- > 注意: 多窗口的回放只支持从创建房间开始就是多窗口的房间
3
+ > Note: Multi-window playback only supports multi-window rooms from the creation of the room
4
4
 
5
- > 如果是一开始作为单窗口模式使用,又转变成多窗口模式使用, 则会造成回放渲染空白
5
+ > If it is used as a single-window mode at the beginning and then converted to a multi-window mode, it will cause blank playback rendering
6
6
 
7
7
  <br>
8
8
 
@@ -13,28 +13,28 @@ import { WindowManager, BuiltinApps } from "@netless/window-manager";
13
13
  import "@netless/window-manager/dist/style.css";
14
14
 
15
15
  const sdk = new WhiteWebSdk({
16
- appIdentifier: "appIdentifier",
17
- useMobXState: true // 请确保打开这个选项
16
+ appIdentifier: "appIdentifier",
17
+ useMobXState: true // make sure this option is turned on
18
18
  });
19
19
 
20
20
  let manager: WindowManager;
21
21
 
22
22
  sdk.replayRoom({
23
- uuid: "room uuid",
24
- roomToken: "room token",
25
- invisiblePlugins: [WindowManager],
26
- useMultiViews: true, // 多窗口必须用开启 useMultiViews
23
+ uuid: "room uuid",
24
+ roomToken: "room token",
25
+ invisiblePlugins: [WindowManager],
26
+ useMultiViews: true, // Multi-window must be enabled useMultiViews
27
27
  }).then(player => {
28
- player.callbacks.on("onPhaseChanged", async (phase) => {
29
- if (phase === PlayerPhase.Playing) {
30
- if (manager) return;
31
- manager = await WindowManager.mount({
32
- room: player,
33
- container: document.getElementById("container")
34
- });
35
- }
36
- })
28
+ player.callbacks.on("onPhaseChanged", async (phase) => {
29
+ if (phase === PlayerPhase.Playing) {
30
+ if (manager) return;
31
+ manager = await WindowManager.mount({
32
+ room: player,
33
+ container: document.getElementById("container")
34
+ });
35
+ }
36
+ })
37
37
  });
38
38
 
39
- player.play(); // WindowManager 只有在播放之后才能挂载
40
- ```
39
+ player.play(); // WindowManager can only be mounted after playing
40
+ ```
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "0.4.54",
3
+ "version": "0.4.56",
4
4
  "description": "",
5
- "main": "dist/index.cjs.js",
6
- "module": "dist/index.es.js",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "repository": "netless-io/window-manager",
9
9
  "author": "l1shen <lishen1635@gmail.com> (https://github.com/l1shen)",
package/src/Helper.ts CHANGED
@@ -44,7 +44,7 @@ export const checkVersion = () => {
44
44
 
45
45
  export const findMemberByUid = (room: Room | undefined, uid: string) => {
46
46
  const roomMembers = room?.state.roomMembers || [];
47
- let maxMemberId = 0;
47
+ let maxMemberId = -1; // 第一个进入房间的用户 memberId 是 0
48
48
  let result: RoomMember | undefined = undefined;
49
49
  for (const member of roomMembers) {
50
50
  if (member.payload?.uid === uid && maxMemberId < member.memberId) {
package/vite.config.js CHANGED
@@ -36,7 +36,9 @@ export default defineConfig(({ mode }) => {
36
36
  entry: path.resolve(__dirname, "src/index.ts"),
37
37
  formats: ["es", "umd", "cjs"],
38
38
  name: "WindowManager",
39
- fileName: "index"
39
+ fileName: (moduleType) => {
40
+ return moduleType === "es" ? "index.mjs" : "index.js";
41
+ }
40
42
  },
41
43
  outDir: "dist",
42
44
  sourcemap: true,