@netless/window-manager 0.3.18 → 0.4.0-canary.11

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.
Files changed (75) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +4 -43
  3. package/dist/App/MagixEvent/index.d.ts +28 -0
  4. package/dist/App/Storage/StorageEvent.d.ts +8 -0
  5. package/dist/App/Storage/index.d.ts +38 -0
  6. package/dist/App/Storage/typings.d.ts +21 -0
  7. package/dist/App/Storage/utils.d.ts +5 -0
  8. package/dist/AppContext.d.ts +42 -17
  9. package/dist/AppListener.d.ts +2 -2
  10. package/dist/AppManager.d.ts +18 -14
  11. package/dist/AppProxy.d.ts +5 -3
  12. package/dist/AttributesDelegate.d.ts +19 -11
  13. package/dist/Base/Context.d.ts +0 -1
  14. package/dist/Base/index.d.ts +1 -2
  15. package/dist/BoxManager.d.ts +24 -7
  16. package/dist/BuiltinApps.d.ts +6 -0
  17. package/dist/ContainerResizeObserver.d.ts +10 -0
  18. package/dist/Cursor/Cursor.d.ts +2 -3
  19. package/dist/Cursor/index.d.ts +9 -5
  20. package/dist/Helper.d.ts +6 -0
  21. package/dist/ReconnectRefresher.d.ts +9 -3
  22. package/dist/Utils/Common.d.ts +3 -1
  23. package/dist/Utils/Reactive.d.ts +1 -1
  24. package/dist/Utils/RoomHacker.d.ts +2 -2
  25. package/dist/Utils/error.d.ts +3 -0
  26. package/dist/{MainView.d.ts → View/MainView.d.ts} +3 -4
  27. package/dist/View/ViewManager.d.ts +13 -0
  28. package/dist/constants.d.ts +3 -7
  29. package/dist/index.d.ts +25 -27
  30. package/dist/index.es.js +1 -1
  31. package/dist/index.es.js.map +1 -1
  32. package/dist/index.umd.js +1 -1
  33. package/dist/index.umd.js.map +1 -1
  34. package/dist/style.css +1 -1
  35. package/dist/typings.d.ts +3 -2
  36. package/docs/api.md +17 -0
  37. package/docs/migrate.md +42 -0
  38. package/package.json +6 -4
  39. package/src/App/MagixEvent/index.ts +66 -0
  40. package/src/App/Storage/StorageEvent.ts +21 -0
  41. package/src/App/Storage/index.ts +284 -0
  42. package/src/App/Storage/typings.ts +21 -0
  43. package/src/App/Storage/utils.ts +17 -0
  44. package/src/AppContext.ts +61 -21
  45. package/src/AppListener.ts +15 -11
  46. package/src/AppManager.ts +141 -95
  47. package/src/AppProxy.ts +49 -52
  48. package/src/AttributesDelegate.ts +76 -49
  49. package/src/Base/Context.ts +2 -6
  50. package/src/Base/index.ts +2 -2
  51. package/src/BoxManager.ts +89 -31
  52. package/src/BuiltinApps.ts +24 -0
  53. package/src/ContainerResizeObserver.ts +62 -0
  54. package/src/Cursor/Cursor.ts +35 -39
  55. package/src/Cursor/index.ts +79 -43
  56. package/src/Helper.ts +30 -0
  57. package/src/ReconnectRefresher.ts +25 -10
  58. package/src/Utils/Common.ts +35 -13
  59. package/src/Utils/Reactive.ts +9 -3
  60. package/src/Utils/RoomHacker.ts +20 -5
  61. package/src/Utils/error.ts +6 -1
  62. package/src/{MainView.ts → View/MainView.ts} +19 -27
  63. package/src/View/ViewManager.ts +53 -0
  64. package/src/constants.ts +2 -3
  65. package/src/index.ts +144 -171
  66. package/src/shim.d.ts +4 -0
  67. package/src/style.css +7 -1
  68. package/src/typings.ts +3 -2
  69. package/vite.config.js +4 -1
  70. package/dist/Utils/CameraStore.d.ts +0 -15
  71. package/dist/ViewManager.d.ts +0 -29
  72. package/dist/sdk.d.ts +0 -14
  73. package/src/Utils/CameraStore.ts +0 -72
  74. package/src/sdk.ts +0 -39
  75. package/src/viewManager.ts +0 -177
