@netless/window-manager 1.0.12 → 1.0.13-bate.1

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
@@ -5690,11 +5690,274 @@ class BoxManager {
5690
5690
  }
5691
5691
  }
5692
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
+ }
5693
5775
  const log = (...args) => {
5694
5776
  if (WindowManager.debug) {
5695
5777
  console.log(`[WindowManager]:`, ...args);
5696
5778
  }
5697
5779
  };
5780
+ class LocalConsole {
5781
+ constructor(name, debounceTime) {
5782
+ this.name = name;
5783
+ this.debounceTime = debounceTime;
5784
+ this.pendingArgs = null;
5785
+ this.flushTimer = null;
5786
+ }
5787
+ flush() {
5788
+ this.flushTimer = null;
5789
+ const args = this.pendingArgs;
5790
+ this.pendingArgs = null;
5791
+ if (args === null) {
5792
+ return;
5793
+ }
5794
+ console.log(`[window-manager][${this.name}]: ${args.join(", ")}`);
5795
+ }
5796
+ log(...args) {
5797
+ const ms = this.debounceTime;
5798
+ if (ms != null && ms > 0) {
5799
+ this.pendingArgs = args;
5800
+ if (this.flushTimer != null) {
5801
+ clearTimeout(this.flushTimer);
5802
+ }
5803
+ this.flushTimer = setTimeout(() => this.flush(), ms);
5804
+ return;
5805
+ }
5806
+ console.log(`[window-manager][${this.name}]: ${args.join(", ")}`);
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
+ }
5960
+ }
5698
5961
  const setupWrapper = (root) => {
5699
5962
  const playground = document.createElement("div");
5700
5963
  playground.className = "netless-window-manager-playground";
@@ -7372,6 +7635,9 @@ const _AppProxy = class {
7372
7635
  get appAttributes() {
7373
7636
  return this.store.getAppAttributes(this.id);
7374
7637
  }
7638
+ get Logger() {
7639
+ return this.manager.windowManger.Logger;
7640
+ }
7375
7641
  getFullScenePath() {
7376
7642
  if (this.scenePath) {
7377
7643
  return get(this.appAttributes, [Fields.FullPath]) || this.getFullScenePathFromScenes();
@@ -7392,6 +7658,7 @@ const _AppProxy = class {
7392
7658
  var _a;
7393
7659
  const params = this.params;
7394
7660
  if (!params.kind) {
7661
+ this.Logger && this.Logger.error(`[WindowManager]: kind require`);
7395
7662
  throw new Error("[WindowManager]: kind require");
7396
7663
  }
7397
7664
  const appImpl = await ((_a = appRegister.appClasses.get(params.kind)) == null ? void 0 : _a());
@@ -7409,6 +7676,7 @@ const _AppProxy = class {
7409
7676
  params.isDragContent
7410
7677
  );
7411
7678
  } else {
7679
+ this.Logger && this.Logger.error(`[WindowManager]: app load failed ${params.kind} ${params.src}`);
7412
7680
  throw new Error(`[WindowManager]: app load failed ${params.kind} ${params.src}`);
7413
7681
  }
7414
7682
  internalEmitter.emit("updateManagerRect");
@@ -7446,7 +7714,7 @@ const _AppProxy = class {
7446
7714
  currentMainViewScenePath = this.manager.mainView.scenePath;
7447
7715
  }
7448
7716
  setTimeout(async () => {
7449
- console.log("setup app", app);
7717
+ this.Logger && this.Logger.info(`[WindowManager]: setup app ${this.kind}, appId: ${appId}`);
7450
7718
  const result = await app.setup(context);
7451
7719
  this.appResult = result;
7452
7720
  appRegister.notifyApp(this.kind, "created", { appId, result });
@@ -7481,7 +7749,7 @@ const _AppProxy = class {
7481
7749
  this.boxManager.focusBox({ appId }, false);
7482
7750
  }
7483
7751
  } catch (error) {
7484
- console.error(error);
7752
+ this.Logger && this.Logger.error(`[WindowManager]: app setup error: ${error.message}`);
7485
7753
  throw new Error(`[WindowManager]: app setup error: ${error.message}`);
7486
7754
  }
7487
7755
  }
@@ -7660,6 +7928,7 @@ const _AppProxy = class {
7660
7928
  await appRegister.notifyApp(this.kind, "destroy", { appId: this.id });
7661
7929
  await this.appEmitter.emit("destroy", { error });
7662
7930
  } catch (error2) {
7931
+ this.Logger && this.Logger.error(`[WindowManager]: notifyApp error: ${error2.message}`);
7663
7932
  console.error("[WindowManager]: notifyApp error", error2.message, error2.stack);
7664
7933
  }
7665
7934
  this.appEmitter.clearListeners();
@@ -7681,6 +7950,7 @@ const _AppProxy = class {
7681
7950
  this.manager.refresher.remove(this.stateKey);
7682
7951
  this.manager.refresher.remove(`${this.id}-fullPath`);
7683
7952
  this._prevFullPath = void 0;
7953
+ this.Logger && this.Logger.info(`[WindowManager]: destroy app ${this.kind} appId: ${this.id}`);
7684
7954
  }
7685
7955
  close() {
7686
7956
  return this.destroy(true, true, false);
@@ -7744,9 +8014,15 @@ class MainViewProxy {
7744
8014
  this.polling = false;
7745
8015
  this.started = false;
7746
8016
  this.mainViewIsAddListener = false;
8017
+ this.isForcingMainViewDivElement = false;
8018
+ this.wrapperRectWorkaroundFrame = 0;
7747
8019
  this.store = this.manager.store;
7748
8020
  this.viewMode = this.manager.windowManger.viewMode;
7749
8021
  this.sideEffectManager = new o$2();
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);
7750
8026
  this.syncCamera = () => {
7751
8027
  if (!this.polling || this.viewMode !== ViewMode.Broadcaster)
7752
8028
  return;
@@ -7766,6 +8042,32 @@ class MainViewProxy {
7766
8042
  });
7767
8043
  });
7768
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
+ };
7769
8071
  this.addCameraReaction = () => {
7770
8072
  this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
7771
8073
  };
@@ -7776,6 +8078,7 @@ class MainViewProxy {
7776
8078
  if (camera && camera.id !== this.manager.uid) {
7777
8079
  this.moveCameraToContian(this.mainViewSize);
7778
8080
  this.moveCamera(camera);
8081
+ this.cameraReactionLocalConsole.log(`camera: ${JSON.stringify(camera)}, current size: ${JSON.stringify(this.mainViewSize)}`);
7779
8082
  }
7780
8083
  },
7781
8084
  { fireImmediately: true }
@@ -7785,11 +8088,13 @@ class MainViewProxy {
7785
8088
  if (size2) {
7786
8089
  this.moveCameraToContian(size2);
7787
8090
  this.moveCamera(this.mainViewCamera);
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));
7788
8092
  }
7789
8093
  this.ensureMainViewSize();
7790
8094
  }, 30);
