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

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,7 @@ class MainViewProxy {
7852
7882
  this.startListenWritableChange();
7853
7883
  });
7854
7884
  const playgroundSizeChangeListener = () => {
7855
- console.log("[window-manager] playgroundSizeChangeListener====>", JSON.stringify(this.mainViewSize));
7885
+ this.playgroundSizeChangeListenerLocalConsole.log(JSON.stringify(this.mainViewSize), JSON.stringify(this.mainViewCamera));
7856
7886
  this.sizeChangeHandler(this.mainViewSize);
7857
7887
  };
7858
7888
  this.sideEffectManager.add(() => {
@@ -7892,7 +7922,7 @@ class MainViewProxy {
7892
7922
  this.moveCamera(this.mainViewCamera);
7893
7923
  }
7894
7924
  start() {
7895
- console.log("[window-manager] start====>", JSON.stringify(this.mainViewSize));
7925
+ console.log("[window-manager] start ", JSON.stringify(this.mainViewSize));
7896
7926
  this.sizeChangeHandler(this.mainViewSize);
7897
7927
  if (this.started)
7898
7928
  return;
@@ -8109,6 +8139,7 @@ class AppManager {
8109
8139
  var _a, _b;
8110
8140
  const { scenePath } = params;
8111
8141
  if (scenePath === ROOT_DIR) {
8142
+ console.log("[window-manager] onRemoveScenes ROOT_DIR");
8112
8143
  await this.onRootDirRemoved();
8113
8144
  this.dispatchInternalEvent(Events.RootDirRemoved);
8114
8145
  return;
@@ -8121,6 +8152,7 @@ class AppManager {
8121
8152
  sceneName = (_b = this.callbacksNode) == null ? void 0 : _b.scenes[nextIndex];
8122
8153
  }
8123
8154
  if (sceneName) {
8155
+ console.log("[window-manager] onRemoveScenes setMainViewScenePath", `${ROOT_DIR}${sceneName}`);
8124
8156
  this.setMainViewScenePath(`${ROOT_DIR}${sceneName}`);
8125
8157
  }
8126
8158
  await this.setMainViewSceneIndex(nextIndex);
@@ -8418,7 +8450,7 @@ class AppManager {
8418
8450
  const pageName = scenePath.replace(sceneDir, "").replace("/", "");
8419
8451
  const index2 = scenes.findIndex((scene) => scene.name === pageName);
8420
8452
  if (isInteger(index2) && index2 >= 0) {
8421
- console.log("[window-manager] updateSceneIndex====>", index2);
8453
+ console.log("[window-manager] updateSceneIndex ", index2);
8422
8454
  this.safeSetAttributes({ _mainSceneIndex: index2 });
8423
8455
  }
8424
8456
  }
@@ -8694,6 +8726,23 @@ class AppManager {
8694
8726
  }
8695
8727
  internalEmitter.emit("mainViewMounted");
8696
8728
  callbacks$1.emit("onMainViewMounted", mainView);
8729
+ const hasRoot = this.hasRoot(mainView.divElement);
8730
+ const rect = this.getRectByDivElement(mainView.divElement);
8731
+ console.log("[window-manager] bindMainView hasRoot", hasRoot, JSON.stringify(rect), window.outerHeight, window.outerWidth);
8732
+ }
8733
+ hasRoot(divElement) {
8734
+ let current = divElement;
8735
+ while (current) {
8736
+ if (current.parentElement === document.body) {
8737
+ return true;
8738
+ }
8739
+ current = current.parentElement;
8740
+ }
8741
+ return false;
8742
+ }
8743
+ getRectByDivElement(divElement) {
8744
+ const rect = divElement.getBoundingClientRect();
8745
+ return rect;
8697
8746
  }
8698
8747
  setMainViewFocusPath(scenePath) {
8699
8748
  var _a;
@@ -8805,7 +8854,7 @@ class AppManager {
8805
8854
  async _setMainViewScenePath(scenePath) {
8806
8855
  const success = this.setMainViewFocusPath(scenePath);
8807
8856
  if (success) {
8808
- console.log("[window-manager] _setMainViewScenePath====>", scenePath);
8857
+ console.log("[window-manager] _setMainViewScenePath ", scenePath);
8809
8858
  this.safeSetAttributes({ _mainScenePath: scenePath });
8810
8859
  this.store.setMainViewFocusPath(this.mainView);
8811
8860
  this.updateSceneIndex();
@@ -8833,7 +8882,7 @@ class AppManager {
8833
8882
  }
8834
8883
  }
8835
8884
  dispatchSetMainViewScenePath(scenePath) {
8836
- console.log("[window-manager] dispatchSetMainViewScenePath====>", JSON.stringify(scenePath));
8885
+ console.log("[window-manager] dispatchSetMainViewScenePath ", JSON.stringify(scenePath));
8837
8886
  this.dispatchInternalEvent(Events.SetMainViewScenePath, { nextScenePath: scenePath });
8838
8887
  callbacks$1.emit("mainViewScenePathChange", scenePath);
8839
8888
  setScenePath(this.room, scenePath);
@@ -9101,8 +9150,12 @@ const replaceRoomFunction = (room, manager) => {
9101
9150
  });
9102
9151
  const _scalePptToFit = room.scalePptToFit;
9103
9152
  room.scalePptToFit = (...args) => {
9104
- console.log("[window-manager] scalePptToFit====>", JSON.stringify(args));
9153
+ var _a;
9105
9154
  _scalePptToFit.call(room, ...args);
9155
+ if ((_a = manager.appManager) == null ? void 0 : _a.mainViewProxy) {
9156
+ console.log("[window-manager] scalePptToFit ", JSON.stringify(args));
9157
+ manager.appManager.mainViewProxy.setCameraAndSize();
9158
+ }
9106
9159
  };
9107
9160
  room.moveCamera = (camera) => manager.moveCamera(camera);
9108
9161
  room.moveCameraToContain = (...args) => manager.moveCameraToContain(...args);
@@ -19694,15 +19747,20 @@ const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
19694
19747
  const _WindowManager = class extends InvisiblePlugin {
19695
19748
  constructor(context) {
19696
19749
  super(context);
19697
- this.version = "1.0.13-test.2";
19750
+ this.version = "1.0.13-test.3";
19698
19751
  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
19752
  this.emitter = callbacks$1;
19700
19753
  this.viewMode = ViewMode.Broadcaster;
19701
19754
  this.isReplay = isPlayer(this.displayer);
19702
19755
  this._cursorUIDs = [];
19703
19756
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
19757
+ this.visibleStateListener = () => {
19758
+ console.log("[window-manager] visibleStateListener isVisible:", !document.hidden);
19759
+ };
19704
19760
  _WindowManager.displayer = context.displayer;
19705
19761
  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" } };
19762
+ this.visibleStateListener();
19763
+ document.addEventListener("visibilitychange", this.visibleStateListener);
19706
19764
  }
19707
19765
  get Logger() {
19708
19766
  return this._roomLogger;
@@ -20378,6 +20436,7 @@ const _WindowManager = class extends InvisiblePlugin {
20378
20436
  (_e = _WindowManager.playground.parentNode) == null ? void 0 : _e.removeChild(_WindowManager.playground);
20379
20437
  }
20380
20438
  _WindowManager.params = void 0;
20439
+ document.removeEventListener("visibilitychange", this.visibleStateListener);
20381
20440
  (_f = this._iframeBridge) == null ? void 0 : _f.destroy();
20382
20441
  this._iframeBridge = void 0;
20383
20442
  log("Destroyed");