@netless/window-manager 0.4.0-canary.0 → 0.4.0-canary.12

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 (65) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/App/MagixEvent/index.d.ts +28 -0
  3. package/dist/App/Storage/StorageEvent.d.ts +8 -0
  4. package/dist/App/Storage/index.d.ts +38 -0
  5. package/dist/App/Storage/typings.d.ts +21 -0
  6. package/dist/App/Storage/utils.d.ts +5 -0
  7. package/dist/AppContext.d.ts +40 -16
  8. package/dist/AppListener.d.ts +1 -1
  9. package/dist/AppManager.d.ts +8 -7
  10. package/dist/AppProxy.d.ts +4 -4
  11. package/dist/Base/Context.d.ts +0 -1
  12. package/dist/BoxManager.d.ts +1 -0
  13. package/dist/BuiltinApps.d.ts +6 -0
  14. package/dist/ContainerResizeObserver.d.ts +10 -0
  15. package/dist/Cursor/Cursor.d.ts +2 -3
  16. package/dist/Cursor/index.d.ts +7 -4
  17. package/dist/Helper.d.ts +6 -0
  18. package/dist/ReconnectRefresher.d.ts +8 -3
  19. package/dist/Utils/Common.d.ts +3 -1
  20. package/dist/Utils/Reactive.d.ts +1 -1
  21. package/dist/{MainView.d.ts → View/MainView.d.ts} +3 -4
  22. package/dist/View/ViewManager.d.ts +13 -0
  23. package/dist/constants.d.ts +3 -7
  24. package/dist/index.d.ts +14 -14
  25. package/dist/index.es.js +1 -1
  26. package/dist/index.es.js.map +1 -1
  27. package/dist/index.umd.js +1 -1
  28. package/dist/index.umd.js.map +1 -1
  29. package/dist/style.css +1 -1
  30. package/dist/typings.d.ts +3 -2
  31. package/package.json +7 -5
  32. package/src/App/MagixEvent/index.ts +66 -0
  33. package/src/App/Storage/StorageEvent.ts +21 -0
  34. package/src/App/Storage/index.ts +284 -0
  35. package/src/App/Storage/typings.ts +21 -0
  36. package/src/App/Storage/utils.ts +17 -0
  37. package/src/AppContext.ts +61 -19
  38. package/src/AppListener.ts +9 -8
  39. package/src/AppManager.ts +71 -36
  40. package/src/AppProxy.ts +39 -48
  41. package/src/Base/Context.ts +0 -4
  42. package/src/BoxManager.ts +9 -8
  43. package/src/BuiltinApps.ts +24 -0
  44. package/src/ContainerResizeObserver.ts +62 -0
  45. package/src/Cursor/Cursor.ts +23 -34
  46. package/src/Cursor/index.ts +70 -41
  47. package/src/Helper.ts +30 -0
  48. package/src/ReconnectRefresher.ts +15 -4
  49. package/src/Utils/Common.ts +35 -13
  50. package/src/Utils/Reactive.ts +9 -3
  51. package/src/Utils/RoomHacker.ts +15 -0
  52. package/src/{MainView.ts → View/MainView.ts} +19 -27
  53. package/src/View/ViewManager.ts +53 -0
  54. package/src/constants.ts +2 -3
  55. package/src/index.ts +81 -117
  56. package/src/shim.d.ts +4 -0
  57. package/src/style.css +6 -0
  58. package/src/typings.ts +3 -2
  59. package/vite.config.js +4 -1
  60. package/dist/Utils/CameraStore.d.ts +0 -15
  61. package/dist/ViewManager.d.ts +0 -29
  62. package/dist/sdk.d.ts +0 -14
  63. package/src/Utils/CameraStore.ts +0 -72
  64. package/src/sdk.ts +0 -39
  65. package/src/viewManager.ts +0 -177
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.4.0
2
+
3
+ 1. 废弃 `WindowManager.mount` 的多参数类型
4
+ 2. 添加 `bindContainer` 接口,`mount` 时 `container` 参数不再是必选
5
+
6
+
1
7
  ## 0.3.18
2
8
 
