@netless/window-manager 0.3.16-canary.0 → 0.3.16
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/dist/BoxManager.d.ts +2 -1
- package/dist/MainView.d.ts +3 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/AppManager.ts +3 -0
- package/src/BoxManager.ts +12 -2
- package/src/MainView.ts +24 -30
- package/src/index.ts +3 -1
package/package.json
CHANGED
package/src/AppManager.ts
CHANGED
package/src/BoxManager.ts
CHANGED
@@ -268,8 +268,8 @@ export class BoxManager {
|
|
268
268
|
this.teleBoxManager.update(appId, { x, y }, true);
|
269
269
|
}
|
270
270
|
|
271
|
-
public focusBox({ appId }: AppId): void {
|
272
|
-
this.teleBoxManager.update(appId, { focus: true },
|
271
|
+
public focusBox({ appId }: AppId, skipUpdate = true): void {
|
272
|
+
this.teleBoxManager.update(appId, { focus: true }, skipUpdate);
|
273
273
|
}
|
274
274
|
|
275
275
|
public resizeBox({ appId, width, height, skipUpdate }: ResizeBoxParams): void {
|
@@ -315,6 +315,16 @@ export class BoxManager {
|
|
315
315
|
this.teleBoxManager.setMinimized(minimized, skipUpdate);
|
316
316
|
}
|
317
317
|
|
318
|
+
public focusTopBox(): void {
|
319
|
+
const boxes = this.teleBoxManager.query();
|
320
|
+
if (boxes.length >= 1) {
|
321
|
+
const box = this.getTopBox();
|
322
|
+
if (box) {
|
323
|
+
this.focusBox({ appId: box.id }, false);
|
324
|
+
}
|
325
|
+
}
|
326
|
+
}
|
327
|
+
|
318
328
|
public setReadonly(readonly: boolean) {
|
319
329
|
this.teleBoxManager.setReadonly(readonly);
|
320
330
|
}
|
package/src/MainView.ts
CHANGED
@@ -24,8 +24,14 @@ export class MainViewProxy extends Base {
|
|
24
24
|
emitter.once("mainViewMounted").then(() => {
|
25
25
|
setTimeout(() => {
|
26
26
|
this.start();
|
27
|
+
if (!this.mainViewCamera || !this.mainViewSize) {
|
28
|
+
this.setCameraAndSize();
|
29
|
+
}
|
27
30
|
}, 200); // 等待 mainView 挂载完毕再进行监听,否则会触发不必要的 onSizeUpdated
|
28
31
|
});
|
32
|
+
emitter.on("playgroundSizeChange", () => {
|
33
|
+
this.sizeChangeHandler(this.mainViewSize);
|
34
|
+
});
|
29
35
|
}
|
30
36
|
|
31
37
|
private get mainViewCamera() {
|
@@ -43,10 +49,9 @@ export class MainViewProxy extends Base {
|
|
43
49
|
|
44
50
|
public start() {
|
45
51
|
if (this.started) return;
|
52
|
+
this.sizeChangeHandler(this.mainViewSize);
|
46
53
|
this.addCameraListener();
|
47
54
|
this.manager.refresher?.add(Fields.MainViewCamera, this.cameraReaction);
|
48
|
-
this.manager.refresher?.add(Fields.MainViewSize, this.sizeReaction);
|
49
|
-
this.view.callbacks.on("onSizeUpdated", this.sizeListener);
|
50
55
|
this.started = true;
|
51
56
|
}
|
52
57
|
|
@@ -60,6 +65,7 @@ export class MainViewProxy extends Base {
|
|
60
65
|
() => this.mainViewCamera,
|
61
66
|
camera => {
|
62
67
|
if (camera && camera.id !== this.context.uid) {
|
68
|
+
this.moveCameraToContian(this.mainViewSize);
|
63
69
|
this.moveCamera(camera);
|
64
70
|
}
|
65
71
|
},
|
@@ -69,20 +75,12 @@ export class MainViewProxy extends Base {
|
|
69
75
|
);
|
70
76
|
};
|
71
77
|
|
72
|
-
private
|
73
|
-
|
74
|
-
()
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
this.moveCamera(this.mainViewCamera);
|
79
|
-
}
|
80
|
-
},
|
81
|
-
{
|
82
|
-
fireImmediately: true,
|
83
|
-
}
|
84
|
-
);
|
85
|
-
};
|
78
|
+
private sizeChangeHandler = debounce((size: Size) => {
|
79
|
+
if (size) {
|
80
|
+
this.moveCameraToContian(size);
|
81
|
+
this.moveCamera(this.mainViewCamera);
|
82
|
+
}
|
83
|
+
}, 30);
|
86
84
|
|
87
85
|
public get view(): View {
|
88
86
|
return this.mainView;
|
@@ -104,9 +102,9 @@ export class MainViewProxy extends Base {
|
|
104
102
|
return mainView;
|
105
103
|
}
|
106
104
|
|
107
|
-
private
|
105
|
+
private onCameraUpdatedByDevice = (camera: Camera) => {
|
108
106
|
this.store.setMainViewCamera({ ...camera, id: this.context.uid });
|
109
|
-
if (this.
|
107
|
+
if (!isEqual(this.mainViewSize, {...this.mainView.size, id: this.context.uid})) {
|
110
108
|
this.setMainViewSize(this.view.size);
|
111
109
|
}
|
112
110
|
};
|
@@ -138,28 +136,25 @@ export class MainViewProxy extends Base {
|
|
138
136
|
this.context.blurFocusBox();
|
139
137
|
}
|
140
138
|
|
141
|
-
private sizeListener = (size: Size) => {
|
142
|
-
this.setMainViewSize(size);
|
143
|
-
callbacks.emit("cameraStateChange", this.cameraState);
|
144
|
-
};
|
145
|
-
|
146
139
|
public setMainViewSize = debounce(size => {
|
147
140
|
this.store.setMainViewSize({ ...size, id: this.context.uid });
|
148
141
|
}, 50);
|
149
142
|
|
150
143
|
private addCameraListener() {
|
151
|
-
this.view.callbacks.on("onCameraUpdatedByDevice", this.
|
152
|
-
this.view.callbacks.on("onCameraUpdated", this.
|
144
|
+
this.view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
145
|
+
this.view.callbacks.on("onCameraUpdated", this.onCameraOrSizeUpdated);
|
146
|
+
this.view.callbacks.on("onSizeUpdated", this.onCameraOrSizeUpdated);
|
153
147
|
}
|
154
148
|
|
155
149
|
private removeCameraListener() {
|
156
|
-
this.view.callbacks.off("onCameraUpdatedByDevice", this.
|
157
|
-
this.view.callbacks.off("onCameraUpdated", this.
|
150
|
+
this.view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
151
|
+
this.view.callbacks.off("onCameraUpdated", this.onCameraOrSizeUpdated);
|
152
|
+
this.view.callbacks.off("onSizeUpdated", this.onCameraOrSizeUpdated);
|
158
153
|
}
|
159
154
|
|
160
|
-
private
|
155
|
+
private onCameraOrSizeUpdated = () => {
|
161
156
|
callbacks.emit("cameraStateChange", this.cameraState);
|
162
|
-
}
|
157
|
+
};
|
163
158
|
|
164
159
|
public switchViewModeToWriter(): void {
|
165
160
|
if (!this.manager.canOperate) return;
|
@@ -203,7 +198,6 @@ export class MainViewProxy extends Base {
|
|
203
198
|
this.removeCameraListener();
|
204
199
|
this.manager.refresher?.remove(Fields.MainViewCamera);
|
205
200
|
this.manager.refresher?.remove(Fields.MainViewSize);
|
206
|
-
this.view.callbacks.off("onSizeUpdated", this.sizeListener);
|
207
201
|
this.started = false;
|
208
202
|
}
|
209
203
|
|
package/src/index.ts
CHANGED
@@ -135,6 +135,7 @@ export type EmitterEvent = {
|
|
135
135
|
mainViewMounted: undefined;
|
136
136
|
observerIdChange: number;
|
137
137
|
boxStateChange: string;
|
138
|
+
playgroundSizeChange: DOMRect;
|
138
139
|
};
|
139
140
|
|
140
141
|
export const emitter: Emittery<EmitterEvent> = new Emittery();
|
@@ -175,7 +176,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
175
176
|
public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
|
176
177
|
private static isCreated = false;
|
177
178
|
|
178
|
-
public version = "0.3.16
|
179
|
+
public version = "0.3.16";
|
179
180
|
|
180
181
|
public appListeners?: AppListeners;
|
181
182
|
|
@@ -700,6 +701,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
700
701
|
this.updateSizer(containerRect, sizer, wrapper);
|
701
702
|
this.cursorManager?.updateContainerRect();
|
702
703
|
this.appManager?.boxManager.updateManagerRect();
|
704
|
+
emitter.emit("playgroundSizeChange", containerRect);
|
703
705
|
}
|
704
706
|
});
|
705
707
|
|