@netless/window-manager 0.4.17 → 0.4.20

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 (43) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +9 -3
  3. package/dist/{AppContext.d.ts → App/AppContext.d.ts} +12 -6
  4. package/dist/App/AppPageStateImpl.d.ts +17 -0
  5. package/dist/{AppProxy.d.ts → App/AppProxy.d.ts} +15 -7
  6. package/dist/App/Storage/index.d.ts +1 -1
  7. package/dist/App/index.d.ts +2 -0
  8. package/dist/AppManager.d.ts +1 -1
  9. package/dist/Page/PageController.d.ts +15 -0
  10. package/dist/Page/index.d.ts +1 -0
  11. package/dist/PageState.d.ts +1 -4
  12. package/dist/RedoUndo.d.ts +1 -1
  13. package/dist/Utils/AppCreateQueue.d.ts +1 -1
  14. package/dist/Utils/Common.d.ts +1 -1
  15. package/dist/callback.d.ts +1 -1
  16. package/dist/index.d.ts +4 -8
  17. package/dist/index.es.js +15403 -5
  18. package/dist/index.es.js.map +1 -1
  19. package/dist/index.umd.js +46 -41
  20. package/dist/index.umd.js.map +1 -1
  21. package/dist/style.css +1 -1
  22. package/dist/typings.d.ts +5 -2
  23. package/docs/app-context.md +46 -1
  24. package/docs/develop-app.md +4 -0
  25. package/jest.config.js +27 -0
  26. package/package.json +11 -3
  27. package/pnpm-lock.yaml +8176 -0
  28. package/src/{AppContext.ts → App/AppContext.ts} +49 -7
  29. package/src/App/AppPageStateImpl.ts +49 -0
  30. package/src/{AppProxy.ts → App/AppProxy.ts} +57 -17
  31. package/src/App/Storage/index.ts +1 -1
  32. package/src/App/index.ts +2 -0
  33. package/src/AppManager.ts +1 -1
  34. package/src/Page/PageController.ts +18 -0
  35. package/src/Page/index.ts +1 -0
  36. package/src/PageState.ts +2 -6
  37. package/src/RedoUndo.ts +1 -1
  38. package/src/Utils/AppCreateQueue.ts +3 -3
  39. package/src/Utils/Common.ts +2 -2
  40. package/src/View/MainView.ts +4 -2
  41. package/src/callback.ts +1 -1
  42. package/src/index.ts +4 -9
  43. package/src/typings.ts +5 -2
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 0.4.20
2
+
3
+ 1. 导出 Page 相关类型
4
+
5
+ ## 0.4.19
6
+
7
+ 1. 升级 @netless/app-docs-viewer@0.2.9
8
+
9
+ ## 0.4.18
10
+
11
+ 1. 修复设置 viewMode freedom 时, 不能 focus 到主白板的问题
12
+
1
13
  ## 0.4.17
2
14
 
3
15
  1. 修复 safari 浏览器下 removeScenes 为 "/" 没有清理完成完成时可以 addApp
package/README.md CHANGED
@@ -210,8 +210,14 @@ manager.destroy();
210
210
 
211
211
  ## 开发流程
212
212
 
213
- yarn build:lib
213
+ ```bash
214
+ pnpm install
214
215
 
215
- cd test
216
+ pnpm build
216
217
 
217
- yarn dev
218
+ cd example
219
+
220
+ pnpm install
221
+
222
+ pnpm dev
223
+ ```
@@ -1,14 +1,15 @@
1
- import { Storage } from "./App/Storage";
1
+ import { Storage } from "./Storage";
2
2
  import { autorun, listenDisposed, listenUpdated, reaction, unlistenDisposed, unlistenUpdated, toJS } from "white-web-sdk";
3
3
  import type { Room, SceneDefinition, View } from "white-web-sdk";
4
4
  import type { ReadonlyTeleBox } from "@netless/telebox-insider";
5
5
  import type Emittery from "emittery";
6
- import type { BoxManager } from "./BoxManager";
7
- import type { AppEmitterEvent } from "./index";
8
- import type { AppManager } from "./AppManager";
6
+ import type { BoxManager } from "../BoxManager";
7
+ import type { AppEmitterEvent } from "../index";
8
+ import type { AppManager } from "../AppManager";
9
9
  import type { AppProxy } from "./AppProxy";
