@netless/window-manager 1.0.13-test.3 → 1.0.13-test.5
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/index.d.ts +1 -0
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/AppListener.ts +1 -1
- package/src/AppManager.ts +6 -2
- package/src/ContainerResizeObserver.ts +2 -0
- package/src/Utils/RoomHacker.ts +1 -1
- package/src/Utils/log.ts +2 -2
- package/src/View/MainView.ts +12 -5
- package/src/index.ts +21 -2
package/package.json
CHANGED
package/src/AppListener.ts
CHANGED
|
@@ -47,7 +47,7 @@ export class AppListeners {
|
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
49
49
|
case Events.SetMainViewScenePath: {
|
|
50
|
-
console.log("[window-manager] mainMagixEventListener "
|
|
50
|
+
console.log("[window-manager] mainMagixEventListener " + JSON.stringify(data.payload));
|
|
51
51
|
this.setMainViewScenePathHandler(data.payload);
|
|
52
52
|
break;
|
|
53
53
|
}
|
package/src/AppManager.ts
CHANGED
|
@@ -159,7 +159,7 @@ export class AppManager {
|
|
|
159
159
|
sceneName = this.callbacksNode?.scenes[nextIndex];
|
|
160
160
|
}
|
|
161
161
|
if (sceneName) {
|
|
162
|
-
console.log("[window-manager] onRemoveScenes setMainViewScenePath"
|
|
162
|
+
console.log("[window-manager] onRemoveScenes setMainViewScenePath" + `${ROOT_DIR}${sceneName}`);
|
|
163
163
|
this.setMainViewScenePath(`${ROOT_DIR}${sceneName}`);
|
|
164
164
|
}
|
|
165
165
|
await this.setMainViewSceneIndex(nextIndex);
|
|
@@ -713,7 +713,11 @@ export class AppManager {
|
|
|
713
713
|
callbacks.emit("onMainViewMounted", mainView);
|
|
714
714
|
const hasRoot = this.hasRoot(mainView.divElement);
|
|
715
715
|
const rect = this.getRectByDivElement(mainView.divElement);
|
|
716
|
-
console.log("[window-manager] bindMainView hasRoot"
|
|
716
|
+
console.log("[window-manager] bindMainView hasRoot" + hasRoot + JSON.stringify(rect) +
|
|
717
|
+
window.outerHeight + window.outerWidth,
|
|
718
|
+
window.visualViewport?.width ?? "null", window.visualViewport?.height ?? "null",
|
|
719
|
+
window.visualViewport?.offsetLeft ?? "null", window.visualViewport?.offsetTop ?? "null",
|
|
720
|
+
);
|
|
717
721
|
}
|
|
718
722
|
|
|
719
723
|
private hasRoot(divElement: HTMLDivElement){
|
|
@@ -28,12 +28,14 @@ export class ContainerResizeObserver {
|
|
|
28
28
|
sizer: HTMLElement,
|
|
29
29
|
wrapper: HTMLDivElement
|
|
30
30
|
) {
|
|
31
|
+
console.log(`[window-manager] observePlaygroundSize ${container.getBoundingClientRect(), sizer.getBoundingClientRect(), wrapper.getBoundingClientRect()}`);
|
|
31
32
|
this.updateSizer(container.getBoundingClientRect(), sizer, wrapper);
|
|
32
33
|
|
|
33
34
|
this.containerResizeObserver = new ResizeObserver(entries => {
|
|
34
35
|
const containerRect = entries[0]?.contentRect;
|
|
35
36
|
if (containerRect) {
|
|
36
37
|
this.updateSizer(containerRect, sizer, wrapper);
|
|
38
|
+
console.log(`[window-manager] containerResizeObserver ${containerRect}`);
|
|
37
39
|
this.emitter.emit("playgroundSizeChange", containerRect);
|
|
38
40
|
}
|
|
39
41
|
});
|
package/src/Utils/RoomHacker.ts
CHANGED
|
@@ -37,7 +37,7 @@ export const replaceRoomFunction = (room: Room | Player, manager: WindowManager)
|
|
|
37
37
|
room.scalePptToFit = (...args) => {
|
|
38
38
|
_scalePptToFit.call(room, ...args);
|
|
39
39
|
if (manager.appManager?.mainViewProxy) {
|
|
40
|
-
console.log("[window-manager] scalePptToFit "
|
|
40
|
+
console.log("[window-manager] scalePptToFit " + JSON.stringify(args));
|
|
41
41
|
manager.appManager.mainViewProxy.setCameraAndSize();
|
|
42
42
|
}
|
|
43
43
|
};
|
package/src/Utils/log.ts
CHANGED
|
@@ -26,7 +26,7 @@ export class LocalConsole {
|
|
|
26
26
|
if (args === null) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
console.log(`[window-manager][${this.name}]
|
|
29
|
+
console.log(`[window-manager][${this.name}]: ${args.join(", ")}`);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
log(...args: unknown[]): void {
|
|
@@ -39,6 +39,6 @@ export class LocalConsole {
|
|
|
39
39
|
this.flushTimer = setTimeout(() => this.flush(), ms);
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
console.log(`[window-manager][${this.name}]
|
|
42
|
+
console.log(`[window-manager][${this.name}]: ${args.join(", ")}`);
|
|
43
43
|
}
|
|
44
44
|
}
|
package/src/View/MainView.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { AppManager } from "../AppManager";
|
|
|
11
11
|
import { Events } from "../constants";
|
|
12
12
|
import { LocalConsole } from "../Utils/log";
|
|
13
13
|
|
|
14
|
+
(window as any).___local_log = (window as any).___local_log || new Set();
|
|
14
15
|
export class MainViewProxy {
|
|
15
16
|
/** Refresh the view's camera in an interval of 1.5s. */
|
|
16
17
|
public polling = false;
|
|
@@ -36,8 +37,13 @@ export class MainViewProxy {
|
|
|
36
37
|
this.startListenWritableChange();
|
|
37
38
|
});
|
|
38
39
|
const playgroundSizeChangeListener = () => {
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
this.playgroundSizeChangeListenerLocalConsole.log(
|
|
41
|
+
JSON.stringify(this.mainViewSize),
|
|
42
|
+
JSON.stringify(this.mainViewCamera),
|
|
43
|
+
window.outerHeight, window.outerWidth,
|
|
44
|
+
window.visualViewport?.width ?? "null", window.visualViewport?.height ?? "null",
|
|
45
|
+
window.visualViewport?.offsetLeft ?? "null", window.visualViewport?.offsetTop ?? "null",
|
|
46
|
+
);
|
|
41
47
|
this.sizeChangeHandler(this.mainViewSize);
|
|
42
48
|
};
|
|
43
49
|
this.sideEffectManager.add(() => {
|
|
@@ -126,7 +132,7 @@ export class MainViewProxy {
|
|
|
126
132
|
() => this.mainViewCamera,
|
|
127
133
|
camera => {
|
|
128
134
|
if (camera && camera.id !== this.manager.uid) {
|
|
129
|
-
console.log("[window-manager] cameraReaction "
|
|
135
|
+
console.log("[window-manager] cameraReaction " + JSON.stringify(camera) + JSON.stringify(this.mainViewSize));
|
|
130
136
|
this.moveCameraToContian(this.mainViewSize);
|
|
131
137
|
this.moveCamera(camera);
|
|
132
138
|
}
|
|
@@ -137,16 +143,17 @@ export class MainViewProxy {
|
|
|
137
143
|
|
|
138
144
|
public sizeChangeHandler = debounce((size: Size) => {
|
|
139
145
|
if (size) {
|
|
140
|
-
console.log("[window-manager] sizeChangeHandler current size and camera", JSON.stringify(size), JSON.stringify(this.mainViewCamera));
|
|
141
146
|
this.moveCameraToContian(size);
|
|
142
147
|
this.moveCamera(this.mainViewCamera);
|
|
148
|
+
console.log("[window-manager] sizeChangeHandler current size and camera" + JSON.stringify(size) + JSON.stringify(this.mainViewCamera) +
|
|
149
|
+
JSON.stringify(this.mainView.camera) + JSON.stringify(this.mainView.size));
|
|
143
150
|
}
|
|
144
151
|
this.ensureMainViewSize();
|
|
145
152
|
}, 30);
|
|
146
153
|
|
|
147
154
|
public onUpdateContainerSizeRatio = () => {
|
|
148
155
|
const size = this.store.getMainViewSize();
|
|
149
|
-
console.log("[window-manager] onUpdateContainerSizeRatio "
|
|
156
|
+
console.log("[window-manager] onUpdateContainerSizeRatio " + JSON.stringify(size));
|
|
150
157
|
this.sizeChangeHandler(size);
|
|
151
158
|
};
|
|
152
159
|
|
package/src/index.ts
CHANGED
|
@@ -255,10 +255,12 @@ export class WindowManager
|
|
|
255
255
|
(window as any).NETLESS_DEPS = __APP_DEPENDENCIES__;
|
|
256
256
|
this.visibleStateListener();
|
|
257
257
|
document.addEventListener("visibilitychange", this.visibleStateListener);
|
|
258
|
+
this.emitter.on('mainViewScenePathChange', this.onMainViewScenePathChangeHandler)
|
|
258
259
|
}
|
|
259
260
|
|
|
261
|
+
|
|
260
262
|
private visibleStateListener = () => {
|
|
261
|
-
console.log("[window-manager] visibleStateListener isVisible:"
|
|
263
|
+
console.log("[window-manager] visibleStateListener isVisible:" + !document.hidden);
|
|
262
264
|
}
|
|
263
265
|
|
|
264
266
|
public static onCreate(manager: WindowManager) {
|
|
@@ -392,10 +394,26 @@ export class WindowManager
|
|
|
392
394
|
console.warn("[WindowManager]: indexedDB open failed");
|
|
393
395
|
console.log(error);
|
|
394
396
|
}
|
|
397
|
+
manager.emitter.on('mainViewScenePathChange', manager.onMainViewScenePathChangeHandler)
|
|
395
398
|
return manager;
|
|
396
399
|
}
|
|
397
400
|
|
|
398
|
-
|
|
401
|
+
public onMainViewScenePathChangeHandler = (scenePath: string) => {
|
|
402
|
+
const mainViewElement = this.mainView.divElement;
|
|
403
|
+
if (mainViewElement) {
|
|
404
|
+
const backgroundImage = mainViewElement.querySelector('.background img');
|
|
405
|
+
if (backgroundImage) {
|
|
406
|
+
// todo 获取到 back ground image 的 rect情况以及css情况是否可见
|
|
407
|
+
const backgroundImageRect = backgroundImage?.getBoundingClientRect();
|
|
408
|
+
const backgroundImageCSS = window.getComputedStyle(backgroundImage);
|
|
409
|
+
const backgroundImageVisible = backgroundImageRect?.width > 0 && backgroundImageRect?.height > 0 && backgroundImageCSS.display !== 'none';
|
|
410
|
+
console.log("[window-manager] backgroundImageVisible" + backgroundImageVisible);
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
console.log("[window-manager] onMainViewScenePathChange" + scenePath + 'backgroundImageVisible is not found');
|
|
414
|
+
}
|
|
415
|
+
console.log("[window-manager] onMainViewScenePathChange" + scenePath + 'mainViewElement is not found');
|
|
416
|
+
}
|
|
399
417
|
|
|
400
418
|
private static initManager(room: Room): Promise<WindowManager | undefined> {
|
|
401
419
|
return createInvisiblePlugin(room);
|
|
@@ -1065,6 +1083,7 @@ export class WindowManager
|
|
|
1065
1083
|
}
|
|
1066
1084
|
WindowManager.params = undefined;
|
|
1067
1085
|
document.removeEventListener("visibilitychange", this.visibleStateListener);
|
|
1086
|
+
this.emitter.off('mainViewScenePathChange', this.onMainViewScenePathChangeHandler);
|
|
1068
1087
|
this._iframeBridge?.destroy();
|
|
1069
1088
|
this._iframeBridge = undefined;
|
|
1070
1089
|
log("Destroyed");
|