@netless/window-manager 1.0.13-test.8 → 1.0.13

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,6 @@ 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);
356
355
  room.setScenePath(nextScenePath);
357
356
  }
358
357
  }
@@ -464,7 +463,6 @@ class AppListeners {
464
463
  break;
465
464
  }
466
465
  case Events.SetMainViewScenePath: {
467
- console.log("[window-manager] mainMagixEventListener " + JSON.stringify(data.payload));
468
466
  this.setMainViewScenePathHandler(data.payload);
469
467
  break;
470
468
  }
@@ -5692,6 +5690,88 @@ class BoxManager {
5692
5690
  }
5693
5691
  }
5694
5692
  BoxManager.kind = "BoxManager";
5693
+ function formatAttributesLogObjectKey(key) {
5694
+ return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
5695
+ }
5696
+ function stringifyForAttributesLog(value, seen) {
5697
+ if (value === void 0) {
5698
+ return "undefined";
5699
+ }
5700
+ if (value === null) {
5701
+ return "null";
5702
+ }
5703
+ const t2 = typeof value;
5704
+ if (t2 === "bigint") {
5705
+ return `${value}n`;
5706
+ }
5707
+ if (t2 === "symbol") {
5708
+ return String(value);
5709
+ }
5710
+ if (t2 === "function") {
5711
+ const fn = value;
5712
+ return `[Function ${fn.name || "anonymous"}]`;
5713
+ }
5714
+ if (t2 !== "object") {
5715
+ return t2 === "string" ? JSON.stringify(value) : String(value);
5716
+ }
5717
+ const obj = value;
5718
+ if (seen == null ? void 0 : seen.has(obj)) {
5719
+ return "[Circular]";
5720
+ }
5721
+ const nextSeen = seen != null ? seen : /* @__PURE__ */ new WeakSet();
5722
+ nextSeen.add(obj);
5723
+ try {
5724
+ if (Array.isArray(value)) {
5725
+ return `[${Array.from(
5726
+ value,
5727
+ (item) => stringifyForAttributesLog(item, nextSeen)
5728
+ ).join(",")}]`;
5729
+ }
5730
+ if (value instanceof Date) {
5731
+ return JSON.stringify(value.toISOString());
5732
+ }
5733
+ if (value instanceof RegExp) {
5734
+ return String(value);
5735
+ }
5736
+ const keys = Object.keys(value);
5737
+ const pairs = keys.map((k2) => {
5738
+ let v2;
5739
+ try {
5740
+ v2 = value[k2];
5741
+ } catch {
5742
+ return `${formatAttributesLogObjectKey(k2)}:[Threw]`;
5743
+ }
5744
+ return `${formatAttributesLogObjectKey(k2)}:${stringifyForAttributesLog(v2, nextSeen)}`;
5745
+ });
5746
+ return `{${pairs.join(",")}}`;
5747
+ } catch {
5748
+ return "[Unserializable]";
5749
+ } finally {
5750
+ nextSeen.delete(obj);
5751
+ }
5752
+ }
5753
+ function isShallowMergeAttributesRecord(value) {
5754
+ return value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp);
5755
+ }
5756
+ const ARGUS_LOG_INFO_MAX_LENGTH = 1500;
5757
+ function truncateArgusLogInfoMessage(message) {
5758
+ if (message.length <= ARGUS_LOG_INFO_MAX_LENGTH) {
5759
+ return message;
5760
+ }
5761
+ const ellipsis = "\u2026";
5762
+ return message.slice(0, ARGUS_LOG_INFO_MAX_LENGTH - ellipsis.length) + ellipsis;
5763
+ }
5764
+ function keysPathEqual(a2, b2) {
5765
+ if (a2.length !== b2.length) {
5766
+ return false;
5767
+ }
5768
+ for (let i2 = 0; i2 < a2.length; i2++) {
5769
+ if (a2[i2] !== b2[i2]) {
5770
+ return false;
5771
+ }
5772
+ }
5773
+ return true;
5774
+ }
5695
5775
  const log = (...args) => {
5696
5776
  if (WindowManager.debug) {
5697
5777
  console.log(`[WindowManager]:`, ...args);
@@ -5725,6 +5805,158 @@ class LocalConsole {
5725
5805
  }
5726
5806
  console.log(`[window-manager][${this.name}]: ${args.join(", ")}`);
5727
5807
  }
5808
+ destroy() {
5809
+ if (this.flushTimer != null) {
5810
+ clearTimeout(this.flushTimer);
5811
+ this.flushTimer = null;
5812
+ }
5813
+ this.pendingArgs = null;
5814
+ }
5815
+ }
5816
+ class ArgusLog {
5817
+ constructor(logger, name, debounceTime) {
5818
+ this.logger = logger;
5819
+ this.name = name;
5820
+ this.debounceTime = debounceTime;
5821
+ this.pendingArgs = null;
5822
+ this.flushTimer = null;
5823
+ this.pendingShallowMerge = null;
5824
+ this.shallowMergeTimer = null;
5825
+ this.pendingUpdateSegments = null;
5826
+ this.updateMergeTimer = null;
5827
+ }
5828
+ emitInfo(message) {
5829
+ this.logger.info(truncateArgusLogInfoMessage(message));
5830
+ }
5831
+ flush() {
5832
+ this.flushTimer = null;
5833
+ const args = this.pendingArgs;
5834
+ this.pendingArgs = null;
5835
+ if (args === null) {
5836
+ return;
5837
+ }
5838
+ this.emitInfo(`[WindowManager][${this.name}]: ${args.join(", ")}`);
5839
+ }
5840
+ flushShallowMerge() {
5841
+ this.shallowMergeTimer = null;
5842
+ const p2 = this.pendingShallowMerge;
5843
+ this.pendingShallowMerge = null;
5844
+ if (p2 === null) {
5845
+ return;
5846
+ }
5847
+ const body = p2.kind === "record" ? stringifyForAttributesLog(p2.data) : stringifyForAttributesLog(p2.value);
5848
+ this.emitInfo(`[WindowManager][${this.name}]: ${p2.label} ${body}`);
5849
+ if (p2.kind === "record") {
5850
+ for (const k2 of Object.keys(p2.data)) {
5851
+ delete p2.data[k2];
5852
+ }
5853
+ }
5854
+ }
5855
+ log(...args) {
5856
+ const ms = this.debounceTime;
5857
+ if (ms != null && ms > 0) {
5858
+ this.pendingArgs = args;
5859
+ if (this.flushTimer != null) {
5860
+ clearTimeout(this.flushTimer);
5861
+ }
5862
+ this.flushTimer = setTimeout(() => this.flush(), ms);
5863
+ return;
5864
+ }
5865
+ this.emitInfo(`[WindowManager][${this.name}]: ${args.join(", ")}`);
5866
+ }
5867
+ logDebouncedShallowMerge(label, payload) {
5868
+ var _a;
5869
+ const ms = this.debounceTime;
5870
+ const debounced = ms != null && ms > 0;
5871
+ const emit = (text2) => {
5872
+ this.emitInfo(`[WindowManager][${this.name}]: ${label} ${text2}`);
5873
+ };
5874
+ if (!debounced) {
5875
+ emit(stringifyForAttributesLog(payload));
5876
+ return;
5877
+ }
5878
+ if (this.shallowMergeTimer != null) {
5879
+ clearTimeout(this.shallowMergeTimer);
5880
+ this.shallowMergeTimer = null;
5881
+ }
5882
+ if (isShallowMergeAttributesRecord(payload)) {
5883
+ if (((_a = this.pendingShallowMerge) == null ? void 0 : _a.kind) === "record") {
5884
+ this.pendingShallowMerge = {
5885
+ kind: "record",
5886
+ label,
5887
+ data: { ...this.pendingShallowMerge.data, ...payload }
5888
+ };
5889
+ } else {
5890
+ this.pendingShallowMerge = { kind: "record", label, data: { ...payload } };
5891
+ }
5892
+ } else {
5893
+ this.pendingShallowMerge = { kind: "atom", label, value: payload };
5894
+ }
5895
+ this.shallowMergeTimer = setTimeout(() => this.flushShallowMerge(), ms);
5896
+ }
5897
+ flushUpdateAttributesMerge() {
5898
+ this.updateMergeTimer = null;
5899
+ const segments = this.pendingUpdateSegments;
5900
+ this.pendingUpdateSegments = null;
5901
+ if (segments === null || segments.length === 0) {
5902
+ return;
5903
+ }
5904
+ const parts = segments.map(
5905
+ (s2) => `${s2.keys.join(", ")} ${stringifyForAttributesLog(s2.value)}`
5906
+ );
5907
+ this.emitInfo(`[WindowManager][${this.name}]: safeUpdateAttributes ${parts.join(" | ")}`);
5908
+ for (const s2 of segments) {
5909
+ s2.keys.length = 0;
5910
+ s2.value = void 0;
5911
+ }
5912
+ segments.length = 0;
5913
+ }
5914
+ logDebouncedUpdateAttributes(keys, value) {
5915
+ const ms = this.debounceTime;
5916
+ const debounced = ms != null && ms > 0;
5917
+ const keysCopy = [...keys];
5918
+ if (!debounced) {
5919
+ this.emitInfo(
5920
+ `[WindowManager][${this.name}]: safeUpdateAttributes ${keysCopy.join(", ")} ${stringifyForAttributesLog(value)}`
5921
+ );
5922
+ return;
5923
+ }
5924
+ if (this.updateMergeTimer != null) {
5925
+ clearTimeout(this.updateMergeTimer);
5926
+ this.updateMergeTimer = null;
5927
+ }
5928
+ if (this.pendingUpdateSegments === null || this.pendingUpdateSegments.length === 0) {
5929
+ this.pendingUpdateSegments = [{ keys: keysCopy, value }];
5930
+ } else {
5931
+ const last = this.pendingUpdateSegments[this.pendingUpdateSegments.length - 1];
5932
+ if (keysPathEqual(last.keys, keysCopy)) {
5933
+ last.value = value;
5934
+ } else {
5935
+ this.pendingUpdateSegments.push({ keys: keysCopy, value });
5936
+ }
5937
+ }
5938
+ this.updateMergeTimer = setTimeout(() => this.flushUpdateAttributesMerge(), ms);
5939
+ }
5940
+ destroy() {
5941
+ if (this.flushTimer != null) {
5942
+ clearTimeout(this.flushTimer);
5943
+ this.flushTimer = null;
5944
+ }
5945
+ if (this.shallowMergeTimer != null) {
5946
+ clearTimeout(this.shallowMergeTimer);
5947
+ this.shallowMergeTimer = null;
5948
+ }
5949
+ if (this.updateMergeTimer != null) {
5950
+ clearTimeout(this.updateMergeTimer);
5951
+ this.updateMergeTimer = null;
5952
+ }
5953
+ this.pendingArgs = null;
5954
+ this.pendingShallowMerge = null;
5955
+ this.pendingUpdateSegments = null;
5956
+ }
5957
+ dispose() {
5958
+ this.destroy();
5959
+ }
5728
5960
  }
