@netless/window-manager 1.0.13-test.12 → 1.0.13-test.13
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 +5 -1
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/View/MainView.ts +73 -16
package/dist/index.mjs
CHANGED
|
@@ -7791,6 +7791,7 @@ class MainViewProxy {
|
|
|
7791
7791
|
this.polling = false;
|
|
7792
7792
|
this.started = false;
|
|
7793
7793
|
this.mainViewIsAddListener = false;
|
|
7794
|
+
this.isForcingMainViewDivElement = false;
|
|
7794
7795
|
this.store = this.manager.store;
|
|
7795
7796
|
this.viewMode = this.manager.windowManger.viewMode;
|
|
7796
7797
|
this.sideEffectManager = new o$2();
|
|
@@ -7863,10 +7864,15 @@ class MainViewProxy {
|
|
|
7863
7864
|
return;
|
|
7864
7865
|
const target = entry.target;
|
|
7865
7866
|
const child = target.children[0];
|
|
7867
|
+
const observedSize = {
|
|
7868
|
+
width: entry.contentRect.width,
|
|
7869
|
+
height: entry.contentRect.height
|
|
7870
|
+
};
|
|
7866
7871
|
console.log("[window-manager] mainViewResizeObserver " + JSON.stringify({
|
|
7872
|
+
sameTarget: target === this.mainView.divElement,
|
|
7867
7873
|
contentRect: {
|
|
7868
|
-
width:
|
|
7869
|
-
height:
|
|
7874
|
+
width: observedSize.width,
|
|
7875
|
+
height: observedSize.height
|
|
7870
7876
|
},
|
|
7871
7877
|
client: {
|
|
7872
7878
|
width: target.clientWidth,
|
|
@@ -7886,16 +7892,18 @@ class MainViewProxy {
|
|
|
7886
7892
|
} : null,
|
|
7887
7893
|
viewSize: this.mainView.size
|
|
7888
7894
|
}));
|
|
7895
|
+
this.forceSyncMainViewDivElement("mainViewResizeObserver", observedSize, target);
|
|
7889
7896
|
};
|
|
7890
7897
|
this._syncMainViewTimer = 0;
|
|
7891
|
-
this.
|
|
7892
|
-
console.log("[window-manager]
|
|
7898
|
+
this.handleCameraOrSizeUpdated = (source, payload) => {
|
|
7899
|
+
console.log("[window-manager] " + source + " payload " + JSON.stringify(payload));
|
|
7900
|
+
console.log("[window-manager] " + source + " state " + JSON.stringify(this.cameraState));
|
|
7893
7901
|
if (this.mainView.divElement) {
|
|
7894
7902
|
const children2 = this.mainView.divElement.children;
|
|
7895
|
-
console.log("[window-manager]
|
|
7903
|
+
console.log("[window-manager] " + source + " rect " + JSON.stringify(this.mainView.divElement.getBoundingClientRect()));
|
|
7896
7904
|
const child = children2[0];
|
|
7897
7905
|
if (child) {
|
|
7898
|
-
console.log("[window-manager] child" + JSON.stringify(child.getBoundingClientRect()));
|
|
7906
|
+
console.log("[window-manager] " + source + " child" + JSON.stringify(child.getBoundingClientRect()));
|
|
7899
7907
|
}
|
|
7900
7908
|
}
|
|
7901
7909
|
callbacks$1.emit("cameraStateChange", this.cameraState);
|
|
@@ -7905,6 +7913,12 @@ class MainViewProxy {
|
|
|
7905
7913
|
}
|
|
7906
7914
|
this.ensureMainViewSize();
|
|
7907
7915
|
};
|
|
7916
|
+
this.onCameraUpdated = (camera) => {
|
|
7917
|
+
this.handleCameraOrSizeUpdated("onCameraUpdated", camera);
|
|
7918
|
+
};
|
|
7919
|
+
this.onSizeUpdated = (size2) => {
|
|
7920
|
+
this.handleCameraOrSizeUpdated("onSizeUpdated", size2);
|
|
7921
|
+
};
|
|
7908
7922
|
this.syncMainView = (room) => {
|
|
7909
7923
|
if (room.isWritable) {
|
|
7910
7924
|
console.log("[window-manager] syncMainView ");
|
|
@@ -7925,7 +7939,6 @@ class MainViewProxy {
|
|
|
7925
7939
|
});
|
|
7926
7940
|
const playgroundSizeChangeListener = () => {
|
|
7927
7941
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7928
|
-
this.refreshScreenSizeIfStale();
|
|
7929
7942
|
this.playgroundSizeChangeListenerLocalConsole.log(
|
|
7930
7943
|
JSON.stringify(this.mainView.camera),
|
|
7931
7944
|
JSON.stringify(this.mainView.size),
|
|
@@ -7977,22 +7990,46 @@ class MainViewProxy {
|
|
|
7977
7990
|
this.moveCamera(this.mainViewCamera);
|
|
7978
7991
|
}
|
|
7979
7992
|
refreshScreenSizeIfStale() {
|
|
7980
|
-
var _a;
|
|
7981
7993
|
const element2 = this.mainView.divElement;
|
|
7982
7994
|
if (!element2)
|
|
7983
7995
|
return;
|
|
7984
7996
|
const { width, height } = element2.getBoundingClientRect();
|
|
7985
7997
|
if (width <= 0 || height <= 0)
|
|
7986
7998
|
return;
|
|
7999
|
+
this.forceSyncMainViewDivElement("playgroundSizeChange", { width, height }, element2);
|
|
8000
|
+
}
|
|
8001
|
+
forceSyncMainViewDivElement(reason, observedSize, element2) {
|
|
7987
8002
|
const { width: viewWidth, height: viewHeight } = this.mainView.size;
|
|
7988
|
-
if (Math.abs(viewWidth - width)
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
8003
|
+
if (Math.abs(viewWidth - observedSize.width) <= 0.5 && Math.abs(viewHeight - observedSize.height) <= 0.5) {
|
|
8004
|
+
return;
|
|
8005
|
+
}
|
|
8006
|
+
if (this.isForcingMainViewDivElement) {
|
|
8007
|
+
console.log("[window-manager] skipForceSyncMainViewDivElement " + JSON.stringify({
|
|
8008
|
+
reason,
|
|
8009
|
+
observedSize,
|
|
8010
|
+
viewSize: this.mainView.size
|
|
7993
8011
|
}));
|
|
7994
|
-
|
|
8012
|
+
return;
|
|
7995
8013
|
}
|
|
8014
|
+
this.isForcingMainViewDivElement = true;
|
|
8015
|
+
console.log("[window-manager] forceSyncMainViewDivElement " + JSON.stringify({
|
|
8016
|
+
reason,
|
|
8017
|
+
observedSize,
|
|
8018
|
+
viewSize: this.mainView.size,
|
|
8019
|
+
mainViewSize: this.mainViewSize,
|
|
8020
|
+
mainViewCamera: this.mainViewCamera
|
|
8021
|
+
}));
|
|
8022
|
+
this.mainView.divElement = null;
|
|
8023
|
+
this.mainView.divElement = element2;
|
|
8024
|
+
queueMicrotask(() => {
|
|
8025
|
+
const rect = element2.getBoundingClientRect();
|
|
8026
|
+
console.log("[window-manager] forceSyncMainViewDivElementResult " + JSON.stringify({
|
|
8027
|
+
reason,
|
|
8028
|
+
viewSize: this.mainView.size,
|
|
8029
|
+
rect: { width: rect.width, height: rect.height }
|
|
8030
|
+
}));
|
|
8031
|
+
this.isForcingMainViewDivElement = false;
|
|
8032
|
+
});
|
|
7996
8033
|
}
|
|
7997
8034
|
start() {
|
|
7998
8035
|
console.log("[window-manager] start " + JSON.stringify(this.mainViewSize));
|
|
@@ -8004,6 +8041,7 @@ class MainViewProxy {
|
|
|
8004
8041
|
if (this.manager.room)
|
|
8005
8042
|
this.syncMainView(this.manager.room);
|
|
8006
8043
|
this.started = true;
|
|
8044
|
+
console.log("[window-manager] start end " + JSON.stringify(this.mainViewSize), JSON.stringify(this.mainView.size));
|
|
8007
8045
|
}
|
|
8008
8046
|
setCameraAndSize() {
|
|
8009
8047
|
const camera = { ...this.mainView.camera, id: this.manager.uid };
|
|
@@ -8079,13 +8117,13 @@ class MainViewProxy {
|
|
|
8079
8117
|
}
|
|
8080
8118
|
addCameraListener() {
|
|
8081
8119
|
this.view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
|
8082
|
-
this.view.callbacks.on("onCameraUpdated", this.
|
|
8083
|
-
this.view.callbacks.on("onSizeUpdated", this.
|
|
8120
|
+
this.view.callbacks.on("onCameraUpdated", this.onCameraUpdated);
|
|
8121
|
+
this.view.callbacks.on("onSizeUpdated", this.onSizeUpdated);
|
|
8084
8122
|
}
|
|
8085
8123
|
removeCameraListener() {
|
|
8086
8124
|
this.view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
|
8087
|
-
this.view.callbacks.off("onCameraUpdated", this.
|
|
8088
|
-
this.view.callbacks.off("onSizeUpdated", this.
|
|
8125
|
+
this.view.callbacks.off("onCameraUpdated", this.onCameraUpdated);
|
|
8126
|
+
this.view.callbacks.off("onSizeUpdated", this.onSizeUpdated);
|
|
8089
8127
|
}
|
|
8090
8128
|
observeMainViewDivElement() {
|
|
8091
8129
|
this.disconnectMainViewResizeObserver();
|
|
@@ -8093,6 +8131,10 @@ class MainViewProxy {
|
|
|
8093
8131
|
return;
|
|
8094
8132
|
if (!this.mainView.divElement)
|
|
8095
8133
|
return;
|
|
8134
|
+
console.log("[window-manager] observeMainViewDivElement " + JSON.stringify({
|
|
8135
|
+
rect: this.mainView.divElement.getBoundingClientRect(),
|
|
8136
|
+
viewSize: this.mainView.size
|
|
8137
|
+
}));
|
|
8096
8138
|
this.mainViewResizeObserver = new window.ResizeObserver(this.onResize);
|
|
8097
8139
|
this.mainViewResizeObserver.observe(this.mainView.divElement);
|
|
8098
8140
|
}
|
|
@@ -8139,6 +8181,7 @@ class MainViewProxy {
|
|
|
8139
8181
|
this.started = false;
|
|
8140
8182
|
}
|
|
8141
8183
|
destroy() {
|
|
8184
|
+
console.log("[window-manager] destroy ");
|
|
8142
8185
|
this.removeMainViewListener();
|
|
8143
8186
|
this.disconnectMainViewResizeObserver();
|
|
8144
8187
|
this.stop();
|
|
@@ -19849,7 +19892,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
|
|
|
19849
19892
|
const _WindowManager = class extends InvisiblePlugin {
|
|
19850
19893
|
constructor(context) {
|
|
19851
19894
|
super(context);
|
|
19852
|
-
this.version = "1.0.13-test.
|
|
19895
|
+
this.version = "1.0.13-test.13";
|
|
19853
19896
|
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.3.0", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "uuid": "^7.0.3", "video.js": ">=7" }, "peerDependencies": { "jspdf": "2.5.1", "white-web-sdk": "^2.16.53" }, "devDependencies": { "@hyrious/dts": "^0.2.2", "@netless/app-docs-viewer": "^0.2.19", "@netless/app-media-player": "0.1.4", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "1.0.0-next.30", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "jspdf": "^2.5.1", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "side-effect-manager": "0.1.5", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.9.9", "vitest": "^0.14.1", "white-web-sdk": "^2.16.53" } };
|
|
19854
19897
|
this.emitter = callbacks$1;
|
|
19855
19898
|
this.viewMode = ViewMode.Broadcaster;
|