@netless/window-manager 1.0.0-canary.63 → 1.0.0-canary.65

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.js CHANGED
@@ -873,7 +873,7 @@ class WhiteBoardView {
873
873
  const camera$ = new valueEnhancer.Val(pickCamera(this.view.camera));
874
874
  this.baseRect$ = baseRect$;
875
875
  this.pageState$ = pageState$;
876
- this.baseCamera$ = camera$;
876
+ this.camera$ = camera$;
877
877
  this.appProxy.sideEffectManager.add(() => [
878
878
  appProxy.appEmitter.on("pageStateChange", (pageState) => pageState$.setValue(pageState)),
879
879
  appProxy.camera$.subscribe((camera) => {
@@ -1271,6 +1271,7 @@ class CameraSynchronizer {
1271
1271
  constructor(saveCamera) {
1272
1272
  this.saveCamera = saveCamera;
1273
1273
  this.scale = 1;
1274
+ this.cameraUpdating = false;
1274
1275
  this.setRect = (rect, updateCamera = true) => {
1275
1276
  this.rect = rect;
1276
1277
  if (this.remoteCamera && this.remoteSize && updateCamera) {
@@ -1328,7 +1329,7 @@ class CameraSynchronizer {
1328
1329
  }
1329
1330
  }
1330
1331
  moveCamera(camera) {
1331
- if (!lodash.isEmpty(camera) && this.view && camera.centerX && camera.centerY) {
1332
+ if (!lodash.isEmpty(camera) && this.view && camera.centerX != null && camera.centerY != null) {
1332
1333
  if (lodash.isEqual(camera, this.view.camera))
1333
1334
  return;
1334
1335
  const { centerX, centerY, scale: scale2 } = camera;
@@ -2471,6 +2472,39 @@ class MainViewProxy {
2471
2472
  })
2472
2473
  );
2473
2474
  };
2475
+ this.moveCamera = (camera) => {
2476
+ this.debouncedStoreCamera();
2477
+ this.moveCameraToPromise(camera);
2478
+ };
2479
+ this.moveCameraToPromise = (camera) => {
2480
+ const promise = new Promise((resolve) => {
2481
+ const cameraListener = lodash.debounce(() => {
2482
+ this.mainView.callbacks.off("onCameraUpdated", cameraListener);
2483
+ this.cameraUpdatePromise = void 0;
2484
+ resolve(true);
2485
+ }, 50);
2486
+ this.mainView.callbacks.on("onCameraUpdated", cameraListener);
2487
+ this.mainView.moveCamera(camera);
2488
+ });
2489
+ this.cameraUpdatePromise = promise;
2490
+ return promise;
2491
+ };
2492
+ this.debouncedStoreCamera = () => {
2493
+ this.storeCurrentSize();
2494
+ const cameraListener = lodash.debounce(() => {
2495
+ this.saveToCamera$();
2496
+ this.storeCurrentCameraSize();
2497
+ this.mainView.callbacks.off("onCameraUpdated", cameraListener);
2498
+ }, 50);
2499
+ this.mainView.callbacks.on("onCameraUpdated", cameraListener);
2500
+ };
2501
+ this.storeCurrentCameraSize = lodash.debounce(() => __async$4(this, null, function* () {
2502
+ if (this.cameraUpdatePromise) {
2503
+ yield this.cameraUpdatePromise;
2504
+ }
2505
+ this.storeCurrentCamera();
2506
+ this.storeCurrentSize();
2507
+ }), 500);
2474
2508
  this.addCameraReaction = () => {
2475
2509
  this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
2476
2510
  this.manager.refresher.add(Fields.MainViewSize, this.sizeReaction);
@@ -2489,11 +2523,14 @@ class MainViewProxy {
2489
2523
  var _a2;
2490
2524
  const rect = (_a2 = this.manager.boxManager) == null ? void 0 : _a2.stageRect;
2491
2525
  if (rect) {
2492
- this.storeSize({
2526
+ const size = {
2493
2527
  id: this.manager.uid,
2494
2528
  width: rect.width,
2495
2529
  height: rect.height
2496
- });
2530
+ };
2531
+ if (!lodash.isEqual(size, this.mainViewSize)) {
2532
+ this.storeSize(size);
2533
+ }
2497
2534
  }
2498
2535
  };
2499
2536
  this.storeCamera = (camera) => {
@@ -2560,11 +2597,6 @@ class MainViewProxy {
2560
2597
  }
2561
2598
  }
2562
2599
  }));
2563
- this.camera$.reaction((camera) => {
2564
- if (camera) {
2565
- callbacks.emit("baseCameraChange", camera);
2566
- }
2567
- });
2568
2600
  this.size$.reaction((size) => {
2569
2601
  if (size) {
2570
2602
  callbacks.emit("baseSizeChange", size);
@@ -2889,6 +2921,8 @@ class ScrollMode {
2889
2921
  });
2890
2922
  this.sideEffect.add(() => {
2891
2923
  const onCameraUpdated = (camera) => {
2924
+ if (!this.manager.canOperate)
2925
+ return;
2892
2926
  const halfWbHeight = size$.value.height / 2 / scale$.value;
2893
2927
  const scrollTop = camera.centerY;
2894
2928
  this.scrollStorage.setState({
@@ -12756,7 +12790,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
12756
12790
  const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
12757
12791
  constructor(context) {
12758
12792
  super(context);
12759
- this.version = "1.0.0-canary.63";
12793
+ this.version = "1.0.0-canary.65";
12760
12794
  this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/synced-store": "^2.0.7", "@netless/telebox-insider": "1.0.0-alpha.37", "emittery": "^0.11.0", "lodash": "^4.17.21", "p-retry": "^4.6.2", "side-effect-manager": "^1.2.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^1.0.0-canary.3", "@netless/app-plyr": "^0.2.3", "@playwright/test": "^1.23.2", "@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.49", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.2", "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", "less": "^4.1.3", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^3.1.3", "vite-plugin-dts": "^1.5.0", "vitest": "^0.23.4", "white-web-sdk": "^2.16.35" } };
12761
12795
  this.emitter = callbacks;
12762
12796
  this.viewMode$ = new valueEnhancer.Val(whiteWebSdk.ViewMode.Broadcaster);
@@ -12764,24 +12798,13 @@ const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
12764
12798
  this.isReplay = whiteWebSdk.isPlayer(this.displayer);
12765
12799
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
12766
12800
  this.moveCamera = (camera) => {
12767
- var _a2;
12801
+ var _a2, _b;
12768
12802
  const pureCamera = lodash.omit(camera, ["animationMode"]);
12769
12803
  const mainViewCamera = __spreadValues({}, this.mainView.camera);
12770
12804
  if (lodash.isEqual(__spreadValues(__spreadValues({}, mainViewCamera), pureCamera), mainViewCamera))
12771
12805
  return;
12772
- this.debouncedStoreCamera();
12773
- this.mainView.moveCamera(camera);
12774
- (_a2 = this.appManager) == null ? void 0 : _a2.dispatchInternalEvent(Events.MoveCamera, camera);
12775
- };
12776
- this.debouncedStoreCamera = () => {
12777
- const storeCamera = lodash.debounce(() => {
12778
- var _a2, _b, _c;
12779
- (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.saveToCamera$();
12780
- (_b = this.appManager) == null ? void 0 : _b.mainViewProxy.storeCurrentCamera();
12781
- (_c = this.appManager) == null ? void 0 : _c.mainViewProxy.storeCurrentSize();
12782
- this.mainView.callbacks.off("onCameraUpdated", storeCamera);
12783
- }, 200);
12784
- this.mainView.callbacks.on("onCameraUpdated", storeCamera);
12806
+ (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.moveCamera(camera);
12807
+ (_b = this.appManager) == null ? void 0 : _b.dispatchInternalEvent(Events.MoveCamera, camera);
12785
12808
  };
12786
12809
  _WindowManager.displayer = context.displayer;
12787
12810
  window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/synced-store": "^2.0.7", "@netless/telebox-insider": "1.0.0-alpha.37", "emittery": "^0.11.0", "lodash": "^4.17.21", "p-retry": "^4.6.2", "side-effect-manager": "^1.2.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^1.0.0-canary.3", "@netless/app-plyr": "^0.2.3", "@playwright/test": "^1.23.2", "@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.49", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.2", "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", "less": "^4.1.3", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^3.1.3", "vite-plugin-dts": "^1.5.0", "vitest": "^0.23.4", "white-web-sdk": "^2.16.35" } };
@@ -13164,8 +13187,8 @@ const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
13164
13187
  var _a2;
13165
13188
  log("setViewMode", mode);
13166
13189
  const mainViewProxy = (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy;
13167
- if (mode === whiteWebSdk.ViewMode.Broadcaster) {
13168
- if (this.canOperate) {
13190
+ if (mode === whiteWebSdk.ViewMode.Broadcaster || mode === whiteWebSdk.ViewMode.Follower) {
13191
+ if (this.canOperate && mode === whiteWebSdk.ViewMode.Broadcaster) {
13169
13192
  mainViewProxy == null ? void 0 : mainViewProxy.storeCurrentCamera();
13170
13193
  mainViewProxy == null ? void 0 : mainViewProxy.storeCurrentSize();
13171
13194
  }
@@ -13350,7 +13373,6 @@ const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
13350
13373
  }
13351
13374
  moveCameraToContain(rectangle) {
13352
13375
  var _a2;
13353
- this.debouncedStoreCamera();
13354
13376
  this.mainView.moveCameraToContain(rectangle);
13355
13377
  (_a2 = this.appManager) == null ? void 0 : _a2.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
13356
13378
  }
package/dist/index.mjs CHANGED
@@ -868,7 +868,7 @@ class WhiteBoardView {
868
868
  const camera$ = new Val(pickCamera(this.view.camera));
869
869
  this.baseRect$ = baseRect$;
870
870
  this.pageState$ = pageState$;
871
- this.baseCamera$ = camera$;
871
+ this.camera$ = camera$;
872
872
  this.appProxy.sideEffectManager.add(() => [
873
873
  appProxy.appEmitter.on("pageStateChange", (pageState) => pageState$.setValue(pageState)),
874
874
  appProxy.camera$.subscribe((camera) => {
@@ -1266,6 +1266,7 @@ class CameraSynchronizer {
1266
1266
  constructor(saveCamera) {
1267
1267
  this.saveCamera = saveCamera;
1268
1268
  this.scale = 1;
1269
+ this.cameraUpdating = false;
1269
1270
  this.setRect = (rect, updateCamera = true) => {
1270
1271
  this.rect = rect;
1271
1272
  if (this.remoteCamera && this.remoteSize && updateCamera) {
@@ -1323,7 +1324,7 @@ class CameraSynchronizer {
1323
1324
  }
1324
1325
  }
1325
1326
  moveCamera(camera) {
1326
- if (!isEmpty(camera) && this.view && camera.centerX && camera.centerY) {
1327
+ if (!isEmpty(camera) && this.view && camera.centerX != null && camera.centerY != null) {
1327
1328
  if (isEqual(camera, this.view.camera))
1328
1329
  return;
1329
1330
  const { centerX, centerY, scale: scale2 } = camera;
@@ -2466,6 +2467,39 @@ class MainViewProxy {
2466
2467
  })
2467
2468
  );
2468
2469
  };
2470
+ this.moveCamera = (camera) => {
2471
+ this.debouncedStoreCamera();
2472
+ this.moveCameraToPromise(camera);
2473
+ };
2474
+ this.moveCameraToPromise = (camera) => {
2475
+ const promise = new Promise((resolve) => {
2476
+ const cameraListener = debounce(() => {
2477
+ this.mainView.callbacks.off("onCameraUpdated", cameraListener);
2478
+ this.cameraUpdatePromise = void 0;
2479
+ resolve(true);
2480
+ }, 50);
2481
+ this.mainView.callbacks.on("onCameraUpdated", cameraListener);
2482
+ this.mainView.moveCamera(camera);
2483
+ });
2484
+ this.cameraUpdatePromise = promise;
2485
+ return promise;
2486
+ };
2487
+ this.debouncedStoreCamera = () => {
2488
+ this.storeCurrentSize();
2489
+ const cameraListener = debounce(() => {
2490
+ this.saveToCamera$();
2491
+ this.storeCurrentCameraSize();
2492
+ this.mainView.callbacks.off("onCameraUpdated", cameraListener);
2493
+ }, 50);
2494
+ this.mainView.callbacks.on("onCameraUpdated", cameraListener);
2495
+ };
2496
+ this.storeCurrentCameraSize = debounce(() => __async$4(this, null, function* () {
2497
+ if (this.cameraUpdatePromise) {
2498
+ yield this.cameraUpdatePromise;
2499
+ }
2500
+ this.storeCurrentCamera();
2501
+ this.storeCurrentSize();
2502
+ }), 500);
2469
2503
  this.addCameraReaction = () => {
2470
2504
  this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
2471
2505
  this.manager.refresher.add(Fields.MainViewSize, this.sizeReaction);
@@ -2484,11 +2518,14 @@ class MainViewProxy {
2484
2518
  var _a2;
2485
2519
  const rect = (_a2 = this.manager.boxManager) == null ? void 0 : _a2.stageRect;
2486
2520
  if (rect) {
2487
- this.storeSize({
2521
+ const size = {
2488
2522
  id: this.manager.uid,
2489
2523
  width: rect.width,
2490
2524
  height: rect.height
2491
- });
2525
+ };
2526
+ if (!isEqual(size, this.mainViewSize)) {
2527
+ this.storeSize(size);
2528
+ }
2492
2529
  }
2493
2530
  };
2494
2531
  this.storeCamera = (camera) => {
@@ -2555,11 +2592,6 @@ class MainViewProxy {
2555
2592
  }
2556
2593
  }
2557
2594
  }));
2558
- this.camera$.reaction((camera) => {
2559
- if (camera) {
2560
- callbacks.emit("baseCameraChange", camera);
2561
- }
2562
- });
2563
2595
  this.size$.reaction((size) => {
2564
2596
  if (size) {
2565
2597
  callbacks.emit("baseSizeChange", size);
@@ -2884,6 +2916,8 @@ class ScrollMode {
2884
2916
  });
2885
2917
  this.sideEffect.add(() => {
2886
2918
  const onCameraUpdated = (camera) => {
2919
+ if (!this.manager.canOperate)
2920
+ return;
2887
2921
  const halfWbHeight = size$.value.height / 2 / scale$.value;
2888
2922
  const scrollTop = camera.centerY;
2889
2923
  this.scrollStorage.setState({
@@ -12751,7 +12785,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
12751
12785
  const _WindowManager = class extends InvisiblePlugin {
12752
12786
  constructor(context) {
12753
12787
  super(context);
12754
- this.version = "1.0.0-canary.63";
12788
+ this.version = "1.0.0-canary.65";
12755
12789
  this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/synced-store": "^2.0.7", "@netless/telebox-insider": "1.0.0-alpha.37", "emittery": "^0.11.0", "lodash": "^4.17.21", "p-retry": "^4.6.2", "side-effect-manager": "^1.2.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^1.0.0-canary.3", "@netless/app-plyr": "^0.2.3", "@playwright/test": "^1.23.2", "@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.49", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.2", "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", "less": "^4.1.3", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^3.1.3", "vite-plugin-dts": "^1.5.0", "vitest": "^0.23.4", "white-web-sdk": "^2.16.35" } };
12756
12790
  this.emitter = callbacks;
12757
12791
  this.viewMode$ = new Val(ViewMode.Broadcaster);
@@ -12759,24 +12793,13 @@ const _WindowManager = class extends InvisiblePlugin {
12759
12793
  this.isReplay = isPlayer(this.displayer);
12760
12794
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
12761
12795
  this.moveCamera = (camera) => {
12762
- var _a2;
12796
+ var _a2, _b;
12763
12797
  const pureCamera = omit(camera, ["animationMode"]);
12764
12798
  const mainViewCamera = __spreadValues({}, this.mainView.camera);
12765
12799
  if (isEqual(__spreadValues(__spreadValues({}, mainViewCamera), pureCamera), mainViewCamera))
12766
12800
  return;
12767
- this.debouncedStoreCamera();
12768
- this.mainView.moveCamera(camera);
12769
- (_a2 = this.appManager) == null ? void 0 : _a2.dispatchInternalEvent(Events.MoveCamera, camera);
12770
- };
12771
- this.debouncedStoreCamera = () => {
12772
- const storeCamera = debounce(() => {
12773
- var _a2, _b, _c;
12774
- (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.saveToCamera$();
12775
- (_b = this.appManager) == null ? void 0 : _b.mainViewProxy.storeCurrentCamera();
12776
- (_c = this.appManager) == null ? void 0 : _c.mainViewProxy.storeCurrentSize();
12777
- this.mainView.callbacks.off("onCameraUpdated", storeCamera);
12778
- }, 200);
12779
- this.mainView.callbacks.on("onCameraUpdated", storeCamera);
12801
+ (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.moveCamera(camera);
12802
+ (_b = this.appManager) == null ? void 0 : _b.dispatchInternalEvent(Events.MoveCamera, camera);
12780
12803
  };
12781
12804
  _WindowManager.displayer = context.displayer;
12782
12805
  window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/synced-store": "^2.0.7", "@netless/telebox-insider": "1.0.0-alpha.37", "emittery": "^0.11.0", "lodash": "^4.17.21", "p-retry": "^4.6.2", "side-effect-manager": "^1.2.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^1.0.0-canary.3", "@netless/app-plyr": "^0.2.3", "@playwright/test": "^1.23.2", "@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.49", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.2", "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", "less": "^4.1.3", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^3.1.3", "vite-plugin-dts": "^1.5.0", "vitest": "^0.23.4", "white-web-sdk": "^2.16.35" } };
@@ -13159,8 +13182,8 @@ const _WindowManager = class extends InvisiblePlugin {
13159
13182
  var _a2;
13160
13183
  log("setViewMode", mode);
13161
13184
  const mainViewProxy = (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy;
13162
- if (mode === ViewMode.Broadcaster) {
13163
- if (this.canOperate) {
13185
+ if (mode === ViewMode.Broadcaster || mode === ViewMode.Follower) {
13186
+ if (this.canOperate && mode === ViewMode.Broadcaster) {
13164
13187
  mainViewProxy == null ? void 0 : mainViewProxy.storeCurrentCamera();
13165
13188
  mainViewProxy == null ? void 0 : mainViewProxy.storeCurrentSize();
13166
13189
  }
@@ -13345,7 +13368,6 @@ const _WindowManager = class extends InvisiblePlugin {
13345
13368
  }
13346
13369
  moveCameraToContain(rectangle) {
13347
13370
  var _a2;
13348
- this.debouncedStoreCamera();
13349
13371
  this.mainView.moveCameraToContain(rectangle);
13350
13372
  (_a2 = this.appManager) == null ? void 0 : _a2.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
13351
13373
  }
package/dist/index.umd.js CHANGED
@@ -866,7 +866,7 @@
866
866
  const camera$ = new valueEnhancer.Val(pickCamera(this.view.camera));
867
867
  this.baseRect$ = baseRect$;
868
868
  this.pageState$ = pageState$;
869
- this.baseCamera$ = camera$;
869
+ this.camera$ = camera$;
870
870
  this.appProxy.sideEffectManager.add(() => [
871
871
  appProxy.appEmitter.on("pageStateChange", (pageState) => pageState$.setValue(pageState)),
872
872
  appProxy.camera$.subscribe((camera) => {
@@ -1264,6 +1264,7 @@
1264
1264
  constructor(saveCamera) {
1265
1265
  this.saveCamera = saveCamera;
1266
1266
  this.scale = 1;
1267
+ this.cameraUpdating = false;
1267
1268
  this.setRect = (rect, updateCamera = true) => {
1268
1269
  this.rect = rect;
1269
1270
  if (this.remoteCamera && this.remoteSize && updateCamera) {
@@ -1321,7 +1322,7 @@
1321
1322
  }
1322
1323
  }
1323
1324
  moveCamera(camera) {
1324
- if (!lodash.isEmpty(camera) && this.view && camera.centerX && camera.centerY) {
1325
+ if (!lodash.isEmpty(camera) && this.view && camera.centerX != null && camera.centerY != null) {
1325
1326
  if (lodash.isEqual(camera, this.view.camera))
1326
1327
  return;
1327
1328
  const { centerX, centerY, scale: scale2 } = camera;
@@ -2464,6 +2465,39 @@
2464
2465
  })
2465
2466
  );
2466
2467
  };
2468
+ this.moveCamera = (camera) => {
2469
+ this.debouncedStoreCamera();
2470
+ this.moveCameraToPromise(camera);
2471
+ };
2472
+ this.moveCameraToPromise = (camera) => {
2473
+ const promise = new Promise((resolve) => {
2474
+ const cameraListener = lodash.debounce(() => {
2475
+ this.mainView.callbacks.off("onCameraUpdated", cameraListener);
2476
+ this.cameraUpdatePromise = void 0;
2477
+ resolve(true);
2478
+ }, 50);
2479
+ this.mainView.callbacks.on("onCameraUpdated", cameraListener);
2480
+ this.mainView.moveCamera(camera);
2481
+ });
2482
+ this.cameraUpdatePromise = promise;
2483
+ return promise;
2484
+ };
2485
+ this.debouncedStoreCamera = () => {
2486
+ this.storeCurrentSize();
2487
+ const cameraListener = lodash.debounce(() => {
2488
+ this.saveToCamera$();
2489
+ this.storeCurrentCameraSize();
2490
+ this.mainView.callbacks.off("onCameraUpdated", cameraListener);
2491
+ }, 50);
2492
+ this.mainView.callbacks.on("onCameraUpdated", cameraListener);
2493
+ };
2494
+ this.storeCurrentCameraSize = lodash.debounce(() => __async$4(this, null, function* () {
2495
+ if (this.cameraUpdatePromise) {
2496
+ yield this.cameraUpdatePromise;
2497
+ }
2498
+ this.storeCurrentCamera();
2499
+ this.storeCurrentSize();
2500
+ }), 500);
2467
2501
  this.addCameraReaction = () => {
2468
2502
  this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
2469
2503
  this.manager.refresher.add(Fields.MainViewSize, this.sizeReaction);
@@ -2482,11 +2516,14 @@
2482
2516
  var _a2;
2483
2517
  const rect = (_a2 = this.manager.boxManager) == null ? void 0 : _a2.stageRect;
2484
2518
  if (rect) {
2485
- this.storeSize({
2519
+ const size = {
2486
2520
  id: this.manager.uid,
2487
2521
  width: rect.width,
2488
2522
  height: rect.height
2489
- });
2523
+ };
2524
+ if (!lodash.isEqual(size, this.mainViewSize)) {
2525
+ this.storeSize(size);
2526
+ }
2490
2527
  }
2491
2528
  };
2492
2529
  this.storeCamera = (camera) => {
@@ -2553,11 +2590,6 @@
2553
2590
  }
2554
2591
  }
2555
2592
  }));
2556
- this.camera$.reaction((camera) => {
2557
- if (camera) {
2558
- callbacks.emit("baseCameraChange", camera);
2559
- }
2560
- });
2561
2593
  this.size$.reaction((size) => {
2562
2594
  if (size) {
2563
2595
  callbacks.emit("baseSizeChange", size);
@@ -2882,6 +2914,8 @@
2882
2914
  });
2883
2915
  this.sideEffect.add(() => {
2884
2916
  const onCameraUpdated = (camera) => {
2917
+ if (!this.manager.canOperate)
2918
+ return;
2885
2919
  const halfWbHeight = size$.value.height / 2 / scale$.value;
2886
2920
  const scrollTop = camera.centerY;
2887
2921
  this.scrollStorage.setState({
@@ -12749,7 +12783,7 @@
12749
12783
  const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
12750
12784
  constructor(context) {
12751
12785
  super(context);
12752
- this.version = "1.0.0-canary.63";
12786
+ this.version = "1.0.0-canary.65";
12753
12787
  this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/synced-store": "^2.0.7", "@netless/telebox-insider": "1.0.0-alpha.37", "emittery": "^0.11.0", "lodash": "^4.17.21", "p-retry": "^4.6.2", "side-effect-manager": "^1.2.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^1.0.0-canary.3", "@netless/app-plyr": "^0.2.3", "@playwright/test": "^1.23.2", "@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.49", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.2", "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", "less": "^4.1.3", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^3.1.3", "vite-plugin-dts": "^1.5.0", "vitest": "^0.23.4", "white-web-sdk": "^2.16.35" } };
12754
12788
  this.emitter = callbacks;
12755
12789
  this.viewMode$ = new valueEnhancer.Val(whiteWebSdk.ViewMode.Broadcaster);
@@ -12757,24 +12791,13 @@
12757
12791
  this.isReplay = whiteWebSdk.isPlayer(this.displayer);
12758
12792
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
12759
12793
  this.moveCamera = (camera) => {
12760
- var _a2;
12794
+ var _a2, _b;
12761
12795
  const pureCamera = lodash.omit(camera, ["animationMode"]);
12762
12796
  const mainViewCamera = __spreadValues({}, this.mainView.camera);
12763
12797
  if (lodash.isEqual(__spreadValues(__spreadValues({}, mainViewCamera), pureCamera), mainViewCamera))
12764
12798
  return;
12765
- this.debouncedStoreCamera();
12766
- this.mainView.moveCamera(camera);
12767
- (_a2 = this.appManager) == null ? void 0 : _a2.dispatchInternalEvent(Events.MoveCamera, camera);
12768
- };
12769
- this.debouncedStoreCamera = () => {
12770
- const storeCamera = lodash.debounce(() => {
12771
- var _a2, _b, _c;
12772
- (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.saveToCamera$();
12773
- (_b = this.appManager) == null ? void 0 : _b.mainViewProxy.storeCurrentCamera();
12774
- (_c = this.appManager) == null ? void 0 : _c.mainViewProxy.storeCurrentSize();
12775
- this.mainView.callbacks.off("onCameraUpdated", storeCamera);
12776
- }, 200);
12777
- this.mainView.callbacks.on("onCameraUpdated", storeCamera);
12799
+ (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.moveCamera(camera);
12800
+ (_b = this.appManager) == null ? void 0 : _b.dispatchInternalEvent(Events.MoveCamera, camera);
12778
12801
  };
12779
12802
  _WindowManager.displayer = context.displayer;
12780
12803
  window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/synced-store": "^2.0.7", "@netless/telebox-insider": "1.0.0-alpha.37", "emittery": "^0.11.0", "lodash": "^4.17.21", "p-retry": "^4.6.2", "side-effect-manager": "^1.2.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^1.0.0-canary.3", "@netless/app-plyr": "^0.2.3", "@playwright/test": "^1.23.2", "@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.49", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.2", "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", "less": "^4.1.3", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^3.1.3", "vite-plugin-dts": "^1.5.0", "vitest": "^0.23.4", "white-web-sdk": "^2.16.35" } };
@@ -13157,8 +13180,8 @@
13157
13180
  var _a2;
13158
13181
  log("setViewMode", mode);
13159
13182
  const mainViewProxy = (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy;
13160
- if (mode === whiteWebSdk.ViewMode.Broadcaster) {
13161
- if (this.canOperate) {
13183
+ if (mode === whiteWebSdk.ViewMode.Broadcaster || mode === whiteWebSdk.ViewMode.Follower) {
13184
+ if (this.canOperate && mode === whiteWebSdk.ViewMode.Broadcaster) {
13162
13185
  mainViewProxy == null ? void 0 : mainViewProxy.storeCurrentCamera();
13163
13186
  mainViewProxy == null ? void 0 : mainViewProxy.storeCurrentSize();
13164
13187
  }
@@ -13343,7 +13366,6 @@
13343
13366
  }
13344
13367
  moveCameraToContain(rectangle) {
13345
13368
  var _a2;
13346
- this.debouncedStoreCamera();
13347
13369
  this.mainView.moveCameraToContain(rectangle);
13348
13370
  (_a2 = this.appManager) == null ? void 0 : _a2.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
13349
13371
  }
@@ -13,7 +13,7 @@ export declare class WhiteBoardView implements PageController {
13
13
  protected appProxy: AppProxy;
14
14
  ensureSize: (size: number) => void;
15
15
  readonly pageState$: ReadonlyVal<PageState>;
16
- readonly baseCamera$: ReadonlyVal<WhiteBoardViewCamera>;
16
+ readonly camera$: ReadonlyVal<WhiteBoardViewCamera>;
17
17
  readonly baseRect$: ReadonlyVal<WhiteBoardViewRect | undefined>;
18
18
  constructor(view: View, appContext: AppContext, appProxy: AppProxy, ensureSize: (size: number) => void);
19
19
  get pageState(): PageState;
@@ -9,6 +9,7 @@ export declare class CameraSynchronizer {
9
9
  protected rect?: TeleBoxRect;
10
10
  protected view?: View;
11
11
  protected scale: number;
12
+ protected cameraUpdating: boolean;
12
13
  constructor(saveCamera: SaveCamera);
13
14
  setRect: (rect: TeleBoxRect, updateCamera?: boolean) => void;
14
15
  setView(view: View): void;
@@ -3,6 +3,7 @@ import { ViewSync } from "./ViewSync";
3
3
  import type { ICamera, ISize } from "../AttributesDelegate";
4
4
  import type { Size, View } from "white-web-sdk";
5
5
  import type { AppManager } from "../AppManager";
6
+ import type { MoveCameraParams } from "../typings";
6
7
  export declare class MainViewProxy {
7
8
  private manager;
8
9
  private started;
@@ -18,11 +19,16 @@ export declare class MainViewProxy {
18
19
  } | undefined, any>;
19
20
  size$: Val<ISize | undefined, any>;
20
21
  view$: Val<View | undefined, any>;
22
+ private cameraUpdatePromise?;
21
23
  viewSync?: ViewSync;
22
24
  constructor(manager: AppManager);
23
25
  createViewSync: () => void;
24
26
  private startListenWritableChange;
25
27
  ensureCameraAndSize(): void;
28
+ moveCamera: (camera: MoveCameraParams) => void;
29
+ moveCameraToPromise: (camera: MoveCameraParams) => Promise<boolean>;
30
+ private debouncedStoreCamera;
31
+ private storeCurrentCameraSize;
26
32
  private get mainViewCamera();
27
33
  private get mainViewSize();
28
34
  private get didRelease();
@@ -3,7 +3,7 @@ import type { TeleBoxColorScheme, TeleBoxFullscreen, TELE_BOX_STATE } from "@net
3
3
  import type { CameraState, SceneState, ViewVisionMode } from "white-web-sdk";
4
4
  import type { LoadAppEvent } from "./Register";
5
5
  import type { PageState } from "./Page";
6
- import type { ICamera, ISize } from "./AttributesDelegate";
6
+ import type { ISize } from "./AttributesDelegate";
7
7
  import type { ScrollState } from "./View/ScrollMode";
8
8
  export declare type PublicEvent = {
9
9
  mainViewModeChange: ViewVisionMode;
@@ -26,7 +26,6 @@ export declare type PublicEvent = {
26
26
  kind: string;
27
27
  error?: Error;
28
28
  };
29
- baseCameraChange: ICamera;
30
29
  baseSizeChange: ISize;
31
30
  fullscreenChange: TeleBoxFullscreen;
32
31
  userScroll: undefined;
@@ -7,7 +7,7 @@ import type { TELE_BOX_STATE } from "./BoxManager";
7
7
  import type { Apps, Position, ICamera, ISize } from "./AttributesDelegate";
8
8
  import type { Displayer, SceneDefinition, View, Room, InvisiblePluginContext, Camera, CameraBound, Point, CameraState, Player, ImageInformation, SceneState, Size, AnimationMode, Rectangle } from "white-web-sdk";
9
9
  import type { AppListeners } from "./AppListener";
10
- import type { ApplianceIcons, ManagerViewMode, NetlessApp, RegisterParams } from "./typings";
10
+ import type { ApplianceIcons, ManagerViewMode, MoveCameraParams, NetlessApp, RegisterParams } from "./typings";
11
11
  import type { TeleBoxColorScheme, TeleBoxFullscreen, TeleBoxManager, TeleBoxManagerThemeConfig, TeleBoxState } from "@netless/telebox-insider";
12
12
  import type { AppProxy } from "./App";
13
13
  import type { PublicEvent } from "./callback";
@@ -241,13 +241,10 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
241
241
  * 关闭 APP
242
242
  */
243
243
  closeApp(appId: string): Promise<void>;
244
- moveCamera: (camera: Partial<Camera> & {
245
- animationMode?: AnimationMode;
246
- }) => void;
244
+ moveCamera: (camera: MoveCameraParams) => void;
247
245
  moveCameraToContain(rectangle: Rectangle & Readonly<{
248
246
  animationMode?: AnimationMode;
249
247
  }>): void;
250
- private debouncedStoreCamera;
251
248
  convertToPointInWorld(point: Point): Point;
252
249
  setCameraBound(cameraBound: CameraBound): void;
253
250
  onDestroy(): void;
@@ -1,5 +1,5 @@
1
1
  import type Emittery from "emittery";
2
- import type { AnimationMode, ApplianceNames, Displayer, DisplayerState, Player, Room, SceneDefinition, SceneState, View, ViewMode } from "white-web-sdk";
2
+ import type { AnimationMode, ApplianceNames, Camera, Displayer, DisplayerState, Player, Room, SceneDefinition, SceneState, View, ViewMode } from "white-web-sdk";
3
3
  import type { AppContext } from "./App";
4
4
  import type { ReadonlyTeleBox, TeleBoxRect, TeleBoxFullscreen } from "@netless/telebox-insider";
5
5
  import type { PageState } from "./Page";
@@ -81,6 +81,9 @@ export declare type Writeable<T> = {
81
81
  -readonly [P in keyof T]: T[P];
82
82
  };
83
83
  export declare type ManagerViewMode = `${ViewMode}` | "scroll";
84
+ export declare type MoveCameraParams = Partial<Camera> & {
85
+ animationMode?: AnimationMode;
86
+ };
84
87
  export type { AppContext } from "./App/AppContext";
85
88
  export type { WhiteBoardView } from "./App";
86
89
  export type { ReadonlyTeleBox, TeleBoxRect, TeleBoxFullscreen };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "1.0.0-canary.63",
3
+ "version": "1.0.0-canary.65",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -15,7 +15,7 @@ export type WhiteBoardViewRect = Omit<ISize, "id">;
15
15
 
16
16
  export class WhiteBoardView implements PageController {
17
17
  public readonly pageState$: ReadonlyVal<PageState>;
18
- public readonly baseCamera$: ReadonlyVal<WhiteBoardViewCamera>;
18
+ public readonly camera$: ReadonlyVal<WhiteBoardViewCamera>;
19
19
  public readonly baseRect$: ReadonlyVal<WhiteBoardViewRect | undefined>;
20
20
 
21
21
  constructor(
@@ -31,7 +31,7 @@ export class WhiteBoardView implements PageController {
31
31
  const camera$ = new Val<WhiteBoardViewCamera>(pickCamera(this.view.camera));
32
32
  this.baseRect$ = baseRect$;
33
33
  this.pageState$ = pageState$;
34
- this.baseCamera$ = camera$;
34
+ this.camera$ = camera$;
35
35
  this.appProxy.sideEffectManager.add(() => [
36
36
  appProxy.appEmitter.on("pageStateChange", pageState => pageState$.setValue(pageState)),
37
37
  appProxy.camera$.subscribe(camera => {
@@ -12,6 +12,7 @@ export class CameraSynchronizer {
12
12
  protected rect?: TeleBoxRect;
13
13
  protected view?: View;
14
14
  protected scale = 1;
15
+ protected cameraUpdating = false;
15
16
 
16
17
  constructor(protected saveCamera: SaveCamera) {}
17
18
 
@@ -75,7 +76,7 @@ export class CameraSynchronizer {
75
76
  }
76
77
 
77
78
  private moveCamera(camera: ICamera): void {
78
- if (!isEmpty(camera) && this.view && camera.centerX && camera.centerY) {
79
+ if (!isEmpty(camera) && this.view && camera.centerX != null && camera.centerY != null) {
79
80
  if (isEqual(camera, this.view.camera)) return;
80
81
  const { centerX, centerY, scale } = camera;
81
82
  const needScale = scale * (this.scale || 1);
@@ -12,6 +12,7 @@ import { ViewSync } from "./ViewSync";
12
12
  import type { ICamera, ISize } from "../AttributesDelegate";
13
13
  import type { Size, View } from "white-web-sdk";
14
14
  import type { AppManager } from "../AppManager";
15
+ import type { MoveCameraParams } from "../typings";
15
16
 
16
17
  export class MainViewProxy {
17
18
  private started = false;
@@ -24,6 +25,7 @@ export class MainViewProxy {
24
25
  public camera$ = new Val<ICamera | undefined>(undefined);
25
26
  public size$ = new Val<ISize | undefined>(undefined);
26
27
  public view$ = new Val<View | undefined>(undefined);
28
+ private cameraUpdatePromise?: Promise<boolean>;
27
29
 
28
30
  public viewSync?: ViewSync;
29
31
 
@@ -49,11 +51,6 @@ export class MainViewProxy {
49
51
  }
50
52
  }
51
53
  }));
52
- this.camera$.reaction(camera => {
53
- if (camera) {
54
- callbacks.emit("baseCameraChange", camera);
55
- }
56
- });
57
54
  this.size$.reaction(size => {
58
55
  if (size) {
59
56
  callbacks.emit("baseSizeChange", size);
@@ -105,6 +102,43 @@ export class MainViewProxy {
105
102
  }
106
103
  }
107
104
 
105
+ public moveCamera = (camera: MoveCameraParams) => {
106
+ this.debouncedStoreCamera();
107
+ this.moveCameraToPromise(camera);
108
+ };
109
+
110
+ public moveCameraToPromise = (camera: MoveCameraParams) => {
111
+ const promise = new Promise<boolean>((resolve) => {
112
+ const cameraListener = debounce(() => {
113
+ this.mainView.callbacks.off("onCameraUpdated", cameraListener);
114
+ this.cameraUpdatePromise = undefined;
115
+ resolve(true);
116
+ }, 50);
117
+ this.mainView.callbacks.on("onCameraUpdated", cameraListener);
118
+ this.mainView.moveCamera(camera);
119
+ });
120
+ this.cameraUpdatePromise = promise;
121
+ return promise;
122
+ }
123
+
124
+ private debouncedStoreCamera = () => {
125
+ this.storeCurrentSize();
126
+ const cameraListener = debounce(() => {
127
+ this.saveToCamera$();
128
+ this.storeCurrentCameraSize();
129
+ this.mainView.callbacks.off("onCameraUpdated", cameraListener);
130
+ }, 50);
131
+ this.mainView.callbacks.on("onCameraUpdated", cameraListener);
132
+ }
133
+
134
+ private storeCurrentCameraSize = debounce(async () => {
135
+ if (this.cameraUpdatePromise) {
136
+ await this.cameraUpdatePromise;
137
+ }
138
+ this.storeCurrentCamera();
139
+ this.storeCurrentSize();
140
+ }, 500);
141
+
108
142
  private get mainViewCamera() {
109
143
  return this.store.getMainViewCamera();
110
144
  }
@@ -146,11 +180,14 @@ export class MainViewProxy {
146
180
  public storeCurrentSize = () => {
147
181
  const rect = this.manager.boxManager?.stageRect;
148
182
  if (rect) {
149
- this.storeSize({
183
+ const size = {
150
184
  id: this.manager.uid,
151
185
  width: rect.width,
152
186
  height: rect.height
153
- });
187
+ }
188
+ if (!isEqual(size, this.mainViewSize)) {
189
+ this.storeSize(size);
190
+ }
154
191
  }
155
192
  }
156
193
 
@@ -76,6 +76,7 @@ export class ScrollMode {
76
76
 
77
77
  this.sideEffect.add(() => {
78
78
  const onCameraUpdated = (camera: Camera): void => {
79
+ if (!this.manager.canOperate) return;
79
80
  const halfWbHeight = size$.value.height / 2 / scale$.value;
80
81
  const scrollTop = camera.centerY;
81
82
  this.scrollStorage.setState({
package/src/callback.ts CHANGED
@@ -3,7 +3,7 @@ import type { TeleBoxColorScheme, TeleBoxFullscreen, TELE_BOX_STATE } from "@net
3
3
  import type { CameraState, SceneState, ViewVisionMode } from "white-web-sdk";
4
4
  import type { LoadAppEvent } from "./Register";
5
5
  import type { PageState } from "./Page";
6
- import type { ICamera, ISize } from "./AttributesDelegate";
6
+ import type { ISize } from "./AttributesDelegate";
7
7
  import type { ScrollState } from "./View/ScrollMode";
8
8
 
9
9
  export type PublicEvent = {
@@ -23,7 +23,6 @@ export type PublicEvent = {
23
23
  sceneStateChange: SceneState;
24
24
  pageStateChange: PageState;
25
25
  appClose: { appId: string; kind: string, error?: Error };
26
- baseCameraChange: ICamera;
27
26
  baseSizeChange: ISize;
28
27
  fullscreenChange: TeleBoxFullscreen;
29
28
  userScroll: undefined;
package/src/index.ts CHANGED
@@ -10,7 +10,7 @@ import { emitter } from "./InternalEmitter";
10
10
  import { Fields } from "./AttributesDelegate";
11
11
  import { initDb } from "./Register/storage";
12
12
  import { InvisiblePlugin, isPlayer, isRoom, RoomPhase, ViewMode } from "white-web-sdk";
13
- import { isEqual, isNull, isObject, isNumber, omit, debounce } from "lodash";
13
+ import { isEqual, isNull, isObject, isNumber, omit } from "lodash";
14
14
  import { log } from "./Utils/log";
15
15
  import { PageStateImpl } from "./PageState";
16
16
  import { ReconnectRefresher } from "./ReconnectRefresher";
@@ -49,7 +49,7 @@ import type {
49
49
  Rectangle,
50
50
  } from "white-web-sdk";
51
51
  import type { AppListeners } from "./AppListener";
52
- import type { ApplianceIcons, ManagerViewMode, NetlessApp, RegisterParams } from "./typings";
52
+ import type { ApplianceIcons, ManagerViewMode, MoveCameraParams, NetlessApp, RegisterParams } from "./typings";
53
53
  import type { TeleBoxColorScheme, TeleBoxFullscreen, TeleBoxManager, TeleBoxManagerThemeConfig, TeleBoxState } from "@netless/telebox-insider";
54
54
  import type { AppProxy } from "./App";
55
55
  import type { PublicEvent } from "./callback";
@@ -627,8 +627,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
627
627
  public setViewMode(mode: ManagerViewMode): void {
628
628
  log("setViewMode", mode);
629
629
  const mainViewProxy = this.appManager?.mainViewProxy;
630
- if (mode === ViewMode.Broadcaster) {
631
- if (this.canOperate) {
630
+ if (mode === ViewMode.Broadcaster || mode === ViewMode.Follower) {
631
+ if (this.canOperate && mode === ViewMode.Broadcaster) {
632
632
  mainViewProxy?.storeCurrentCamera();
633
633
  mainViewProxy?.storeCurrentSize();
634
634
  }
@@ -830,14 +830,13 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
830
830
  return this.appManager?.closeApp(appId);
831
831
  }
832
832
 
833
- public moveCamera = (camera: Partial<Camera> & { animationMode?: AnimationMode } ): void => {
833
+ public moveCamera = (camera: MoveCameraParams): void => {
834
834
  const pureCamera = omit(camera, ["animationMode"]);
835
835
  const mainViewCamera = { ...this.mainView.camera };
836
836
  if (isEqual({ ...mainViewCamera, ...pureCamera }, mainViewCamera)) return;
837
- this.debouncedStoreCamera();
838
- this.mainView.moveCamera(camera);
837
+ this.appManager?.mainViewProxy.moveCamera(camera);
839
838
  this.appManager?.dispatchInternalEvent(Events.MoveCamera, camera);
840
- };
839
+ }
841
840
 
842
841
  public moveCameraToContain(
843
842
  rectangle: Rectangle &
@@ -845,21 +844,11 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes, any>
845
844
  animationMode?: AnimationMode;
846
845
  }>
847
846
  ): void {
848
- this.debouncedStoreCamera();
847
+ // this.debouncedStoreCamera();
849
848
  this.mainView.moveCameraToContain(rectangle);
850
849
  this.appManager?.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
851
850
  }
852
851
 
853
- private debouncedStoreCamera = () => {
854
- const storeCamera = debounce(() => {
855
- this.appManager?.mainViewProxy.saveToCamera$();
856
- this.appManager?.mainViewProxy.storeCurrentCamera();
857
- this.appManager?.mainViewProxy.storeCurrentSize();
858
- this.mainView.callbacks.off("onCameraUpdated", storeCamera);
859
- }, 200);
860
- this.mainView.callbacks.on("onCameraUpdated", storeCamera);
861
- }
862
-
863
852
  public convertToPointInWorld(point: Point): Point {
864
853
  return this.mainView.convertToPointInWorld(point);
865
854
  }
package/src/typings.ts CHANGED
@@ -2,6 +2,7 @@ import type Emittery from "emittery";
2
2
  import type {
3
3
  AnimationMode,
4
4
  ApplianceNames,
5
+ Camera,
5
6
  Displayer,
6
7
  DisplayerState,
7
8
  Player,
@@ -93,6 +94,8 @@ export type Writeable<T> = { -readonly [P in keyof T]: T[P] };
93
94
 
94
95
  export type ManagerViewMode = `${ViewMode}` | "scroll";
95
96
 
97
+ export type MoveCameraParams = Partial<Camera> & { animationMode?: AnimationMode };
98
+
96
99
  export type { AppContext } from "./App/AppContext";
97
100
  export type { WhiteBoardView } from "./App";
98
101
  export type { ReadonlyTeleBox, TeleBoxRect, TeleBoxFullscreen };