@netless/window-manager 1.0.12 → 1.0.13-beta.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
@@ -7372,6 +7372,9 @@ const _AppProxy = class {
7372
7372
  get appAttributes() {
7373
7373
  return this.store.getAppAttributes(this.id);
7374
7374
  }
7375
+ get Logger() {
7376
+ return this.manager.windowManger.Logger;
7377
+ }
7375
7378
  getFullScenePath() {
7376
7379
  if (this.scenePath) {
7377
7380
  return get(this.appAttributes, [Fields.FullPath]) || this.getFullScenePathFromScenes();
@@ -7389,12 +7392,13 @@ const _AppProxy = class {
7389
7392
  this.manager.safeUpdateAttributes(["apps", this.id, Fields.FullPath], path);
7390
7393
  }
7391
7394
  async baseInsertApp(skipUpdate = false, boxStatus = TELE_BOX_STATE.Normal) {
7392
- var _a;
7395
+ var _a, _b, _c;
7393
7396
  const params = this.params;
7394
7397
  if (!params.kind) {
7398
+ (_a = this.Logger) == null ? void 0 : _a.error(`[WindowManager]: kind require`);
7395
7399
  throw new Error("[WindowManager]: kind require");
7396
7400
  }
7397
- const appImpl = await ((_a = appRegister.appClasses.get(params.kind)) == null ? void 0 : _a());
7401
+ const appImpl = await ((_b = appRegister.appClasses.get(params.kind)) == null ? void 0 : _b());
7398
7402
  const appParams = appRegister.registered.get(params.kind);
7399
7403
  if (appImpl) {
7400
7404
  await this.setupApp(
@@ -7409,6 +7413,7 @@ const _AppProxy = class {
7409
7413
  params.isDragContent
7410
7414
  );
7411
7415
  } else {
7416
+ (_c = this.Logger) == null ? void 0 : _c.error(`[WindowManager]: app load failed ${params.kind} ${params.src}`);
7412
7417
  throw new Error(`[WindowManager]: app load failed ${params.kind} ${params.src}`);
7413
7418
  }
7414
7419
  internalEmitter.emit("updateManagerRect");
@@ -7422,7 +7427,7 @@ const _AppProxy = class {
7422
7427
  return (_a = this.boxManager) == null ? void 0 : _a.getBox(this.id);
7423
7428
  }
7424
7429
  async setupApp(appId, skipUpdate, app, options, appOptions, boxStatus, forceTop, forceNormal, isDragContent) {
7425
- var _a;
7430
+ var _a, _b;
7426
7431
  log("setupApp", appId, app, options, boxStatus, forceTop, forceNormal, isDragContent);
7427
7432
  if (!this.boxManager) {
7428
7433
  throw new BoxManagerNotFoundError();
@@ -7446,7 +7451,8 @@ const _AppProxy = class {
7446
7451
  currentMainViewScenePath = this.manager.mainView.scenePath;
7447
7452
  }
7448
7453
  setTimeout(async () => {
7449
- console.log("setup app", app);
7454
+ var _a3;
7455
+ (_a3 = this.Logger) == null ? void 0 : _a3.info(`[WindowManager]: setup app ${this.kind}, appId: ${appId}`);
7450
7456
  const result = await app.setup(context);
7451
7457
  this.appResult = result;
7452
7458
  appRegister.notifyApp(this.kind, "created", { appId, result });
@@ -7481,7 +7487,7 @@ const _AppProxy = class {
7481
7487
  this.boxManager.focusBox({ appId }, false);
7482
7488
  }
7483
7489
  } catch (error) {
7484
- console.error(error);
7490
+ (_b = this.Logger) == null ? void 0 : _b.error(`[WindowManager]: app setup error: ${error.message}`);
7485
7491
  throw new Error(`[WindowManager]: app setup error: ${error.message}`);
7486
7492
  }
7487
7493
  }
@@ -7652,7 +7658,7 @@ const _AppProxy = class {
7652
7658
  }
7653
7659
  }
7654
7660
  async destroy(needCloseBox, cleanAttrs, skipUpdate, error) {
7655
- var _a;
7661
+ var _a, _b, _c;
7656
7662
  if (this.status === "destroyed")
7657
7663
  return;
7658
7664
  this.status = "destroyed";
@@ -7660,12 +7666,13 @@ const _AppProxy = class {
7660
7666
  await appRegister.notifyApp(this.kind, "destroy", { appId: this.id });
7661
7667
  await this.appEmitter.emit("destroy", { error });
7662
7668
  } catch (error2) {
7669
+ (_a = this.Logger) == null ? void 0 : _a.error(`[WindowManager]: notifyApp error: ${error2.message}`);
7663
7670
  console.error("[WindowManager]: notifyApp error", error2.message, error2.stack);
7664
7671
  }
7665
7672
  this.appEmitter.clearListeners();
7666
7673
  internalEmitter.emit(`destroy-${this.id}`, { error });
7667
7674
  if (needCloseBox) {
7668
- (_a = this.boxManager) == null ? void 0 : _a.closeBox(this.id, skipUpdate);
7675
+ (_b = this.boxManager) == null ? void 0 : _b.closeBox(this.id, skipUpdate);
7669
7676
  }
7670
7677
  if (cleanAttrs) {
7671
7678
  this.store.cleanAppAttributes(this.id);
@@ -7681,6 +7688,7 @@ const _AppProxy = class {
7681
7688
  this.manager.refresher.remove(this.stateKey);
7682
7689
  this.manager.refresher.remove(`${this.id}-fullPath`);
7683
7690
  this._prevFullPath = void 0;
7691
+ (_c = this.Logger) == null ? void 0 : _c.info(`[WindowManager]: destroy app ${this.kind} appId: ${this.id}`);
7684
7692
  }
7685
7693
  close() {
7686
7694
  return this.destroy(true, true, false);
@@ -8436,6 +8444,8 @@ class AppManager {
8436
8444
  internalEmitter.on("setReadonly", this.onReadonlyChanged);
8437
8445
  this.createRootDirScenesCallback();
8438
8446
  appRegister.setSyncRegisterApp((payload) => {
8447
+ var _a;
8448
+ (_a = this.Logger) == null ? void 0 : _a.info(`[WindowManager] syncRegisterApp ${JSON.stringify(payload)}`);
8439
8449
  this.safeUpdateAttributes([Fields.Registered, payload.kind], payload);
8440
8450
  });
8441
8451
  }
@@ -8491,6 +8501,9 @@ class AppManager {
8491
8501
  var _a;
8492
8502
  return ((_a = this.room) == null ? void 0 : _a.uid) || "";
8493
8503
  }
8504
+ get Logger() {
8505
+ return this.windowManger.Logger;
8506
+ }
8494
8507
  getMainViewSceneDir() {
8495
8508
  const scenePath = this.store.getMainViewScenePath();
8496
8509
  if (scenePath) {
@@ -8584,6 +8597,7 @@ class AppManager {
8584
8597
  }
8585
8598
  }
8586
8599
  async _attributesUpdateCallback(apps) {
8600
+ var _a;
8587
8601
  if (apps && WindowManager.container) {
8588
8602
  const appIds = Object.keys(apps);
8589
8603
  if (appIds.length === 0) {
@@ -8607,6 +8621,9 @@ class AppManager {
8607
8621
  try {
8608
8622
  const appAttributes = this.attributes[id2];
8609
8623
  if (!appAttributes) {
8624
+ (_a = this.Logger) == null ? void 0 : _a.error(
8625
+ `[WindowManager]: appAttributes is undefined, appId: ${id2}`
8626
+ );
8610
8627
  throw new Error("appAttributes is undefined");
8611
8628
  }
8612
8629
  this.appCreateQueue.push(async () => {
@@ -8678,7 +8695,11 @@ class AppManager {
8678
8695
  }
8679
8696
  }
8680
8697
  async addApp(params, isDynamicPPT) {
8698
+ var _a;
8681
8699
  log("addApp", params);
8700
+ (_a = this.windowManger.Logger) == null ? void 0 : _a.info(
8701
+ `[WindowManager]: addApp ${params.kind}, isDynamicPPT: ${isDynamicPPT}`
8702
+ );
8682
8703
  const { appId, needFocus } = await this.beforeAddApp(params, isDynamicPPT);
8683
8704
  const appProxy = await this.baseInsertApp(params, appId, true, needFocus);
8684
8705
  this.afterAddApp(appProxy);
@@ -8719,8 +8740,11 @@ class AppManager {
8719
8740
  }
8720
8741
  }
8721
8742
  async baseInsertApp(params, appId, isAddApp, focus) {
8743
+ var _a, _b;
8722
8744
  if (this.appProxies.has(appId)) {
8723
- console.warn("[WindowManager]: app duplicate exists and cannot be created again");
8745
+ (_a = this.windowManger.Logger) == null ? void 0 : _a.warn(
8746
+ `[WindowManager]: app duplicate exists and cannot be created again, appId: ${appId}`
8747
+ );
8724
8748
  return;
8725
8749
  }
8726
8750
  const AppProxyClass = getExtendClass$1(AppProxy, WindowManager.extendClass);
@@ -8731,6 +8755,7 @@ class AppManager {
8731
8755
  return appProxy;
8732
8756
  } else {
8733
8757
  this.appStatus.delete(appId);
8758
+ (_b = this.Logger) == null ? void 0 : _b.error(`[WindowManager]: initialize AppProxy failed, appId: ${appId}`);
8734
8759
  throw new Error("[WindowManger]: initialize AppProxy failed");
8735
8760
  }
8736
8761
  }
@@ -8741,13 +8766,16 @@ class AppManager {
8741
8766
  this.windowManger.safeUpdateAttributes(keys, value);
8742
8767
  }
8743
8768
  async setMainViewScenePath(scenePath) {
8769
+ var _a, _b;
8744
8770
  if (this.room) {
8745
8771
  const scenePathType = this.displayer.scenePathType(scenePath);
8746
8772
  const sceneDir = parseSceneDir(scenePath);
8747
8773
  if (sceneDir !== ROOT_DIR) {
8774
+ (_a = this.Logger) == null ? void 0 : _a.error(`[WindowManager]: main view scenePath must in root dir "/"`);
8748
8775
  throw new Error(`[WindowManager]: main view scenePath must in root dir "/"`);
8749
8776
  }
8750
8777
  if (scenePathType === ScenePathType.None) {
8778
+ (_b = this.Logger) == null ? void 0 : _b.error(`[WindowManager]: ${scenePath} not valid scene`);
8751
8779
  throw new Error(`[WindowManager]: ${scenePath} not valid scene`);
8752
8780
  } else if (scenePathType === ScenePathType.Page) {
8753
8781
  await this._setMainViewScenePath(scenePath);
@@ -8769,7 +8797,7 @@ class AppManager {
8769
8797
  }
8770
8798
  }
8771
8799
  async setMainViewSceneIndex(index2) {
8772
- var _a;
8800
+ var _a, _b;
8773
8801
  if (this.room) {
8774
8802
  if (this.store.getMainViewSceneIndex() === index2)
8775
8803
  return;
@@ -8783,6 +8811,7 @@ class AppManager {
8783
8811
  this.dispatchSetMainViewScenePath(scenePath);
8784
8812
  }
8785
8813
  } else {
8814
+ (_b = this.Logger) == null ? void 0 : _b.error(`[WindowManager]: ${index2} not valid index`);
8786
8815
  throw new Error(`[WindowManager]: ${index2} not valid index`);
8787
8816
  }
8788
8817
  }
@@ -19643,20 +19672,24 @@ const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
19643
19672
  const _WindowManager = class extends InvisiblePlugin {
19644
19673
  constructor(context) {
19645
19674
  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" } };
19675
+ this.version = "1.0.13-beta.1";
19676
+ 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" } };
19648
19677
  this.emitter = callbacks$1;
19649
19678
  this.viewMode = ViewMode.Broadcaster;
19650
19679
  this.isReplay = isPlayer(this.displayer);
19651
19680
  this._cursorUIDs = [];
19652
19681
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
19653
19682
  _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" } };
19683
+ 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" } };
19684
+ }
19685
+ get Logger() {
19686
+ return this._roomLogger;
19655
19687
  }
19656
19688
  static onCreate(manager) {
19657
19689
  _WindowManager._resolve(manager);
19658
19690
  }
19659
19691
  static async mount(params, extendClass) {
19692
+ var _a;
19660
19693
  const room = params.room;
19661
19694
  _WindowManager.container = params.container;
19662
19695
  _WindowManager.supportAppliancePlugin = params.supportAppliancePlugin;
@@ -19676,6 +19709,16 @@ const _WindowManager = class extends InvisiblePlugin {
19676
19709
  room.disableSerialization = false;
19677
19710
  }
19678
19711
  manager = await this.initManager(room);
19712
+ if (manager) {
19713
+ manager._roomLogger = room.logger;
19714
+ if (_WindowManager.registered.size > 0) {
19715
+ manager._roomLogger.info(
19716
+ `[WindowManager] registered apps: ${JSON.stringify(
19717
+ Array.from(_WindowManager.registered.keys())
19718
+ )}`
19719
+ );
19720
+ }
19721
+ }
19679
19722
  }
19680
19723
  if (_WindowManager.isCreated) {
19681
19724
  throw new Error("[WindowManager]: Already created cannot be created again");
@@ -19684,7 +19727,13 @@ const _WindowManager = class extends InvisiblePlugin {
19684
19727
  if (this.debug) {
19685
19728
  v({ verbose: true });
19686
19729
  }
19687
- log("Already insert room", manager);
19730
+ if (manager == null ? void 0 : manager._roomLogger) {
19731
+ manager._roomLogger.info(
19732
+ `[WindowManager] Already insert room version: ${manager.version}`
19733
+ );
19734
+ } else {
19735
+ log("Already insert room", manager);
19736
+ }
19688
19737
  if (isRoom(this.displayer)) {
19689
19738
  if (!manager) {
19690
19739
  throw new Error("[WindowManager]: init InvisiblePlugin failed");
@@ -19733,9 +19782,17 @@ const _WindowManager = class extends InvisiblePlugin {
19733
19782
  replaceRoomFunction(room, manager);
19734
19783
  internalEmitter.emit("onCreated");
19735
19784
  _WindowManager.isCreated = true;
19785
+ if (manager._roomLogger && manager.attributes.registered && Object.keys(manager.attributes.registered).length > 0) {
19786
+ manager._roomLogger.info(
19787
+ `[WindowManager] attributes registered apps: ${JSON.stringify(
19788
+ Array.from(Object.keys(manager.attributes.registered))
19789
+ )}`
19790
+ );
19791
+ }
19736
19792
  try {
19737
19793
  await initDb();
19738
19794
  } catch (error) {
19795
+ (_a = manager._roomLogger) == null ? void 0 : _a.warn(`[WindowManager] indexedDB open failed: ${error.message}`);
19739
19796
  console.warn("[WindowManager]: indexedDB open failed");
19740
19797
  console.log(error);
19741
19798
  }