@netless/window-manager 1.0.0-canary.64 → 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
@@ -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) {
@@ -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) => {
@@ -2884,6 +2921,8 @@ class ScrollMode {
2884
2921
  });
2885
2922
  this.sideEffect.add(() => {
2886
2923
  const onCameraUpdated = (camera) => {
2924
+ if (!this.manager.canOperate)
2925
+ return;
2887
2926
  const halfWbHeight = size$.value.height / 2 / scale$.value;
2888
2927
  const scrollTop = camera.centerY;
2889
2928
  this.scrollStorage.setState({
@@ -12751,7 +12790,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
12751
12790
  const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
12752
12791
  constructor(context) {
12753
12792
  super(context);
12754
- this.version = "1.0.0-canary.64";
12793
+ this.version = "1.0.0-canary.65";
12755
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" } };
12756
12795
  this.emitter = callbacks;
12757
12796
  this.viewMode$ = new valueEnhancer.Val(whiteWebSdk.ViewMode.Broadcaster);
@@ -12759,29 +12798,14 @@ const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
12759
12798
  this.isReplay = whiteWebSdk.isPlayer(this.displayer);
12760
12799
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
12761
12800
  this.moveCamera = (camera) => {
12762
- var _a2;
12801
+ var _a2, _b;
12763
12802
  const pureCamera = lodash.omit(camera, ["animationMode"]);
12764
12803
  const mainViewCamera = __spreadValues({}, this.mainView.camera);
12765
12804
  if (lodash.isEqual(__spreadValues(__spreadValues({}, mainViewCamera), pureCamera), mainViewCamera))
12766
12805
  return;
12767
- this.debouncedStoreCamera();
12768
- this.mainView.moveCamera(camera);
12769
- (_a2 = this.appManager) == null ? void 0 : _a2.dispatchInternalEvent(Events.MoveCamera, camera);
12806
+ (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.moveCamera(camera);
12807
+ (_b = this.appManager) == null ? void 0 : _b.dispatchInternalEvent(Events.MoveCamera, camera);
12770
12808
  };
12771
- this.debouncedStoreCamera = () => {
12772
- const cameraListener = lodash.debounce(() => {
12773
- var _a2;
12774
- (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.saveToCamera$();
12775
- this.storeCamera();
12776
- this.mainView.callbacks.off("onCameraUpdated", cameraListener);
12777
- }, 50);
12778
- this.mainView.callbacks.on("onCameraUpdated", cameraListener);
12779
- };
12780
- this.storeCamera = lodash.debounce(() => {
12781
- var _a2, _b;
12782
- (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.storeCurrentCamera();
12783
- (_b = this.appManager) == null ? void 0 : _b.mainViewProxy.storeCurrentSize();
12784
- }, 300);
12785
12809
  _WindowManager.displayer = context.displayer;
12786
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" } };
12787
12811
  }
@@ -13349,7 +13373,6 @@ const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
13349
13373
  }
13350
13374
  moveCameraToContain(rectangle) {
13351
13375
  var _a2;
13352
- this.debouncedStoreCamera();
13353
13376
  this.mainView.moveCameraToContain(rectangle);
13354
13377
  (_a2 = this.appManager) == null ? void 0 : _a2.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
13355
13378
  }
package/dist/index.mjs CHANGED
@@ -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) {
@@ -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) => {
@@ -2879,6 +2916,8 @@ class ScrollMode {
2879
2916
  });
2880
2917
  this.sideEffect.add(() => {
2881
2918
  const onCameraUpdated = (camera) => {
2919
+ if (!this.manager.canOperate)
2920
+ return;
2882
2921
  const halfWbHeight = size$.value.height / 2 / scale$.value;
2883
2922
  const scrollTop = camera.centerY;
2884
2923
  this.scrollStorage.setState({
@@ -12746,7 +12785,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
12746
12785
  const _WindowManager = class extends InvisiblePlugin {
12747
12786
  constructor(context) {
12748
12787
  super(context);
12749
- this.version = "1.0.0-canary.64";
12788
+ this.version = "1.0.0-canary.65";
12750
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" } };
12751
12790
  this.emitter = callbacks;
12752
12791
  this.viewMode$ = new Val(ViewMode.Broadcaster);
@@ -12754,29 +12793,14 @@ const _WindowManager = class extends InvisiblePlugin {
12754
12793
  this.isReplay = isPlayer(this.displayer);
12755
12794
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
12756
12795
  this.moveCamera = (camera) => {
12757
- var _a2;
12796
+ var _a2, _b;
12758
12797
  const pureCamera = omit(camera, ["animationMode"]);
12759
12798
  const mainViewCamera = __spreadValues({}, this.mainView.camera);
12760
12799
  if (isEqual(__spreadValues(__spreadValues({}, mainViewCamera), pureCamera), mainViewCamera))
12761
12800
  return;
12762
- this.debouncedStoreCamera();
12763
- this.mainView.moveCamera(camera);
12764
- (_a2 = this.appManager) == null ? void 0 : _a2.dispatchInternalEvent(Events.MoveCamera, camera);
12801
+ (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.moveCamera(camera);
12802
+ (_b = this.appManager) == null ? void 0 : _b.dispatchInternalEvent(Events.MoveCamera, camera);
12765
12803
  };
12766
- this.debouncedStoreCamera = () => {
12767
- const cameraListener = debounce(() => {
12768
- var _a2;
12769
- (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.saveToCamera$();
12770
- this.storeCamera();
12771
- this.mainView.callbacks.off("onCameraUpdated", cameraListener);
12772
- }, 50);
12773
- this.mainView.callbacks.on("onCameraUpdated", cameraListener);
12774
- };
12775
- this.storeCamera = debounce(() => {
12776
- var _a2, _b;
12777
- (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.storeCurrentCamera();
12778
- (_b = this.appManager) == null ? void 0 : _b.mainViewProxy.storeCurrentSize();
12779
- }, 300);
12780
12804
  _WindowManager.displayer = context.displayer;
12781
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" } };
12782
12806
  }
@@ -13344,7 +13368,6 @@ const _WindowManager = class extends InvisiblePlugin {
13344
13368
  }
13345
13369
  moveCameraToContain(rectangle) {
13346
13370
  var _a2;
13347
- this.debouncedStoreCamera();
13348
13371
  this.mainView.moveCameraToContain(rectangle);
13349
13372
  (_a2 = this.appManager) == null ? void 0 : _a2.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
13350
13373
  }
package/dist/index.umd.js CHANGED
@@ -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) {
@@ -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) => {
@@ -2877,6 +2914,8 @@
2877
2914
  });
2878
2915
  this.sideEffect.add(() => {
2879
2916
  const onCameraUpdated = (camera) => {
2917
+ if (!this.manager.canOperate)
2918
+ return;
2880
2919
  const halfWbHeight = size$.value.height / 2 / scale$.value;
2881
2920
  const scrollTop = camera.centerY;
2882
2921
  this.scrollStorage.setState({
@@ -12744,7 +12783,7 @@
12744
12783
  const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
12745
12784
  constructor(context) {
12746
12785
  super(context);
12747
- this.version = "1.0.0-canary.64";
12786
+ this.version = "1.0.0-canary.65";
12748
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" } };
12749
12788
  this.emitter = callbacks;
12750
12789
  this.viewMode$ = new valueEnhancer.Val(whiteWebSdk.ViewMode.Broadcaster);
@@ -12752,29 +12791,14 @@
12752
12791
  this.isReplay = whiteWebSdk.isPlayer(this.displayer);
12753
12792
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
12754
12793
  this.moveCamera = (camera) => {
12755
- var _a2;
12794
+ var _a2, _b;
12756
12795
  const pureCamera = lodash.omit(camera, ["animationMode"]);
12757
12796
  const mainViewCamera = __spreadValues({}, this.mainView.camera);
12758
12797
  if (lodash.isEqual(__spreadValues(__spreadValues({}, mainViewCamera), pureCamera), mainViewCamera))
12759
12798
  return;
12760
- this.debouncedStoreCamera();
12761
- this.mainView.moveCamera(camera);
12762
- (_a2 = this.appManager) == null ? void 0 : _a2.dispatchInternalEvent(Events.MoveCamera, camera);
12799
+ (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.moveCamera(camera);
12800
+ (_b = this.appManager) == null ? void 0 : _b.dispatchInternalEvent(Events.MoveCamera, camera);
12763
12801
  };
12764
- this.debouncedStoreCamera = () => {
12765
- const cameraListener = lodash.debounce(() => {
12766
- var _a2;
12767
- (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.saveToCamera$();
12768
- this.storeCamera();
12769
- this.mainView.callbacks.off("onCameraUpdated", cameraListener);
12770
- }, 50);
12771
- this.mainView.callbacks.on("onCameraUpdated", cameraListener);
12772
- };
12773
- this.storeCamera = lodash.debounce(() => {
12774
- var _a2, _b;
12775
- (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.storeCurrentCamera();
12776
- (_b = this.appManager) == null ? void 0 : _b.mainViewProxy.storeCurrentSize();
12777
- }, 300);
12778
12802
  _WindowManager.displayer = context.displayer;
12779
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" } };
12780
12804
  }
@@ -13342,7 +13366,6 @@
13342
13366
  }
13343
13367
  moveCameraToContain(rectangle) {
13344
13368
  var _a2;
13345
- this.debouncedStoreCamera();
13346
13369
  this.mainView.moveCameraToContain(rectangle);
13347
13370
  (_a2 = this.appManager) == null ? void 0 : _a2.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
13348
13371
  }
@@ -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();
@@ -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,14 +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
- private storeCamera;
252
248
  convertToPointInWorld(point: Point): Point;
253
249
  setCameraBound(cameraBound: CameraBound): void;
254
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.64",
3
+ "version": "1.0.0-canary.65",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -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
 
@@ -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
 
@@ -100,6 +102,43 @@ export class MainViewProxy {
100
102
  }
101
103
  }
102
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
+
103
142
  private get mainViewCamera() {
104
143
  return this.store.getMainViewCamera();
105
144
  }
@@ -141,11 +180,14 @@ export class MainViewProxy {
141
180
  public storeCurrentSize = () => {
142
181
  const rect = this.manager.boxManager?.stageRect;
143
182
  if (rect) {
144
- this.storeSize({
183
+ const size = {
145
184
  id: this.manager.uid,
146
185
  width: rect.width,
147
186
  height: rect.height
148
- });
187
+ }
188
+ if (!isEqual(size, this.mainViewSize)) {
189
+ this.storeSize(size);
190
+ }
149
191
  }
150
192
  }
151
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/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";
@@ -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,25 +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 cameraListener = debounce(() => {
855
- this.appManager?.mainViewProxy.saveToCamera$();
856
- this.storeCamera();
857
- this.mainView.callbacks.off("onCameraUpdated", cameraListener);
858
- }, 50);
859
- this.mainView.callbacks.on("onCameraUpdated", cameraListener);
860
- }
861
-
862
- private storeCamera = debounce(() => {
863
- this.appManager?.mainViewProxy.storeCurrentCamera();
864
- this.appManager?.mainViewProxy.storeCurrentSize();
865
- }, 300);
866
-
867
852
  public convertToPointInWorld(point: Point): Point {
868
853
  return this.mainView.convertToPointInWorld(point);
869
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 };