@@ -4,11 +4,13 @@ import type Emittery from "emittery";
4
4
  export declare const genAppId: (kind: string) => Promise<string>;
5
5
  export declare const setViewFocusScenePath: (view: View, focusScenePath: string) => void;
6
6
  export declare const setScenePath: (room: Room | undefined, scenePath: string) => void;
7
+ export declare const getScenePath: (room: Room | undefined, dir: string | undefined, index: number) => string | undefined;
7
8
  export declare const setViewMode: (view: View, mode: ViewVisionMode) => void;
8
9
  export declare const emitError: (error: Error) => void;
9
10
  export declare const addEmitterOnceListener: (event: any, listener: any) => void;
10
11
  export declare const notifyMainViewModeChange: import("lodash").DebouncedFunc<(callbacks: Emittery<PublicEvent>, mode: ViewVisionMode) => void>;
11
- export declare const makeValidScenePath: (displayer: Displayer, scenePath: string) => string;
12
+ export declare const makeValidScenePath: (displayer: Displayer, scenePath: string, index?: number) => string | undefined;
13
+ export declare const entireScenes: (displayer: Displayer) => import("white-web-sdk").SceneMap;
12
14
  export declare const isValidScenePath: (scenePath: string) => boolean;
13
15
  export declare const ensureValidScenePath: (scenePath: string) => string;
14
16
  export declare const getVersionNumber: (version: string) => number;
@@ -1,6 +1,6 @@
1
1
  import { UpdateEventKind } from "white-web-sdk";
2
2
  import type { AkkoObjectUpdatedListener } from "white-web-sdk";
3
3
  export declare const onObjectByEvent: (event: UpdateEventKind) => (object: any, func: () => void) => (() => void) | undefined;
4
- export declare const safeListenPropsUpdated: <T>(getProps: () => T, callback: AkkoObjectUpdatedListener<T>) => () => void;
4
+ export declare const safeListenPropsUpdated: <T>(getProps: () => T, callback: AkkoObjectUpdatedListener<T>, onDestroyed?: ((props: unknown) => void) | undefined) => () => void;
5
5
  export declare const onObjectRemoved: (object: any, func: () => void) => (() => void) | undefined;
6
6
  export declare const onObjectInserted: (object: any, func: () => void) => (() => void) | undefined;
@@ -1,3 +1,3 @@
1
+ import type { WindowManager } from '../index';
1
2
  import type { Room } from "white-web-sdk";
