@netless/window-manager 0.4.14 → 0.4.15
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/CHANGELOG.md +4 -0
- package/dist/index.es.js +2 -2
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/docs/app-context.md +111 -0
- package/docs/develop-app.md +2 -0
- package/package.json +1 -1
- package/src/View/MainView.ts +2 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
## AppContext
|
|
2
|
+
|
|
3
|
+
- [api](#api)
|
|
4
|
+
- [events](#events)
|
|
5
|
+
|
|
6
|
+
<h2 id="api">API</h2>
|
|
7
|
+
|
|
8
|
+
### appId
|
|
9
|
+
|
|
10
|
+
插入 `app` 时生成的唯一 ID
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
const appId = context.appId
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### getDisplayer
|
|
17
|
+
|
|
18
|
+
在默认情况下 `Displayer` 为白板的 `room` 实例
|
|
19
|
+
|
|
20
|
+
回放时则为 `Player` 实例
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
const displayer = context.getDisplayer()
|
|
24
|
+
|
|
25
|
+
assert(displayer, room) // 互动房间
|
|
26
|
+
assert(displayer, player) // 回放房间
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### getScenes
|
|
30
|
+
|
|
31
|
+
`scenes` 在 `addApp` 时传入 `scenePath` 会由 `WindowManager` 创建
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
const scenes = context.getScenes()
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### getView
|
|
38
|
+
|
|
39
|
+
`View` 为白板中一块可标注部分
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
const view = context.getView()
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### getIsWritable
|
|
46
|
+
|
|
47
|
+
获取当前状态是否可写
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
// isWritable === (room.isWritable && box.readonly)
|
|
51
|
+
const isWritable = context.getIsWritable()
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### getBox
|
|
55
|
+
|
|
56
|
+
获取当前 app 的 box
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
const box = context.getBox()
|
|
60
|
+
|
|
61
|
+
box.$content // box 的 main element
|
|
62
|
+
box.$footer
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### setScenePath
|
|
66
|
+
|
|
67
|
+
切换当前 `view` 的 `scenePath`
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
context.setScenePath("/page/2")
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### mountView
|
|
74
|
+
|
|
75
|
+
挂载 view 到指定 dom
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
context.mountView(ref)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
<h2 id="events">events</h2>
|
|
82
|
+
|
|
83
|
+
### destroy
|
|
84
|
+
|
|
85
|
+
app 被关闭时发送的事件
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
context.emitter.on("destroy", () => {
|
|
89
|
+
// release your listeners
|
|
90
|
+
})
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### writableChange
|
|
94
|
+
|
|
95
|
+
白板可写状态切换时触发
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
context.emitter.on("writableChange", isWritable => {
|
|
99
|
+
//
|
|
100
|
+
})
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### focus
|
|
104
|
+
|
|
105
|
+
当前 app 获得焦点或者失去焦点时触发
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
context.emitter.on("focus", focus => {
|
|
109
|
+
//
|
|
110
|
+
})
|
|
111
|
+
```
|
package/docs/develop-app.md
CHANGED
package/package.json
CHANGED
package/src/View/MainView.ts
CHANGED
|
@@ -22,7 +22,6 @@ export class MainViewProxy {
|
|
|
22
22
|
this.mainView = this.createMainView();
|
|
23
23
|
this.moveCameraSizeByAttributes();
|
|
24
24
|
emitter.once("mainViewMounted").then(() => {
|
|
25
|
-
this.addMainViewListener();
|
|
26
25
|
setTimeout(() => {
|
|
27
26
|
this.start();
|
|
28
27
|
if (!this.mainViewCamera || !this.mainViewSize) {
|
|
@@ -55,6 +54,7 @@ export class MainViewProxy {
|
|
|
55
54
|
public start() {
|
|
56
55
|
if (this.started) return;
|
|
57
56
|
this.sizeChangeHandler(this.mainViewSize);
|
|
57
|
+
this.addMainViewListener();
|
|
58
58
|
this.addCameraListener();
|
|
59
59
|
this.manager.refresher?.add(Fields.MainViewCamera, this.cameraReaction);
|
|
60
60
|
this.started = true;
|
|
@@ -143,6 +143,7 @@ export class MainViewProxy {
|
|
|
143
143
|
this.view.divElement.removeEventListener("click", this.mainViewClickListener);
|
|
144
144
|
this.view.divElement.removeEventListener("touchend", this.mainViewClickListener);
|
|
145
145
|
}
|
|
146
|
+
this.mainViewIsAddListener = false;
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
private mainViewClickListener = () => {
|