5729
5961
  const setupWrapper = (root) => {
5730
5962
  const playground = document.createElement("div");
@@ -7033,7 +7265,6 @@ var Fields = /* @__PURE__ */ ((Fields2) => {
7033
7265
  class AttributesDelegate {
7034
7266
  constructor(context) {
7035
7267
  this.context = context;
7036
- this.setMainViewCameraConsole = new LocalConsole("setMainViewCamera", 50);
7037
7268
  this.setAppFocus = (appId, focus) => {
7038
7269
  if (focus) {
7039
7270
  this.context.safeSetAttributes({ ["focus"]: appId });
@@ -7159,11 +7390,9 @@ class AttributesDelegate {
7159
7390
  return this.attributes["boxState"];
7160
7391
  }
7161
7392
  setMainViewScenePath(scenePath) {
7162
- console.log("[window-manager] setMainViewScenePath ", scenePath);
7163
7393
  this.context.safeSetAttributes({ _mainScenePath: scenePath });
7164
7394
  }
7165
7395
  setMainViewSceneIndex(index2) {
7166
- console.log("[window-manager] setMainViewSceneIndex ", index2);
7167
7396
  this.context.safeSetAttributes({ _mainSceneIndex: index2 });
7168
7397
  }
7169
7398
  getMainViewCamera() {
@@ -7173,19 +7402,16 @@ class AttributesDelegate {
7173
7402
  return get(this.attributes, ["mainViewSize"]);
7174
7403
  }
7175
7404
  setMainViewCamera(camera) {
7176
- this.setMainViewCameraConsole.log(JSON.stringify(camera));
7177
7405
  this.context.safeSetAttributes({ ["mainViewCamera"]: { ...camera } });
7178
7406
  }
7179
7407
  setMainViewSize(size2) {
7180
7408
  if (size2.width === 0 || size2.height === 0)
7181
7409
  return;
7182
- console.log("[window-manager] setMainViewSize ", JSON.stringify(size2));
7183
7410
  this.context.safeSetAttributes({ ["mainViewSize"]: { ...size2 } });
7184
7411
  }
7185
7412
  setMainViewCameraAndSize(camera, size2) {
7186
7413
  if (size2.width === 0 || size2.height === 0)
7187
7414
  return;
7188
- console.log("[window-manager] setMainViewCameraAndSize ", JSON.stringify(camera), JSON.stringify(size2));
7189
7415
  this.context.safeSetAttributes({
7190
7416
  ["mainViewCamera"]: { ...camera },
7191
7417
  ["mainViewSize"]: { ...size2 }
@@ -7429,13 +7655,13 @@ const _AppProxy = class {
7429
7655
  this.manager.safeUpdateAttributes(["apps", this.id, Fields.FullPath], path);
7430
7656
  }
7431
7657
  async baseInsertApp(skipUpdate = false, boxStatus = TELE_BOX_STATE.Normal) {
7432
- var _a, _b, _c;
7658
+ var _a;
7433
7659
  const params = this.params;
7434
7660
  if (!params.kind) {
7435
- (_a = this.Logger) == null ? void 0 : _a.error(`[WindowManager]: kind require`);
7661
+ this.Logger && this.Logger.error(`[WindowManager]: kind require`);
7436
7662
  throw new Error("[WindowManager]: kind require");
7437
7663
  }
7438
- const appImpl = await ((_b = appRegister.appClasses.get(params.kind)) == null ? void 0 : _b());
7664
+ const appImpl = await ((_a = appRegister.appClasses.get(params.kind)) == null ? void 0 : _a());
7439
7665
  const appParams = appRegister.registered.get(params.kind);
7440
7666
  if (appImpl) {
7441
7667
  await this.setupApp(
@@ -7450,7 +7676,7 @@ const _AppProxy = class {
7450
7676
  params.isDragContent
7451
7677
  );
7452
7678
  } else {
7453
- (_c = this.Logger) == null ? void 0 : _c.error(`[WindowManager]: app load failed ${params.kind} ${params.src}`);
7679
+ this.Logger && this.Logger.error(`[WindowManager]: app load failed ${params.kind} ${params.src}`);
7454
7680
  throw new Error(`[WindowManager]: app load failed ${params.kind} ${params.src}`);
7455
7681
  }
7456
7682
  internalEmitter.emit("updateManagerRect");
@@ -7464,7 +7690,7 @@ const _AppProxy = class {
7464
7690
  return (_a = this.boxManager) == null ? void 0 : _a.getBox(this.id);
7465
7691
  }
7466
7692
  async setupApp(appId, skipUpdate, app, options, appOptions, boxStatus, forceTop, forceNormal, isDragContent) {
7467
- var _a, _b;
7693
+ var _a;
7468
7694
  log("setupApp", appId, app, options, boxStatus, forceTop, forceNormal, isDragContent);
7469
7695
  if (!this.boxManager) {
7470
7696
  throw new BoxManagerNotFoundError();
@@ -7488,8 +7714,7 @@ const _AppProxy = class {
7488
7714
  currentMainViewScenePath = this.manager.mainView.scenePath;
7489
7715
  }
7490
7716
  setTimeout(async () => {
7491
- var _a3;
7492
- (_a3 = this.Logger) == null ? void 0 : _a3.info(`[WindowManager]: setup app ${this.kind}, appId: ${appId}`);
7717
+ this.Logger && this.Logger.info(`[WindowManager]: setup app ${this.kind}, appId: ${appId}`);
7493
7718
  const result = await app.setup(context);
7494
7719
  this.appResult = result;
7495
7720
  appRegister.notifyApp(this.kind, "created", { appId, result });
@@ -7524,7 +7749,7 @@ const _AppProxy = class {
7524
7749
  this.boxManager.focusBox({ appId }, false);
7525
7750
  }
7526
7751
  } catch (error) {
7527
- (_b = this.Logger) == null ? void 0 : _b.error(`[WindowManager]: app setup error: ${error.message}`);
7752
+ this.Logger && this.Logger.error(`[WindowManager]: app setup error: ${error.message}`);
7528
7753
  throw new Error(`[WindowManager]: app setup error: ${error.message}`);
7529
7754
  }
7530
7755
  }
@@ -7695,7 +7920,7 @@ const _AppProxy = class {
7695
7920
  }
7696
7921
  }
7697
7922
  async destroy(needCloseBox, cleanAttrs, skipUpdate, error) {
7698
- var _a, _b, _c;
7923
+ var _a;
7699
7924
  if (this.status === "destroyed")
7700
7925
  return;
7701
7926
  this.status = "destroyed";
@@ -7703,13 +7928,13 @@ const _AppProxy = class {
7703
7928
  await appRegister.notifyApp(this.kind, "destroy", { appId: this.id });
7704
7929
  await this.appEmitter.emit("destroy", { error });
7705
7930
  } catch (error2) {
7706
- (_a = this.Logger) == null ? void 0 : _a.error(`[WindowManager]: notifyApp error: ${error2.message}`);
7931
+ this.Logger && this.Logger.error(`[WindowManager]: notifyApp error: ${error2.message}`);
7707
7932
  console.error("[WindowManager]: notifyApp error", error2.message, error2.stack);
7708
7933
  }
7709
7934
  this.appEmitter.clearListeners();
7710
7935
  internalEmitter.emit(`destroy-${this.id}`, { error });
7711
7936
  if (needCloseBox) {
7712
- (_b = this.boxManager) == null ? void 0 : _b.closeBox(this.id, skipUpdate);
7937
+ (_a = this.boxManager) == null ? void 0 : _a.closeBox(this.id, skipUpdate);
7713
7938
  }
7714
7939
  if (cleanAttrs) {
7715
7940
  this.store.cleanAppAttributes(this.id);
@@ -7725,7 +7950,7 @@ const _AppProxy = class {
7725
7950
  this.manager.refresher.remove(this.stateKey);
7726
7951
  this.manager.refresher.remove(`${this.id}-fullPath`);
7727
7952
  this._prevFullPath = void 0;
7728
- (_c = this.Logger) == null ? void 0 : _c.info(`[WindowManager]: destroy app ${this.kind} appId: ${this.id}`);
7953
+ this.Logger && this.Logger.info(`[WindowManager]: destroy app ${this.kind} appId: ${this.id}`);
7729
7954
  }
7730
7955
  close() {
7731
7956
  return this.destroy(true, true, false);
@@ -7783,17 +8008,21 @@ const setDefaultCameraBound = (view) => {
7783
8008
  minContentMode: () => 0.1
7784
8009
  });
7785
8010
  };
7786
- window.___local_log = window.___local_log || /* @__PURE__ */ new Set();
7787
8011
  class MainViewProxy {
7788
8012
  constructor(manager) {
7789
8013
  this.manager = manager;
7790
8014
  this.polling = false;
7791
8015
  this.started = false;
7792
8016
  this.mainViewIsAddListener = false;
8017
+ this.isForcingMainViewDivElement = false;
8018
+ this.wrapperRectWorkaroundFrame = 0;
7793
8019
  this.store = this.manager.store;
7794
8020
  this.viewMode = this.manager.windowManger.viewMode;
7795
8021
  this.sideEffectManager = new o$2();
7796
- this.playgroundSizeChangeListenerLocalConsole = new LocalConsole("playgroundSizeChangeListener", 30);
8022
+ this.playgroundSizeChangeListenerLocalConsole = new LocalConsole("playgroundSizeChangeListener", 100);
8023
+ this.sizeUpdatedLocalConsole = new LocalConsole("sizeUpdated", 100);
8024
+ this.cameraUpdatedLocalConsole = new LocalConsole("cameraUpdated", 100);
8025
+ this.cameraReactionLocalConsole = new LocalConsole("cameraReaction", 100);
7797
8026
  this.syncCamera = () => {
7798
8027
  if (!this.polling || this.viewMode !== ViewMode.Broadcaster)
7799
8028
  return;
@@ -7813,6 +8042,32 @@ class MainViewProxy {
7813
8042
  });
7814
8043
  });
7815
8044
  };
8045
+ this.onWrapperRectChange = (payload) => {
8046
+ this.pendingWrapperRectChange = payload;
8047
+ if (this.wrapperRectWorkaroundFrame) {
8048
+ cancelAnimationFrame(this.wrapperRectWorkaroundFrame);
8049
+ }
8050
+ this.wrapperRectWorkaroundFrame = requestAnimationFrame(this.runWrapperRectWorkaround);
8051
+ };
8052
+ this.runWrapperRectWorkaround = () => {
8053
+ this.wrapperRectWorkaroundFrame = 0;
8054
+ const payload = this.pendingWrapperRectChange;
8055
+ const element2 = this.mainView.divElement;
8056
+ this.pendingWrapperRectChange = void 0;
8057
+ if (!payload || !element2)
8058
+ return;
8059
+ const rect = element2.getBoundingClientRect();
8060
+ const observedSize = { width: rect.width, height: rect.height };
8061
+ const wrapperMatchesDom = Math.abs(payload.width - observedSize.width) <= 0.5 && Math.abs(payload.height - observedSize.height) <= 0.5;
8062
+ const viewIsStale = Math.abs(this.mainView.size.width - observedSize.width) > 0.5 || Math.abs(this.mainView.size.height - observedSize.height) > 0.5;
8063
+ if (wrapperMatchesDom && viewIsStale) {
8064
+ this.forceSyncMainViewDivElement(
8065
+ `wrapperRectChange:${payload.origin || "unknown"}`,
8066
+ observedSize,
8067
+ element2
8068
+ );
8069
+ }
8070
+ };
7816
8071
  this.addCameraReaction = () => {
7817
8072
  this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
7818
8073
  };
@@ -7821,9 +8076,9 @@ class MainViewProxy {
7821
8076
  () => this.mainViewCamera,
7822
8077
  (camera) => {
7823
8078
  if (camera && camera.id !== this.manager.uid) {
7824
- console.log("[window-manager] cameraReaction " + JSON.stringify(camera) + JSON.stringify(this.mainViewSize));
7825
8079
  this.moveCameraToContian(this.mainViewSize);
7826
8080
  this.moveCamera(camera);
8081
+ this.cameraReactionLocalConsole.log(`camera: ${JSON.stringify(camera)}, current size: ${JSON.stringify(this.mainViewSize)}`);
7827
8082
  }
7828
8083
  },
7829
8084
  { fireImmediately: true }
@@ -7833,7 +8088,7 @@ class MainViewProxy {
7833
8088
  if (size2) {
7834
8089
  this.moveCameraToContian(size2);
7835
8090
  this.moveCamera(this.mainViewCamera);
7836
- console.log("[window-manager] sizeChangeHandler current size and camera" + JSON.stringify(size2) + JSON.stringify(this.mainViewCamera) + JSON.stringify(this.mainView.camera) + JSON.stringify(this.mainView.size));
8091
+ console.log("[window-manager] sizeChangeHandler current size and camera" + JSON.stringify(size2) + JSON.stringify(this.mainViewCamera) + JSON.stringify(this.mainView.camera) + JSON.stringify(this.mainView.size));
7837
8092
  }
7838
8093
  this.ensureMainViewSize();
7839
8094
  }, 30);
@@ -7857,7 +8112,7 @@ class MainViewProxy {
7857
8112
  this.store.setMainViewSize({ ...size2, id: this.manager.uid });
7858
8113
  }, 50);
7859
8114
  this._syncMainViewTimer = 0;
7860
- this.onCameraOrSizeUpdated = () => {
8115
+ this.handleCameraOrSizeUpdated = () => {
7861
8116
  callbacks$1.emit("cameraStateChange", this.cameraState);
7862
8117
  if (this.manager.room && this.manager.room.syncMainView) {
7863
8118
  clearTimeout(this._syncMainViewTimer);
@@ -7865,9 +8120,16 @@ class MainViewProxy {
7865
8120
  }
7866
8121
  this.ensureMainViewSize();
7867
8122
  };
8123
+ this.onCameraUpdated = (camera) => {
8124
+ this.cameraUpdatedLocalConsole.log(JSON.stringify(camera));
8125
+ this.handleCameraOrSizeUpdated();
8126
+ };
8127
+ this.onSizeUpdated = (size2) => {
8128
+ this.sizeUpdatedLocalConsole.log(JSON.stringify(size2));
8129
+ this.handleCameraOrSizeUpdated();
8130
+ };
7868
8131
  this.syncMainView = (room) => {
7869
8132
  if (room.isWritable) {
7870
- console.log("[window-manager] syncMainView ");
7871
8133
  room.syncMainView(this.mainView);
7872
8134
  }
7873
8135
  };
@@ -7904,6 +8166,9 @@ class MainViewProxy {
7904
8166
  this.sideEffectManager.add(() => {
7905
8167
  return internalEmitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio);
7906
8168
  });
8169
+ this.sideEffectManager.add(() => {
8170
+ return internalEmitter.on("wrapperRectChange", this.onWrapperRectChange);
8171
+ });
7907
8172
  this.sideEffectManager.add(() => {
7908
8173
  return internalEmitter.on("startReconnect", () => {
7909
8174
  if (!this.didRelease) {
@@ -7934,8 +8199,52 @@ class MainViewProxy {
7934
8199
  this.moveCameraToContian(this.mainViewSize);
7935
8200
  this.moveCamera(this.mainViewCamera);
7936
8201
  }
8202
+ forceSyncMainViewDivElement(reason, observedSize, element2) {
8203
+ var _a, _b;
8204
+ const { width: viewWidth, height: viewHeight } = this.mainView.size;
8205
+ let targetElement = element2;
8206
+ if (Math.abs(viewWidth - observedSize.width) <= 0.5 && Math.abs(viewHeight - observedSize.height) <= 0.5) {
8207
+ return;
8208
+ }
8209
+ if (this.isForcingMainViewDivElement) {
8210
+ console.log("[window-manager] skipForceSyncMainViewDivElement " + JSON.stringify({
8211
+ reason,
8212
+ observedSize,
8213
+ viewSize: this.mainView.size
8214
+ }));
8215
+ return;
8216
+ }
8217
+ this.isForcingMainViewDivElement = true;
8218
+ try {
8219
+ const mainView = this.mainView;
8220
+ const screen = mainView.screen;
8221
+ const resizeObserver = screen == null ? void 0 : screen.resizeObserver;
8222
+ if (typeof (screen == null ? void 0 : screen.refreshSize) === "function") {
8223
+ console.log(
8224
+ "[window-manager] forceSyncMainViewDivElement observerReset " + JSON.stringify({
8225
+ reason,
8226
+ viewSize: this.mainView.size,
8227
+ observedSize
8228
+ })
8229
+ );
8230
+ (_a = resizeObserver == null ? void 0 : resizeObserver.disconnect) == null ? void 0 : _a.call(resizeObserver);
8231
+ screen.refreshSize(observedSize.width, observedSize.height);
8232
+ (_b = resizeObserver == null ? void 0 : resizeObserver.observe) == null ? void 0 : _b.call(resizeObserver, element2);
8233
+ }
8234
+ } finally {
8235
+ queueMicrotask(() => {
8236
+ const rect = targetElement.getBoundingClientRect();
8237
+ console.log("[window-manager] forceSyncMainViewDivElementResult " + JSON.stringify({
8238
+ reason,
8239
+ viewSize: this.mainView.size,
8240
+ rect: { width: rect.width, height: rect.height }
8241
+ }));
8242
+ this.isForcingMainViewDivElement = false;
8243
+ });
8244
+ }
8245
+ }
7937
8246
  start() {
7938
- console.log("[window-manager] start " + JSON.stringify(this.mainViewSize));
8247
+ console.log("[window-manager] start attributes size:" + JSON.stringify(this.mainViewSize));
7939
8248
  this.sizeChangeHandler(this.mainViewSize);
7940
8249
  if (this.started)
7941
8250
  return;
@@ -7944,6 +8253,10 @@ class MainViewProxy {
7944
8253
  if (this.manager.room)
7945
8254
  this.syncMainView(this.manager.room);
7946
8255
  this.started = true;
8256
+ if (this.mainView.focusScenePath) {
8257
+ this.manager.windowManger.onMainViewScenePathChangeHandler(this.mainView.focusScenePath);
8258
+ }
8259
+ console.log("[window-manager] start end mainView size:" + JSON.stringify(this.mainView.size));
7947
8260
  }
7948
8261
  setCameraAndSize() {
7949
8262
  const camera = { ...this.mainView.camera, id: this.manager.uid };
@@ -8017,13 +8330,13 @@ class MainViewProxy {
8017
8330
  }
8018
8331
  addCameraListener() {
8019
8332
  this.view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
8020
- this.view.callbacks.on("onCameraUpdated", this.onCameraOrSizeUpdated);
8021
- this.view.callbacks.on("onSizeUpdated", this.onCameraOrSizeUpdated);
8333
+ this.view.callbacks.on("onCameraUpdated", this.onCameraUpdated);
8334
+ this.view.callbacks.on("onSizeUpdated", this.onSizeUpdated);
8022
8335
  }
8023
8336
  removeCameraListener() {
8024
8337
  this.view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
8025
- this.view.callbacks.off("onCameraUpdated", this.onCameraOrSizeUpdated);
8026
- this.view.callbacks.off("onSizeUpdated", this.onCameraOrSizeUpdated);
8338
+ this.view.callbacks.off("onCameraUpdated", this.onCameraUpdated);
8339
+ this.view.callbacks.off("onSizeUpdated", this.onSizeUpdated);
8027
8340
  }
8028
8341
  ensureMainViewSize() {
8029
8342
  if ((!this.mainViewSize || this.mainViewSize.width === 0 || this.mainViewSize.height === 0) && this.mainView.size.width > 0 && this.mainView.size.height > 0) {
@@ -8063,6 +8376,15 @@ class MainViewProxy {
8063
8376
  this.started = false;
8064
8377
  }
8065
8378
  destroy() {
8379
+ console.log("[window-manager] destroy ");
8380
+ if (this.wrapperRectWorkaroundFrame) {
8381
+ cancelAnimationFrame(this.wrapperRectWorkaroundFrame);
8382
+ this.wrapperRectWorkaroundFrame = 0;
8383
+ }
8384
+ this.playgroundSizeChangeListenerLocalConsole.destroy();
8385
+ this.sizeUpdatedLocalConsole.destroy();
8386
+ this.cameraUpdatedLocalConsole.destroy();
8387
+ this.cameraReactionLocalConsole.destroy();
8066
8388
  this.removeMainViewListener();
8067
8389
  this.stop();
8068
8390
  this.sideEffectManager.flushAll();
@@ -8152,7 +8474,7 @@ class AppManager {
8152
8474
  var _a, _b;
8153
8475
  const { scenePath } = params;
8154
8476
  if (scenePath === ROOT_DIR) {
8155
- console.log("[window-manager] onRemoveScenes ROOT_DIR");
8477
+ console.log("[window-manager] onRemoveScenes ROOT_DIR");
8156
8478
  await this.onRootDirRemoved();
8157
8479
  this.dispatchInternalEvent(Events.RootDirRemoved);
8158
8480
  return;
@@ -8165,7 +8487,7 @@ class AppManager {
8165
8487
  sceneName = (_b = this.callbacksNode) == null ? void 0 : _b.scenes[nextIndex];
8166
8488
  }
8167
8489
  if (sceneName) {
8168
- console.log(`[window-manager] onRemoveScenes setMainViewScenePath${ROOT_DIR}${sceneName}`);
8490
+ console.log(`[window-manager] onRemoveScenes setMainViewScenePath ${ROOT_DIR}${sceneName}`);
8169
8491
  this.setMainViewScenePath(`${ROOT_DIR}${sceneName}`);
8170
8492
  }
8171
8493
  await this.setMainViewSceneIndex(nextIndex);
@@ -8463,7 +8785,6 @@ class AppManager {
8463
8785
  const pageName = scenePath.replace(sceneDir, "").replace("/", "");
8464
8786
  const index2 = scenes.findIndex((scene) => scene.name === pageName);
8465
8787
  if (isInteger(index2) && index2 >= 0) {
8466
- console.log("[window-manager] updateSceneIndex ", index2);
8467
8788
  this.safeSetAttributes({ _mainSceneIndex: index2 });
8468
8789
  }
8469
8790
  }
@@ -8504,8 +8825,6 @@ class AppManager {
8504
8825
  internalEmitter.on("setReadonly", this.onReadonlyChanged);
8505
8826
  this.createRootDirScenesCallback();
8506
8827
  appRegister.setSyncRegisterApp((payload) => {
8507
- var _a;
8508
- (_a = this.Logger) == null ? void 0 : _a.info(`[WindowManager] syncRegisterApp ${JSON.stringify(payload)}`);
8509
8828
  this.safeUpdateAttributes([Fields.Registered, payload.kind], payload);
8510
8829
  });
8511
8830
  }
@@ -8657,7 +8976,6 @@ class AppManager {
8657
8976
  }
8658
8977
  }
8659
8978
  async _attributesUpdateCallback(apps) {
8660
- var _a;
8661
8979
  if (apps && WindowManager.container) {
8662
8980
  const appIds = Object.keys(apps);
8663
8981
  if (appIds.length === 0) {
@@ -8681,7 +8999,7 @@ class AppManager {
8681
8999
  try {
8682
9000
  const appAttributes = this.attributes[id2];
8683
9001
  if (!appAttributes) {
8684
- (_a = this.Logger) == null ? void 0 : _a.error(
9002
+ this.Logger && this.Logger.error(
8685
9003
  `[WindowManager]: appAttributes is undefined, appId: ${id2}`
8686
9004
  );
8687
9005
  throw new Error("appAttributes is undefined");
@@ -8731,7 +9049,6 @@ class AppManager {
8731
9049
  (_a = this.boxManager) == null ? void 0 : _a.setMinimized(Boolean(this.store.getMinimized()));
8732
9050
  }
8733
9051
  bindMainView(divElement, disableCameraTransform) {
8734
- var _a, _b, _c, _d, _e, _f, _g, _h;
8735
9052
  const mainView = this.mainViewProxy.view;
8736
9053
  mainView.disableCameraTransform = disableCameraTransform;
8737
9054
  mainView.divElement = divElement;
@@ -8742,13 +9059,12 @@ class AppManager {
8742
9059
  callbacks$1.emit("onMainViewMounted", mainView);
8743
9060
  const hasRoot = this.hasRoot(mainView.divElement);
8744
9061
  const rect = this.getRectByDivElement(mainView.divElement);
8745
- console.log(
8746
- "[window-manager] bindMainView hasRoot" + hasRoot + JSON.stringify(rect) + window.outerHeight + window.outerWidth,
8747
- (_b = (_a = window.visualViewport) == null ? void 0 : _a.width) != null ? _b : "null",
8748
- (_d = (_c = window.visualViewport) == null ? void 0 : _c.height) != null ? _d : "null",
8749
- (_f = (_e = window.visualViewport) == null ? void 0 : _e.offsetLeft) != null ? _f : "null",
8750
- (_h = (_g = window.visualViewport) == null ? void 0 : _g.offsetTop) != null ? _h : "null"
8751
- );
9062
+ let log2 = `[window-manager] bindMainView hasRoot:${hasRoot}, rect:${JSON.stringify(rect)}, outerHeight:${window.outerHeight}, outerWidth:${window.outerWidth}`;
9063
+ const visualViewport = window.visualViewport;
9064
+ if (visualViewport) {
9065
+ log2 += `, visualViewportWidth:${visualViewport.width}, visualViewportHeight:${visualViewport.height}, visualViewportOffsetLeft:${visualViewport.offsetLeft}, visualViewportOffsetTop:${visualViewport.offsetTop}`;
9066
+ }
9067
+ console.log(log2);
8752
9068
  }
8753
9069
  hasRoot(divElement) {
8754
9070
  let current = divElement;
@@ -8824,7 +9140,7 @@ class AppManager {
8824
9140
  }
8825
9141
  }
8826
9142
  async baseInsertApp(params, appId, isAddApp, focus) {
8827
- var _a, _b;
9143
+ var _a;
8828
9144
  if (this.appProxies.has(appId)) {
8829
9145
  (_a = this.windowManger.Logger) == null ? void 0 : _a.warn(
8830
9146
  `[WindowManager]: app duplicate exists and cannot be created again, appId: ${appId}`
@@ -8839,7 +9155,7 @@ class AppManager {
8839
9155
  return appProxy;
8840
9156
  } else {
8841
9157
  this.appStatus.delete(appId);
8842
- (_b = this.Logger) == null ? void 0 : _b.error(`[WindowManager]: initialize AppProxy failed, appId: ${appId}`);
9158
+ this.Logger && this.Logger.error(`[WindowManager]: initialize AppProxy failed, appId: ${appId}`);
8843
9159
  throw new Error("[WindowManger]: initialize AppProxy failed");
8844
9160
  }
8845
9161
  }
@@ -8850,16 +9166,15 @@ class AppManager {
8850
9166
  this.windowManger.safeUpdateAttributes(keys, value);
8851
9167
  }
8852
9168
  async setMainViewScenePath(scenePath) {
8853
- var _a, _b;
8854
9169
  if (this.room) {
8855
9170
  const scenePathType = this.displayer.scenePathType(scenePath);
8856
9171
  const sceneDir = parseSceneDir(scenePath);
8857
9172
  if (sceneDir !== ROOT_DIR) {
8858
- (_a = this.Logger) == null ? void 0 : _a.error(`[WindowManager]: main view scenePath must in root dir "/"`);
9173
+ this.Logger && this.Logger.error(`[WindowManager]: main view scenePath must in root dir "/"`);
8859
9174
  throw new Error(`[WindowManager]: main view scenePath must in root dir "/"`);
8860
9175
  }
8861
9176
  if (scenePathType === ScenePathType.None) {
8862
- (_b = this.Logger) == null ? void 0 : _b.error(`[WindowManager]: ${scenePath} not valid scene`);
9177
+ this.Logger && this.Logger.error(`[WindowManager]: ${scenePath} not valid scene`);
8863
9178
  throw new Error(`[WindowManager]: ${scenePath} not valid scene`);
8864
9179
  } else if (scenePathType === ScenePathType.Page) {
8865
9180
  await this._setMainViewScenePath(scenePath);
@@ -8874,7 +9189,6 @@ class AppManager {
8874
9189
  async _setMainViewScenePath(scenePath) {
8875
9190
  const success = this.setMainViewFocusPath(scenePath);
8876
9191
  if (success) {
8877
- console.log("[window-manager] _setMainViewScenePath ", scenePath);
8878
9192
  this.safeSetAttributes({ _mainScenePath: scenePath });
8879
9193
  this.store.setMainViewFocusPath(this.mainView);
8880
9194
  this.updateSceneIndex();
@@ -8882,7 +9196,7 @@ class AppManager {
8882
9196
  }
8883
9197
  }
8884
9198
  async setMainViewSceneIndex(index2) {
8885
- var _a, _b;
9199
+ var _a;
8886
9200
  if (this.room) {
8887
9201
  if (this.store.getMainViewSceneIndex() === index2)
8888
9202
  return;
@@ -8896,13 +9210,12 @@ class AppManager {
8896
9210
  this.dispatchSetMainViewScenePath(scenePath);
8897
9211
  }
8898
9212
  } else {
8899
- (_b = this.Logger) == null ? void 0 : _b.error(`[WindowManager]: ${index2} not valid index`);
9213
+ this.Logger && this.Logger.error(`[WindowManager]: ${index2} not valid index`);
8900
9214
  throw new Error(`[WindowManager]: ${index2} not valid index`);
8901
9215
  }
8902
9216
  }
8903
9217
  }
8904
9218
  dispatchSetMainViewScenePath(scenePath) {
8905
- console.log("[window-manager] dispatchSetMainViewScenePath ", JSON.stringify(scenePath));
8906
9219
  this.dispatchInternalEvent(Events.SetMainViewScenePath, { nextScenePath: scenePath });
8907
9220
  callbacks$1.emit("mainViewScenePathChange", scenePath);
8908
9221
  setScenePath(this.room, scenePath);
@@ -8978,6 +9291,7 @@ const ResizeObserver$2 = window.ResizeObserver || ResizeObserver$3;
8978
9291
  class ContainerResizeObserver {
8979
9292
  constructor(emitter) {
8980
9293
  this.emitter = emitter;
9294
+ this.updateSizerLocalConsole = new LocalConsole("updateSizer", 100);
8981
9295
  }
8982
9296
  static create(container, sizer, wrapper, emitter) {
8983
9297
  const containerResizeObserver = new ContainerResizeObserver(emitter);
@@ -8985,26 +9299,23 @@ class ContainerResizeObserver {
8985
9299
  return containerResizeObserver;
8986
9300
  }
8987
9301
  observePlaygroundSize(container, sizer, wrapper) {
8988
- console.log(`[window-manager] observePlaygroundSize ${JSON.stringify(container.getBoundingClientRect())}, ${JSON.stringify(sizer.getBoundingClientRect())}, ${JSON.stringify(wrapper.getBoundingClientRect())}`);
8989
- this.updateSizer(container.getBoundingClientRect(), sizer, wrapper);
9302
+ this.updateSizer(container.getBoundingClientRect(), sizer, wrapper, "observePlaygroundSize");
8990
9303
  this.containerResizeObserver = new ResizeObserver$2((entries) => {
8991
9304
  var _a;
8992
9305
  const containerRect = (_a = entries[0]) == null ? void 0 : _a.contentRect;
8993
9306
  if (containerRect) {
8994
- this.updateSizer(containerRect, sizer, wrapper);
8995
- console.log(`[window-manager] containerResizeObserver ${JSON.stringify(containerRect)}`);
9307
+ this.updateSizer(containerRect, sizer, wrapper, "containerResizeObserver");
8996
9308
  this.emitter.emit("playgroundSizeChange", containerRect);
8997
9309
  }
8998
9310
  });
8999
9311
  this.disposer = this.emitter.on("containerSizeRatioUpdate", () => {
9000
9312
  const containerRect = container.getBoundingClientRect();
9001
- console.log(`[window-manager] containerSizeRatioUpdate ${JSON.stringify(containerRect)}`);
9002
- this.updateSizer(containerRect, sizer, wrapper);
9313
+ this.updateSizer(containerRect, sizer, wrapper, "containerSizeRatioUpdate");
9003
9314
  this.emitter.emit("playgroundSizeChange", containerRect);
9004
9315
  });
9005
9316
  this.containerResizeObserver.observe(container);
9006
9317
  }
9007
- updateSizer({ width, height }, sizer, wrapper) {
9318
+ updateSizer({ width, height }, sizer, wrapper, origin) {
9008
9319
  if (width && height) {
9009
9320
  if (height / width > WindowManager.containerSizeRatio) {
9010
9321
  height = width * WindowManager.containerSizeRatio;
@@ -9015,16 +9326,21 @@ class ContainerResizeObserver {
9015
9326
  }
9016
9327
  wrapper.style.width = `${width}px`;
9017
9328
  wrapper.style.height = `${height}px`;
9018
- console.log(`[window-manager] updateSizer ${JSON.stringify({ width, height })}`);
9329
+ const wrapperRect = wrapper.getBoundingClientRect();
9330
+ this.updateSizerLocalConsole.log(`from ${origin}, traget size: ${JSON.stringify({ width, height })}, wrapperRect: ${wrapperRect.width} ${wrapperRect.height}`);
9331
+ this.emitter.emit("wrapperRectChange", {
9332
+ width: wrapperRect.width,
9333
+ height: wrapperRect.height,
9334
+ origin
9335
+ });
9019
9336
  }
9020
9337
  }
9021
9338
  disconnect() {
9022
- var _a;
9339
+ var _a, _b;
9340
+ this.updateSizerLocalConsole.destroy();
9023
9341
  (_a = this.containerResizeObserver) == null ? void 0 : _a.disconnect();
9024
- if (isFunction(this.disposer)) {
9025
- this.disposer();
9026
- this.disposer = void 0;
9027
- }
9342
+ (_b = this.disposer) == null ? void 0 : _b.call(this);
9343
+ this.disposer = void 0;
9028
9344
  }
9029
9345
  }
9030
9346
  class PageStateImpl {
@@ -9177,10 +9493,24 @@ const replaceRoomFunction = (room, manager) => {
9177
9493
  var _a;
9178
9494
  _scalePptToFit.call(room, ...args);
9179
9495
  if ((_a = manager.appManager) == null ? void 0 : _a.mainViewProxy) {
9180
- console.log("[window-manager] scalePptToFit " + JSON.stringify(args));
9181
9496
  manager.appManager.mainViewProxy.setCameraAndSize();
9182
9497
  }
9183
9498
  };
9499
+ const _putScenes = room.putScenes;
9500
+ room.putScenes = (...args) => {
9501
+ const [path, scenes] = args;
9502
+ const currentScenePath = manager.mainView.focusScenePath;
9503
+ if (currentScenePath && path && scenes) {
9504
+ console.log("[window-manager] putScenes " + JSON.stringify(args));
9505
+ for (const scene of scenes) {
9506
+ if (`${path}${scene.name}` === currentScenePath) {
9507
+ console.error(`[window-manager] putScenes: scene name can not be the same as the current scene path: ${currentScenePath}`);
9508
+ return;
9509
+ }
9510
+ }
9511
+ }
9512
+ return _putScenes.call(room, ...args);
9513
+ };
9184
9514
  room.moveCamera = (camera) => manager.moveCamera(camera);
9185
9515
  room.moveCameraToContain = (...args) => manager.moveCameraToContain(...args);
9186
9516
  room.convertToPointInWorld = (...args) => manager.mainView.convertToPointInWorld(...args);
@@ -11427,7 +11757,7 @@ class StaticDocsViewer {
11427
11757
  img.src = pdfPageSrc;
11428
11758
  await new Promise((resolve) => img.onload = resolve);
11429
11759
  whiteCtx.drawImage(img, 0, 0);
11430
- const pdfPageBase64 = whiteSnapshotCanvas.toDataURL("image/jpeg", 0.6);
11760
+ const pdfPageBase64 = whiteSnapshotCanvas.toDataURL("image/png");
11431
11761
  whiteCtx.clearRect(0, 0, width, height);
11432
11762
  const camera = {
11433
11763
  centerX: width / 2,
@@ -11447,7 +11777,7 @@ class StaticDocsViewer {
11447
11777
  this.whiteboardView.screenshotToCanvas(whiteCtx, scenePath, width, height, camera);
11448
11778
  }
11449
11779
  const snapshot = whiteSnapshotCanvas.toDataURL("image/png");
11450
- pdf.addImage(pdfPageBase64, "JPEG", 0, 0, width, height, "", "FAST");
11780
+ pdf.addImage(pdfPageBase64, "PNG", 0, 0, width, height, "", "FAST");
11451
11781
  pdf.addImage(snapshot, "PNG", 0, 0, width, height, "", "FAST");
11452
11782
  whiteCtx.clearRect(0, 0, width, height);
11453
11783
  const progress = Math.ceil((index2 + 1) / this.pages.length * 100);
@@ -19771,16 +20101,13 @@ const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
19771
20101
  const _WindowManager = class extends InvisiblePlugin {
19772
20102
  constructor(context) {
19773
20103
  super(context);
19774
- this.version = "1.0.13-test.8";
19775
- 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" } };
20104
+ this.version = "1.0.13";
20105
+ 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.54" }, "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.54" } };
19776
20106
  this.emitter = callbacks$1;
19777
20107
  this.viewMode = ViewMode.Broadcaster;
19778
20108
  this.isReplay = isPlayer(this.displayer);
19779
20109
  this._cursorUIDs = [];
19780
20110
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
19781
- this.visibleStateListener = () => {
19782
- console.log("[window-manager] visibleStateListener isVisible:" + !document.hidden);
19783
- };
19784
20111
  this.onMainViewScenePathChangeHandler = (scenePath) => {
19785
20112
  const mainViewElement = this.mainView.divElement;
19786
20113
  if (mainViewElement) {
@@ -19789,17 +20116,17 @@ const _WindowManager = class extends InvisiblePlugin {
19789
20116
  const backgroundImageRect = backgroundImage == null ? void 0 : backgroundImage.getBoundingClientRect();
19790
20117
  const backgroundImageCSS = window.getComputedStyle(backgroundImage);
19791
20118
  const backgroundImageVisible = (backgroundImageRect == null ? void 0 : backgroundImageRect.width) > 0 && (backgroundImageRect == null ? void 0 : backgroundImageRect.height) > 0 && backgroundImageCSS.display !== "none";
19792
- console.log("[window-manager] backgroundImageVisible" + backgroundImageVisible);
20119
+ const camera = this.mainView.camera;
20120
+ console.log("[window-manager] backgroundImageVisible:" + backgroundImageVisible + " camera:" + JSON.stringify(camera));
19793
20121
  return;
19794
20122
  }
19795
- console.log("[window-manager] onMainViewScenePathChange" + scenePath + "backgroundImageVisible is not found");
20123
+ console.log("[window-manager] onMainViewScenePathChange scenePath:" + scenePath + " backgroundImageVisible is not found");
20124
+ return;
19796
20125
  }
19797
- console.log("[window-manager] onMainViewScenePathChange" + scenePath + "mainViewElement is not found");
20126
+ console.log("[window-manager] onMainViewScenePathChange scenePath:" + scenePath + " mainViewElement is not found");
19798
20127
  };
19799
20128
  _WindowManager.displayer = context.displayer;
19800
- 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" } };
19801
- this.visibleStateListener();
19802
- document.addEventListener("visibilitychange", this.visibleStateListener);
20129
+ 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.54" }, "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.54" } };
19803
20130
  this.emitter.on("mainViewScenePathChange", this.onMainViewScenePathChangeHandler);
19804
20131
  }
19805
20132
  get Logger() {
@@ -19831,6 +20158,7 @@ const _WindowManager = class extends InvisiblePlugin {
19831
20158
  manager = await this.initManager(room);
19832
20159
  if (manager) {
19833
20160
  manager._roomLogger = room.logger;
20161
+ manager.attributesDeboundceLog = new ArgusLog(manager._roomLogger, "attributes", 300);
19834
20162
  if (_WindowManager.registered.size > 0) {
19835
20163
  manager._roomLogger.info(
19836
20164
  `[WindowManager] registered apps: ${JSON.stringify(
@@ -20445,7 +20773,6 @@ const _WindowManager = class extends InvisiblePlugin {
20445
20773
  }, 500);
20446
20774
  }
20447
20775
  moveCameraToContain(rectangle) {
20448
- console.log("[window-manager] moveCameraToContain" + JSON.stringify(rectangle));
20449
20776
  this.mainView.moveCameraToContain(rectangle);
20450
20777
  setTimeout(() => {
20451
20778
  var _a;
@@ -20465,22 +20792,23 @@ const _WindowManager = class extends InvisiblePlugin {
20465
20792
  this._destroy();
20466
20793
  }
20467
20794
  _destroy() {
20468
- var _a, _b, _c, _d, _e, _f;
20469
- (_a = this.containerResizeObserver) == null ? void 0 : _a.disconnect();
20470
- (_b = this.appManager) == null ? void 0 : _b.destroy();
20471
- (_c = this.cursorManager) == null ? void 0 : _c.destroy();
20472
- (_d = this.extendPluginManager) == null ? void 0 : _d.destroy();
20795
+ var _a, _b, _c, _d, _e, _f, _g;
20796
+ (_a = this.attributesDeboundceLog) == null ? void 0 : _a.destroy();
20797
+ this.attributesDeboundceLog = void 0;
20798
+ (_b = this.containerResizeObserver) == null ? void 0 : _b.disconnect();
20799
+ (_c = this.appManager) == null ? void 0 : _c.destroy();
20800
+ (_d = this.cursorManager) == null ? void 0 : _d.destroy();
20801
+ (_e = this.extendPluginManager) == null ? void 0 : _e.destroy();
20473
20802
  _WindowManager.container = void 0;
20474
20803
  _WindowManager.wrapper = void 0;
20475
20804
  _WindowManager.sizer = void 0;
20476
20805
  _WindowManager.isCreated = false;
20477
20806
  if (_WindowManager.playground) {
20478
- (_e = _WindowManager.playground.parentNode) == null ? void 0 : _e.removeChild(_WindowManager.playground);
20807
+ (_f = _WindowManager.playground.parentNode) == null ? void 0 : _f.removeChild(_WindowManager.playground);
20479
20808
  }
20480
20809
  _WindowManager.params = void 0;
20481
- document.removeEventListener("visibilitychange", this.visibleStateListener);
20482
20810
  this.emitter.off("mainViewScenePathChange", this.onMainViewScenePathChangeHandler);
20483
- (_f = this._iframeBridge) == null ? void 0 : _f.destroy();
20811
+ (_g = this._iframeBridge) == null ? void 0 : _g.destroy();
20484
20812
  this._iframeBridge = void 0;
20485
20813
  log("Destroyed");
20486
20814
  }
@@ -20504,11 +20832,17 @@ const _WindowManager = class extends InvisiblePlugin {
20504
20832
  safeSetAttributes(attributes) {
20505
20833
  if (this.canOperate) {
20506
20834
  this.setAttributes(attributes);
20835
+ if (this.attributesDeboundceLog) {
20836
+ this.attributesDeboundceLog.logDebouncedShallowMerge("safeSetAttributes", attributes);
20837
+ }
20507
20838
  }
20508
20839
  }
20509
20840
  safeUpdateAttributes(keys, value) {
20510
20841
  if (this.canOperate) {
20511
20842
  this.updateAttributes(keys, value);
20843
+ if (this.attributesDeboundceLog) {
20844
+ this.attributesDeboundceLog.logDebouncedUpdateAttributes(keys, value);
20845
+ }
20512
20846
  }
20513
20847
  }
20514
20848
  setPrefersColorScheme(scheme) {
@@ -20516,9 +20850,10 @@ const _WindowManager = class extends InvisiblePlugin {
20516
20850
  (_b = (_a = this.appManager) == null ? void 0 : _a.boxManager) == null ? void 0 : _b.setPrefersColorScheme(scheme);
20517
20851
  }
20518
20852
  cleanCurrentScene() {
20519
- var _a;
20853
+ var _a, _b;
20520
20854
  log("clean current scene");
20521
20855
  (_a = this.focusedView) == null ? void 0 : _a.cleanCurrentScene();
20856
+ this.Logger && this.Logger.info(`[WindowManager]: cleanCurrentScene ${(_b = this.focusedView) == null ? void 0 : _b.focusScenePath}`);
20522
20857
  }
20523
20858
  redo() {
20524
20859
  var _a;
@@ -20529,8 +20864,9 @@ const _WindowManager = class extends InvisiblePlugin {
20529
20864
  return ((_a = this.focusedView) == null ? void 0 : _a.undo()) || 0;
20530
20865
  }
20531
20866
  delete() {
20532
- var _a;
20867
+ var _a, _b;
20533
20868
  (_a = this.focusedView) == null ? void 0 : _a.delete();
20869
+ this.Logger && this.Logger.info(`[WindowManager]: delete ${(_b = this.focusedView) == null ? void 0 : _b.focusScenePath}`);
20534
20870
  }
20535
20871
  copy() {
20536
20872
  var _a;