7791
8095
  this.onUpdateContainerSizeRatio = () => {
7792
8096
  const size2 = this.store.getMainViewSize();
8097
+ console.log("[window-manager] onUpdateContainerSizeRatio " + JSON.stringify(size2));
7793
8098
  this.sizeChangeHandler(size2);
7794
8099
  };
7795
8100
  this.onCameraUpdatedByDevice = (camera) => {
@@ -7807,7 +8112,7 @@ class MainViewProxy {
7807
8112
  this.store.setMainViewSize({ ...size2, id: this.manager.uid });
7808
8113
  }, 50);
7809
8114
  this._syncMainViewTimer = 0;
7810
- this.onCameraOrSizeUpdated = () => {
8115
+ this.handleCameraOrSizeUpdated = () => {
7811
8116
  callbacks$1.emit("cameraStateChange", this.cameraState);
7812
8117
  if (this.manager.room && this.manager.room.syncMainView) {
7813
8118
  clearTimeout(this._syncMainViewTimer);
@@ -7815,6 +8120,14 @@ class MainViewProxy {
7815
8120
  }
7816
8121
  this.ensureMainViewSize();
7817
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
+ };
7818
8131
  this.syncMainView = (room) => {
7819
8132
  if (room.isWritable) {
7820
8133
  room.syncMainView(this.mainView);
@@ -7832,6 +8145,19 @@ class MainViewProxy {
7832
8145
  this.startListenWritableChange();
7833
8146
  });
7834
8147
  const playgroundSizeChangeListener = () => {
8148
+ var _a, _b, _c, _d, _e, _f, _g, _h;
8149
+ this.playgroundSizeChangeListenerLocalConsole.log(
8150
+ JSON.stringify(this.mainView.camera),
8151
+ JSON.stringify(this.mainView.size),
8152
+ JSON.stringify(this.mainViewSize),
8153
+ JSON.stringify(this.mainViewCamera),
8154
+ window.outerHeight,
8155
+ window.outerWidth,
8156
+ (_b = (_a = window.visualViewport) == null ? void 0 : _a.width) != null ? _b : "null",
8157
+ (_d = (_c = window.visualViewport) == null ? void 0 : _c.height) != null ? _d : "null",
8158
+ (_f = (_e = window.visualViewport) == null ? void 0 : _e.offsetLeft) != null ? _f : "null",
8159
+ (_h = (_g = window.visualViewport) == null ? void 0 : _g.offsetTop) != null ? _h : "null"
8160
+ );
7835
8161
  this.sizeChangeHandler(this.mainViewSize);
7836
8162
  };
7837
8163
  this.sideEffectManager.add(() => {
@@ -7840,6 +8166,9 @@ class MainViewProxy {
7840
8166
  this.sideEffectManager.add(() => {
7841
8167
  return internalEmitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio);
7842
8168
  });
8169
+ this.sideEffectManager.add(() => {
8170
+ return internalEmitter.on("wrapperRectChange", this.onWrapperRectChange);
8171
+ });
7843
8172
  this.sideEffectManager.add(() => {
7844
8173
  return internalEmitter.on("startReconnect", () => {
7845
8174
  if (!this.didRelease) {
@@ -7870,7 +8199,52 @@ class MainViewProxy {
7870
8199
  this.moveCameraToContian(this.mainViewSize);
7871
8200
  this.moveCamera(this.mainViewCamera);
7872
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
+ }
7873
8246
  start() {
8247
+ console.log("[window-manager] start attributes size:" + JSON.stringify(this.mainViewSize));
7874
8248
  this.sizeChangeHandler(this.mainViewSize);
7875
8249
  if (this.started)
7876
8250
  return;
@@ -7879,6 +8253,10 @@ class MainViewProxy {
7879
8253
  if (this.manager.room)
7880
8254
  this.syncMainView(this.manager.room);
7881
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));
7882
8260
  }
7883
8261
  setCameraAndSize() {
7884
8262
  const camera = { ...this.mainView.camera, id: this.manager.uid };
@@ -7952,13 +8330,13 @@ class MainViewProxy {
7952
8330
  }
7953
8331
  addCameraListener() {
7954
8332
  this.view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
7955
- this.view.callbacks.on("onCameraUpdated", this.onCameraOrSizeUpdated);
7956
- this.view.callbacks.on("onSizeUpdated", this.onCameraOrSizeUpdated);
8333
+ this.view.callbacks.on("onCameraUpdated", this.onCameraUpdated);
8334
+ this.view.callbacks.on("onSizeUpdated", this.onSizeUpdated);
7957
8335
  }
7958
8336
  removeCameraListener() {
7959
8337
  this.view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
7960
- this.view.callbacks.off("onCameraUpdated", this.onCameraOrSizeUpdated);
7961
- this.view.callbacks.off("onSizeUpdated", this.onCameraOrSizeUpdated);
8338
+ this.view.callbacks.off("onCameraUpdated", this.onCameraUpdated);
8339
+ this.view.callbacks.off("onSizeUpdated", this.onSizeUpdated);
7962
8340
  }
7963
8341
  ensureMainViewSize() {
7964
8342
  if ((!this.mainViewSize || this.mainViewSize.width === 0 || this.mainViewSize.height === 0) && this.mainView.size.width > 0 && this.mainView.size.height > 0) {
@@ -7998,6 +8376,15 @@ class MainViewProxy {
7998
8376
  this.started = false;
7999
8377
  }
8000
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();
8001
8388
  this.removeMainViewListener();
8002
8389
  this.stop();
8003
8390
  this.sideEffectManager.flushAll();
@@ -8087,6 +8474,7 @@ class AppManager {
8087
8474
  var _a, _b;
8088
8475
  const { scenePath } = params;
8089
8476
  if (scenePath === ROOT_DIR) {
8477
+ console.log("[window-manager] onRemoveScenes ROOT_DIR");
8090
8478
  await this.onRootDirRemoved();
8091
8479
  this.dispatchInternalEvent(Events.RootDirRemoved);
8092
8480
  return;
@@ -8099,6 +8487,7 @@ class AppManager {
8099
8487
  sceneName = (_b = this.callbacksNode) == null ? void 0 : _b.scenes[nextIndex];
8100
8488
  }
8101
8489
  if (sceneName) {
8490
+ console.log(`[window-manager] onRemoveScenes setMainViewScenePath ${ROOT_DIR}${sceneName}`);
8102
8491
  this.setMainViewScenePath(`${ROOT_DIR}${sceneName}`);
8103
8492
  }
8104
8493
  await this.setMainViewSceneIndex(nextIndex);
@@ -8491,6 +8880,9 @@ class AppManager {
8491
8880
  var _a;
8492
8881
  return ((_a = this.room) == null ? void 0 : _a.uid) || "";
8493
8882
  }
8883
+ get Logger() {
8884
+ return this.windowManger.Logger;
8885
+ }
8494
8886
  getMainViewSceneDir() {
8495
8887
  const scenePath = this.store.getMainViewScenePath();
8496
8888
  if (scenePath) {
@@ -8607,6 +8999,9 @@ class AppManager {
8607
8999
  try {
8608
9000
  const appAttributes = this.attributes[id2];
8609
9001
  if (!appAttributes) {
9002
+ this.Logger && this.Logger.error(
9003
+ `[WindowManager]: appAttributes is undefined, appId: ${id2}`
9004
+ );
8610
9005
  throw new Error("appAttributes is undefined");
8611
9006
  }
8612
9007
  this.appCreateQueue.push(async () => {
@@ -8662,6 +9057,28 @@ class AppManager {
8662
9057
  }
8663
9058
  internalEmitter.emit("mainViewMounted");
8664
9059
  callbacks$1.emit("onMainViewMounted", mainView);
9060
+ const hasRoot = this.hasRoot(mainView.divElement);
9061
+ const rect = this.getRectByDivElement(mainView.divElement);
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);
9068
+ }
9069
+ hasRoot(divElement) {
9070
+ let current = divElement;
9071
+ while (current) {
9072
+ if (current.parentElement === document.body) {
9073
+ return true;
9074
+ }
9075
+ current = current.parentElement;
9076
+ }
9077
+ return false;
9078
+ }
9079
+ getRectByDivElement(divElement) {
9080
+ const rect = divElement.getBoundingClientRect();
9081
+ return rect;
8665
9082
  }
8666
9083
  setMainViewFocusPath(scenePath) {
8667
9084
  var _a;
@@ -8678,7 +9095,11 @@ class AppManager {
8678
9095
  }
8679
9096
  }
8680
9097
  async addApp(params, isDynamicPPT) {
9098
+ var _a;
8681
9099
  log("addApp", params);
9100
+ (_a = this.windowManger.Logger) == null ? void 0 : _a.info(
9101
+ `[WindowManager]: addApp ${params.kind}, isDynamicPPT: ${isDynamicPPT}`
9102
+ );
8682
9103
  const { appId, needFocus } = await this.beforeAddApp(params, isDynamicPPT);
8683
9104
  const appProxy = await this.baseInsertApp(params, appId, true, needFocus);
8684
9105
  this.afterAddApp(appProxy);
@@ -8719,8 +9140,11 @@ class AppManager {
8719
9140
  }
8720
9141
  }
8721
9142
  async baseInsertApp(params, appId, isAddApp, focus) {
9143
+ var _a;
8722
9144
  if (this.appProxies.has(appId)) {
8723
- console.warn("[WindowManager]: app duplicate exists and cannot be created again");
9145
+ (_a = this.windowManger.Logger) == null ? void 0 : _a.warn(
9146
+ `[WindowManager]: app duplicate exists and cannot be created again, appId: ${appId}`
9147
+ );
8724
9148
  return;
8725
9149
  }
8726
9150
  const AppProxyClass = getExtendClass$1(AppProxy, WindowManager.extendClass);
@@ -8731,6 +9155,7 @@ class AppManager {
8731
9155
  return appProxy;
8732
9156
  } else {
8733
9157
  this.appStatus.delete(appId);
9158
+ this.Logger && this.Logger.error(`[WindowManager]: initialize AppProxy failed, appId: ${appId}`);
8734
9159
  throw new Error("[WindowManger]: initialize AppProxy failed");
8735
9160
  }
8736
9161
  }
@@ -8745,9 +9170,11 @@ class AppManager {
8745
9170
  const scenePathType = this.displayer.scenePathType(scenePath);
8746
9171
  const sceneDir = parseSceneDir(scenePath);
8747
9172
  if (sceneDir !== ROOT_DIR) {
9173
+ this.Logger && this.Logger.error(`[WindowManager]: main view scenePath must in root dir "/"`);
8748
9174
  throw new Error(`[WindowManager]: main view scenePath must in root dir "/"`);
8749
9175
  }
8750
9176
  if (scenePathType === ScenePathType.None) {
9177
+ this.Logger && this.Logger.error(`[WindowManager]: ${scenePath} not valid scene`);
8751
9178
  throw new Error(`[WindowManager]: ${scenePath} not valid scene`);
8752
9179
  } else if (scenePathType === ScenePathType.Page) {
8753
9180
  await this._setMainViewScenePath(scenePath);
@@ -8783,6 +9210,7 @@ class AppManager {
8783
9210
  this.dispatchSetMainViewScenePath(scenePath);
8784
9211
  }
8785
9212
  } else {
9213
+ this.Logger && this.Logger.error(`[WindowManager]: ${index2} not valid index`);
8786
9214
  throw new Error(`[WindowManager]: ${index2} not valid index`);
8787
9215
  }
8788
9216
  }
@@ -8863,6 +9291,7 @@ const ResizeObserver$2 = window.ResizeObserver || ResizeObserver$3;
8863
9291
  class ContainerResizeObserver {
8864
9292
  constructor(emitter) {
8865
9293
  this.emitter = emitter;
9294
+ this.updateSizerLocalConsole = new LocalConsole("updateSizer", 100);
8866
9295
  }
8867
9296
  static create(container, sizer, wrapper, emitter) {
8868
9297
  const containerResizeObserver = new ContainerResizeObserver(emitter);
@@ -8870,23 +9299,23 @@ class ContainerResizeObserver {
8870
9299
  return containerResizeObserver;
8871
9300
  }
8872
9301
  observePlaygroundSize(container, sizer, wrapper) {
8873
- this.updateSizer(container.getBoundingClientRect(), sizer, wrapper);
9302
+ this.updateSizer(container.getBoundingClientRect(), sizer, wrapper, "observePlaygroundSize");
8874
9303
  this.containerResizeObserver = new ResizeObserver$2((entries) => {
8875
9304
  var _a;
8876
9305
  const containerRect = (_a = entries[0]) == null ? void 0 : _a.contentRect;
8877
9306
  if (containerRect) {
8878
- this.updateSizer(containerRect, sizer, wrapper);
9307
+ this.updateSizer(containerRect, sizer, wrapper, "containerResizeObserver");
8879
9308
  this.emitter.emit("playgroundSizeChange", containerRect);
8880
9309
  }
8881
9310
  });
8882
9311
  this.disposer = this.emitter.on("containerSizeRatioUpdate", () => {
8883
9312
  const containerRect = container.getBoundingClientRect();
8884
- this.updateSizer(containerRect, sizer, wrapper);
9313
+ this.updateSizer(containerRect, sizer, wrapper, "containerSizeRatioUpdate");
8885
9314
  this.emitter.emit("playgroundSizeChange", containerRect);
8886
9315
  });
8887
9316
  this.containerResizeObserver.observe(container);
8888
9317
  }
8889
- updateSizer({ width, height }, sizer, wrapper) {
9318
+ updateSizer({ width, height }, sizer, wrapper, origin) {
8890
9319
  if (width && height) {
8891
9320
  if (height / width > WindowManager.containerSizeRatio) {
8892
9321
  height = width * WindowManager.containerSizeRatio;
@@ -8897,15 +9326,21 @@ class ContainerResizeObserver {
8897
9326
  }
8898
9327
  wrapper.style.width = `${width}px`;
8899
9328
  wrapper.style.height = `${height}px`;
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
+ });
8900
9336
  }
8901
9337
  }
8902
9338
  disconnect() {
8903
- var _a;
9339
+ var _a, _b;
9340
+ this.updateSizerLocalConsole.destroy();
8904
9341
  (_a = this.containerResizeObserver) == null ? void 0 : _a.disconnect();
8905
- if (isFunction(this.disposer)) {
8906
- this.disposer();
8907
- this.disposer = void 0;
8908
- }
9342
+ (_b = this.disposer) == null ? void 0 : _b.call(this);
9343
+ this.disposer = void 0;
8909
9344
  }
8910
9345
  }
8911
9346
  class PageStateImpl {
@@ -9053,6 +9488,29 @@ const replaceRoomFunction = (room, manager) => {
9053
9488
  return manager.canRedoSteps;
9054
9489
  }
9055
9490
  });
9491
+ const _scalePptToFit = room.scalePptToFit;
9492
+ room.scalePptToFit = (...args) => {
9493
+ var _a;
9494
+ _scalePptToFit.call(room, ...args);
9495
+ if ((_a = manager.appManager) == null ? void 0 : _a.mainViewProxy) {
9496
+ manager.appManager.mainViewProxy.setCameraAndSize();
9497
+ }
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
+ };
9056
9514
  room.moveCamera = (camera) => manager.moveCamera(camera);
9057
9515
  room.moveCameraToContain = (...args) => manager.moveCameraToContain(...args);
9058
9516
  room.convertToPointInWorld = (...args) => manager.mainView.convertToPointInWorld(...args);
@@ -11299,7 +11757,7 @@ class StaticDocsViewer {
11299
11757
  img.src = pdfPageSrc;
11300
11758
  await new Promise((resolve) => img.onload = resolve);
11301
11759
  whiteCtx.drawImage(img, 0, 0);
11302
- const pdfPageBase64 = whiteSnapshotCanvas.toDataURL("image/jpeg", 0.6);
11760
+ const pdfPageBase64 = whiteSnapshotCanvas.toDataURL("image/png");
11303
11761
  whiteCtx.clearRect(0, 0, width, height);
11304
11762
  const camera = {
11305
11763
  centerX: width / 2,
@@ -11319,7 +11777,7 @@ class StaticDocsViewer {
11319
11777
  this.whiteboardView.screenshotToCanvas(whiteCtx, scenePath, width, height, camera);
11320
11778
  }
11321
11779
  const snapshot = whiteSnapshotCanvas.toDataURL("image/png");
11322
- pdf.addImage(pdfPageBase64, "JPEG", 0, 0, width, height, "", "FAST");
11780
+ pdf.addImage(pdfPageBase64, "PNG", 0, 0, width, height, "", "FAST");
11323
11781
  pdf.addImage(snapshot, "PNG", 0, 0, width, height, "", "FAST");
11324
11782
  whiteCtx.clearRect(0, 0, width, height);
11325
11783
  const progress = Math.ceil((index2 + 1) / this.pages.length * 100);
@@ -19643,20 +20101,42 @@ const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
19643
20101
  const _WindowManager = class extends InvisiblePlugin {
19644
20102
  constructor(context) {
19645
20103
  super(context);
19646
- this.version = "1.0.12";
19647
- 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.52" }, "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.52" } };
20104
+ this.version = "1.0.13-bate.1";
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" } };
19648
20106
  this.emitter = callbacks$1;
19649
20107
  this.viewMode = ViewMode.Broadcaster;
19650
20108
  this.isReplay = isPlayer(this.displayer);
19651
20109
  this._cursorUIDs = [];
19652
20110
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
20111
+ this.onMainViewScenePathChangeHandler = (scenePath) => {
20112
+ const mainViewElement = this.mainView.divElement;
20113
+ if (mainViewElement) {
20114
+ const backgroundImage = mainViewElement.querySelector(".background img");
20115
+ if (backgroundImage) {
20116
+ const backgroundImageRect = backgroundImage == null ? void 0 : backgroundImage.getBoundingClientRect();
20117
+ const backgroundImageCSS = window.getComputedStyle(backgroundImage);
20118
+ const backgroundImageVisible = (backgroundImageRect == null ? void 0 : backgroundImageRect.width) > 0 && (backgroundImageRect == null ? void 0 : backgroundImageRect.height) > 0 && backgroundImageCSS.display !== "none";
20119
+ const camera = this.mainView.camera;
20120
+ console.log("[window-manager] backgroundImageVisible:" + backgroundImageVisible + " camera:" + JSON.stringify(camera));
20121
+ return;
20122
+ }
20123
+ console.log("[window-manager] onMainViewScenePathChange scenePath:" + scenePath + " backgroundImageVisible is not found");
20124
+ return;
20125
+ }
20126
+ console.log("[window-manager] onMainViewScenePathChange scenePath:" + scenePath + " mainViewElement is not found");
20127
+ };
19653
20128
  _WindowManager.displayer = context.displayer;
19654
- 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.52" }, "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.52" } };
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" } };
20130
+ this.emitter.on("mainViewScenePathChange", this.onMainViewScenePathChangeHandler);
20131
+ }
20132
+ get Logger() {
20133
+ return this._roomLogger;
19655
20134
  }
19656
20135
  static onCreate(manager) {
19657
20136
  _WindowManager._resolve(manager);
19658
20137
  }
19659
20138
  static async mount(params, extendClass) {
20139
+ var _a;
19660
20140
  const room = params.room;
19661
20141
  _WindowManager.container = params.container;
19662
20142
  _WindowManager.supportAppliancePlugin = params.supportAppliancePlugin;
@@ -19676,6 +20156,17 @@ const _WindowManager = class extends InvisiblePlugin {
19676
20156
  room.disableSerialization = false;
19677
20157
  }
19678
20158
  manager = await this.initManager(room);
20159
+ if (manager) {
20160
+ manager._roomLogger = room.logger;
20161
+ manager.attributesDeboundceLog = new ArgusLog(manager._roomLogger, "attributes", 300);
20162
+ if (_WindowManager.registered.size > 0) {
20163
+ manager._roomLogger.info(
20164
+ `[WindowManager] registered apps: ${JSON.stringify(
20165
+ Array.from(_WindowManager.registered.keys())
20166
+ )}`
20167
+ );
20168
+ }
20169
+ }
19679
20170
  }
19680
20171
  if (_WindowManager.isCreated) {
19681
20172
  throw new Error("[WindowManager]: Already created cannot be created again");
@@ -19684,7 +20175,13 @@ const _WindowManager = class extends InvisiblePlugin {
19684
20175
  if (this.debug) {
19685
20176
  v({ verbose: true });
19686
20177
  }
19687
- log("Already insert room", manager);
20178
+ if (manager == null ? void 0 : manager._roomLogger) {
20179
+ manager._roomLogger.info(
20180
+ `[WindowManager] Already insert room version: ${manager.version}`
20181
+ );
20182
+ } else {
20183
+ log("Already insert room", manager);
20184
+ }
19688
20185
  if (isRoom(this.displayer)) {
19689
20186
  if (!manager) {
19690
20187
  throw new Error("[WindowManager]: init InvisiblePlugin failed");
@@ -19733,12 +20230,21 @@ const _WindowManager = class extends InvisiblePlugin {
19733
20230
  replaceRoomFunction(room, manager);
19734
20231
  internalEmitter.emit("onCreated");
19735
20232
  _WindowManager.isCreated = true;
20233
+ if (manager._roomLogger && manager.attributes.registered && Object.keys(manager.attributes.registered).length > 0) {
20234
+ manager._roomLogger.info(
20235
+ `[WindowManager] attributes registered apps: ${JSON.stringify(
20236
+ Array.from(Object.keys(manager.attributes.registered))
20237
+ )}`
20238
+ );
20239
+ }
19736
20240
  try {
19737
20241
  await initDb();
19738
20242
  } catch (error) {
20243
+ (_a = manager._roomLogger) == null ? void 0 : _a.warn(`[WindowManager] indexedDB open failed: ${error.message}`);
19739
20244
  console.warn("[WindowManager]: indexedDB open failed");
19740
20245
  console.log(error);
19741
20246
  }
20247
+ manager.emitter.on("mainViewScenePathChange", manager.onMainViewScenePathChangeHandler);
19742
20248
  return manager;
19743
20249
  }
19744
20250
  static initManager(room) {
@@ -20286,20 +20792,23 @@ const _WindowManager = class extends InvisiblePlugin {
20286
20792
  this._destroy();
20287
20793
  }
20288
20794
  _destroy() {
20289
- var _a, _b, _c, _d, _e, _f;
20290
- (_a = this.containerResizeObserver) == null ? void 0 : _a.disconnect();
20291
- (_b = this.appManager) == null ? void 0 : _b.destroy();
20292
- (_c = this.cursorManager) == null ? void 0 : _c.destroy();
20293
- (_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();
20294
20802
  _WindowManager.container = void 0;
20295
20803
  _WindowManager.wrapper = void 0;
20296
20804
  _WindowManager.sizer = void 0;
20297
20805
  _WindowManager.isCreated = false;
20298
20806
  if (_WindowManager.playground) {
20299
- (_e = _WindowManager.playground.parentNode) == null ? void 0 : _e.removeChild(_WindowManager.playground);
20807
+ (_f = _WindowManager.playground.parentNode) == null ? void 0 : _f.removeChild(_WindowManager.playground);
20300
20808
  }
20301
20809
  _WindowManager.params = void 0;
20302
- (_f = this._iframeBridge) == null ? void 0 : _f.destroy();
20810
+ this.emitter.off("mainViewScenePathChange", this.onMainViewScenePathChangeHandler);
20811
+ (_g = this._iframeBridge) == null ? void 0 : _g.destroy();
20303
20812
  this._iframeBridge = void 0;
20304
20813
  log("Destroyed");
20305
20814
  }
@@ -20323,11 +20832,17 @@ const _WindowManager = class extends InvisiblePlugin {
20323
20832
  safeSetAttributes(attributes) {
20324
20833
  if (this.canOperate) {
20325
20834
  this.setAttributes(attributes);
20835
+ if (this.attributesDeboundceLog) {
20836
+ this.attributesDeboundceLog.logDebouncedShallowMerge("safeSetAttributes", attributes);
20837
+ }
20326
20838
  }
20327
20839
  }
20328
20840
  safeUpdateAttributes(keys, value) {
20329
20841
  if (this.canOperate) {
20330
20842
  this.updateAttributes(keys, value);
20843
+ if (this.attributesDeboundceLog) {
20844
+ this.attributesDeboundceLog.logDebouncedUpdateAttributes(keys, value);
20845
+ }
20331
20846
  }
20332
20847
  }
20333
20848
  setPrefersColorScheme(scheme) {
@@ -20335,9 +20850,10 @@ const _WindowManager = class extends InvisiblePlugin {
20335
20850
  (_b = (_a = this.appManager) == null ? void 0 : _a.boxManager) == null ? void 0 : _b.setPrefersColorScheme(scheme);
20336
20851
  }
20337
20852
  cleanCurrentScene() {
20338
- var _a;
20853
+ var _a, _b;
20339
20854
  log("clean current scene");
20340
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}`);
20341
20857
  }
20342
20858
  redo() {
20343
20859
  var _a;
@@ -20348,8 +20864,9 @@ const _WindowManager = class extends InvisiblePlugin {
20348
20864
  return ((_a = this.focusedView) == null ? void 0 : _a.undo()) || 0;
20349
20865
  }
20350
20866
  delete() {
20351
- var _a;
20867
+ var _a, _b;
20352
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}`);
20353
20870
  }
20354
20871
  copy() {
20355
20872
  var _a;