@netless/window-manager 0.4.22 → 0.4.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.
- package/CHANGELOG.md +5 -1
- package/dist/AttributesDelegate.d.ts +9 -6
- package/dist/InternalEmitter.d.ts +1 -0
- package/dist/View/MainView.d.ts +2 -0
- package/dist/index.es.js +28 -7
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +10 -10
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/AppManager.ts +1 -0
- package/src/AttributesDelegate.ts +14 -2
- package/src/InternalEmitter.ts +1 -0
- package/src/View/MainView.ts +25 -8
package/package.json
CHANGED
package/src/AppManager.ts
CHANGED
@@ -38,6 +38,11 @@ export type StoreContext = {
|
|
38
38
|
safeUpdateAttributes: (keys: string[], value: any) => void;
|
39
39
|
safeSetAttributes: (attributes: any) => void;
|
40
40
|
}
|
41
|
+
|
42
|
+
export type ICamera = Camera & { id: string };
|
43
|
+
|
44
|
+
export type ISize = Size & { id: string };
|
45
|
+
|
41
46
|
export class AttributesDelegate {
|
42
47
|
|
43
48
|
constructor(private context: StoreContext) {}
|
@@ -152,14 +157,21 @@ export class AttributesDelegate {
|
|
152
157
|
return get(this.attributes, [Fields.MainViewSize]);
|
153
158
|
}
|
154
159
|
|
155
|
-
public setMainViewCamera(camera:
|
160
|
+
public setMainViewCamera(camera: ICamera) {
|
156
161
|
this.context.safeSetAttributes({ [Fields.MainViewCamera]: { ...camera } });
|
157
162
|
}
|
158
163
|
|
159
|
-
public setMainViewSize(size:
|
164
|
+
public setMainViewSize(size: ISize) {
|
160
165
|
this.context.safeSetAttributes({ [Fields.MainViewSize]: { ...size } });
|
161
166
|
}
|
162
167
|
|
168
|
+
public setMainViewCameraAndSize(camera: ICamera, size: ISize) {
|
169
|
+
this.context.safeSetAttributes({
|
170
|
+
[Fields.MainViewCamera]: { ...camera },
|
171
|
+
[Fields.MainViewSize]: { ...size },
|
172
|
+
});
|
173
|
+
}
|
174
|
+
|
163
175
|
public setAppFocus = (appId: string, focus: boolean) => {
|
164
176
|
if (focus) {
|
165
177
|
this.context.safeSetAttributes({ [Fields.Focus]: appId });
|
package/src/InternalEmitter.ts
CHANGED
package/src/View/MainView.ts
CHANGED
@@ -25,10 +25,8 @@ export class MainViewProxy {
|
|
25
25
|
emitter.once("mainViewMounted").then(() => {
|
26
26
|
this.addMainViewListener();
|
27
27
|
this.start();
|
28
|
-
|
29
|
-
|
30
|
-
this.setCameraAndSize();
|
31
|
-
}
|
28
|
+
this.ensureCameraAndSize();
|
29
|
+
this.startListenWritableChange();
|
32
30
|
});
|
33
31
|
const playgroundSizeChangeListener = () => {
|
34
32
|
this.sizeChangeHandler(this.mainViewSize);
|
@@ -39,6 +37,23 @@ export class MainViewProxy {
|
|
39
37
|
});
|
40
38
|
}
|
41
39
|
|
40
|
+
private startListenWritableChange = () => {
|
41
|
+
this.sideEffectManager.add(() => {
|
42
|
+
return emitter.on("writableChange", isWritable => {
|
43
|
+
if (isWritable) {
|
44
|
+
this.ensureCameraAndSize();
|
45
|
+
}
|
46
|
+
});
|
47
|
+
});
|
48
|
+
}
|
49
|
+
|
50
|
+
public ensureCameraAndSize() {
|
51
|
+
if (!this.mainViewCamera || !this.mainViewSize) {
|
52
|
+
this.manager.dispatchInternalEvent(Events.InitMainViewCamera);
|
53
|
+
this.setCameraAndSize();
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
42
57
|
private get mainViewCamera() {
|
43
58
|
return this.store.getMainViewCamera();
|
44
59
|
}
|
@@ -62,11 +77,12 @@ export class MainViewProxy {
|
|
62
77
|
|
63
78
|
public addCameraReaction = () => {
|
64
79
|
this.manager.refresher?.add(Fields.MainViewCamera, this.cameraReaction);
|
65
|
-
}
|
80
|
+
};
|
66
81
|
|
67
82
|
public setCameraAndSize(): void {
|
68
|
-
|
69
|
-
|
83
|
+
const camera = { ...this.mainView.camera, id: this.manager.uid };
|
84
|
+
const size = { ...this.mainView.size, id: this.manager.uid };
|
85
|
+
this.store.setMainViewCameraAndSize(camera, size);
|
70
86
|
}
|
71
87
|
|
72
88
|
private cameraReaction = () => {
|
@@ -77,7 +93,8 @@ export class MainViewProxy {
|
|
77
93
|
this.moveCameraToContian(this.mainViewSize);
|
78
94
|
this.moveCamera(camera);
|
79
95
|
}
|
80
|
-
},
|
96
|
+
},
|
97
|
+
{ fireImmediately: true }
|
81
98
|
);
|
82
99
|
};
|
83
100
|
|