3
9
  1. 修复最小化时刷新页面 box 位置错误的问题
@@ -0,0 +1,28 @@
1
+ import type { MagixEventListenerOptions as WhiteMagixListenerOptions, Event as WhiteEvent, EventPhase as WhiteEventPhase, Scope as WhiteScope } from "white-web-sdk";
2
+ export interface MagixEventListenerOptions extends WhiteMagixListenerOptions {
3
+ /**
4
+ * Rapid emitted callbacks will be slowed down to this interval (in ms).
5
+ */
6
+ fireInterval?: number;
7
+ /**
8
+ * If `true`, sent events will reach self-listeners after committed to server.
9
+ * Otherwise the events will reach self-listeners immediately.
10
+ */
11
+ fireSelfEventAfterCommit?: boolean;
12
+ }
13
+ export interface MagixEventMessage<TPayloads = any, TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>> extends Omit<WhiteEvent, "scope" | "phase"> {
14
+ /** Event name */
15
+ event: TEvent;
16
+ /** Event Payload */
17
+ payload: TPayloads[TEvent];
18
+ /** Whiteboard ID of the client who dispatched the event. It will be AdminObserverId for system events. */
19
+ authorId: number;
20
+ scope: `${WhiteScope}`;
21
+ phase: `${WhiteEventPhase}`;
22
+ }
23
+ export declare type MagixEventTypes<TPayloads = any> = Extract<keyof TPayloads, string>;
24
+ export declare type MagixEventPayload<TPayloads = any, TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>> = TPayloads[TEvent];
25
+ export declare type MagixEventDispatcher<TPayloads = any> = <TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>>(event: TEvent, payload: TPayloads[TEvent]) => void;
26
+ export declare type MagixEventHandler<TPayloads = any, TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>> = (message: MagixEventMessage<TPayloads, TEvent>) => void;
27
+ export declare type MagixEventAddListener<TPayloads = any> = <TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>>(event: TEvent, handler: MagixEventHandler<TPayloads, TEvent>, options?: MagixEventListenerOptions | undefined) => void;
28
+ export declare type MagixEventRemoveListener<TPayloads = any> = <TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>>(event: TEvent, handler?: MagixEventHandler<TPayloads, TEvent>) => void;
@@ -0,0 +1,8 @@
1
+ export declare type StorageEventListener<T> = (event: T) => void;
2
+ export declare class StorageEvent<TMessage> {
3
+ listeners: Set<StorageEventListener<TMessage>>;
4
+ get length(): number;
5
+ dispatch(message: TMessage): void;
6
+ addListener(listener: StorageEventListener<TMessage>): void;
7
+ removeListener(listener: StorageEventListener<TMessage>): void;
8
+ }
@@ -0,0 +1,38 @@
1
+ import type { AppContext } from "../../AppContext";
2
+ import type { Diff } from "./typings";
3
+ import { StorageEvent } from "./StorageEvent";
4
+ export * from './typings';
5
+ export declare const STORAGE_NS = "_WM-STORAGE_";
6
+ export declare class Storage<TState extends Record<string, any> = any> implements Storage<TState> {
7
+ readonly id: string | null;
8
+ private readonly _context;
9
+ private readonly _sideEffect;
10
+ private _state;
11
+ private _destroyed;
12
+ private _refMap;
13
+ /**
14
+ * `setState` alters local state immediately before sending to server. This will cache the old value for onStateChanged diffing.
15
+ */
16
+ private _lastValue;
17
+ constructor(context: AppContext, id?: string, defaultState?: TState);
18
+ get state(): Readonly<TState>;
19
+ readonly onStateChanged: StorageEvent<Diff<TState>>;
20
+ ensureState(state: Partial<TState>): void;
21
+ setState(state: Partial<TState>): void;
22
+ /**
23
+ * Empty storage data.
24
+ */
25
+ emptyStorage(): void;
26
+ /**
27
+ * Delete storage index with all of its data and destroy the Storage instance.
28
+ */
29
+ deleteStorage(): void;
30
+ get destroyed(): boolean;
31
+ /**
32
+ * Destroy the Storage instance. The data will be kept.
33
+ */
34
+ destroy(): void;
35
+ private _getRawState;
36
+ private _setRawState;
37
+ private _updateProperties;
38
+ }
@@ -0,0 +1,21 @@
1
+ import type { StorageEventListener } from "./StorageEvent";
2
+ export declare type RefValue<TValue = any> = {
3
+ k: string;
4
+ v: TValue;
5
+ __isRef: true;
6
+ };
7
+ export declare type ExtractRawValue<TValue> = TValue extends RefValue<infer TRefValue> ? TRefValue : TValue;
8
+ export declare type AutoRefValue<TValue> = RefValue<ExtractRawValue<TValue>>;
9
+ export declare type MaybeRefValue<TValue> = TValue | AutoRefValue<TValue>;
10
+ export declare type DiffOne<T> = {
11
+ oldValue?: T;
12
+ newValue?: T;
13
+ };
14
+ export declare type Diff<T> = {
15
+ [K in keyof T]?: DiffOne<T[K]>;
16
+ };
17
+ export declare type StorageOnSetStatePayload<TState = unknown> = {
18
+ [K in keyof TState]?: MaybeRefValue<TState[K]>;
19
+ };
20
+ export declare type StorageStateChangedEvent<TState = any> = Diff<TState>;
21
+ export declare type StorageStateChangedListener<TState = any> = StorageEventListener<StorageStateChangedEvent<TState>>;
@@ -0,0 +1,5 @@
1
+ import type { AutoRefValue, RefValue } from "./typings";
2
+ export declare const plainObjectKeys: <T>(o: T) => Extract<keyof T, string>[];
3
+ export declare function isRef<TValue = unknown>(e: unknown): e is RefValue<TValue>;
4
+ export declare function makeRef<TValue>(v: TValue): RefValue<TValue>;
5
+ export declare function makeAutoRef<TValue>(v: TValue): AutoRefValue<TValue>;
@@ -6,13 +6,15 @@ import type { BoxManager } from "./BoxManager";
6
6
  import type { AppEmitterEvent } from "./index";
