@netless/window-manager 1.0.0-canary.51 → 1.0.0-canary.53

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.cjs.js CHANGED
@@ -525,9 +525,9 @@ const isRootDirPage = (scenePath) => {
525
525
  class CameraSynchronizer {
526
526
  constructor(saveCamera) {
527
527
  this.saveCamera = saveCamera;
528
- this.setRect = (rect) => {
528
+ this.setRect = (rect, updateCamera = true) => {
529
529
  this.rect = rect;
530
- if (this.remoteCamera && this.remoteSize) {
530
+ if (this.remoteCamera && this.remoteSize && updateCamera) {
531
531
  this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
532
532
  }
533
533
  };
@@ -545,6 +545,7 @@ class CameraSynchronizer {
545
545
  if (camera.centerY !== null) {
546
546
  config.centerY = camera.centerY;
547
547
  }
548
+ console.trace("moveCamera");
548
549
  this.moveCamera(config);
549
550
  }
550
551
  }, 10);
@@ -1441,7 +1442,7 @@ class ViewSync {
1441
1442
  };
1442
1443
  this.subscribeSize = () => {
1443
1444
  return this.context.size$.subscribe((size) => {
1444
- if (size) {
1445
+ if (size && this.isBroadcastMode) {
1445
1446
  this.synchronizer.onRemoteSizeUpdate(size);
1446
1447
  }
1447
1448
  });
@@ -1449,7 +1450,7 @@ class ViewSync {
1449
1450
  this.subscribeStageRect = () => {
1450
1451
  return this.context.stageRect$.subscribe((rect) => {
1451
1452
  if (rect) {
1452
- this.synchronizer.setRect(rect);
1453
+ this.synchronizer.setRect(rect, this.isBroadcastMode);
1453
1454
  }
1454
1455
  });
1455
1456
  };
@@ -1466,6 +1467,8 @@ class ViewSync {
1466
1467
  this.onCameraUpdatedByDevice = (camera) => {
1467
1468
  if (!camera)
1468
1469
  return;
1470
+ if (!this.isBroadcastMode)
1471
+ return;
1469
1472
  if (this.context.size$.value && this.context.stageRect$.value) {
1470
1473
  const diffScale = computedMinScale(this.context.size$.value, this.context.stageRect$.value);
1471
1474
  const remoteScale = camera.scale / diffScale;
@@ -1488,6 +1491,10 @@ class ViewSync {
1488
1491
  }
1489
1492
  });
1490
1493
  }
1494
+ get isBroadcastMode() {
1495
+ var _a;
1496
+ return ((_a = this.context.viewMode$) == null ? void 0 : _a.value) === whiteWebSdk.ViewMode.Broadcaster;
1497
+ }
1491
1498
  destroy() {
1492
1499
  this.sem.flushAll();
1493
1500
  }
@@ -2756,8 +2763,8 @@ class AppManager {
2756
2763
  this.onBoxMove = (payload) => {
2757
2764
  this.dispatchInternalEvent(Events.AppMove, payload);
2758
2765
  this.store.updateAppState(payload.appId, AppAttributes.Position, {
2759
- x: payload.x,
2760
- y: payload.y
2766
+ x: isNaN(payload.x) ? 0 : payload.x,
2767
+ y: isNaN(payload.y) ? 0 : payload.y
2761
2768
  });
2762
2769
  };
2763
2770
  this.onBoxResize = (payload) => {
@@ -11688,7 +11695,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
11688
11695
  const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
11689
11696
  constructor(context) {
11690
11697
  super(context);
11691
- this.version = "1.0.0-canary.51";
11698
+ this.version = "1.0.0-canary.53";
11692
11699
  this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@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.1.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.3.3", "@netless/app-plyr": "0.2.2", "@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": "^2.5.3", "vite-plugin-dts": "^1.2.1", "vitest": "^0.18.0", "white-web-sdk": "2.16.26" } };
11693
11700
  this.emitter = callbacks;
11694
11701
  this.viewMode = whiteWebSdk.ViewMode.Broadcaster;
package/dist/index.es.js CHANGED
@@ -518,9 +518,9 @@ const isRootDirPage = (scenePath) => {
518
518
  class CameraSynchronizer {
519
519
  constructor(saveCamera) {
520
520
  this.saveCamera = saveCamera;
521
- this.setRect = (rect) => {
521
+ this.setRect = (rect, updateCamera = true) => {
522
522
  this.rect = rect;
523
- if (this.remoteCamera && this.remoteSize) {
523
+ if (this.remoteCamera && this.remoteSize && updateCamera) {
524
524
  this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
525
525
  }
526
526
  };
@@ -538,6 +538,7 @@ class CameraSynchronizer {
538
538
  if (camera.centerY !== null) {
539
539
  config.centerY = camera.centerY;
540
540
  }
541
+ console.trace("moveCamera");
541
542
  this.moveCamera(config);
542
543
  }
543
544
  }, 10);
@@ -1434,7 +1435,7 @@ class ViewSync {
1434
1435
  };
1435
1436
  this.subscribeSize = () => {
1436
1437
  return this.context.size$.subscribe((size2) => {
1437
- if (size2) {
1438
+ if (size2 && this.isBroadcastMode) {
1438
1439
  this.synchronizer.onRemoteSizeUpdate(size2);
1439
1440
  }
1440
1441
  });
@@ -1442,7 +1443,7 @@ class ViewSync {
1442
1443
  this.subscribeStageRect = () => {
1443
1444
  return this.context.stageRect$.subscribe((rect) => {
1444
1445
  if (rect) {
1445
- this.synchronizer.setRect(rect);
1446
+ this.synchronizer.setRect(rect, this.isBroadcastMode);
1446
1447
  }
1447
1448
  });
1448
1449
  };
@@ -1459,6 +1460,8 @@ class ViewSync {
1459
1460
  this.onCameraUpdatedByDevice = (camera) => {
1460
1461
  if (!camera)
1461
1462
  return;
1463
+ if (!this.isBroadcastMode)
1464
+ return;
1462
1465
  if (this.context.size$.value && this.context.stageRect$.value) {
1463
1466
  const diffScale = computedMinScale(this.context.size$.value, this.context.stageRect$.value);
1464
1467
  const remoteScale = camera.scale / diffScale;
@@ -1481,6 +1484,10 @@ class ViewSync {
1481
1484
  }
1482
1485
  });
1483
1486
  }
1487
+ get isBroadcastMode() {
1488
+ var _a;
1489
+ return ((_a = this.context.viewMode$) == null ? void 0 : _a.value) === ViewMode.Broadcaster;
1490
+ }
1484
1491
  destroy() {
1485
1492
  this.sem.flushAll();
1486
1493
  }
@@ -2749,8 +2756,8 @@ class AppManager {
2749
2756
  this.onBoxMove = (payload) => {
2750
2757
  this.dispatchInternalEvent(Events.AppMove, payload);
2751
2758
  this.store.updateAppState(payload.appId, AppAttributes.Position, {
2752
- x: payload.x,
2753
- y: payload.y
2759
+ x: isNaN(payload.x) ? 0 : payload.x,
2760
+ y: isNaN(payload.y) ? 0 : payload.y
2754
2761
  });
2755
2762
  };
2756
2763
  this.onBoxResize = (payload) => {
@@ -11681,7 +11688,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
11681
11688
  const _WindowManager = class extends InvisiblePlugin {
11682
11689
  constructor(context) {
11683
11690
  super(context);
11684
- this.version = "1.0.0-canary.51";
11691
+ this.version = "1.0.0-canary.53";
11685
11692
  this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@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.1.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.3.3", "@netless/app-plyr": "0.2.2", "@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": "^2.5.3", "vite-plugin-dts": "^1.2.1", "vitest": "^0.18.0", "white-web-sdk": "2.16.26" } };
11686
11693
  this.emitter = callbacks;
11687
11694
  this.viewMode = ViewMode.Broadcaster;
package/dist/index.umd.js CHANGED
@@ -519,9 +519,9 @@ var __objRest = (source, exclude) => {
519
519
  class CameraSynchronizer {
520
520
  constructor(saveCamera) {
521
521
  this.saveCamera = saveCamera;
522
- this.setRect = (rect) => {
522
+ this.setRect = (rect, updateCamera = true) => {
523
523
  this.rect = rect;
524
- if (this.remoteCamera && this.remoteSize) {
524
+ if (this.remoteCamera && this.remoteSize && updateCamera) {
525
525
  this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
526
526
  }
527
527
  };
@@ -539,6 +539,7 @@ var __objRest = (source, exclude) => {
539
539
  if (camera.centerY !== null) {
540
540
  config.centerY = camera.centerY;
541
541
  }
542
+ console.trace("moveCamera");
542
543
  this.moveCamera(config);
543
544
  }
544
545
  }, 10);
@@ -1435,7 +1436,7 @@ var __objRest = (source, exclude) => {
1435
1436
  };
1436
1437
  this.subscribeSize = () => {
1437
1438
  return this.context.size$.subscribe((size) => {
1438
- if (size) {
1439
+ if (size && this.isBroadcastMode) {
1439
1440
  this.synchronizer.onRemoteSizeUpdate(size);
1440
1441
  }
1441
1442
  });
@@ -1443,7 +1444,7 @@ var __objRest = (source, exclude) => {
1443
1444
  this.subscribeStageRect = () => {
1444
1445
  return this.context.stageRect$.subscribe((rect) => {
1445
1446
  if (rect) {
1446
- this.synchronizer.setRect(rect);
1447
+ this.synchronizer.setRect(rect, this.isBroadcastMode);
1447
1448
  }
1448
1449
  });
1449
1450
  };
@@ -1460,6 +1461,8 @@ var __objRest = (source, exclude) => {
1460
1461
  this.onCameraUpdatedByDevice = (camera) => {
1461
1462
  if (!camera)
1462
1463
  return;
1464
+ if (!this.isBroadcastMode)
1465
+ return;
1463
1466
  if (this.context.size$.value && this.context.stageRect$.value) {
1464
1467
  const diffScale = computedMinScale(this.context.size$.value, this.context.stageRect$.value);
1465
1468
  const remoteScale = camera.scale / diffScale;
@@ -1482,6 +1485,10 @@ var __objRest = (source, exclude) => {
1482
1485
  }
1483
1486
  });
1484
1487
  }
1488
+ get isBroadcastMode() {
1489
+ var _a;
1490
+ return ((_a = this.context.viewMode$) == null ? void 0 : _a.value) === whiteWebSdk.ViewMode.Broadcaster;
1491
+ }
1485
1492
  destroy() {
1486
1493
  this.sem.flushAll();
1487
1494
  }
@@ -2750,8 +2757,8 @@ var __objRest = (source, exclude) => {
2750
2757
  this.onBoxMove = (payload) => {
2751
2758
  this.dispatchInternalEvent(Events.AppMove, payload);
2752
2759
  this.store.updateAppState(payload.appId, AppAttributes.Position, {
2753
- x: payload.x,
2754
- y: payload.y
2760
+ x: isNaN(payload.x) ? 0 : payload.x,
2761
+ y: isNaN(payload.y) ? 0 : payload.y
2755
2762
  });
2756
2763
  };
2757
2764
  this.onBoxResize = (payload) => {
@@ -11682,7 +11689,7 @@ var __objRest = (source, exclude) => {
11682
11689
  const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
11683
11690
  constructor(context) {
11684
11691
  super(context);
11685
- this.version = "1.0.0-canary.51";
11692
+ this.version = "1.0.0-canary.53";
11686
11693
  this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@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.1.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.3.3", "@netless/app-plyr": "0.2.2", "@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": "^2.5.3", "vite-plugin-dts": "^1.2.1", "vitest": "^0.18.0", "white-web-sdk": "2.16.26" } };
11687
11694
  this.emitter = callbacks;
11688
11695
  this.viewMode = whiteWebSdk.ViewMode.Broadcaster;
@@ -9,7 +9,7 @@ export declare class CameraSynchronizer {
9
9
  protected rect?: TeleBoxRect;
10
10
  protected view?: View;
11
11
  constructor(saveCamera: SaveCamera);
12
- setRect: (rect: TeleBoxRect) => void;
12
+ setRect: (rect: TeleBoxRect, updateCamera?: boolean) => void;
13
13
  setView(view: View): void;
14
14
  onRemoteUpdate: import("lodash").DebouncedFunc<(camera: ICamera, size: ISize) => void>;
15
15
  onRemoteSizeUpdate(size: ISize): void;
@@ -18,6 +18,7 @@ export declare class ViewSync {
18
18
  private sem;
19
19
  private synchronizer;
20
20
  constructor(context: ViewSyncContext);
21
+ private get isBroadcastMode();
21
22
  private createSynchronizer;
22
23
  private subscribeView;
23
24
  private subscribeCamera;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "1.0.0-canary.51",
3
+ "version": "1.0.0-canary.53",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
package/src/AppManager.ts CHANGED
@@ -376,8 +376,8 @@ export class AppManager {
376
376
  private onBoxMove = (payload: BoxMovePayload) => {
377
377
  this.dispatchInternalEvent(Events.AppMove, payload);
378
378
  this.store.updateAppState(payload.appId, AppAttributes.Position, {
379
- x: payload.x,
380
- y: payload.y,
379
+ x: isNaN(payload.x) ? 0 : payload.x,
380
+ y: isNaN(payload.y) ? 0 : payload.y,
381
381
  });
382
382
  };
383
383
 
package/src/BoxManager.ts CHANGED
@@ -355,7 +355,7 @@ export class BoxManager {
355
355
  public moveBox({ appId, x, y }: MoveBoxParams): void {
356
356
  const box = this.getBox(appId);
357
357
  if (box) {
358
- box._intrinsicCoord$.setValue({ x, y}, true);
358
+ box._intrinsicCoord$.setValue({ x, y }, true);
359
359
  }
360
360
  }
361
361
 
@@ -14,9 +14,9 @@ export class CameraSynchronizer {
14
14
 
15
15
  constructor(protected saveCamera: SaveCamera) {}
16
16
 
17
- public setRect = (rect: TeleBoxRect) => {
17
+ public setRect = (rect: TeleBoxRect, updateCamera = true) => {
18
18
  this.rect = rect;
19
- if (this.remoteCamera && this.remoteSize) {
19
+ if (this.remoteCamera && this.remoteSize && updateCamera) {
20
20
  this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
21
21
  }
22
22
  }
@@ -40,6 +40,7 @@ export class CameraSynchronizer {
40
40
  if (camera.centerY !== null) {
41
41
  config.centerY = camera.centerY;
42
42
  }
43
+ console.trace("moveCamera");
43
44
  this.moveCamera(config);
44
45
  }
45
46
  }, 10);
@@ -47,6 +47,10 @@ export class ViewSync {
47
47
  });
48
48
  }
49
49
 
50
+ private get isBroadcastMode() {
51
+ return this.context.viewMode$?.value === ViewMode.Broadcaster;
52
+ }
53
+
50
54
  private createSynchronizer = () => {
51
55
  return new CameraSynchronizer((camera: ICamera) => {
52
56
  this.context.camera$.setValue(camera, true);
@@ -86,7 +90,7 @@ export class ViewSync {
86
90
 
87
91
  private subscribeSize = () => {
88
92
  return this.context.size$.subscribe(size => {
89
- if (size) {
93
+ if (size && this.isBroadcastMode) {
90
94
  this.synchronizer.onRemoteSizeUpdate(size);
91
95
  }
92
96
  });
@@ -95,7 +99,7 @@ export class ViewSync {
95
99
  private subscribeStageRect = () => {
96
100
  return this.context.stageRect$.subscribe(rect => {
97
101
  if (rect) {
98
- this.synchronizer.setRect(rect);
102
+ this.synchronizer.setRect(rect, this.isBroadcastMode);
99
103
  }
100
104
  });
101
105
  }
@@ -113,6 +117,7 @@ export class ViewSync {
113
117
 
114
118
  private onCameraUpdatedByDevice = (camera: Camera) => {
115
119
  if (!camera) return;
120
+ if (!this.isBroadcastMode) return;
116
121
  if (this.context.size$.value && this.context.stageRect$.value) {
117
122
  // 始终以远端的 size 为标准, 设置到 attributes 时根据尺寸的大小还原回去
118
123
  const diffScale = computedMinScale(this.context.size$.value, this.context.stageRect$.value);