@netless/window-manager 0.4.0-canary.8 → 0.4.0-canary.9

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.4.0-canary.8",
3
+ "version": "0.4.0-canary.9",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
package/src/AppContext.ts CHANGED
@@ -17,7 +17,7 @@ import type { AppManager } from "./AppManager";
17
17
  import type { AppProxy } from "./AppProxy";
18
18
  import { Storage } from './App/Storage';
19
19
 
20
- export class AppContext<TAttrs extends Record<string, any>, AppOptions = any> {
20
+ export class AppContext<TAttrs extends Record<string, any> = any, AppOptions = any> {
21
21
  public readonly emitter: Emittery<AppEmitterEvent<TAttrs>>;
22
22
  public readonly mobxUtils = {
23
23
  autorun,
@@ -67,6 +67,7 @@ export class AppListeners {
67
67
 
68
68
  private setMainViewScenePathHandler = ({ nextScenePath }: { nextScenePath: string }) => {
69
69
  setViewFocusScenePath(this.manager.mainView, nextScenePath);
70
+ callbacks.emit("mainViewScenePathChange", nextScenePath);
70
71
  }
71
72
 
72
73
  private moveCameraToContainHandler = (payload: any) => {
package/src/AppManager.ts CHANGED
@@ -8,7 +8,7 @@ import { genAppId, makeValidScenePath, setScenePath, setViewFocusScenePath } fro
8
8
  import { log } from "./Utils/log";
9
9
  import { MainViewProxy } from "./View/MainView";
10
10
  import { onObjectRemoved, safeListenPropsUpdated } from "./Utils/Reactive";
11
- import { sortBy } from "lodash";
11
+ import { get, sortBy } from "lodash";
12
12
  import { store } from "./AttributesDelegate";
13
13
  import { ViewManager } from "./View/ViewManager";
14
14
  import type { ReconnectRefresher } from "./ReconnectRefresher";
@@ -29,6 +29,8 @@ export class AppManager {
29
29
  private appListeners: AppListeners;
30
30
  public boxManager?: BoxManager;
31
31
 
32
+ private _prevSceneIndex: number | undefined;
33
+
32
34
  constructor(public windowManger: WindowManager) {
33
35
  this.displayer = windowManger.displayer;
34
36
  this.store.setContext({
@@ -95,6 +97,15 @@ export class AppManager {
95
97
  }
96
98
  });
97
99
  });
100
+ this.refresher?.add("mainViewIndex", () => {
101
+ return autorun(() => {
102
+ const mainSceneIndex = get(this.attributes, "_mainSceneIndex");
103
+ if (mainSceneIndex !== undefined && this._prevSceneIndex !== mainSceneIndex) {
104
+ callbacks.emit("mainViewSceneIndexChange", mainSceneIndex);
105
+ this._prevSceneIndex = mainSceneIndex;
106
+ }
107
+ });
108
+ });
98
109
  if (!this.attributes.apps || Object.keys(this.attributes.apps).length === 0) {
99
110
  const mainScenePath = this.store.getMainViewScenePath();
100
111
  if (!mainScenePath) return;
@@ -374,7 +385,7 @@ export class AppManager {
374
385
  this.store.setMainViewScenePath(scenePath);
375
386
  this.setMainViewFocusPath();
376
387
  }
377
- }
388
+ }
378
389
  }
379
390
  }
380
391
 
@@ -477,5 +488,6 @@ export class AppManager {
477
488
  this.refresher?.destroy();
478
489
  this.mainViewProxy.destroy();
479
490
  callbacks.clearListeners();
491
+ this._prevSceneIndex = undefined;
480
492
  }
481
493
  }
@@ -29,6 +29,18 @@ export const replaceRoomFunction = (room: Room, manager: WindowManager) => {
29
29
  },
30
30
  });
31
31
 
32
+ Object.defineProperty(room, "canUndoSteps", {
33
+ get() {
34
+ return manager.mainView.canUndoSteps;
35
+ }
36
+ });
37
+
38
+ Object.defineProperty(room, "canRedoSteps", {
39
+ get() {
40
+ return manager.mainView.canRedoSteps;
41
+ }
42
+ });
43
+
32
44
  room.moveCamera = (camera: Camera) => manager.mainView.moveCamera(camera);
33
45
  room.moveCameraToContain = (...args) => manager.moveCameraToContain(...args);
34
46
  room.convertToPointInWorld = (...args) => manager.mainView.convertToPointInWorld(...args);
@@ -36,6 +48,9 @@ export const replaceRoomFunction = (room: Room, manager: WindowManager) => {
36
48
  room.scenePreview = (...args) => manager.mainView.scenePreview(...args);
37
49
  room.fillSceneSnapshot = (...args) => manager.mainView.fillSceneSnapshot(...args);
38
50
  room.generateScreenshot = (...args) => manager.mainView.generateScreenshot(...args);
51
+ room.setMemberState = (...args) => manager.mainView.setMemberState(...args);
52
+ room.redo = () => manager.mainView.redo();
53
+ room.undo = () => manager.mainView.undo();
39
54
  }
40
55
 
41
56
  };
package/src/constants.ts CHANGED
@@ -37,7 +37,7 @@ export enum CursorState {
37
37
  Normal = "normal",
38
38
  }
39
39
 
40
- export const REQUIRE_VERSION = "2.13.16";
40
+ export const REQUIRE_VERSION = "2.16.0";
41
41
 
42
42
  export const MIN_WIDTH = 340 / 720;
43
43
  export const MIN_HEIGHT = 340 / 720;
package/src/index.ts CHANGED
@@ -149,6 +149,8 @@ export type PublicEvent = {
149
149
  darkModeChange: boolean;
150
150
  prefersColorSchemeChange: TeleBoxColorScheme;
151
151
  cameraStateChange: CameraState;
152
+ mainViewScenePathChange: string;
153
+ mainViewSceneIndexChange: number;
152
154
  };
153
155
 
154
156
  export type MountParams = {