@netless/window-manager 1.0.13-test.2 → 1.0.13-test.4

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
@@ -352,7 +352,7 @@ const setScenePath = (room, scenePath) => {
352
352
  if (room && room.isWritable) {
353
353
  if (room.state.sceneState.scenePath !== scenePath) {
354
354
  const nextScenePath = scenePath === "/" ? "" : scenePath;
355
- console.log("[window-manager] real setScenePath for current room====>", nextScenePath);
355
+ console.log("[window-manager] real setScenePath for current room ", nextScenePath);
356
356
  room.setScenePath(nextScenePath);
357
357
  }
358
358
  }
@@ -464,7 +464,7 @@ class AppListeners {
464
464
  break;
465
465
  }
466
466
  case Events.SetMainViewScenePath: {
467
- console.log("[window-manager] mainMagixEventListener====>", JSON.stringify(data.payload));
467
+ console.log("[window-manager] mainMagixEventListener ", JSON.stringify(data.payload));
468
468
  this.setMainViewScenePathHandler(data.payload);
469
469
  break;
470
470
  }
@@ -5697,6 +5697,35 @@ const log = (...args) => {
5697
5697
  console.log(`[WindowManager]:`, ...args);
5698
5698
  }
5699
5699
  };
5700
+ class LocalConsole {
5701
+ constructor(name, debounceTime) {
5702
+ this.name = name;
5703
+ this.debounceTime = debounceTime;
5704
+ this.pendingArgs = null;
5705
+ this.flushTimer = null;
5706
+ }
5707
+ flush() {
5708
+ this.flushTimer = null;
5709
+ const args = this.pendingArgs;
5710
+ this.pendingArgs = null;
5711
+ if (args === null) {
5712
+ return;
5713
+ }
5714
+ console.log(`[window-manager][${this.name}]:`, ...args);
5715
+ }
5716
+ log(...args) {
5717
+ const ms = this.debounceTime;
5718
+ if (ms != null && ms > 0) {
5719
+ this.pendingArgs = args;
5720
+ if (this.flushTimer != null) {
5721
+ clearTimeout(this.flushTimer);
5722
+ }
5723
+ this.flushTimer = setTimeout(() => this.flush(), ms);
5724
+ return;
5725
+ }
5726
+ console.log(`[window-manager][${this.name}]:`, ...args);
5727
+ }
5728
+ }
5700
5729
  const setupWrapper = (root) => {
5701
5730
  const playground = document.createElement("div");
5702
5731
  playground.className = "netless-window-manager-playground";
@@ -7004,6 +7033,7 @@ var Fields = /* @__PURE__ */ ((Fields2) => {
7004
7033
  class AttributesDelegate {
7005
7034
  constructor(context) {
7006
7035
  this.context = context;
7036
+ this.setMainViewCameraConsole = new LocalConsole("setMainViewCamera", 50);
7007
7037
  this.setAppFocus = (appId, focus) => {
7008
7038
  if (focus) {
7009
7039
  this.context.safeSetAttributes({ ["focus"]: appId });
@@ -7129,11 +7159,11 @@ class AttributesDelegate {
7129
7159
  return this.attributes["boxState"];
7130
7160
  }
7131
7161
  setMainViewScenePath(scenePath) {
7132
- console.log("[window-manager] setMainViewScenePath====>", scenePath);
7162
+ console.log("[window-manager] setMainViewScenePath ", scenePath);
7133
7163
  this.context.safeSetAttributes({ _mainScenePath: scenePath });
7134
7164
  }
7135
7165
  setMainViewSceneIndex(index2) {
7136
- console.log("[window-manager] setMainViewSceneIndex====>", index2);
7166
+ console.log("[window-manager] setMainViewSceneIndex ", index2);
7137
7167
  this.context.safeSetAttributes({ _mainSceneIndex: index2 });
7138
7168
  }
7139
7169
  getMainViewCamera() {
@@ -7143,19 +7173,19 @@ class AttributesDelegate {
7143
7173
  return get(this.attributes, ["mainViewSize"]);
7144
7174
  }
7145
7175
  setMainViewCamera(camera) {
7146
- console.log("[window-manager] setMainViewCamera====>", JSON.stringify(camera));
7176
+ this.setMainViewCameraConsole.log(JSON.stringify(camera));
7147
7177
  this.context.safeSetAttributes({ ["mainViewCamera"]: { ...camera } });
7148
7178
  }
7149
7179
  setMainViewSize(size2) {
7150
7180
  if (size2.width === 0 || size2.height === 0)
7151
7181
  return;
7152
- console.log("[window-manager] setMainViewSize====>", JSON.stringify(size2));
7182
+ console.log("[window-manager] setMainViewSize ", JSON.stringify(size2));
7153
7183
  this.context.safeSetAttributes({ ["mainViewSize"]: { ...size2 } });
7154
7184
  }
7155
7185
  setMainViewCameraAndSize(camera, size2) {
7156
7186
  if (size2.width === 0 || size2.height === 0)
7157
7187
  return;
7158
- console.log("[window-manager] setMainViewCameraAndSize====>", JSON.stringify(camera), JSON.stringify(size2));
7188
+ console.log("[window-manager] setMainViewCameraAndSize ", JSON.stringify(camera), JSON.stringify(size2));
7159
7189
  this.context.safeSetAttributes({
7160
7190
  ["mainViewCamera"]: { ...camera },
7161
7191
  ["mainViewSize"]: { ...size2 }
@@ -7762,6 +7792,7 @@ class MainViewProxy {
7762
7792
  this.store = this.manager.store;
7763
7793
  this.viewMode = this.manager.windowManger.viewMode;
7764
7794
  this.sideEffectManager = new o$2();
7795
+ this.playgroundSizeChangeListenerLocalConsole = new LocalConsole("playgroundSizeChangeListener", 30);
7765
7796
  this.syncCamera = () => {
7766
7797
  if (!this.polling || this.viewMode !== ViewMode.Broadcaster)
7767
7798
  return;
@@ -7789,7 +7820,7 @@ class MainViewProxy {
7789
7820
  () => this.mainViewCamera,
7790
7821
  (camera) => {
7791
7822
  if (camera && camera.id !== this.manager.uid) {
7792
- console.log("[window-manager] cameraReaction====>", JSON.stringify(camera), JSON.stringify(this.mainViewSize));
7823
+ console.log("[window-manager] cameraReaction ", JSON.stringify(camera), JSON.stringify(this.mainViewSize));
7793
7824
  this.moveCameraToContian(this.mainViewSize);
7794
7825
  this.moveCamera(camera);
7795
7826
  }
@@ -7799,15 +7830,15 @@ class MainViewProxy {
7799
7830
  };
7800
7831
  this.sizeChangeHandler = debounce((size2) => {
7801
7832
  if (size2) {
7833
+ console.log("[window-manager] sizeChangeHandler current size and camera", JSON.stringify(size2), JSON.stringify(this.mainViewCamera));
7802
7834
  this.moveCameraToContian(size2);
7803
7835
  this.moveCamera(this.mainViewCamera);
7804
- console.log("[window-manager] sizeChangeHandler====> current size and camera", JSON.stringify(size2), JSON.stringify(this.mainViewCamera));
7805
7836
  }
7806
7837
  this.ensureMainViewSize();
7807
7838
  }, 30);
7808
7839
  this.onUpdateContainerSizeRatio = () => {
7809
7840
  const size2 = this.store.getMainViewSize();
7810
- console.log("[window-manager] onUpdateContainerSizeRatio====>", JSON.stringify(size2));
7841
+ console.log("[window-manager] onUpdateContainerSizeRatio ", JSON.stringify(size2));
7811
7842
  this.sizeChangeHandler(size2);
7812
7843
  };
7813
7844
  this.onCameraUpdatedByDevice = (camera) => {
@@ -7831,12 +7862,11 @@ class MainViewProxy {
7831
7862
  clearTimeout(this._syncMainViewTimer);
7832
7863
  this._syncMainViewTimer = setTimeout(this.syncMainView, 100, this.manager.room);
7833
7864
  }
7834
- console.log("[window-manager] onCameraOrSizeUpdated====>", JSON.stringify(this.cameraState));
7835
7865
  this.ensureMainViewSize();
7836
7866
  };
7837
7867
  this.syncMainView = (room) => {
7838
7868
  if (room.isWritable) {
7839
- console.log("[window-manager] syncMainView====>");
7869
+ console.log("[window-manager] syncMainView ");
7840
7870
  room.syncMainView(this.mainView);
7841
7871
  }
7842
7872
  };
@@ -7852,7 +7882,17 @@ class MainViewProxy {
7852
7882
  this.startListenWritableChange();
7853
7883
  });
7854
7884
  const playgroundSizeChangeListener = () => {
7855
- console.log("[window-manager] playgroundSizeChangeListener====>", JSON.stringify(this.mainViewSize));
7885
+ var _a, _b, _c, _d, _e, _f, _g, _h;
7886
+ this.playgroundSizeChangeListenerLocalConsole.log(
7887
+ JSON.stringify(this.mainViewSize),
7888
+ JSON.stringify(this.mainViewCamera),
7889
+ window.outerHeight,
7890
+ window.outerWidth,
7891
+ (_b = (_a = window.visualViewport) == null ? void 0 : _a.width) != null ? _b : "null",
7892
+ (_d = (_c = window.visualViewport) == null ? void 0 : _c.height) != null ? _d : "null",
7893
+ (_f = (_e = window.visualViewport) == null ? void 0 : _e.offsetLeft) != null ? _f : "null",
7894
+ (_h = (_g = window.visualViewport) == null ? void 0 : _g.offsetTop) != null ? _h : "null"
7895
+ );
7856
7896
  this.sizeChangeHandler(this.mainViewSize);
7857
7897
  };
7858
7898
  this.sideEffectManager.add(() => {
@@ -7892,7 +7932,7 @@ class MainViewProxy {
7892
7932
  this.moveCamera(this.mainViewCamera);
7893
7933
  }
7894
7934
  start() {
7895
- console.log("[window-manager] start====>", JSON.stringify(this.mainViewSize));
7935
+ console.log("[window-manager] start ", JSON.stringify(this.mainViewSize));
7896
7936
  this.sizeChangeHandler(this.mainViewSize);
7897
7937
  if (this.started)
7898
7938
  return;
@@ -8109,6 +8149,7 @@ class AppManager {
8109
8149
  var _a, _b;
8110
8150
  const { scenePath } = params;
8111
8151
  if (scenePath === ROOT_DIR) {
8152
+ console.log("[window-manager] onRemoveScenes ROOT_DIR");
8112
8153
  await this.onRootDirRemoved();
8113
8154
  this.dispatchInternalEvent(Events.RootDirRemoved);
8114
8155
  return;
@@ -8121,6 +8162,7 @@ class AppManager {
8121
8162
  sceneName = (_b = this.callbacksNode) == null ? void 0 : _b.scenes[nextIndex];
8122
8163
  }
8123
8164
  if (sceneName) {
8165
+ console.log("[window-manager] onRemoveScenes setMainViewScenePath", `${ROOT_DIR}${sceneName}`);
8124
8166
  this.setMainViewScenePath(`${ROOT_DIR}${sceneName}`);
8125
8167
  }
8126
8168
  await this.setMainViewSceneIndex(nextIndex);
@@ -8418,7 +8460,7 @@ class AppManager {
8418
8460
  const pageName = scenePath.replace(sceneDir, "").replace("/", "");
8419
8461
  const index2 = scenes.findIndex((scene) => scene.name === pageName);
8420
8462
  if (isInteger(index2) && index2 >= 0) {
8421
- console.log("[window-manager] updateSceneIndex====>", index2);
8463
+ console.log("[window-manager] updateSceneIndex ", index2);
8422
8464
  this.safeSetAttributes({ _mainSceneIndex: index2 });
8423
8465
  }
8424
8466
  }
@@ -8686,6 +8728,7 @@ class AppManager {
8686
8728
  (_a = this.boxManager) == null ? void 0 : _a.setMinimized(Boolean(this.store.getMinimized()));
8687
8729
  }
8688
8730
  bindMainView(divElement, disableCameraTransform) {
8731
+ var _a, _b, _c, _d, _e, _f, _g, _h;
8689
8732
  const mainView = this.mainViewProxy.view;
8690
8733
  mainView.disableCameraTransform = disableCameraTransform;
8691
8734
  mainView.divElement = divElement;
@@ -8694,6 +8737,33 @@ class AppManager {
8694
8737
  }
8695
8738
  internalEmitter.emit("mainViewMounted");
8696
8739
  callbacks$1.emit("onMainViewMounted", mainView);
8740
+ const hasRoot = this.hasRoot(mainView.divElement);
8741
+ const rect = this.getRectByDivElement(mainView.divElement);
8742
+ console.log(
8743
+ "[window-manager] bindMainView hasRoot",
8744
+ hasRoot,
8745
+ JSON.stringify(rect),
8746
+ window.outerHeight,
8747
+ window.outerWidth,
8748
+ (_b = (_a = window.visualViewport) == null ? void 0 : _a.width) != null ? _b : "null",
8749
+ (_d = (_c = window.visualViewport) == null ? void 0 : _c.height) != null ? _d : "null",
8750
+ (_f = (_e = window.visualViewport) == null ? void 0 : _e.offsetLeft) != null ? _f : "null",
8751
+ (_h = (_g = window.visualViewport) == null ? void 0 : _g.offsetTop) != null ? _h : "null"
8752
+ );
8753
+ }
8754
+ hasRoot(divElement) {
8755
+ let current = divElement;
8756
+ while (current) {
8757
+ if (current.parentElement === document.body) {
8758
+ return true;
8759
+ }
8760
+ current = current.parentElement;
8761
+ }
8762
+ return false;
8763
+ }
8764
+ getRectByDivElement(divElement) {
8765
+ const rect = divElement.getBoundingClientRect();
8766
+ return rect;
8697
8767
  }
8698
8768
  setMainViewFocusPath(scenePath) {
8699
8769
  var _a;
@@ -8805,7 +8875,7 @@ class AppManager {
8805
8875
  async _setMainViewScenePath(scenePath) {
8806
8876
  const success = this.setMainViewFocusPath(scenePath);
8807
8877
  if (success) {
8808
- console.log("[window-manager] _setMainViewScenePath====>", scenePath);
8878
+ console.log("[window-manager] _setMainViewScenePath ", scenePath);
8809
8879
  this.safeSetAttributes({ _mainScenePath: scenePath });
8810
8880
  this.store.setMainViewFocusPath(this.mainView);
8811
8881
  this.updateSceneIndex();
@@ -8833,7 +8903,7 @@ class AppManager {
8833
8903
  }
8834
8904
  }
8835
8905
  dispatchSetMainViewScenePath(scenePath) {
8836
- console.log("[window-manager] dispatchSetMainViewScenePath====>", JSON.stringify(scenePath));
8906
+ console.log("[window-manager] dispatchSetMainViewScenePath ", JSON.stringify(scenePath));
8837
8907
  this.dispatchInternalEvent(Events.SetMainViewScenePath, { nextScenePath: scenePath });
8838
8908
  callbacks$1.emit("mainViewScenePathChange", scenePath);
8839
8909
  setScenePath(this.room, scenePath);
@@ -9101,8 +9171,12 @@ const replaceRoomFunction = (room, manager) => {
9101
9171
  });
9102
9172
  const _scalePptToFit = room.scalePptToFit;
9103
9173
  room.scalePptToFit = (...args) => {
9104
- console.log("[window-manager] scalePptToFit====>", JSON.stringify(args));
9174
+ var _a;
9105
9175
  _scalePptToFit.call(room, ...args);
9176
+ if ((_a = manager.appManager) == null ? void 0 : _a.mainViewProxy) {
9177
+ console.log("[window-manager] scalePptToFit ", JSON.stringify(args));
9178
+ manager.appManager.mainViewProxy.setCameraAndSize();
9179
+ }
9106
9180
  };
9107
9181
  room.moveCamera = (camera) => manager.moveCamera(camera);
9108
9182
  room.moveCameraToContain = (...args) => manager.moveCameraToContain(...args);
@@ -19694,15 +19768,20 @@ const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
19694
19768
  const _WindowManager = class extends InvisiblePlugin {
19695
19769
  constructor(context) {
19696
19770
  super(context);
19697
- this.version = "1.0.13-test.2";
19771
+ this.version = "1.0.13-test.4";
19698
19772
  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" } };
19699
19773
  this.emitter = callbacks$1;
19700
19774
  this.viewMode = ViewMode.Broadcaster;
19701
19775
  this.isReplay = isPlayer(this.displayer);
19702
19776
  this._cursorUIDs = [];
19703
19777
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
19778
+ this.visibleStateListener = () => {
19779
+ console.log("[window-manager] visibleStateListener isVisible:", !document.hidden);
19780
+ };
19704
19781
  _WindowManager.displayer = context.displayer;
19705
19782
  window.NETLESS_DEPS = { "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" } };
19783
+ this.visibleStateListener();
19784
+ document.addEventListener("visibilitychange", this.visibleStateListener);
19706
19785
  }
19707
19786
  get Logger() {
19708
19787
  return this._roomLogger;
@@ -20378,6 +20457,7 @@ const _WindowManager = class extends InvisiblePlugin {
20378
20457
  (_e = _WindowManager.playground.parentNode) == null ? void 0 : _e.removeChild(_WindowManager.playground);
20379
20458
  }
20380
20459
  _WindowManager.params = void 0;
20460
+ document.removeEventListener("visibilitychange", this.visibleStateListener);
20381
20461
  (_f = this._iframeBridge) == null ? void 0 : _f.destroy();
20382
20462
  this._iframeBridge = void 0;
20383
20463
  log("Destroyed");