@netless/window-manager 1.0.0-canary.14 → 1.0.0-canary.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "1.0.0-canary.14",
3
+ "version": "1.0.0-canary.15",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@juggle/resize-observer": "^3.3.1",
26
- "@netless/telebox-insider": "1.0.0-alpha.16",
26
+ "@netless/telebox-insider": "1.0.0-alpha.17",
27
27
  "emittery": "^0.9.2",
28
28
  "lodash": "^4.17.21",
29
29
  "p-retry": "^4.6.1",
package/pnpm-lock.yaml CHANGED
@@ -4,7 +4,7 @@ specifiers:
4
4
  '@juggle/resize-observer': ^3.3.1
5
5
  '@netless/app-docs-viewer': ^0.2.9
6
6
  '@netless/app-media-player': 0.1.0-beta.5
7
- '@netless/telebox-insider': 1.0.0-alpha.16
7
+ '@netless/telebox-insider': 1.0.0-alpha.17
8
8
  '@rollup/plugin-commonjs': ^20.0.0
9
9
  '@rollup/plugin-node-resolve': ^13.0.4
10
10
  '@rollup/plugin-url': ^6.1.0
@@ -43,7 +43,7 @@ specifiers:
43
43
 
44
44
  dependencies:
45
45
  '@juggle/resize-observer': registry.npmmirror.com/@juggle/resize-observer/3.3.1
46
- '@netless/telebox-insider': 1.0.0-alpha.16
46
+ '@netless/telebox-insider': 1.0.0-alpha.17
47
47
  emittery: registry.npmmirror.com/emittery/0.9.2
48
48
  lodash: registry.npmmirror.com/lodash/4.17.21
49
49
  p-retry: registry.npmmirror.com/p-retry/4.6.1
@@ -97,8 +97,8 @@ packages:
97
97
  vanilla-lazyload: 17.6.1
98
98
  dev: true
99
99
 
100
- /@netless/telebox-insider/1.0.0-alpha.16:
101
- resolution: {integrity: sha512-WoBhBMVXKqZuTYEhcDapYOX05ScvngcdCfcrc2fXHkH5PQxtWWwOc4G2X/stK8giHdlGlAkq+HdKTpQ1Ymn7Aw==}
100
+ /@netless/telebox-insider/1.0.0-alpha.17:
101
+ resolution: {integrity: sha512-FoiX5tKKT26EyDiO/gT4P7rhr9Pvkcf2RJuSPxt5PO0ij73vUaU6OwjXJzZkcnIZlHPHhleJoqt1difaJpmyLQ==}
102
102
  dependencies:
103
103
  '@juggle/resize-observer': 3.3.1
104
104
  '@types/shallowequal': 1.1.1
@@ -110,6 +110,12 @@ export class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOption
110
110
  this.ensurePageSize(size);
111
111
  }
112
112
  this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy, removeViewWrapper, this.ensurePageSize);
113
+ this.appProxy.sideEffectManager.add(() => {
114
+ return () => {
115
+ this.whiteBoardView?.destroy();
116
+ this.whiteBoardView = undefined;
117
+ }
118
+ });
113
119
  return this.whiteBoardView;
114
120
  }
115
121
 
@@ -61,7 +61,7 @@ export class AppProxy implements PageRemoveService {
61
61
  public appResult?: NetlessApp;
62
62
  public appContext?: AppContext;
63
63
 
64
- private sideEffectManager = new SideEffectManager();
64
+ public sideEffectManager = new SideEffectManager();
65
65
  private valManager = new ValManager();
66
66
 
67
67
  private fullPath$ = this.valManager.attach(new Val<string | undefined>(undefined));
@@ -589,8 +589,9 @@ export class AppProxy implements PageRemoveService {
589
589
  if (!this.camera$.value) {
590
590
  return;
591
591
  }
592
- const nextCamera = { ...this.camera$.value, ...camera };
592
+ const nextCamera = { ...this.camera$.value, ...camera, id: this.uid };
593
593
  this.storeCamera(nextCamera);
594
+ this.camera$.setValue(nextCamera);
594
595
  };
595
596
 
596
597
  public async destroy(
@@ -1,5 +1,6 @@
1
1
  import { putScenes } from "../Utils/Common";
2
2
  import { Val } from "value-enhancer";
3
+ import { pick } from "lodash";
3
4
 
4
5
  import type { ReadonlyVal } from "value-enhancer";
5
6
  import type { AddPageParams, PageController, PageState } from "../Page";
@@ -8,9 +9,11 @@ import type { AppContext } from "./AppContext";
8
9
  import type { Camera, View } from "white-web-sdk";
9
10
  import type { TeleBoxRect } from "@netless/telebox-insider";
10
11
 
12
+ export type WhiteBoardViewCamera = Omit<Camera, "scale">;
13
+
11
14
  export class WhiteBoardView implements PageController {
12
15
  public readonly pageState$: ReadonlyVal<PageState>;
13
- public readonly camera$: ReadonlyVal<Camera>;
16
+ public readonly camera$: ReadonlyVal<WhiteBoardViewCamera>;
14
17
 
15
18
  constructor(
16
19
  public view: View,
@@ -21,16 +24,22 @@ export class WhiteBoardView implements PageController {
21
24
  ) {
22
25
  const pageState$ = new Val<PageState>(appProxy.pageState);
23
26
  this.pageState$ = pageState$;
24
- appProxy.appEmitter.on("pageStateChange", pageState => {
25
- pageState$.setValue(pageState);
26
- });
27
- const camera$ = new Val<Camera, boolean>(this.view.camera);
28
- this.camera$ = camera$
29
- appProxy.camera$.subscribe(camera => {
30
- if (camera) {
31
- camera$.setValue(camera, true);
32
- }
33
- });
27
+ this.appProxy.sideEffectManager.add(() =>
28
+ appProxy.appEmitter.on("pageStateChange", pageState => {
29
+ pageState$.setValue(pageState);
30
+ })
31
+ );
32
+ const camera$ = new Val<WhiteBoardViewCamera>(
33
+ pick(this.view.camera, ["centerX", "centerY"])
34
+ );
35
+ this.camera$ = camera$;
36
+ this.appProxy.sideEffectManager.add(() =>
37
+ appProxy.camera$.subscribe(camera => {
38
+ if (camera) {
39
+ camera$.setValue(pick(camera, ["centerX", "centerY"]));
40
+ }
41
+ })
42
+ );
34
43
  view.disableCameraTransform = true;
35
44
  }
36
45
 
@@ -38,7 +47,7 @@ export class WhiteBoardView implements PageController {
38
47
  return this.pageState$.value;
39
48
  }
40
49
 
41
- public moveCamera(camera: Partial<Camera>) {
50
+ public moveCamera(camera: Partial<WhiteBoardViewCamera>) {
42
51
  this.appProxy.moveCamera(camera);
43
52
  }
44
53