@netless/window-manager 1.0.0-canary.73 → 1.0.0-canary.75

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.
@@ -2,6 +2,7 @@ import { SideEffectManager } from "side-effect-manager";
2
2
  import type { ReadonlyVal } from "value-enhancer";
3
3
  import type { AppManager } from "../AppManager";
4
4
  import type { ScrollStorage } from "../storage";
5
+ import type { View } from "white-web-sdk";
5
6
  export declare type ScrollState = {
6
7
  scrollTop: number;
7
8
  page: number;
@@ -13,14 +14,14 @@ export declare class ScrollMode {
13
14
  private readonly _root$;
14
15
  private readonly _whiteboard$;
15
16
  private readonly _scrollTop$;
16
- readonly _page$: ReadonlyVal<number>;
17
+ private readonly _page$;
17
18
  private readonly _scale$;
18
19
  private readonly _size$;
19
- private readonly _mainView$;
20
20
  private baseWidth;
21
21
  private baseHeight;
22
- scrollStorage: ScrollStorage;
22
+ readonly scrollStorage: ScrollStorage;
23
23
  readonly scrollState$: ReadonlyVal<ScrollState>;
24
+ get mainView(): View;
24
25
  setRoot(root: HTMLElement): void;
25
26
  constructor(manager: AppManager);
26
27
  private initScroll;
@@ -28,5 +29,6 @@ export declare class ScrollMode {
28
29
  private updateBound;
29
30
  dispose(): void;
30
31
  private getWhiteboardElement;
32
+ private shouldBroadcast;
31
33
  private onWheel;
32
34
  }
package/dist/index.js CHANGED
@@ -2557,12 +2557,12 @@ class ScrollMode {
2557
2557
  this.onWheel = (ev) => {
2558
2558
  var _a2;
2559
2559
  const target = ev.target;
2560
- if (this.manager.canOperate && ((_a2 = this._whiteboard$.value) == null ? void 0 : _a2.contains(target))) {
2560
+ if ((_a2 = this._whiteboard$.value) == null ? void 0 : _a2.contains(target)) {
2561
2561
  ev.preventDefault();
2562
2562
  ev.stopPropagation();
2563
2563
  const dy = ev.deltaY || 0;
2564
2564
  const { width } = this._size$.value;
2565
- if (dy && width > 0) {
2565
+ if (this.shouldBroadcast() && dy && width > 0) {
2566
2566
  const halfWbHeight = this._size$.value.height / 2 / this._scale$.value;
2567
2567
  const scrollTop = this._scrollTop$.value + dy / this._scale$.value;
2568
2568
  this.scrollStorage.setState({
@@ -2573,8 +2573,7 @@ class ScrollMode {
2573
2573
  }
2574
2574
  };
2575
2575
  this._root$ = new valueEnhancer.Val(null);
2576
- this._mainView$ = new valueEnhancer.Val(this.manager.mainView);
2577
- this._mainView$.value.disableCameraTransform = false;
2576
+ this.mainView.disableCameraTransform = false;
2578
2577
  if ((_a = manager.scrollBaseSize$) == null ? void 0 : _a.value) {
2579
2578
  this.baseWidth = manager.scrollBaseSize$.value.width;
2580
2579
  this.baseHeight = manager.scrollBaseSize$.value.height;
@@ -2594,9 +2593,9 @@ class ScrollMode {
2594
2593
  this._size$ = size$;
2595
2594
  this.sideEffect.add(() => {
2596
2595
  const onSizeUpdated = size$.setValue.bind(size$);
2597
- onSizeUpdated(this._mainView$.value.size);
2598
- this._mainView$.value.callbacks.on("onSizeUpdated", onSizeUpdated);
2599
- return () => this._mainView$.value.callbacks.off("onSizeUpdated", onSizeUpdated);
2596
+ onSizeUpdated(this.mainView.size);
2597
+ this.mainView.callbacks.on("onSizeUpdated", onSizeUpdated);
2598
+ return () => this.mainView.callbacks.off("onSizeUpdated", onSizeUpdated);
2600
2599
  });
2601
2600
  this.sideEffect.add(() => {
2602
2601
  const onCameraUpdated = (camera) => {
@@ -2609,8 +2608,8 @@ class ScrollMode {
2609
2608
  });
2610
2609
  callbacks.emit("userScroll");
2611
2610
  };
2612
- this._mainView$.value.callbacks.on("onCameraUpdatedByDevice", onCameraUpdated);
2613
- return () => this._mainView$.value.callbacks.off("onCameraUpdatedByDevice", onCameraUpdated);
2611
+ this.mainView.callbacks.on("onCameraUpdatedByDevice", onCameraUpdated);
2612
+ return () => this.mainView.callbacks.off("onCameraUpdatedByDevice", onCameraUpdated);
2614
2613
  });
2615
2614
  const scale$ = valueEnhancer.derive(size$, (size) => size.width / this.baseWidth);
2616
2615
  this._scale$ = scale$;
@@ -2677,25 +2676,28 @@ class ScrollMode {
2677
2676
  "initScroll"
2678
2677
  );
2679
2678
  }
2679
+ get mainView() {
2680
+ return this.manager.mainView;
2681
+ }
2680
2682
  setRoot(root) {
2681
2683
  this._root$.setValue(root);
2682
2684
  }
2683
2685
  updateScroll(scrollTop) {
2684
- this._mainView$.value.moveCamera({
2686
+ this.mainView.moveCamera({
2685
2687
  centerY: scrollTop,
2686
2688
  animationMode: whiteWebSdk.AnimationMode.Immediately
2687
2689
  });
2688
2690
  }
2689
2691
  updateBound(scrollTop, { height }, scale2) {
2690
2692
  if (scale2 > 0) {
2691
- this._mainView$.value.moveCameraToContain({
2693
+ this.mainView.moveCameraToContain({
2692
2694
  originX: 0,
2693
2695
  originY: scrollTop - height / scale2 / 2,
2694
2696
  width: this.baseWidth,
2695
2697
  height: height / scale2,
2696
2698
  animationMode: whiteWebSdk.AnimationMode.Immediately
2697
2699
  });
2698
- this._mainView$.value.setCameraBound({
2700
+ this.mainView.setCameraBound({
2699
2701
  damping: 1,
2700
2702
  maxContentMode: () => scale2,
2701
2703
  minContentMode: () => scale2,
@@ -2716,7 +2718,10 @@ class ScrollMode {
2716
2718
  this.scrollState$.destroy();
2717
2719
  this._page$.destroy();
2718
2720
  this._size$.destroy();
2719
- this._mainView$.destroy();
2721
+ }
2722
+ shouldBroadcast() {
2723
+ var _a;
2724
+ return this.manager.canOperate && ((_a = this.manager.room) == null ? void 0 : _a.disableDeviceInputs) === false;
2720
2725
  }
2721
2726
  }
2722
2727
  class AppManager {
@@ -12317,7 +12322,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
12317
12322
  const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
12318
12323
  constructor(context) {
12319
12324
  super(context);
12320
- this.version = "1.0.0-canary.73";
12325
+ this.version = "1.0.0-canary.75";
12321
12326
  this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.4.0", "@netless/synced-store": "^2.0.7", "@netless/telebox-insider": "1.0.0-alpha.37", "emittery": "^0.11.0", "jspdf": "^2.5.1", "lodash": "^4.17.21", "p-retry": "^5.1.2", "side-effect-manager": "^1.2.1", "uuid": "^9.0.0", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "1.0.0-canary.5", "@netless/app-plyr": "^0.2.4", "@playwright/test": "^1.28.1", "@rollup/plugin-commonjs": "^23.0.4", "@rollup/plugin-node-resolve": "^15.0.1", "@rollup/plugin-url": "^8.0.1", "@sveltejs/vite-plugin-svelte": "^2.0.2", "@tsconfig/svelte": "^3.0.0", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^9.0.0", "@typescript-eslint/eslint-plugin": "^5.46.1", "@typescript-eslint/parser": "^5.46.1", "@vitest/ui": "^0.25.7", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^8.29.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^4.0.0", "jsdom": "^19.0.0", "less": "^4.1.3", "prettier": "^2.8.1", "prettier-plugin-svelte": "^2.9.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^4.0.0", "svelte": "^3.54.0", "typescript": "^4.9.4", "vite": "^4.0.3", "vite-plugin-dts": "^1.7.1", "vitest": "^0.25.7", "white-web-sdk": "^2.16.40" } };
12322
12327
  this.emitter = callbacks;
12323
12328
  this.viewMode$ = new valueEnhancer.Val(whiteWebSdk.ViewMode.Broadcaster);
package/dist/index.mjs CHANGED
@@ -2537,12 +2537,12 @@ class ScrollMode {
2537
2537
  this.onWheel = (ev) => {
2538
2538
  var _a2;
2539
2539
  const target = ev.target;
2540
- if (this.manager.canOperate && ((_a2 = this._whiteboard$.value) == null ? void 0 : _a2.contains(target))) {
2540
+ if ((_a2 = this._whiteboard$.value) == null ? void 0 : _a2.contains(target)) {
2541
2541
  ev.preventDefault();
2542
2542
  ev.stopPropagation();
2543
2543
  const dy = ev.deltaY || 0;
2544
2544
  const { width } = this._size$.value;
2545
- if (dy && width > 0) {
2545
+ if (this.shouldBroadcast() && dy && width > 0) {
2546
2546
  const halfWbHeight = this._size$.value.height / 2 / this._scale$.value;
2547
2547
  const scrollTop = this._scrollTop$.value + dy / this._scale$.value;
2548
2548
  this.scrollStorage.setState({
@@ -2553,8 +2553,7 @@ class ScrollMode {
2553
2553
  }
2554
2554
  };
2555
2555
  this._root$ = new Val(null);
2556
- this._mainView$ = new Val(this.manager.mainView);
2557
- this._mainView$.value.disableCameraTransform = false;
2556
+ this.mainView.disableCameraTransform = false;
2558
2557
  if ((_a = manager.scrollBaseSize$) == null ? void 0 : _a.value) {
2559
2558
  this.baseWidth = manager.scrollBaseSize$.value.width;
2560
2559
  this.baseHeight = manager.scrollBaseSize$.value.height;
@@ -2574,9 +2573,9 @@ class ScrollMode {
2574
2573
  this._size$ = size$;
2575
2574
  this.sideEffect.add(() => {
2576
2575
  const onSizeUpdated = size$.setValue.bind(size$);
2577
- onSizeUpdated(this._mainView$.value.size);
2578
- this._mainView$.value.callbacks.on("onSizeUpdated", onSizeUpdated);
2579
- return () => this._mainView$.value.callbacks.off("onSizeUpdated", onSizeUpdated);
2576
+ onSizeUpdated(this.mainView.size);
2577
+ this.mainView.callbacks.on("onSizeUpdated", onSizeUpdated);
2578
+ return () => this.mainView.callbacks.off("onSizeUpdated", onSizeUpdated);
2580
2579
  });
2581
2580
  this.sideEffect.add(() => {
2582
2581
  const onCameraUpdated = (camera) => {
@@ -2589,8 +2588,8 @@ class ScrollMode {
2589
2588
  });
2590
2589
  callbacks.emit("userScroll");
2591
2590
  };
2592
- this._mainView$.value.callbacks.on("onCameraUpdatedByDevice", onCameraUpdated);
2593
- return () => this._mainView$.value.callbacks.off("onCameraUpdatedByDevice", onCameraUpdated);
2591
+ this.mainView.callbacks.on("onCameraUpdatedByDevice", onCameraUpdated);
2592
+ return () => this.mainView.callbacks.off("onCameraUpdatedByDevice", onCameraUpdated);
2594
2593
  });
2595
2594
  const scale$ = derive(size$, (size) => size.width / this.baseWidth);
2596
2595
  this._scale$ = scale$;
@@ -2657,25 +2656,28 @@ class ScrollMode {
2657
2656
  "initScroll"
2658
2657
  );
2659
2658
  }
2659
+ get mainView() {
2660
+ return this.manager.mainView;
2661
+ }
2660
2662
  setRoot(root) {
2661
2663
  this._root$.setValue(root);
2662
2664
  }
2663
2665
  updateScroll(scrollTop) {
2664
- this._mainView$.value.moveCamera({
2666
+ this.mainView.moveCamera({
2665
2667
  centerY: scrollTop,
2666
2668
  animationMode: AnimationMode.Immediately
2667
2669
  });
2668
2670
  }
2669
2671
  updateBound(scrollTop, { height }, scale2) {
2670
2672
  if (scale2 > 0) {
2671
- this._mainView$.value.moveCameraToContain({
2673
+ this.mainView.moveCameraToContain({
2672
2674
  originX: 0,
2673
2675
  originY: scrollTop - height / scale2 / 2,
2674
2676
  width: this.baseWidth,
2675
2677
  height: height / scale2,
2676
2678
  animationMode: AnimationMode.Immediately
2677
2679
  });
2678
- this._mainView$.value.setCameraBound({
2680
+ this.mainView.setCameraBound({
2679
2681
  damping: 1,
2680
2682
  maxContentMode: () => scale2,
2681
2683
  minContentMode: () => scale2,
@@ -2696,7 +2698,10 @@ class ScrollMode {
2696
2698
  this.scrollState$.destroy();
2697
2699
  this._page$.destroy();
2698
2700
  this._size$.destroy();
2699
- this._mainView$.destroy();
2701
+ }
2702
+ shouldBroadcast() {
2703
+ var _a;
2704
+ return this.manager.canOperate && ((_a = this.manager.room) == null ? void 0 : _a.disableDeviceInputs) === false;
2700
2705
  }
2701
2706
  }
2702
2707
  class AppManager {
@@ -12297,7 +12302,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
12297
12302
  const _WindowManager = class extends InvisiblePlugin {
12298
12303
  constructor(context) {
12299
12304
  super(context);
12300
- this.version = "1.0.0-canary.73";
12305
+ this.version = "1.0.0-canary.75";
12301
12306
  this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.4.0", "@netless/synced-store": "^2.0.7", "@netless/telebox-insider": "1.0.0-alpha.37", "emittery": "^0.11.0", "jspdf": "^2.5.1", "lodash": "^4.17.21", "p-retry": "^5.1.2", "side-effect-manager": "^1.2.1", "uuid": "^9.0.0", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "1.0.0-canary.5", "@netless/app-plyr": "^0.2.4", "@playwright/test": "^1.28.1", "@rollup/plugin-commonjs": "^23.0.4", "@rollup/plugin-node-resolve": "^15.0.1", "@rollup/plugin-url": "^8.0.1", "@sveltejs/vite-plugin-svelte": "^2.0.2", "@tsconfig/svelte": "^3.0.0", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^9.0.0", "@typescript-eslint/eslint-plugin": "^5.46.1", "@typescript-eslint/parser": "^5.46.1", "@vitest/ui": "^0.25.7", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^8.29.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^4.0.0", "jsdom": "^19.0.0", "less": "^4.1.3", "prettier": "^2.8.1", "prettier-plugin-svelte": "^2.9.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^4.0.0", "svelte": "^3.54.0", "typescript": "^4.9.4", "vite": "^4.0.3", "vite-plugin-dts": "^1.7.1", "vitest": "^0.25.7", "white-web-sdk": "^2.16.40" } };
12302
12307
  this.emitter = callbacks;
12303
12308
  this.viewMode$ = new Val(ViewMode.Broadcaster);
package/dist/index.umd.js CHANGED
@@ -2532,12 +2532,12 @@
2532
2532
  this.onWheel = (ev) => {
2533
2533
  var _a2;
2534
2534
  const target = ev.target;
2535
- if (this.manager.canOperate && ((_a2 = this._whiteboard$.value) == null ? void 0 : _a2.contains(target))) {
2535
+ if ((_a2 = this._whiteboard$.value) == null ? void 0 : _a2.contains(target)) {
2536
2536
  ev.preventDefault();
2537
2537
  ev.stopPropagation();
2538
2538
  const dy = ev.deltaY || 0;
2539
2539
  const { width } = this._size$.value;
2540
- if (dy && width > 0) {
2540
+ if (this.shouldBroadcast() && dy && width > 0) {
2541
2541
  const halfWbHeight = this._size$.value.height / 2 / this._scale$.value;
2542
2542
  const scrollTop = this._scrollTop$.value + dy / this._scale$.value;
2543
2543
  this.scrollStorage.setState({
@@ -2548,8 +2548,7 @@
2548
2548
  }
2549
2549
  };
2550
2550
  this._root$ = new valueEnhancer.Val(null);
2551
- this._mainView$ = new valueEnhancer.Val(this.manager.mainView);
2552
- this._mainView$.value.disableCameraTransform = false;
2551
+ this.mainView.disableCameraTransform = false;
2553
2552
  if ((_a = manager.scrollBaseSize$) == null ? void 0 : _a.value) {
2554
2553
  this.baseWidth = manager.scrollBaseSize$.value.width;
2555
2554
  this.baseHeight = manager.scrollBaseSize$.value.height;
@@ -2569,9 +2568,9 @@
2569
2568
  this._size$ = size$;
2570
2569
  this.sideEffect.add(() => {
2571
2570
  const onSizeUpdated = size$.setValue.bind(size$);
2572
- onSizeUpdated(this._mainView$.value.size);
2573
- this._mainView$.value.callbacks.on("onSizeUpdated", onSizeUpdated);
2574
- return () => this._mainView$.value.callbacks.off("onSizeUpdated", onSizeUpdated);
2571
+ onSizeUpdated(this.mainView.size);
2572
+ this.mainView.callbacks.on("onSizeUpdated", onSizeUpdated);
2573
+ return () => this.mainView.callbacks.off("onSizeUpdated", onSizeUpdated);
2575
2574
  });
2576
2575
  this.sideEffect.add(() => {
2577
2576
  const onCameraUpdated = (camera) => {
@@ -2584,8 +2583,8 @@
2584
2583
  });
2585
2584
  callbacks.emit("userScroll");
2586
2585
  };
2587
- this._mainView$.value.callbacks.on("onCameraUpdatedByDevice", onCameraUpdated);
2588
- return () => this._mainView$.value.callbacks.off("onCameraUpdatedByDevice", onCameraUpdated);
2586
+ this.mainView.callbacks.on("onCameraUpdatedByDevice", onCameraUpdated);
2587
+ return () => this.mainView.callbacks.off("onCameraUpdatedByDevice", onCameraUpdated);
2589
2588
  });
2590
2589
  const scale$ = valueEnhancer.derive(size$, (size) => size.width / this.baseWidth);
2591
2590
  this._scale$ = scale$;
@@ -2652,25 +2651,28 @@
2652
2651
  "initScroll"
2653
2652
  );
2654
2653
  }
2654
+ get mainView() {
2655
+ return this.manager.mainView;
2656
+ }
2655
2657
  setRoot(root) {
2656
2658
  this._root$.setValue(root);
2657
2659
  }
2658
2660
  updateScroll(scrollTop) {
2659
- this._mainView$.value.moveCamera({
2661
+ this.mainView.moveCamera({
2660
2662
  centerY: scrollTop,
2661
2663
  animationMode: whiteWebSdk.AnimationMode.Immediately
2662
2664
  });
2663
2665
  }
2664
2666
  updateBound(scrollTop, { height }, scale2) {
2665
2667
  if (scale2 > 0) {
2666
- this._mainView$.value.moveCameraToContain({
2668
+ this.mainView.moveCameraToContain({
2667
2669
  originX: 0,
2668
2670
  originY: scrollTop - height / scale2 / 2,
2669
2671
  width: this.baseWidth,
2670
2672
  height: height / scale2,
2671
2673
  animationMode: whiteWebSdk.AnimationMode.Immediately
2672
2674
  });
2673
- this._mainView$.value.setCameraBound({
2675
+ this.mainView.setCameraBound({
2674
2676
  damping: 1,
2675
2677
  maxContentMode: () => scale2,
2676
2678
  minContentMode: () => scale2,
@@ -2691,7 +2693,10 @@
2691
2693
  this.scrollState$.destroy();
2692
2694
  this._page$.destroy();
2693
2695
  this._size$.destroy();
2694
- this._mainView$.destroy();
2696
+ }
2697
+ shouldBroadcast() {
2698
+ var _a;
2699
+ return this.manager.canOperate && ((_a = this.manager.room) == null ? void 0 : _a.disableDeviceInputs) === false;
2695
2700
  }
2696
2701
  }
2697
2702
  class AppManager {
@@ -12292,7 +12297,7 @@
12292
12297
  const _WindowManager = class extends whiteWebSdk.InvisiblePlugin {
12293
12298
  constructor(context) {
12294
12299
  super(context);
12295
- this.version = "1.0.0-canary.73";
12300
+ this.version = "1.0.0-canary.75";
12296
12301
  this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.4.0", "@netless/synced-store": "^2.0.7", "@netless/telebox-insider": "1.0.0-alpha.37", "emittery": "^0.11.0", "jspdf": "^2.5.1", "lodash": "^4.17.21", "p-retry": "^5.1.2", "side-effect-manager": "^1.2.1", "uuid": "^9.0.0", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "1.0.0-canary.5", "@netless/app-plyr": "^0.2.4", "@playwright/test": "^1.28.1", "@rollup/plugin-commonjs": "^23.0.4", "@rollup/plugin-node-resolve": "^15.0.1", "@rollup/plugin-url": "^8.0.1", "@sveltejs/vite-plugin-svelte": "^2.0.2", "@tsconfig/svelte": "^3.0.0", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^9.0.0", "@typescript-eslint/eslint-plugin": "^5.46.1", "@typescript-eslint/parser": "^5.46.1", "@vitest/ui": "^0.25.7", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^8.29.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^4.0.0", "jsdom": "^19.0.0", "less": "^4.1.3", "prettier": "^2.8.1", "prettier-plugin-svelte": "^2.9.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^4.0.0", "svelte": "^3.54.0", "typescript": "^4.9.4", "vite": "^4.0.3", "vite-plugin-dts": "^1.7.1", "vitest": "^0.25.7", "white-web-sdk": "^2.16.40" } };
12297
12302
  this.emitter = callbacks;
12298
12303
  this.viewMode$ = new valueEnhancer.Val(whiteWebSdk.ViewMode.Broadcaster);
package/dist/shim.d.ts CHANGED
@@ -1,11 +1,5 @@
1
- import type { SvelteComponent } from "svelte";
1
+ /// <reference types="svelte" />
2
+ /// <reference types="vite/client" />
2
3
 
3
- declare module "*.svelte" {
4
- const app: SvelteComponent;
5
- export default app;
6
- }
7
-
8
- declare global {
9
- const __APP_VERSION__: string;
10
- const __APP_DEPENDENCIES__: Record<string, string>;
11
- }
4
+ declare const __APP_VERSION__: string;
5
+ declare const __APP_DEPENDENCIES__: Record<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "1.0.0-canary.73",
3
+ "version": "1.0.0-canary.75",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -26,26 +26,28 @@ export class ScrollMode {
26
26
  private readonly _root$: Val<HTMLElement | null>;
27
27
  private readonly _whiteboard$: ReadonlyVal<HTMLElement | null>;
28
28
  private readonly _scrollTop$: Val<number>;
29
- public readonly _page$: ReadonlyVal<number>;
29
+ private readonly _page$: ReadonlyVal<number>;
30
30
  private readonly _scale$: ReadonlyVal<number>;
31
31
  private readonly _size$: Val<Size>;
32
- private readonly _mainView$: Val<View>;
33
32
 
34
33
  private baseWidth = SCROLL_MODE_BASE_WIDTH;
35
34
  private baseHeight = SCROLL_MODE_BASE_HEIGHT;
36
35
 
37
- public scrollStorage: ScrollStorage;
36
+ public readonly scrollStorage: ScrollStorage;
38
37
  public readonly scrollState$: ReadonlyVal<ScrollState>;
39
38
 
39
+ get mainView() {
40
+ return this.manager.mainView;
41
+ }
42
+
40
43
  public setRoot(root: HTMLElement): void {
41
44
  this._root$.setValue(root);
42
45
  }
43
46
 
44
47
  constructor(private manager: AppManager) {
45
48
  this._root$ = new Val<HTMLElement | null>(null);
46
- this._mainView$ = new Val<View>(this.manager.mainView);
47
49
  // 滚动模式下确保 disableCameraTransform 为 false, 否则触摸屏无法滚动
48
- this._mainView$.value.disableCameraTransform = false;
50
+ this.mainView.disableCameraTransform = false;
49
51
 
50
52
  if (manager.scrollBaseSize$?.value) {
51
53
  this.baseWidth = manager.scrollBaseSize$.value.width;
@@ -69,9 +71,9 @@ export class ScrollMode {
69
71
  this._size$ = size$;
70
72
  this.sideEffect.add(() => {
71
73
  const onSizeUpdated = size$.setValue.bind(size$);
72
- onSizeUpdated(this._mainView$.value.size);
73
- this._mainView$.value.callbacks.on("onSizeUpdated", onSizeUpdated);
74
- return () => this._mainView$.value.callbacks.off("onSizeUpdated", onSizeUpdated);
74
+ onSizeUpdated(this.mainView.size);
75
+ this.mainView.callbacks.on("onSizeUpdated", onSizeUpdated);
76
+ return () => this.mainView.callbacks.off("onSizeUpdated", onSizeUpdated);
75
77
  });
76
78
 
77
79
  this.sideEffect.add(() => {
@@ -84,9 +86,9 @@ export class ScrollMode {
84
86
  });
85
87
  callbacks.emit("userScroll");
86
88
  };
87
- this._mainView$.value.callbacks.on("onCameraUpdatedByDevice", onCameraUpdated);
89
+ this.mainView.callbacks.on("onCameraUpdatedByDevice", onCameraUpdated);
88
90
  return () =>
89
- this._mainView$.value.callbacks.off("onCameraUpdatedByDevice", onCameraUpdated);
91
+ this.mainView.callbacks.off("onCameraUpdatedByDevice", onCameraUpdated);
90
92
  });
91
93
 
92
94
  const scale$ = derive(size$, size => size.width / this.baseWidth);
@@ -174,7 +176,7 @@ export class ScrollMode {
174
176
  };
175
177
 
176
178
  private updateScroll(scrollTop: number): void {
177
- this._mainView$.value.moveCamera({
179
+ this.mainView.moveCamera({
178
180
  centerY: scrollTop,
179
181
  animationMode: AnimationMode.Immediately,
180
182
  });
@@ -182,7 +184,7 @@ export class ScrollMode {
182
184
 
183
185
  private updateBound(scrollTop: number, { height }: Size, scale: number): void {
184
186
  if (scale > 0) {
185
- this._mainView$.value.moveCameraToContain({
187
+ this.mainView.moveCameraToContain({
186
188
  originX: 0,
187
189
  originY: scrollTop - height / scale / 2,
188
190
  width: this.baseWidth,
@@ -190,7 +192,7 @@ export class ScrollMode {
190
192
  animationMode: AnimationMode.Immediately,
191
193
  });
192
194
 
193
- this._mainView$.value.setCameraBound({
195
+ this.mainView.setCameraBound({
194
196
  damping: 1,
195
197
  maxContentMode: () => scale,
196
198
  minContentMode: () => scale,
@@ -212,7 +214,6 @@ export class ScrollMode {
212
214
  this.scrollState$.destroy();
213
215
  this._page$.destroy();
214
216
  this._size$.destroy();
215
- this._mainView$.destroy();
216
217
  }
217
218
 
218
219
  private getWhiteboardElement = (root: HTMLElement | null): HTMLElement | null => {
@@ -220,14 +221,18 @@ export class ScrollMode {
220
221
  return root && root.querySelector(className);
221
222
  };
222
223
 
224
+ private shouldBroadcast() {
225
+ return this.manager.canOperate && this.manager.room?.disableDeviceInputs === false;
226
+ }
227
+
223
228
  private onWheel = (ev: WheelEvent): void => {
224
229
  const target = ev.target as HTMLElement | null;
225
- if (this.manager.canOperate && this._whiteboard$.value?.contains(target)) {
230
+ if (this._whiteboard$.value?.contains(target)) {
226
231
  ev.preventDefault();
227
232
  ev.stopPropagation();
228
233
  const dy = ev.deltaY || 0;
229
234
  const { width } = this._size$.value;
230
- if (dy && width > 0) {
235
+ if (this.shouldBroadcast() && dy && width > 0) {
231
236
  const halfWbHeight = this._size$.value.height / 2 / this._scale$.value;
232
237
  const scrollTop = this._scrollTop$.value + dy / this._scale$.value;
233
238
  this.scrollStorage.setState({
package/src/shim.d.ts CHANGED
@@ -1,11 +1,5 @@
1
- import type { SvelteComponent } from "svelte";
1
+ /// <reference types="svelte" />
2
+ /// <reference types="vite/client" />
2
3
 
3
- declare module "*.svelte" {
4
- const app: SvelteComponent;
5
- export default app;
6
- }
7
-
8
- declare global {
9
- const __APP_VERSION__: string;
10
- const __APP_DEPENDENCIES__: Record<string, string>;
11
- }
4
+ declare const __APP_VERSION__: string;
5
+ declare const __APP_DEPENDENCIES__: Record<string, string>;