@netless/window-manager 1.0.13-test.15 → 1.0.13-test.17

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.mjs CHANGED
@@ -7792,6 +7792,7 @@ class MainViewProxy {
7792
7792
  this.started = false;
7793
7793
  this.mainViewIsAddListener = false;
7794
7794
  this.isForcingMainViewDivElement = false;
7795
+ this.wrapperRectWorkaroundFrame = 0;
7795
7796
  this.store = this.manager.store;
7796
7797
  this.viewMode = this.manager.windowManger.viewMode;
7797
7798
  this.sideEffectManager = new o$2();
@@ -7815,6 +7816,44 @@ class MainViewProxy {
7815
7816
  });
7816
7817
  });
7817
7818
  };
7819
+ this.onWrapperRectChange = (payload) => {
7820
+ this.pendingWrapperRectChange = payload;
7821
+ console.log("[window-manager] onWrapperRectChange " + JSON.stringify({
7822
+ ...payload,
7823
+ viewSize: this.mainView.size
7824
+ }));
7825
+ if (this.wrapperRectWorkaroundFrame) {
7826
+ cancelAnimationFrame(this.wrapperRectWorkaroundFrame);
7827
+ }
7828
+ this.wrapperRectWorkaroundFrame = requestAnimationFrame(this.runWrapperRectWorkaround);
7829
+ };
7830
+ this.runWrapperRectWorkaround = () => {
7831
+ this.wrapperRectWorkaroundFrame = 0;
7832
+ const payload = this.pendingWrapperRectChange;
7833
+ const element2 = this.mainView.divElement;
7834
+ this.pendingWrapperRectChange = void 0;
7835
+ if (!payload || !element2)
7836
+ return;
7837
+ const rect = element2.getBoundingClientRect();
7838
+ const observedSize = { width: rect.width, height: rect.height };
7839
+ const wrapperMatchesDom = Math.abs(payload.width - observedSize.width) <= 0.5 && Math.abs(payload.height - observedSize.height) <= 0.5;
7840
+ const viewIsStale = Math.abs(this.mainView.size.width - observedSize.width) > 0.5 || Math.abs(this.mainView.size.height - observedSize.height) > 0.5;
7841
+ console.log("[window-manager] runWrapperRectWorkaround " + JSON.stringify({
7842
+ origin: payload.origin,
7843
+ wrapperRect: payload,
7844
+ domRect: observedSize,
7845
+ viewSize: this.mainView.size,
7846
+ wrapperMatchesDom,
7847
+ viewIsStale
7848
+ }));
7849
+ if (wrapperMatchesDom && viewIsStale) {
7850
+ this.forceSyncMainViewDivElement(
7851
+ `wrapperRectChange:${payload.origin || "unknown"}`,
7852
+ observedSize,
7853
+ element2
7854
+ );
7855
+ }
7856
+ };
7818
7857
  this.addCameraReaction = () => {
7819
7858
  this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
7820
7859
  };
@@ -7893,6 +7932,41 @@ class MainViewProxy {
7893
7932
  viewSize: this.mainView.size
7894
7933
  }));
7895
7934
  };
7935
+ this.onResize2 = (entries) => {
7936
+ const entry = entries[0];
7937
+ if (!entry)
7938
+ return;
7939
+ const target = entry.target;
7940
+ const child = target.children[0];
7941
+ const observedSize = {
7942
+ width: entry.contentRect.width,
7943
+ height: entry.contentRect.height
7944
+ };
7945
+ console.log("[window-manager] mainViewResizeObserver2 " + JSON.stringify({
7946
+ sameTarget: target === this.mainView.divElement,
7947
+ contentRect: {
7948
+ width: observedSize.width,
7949
+ height: observedSize.height
7950
+ },
7951
+ client: {
7952
+ width: target.clientWidth,
7953
+ height: target.clientHeight
7954
+ },
7955
+ offset: {
7956
+ width: target.offsetWidth,
7957
+ height: target.offsetHeight
7958
+ },
7959
+ rect: {
7960
+ width: target.getBoundingClientRect().width,
7961
+ height: target.getBoundingClientRect().height
7962
+ },
7963
+ childRect: child ? {
7964
+ width: child.getBoundingClientRect().width,
7965
+ height: child.getBoundingClientRect().height
7966
+ } : null,
7967
+ viewSize: this.mainView.size
7968
+ }));
7969
+ };
7896
7970
  this._syncMainViewTimer = 0;
