@netless/window-manager 0.2.15 → 0.2.19-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.2.15",
3
+ "version": "0.2.19-canary.0",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
package/src/AppContext.ts CHANGED
@@ -31,7 +31,7 @@ export class AppContext<TAttrs extends Record<string, any>, AppOptions = any> {
31
31
  unlistenDisposed
32
32
  };
33
33
  private boxManager: BoxManager;
34
- private delegate = this.manager.delegate;
34
+ private store = this.manager.store;
35
35
  public readonly isAddApp: boolean;
36
36
 
37
37
  constructor(
@@ -54,7 +54,7 @@ export class AppContext<TAttrs extends Record<string, any>, AppOptions = any> {
54
54
  }
55
55
 
56
56
  public getScenes(): SceneDefinition[] | undefined {
57
- const appAttr = this.delegate.getAppAttributes(this.appId);
57
+ const appAttr = this.store.getAppAttributes(this.appId);
58
58
  if (appAttr?.isDynamicPPT) {
59
59
  const appProxy = this.manager.appProxies.get(this.appId);
60
60
  if (appProxy) {
@@ -2,10 +2,8 @@ import { Events, MagixEventName } from './constants';
2
2
  import { ViewVisionMode } from 'white-web-sdk';
3
3
  import type { Event } from "white-web-sdk";
4
4
  import type { TeleBox } from "@netless/telebox-insider";
5
- import type { ViewManager } from "./ViewManager";
6
5
  import type { AppProxy } from "./AppProxy";
7
6
  import type { AppManager } from "./AppManager";
8
- import type { WindowManager } from "./index";
9
7
 
10
8
  export class AppListeners {
11
9
  private displayer = this.manager.displayer;
@@ -13,8 +11,6 @@ export class AppListeners {
13
11
 
14
12
  constructor(
15
13
  private manager: AppManager,
16
- private windowManager: WindowManager,
17
- private viewManager: ViewManager,
18
14
  private appProxies: Map<string, AppProxy>
19
15
  ) {}
20
16
 
package/src/AppManager.ts CHANGED
@@ -10,11 +10,12 @@ import { AttributesDelegate } from './AttributesDelegate';
10
10
  import { BoxManager, TELE_BOX_STATE } from './BoxManager';
11
11
  import { callbacks, emitter } from './index';
12
12
  import { CameraStore } from './Utils/CameraStore';
13
- import { genAppId, makeValidScenePath } from './Utils/Common';
13
+ import { genAppId, makeValidScenePath, setScenePath } from './Utils/Common';
14
14
  import {
15
15
  isPlayer,
16
16
  isRoom,
17
- ScenePathType
17
+ ScenePathType,
18
+ ViewVisionMode
18
19
  } from 'white-web-sdk';
19
20
  import { log } from './Utils/log';
20
21
  import { MainViewProxy } from './MainView';
@@ -24,7 +25,6 @@ import { ViewManager } from './ViewManager';
24
25
  import type { Displayer, DisplayerState, Room } from "white-web-sdk";
25
26
  import type { CreateCollectorConfig } from "./BoxManager";
26
27
  import type { AddAppParams, BaseInsertParams, WindowManager } from "./index";
27
-
28
28
  export class AppManager {
29
29
  public displayer: Displayer;
30
30
  public boxManager: BoxManager;
@@ -32,7 +32,7 @@ export class AppManager {
32
32
  public viewManager: ViewManager;
33
33
  public appProxies: Map<string, AppProxy> = new Map();
34
34
  public appStatus: Map<string, AppStatus> = new Map();
35
- public delegate = new AttributesDelegate(this);
35
+ public store = new AttributesDelegate(this);
36
36
  public mainViewProxy: MainViewProxy;
37
37
  public refresher?: ReconnectRefresher;
38
38
 
@@ -42,28 +42,24 @@ export class AppManager {
42
42
  constructor(public windowManger: WindowManager, options: CreateCollectorConfig) {
43
43
  this.displayer = windowManger.displayer;
44
44
  this.cameraStore = new CameraStore();
45
+ this.mainViewProxy = new MainViewProxy(this);
45
46
  this.viewManager = new ViewManager(this.displayer as Room, this, this.cameraStore);
46
- this.boxManager = new BoxManager(this, this.viewManager.mainView, this.appProxies, options);
47
- this.appListeners = new AppListeners(
48
- this,
49
- this.windowManger,
50
- this.viewManager,
51
- this.appProxies
52
- );
47
+ this.boxManager = new BoxManager(this, this.mainViewProxy.view, this.appProxies, options);
48
+ this.appListeners = new AppListeners(this, this.appProxies);
53
49
  this.displayer.callbacks.on(this.eventName, this.displayerStateListener);
54
50
  this.appListeners.addListeners();
55
51
 
56
52
  this.refresher = new ReconnectRefresher(this.room, this);
57
53
 
58
- this.mainViewProxy = new MainViewProxy(this);
59
-
60
54
  emitter.once("onCreated").then(() => this.onCreated());
61
55
 
62
56
  if (isPlayer(this.displayer)) {
63
57
  emitter.on("seek", time => {
64
- this.appProxies.forEach(appProxy => appProxy.appEmitter.emit("seek", time));
58
+ this.appProxies.forEach(appProxy => {
59
+ appProxy.onSeek(time);
60
+ });
65
61
  this.attributesUpdateCallback(this.attributes.apps);
66
- })
62
+ });
67
63
  }
68
64
  }
69
65
 
@@ -81,7 +77,7 @@ export class AppManager {
81
77
  });
82
78
  });
83
79
  if (!this.attributes.apps || Object.keys(this.attributes.apps).length === 0) {
84
- const mainScenePath = this.delegate.getMainViewScenePath();
80
+ const mainScenePath = this.store.getMainViewScenePath();
85
81
  if (!mainScenePath) return;
86
82
  const sceneState = this.displayer.state.sceneState;
87
83
  if (sceneState.scenePath !== mainScenePath) {
@@ -127,6 +123,23 @@ export class AppManager {
127
123
  });
128
124
  }
129
125
 
126
+ public bindMainView(divElement: HTMLDivElement, disableCameraTransform: boolean) {
127
+ const mainView = this.mainViewProxy.view;
128
+ mainView.disableCameraTransform = disableCameraTransform;
129
+ mainView.divElement = divElement;
130
+ if (!mainView.focusScenePath) {
131
+ this.store.setMainViewFocusPath();
132
+ }
133
+ if (
134
+ this.store.focus === undefined &&
135
+ mainView.mode !== ViewVisionMode.Writable
136
+ ) {
137
+ this.viewManager.switchMainViewToWriter();
138
+ }
139
+ this.mainViewProxy.addMainViewListener();
140
+ emitter.emit("mainViewMounted");
141
+ }
142
+
130
143
  public async addApp(params: AddAppParams, isDynamicPPT: boolean): Promise<string | undefined> {
131
144
  log("addApp", params);
132
145
  const { appId, needFocus } = await this.beforeAddApp(params, isDynamicPPT);
@@ -138,13 +151,13 @@ export class AppManager {
138
151
  private async beforeAddApp(params: AddAppParams, isDynamicPPT: boolean) {
139
152
  const appId = await genAppId(params.kind);
140
153
  this.appStatus.set(appId, AppStatus.StartCreate);
141
- this.delegate.setupAppAttributes(params, appId, isDynamicPPT);
154
+ this.store.setupAppAttributes(params, appId, isDynamicPPT);
142
155
  if (this.boxManager.boxState === TELE_BOX_STATE.Minimized) {
143
156
  this.boxManager.teleBoxManager.setState(TELE_BOX_STATE.Normal);
144
157
  }
145
158
  const needFocus = this.boxManager.boxState !== TELE_BOX_STATE.Minimized;
146
159
  if (needFocus) {
147
- this.delegate.setAppFocus(appId, true);
160
+ this.store.setAppFocus(appId, true);
148
161
  }
149
162
  const attrs = params.attributes ?? {};
150
163
  this.safeUpdateAttributes([appId], attrs);
@@ -223,8 +236,8 @@ export class AppManager {
223
236
  appProxy.emitAppIsWritableChange();
224
237
  });
225
238
  if (isWritable === true) {
226
- if (!this.delegate.focus) {
227
- this.viewManager.switchMainViewModeToWriter();
239
+ if (!this.store.focus) {
240
+ this.mainViewProxy.switchViewModeToWriter();
228
241
  }
229
242
  this.mainView.disableCameraTransform = false;
230
243
  } else {
@@ -253,7 +266,9 @@ export class AppManager {
253
266
  }
254
267
 
255
268
  public get focusApp() {
256
- return this.appProxies.get(this.delegate.focus);
269
+ if (this.store.focus) {
270
+ return this.appProxies.get(this.store.focus);
271
+ }
257
272
  }
258
273
 
259
274
  public safeSetAttributes(attributes: any) {
@@ -264,40 +279,39 @@ export class AppManager {
264
279
  this.windowManger.safeUpdateAttributes(keys, value);
265
280
  }
266
281
 
267
- public setMainViewScenePath(scenePath: string) {
282
+ public async setMainViewScenePath(scenePath: string) {
268
283
  if (this.room) {
269
284
  const scenePathType = this.displayer.scenePathType(scenePath);
270
285
  if (scenePathType === ScenePathType.None) {
271
286
  throw new Error(`[WindowManager]: ${scenePath} not valid scene`);
272
287
  } else if (scenePathType === ScenePathType.Page) {
273
- this._setMainViewScenePath(scenePath);
288
+ await this._setMainViewScenePath(scenePath);
274
289
  } else if (scenePathType === ScenePathType.Dir) {
275
290
  const validScenePath = makeValidScenePath(this.displayer, scenePath);
276
- this._setMainViewScenePath(validScenePath);
291
+ await this._setMainViewScenePath(validScenePath);
277
292
  }
278
293
  }
279
294
  }
280
295
 
281
- private _setMainViewScenePath(scenePath: string) {
296
+ private async _setMainViewScenePath(scenePath: string) {
282
297
  this.safeSetAttributes({ _mainScenePath: scenePath });
283
- this.viewManager.freedomAllViews();
284
- this.viewManager.switchMainViewToWriter();
285
- this.delegate.setMainViewFocusPath();
298
+ await this.viewManager.switchMainViewToWriter();
299
+ setScenePath(this.room, scenePath);
300
+ this.store.setMainViewFocusPath();
286
301
  }
287
302
 
288
- public setMainViewSceneIndex(index: number) {
303
+ public async setMainViewSceneIndex(index: number) {
289
304
  if (this.room) {
290
305
  this.safeSetAttributes({ _mainSceneIndex: index });
291
- this.viewManager.freedomAllViews();
292
- this.viewManager.switchMainViewToWriter();
306
+ await this.viewManager.switchMainViewToWriter();
293
307
  this.room.setSceneIndex(index);
294
- this.delegate.setMainViewScenePath(this.room.state.sceneState.scenePath);
295
- this.delegate.setMainViewFocusPath();
308
+ this.store.setMainViewScenePath(this.room.state.sceneState.scenePath);
309
+ this.store.setMainViewFocusPath();
296
310
  }
297
311
  }
298
312
 
299
313
  public getAppInitPath(appId: string): string | undefined {
300
- const attrs = this.delegate.getAppAttributes(appId);
314
+ const attrs = this.store.getAppAttributes(appId);
301
315
  if (attrs) {
302
316
  return attrs?.options?.scenePath;
303
317
  }
@@ -313,7 +327,7 @@ export class AppManager {
313
327
  switch (eventName) {
314
328
  case "move": {
315
329
  this.dispatchInternalEvent(Events.AppMove, payload);
316
- this.delegate.updateAppState(payload.appId, AppAttributes.Position, {
330
+ this.store.updateAppState(payload.appId, AppAttributes.Position, {
317
331
  x: payload.x,
318
332
  y: payload.y,
319
333
  });
@@ -330,11 +344,10 @@ export class AppManager {
330
344
  case "resize": {
331
345
  if (payload.width && payload.height) {
332
346
  this.dispatchInternalEvent(Events.AppResize, payload);
333
- this.delegate.updateAppState(payload.appId, AppAttributes.Size, {
347
+ this.store.updateAppState(payload.appId, AppAttributes.Size, {
334
348
  width: payload.width,
335
349
  height: payload.height,
336
350
  });
337
- this.room?.refreshViewSize();
338
351
  }
339
352
  break;
340
353
  }
@@ -348,7 +361,7 @@ export class AppManager {
348
361
  });
349
362
  this.safeSetAttributes({ boxState: eventName });
350
363
 
351
- this.delegate.cleanFocus();
364
+ this.store.cleanFocus();
352
365
  this.boxManager.blurFocusBox();
353
366
  break;
354
367
  }
@@ -384,7 +397,7 @@ export class AppManager {
384
397
  payload,
385
398
  });
386
399
 
387
- this.delegate.updateAppState(payload.appId, AppAttributes.SnapshotRect, {
400
+ this.store.updateAppState(payload.appId, AppAttributes.SnapshotRect, {
388
401
  ...payload.rect,
389
402
  });
390
403
  break;
@@ -403,7 +416,7 @@ export class AppManager {
403
416
 
404
417
  public focusByAttributes(apps: any) {
405
418
  if (apps && Object.keys(apps).length === this.boxManager.appBoxMap.size) {
406
- const focusAppId = this.delegate.focus;
419
+ const focusAppId = this.store.focus;
407
420
  if (focusAppId) {
408
421
  this.boxManager.focusBox({ appId: focusAppId });
409
422
  }
@@ -412,8 +425,8 @@ export class AppManager {
412
425
 
413
426
  public notifyReconnected() {
414
427
  this.appProxies.forEach(appProxy => {
415
- appProxy.appEmitter.emit("reconnected", undefined);
416
- })
428
+ appProxy.onReconnected();
429
+ });
417
430
  }
418
431
 
419
432
  public dispatchInternalEvent(event: Events, payload: any) {
package/src/AppProxy.ts CHANGED
@@ -24,8 +24,9 @@ import type { Camera, SceneState, View, SceneDefinition } from "white-web-sdk";
24
24
  import type { AppManager } from "./AppManager";
25
25
  import type { NetlessApp } from "./typings";
26
26
  import type { ReadonlyTeleBox } from "@netless/telebox-insider";
27
+ import { Base } from './Base';
27
28
 
28
- export class AppProxy {
29
+ export class AppProxy extends Base {
29
30
  public id: string;
30
31
  public scenePath?: string;
31
32
  public appEmitter: Emittery<AppEmitterEvent>;
@@ -41,10 +42,11 @@ export class AppProxy {
41
42
 
42
43
  constructor(
43
44
  private params: BaseInsertParams,
44
- private manager: AppManager,
45
+ manager: AppManager,
45
46
  appId: string,
46
47
  isAddApp: boolean
47
48
  ) {
49
+ super(manager);
48
50
  this.kind = params.kind;
49
51
  this.id = appId;
50
52
  this.appProxies.set(this.id, this);
@@ -63,7 +65,6 @@ export class AppProxy {
63
65
  if (this.params.options?.scenePath) {
64
66
  // 只有传入了 scenePath 的 App 才会创建 View
65
67
  this.createView();
66
- this.addCameraListener();
67
68
  }
68
69
  this.isAddApp = isAddApp;
69
70
  }
@@ -81,7 +82,7 @@ export class AppProxy {
81
82
  }
82
83
 
83
84
  public get appAttributes() {
84
- return this.manager.delegate.getAppAttributes(this.id);
85
+ return this.store.getAppAttributes(this.id);
85
86
  }
86
87
 
87
88
  public getFullScenePath(): string | undefined {
@@ -108,7 +109,7 @@ export class AppProxy {
108
109
  if (focus) {
109
110
  this.focusBox();
110
111
  this.manager.viewManager.switchAppToWriter(this.id);
111
- this.manager.delegate.setMainViewFocusPath();
112
+ this.store.setMainViewFocusPath();
112
113
  }
113
114
  return {
114
115
  appId: this.id,
@@ -174,31 +175,49 @@ export class AppProxy {
174
175
  }
175
176
  }
176
177
 
178
+ public onSeek(time: number) {
179
+ this.appEmitter.emit("seek", time);
180
+ const boxInitState = this.getAppInitState(this.id);
181
+ this.boxManager.updateBoxState(boxInitState);
182
+ }
183
+
184
+ public async onReconnected() {
185
+ this.appEmitter.emit("reconnected", undefined);
186
+ await this.destroy(true, false);
187
+ const params = this.params;
188
+ const appProxy = new AppProxy(params, this.manager, this.id, this.isAddApp);
189
+ await appProxy.baseInsertApp(this.store.focus === this.id);
190
+ }
191
+
177
192
  public switchToWritable() {
178
193
  if (this.view) {
194
+ if (this.view.mode === ViewVisionMode.Writable) return;
195
+ this.removeCameraListener();
179
196
  try {
180
- if (this.view.mode === ViewVisionMode.Writable) return;
181
197
  if (this.manager.mainView.mode === ViewVisionMode.Writable) {
182
- this.manager.delegate.setMainViewFocusPath();
198
+ this.store.setMainViewFocusPath();
183
199
  notifyMainViewModeChange(callbacks, ViewVisionMode.Freedom);
184
200
  setViewMode(this.manager.mainView, ViewVisionMode.Freedom);
185
201
  }
186
202
  setViewMode(this.view, ViewVisionMode.Writable);
203
+ this.recoverCamera();
187
204
  } catch (error) {
188
205
  log("switch view failed", error);
206
+ } finally {
207
+ this.addCameraListener();
189
208
  }
190
209
  }
191
210
  }
192
211
 
193
212
  public getAppInitState = (id: string) => {
194
- const attrs = this.manager.delegate.getAppState(id);
213
+ const attrs = this.store.getAppState(id);
195
214
  if (!attrs) return;
196
215
  const position = attrs?.[AppAttributes.Position];
197
- const focus = this.manager.attributes.focus;
216
+ const focus = this.store.focus;
198
217
  const size = attrs?.[AppAttributes.Size];
199
218
  const snapshotRect = attrs?.[AppAttributes.SnapshotRect];
200
219
  const sceneIndex = attrs?.[AppAttributes.SceneIndex];
201
- const boxState = this.manager.attributes["boxState"];
220
+ const boxState = this.store.getBoxState();
202
221
  let payload = { boxState } as AppInitState;
203
222
  if (position) {
204
223
  payload = { ...payload, id: id, x: position.x, y: position.y };
@@ -215,7 +234,6 @@ export class AppProxy {
215
234
  if (sceneIndex) {
216
235
  payload = { ...payload, sceneIndex };
217
236
  }
218
- emitter.emit(Events.InitReplay, payload);
219
237
  return payload;
220
238
  };
221
239
 
@@ -320,8 +338,9 @@ export class AppProxy {
320
338
  this.view?.callbacks.off("onCameraUpdated", this.cameraListener);
321
339
  }
322
340
 
323
- private createView(): View {
324
- const view = this.viewManager.createView(this.id);
341
+ private async createView(): Promise<View> {
342
+ const view = await this.viewManager.createView(this.id);
343
+ this.addCameraListener();
325
344
  this.setViewFocusScenePath();
326
345
  return view;
327
346
  }
@@ -341,7 +360,7 @@ export class AppProxy {
341
360
  this.boxManager.closeBox(this.id);
342
361
  }
343
362
  if (cleanAttrs) {
344
- this.manager.delegate.cleanAppAttributes(this.id);
363
+ this.store.cleanAppAttributes(this.id);
345
364
  }
346
365
  this.appProxies.delete(this.id);
347
366
  this.manager.cameraStore.deleteCamera(this.id);
@@ -4,6 +4,7 @@ import { setViewFocusScenePath } from "./Utils/Common";
4
4
  import type { AddAppParams, AppSyncAttributes } from "./index";
5
5
  import type { Camera, Size } from "white-web-sdk";
6
6
  import type { AppManager } from "./AppManager";
7
+ import type { Cursor } from "./Cursor/Cursor";
7
8
 
8
9
  export enum Fields {
9
10
  Apps = "apps",
@@ -39,7 +40,7 @@ export class AttributesDelegate {
39
40
  return get(this.manager.attributes, [Fields.Apps]);
40
41
  }
41
42
 
42
- public get focus() {
43
+ public get focus(): string | undefined {
43
44
  return get(this.manager.attributes, [Fields.Focus]);
44
45
  }
45
46
 
@@ -93,16 +94,6 @@ export class AttributesDelegate {
93
94
  this.manager.safeSetAttributes({ [Fields.Focus]: undefined });
94
95
  }
95
96
 
96
- public cleanAttributes() {
97
- this.manager.safeSetAttributes({
98
- [Fields.Apps]: undefined,
99
- [Fields.BoxState]: undefined,
100
- [Fields.Focus]: undefined,
101
- _mainScenePath: undefined,
102
- _mainSceneIndex: undefined,
103
- });
104
- }
105
-
106
97
  public getAppSceneIndex(id: string) {
107
98
  return this.getAppState(id)?.[AppAttributes.SceneIndex];
108
99
  }
@@ -131,11 +122,11 @@ export class AttributesDelegate {
131
122
  this.manager.safeSetAttributes({ _mainSceneIndex: index });
132
123
  }
133
124
 
134
- public getMainViewCamera(): Camera {
125
+ public getMainViewCamera(): MainViewCamera {
135
126
  return get(this.manager.attributes, [Fields.MainViewCamera]);
136
127
  }
137
128
 
138
- public getMainViewSize(): Size & { id: number } | undefined {
129
+ public getMainViewSize(): MainViewSize {
139
130
  return get(this.manager.attributes, [Fields.MainViewSize]);
140
131
  }
141
132
 
@@ -191,3 +182,20 @@ export class AttributesDelegate {
191
182
  }
192
183
  }
193
184
  }
185
+
186
+ export type MainViewSize = {
187
+ id: number;
188
+ width: number;
189
+ height: number;
190
+ }
191
+
192
+ export type MainViewCamera = {
193
+ id: number;
194
+ centerX: number;
195
+ centerY: number;
196
+ scale: number;
197
+ }
198
+
199
+ export type Cursors = {
200
+ [key: number]: Cursor;
201
+ }
@@ -0,0 +1,7 @@
1
+ import type { AppManager } from "../AppManager";
2
+ import { AttributesDelegate } from "../AttributesDelegate";
3
+
4
+ export class Base {
5
+ public store = new AttributesDelegate(this.manager);
6
+ constructor(public manager: AppManager) {}
7
+ }
package/src/BoxManager.ts CHANGED
@@ -50,6 +50,7 @@ export type CreateCollectorConfig = {
50
50
  export class BoxManager {
51
51
  public teleBoxManager: TeleBoxManager;
52
52
  public appBoxMap: Map<string, string> = new Map();
53
+ private store = this.manager.store;
53
54
 
54
55
  constructor(
55
56
  private manager: AppManager,
@@ -126,15 +127,15 @@ export class BoxManager {
126
127
  id: params.appId,
127
128
  };
128
129
  this.teleBoxManager.create(createBoxConfig);
129
- emitter.emit(`${params.appId}${Events.WindowCreated}` as any);
130
+ emitter.emit(`${params.appId}${Events.WindowCreated}` as any);
130
131
 
131
- const appState = this.manager.delegate.getAppState(params.appId);
132
- if (appState) {
133
- const snapshotRect = get(appState, [AppAttributes.SnapshotRect]);
134
- if (isEmpty(snapshotRect)) {
135
- this.setBoxInitState(params.appId);
136
- }
132
+ const appState = this.manager.store.getAppState(params.appId);
133
+ if (appState) {
134
+ const snapshotRect = get(appState, [AppAttributes.SnapshotRect]);
135
+ if (isEmpty(snapshotRect)) {
136
+ this.setBoxInitState(params.appId);
137
137
  }
138
+ }
138
139
  }
139
140
 
140
141
  public setBoxInitState(appId: string): void {
@@ -208,26 +209,32 @@ export class BoxManager {
208
209
  if (!state) return;
209
210
  const box = this.getBox(state.id);
210
211
  if (box) {
211
- this.teleBoxManager.update(box.id, {
212
- x: state.x,
213
- y: state.y,
214
- width: state.width || 0.5,
215
- height: state.height || 0.5,
216
- }, true);
217
- if (state.focus) {
218
- this.teleBoxManager.update(box.id, { focus: true }, true);
219
- }
212
+ this.teleBoxManager.update(
213
+ box.id,
214
+ {
215
+ x: state.x,
216
+ y: state.y,
217
+ width: state.width || 0.5,
218
+ height: state.height || 0.5,
219
+ },
220
+ true
221
+ );
220
222
  // TODO 连续调用 teleboxManager update 和 setState 会导致 box 出现问题. 先用 setTimeout 延迟调用,等 telebox 修复后去掉
223
+ setTimeout(() => {
224
+ if (state.boxState && this.teleBoxManager.state !== state.boxState) {
225
+ this.teleBoxManager.setState(state.boxState, true);
226
+ }
227
+ }, 0);
221
228
  setTimeout(() => {
222
229
  if (state.snapshotRect) {
223
230
  (box as TeleBox).setSnapshot(state.snapshotRect);
224
231
  }
225
232
  }, 30);
226
233
  setTimeout(() => {
227
- if (state.boxState && this.teleBoxManager.state !== state.boxState) {
228
- this.teleBoxManager.setState(state.boxState, true);
234
+ if (state.focus) {
235
+ this.teleBoxManager.update(box.id, { focus: true }, true);
229
236
  }
230
- }, 0);
237
+ }, 50);
231
238
  }
232
239
  }
233
240
 
@@ -134,10 +134,6 @@ export class Cursor {
134
134
  return get(this.cursors, [this.memberId, Fields.Position]);
135
135
  }
136
136
 
137
- public getFocusBox() {
138
- return this.cursorManager.getFocusBox();
139
- }
140
-
141
137
  private autoHidden() {
142
138
  if (this.timer) {
143
139
  clearTimeout(this.timer);