@netless/window-manager 1.0.13-test.1 → 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====>", 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", 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", 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", camera, 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====>", camera, 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,7 +7830,7 @@ class MainViewProxy {
7799
7830
  };
7800
7831
  this.sizeChangeHandler = debounce((size2) => {
7801
7832
  if (size2) {
7802
- console.log("[window-manager] sizeChangeHandler====>", size2, this.mainViewCamera);
7833
+ console.log("[window-manager] sizeChangeHandler current size and camera", JSON.stringify(size2), JSON.stringify(this.mainViewCamera));
7803
7834
  this.moveCameraToContian(size2);
7804
7835
  this.moveCamera(this.mainViewCamera);
7805
7836
  }
@@ -7807,7 +7838,7 @@ class MainViewProxy {
7807
7838
  }, 30);
7808
7839
  this.onUpdateContainerSizeRatio = () => {
7809
7840
  const size2 = this.store.getMainViewSize();
7810
- console.log("[window-manager] onUpdateContainerSizeRatio====>", size2);
7841
+ console.log("[window-manager] onUpdateContainerSizeRatio ", JSON.stringify(size2));
7811
7842
  this.sizeChangeHandler(size2);
7812
7843
  };
7813
7844
  this.onCameraUpdatedByDevice = (camera) => {
@@ -7835,6 +7866,7 @@ class MainViewProxy {
7835
7866
  };
7836
7867
  this.syncMainView = (room) => {
7837
7868
  if (room.isWritable) {
7869
+ console.log("[window-manager] syncMainView ");
7838
7870
  room.syncMainView(this.mainView);
7839
7871
  }
7840
7872
  };
@@ -7850,7 +7882,7 @@ class MainViewProxy {
7850
7882
  this.startListenWritableChange();
7851
7883
  });
7852
7884
  const playgroundSizeChangeListener = () => {
7853
- console.log("[window-manager] playgroundSizeChangeListener====>", this.mainViewSize);
7885
+ this.playgroundSizeChangeListenerLocalConsole.log(JSON.stringify(this.mainViewSize), JSON.stringify(this.mainViewCamera));
7854
7886
  this.sizeChangeHandler(this.mainViewSize);
7855
7887
  };
7856
7888
  this.sideEffectManager.add(() => {
@@ -7890,7 +7922,7 @@ class MainViewProxy {
7890
7922
  this.moveCamera(this.mainViewCamera);
7891
7923
  }
7892
7924
  start() {
7893
- console.log("[window-manager] start====>", this.mainViewSize);
7925
+ console.log("[window-manager] start ", JSON.stringify(this.mainViewSize));
7894
7926
  this.sizeChangeHandler(this.mainViewSize);
7895
7927
  if (this.started)
7896
7928
  return;
@@ -8107,6 +8139,7 @@ class AppManager {
8107
8139
  var _a, _b;
8108
8140
  const { scenePath } = params;
8109
8141
  if (scenePath === ROOT_DIR) {
8142
+ console.log("[window-manager] onRemoveScenes ROOT_DIR");
8110
8143
  await this.onRootDirRemoved();
8111
8144
  this.dispatchInternalEvent(Events.RootDirRemoved);
8112
8145
  return;
@@ -8119,6 +8152,7 @@ class AppManager {
8119
8152
  sceneName = (_b = this.callbacksNode) == null ? void 0 : _b.scenes[nextIndex];
8120
8153
  }
8121
8154
  if (sceneName) {
8155
+ console.log("[window-manager] onRemoveScenes setMainViewScenePath", `${ROOT_DIR}${sceneName}`);
8122
8156
  this.setMainViewScenePath(`${ROOT_DIR}${sceneName}`);
8123
8157
  }
8124
8158
  await this.setMainViewSceneIndex(nextIndex);
@@ -8416,7 +8450,7 @@ class AppManager {
8416
8450
  const pageName = scenePath.replace(sceneDir, "").replace("/", "");
8417
8451
  const index2 = scenes.findIndex((scene) => scene.name === pageName);
8418
8452
  if (isInteger(index2) && index2 >= 0) {
8419
- console.log("[window-manager] updateSceneIndex====>", index2);
8453
+ console.log("[window-manager] updateSceneIndex ", index2);
8420
8454
  this.safeSetAttributes({ _mainSceneIndex: index2 });
8421
8455
  }
8422
8456
  }
@@ -8692,6 +8726,23 @@ class AppManager {
8692
8726
  }
8693
8727
  internalEmitter.emit("mainViewMounted");
8694
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;
8695
8746
  }
8696
8747
  setMainViewFocusPath(scenePath) {
8697
8748
  var _a;
@@ -8803,7 +8854,7 @@ class AppManager {
8803
8854
  async _setMainViewScenePath(scenePath) {
8804
8855
  const success = this.setMainViewFocusPath(scenePath);
8805
8856
  if (success) {
8806
- console.log("[window-manager] _setMainViewScenePath====>", scenePath);
8857
+ console.log("[window-manager] _setMainViewScenePath ", scenePath);
8807
8858
  this.safeSetAttributes({ _mainScenePath: scenePath });
8808
8859
  this.store.setMainViewFocusPath(this.mainView);
8809
8860
  this.updateSceneIndex();
@@ -8831,7 +8882,7 @@ class AppManager {
8831
8882
  }
8832
8883
  }
8833
8884
  dispatchSetMainViewScenePath(scenePath) {
8834
- console.log("[window-manager] dispatchSetMainViewScenePath====>", scenePath);
8885
+ console.log("[window-manager] dispatchSetMainViewScenePath ", JSON.stringify(scenePath));
8835
8886
  this.dispatchInternalEvent(Events.SetMainViewScenePath, { nextScenePath: scenePath });
8836
8887
  callbacks$1.emit("mainViewScenePathChange", scenePath);
8837
8888
  setScenePath(this.room, scenePath);
@@ -9097,6 +9148,15 @@ const replaceRoomFunction = (room, manager) => {
9097
9148
  return manager.canRedoSteps;
9098
9149
  }
9099
9150
  });
9151
+ const _scalePptToFit = room.scalePptToFit;
9152
+ room.scalePptToFit = (...args) => {
9153
+ var _a;
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
+ }
9159
+ };
9100
9160
  room.moveCamera = (camera) => manager.moveCamera(camera);
9101
9161
  room.moveCameraToContain = (...args) => manager.moveCameraToContain(...args);
9102
9162
  room.convertToPointInWorld = (...args) => manager.mainView.convertToPointInWorld(...args);
@@ -19687,15 +19747,20 @@ const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
19687
19747
  const _WindowManager = class extends InvisiblePlugin {
19688
19748
  constructor(context) {
19689
19749
  super(context);
19690
- this.version = "1.0.13-test.1";
19750
+ this.version = "1.0.13-test.3";
19691
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" } };
19692
19752
  this.emitter = callbacks$1;
19693
19753
  this.viewMode = ViewMode.Broadcaster;
19694
19754
  this.isReplay = isPlayer(this.displayer);
19695
19755
  this._cursorUIDs = [];
19696
19756
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
19757
+ this.visibleStateListener = () => {
19758
+ console.log("[window-manager] visibleStateListener isVisible:", !document.hidden);
19759
+ };
19697
19760
  _WindowManager.displayer = context.displayer;
19698
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);
19699
19764
  }
19700
19765
  get Logger() {
19701
19766
  return this._roomLogger;
@@ -20371,6 +20436,7 @@ const _WindowManager = class extends InvisiblePlugin {
20371
20436
  (_e = _WindowManager.playground.parentNode) == null ? void 0 : _e.removeChild(_WindowManager.playground);
20372
20437
  }
20373
20438
  _WindowManager.params = void 0;
20439
+ document.removeEventListener("visibilitychange", this.visibleStateListener);
20374
20440
  (_f = this._iframeBridge) == null ? void 0 : _f.destroy();
20375
20441
  this._iframeBridge = void 0;
20376
20442
  log("Destroyed");