7897
7971
  this.handleCameraOrSizeUpdated = (source, payload) => {
7898
7972
  console.log("[window-manager] " + source + " payload " + JSON.stringify(payload));
@@ -8136,11 +8210,15 @@ class MainViewProxy {
8136
8210
  }));
8137
8211
  this.mainViewResizeObserver = new window.ResizeObserver(this.onResize);
8138
8212
  this.mainViewResizeObserver.observe(this.mainView.divElement);
8213
+ this.mainViewResizeObserver2 = new window.ResizeObserver(this.onResize2);
8214
+ this.mainViewResizeObserver2.observe(this.mainView.divElement);
8139
8215
  }
8140
8216
  disconnectMainViewResizeObserver() {
8141
- var _a;
8217
+ var _a, _b;
8142
8218
  (_a = this.mainViewResizeObserver) == null ? void 0 : _a.disconnect();
8143
8219
  this.mainViewResizeObserver = void 0;
8220
+ (_b = this.mainViewResizeObserver2) == null ? void 0 : _b.disconnect();
8221
+ this.mainViewResizeObserver2 = void 0;
8144
8222
  }
8145
8223
  ensureMainViewSize() {
8146
8224
  if ((!this.mainViewSize || this.mainViewSize.width === 0 || this.mainViewSize.height === 0) && this.mainView.size.width > 0 && this.mainView.size.height > 0) {
@@ -8181,6 +8259,10 @@ class MainViewProxy {
8181
8259
  }
8182
8260
  destroy() {
8183
8261
  console.log("[window-manager] destroy ");
8262
+ if (this.wrapperRectWorkaroundFrame) {
8263
+ cancelAnimationFrame(this.wrapperRectWorkaroundFrame);
8264
+ this.wrapperRectWorkaroundFrame = 0;
8265
+ }
8184
8266
  this.removeMainViewListener();
8185
8267
  this.disconnectMainViewResizeObserver();
8186
8268
  this.stop();
@@ -9135,7 +9217,13 @@ class ContainerResizeObserver {
9135
9217
  wrapper.style.width = `${width}px`;
9136
9218
  wrapper.style.height = `${height}px`;
9137
9219
  wrapper.style.backgroundColor = "green";
9138
- console.log(`[window-manager] updateSizer from ${origin}: ${JSON.stringify({ width, height })} ${wrapper.style.width} ${wrapper.style.height} ${JSON.stringify(wrapper.getBoundingClientRect())}`);
9220
+ const wrapperRect = wrapper.getBoundingClientRect();
9221
+ console.log(`[window-manager] updateSizer from ${origin}: ${JSON.stringify({ width, height })} ${wrapper.style.width} ${wrapper.style.height} ${JSON.stringify(wrapperRect)}`);
9222
+ this.emitter.emit("wrapperRectChange", {
9223
+ width: wrapperRect.width,
9224
+ height: wrapperRect.height,
9225
+ origin
9226
+ });
9139
9227
  }
9140
9228
  }
9141
9229
  disconnect() {
@@ -19891,7 +19979,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
19891
19979
  const _WindowManager = class extends InvisiblePlugin {
19892
19980
  constructor(context) {
19893
19981
  super(context);
19894
- this.version = "1.0.13-test.15";
19982
+ this.version = "1.0.13-test.17";
19895
19983
  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" } };
19896
19984
  this.emitter = callbacks$1;
19897
19985
  this.viewMode = ViewMode.Broadcaster;