@netless/window-manager 1.0.13-test.10 → 1.0.13-test.12
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 -0
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/View/MainView.ts +77 -0
package/dist/index.mjs
CHANGED
|
@@ -7857,9 +7857,47 @@ class MainViewProxy {
|
|
|
7857
7857
|
this.setMainViewSize = debounce((size2) => {
|
|
7858
7858
|
this.store.setMainViewSize({ ...size2, id: this.manager.uid });
|
|
7859
7859
|
}, 50);
|
|
7860
|
+
this.onResize = (entries) => {
|
|
7861
|
+
const entry = entries[0];
|
|
7862
|
+
if (!entry)
|
|
7863
|
+
return;
|
|
7864
|
+
const target = entry.target;
|
|
7865
|
+
const child = target.children[0];
|
|
7866
|
+
console.log("[window-manager] mainViewResizeObserver " + JSON.stringify({
|
|
7867
|
+
contentRect: {
|
|
7868
|
+
width: entry.contentRect.width,
|
|
7869
|
+
height: entry.contentRect.height
|
|
7870
|
+
},
|
|
7871
|
+
client: {
|
|
7872
|
+
width: target.clientWidth,
|
|
7873
|
+
height: target.clientHeight
|
|
7874
|
+
},
|
|
7875
|
+
offset: {
|
|
7876
|
+
width: target.offsetWidth,
|
|
7877
|
+
height: target.offsetHeight
|
|
7878
|
+
},
|
|
7879
|
+
rect: {
|
|
7880
|
+
width: target.getBoundingClientRect().width,
|
|
7881
|
+
height: target.getBoundingClientRect().height
|
|
7882
|
+
},
|
|
7883
|
+
childRect: child ? {
|
|
7884
|
+
width: child.getBoundingClientRect().width,
|
|
7885
|
+
height: child.getBoundingClientRect().height
|
|
7886
|
+
} : null,
|
|
7887
|
+
viewSize: this.mainView.size
|
|
7888
|
+
}));
|
|
7889
|
+
};
|
|
7860
7890
|
this._syncMainViewTimer = 0;
|
|
7861
7891
|
this.onCameraOrSizeUpdated = () => {
|
|
7862
7892
|
console.log("[window-manager] onCameraOrSizeUpdated " + JSON.stringify(this.cameraState));
|
|
7893
|
+
if (this.mainView.divElement) {
|
|
7894
|
+
const children2 = this.mainView.divElement.children;
|
|
7895
|
+
console.log("[window-manager] onCameraOrSizeUpdated " + this.mainView.divElement.getBoundingClientRect());
|
|
7896
|
+
const child = children2[0];
|
|
7897
|
+
if (child) {
|
|
7898
|
+
console.log("[window-manager] child" + JSON.stringify(child.getBoundingClientRect()));
|
|
7899
|
+
}
|
|
7900
|
+
}
|
|
7863
7901
|
callbacks$1.emit("cameraStateChange", this.cameraState);
|
|
7864
7902
|
if (this.manager.room && this.manager.room.syncMainView) {
|
|
7865
7903
|
clearTimeout(this._syncMainViewTimer);
|
|
@@ -7879,6 +7917,7 @@ class MainViewProxy {
|
|
|
7879
7917
|
this.mainView = this.createMainView();
|
|
7880
7918
|
this.moveCameraSizeByAttributes();
|
|
7881
7919
|
internalEmitter.once("mainViewMounted").then(() => {
|
|
7920
|
+
this.observeMainViewDivElement();
|
|
7882
7921
|
this.addMainViewListener();
|
|
7883
7922
|
this.start();
|
|
7884
7923
|
this.ensureCameraAndSize();
|
|
@@ -7886,6 +7925,7 @@ class MainViewProxy {
|
|
|
7886
7925
|
});
|
|
7887
7926
|
const playgroundSizeChangeListener = () => {
|
|
7888
7927
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7928
|
+
this.refreshScreenSizeIfStale();
|
|
7889
7929
|
this.playgroundSizeChangeListenerLocalConsole.log(
|
|
7890
7930
|
JSON.stringify(this.mainView.camera),
|
|
7891
7931
|
JSON.stringify(this.mainView.size),
|
|
@@ -7936,6 +7976,24 @@ class MainViewProxy {
|
|
|
7936
7976
|
this.moveCameraToContian(this.mainViewSize);
|
|
7937
7977
|
this.moveCamera(this.mainViewCamera);
|
|
7938
7978
|
}
|
|
7979
|
+
refreshScreenSizeIfStale() {
|
|
7980
|
+
var _a;
|
|
7981
|
+
const element2 = this.mainView.divElement;
|
|
7982
|
+
if (!element2)
|
|
7983
|
+
return;
|
|
7984
|
+
const { width, height } = element2.getBoundingClientRect();
|
|
7985
|
+
if (width <= 0 || height <= 0)
|
|
7986
|
+
return;
|
|
7987
|
+
const { width: viewWidth, height: viewHeight } = this.mainView.size;
|
|
7988
|
+
if (Math.abs(viewWidth - width) > 0.5 || Math.abs(viewHeight - height) > 0.5) {
|
|
7989
|
+
const resizableView = this.mainView;
|
|
7990
|
+
console.log("[window-manager] forceResizeScreen stale size" + JSON.stringify({
|
|
7991
|
+
viewSize: this.mainView.size,
|
|
7992
|
+
domSize: { width, height }
|
|
7993
|
+
}));
|
|
7994
|
+
(_a = resizableView.resizeScreen) == null ? void 0 : _a.call(resizableView);
|
|
7995
|
+
}
|
|
7996
|
+
}
|
|
7939
7997
|
start() {
|
|
7940
7998
|
console.log("[window-manager] start " + JSON.stringify(this.mainViewSize));
|
|
7941
7999
|
this.sizeChangeHandler(this.mainViewSize);
|
|
@@ -7987,9 +8045,11 @@ class MainViewProxy {
|
|
|
7987
8045
|
this.mainView.release();
|
|
7988
8046
|
}
|
|
7989
8047
|
this.removeMainViewListener();
|
|
8048
|
+
this.disconnectMainViewResizeObserver();
|
|
7990
8049
|
this.mainView = this.createMainView();
|
|
7991
8050
|
this.mainView.disableCameraTransform = disableCameraTransform;
|
|
7992
8051
|
this.mainView.divElement = divElement;
|
|
8052
|
+
this.observeMainViewDivElement();
|
|
7993
8053
|
this.addMainViewListener();
|
|
7994
8054
|
this.start();
|
|
7995
8055
|
callbacks$1.emit("onMainViewRebind", this.mainView);
|
|
@@ -8027,6 +8087,20 @@ class MainViewProxy {
|
|
|
8027
8087
|
this.view.callbacks.off("onCameraUpdated", this.onCameraOrSizeUpdated);
|
|
8028
8088
|
this.view.callbacks.off("onSizeUpdated", this.onCameraOrSizeUpdated);
|
|
8029
8089
|
}
|
|
8090
|
+
observeMainViewDivElement() {
|
|
8091
|
+
this.disconnectMainViewResizeObserver();
|
|
8092
|
+
if (!("ResizeObserver" in window))
|
|
8093
|
+
return;
|
|
8094
|
+
if (!this.mainView.divElement)
|
|
8095
|
+
return;
|
|
8096
|
+
this.mainViewResizeObserver = new window.ResizeObserver(this.onResize);
|
|
8097
|
+
this.mainViewResizeObserver.observe(this.mainView.divElement);
|
|
8098
|
+
}
|
|
8099
|
+
disconnectMainViewResizeObserver() {
|
|
8100
|
+
var _a;
|
|
8101
|
+
(_a = this.mainViewResizeObserver) == null ? void 0 : _a.disconnect();
|
|
8102
|
+
this.mainViewResizeObserver = void 0;
|
|
8103
|
+
}
|
|
8030
8104
|
ensureMainViewSize() {
|
|
8031
8105
|
if ((!this.mainViewSize || this.mainViewSize.width === 0 || this.mainViewSize.height === 0) && this.mainView.size.width > 0 && this.mainView.size.height > 0) {
|
|
8032
8106
|
this.setMainViewSize(this.mainView.size);
|
|
@@ -8066,6 +8140,7 @@ class MainViewProxy {
|
|
|
8066
8140
|
}
|
|
8067
8141
|
destroy() {
|
|
8068
8142
|
this.removeMainViewListener();
|
|
8143
|
+
this.disconnectMainViewResizeObserver();
|
|
8069
8144
|
this.stop();
|
|
8070
8145
|
this.sideEffectManager.flushAll();
|
|
8071
8146
|
}
|
|
@@ -19774,7 +19849,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
|
|
|
19774
19849
|
const _WindowManager = class extends InvisiblePlugin {
|
|
19775
19850
|
constructor(context) {
|
|
19776
19851
|
super(context);
|
|
19777
|
-
this.version = "1.0.13-test.
|
|
19852
|
+
this.version = "1.0.13-test.12";
|
|
19778
19853
|
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" } };
|
|
19779
19854
|
this.emitter = callbacks$1;
|
|
19780
19855
|
this.viewMode = ViewMode.Broadcaster;
|