2
- import type { AppManager } from "../AppManager";
3
- export declare const replaceRoomFunction: (room: Room, manager: AppManager) => void;
3
+ export declare const replaceRoomFunction: (room: Room, manager: WindowManager) => void;
@@ -19,3 +19,6 @@ export declare class BoxNotCreatedError extends Error {
19
19
  export declare class InvalidScenePath extends Error {
20
20
  message: string;
21
21
  }
22
+ export declare class BoxManagerNotFoundError extends Error {
23
+ message: string;
24
+ }
@@ -1,13 +1,13 @@
1
- import { Base } from "./Base";
1
+ import { Base } from "../Base";
2
2
  import type { Camera, Size, View } from "white-web-sdk";
3
- import type { AppManager } from "./AppManager";
3
+ import type { AppManager } from "../AppManager";
4
4
  export declare class MainViewProxy extends Base {
5
5
  private scale?;
6
- private cameraStore;
7
6
  private started;
8
7
  private mainViewIsAddListener;
9
8
  private mainView;
10
9
  private viewId;
10
+ private sideEffectManager;
11
11
  constructor(manager: AppManager);
12
12
  private get mainViewCamera();
13
13
  private get mainViewSize();
@@ -34,7 +34,6 @@ export declare class MainViewProxy extends Base {
34
34
  private addCameraListener;
35
35
  private removeCameraListener;
36
36
  private onCameraOrSizeUpdated;
37
- switchViewModeToWriter(): void;
38
37
  moveCameraToContian(size: Size): void;
39
38
  moveCamera(camera: Camera): void;
40
39
  stop(): void;
@@ -0,0 +1,13 @@
1
+ import type { View, Displayer } from "white-web-sdk";
2
+ export declare class ViewManager {
3
+ private displayer;
4
+ views: Map<string, View>;
5
+ constructor(displayer: Displayer);
6
+ createView(id: string): View;
7
+ getView(id: string): View | undefined;
8
+ destroyView(id: string): void;
9
+ setViewScenePath(id: string, scenePath: string): void;
10
+ destroy(): void;
11
+ }
12
+ export declare const createView: (displayer: Displayer) => View;
13
+ export declare const setDefaultCameraBound: (view: View) => void;
@@ -9,7 +9,8 @@ export declare enum Events {
9
9
  WindowCreated = "WindowCreated",
10
10
  SetMainViewScenePath = "SetMainViewScenePath",
11
11
  SetMainViewSceneIndex = "SetMainViewSceneIndex",
12
- SwitchViewsToFreedom = "SwitchViewsToFreedom"
12
+ SwitchViewsToFreedom = "SwitchViewsToFreedom",
13
+ MoveCameraToContain = "MoveCameraToContain"
13
14
  }
14
15
  export declare const MagixEventName = "__WindowManger";
15
16
  export declare enum AppAttributes {
@@ -30,13 +31,8 @@ export declare enum CursorState {
30
31
  Leave = "leave",
31
32
  Normal = "normal"
32
33
  }
33
- export declare const REQUIRE_VERSION = "2.13.16";
34
+ export declare const REQUIRE_VERSION = "2.16.0";
34
35
  export declare const MIN_WIDTH: number;
35
36
  export declare const MIN_HEIGHT: number;
36
37
  export declare const SET_SCENEPATH_DELAY = 100;
37
- export declare const DEFAULT_COLLECTOR_STYLE: {
38
- right: string;
39
- bottom: string;
40
- position: string;
41
- };
42
38
  export declare const DEFAULT_CONTAINER_RATIO: number;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import Emittery from "emittery";
2
2
  import { AppManager } from "./AppManager";
3
3
  import { CursorManager } from "./Cursor";
4
+ import { ReconnectRefresher } from "./ReconnectRefresher";
4
5
  import "./style.css";
5
6
  import "@netless/telebox-insider/dist/style.css";
6
7
  import type { TELE_BOX_STATE } from "./BoxManager";
@@ -29,11 +30,11 @@ export declare type AddAppOptions = {
29
30
  export declare type setAppOptions = AddAppOptions & {
30
31
  appOptions?: any;
31
32
  };
32
- export declare type AddAppParams = {
33
+ export declare type AddAppParams<TAttributes = any> = {
33
34
  kind: string;
34
35
  src?: string;
35
36
  options?: AddAppOptions;
36
- attributes?: any;
37
+ attributes?: TAttributes;
37
38
  };
38
39
  export declare type BaseInsertParams = {
39
40
  kind: string;
@@ -49,6 +50,7 @@ export declare type AppSyncAttributes = {
49
50
  state?: any;
50
51
  isDynamicPPT?: boolean;
51
52
  fullPath?: string;
53
+ createdAt?: number;
52
54
  };
53
55
  export declare type AppInitState = {
54
56
  id: string;
@@ -90,18 +92,23 @@ export declare type EmitterEvent = {
90
92
  observerIdChange: number;
91
93
  boxStateChange: string;
92
94
  playgroundSizeChange: DOMRect;
95
+ onReconnected: void;
93
96
  };
94
- export declare const emitter: Emittery<EmitterEvent>;
97
+ export declare type EmitterType = Emittery<EmitterEvent>;
98
+ export declare const emitter: EmitterType;
95
99
  export declare type PublicEvent = {
96
100
  mainViewModeChange: ViewVisionMode;
97
101
  boxStateChange: `${TELE_BOX_STATE}`;
98
102
  darkModeChange: boolean;
99
103
  prefersColorSchemeChange: TeleBoxColorScheme;
100
104
  cameraStateChange: CameraState;
105
+ mainViewScenePathChange: string;
106
+ mainViewSceneIndexChange: number;
107
+ focusedChange: string | undefined;
101
108
  };
102
109
  export declare type MountParams = {
103
110
  room: Room;
104
- container: HTMLElement;
111
+ container?: HTMLElement;
105
112
  /** 白板高宽比例, 默认为 9 / 16 */
106
113
  containerSizeRatio?: number;
107
114
  /** 显示 PS 透明背景,默认 true */
@@ -114,7 +121,9 @@ export declare type MountParams = {
114
121
  disableCameraTransform?: boolean;
115
122
  prefersColorScheme?: TeleBoxColorScheme;
116
123
  };
117
- export declare const callbacks: Emittery<PublicEvent>;
124
+ export declare type CallbacksType = Emittery<PublicEvent>;
125
+ export declare const callbacks: CallbacksType;
126
+ export declare const reconnectRefresher: ReconnectRefresher;
118
127
  export declare class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
119
128
  static kind: string;
120
129
  static displayer: Displayer;
@@ -132,20 +141,15 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
132
141
  cursorManager?: CursorManager;
133
142
  viewMode: ViewMode;
134
143
  isReplay: boolean;
144
+ private boxManager?;
145
+ private static params?;
146
+ private containerResizeObserver?;
135
147
  constructor(context: InvisiblePluginContext);
136
- /**
137
- * 挂载 WindowManager
138
- * @deprecated
139
- */
140
- static mount(room: Room, container: HTMLElement, collectorContainer?: HTMLElement, options?: {
141
- chessboard: boolean;
142
- containerSizeRatio: number;
143
- collectorStyles?: Partial<CSSStyleDeclaration>;
144
- debug?: boolean;
145
- overwriteStyles?: string;
146
- }): Promise<WindowManager>;
147
148
  static mount(params: MountParams): Promise<WindowManager>;
148
149
  private static initManager;
150
+ private static initContainer;
151
+ bindContainer(container: HTMLElement): void;
152
+ bindCollectorContainer(container: HTMLElement): void;
149
153
  /**
150
154
  * 注册插件
151
155
  */
@@ -153,7 +157,7 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
153
157
  /**
154
158
  * 创建一个 app 至白板
155
159
  */
156
- addApp(params: AddAppParams): Promise<string | undefined>;
160
+ addApp<T = any>(params: AddAppParams<T>): Promise<string | undefined>;
157
161
  private setupScenePath;
158
162
  /**
159
163
  * 设置 mainView 的 ScenePath, 并且切换白板为可写状态
@@ -191,9 +195,10 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
191
195
  get camera(): Camera;
192
196
  get cameraState(): CameraState;
193
197
  get apps(): Apps | undefined;
194
- get boxState(): TeleBoxState;
198
+ get boxState(): TeleBoxState | undefined;
195
199
  get darkMode(): boolean;
196
- get prefersColorScheme(): TeleBoxColorScheme;
200
+ get prefersColorScheme(): TeleBoxColorScheme | undefined;
201
+ get focused(): string | undefined;
197
202
  /**
198
203
  * 查询所有的 App
199
204
  */
@@ -226,13 +231,6 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
226
231
  private isDynamicPPT;
227
232
  private static checkVersion;
228
233
  private ensureAttributes;
229
- private containerResizeObserver?;
230
- private observePlaygroundSize;
231
- private updateSizer;
232
234
  }
233
- export declare const BuiltinApps: {
234
- DocsViewer: string;
235
- MediaPlayer: string;
236
- };
237
235
  export * from "./typings";
238
- export { WhiteWindowSDK } from "./sdk";
236
+ export { BuiltinApps } from "./BuiltinApps";