@netless/window-manager 1.0.0-canary.6 → 1.0.0-canary.9

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.
@@ -32,34 +32,29 @@ export class MainViewProxy {
32
32
  this.ensureCameraAndSize();
33
33
  this.startListenWritableChange();
34
34
  });
35
- this.sideEffectManager.add(() => {
36
- return emitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio);
37
- });
38
- this.sideEffectManager.add(() => {
39
- return emitter.on("startReconnect", () => {
35
+ this.sideEffectManager.add(() => [
36
+ emitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio),
37
+ emitter.on("startReconnect", () => {
40
38
  releaseView(this.mainView);
41
- });
42
- });
39
+ }),
40
+ emitter.on("playgroundSizeChange", rect => {
41
+ this.synchronizer.setRect(rect);
42
+ })
43
+ ]);
43
44
  const rect = this.manager.boxManager?.stageRect;
44
45
  if (rect) {
45
46
  this.synchronizer.setRect(rect);
46
47
  }
47
- this.sideEffectManager.add(() => {
48
- return emitter.on("playgroundSizeChange", rect => {
49
- this.synchronizer.setRect(rect);
50
- // this.synchronizer.onLocalSizeUpdate(rect);
51
- });
52
- });
53
48
  }
54
49
 
55
50
  private startListenWritableChange = () => {
56
- this.sideEffectManager.add(() => {
57
- return emitter.on("writableChange", isWritable => {
51
+ this.sideEffectManager.add(() =>
52
+ emitter.on("writableChange", isWritable => {
58
53
  if (isWritable) {
59
54
  this.ensureCameraAndSize();
60
55
  }
61
- });
62
- });
56
+ })
57
+ );
63
58
  };
64
59
 
65
60
  public ensureCameraAndSize() {
@@ -87,14 +82,13 @@ export class MainViewProxy {
87
82
 
88
83
  public start() {
89
84
  if (this.started) return;
90
- this.sizeChangeHandler(this.mainViewSize);
91
85
  this.addCameraListener();
92
86
  this.addCameraReaction();
93
87
  this.started = true;
94
88
  }
95
89
 
96
90
  public addCameraReaction = () => {
97
- this.manager.refresher?.add(Fields.MainViewCamera, this.cameraReaction);
91
+ this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
98
92
  };
99
93
 
100
94
  public setCameraAndSize(): void {
@@ -118,15 +112,8 @@ export class MainViewProxy {
118
112
  );
119
113
  };
120
114
 
121
- public sizeChangeHandler = debounce((size: Size) => {
122
- if (size) {
123
- // this.synchronizer.onLocalSizeUpdate(size);
124
- }
125
- }, 30);
126
-
127
115
  public onUpdateContainerSizeRatio = () => {
128
116
  const size = this.store.getMainViewSize();
129
- this.sizeChangeHandler(size);
130
117
  if (size.id === this.manager.uid) {
131
118
  this.setCameraAndSize();
132
119
  }
@@ -242,8 +229,8 @@ export class MainViewProxy {
242
229
 
243
230
  public stop() {
244
231
  this.removeCameraListener();
245
- this.manager.refresher?.remove(Fields.MainViewCamera);
246
- this.manager.refresher?.remove(Fields.MainViewSize);
232
+ this.manager.refresher.remove(Fields.MainViewCamera);
233
+ this.manager.refresher.remove(Fields.MainViewSize);
247
234
  this.started = false;
248
235
  }
249
236
 
package/src/index.ts CHANGED
@@ -129,8 +129,8 @@ export type MountParams = {
129
129
  container?: HTMLElement;
130
130
  /** 白板高宽比例, 默认为 9 / 16 */
131
131
  containerSizeRatio?: number;
132
- /** 显示 PS 透明背景,默认 true */
133
- chessboard?: boolean;
132
+ /** 是否高亮显示同步区域, 默认为 true */
133
+ highlightStage?: boolean;
134
134
  collectorContainer?: HTMLElement;
135
135
  collectorStyles?: Partial<CSSStyleDeclaration>;
136
136
  overwriteStyles?: string;
@@ -241,6 +241,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
241
241
  collectorStyles: params.collectorStyles,
242
242
  prefersColorScheme: params.prefersColorScheme,
243
243
  stageRatio: params.containerSizeRatio,
244
+ highlightStage: params.highlightStage
244
245
  });
245
246
  manager.appManager?.setBoxManager(manager.boxManager);
246
247
  if (params.container) {
@@ -504,6 +505,18 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
504
505
  }
505
506
  }
506
507
 
508
+ public async jumpPage(index: number): Promise<boolean> {
509
+ if (!this.appManager) {
510
+ return false;
511
+ }
512
+ if (index < 0 || index >= this.pageState.length) {
513
+ console.warn(`[WindowManager]: index ${index} out of range`);
514
+ return false;
515
+ }
516
+ await this.appManager.setMainViewSceneIndex(index);
517
+ return true;
518
+ }
519
+
507
520
  public async addPage(params?: AddPageParams): Promise<void> {
508
521
  if (this.appManager) {
509
522
  const after = params?.after;
@@ -1,7 +0,0 @@
1
- import type { Camera, Size } from "white-web-sdk";
2
- export interface ViewSync {
3
- readonly camera: Camera;
4
- readonly size: Size;
5
- setCamera: (camera: Camera) => void;
6
- setSize: (size: Size) => void;
7
- }
@@ -1,10 +0,0 @@
1
- import type { Camera, Size } from "white-web-sdk";
2
-
3
-
4
- export interface ViewSync {
5
- readonly camera: Camera;
6
- readonly size: Size;
7
-
8
- setCamera: (camera: Camera) => void;
9
- setSize: (size: Size) => void;
10
- }