7
7
  import type { AppManager } from "./AppManager";
8
8
  import type { AppProxy } from "./AppProxy";
9
- export declare class AppContext<TAttrs extends Record<string, any>, AppOptions = any> {
9
+ import { Storage } from './App/Storage';
10
+ import type { MagixEventAddListener, MagixEventDispatcher, MagixEventRemoveListener } from './App/MagixEvent';
11
+ export declare class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOptions = any> {
10
12
  private manager;
11
13
  private boxManager;
12
14
  appId: string;
13
15
  private appProxy;
14
16
  private appOptions?;
15
- readonly emitter: Emittery<AppEmitterEvent<TAttrs>>;
17
+ readonly emitter: Emittery<AppEmitterEvent<TAttributes>>;
16
18
  readonly mobxUtils: {
17
19
  autorun: typeof autorun;
18
20
  reaction: typeof reaction;
@@ -27,18 +29,40 @@ export declare class AppContext<TAttrs extends Record<string, any>, AppOptions =
27
29
  private store;
28
30
  readonly isAddApp: boolean;
29
31
  readonly isReplay: boolean;
30
- constructor(manager: AppManager, boxManager: BoxManager, appId: string, appProxy: AppProxy, appOptions?: AppOptions | (() => AppOptions) | undefined);
31
- getDisplayer(): import("white-web-sdk").Displayer<import("white-web-sdk").DisplayerCallbacks>;
32
- getAttributes(): TAttrs | undefined;
33
- getScenes(): SceneDefinition[] | undefined;
34
- getView(): View | undefined;
35
- getInitScenePath(): string | undefined;
36
- getIsWritable(): boolean;
37
- getBox(): ReadonlyTeleBox;
38
- getRoom(): Room | undefined;
39
- setAttributes(attributes: TAttrs): void;
40
- updateAttributes(keys: string[], value: any): void;
41
- setScenePath(scenePath: string): Promise<void>;
42
- mountView(dom: HTMLDivElement): void;
43
- getAppOptions(): AppOptions | undefined;
32
+ constructor(manager: AppManager, boxManager: BoxManager, appId: string, appProxy: AppProxy, appOptions?: TAppOptions | (() => TAppOptions) | undefined);
33
+ getDisplayer: () => import("white-web-sdk").Displayer<import("white-web-sdk").DisplayerCallbacks>;
34
+ /** @deprecated Use context.storage.state instead. */
35
+ getAttributes: () => TAttributes | undefined;
36
+ getScenes: () => SceneDefinition[] | undefined;
37
+ getView: () => View | undefined;
38
+ getInitScenePath: () => string | undefined;
39
+ /** Get App writable status. */
40
+ getIsWritable: () => boolean;
41
+ /** Get the App Window UI box. */
42
+ getBox: () => ReadonlyTeleBox;
43
+ getRoom: () => Room | undefined;
44
+ /** @deprecated Use context.storage.setState instead. */
45
+ setAttributes: (attributes: TAttributes) => void;
46
+ /** @deprecated Use context.storage.setState instead. */
47
+ updateAttributes: (keys: string[], value: any) => void;
48
+ setScenePath: (scenePath: string) => Promise<void>;
49
+ mountView: (dom: HTMLDivElement) => void;
50
+ /** Get the local App options. */
51
+ getAppOptions: () => TAppOptions | undefined;
52
+ private _storage?;
53
+ /** Main Storage for attributes. */
54
+ get storage(): Storage<TAttributes>;
55
+ /**
56
+ * Create separated storages for flexible state management.
57
+ * @param storeId Namespace for the storage. Storages of the same namespace share the same data.
58
+ * @param defaultState Default state for initial storage creation.
59
+ * @returns
60
+ */
61
+ createStorage: <TState>(storeId: string, defaultState?: TState | undefined) => Storage<TState>;
62
+ /** Dispatch events to other clients (and self). */
63
+ dispatchMagixEvent: MagixEventDispatcher<TMagixEventPayloads>;
64
+ /** Listen to events from others clients (and self messages). */
65
+ addMagixEventListener: MagixEventAddListener<TMagixEventPayloads>;
66
+ /** Remove a Magix event listener. */
67
+ removeMagixEventListener: MagixEventRemoveListener<TMagixEventPayloads>;
44
68
  }
@@ -9,7 +9,7 @@ export declare class AppListeners {
9
9
  private mainMagixEventListener;
10
10
  private appMoveHandler;
11
11
  private appResizeHandler;
12
- private switchViewsToFreedomHandler;
13
12
  private boxStateChangeHandler;
14
13
  private setMainViewScenePathHandler;
14
+ private moveCameraToContainHandler;
15
15
  }
@@ -1,17 +1,15 @@
1
1
  import { AppStatus, Events } from "./constants";
2
2
  import { AppProxy } from "./AppProxy";
3
3
  import { WindowManager } from "./index";
4
- import { CameraStore } from "./Utils/CameraStore";
5
- import { MainViewProxy } from "./MainView";
6
- import { ReconnectRefresher } from "./ReconnectRefresher";
7
- import { ViewManager } from "./ViewManager";
4
+ import { MainViewProxy } from "./View/MainView";
5
+ import { ViewManager } from "./View/ViewManager";
6
+ import type { ReconnectRefresher } from "./ReconnectRefresher";
8
7
  import type { BoxManager } from "./BoxManager";
9
8
  import type { Displayer, Room } from "white-web-sdk";
10
9
  import type { AddAppParams, TeleBoxRect } from "./index";
11
10
  export declare class AppManager {
12
11
  windowManger: WindowManager;
13
12
  displayer: Displayer;
14
- cameraStore: CameraStore;
15
13
  viewManager: ViewManager;
16
14
  appProxies: Map<string, AppProxy>;
17
15
  appStatus: Map<string, AppStatus>;
@@ -21,6 +19,8 @@ export declare class AppManager {
21
19
  isReplay: boolean;
22
20
  private appListeners;
23
21
  boxManager?: BoxManager;
22
+ private _prevSceneIndex;
23
+ private _prevFocused;
24
24
  constructor(windowManger: WindowManager);
25
25
  private onCreated;
26
26
  /**
@@ -36,13 +36,14 @@ export declare class AppManager {
36
36
  resetMinimized(): void;
37
37
  private onAppDelete;
38
38
  bindMainView(divElement: HTMLDivElement, disableCameraTransform: boolean): void;
39
+ setMainViewFocusPath(): void;
39
40
  addApp(params: AddAppParams, isDynamicPPT: boolean): Promise<string | undefined>;
40
41
  private beforeAddApp;
41
42
  private afterAddApp;
42
43
  closeApp(appId: string): Promise<void>;
43
44
  private baseInsertApp;
44
45
  private displayerStateListener;
45
- private displayerWritableListener;
46
+ displayerWritableListener: (isReadonly: boolean) => void;
46
47
  private get eventName();
47
48
  get attributes(): import("./index").WindowMangerAttributes;
48
49
  get canOperate(): boolean;
@@ -58,7 +59,7 @@ export declare class AppManager {
58
59
  safeDispatchMagixEvent(event: string, payload: any): void;
59
60
  private boxEventListener;
60
61
  focusByAttributes(apps: any): void;
61
- notifyReconnected(): Promise<void>;
62
+ onReconnected(): Promise<void>;
62
63
  notifyContainerRectUpdate(rect: TeleBoxRect): void;
63
64
  dispatchInternalEvent(event: Events, payload: any): void;
64
65
  destroy(): void;
@@ -15,12 +15,11 @@ export declare class AppProxy extends Base {
15
15
  private boxManager;
16
16
  private appProxies;
17
17
  private viewManager;
18
- private cameraStore;
19
18
  private kind;
20
19
  isAddApp: boolean;
21
20
  private status;
22
21
  private stateKey;
23
- private setupResult?;
22
+ private appResult?;
24
23
  private appContext?;
25
24
  constructor(params: BaseInsertParams, manager: AppManager, appId: string, isAddApp: boolean);
26
25
  private initScenes;
@@ -29,8 +28,9 @@ export declare class AppProxy extends Base {
29
28
  get attributes(): any;
30
29
  get appAttributes(): import("./index").AppSyncAttributes;
31
30
  getFullScenePath(): string | undefined;
31
+ private getFullScenePathFromScenes;
32
32
  setFullPath(path: string): void;
33
- baseInsertApp(skipUpdate?: boolean, focus?: boolean): Promise<{
33
+ baseInsertApp(skipUpdate?: boolean): Promise<{
34
34
  appId: string;
35
35
  app: NetlessApp;
36
36
  }>;
@@ -42,12 +42,12 @@ export declare class AppProxy extends Base {
42
42
  private afterSetupApp;
43
43
  onSeek(time: number): void;
44
44
  onReconnected(): Promise<void>;
45
- switchToWritable(): void;
46
45
  getAppInitState: (id: string) => AppInitState | undefined;
47
46
  emitAppSceneStateChange(sceneState: SceneState): void;
48
47
  emitAppIsWritableChange(): void;
49
48
  private makeAppEventListener;
50
49
  private appAttributesUpdateListener;
50
+ private setFocusScenePathHandler;
51
51
  setScenePath(): void;
52
52
  setViewFocusScenePath(): void;
53
53
  private createView;
@@ -8,6 +8,5 @@ export declare class Context {
8
8
  findMemberByUid: (uid: string) => import("white-web-sdk").RoomMember | undefined;
9
9
  updateManagerRect(): void;
10
10
  blurFocusBox(): void;
11
- switchAppToWriter(id: string): void;
12
11
  }
13
12
  export declare const createContext: (manager: AppManager) => Context;
@@ -56,6 +56,7 @@ export declare class BoxManager {
56
56
  private createTeleBoxManagerConfig?;
57
57
  teleBoxManager: TeleBoxManager;
58
58
  constructor(context: BoxManagerContext, createTeleBoxManagerConfig?: CreateTeleBoxManagerConfig | undefined);
59
+ private playgroundSizeChangeListener;
59
60
  private get mainView();
60
61
  private get canOperate();
61
62
  get boxState(): "normal" | "minimized" | "maximized";
@@ -0,0 +1,6 @@
1
+ import "@netless/app-docs-viewer/dist/style.css";
2
+ export declare const setupBuiltin: () => void;
3
+ export declare const BuiltinApps: {
4
+ DocsViewer: string;
5
+ MediaPlayer: string;
6
+ };
@@ -0,0 +1,10 @@
1
+ import type { EmitterType } from "./index";
2
+ export declare class ContainerResizeObserver {
3
+ private emitter;
4
+ private containerResizeObserver?;
5
+ constructor(emitter: EmitterType);
6
+ static create(container: HTMLElement, sizer: HTMLElement, wrapper: HTMLDivElement, emitter: EmitterType): ContainerResizeObserver;
7
+ observePlaygroundSize(container: HTMLElement, sizer: HTMLElement, wrapper: HTMLDivElement): void;
8
+ private updateSizer;
9
+ disconnect(): void;
10
+ }
@@ -13,11 +13,10 @@ export declare class Cursor extends Base {
13
13
  private cursorManager;
14
14
  private wrapper?;
15
15
  private member?;
16
- private disposer;
17
16
  private timer?;
18
17
  private component?;
19
- constructor(manager: AppManager, cursors: any, memberId: string, cursorManager: CursorManager, wrapper?: HTMLElement | undefined);
20
- private startReaction;
18
+ constructor(manager: AppManager, addCursorChangeListener: (uid: string, callback: (position: Position, state: CursorState) => void) => void, cursors: any, memberId: string, cursorManager: CursorManager, wrapper?: HTMLElement | undefined);
19
+ private onCursorChange;
21
20
  private moveCursor;
22
21
  get memberApplianceName(): ApplianceNames | undefined;
23
22
  get memberColor(): string;
@@ -1,6 +1,7 @@
1
- import { Base } from '../Base';
2
- import { Cursor } from './Cursor';
3
- import type { PositionType } from "../AttributesDelegate";
1
+ import { Base } from "../Base";
2
+ import { Cursor } from "./Cursor";
3
+ import { CursorState } from "../constants";
4
+ import type { PositionType, Position } from "../AttributesDelegate";
4
5
  import type { RoomMember, View } from "white-web-sdk";
5
6
  import type { AppManager } from "../AppManager";
6
7
  export declare type EventType = {
@@ -19,6 +20,7 @@ export declare class CursorManager extends Base {
19
20
  cursorInstances: Map<string, Cursor>;
20
21
  roomMembers?: readonly RoomMember[];
21
22
  private mainViewElement?;
23
+ private sideEffectManager;
22
24
  constructor(appManager: AppManager);
23
25
  setupWrapper(wrapper: HTMLElement): void;
24
26
  setMainViewDivElement(div: HTMLDivElement): void;
@@ -29,7 +31,6 @@ export declare class CursorManager extends Base {
29
31
  get boxState(): any;
30
32
  get focusView(): View | undefined;
31
33
  private mouseMoveListener;
32
- private touchMoveListener;
33
34
  private updateCursor;
34
35
  private getPoint;
35
36
  /**
@@ -44,5 +45,7 @@ export declare class CursorManager extends Base {
44
45
  deleteCursor(uid: string): void;
45
46
  hideCursor(uid: string): void;
46
47
  cleanMemberAttributes(members: readonly RoomMember[]): void;
48
+ onReconnect(): void;
49
+ addCursorChangeListener: (uid: string, callback: (position: Position, state: CursorState) => void) => void;
47
50
  destroy(): void;
48
51
  }
@@ -0,0 +1,6 @@
1
+ export declare const setupWrapper: (root: HTMLElement) => {
2
+ playground: HTMLDivElement;
3
+ wrapper: HTMLDivElement;
4
+ sizer: HTMLDivElement;
5
+ mainViewElement: HTMLDivElement;
6
+ };
@@ -1,12 +1,17 @@
1
1
  import type { Room } from "white-web-sdk";
2
- import type { AppManager } from "./AppManager";
2
+ import type { EmitterType } from "./index";
3
+ export declare type ReconnectRefresherContext = {
4
+ emitter: EmitterType;
5
+ };
3
6
  export declare class ReconnectRefresher {
4
- private manager;
7
+ private ctx;
5
8
  private phase?;
6
9
  private room;
7
10
  private reactors;
8
11
  private disposers;
9
- constructor(room: Room | undefined, manager: AppManager);
12
+ constructor(ctx: ReconnectRefresherContext);
13
+ setRoom(room: Room | undefined): void;
14
+ setContext(ctx: ReconnectRefresherContext): void;
10
15
  private onPhaseChanged;
11
16
  private onReconnected;
12
17
  private releaseDisposers;
@@ -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,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;
@@ -91,6 +92,7 @@ export declare type EmitterEvent = {
91
92
  observerIdChange: number;
92
93
  boxStateChange: string;
93
94
  playgroundSizeChange: DOMRect;
95
+ onReconnected: void;
94
96
  };
95
97
  export declare type EmitterType = Emittery<EmitterEvent>;
96
98
  export declare const emitter: EmitterType;
@@ -100,6 +102,9 @@ export declare type PublicEvent = {
100
102
  darkModeChange: boolean;
101
103
  prefersColorSchemeChange: TeleBoxColorScheme;
102
104
  cameraStateChange: CameraState;
105
+ mainViewScenePathChange: string;
106
+ mainViewSceneIndexChange: number;
107
+ focusedChange: string | undefined;
103
108
  };
104
109
  export declare type MountParams = {
105
110
  room: Room;
@@ -118,6 +123,7 @@ export declare type MountParams = {
118
123
  };
119
124
  export declare type CallbacksType = Emittery<PublicEvent>;
120
125
  export declare const callbacks: CallbacksType;
126
+ export declare const reconnectRefresher: ReconnectRefresher;
121
127
  export declare class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
122
128
  static kind: string;
123
129
  static displayer: Displayer;
@@ -137,21 +143,21 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
137
143
  isReplay: boolean;
138
144
  private boxManager?;
139
145
  private static params?;
146
+ private containerResizeObserver?;
140
147
  constructor(context: InvisiblePluginContext);
141
148
  static mount(params: MountParams): Promise<WindowManager>;
142
149
  private static initManager;
143
150
  private static initContainer;
144
- bindContainer(container: HTMLElement, collectorContainer?: HTMLElement): void;
151
+ bindContainer(container: HTMLElement): void;
152
+ bindCollectorContainer(container: HTMLElement): void;
145
153
  /**
146
154
  * 注册插件
147
155
  */
148
156
  static register<AppOptions = any, SetupResult = any, Attributes = any>(params: RegisterParams<AppOptions, SetupResult, Attributes>): Promise<void>;
149
- static setContainer(container: HTMLElement): void;
150
- static setCollectorContainer(container: HTMLElement): void;
151
157
  /**
152
158
  * 创建一个 app 至白板
153
159
  */
154
- addApp(params: AddAppParams): Promise<string | undefined>;
160
+ addApp<T = any>(params: AddAppParams<T>): Promise<string | undefined>;
155
161
  private setupScenePath;
156
162
  /**
157
163
  * 设置 mainView 的 ScenePath, 并且切换白板为可写状态
@@ -192,6 +198,7 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
192
198
  get boxState(): TeleBoxState | undefined;
193
199
  get darkMode(): boolean;
194
200
  get prefersColorScheme(): TeleBoxColorScheme | undefined;
201
+ get focused(): string | undefined;
195
202
  /**
196
203
  * 查询所有的 App
197
204
  */
@@ -224,13 +231,6 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
224
231
  private isDynamicPPT;
225
232
  private static checkVersion;
226
233
  private ensureAttributes;
227
- private containerResizeObserver?;
228
- private observePlaygroundSize;
229
- private updateSizer;
230
234
  }
231
- export declare const BuiltinApps: {
232
- DocsViewer: string;
233
- MediaPlayer: string;
234
- };
235
235
  export * from "./typings";
236
- export { WhiteWindowSDK } from "./sdk";
236
+ export { BuiltinApps } from "./BuiltinApps";