@netless/window-manager 1.0.0-canary.22 → 1.0.0-canary.23

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.
@@ -75,7 +75,7 @@
75
75
  ```
76
76
 
77
77
  ```ts
78
- const view = context.createWhiteBoardView(10); // 生成带有 10 页的白板
78
+ const view = context.createWhiteBoardView({ size: 10 }); // 生成带有 10 页的白板
79
79
  ```
80
80
 
81
81
  - **WhiteBoardView**
@@ -148,6 +148,18 @@
148
148
  console.log("pageStateChange", pageState)
149
149
  })
150
150
  ```
151
+ - **setRect**
152
+
153
+ 设置白板的显示的宽高\
154
+ 在不同分辨率下会保证所有打开的窗口都能完整显示这个区域
155
+
156
+ ```ts
157
+ const view = context.createWhiteBoardView();
158
+ // 此方法建议只在插入时设置一次
159
+ if (context.isAddApp) {
160
+ view.setRect({ width: 500, height: 500 })
161
+ }
162
+ ```
151
163
 
152
164
  <h3 id="storage">storage</h3>
153
165
 
@@ -301,6 +313,44 @@
301
313
 
302
314
  类型: `ReadonlyTeleBox`
303
315
 
316
+ - **mountStyles()**
317
+
318
+ 挂载样式到 `box` 上
319
+
320
+ 参数: `string | HTMLStyleElement`
321
+
322
+ ```ts
323
+ box.mountStyles(`
324
+ .hello-world-app span {
325
+ color: red;
326
+ }
327
+ `);
328
+ ```
329
+
330
+ - **mountContent()**
331
+
332
+ 挂载元素到 `box` 中\
333
+ 推荐使用 `mountStage` 方法挂载元素到 `stage` 中
334
+
335
+ 参数: `HTMLElement`
336
+
337
+ ```ts
338
+ const app = document.createElement("div");
339
+ box.mountContent(app);
340
+ ```
341
+
342
+ - **mountStage()**
343
+
344
+ 挂载元素到 `box` 的 `contentStage` 中\
345
+ 如无特殊情况, 推荐把所有内容挂载到 `stage` 中
346
+
347
+ 参数: `HTMLElement`
348
+
349
+ ```ts
350
+ const app = document.createElement("div");
351
+ box.mountStage(app);
352
+ ```
353
+
304
354
  - **contentStageRect**
305
355
 
306
356
  可同步区域\
@@ -324,7 +374,43 @@
324
374
  订阅 `contextStateRect` 的变化
325
375
 
326
376
  ```ts
327
- box._contentStageRect$.subscribe(rect => {
377
+ box.onValChanged("contentStageRect", rect => {
328
378
  console.log("contentStageRect changed", rect);
329
379
  });
330
- ```
380
+ ```
381
+
382
+ - **highlightStage**
383
+
384
+ 是否高亮 `stage` 区域\
385
+ 默认为 `true`
386
+
387
+ 类型: `boolean`
388
+
389
+ - **setHighlightStage()**
390
+
391
+ 参数: `boolean`
392
+
393
+
394
+ - **$content**
395
+
396
+ 应用窗口的内容区域
397
+
398
+ 类型: `HTMLElement`
399
+
400
+ - **$footer**
401
+
402
+ 应用窗口的底部区域
403
+
404
+ 类型: `HTMLElement`
405
+
406
+ - **resizable**
407
+
408
+ 是否可以改变窗口大小
409
+
410
+ 类型: `boolean`
411
+
412
+ - **draggable**
413
+
414
+ 窗口是否可以拖动
415
+
416
+ 类型: `boolean`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "1.0.0-canary.22",
3
+ "version": "1.0.0-canary.23",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
@@ -1,5 +1,5 @@
1
1
  import { AnimationMode } from "white-web-sdk";
2
- import { debounce, delay, isEqual, pick, throttle } from "lodash";
2
+ import { isEqual, pick, throttle } from "lodash";
3
3
  import type { TeleBoxRect } from "@netless/telebox-insider";
4
4
  import type { Camera, View } from "white-web-sdk";
5
5
  import type { ICamera, ISize } from "../AttributesDelegate";
@@ -14,12 +14,12 @@ export class CameraSynchronizer {
14
14
 
15
15
  constructor(protected saveCamera: SaveCamera) {}
16
16
 
17
- public setRect = debounce((rect: TeleBoxRect) => {
17
+ public setRect = (rect: TeleBoxRect) => {
18
18
  this.rect = rect;
19
19
  if (this.remoteCamera && this.remoteSize) {
20
20
  this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
21
21
  }
22
- }, 10);
22
+ }
23
23
 
24
24
  public setView(view: View) {
25
25
  this.view = view;
@@ -37,22 +37,17 @@ export class CameraSynchronizer {
37
37
  scale = this.rect.height / size.height;
38
38
  }
39
39
  const nextScale = camera.scale * scale;
40
- const moveCamera = () => {
41
- const config: Partial<Camera> & { animationMode: AnimationMode } = {
42
- scale: nextScale,
43
- animationMode: AnimationMode.Immediately,
44
- }
45
- if (camera.centerX !== null) {
46
- config.centerX = camera.centerX;
47
- }
48
- if (camera.centerY !== null) {
49
- config.centerY = camera.centerY;
50
- }
51
- this.view?.moveCamera(config);
40
+ const config: Partial<Camera> & { animationMode: AnimationMode } = {
41
+ scale: nextScale,
42
+ animationMode: AnimationMode.Immediately,
43
+ }
44
+ if (camera.centerX !== null) {
45
+ config.centerX = camera.centerX;
46
+ }
47
+ if (camera.centerY !== null) {
48
+ config.centerY = camera.centerY;
52
49
  }
53
- moveCamera();
54
- // TODO 直接调用 moveCamera 依然会出现 camera 错误的情况,这里暂时加一个 delay 保证 camera 是对的, 后续需要 SDK 进行修改
55
- delay(moveCamera, 50);
50
+ this.view?.moveCamera(config);
56
51
  }
57
52
  }, 10);
58
53
 
@@ -62,14 +57,10 @@ export class CameraSynchronizer {
62
57
  if (this.rect && this.remoteCamera && needMoveCamera) {
63
58
  const scale = this.rect.width / size.width;
64
59
  const nextScale = this.remoteCamera.scale * scale;
65
- const moveCamera = () => {
66
- this.view?.moveCamera({
67
- scale: nextScale,
68
- animationMode: AnimationMode.Immediately,
69
- })
70
- };
71
- moveCamera();
72
- delay(moveCamera, 50);
60
+ this.view?.moveCamera({
61
+ scale: nextScale,
62
+ animationMode: AnimationMode.Immediately,
63
+ })
73
64
  }
74
65
  }
75
66