10
- import type { MagixEventAddListener, MagixEventDispatcher, MagixEventRemoveListener } from "./App/MagixEvent";
11
- export declare class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOptions = any> {
10
+ import type { MagixEventAddListener, MagixEventDispatcher, MagixEventRemoveListener } from "./MagixEvent";
11
+ import type { AddPageParams, PageController, PageState } from "../Page";
12
+ export declare class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOptions = any> implements PageController {
12
13
  private manager;
13
14
  private boxManager;
14
15
  appId: string;
@@ -65,4 +66,9 @@ export declare class AppContext<TAttributes = any, TMagixEventPayloads = any, TA
65
66
  addMagixEventListener: MagixEventAddListener<TMagixEventPayloads>;
66
67
  /** Remove a Magix event listener. */
67
68
  removeMagixEventListener: MagixEventRemoveListener<TMagixEventPayloads>;
69
+ /** PageController */
70
+ nextPage: () => Promise<boolean>;
71
+ prevPage: () => Promise<boolean>;
72
+ addPage: (params?: AddPageParams | undefined) => Promise<void>;
73
+ get pageState(): PageState;
68
74
  }
@@ -0,0 +1,17 @@
1
+ import type { Displayer, View } from "white-web-sdk";
2
+ import type { PageState } from "../Page";
3
+ export declare type AppPageStateParams = {
4
+ displayer: Displayer;
5
+ scenePath: string | undefined;
6
+ view: View | undefined;
7
+ notifyPageStateChange: () => void;
8
+ };
9
+ export declare class AppPageStateImpl {
10
+ private params;
11
+ private sceneNode;
12
+ constructor(params: AppPageStateParams);
13
+ private onSceneChange;
14
+ getFullPath(index: number): string | undefined;
15
+ toObject(): PageState;
16
+ destroy(): void;
17
+ }
@@ -1,16 +1,19 @@
1
1
  import Emittery from "emittery";
2
- import type { AppEmitterEvent, AppInitState, BaseInsertParams } from "./index";
2
+ import { AppContext } from "./AppContext";
3
+ import type { AppEmitterEvent, AppInitState, BaseInsertParams } from "../index";
3
4
  import type { SceneState, View, SceneDefinition } from "white-web-sdk";
4
- import type { AppManager } from "./AppManager";
5
- import type { NetlessApp } from "./typings";
5
+ import type { AppManager } from "../AppManager";
6
+ import type { NetlessApp } from "../typings";
6
7
  import type { ReadonlyTeleBox } from "@netless/telebox-insider";
8
+ import type { PageState } from "../Page";
9
+ export declare type AppEmitter = Emittery<AppEmitterEvent>;
7
10
  export declare class AppProxy {
8
11
  private params;
9
12
  private manager;
10
13
  kind: string;
11
14
  id: string;
12
15
  scenePath?: string;
13
- appEmitter: Emittery<AppEmitterEvent>;
16
+ appEmitter: AppEmitter;
14
17
  scenes?: SceneDefinition[];
15
18
  private appListener;
16
19
  private boxManager;
@@ -20,14 +23,16 @@ export declare class AppProxy {
20
23
  isAddApp: boolean;
21
24
  private status;
22
25
  private stateKey;
23
- private appResult?;
24
- private appContext?;
26
+ private _pageState;
27
+ appResult?: NetlessApp<any>;
28
+ appContext?: AppContext<any, any>;
25
29
  constructor(params: BaseInsertParams, manager: AppManager, appId: string, isAddApp: boolean);
26
30
  private initScenes;
27
31
  get view(): View | undefined;
32
+ get viewIndex(): number | undefined;
28
33
  get isWritable(): boolean;
29
34
  get attributes(): any;
30
- get appAttributes(): import("./index").AppSyncAttributes;
35
+ get appAttributes(): import("../index").AppSyncAttributes;
31
36
  getFullScenePath(): string | undefined;
32
37
  private getFullScenePathFromScenes;
33
38
  setFullPath(path: string): void;
@@ -50,6 +55,9 @@ export declare class AppProxy {
50
55
  setScenePath(): void;
51
56
  setViewFocusScenePath(): string | undefined;
52
57
  private createView;
58
+ notifyPageStateChange: () => void;
59
+ get pageState(): PageState;
60
+ setSceneIndex(index: number): void;
53
61
  destroy(needCloseBox: boolean, cleanAttrs: boolean, skipUpdate: boolean, error?: Error): Promise<void>;
54
62
  close(): Promise<void>;
55
63
  }
@@ -1,4 +1,4 @@
1
- import type { AppContext } from "../../AppContext";
1
+ import type { AppContext } from "../AppContext";
2
2
  import type { Diff, StorageStateChangedListener, StorageStateChangedListenerDisposer } from "./typings";
3
3
  import { StorageEvent } from "./StorageEvent";
4
4
  export * from './typings';
@@ -0,0 +1,2 @@
1
+ export * from "./AppProxy";
2
+ export * from "./AppContext";
@@ -1,5 +1,5 @@
1
1
  import { AppStatus, Events } from "./constants";
2
- import { AppProxy } from "./AppProxy";
2
+ import { AppProxy } from "./App";
3
3
  import { MainViewProxy } from "./View/MainView";
4
4
  import { WindowManager } from "./index";
5
5
  import { ViewManager } from "./View/ViewManager";
@@ -0,0 +1,15 @@
1
+ import type { SceneDefinition } from "white-web-sdk";
2
+ export declare type AddPageParams = {
3
+ after?: boolean;
4
+ scene?: SceneDefinition;
5
+ };
6
+ export declare type PageState = {
7
+ index: number;
8
+ length: number;
9
+ };
10
+ export interface PageController {
11
+ nextPage: () => Promise<boolean>;
12
+ prevPage: () => Promise<boolean>;
13
+ addPage: (params?: AddPageParams) => Promise<void>;
14
+ pageState: PageState;
15
+ }
@@ -0,0 +1 @@
1
+ export * from "./PageController";
@@ -1,8 +1,5 @@
1
1
  import type { AppManager } from "./AppManager";
2
- export declare type PageState = {
3
- index: number;
4
- length: number;
5
- };
2
+ import type { PageState } from "./Page";
6
3
  export declare class PageStateImpl {
7
4
  private manager;
8
5
  constructor(manager: AppManager);
@@ -1,5 +1,5 @@
1
1
  import type { View } from "white-web-sdk";
2
- import type { AppProxy } from "./AppProxy";
2
+ import type { AppProxy } from "./App";
3
3
  export declare type RedoUndoContext = {
4
4
  mainView: () => View;
5
5
  focus: () => string | undefined;
@@ -1,4 +1,4 @@
1
- import type { AppProxy } from "../AppProxy";
1
+ import type { AppProxy } from "../App";
2
2
  export declare type Invoker = () => Promise<AppProxy | undefined>;
3
3
  export declare class AppCreateQueue {
4
4
  private list;
@@ -13,7 +13,7 @@ export declare const addEmitterOnceListener: (event: any, listener: any) => void
13
13
  export declare const notifyMainViewModeChange: import("lodash").DebouncedFunc<(callbacks: Emittery<PublicEvent>, mode: ViewVisionMode) => void>;
14
14
  export declare const makeValidScenePath: (displayer: Displayer, scenePath: string, index?: number) => string | undefined;
15
15
  export declare const entireScenes: (displayer: Displayer) => import("white-web-sdk").SceneMap;
16
- export declare const putScenes: (room: Room | undefined, path: string, scenes: SceneDefinition[]) => void | undefined;
16
+ export declare const putScenes: (room: Room | undefined, path: string, scenes: SceneDefinition[], index?: number | undefined) => void | undefined;
17
17
  export declare const isValidScenePath: (scenePath: string) => boolean;
18
18
  export declare const parseSceneDir: (scenePath: string) => string;
19
19
  export declare const ensureValidScenePath: (scenePath: string) => string;
@@ -2,7 +2,7 @@ import Emittery from "emittery";
2
2
  import type { TeleBoxColorScheme, TELE_BOX_STATE } from "@netless/telebox-insider";
3
3
  import type { CameraState, SceneState, ViewVisionMode } from "white-web-sdk";
4
4
  import type { LoadAppEvent } from "./Register";
5
- import type { PageState } from "./PageState";
5
+ import type { PageState } from "./Page";
6
6
  export declare type PublicEvent = {
7
7
  mainViewModeChange: ViewVisionMode;
8
8
  boxStateChange: `${TELE_BOX_STATE}`;
package/dist/index.d.ts CHANGED
@@ -11,10 +11,10 @@ import type { Displayer, SceneDefinition, View, Room, InvisiblePluginContext, Ca
11
11
  import type { AppListeners } from "./AppListener";
12
12
  import type { NetlessApp, RegisterParams } from "./typings";
13
13
  import type { TeleBoxColorScheme, TeleBoxState } from "@netless/telebox-insider";
14
- import type { AppProxy } from "./AppProxy";
15
- import type { PublicEvent } from "./Callback";
14
+ import type { AppProxy } from "./App";
15
+ import type { PublicEvent } from "./callback";
16
16
  import type Emittery from "emittery";
17
- import type { PageState } from "./PageState";
17
+ import type { PageController, AddPageParams, PageState } from "./Page";
18
18
  export declare type WindowMangerAttributes = {
19
19
  modelValue?: string;
20
20
  boxState: TELE_BOX_STATE;
@@ -89,11 +89,7 @@ export declare type MountParams = {
89
89
  prefersColorScheme?: TeleBoxColorScheme;
90
90
  };
91
91
  export declare const reconnectRefresher: ReconnectRefresher;
92
- export declare type AddPageParams = {
93
- after?: boolean;
94
- scene?: SceneDefinition;
95
- };
96
- export declare class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
92
+ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttributes> implements PageController {
97
93
  static kind: string;
98
94
  static displayer: Displayer;
99
95
  static wrapper?: HTMLElement;