@netless/window-manager 0.3.8 → 0.3.9-canary.0

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": "0.3.8",
3
+ "version": "0.3.9-canary.0",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
@@ -56,6 +56,6 @@
56
56
  "typescript": "^4.3.5",
57
57
  "video.js": "^7.14.3",
58
58
  "vite": "^2.5.3",
59
- "white-web-sdk": "^2.15.8"
59
+ "white-web-sdk": "^2.15.11"
60
60
  }
61
61
  }
package/src/AppManager.ts CHANGED
@@ -202,10 +202,11 @@ export class AppManager {
202
202
 
203
203
  private afterAddApp(appProxy: AppProxy | undefined) {
204
204
  if (appProxy && appProxy.box) {
205
+ const box = appProxy.box;
205
206
  emitter.emit("move", {
206
207
  appId: appProxy.id,
207
- x: appProxy.box?.x,
208
- y: appProxy.box?.y,
208
+ x: box?.intrinsicX,
209
+ y: box?.intrinsicY,
209
210
  });
210
211
  }
211
212
  if (this.boxManager.minimized) {
package/src/MainView.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { AnimationMode, reaction, ViewVisionMode } from 'white-web-sdk';
2
- import { Base } from './Base';
3
- import { callbacks, emitter } from './index';
4
- import { debounce, isEmpty, isEqual } from 'lodash';
5
- import { Fields } from './AttributesDelegate';
6
- import { notifyMainViewModeChange, setViewFocusScenePath, setViewMode } from './Utils/Common';
1
+ import { AnimationMode, reaction, ViewVisionMode } from "white-web-sdk";
2
+ import { Base } from "./Base";
3
+ import { callbacks, emitter } from "./index";
4
+ import { createView } from "./ViewManager";
5
+ import { debounce, isEmpty, isEqual } from "lodash";
6
+ import { Fields } from "./AttributesDelegate";
7
+ import { notifyMainViewModeChange, setViewFocusScenePath, setViewMode } from "./Utils/Common";
7
8
  import type { Camera, Size, View } from "white-web-sdk";
8
9
  import type { AppManager } from "./AppManager";
9
10
 
@@ -24,7 +25,7 @@ export class MainViewProxy extends Base {
24
25
  setTimeout(() => {
25
26
  this.start();
26
27
  }, 200); // 等待 mainView 挂载完毕再进行监听,否则会触发不必要的 onSizeUpdated
27
- })
28
+ });
28
29
  }
29
30
 
30
31
  private get mainViewCamera() {
@@ -50,7 +51,7 @@ export class MainViewProxy extends Base {
50
51
  }
51
52
 
52
53
  public setCameraAndSize(): void {
53
- this.store.setMainViewCamera({ ...this.mainView.camera, id: this.context.uid });
54
+ this.store.setMainViewCamera({ ...this.mainView.camera, id: this.context.uid });
54
55
  this.store.setMainViewSize({ ...this.mainView.size, id: this.context.uid });
55
56
  }
56
57
 
@@ -65,8 +66,8 @@ export class MainViewProxy extends Base {
65
66
  {
66
67
  fireImmediately: true,
67
68
  }
68
- )
69
- }
69
+ );
70
+ };
70
71
 
71
72
  private sizeReaction = () => {
72
73
  return reaction(
@@ -80,15 +81,15 @@ export class MainViewProxy extends Base {
80
81
  {
81
82
  fireImmediately: true,
82
83
  }
83
- )
84
- }
84
+ );
85
+ };
85
86
 
86
87
  public get view(): View {
87
88
  return this.mainView;
88
89
  }
89
90
 
90
91
  public createMainView(): View {
91
- const mainView = this.manager.displayer.views.createView();
92
+ const mainView = createView(this.manager.displayer);
92
93
  mainView.callbacks.on("onSizeUpdated", () => {
93
94
  this.context.updateManagerRect();
94
95
  });
@@ -103,11 +104,11 @@ export class MainViewProxy extends Base {
103
104
  }
104
105
 
105
106
  private cameraListener = (camera: Camera) => {
106
- this.store.setMainViewCamera({ ...camera, id: this.context.uid});
107
+ this.store.setMainViewCamera({ ...camera, id: this.context.uid });
107
108
  if (this.store.getMainViewSize()?.id !== this.context.uid) {
108
109
  this.setMainViewSize(this.view.size);
109
110
  }
110
- }
111
+ };
111
112
 
112
113
  public addMainViewListener(): void {
113
114
  if (this.mainViewIsAddListener) return;
@@ -138,7 +139,7 @@ export class MainViewProxy extends Base {
138
139
 
139
140
  private sizeListener = (size: Size) => {
140
141
  this.setMainViewSize(size);
141
- }
142
+ };
142
143
 
143
144
  public setMainViewSize = debounce(size => {
144
145
  this.store.setMainViewSize({ ...size, id: this.context.uid });
package/src/index.ts CHANGED
@@ -169,7 +169,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
169
169
  public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
170
170
  private static isCreated = false;
171
171
 
172
- public version = "0.3.8";
172
+ public version = "0.3.9-canary.0";
173
173
 
174
174
  public appListeners?: AppListeners;
175
175
 
@@ -3,7 +3,7 @@ import { callbacks, WindowManager } from "./index";
3
3
  import { reaction, ViewVisionMode } from "white-web-sdk";
4
4
  import { SET_SCENEPATH_DELAY } from "./constants";
5
5
  import { notifyMainViewModeChange, setScenePath, setViewMode } from "./Utils/Common";
6
- import type { View } from "white-web-sdk";
6
+ import type { View, Displayer } from "white-web-sdk";
7
7
  import type { AppManager } from "./AppManager";
8
8
 
9
9
  export class ViewManager extends Base {
@@ -44,7 +44,7 @@ export class ViewManager extends Base {
44
44
  }
45
45
 
46
46
  public createView(appId: string): View {
47
- const view = this.displayer.views.createView();
47
+ const view = createView(this.displayer);
48
48
  setViewMode(view, ViewVisionMode.Freedom);
49
49
  this.views.set(appId, view);
50
50
  return view;
@@ -134,6 +134,19 @@ export class ViewManager extends Base {
134
134
  }
135
135
  }
136
136
 
137
+ export const createView = (displayer: Displayer): View => {
138
+ const view = displayer.views.createView();
139
+ setDefaultCameraBound(view);
140
+ return view;
141
+ };
142
+
143
+ export const setDefaultCameraBound = (view: View) => {
144
+ view.setCameraBound({
145
+ maxContentMode: () => 10,
146
+ minContentMode: () => 0.1,
147
+ });
148
+ };
149
+
137
150
  export const setupWrapper = (
138
151
  root: HTMLElement
139
152
  ): {