@netless/window-manager 1.0.0-canary.24 → 1.0.0-canary.27
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/dist/App/AppContext.d.ts +1 -1
- package/dist/App/WhiteboardView.d.ts +6 -4
- package/dist/AppListener.d.ts +0 -2
- package/dist/BoxManager.d.ts +2 -1
- package/dist/BuiltinApps.d.ts +3 -0
- package/dist/Cursor/index.d.ts +3 -2
- package/dist/Helper.d.ts +3 -1
- package/dist/callback.d.ts +5 -0
- package/dist/constants.d.ts +0 -2
- package/dist/index.cjs.js +82 -12
- package/dist/index.d.ts +16 -9
- package/dist/index.es.js +1620 -704
- package/dist/index.umd.js +82 -12
- package/dist/src/App/AppContext.d.ts +78 -0
- package/dist/src/App/AppPageStateImpl.d.ts +21 -0
- package/dist/src/App/AppProxy.d.ts +98 -0
- package/dist/src/App/MagixEvent/index.d.ts +29 -0
- package/dist/src/App/Storage/StorageEvent.d.ts +8 -0
- package/dist/src/App/Storage/index.d.ts +39 -0
- package/dist/src/App/Storage/typings.d.ts +22 -0
- package/dist/src/App/Storage/utils.d.ts +5 -0
- package/dist/src/App/WhiteboardView.d.ts +27 -0
- package/dist/src/App/index.d.ts +4 -0
- package/dist/src/App/type.d.ts +21 -0
- package/dist/src/AppListener.d.ts +19 -0
- package/dist/src/AppManager.d.ts +107 -0
- package/dist/src/AttributesDelegate.d.ts +83 -0
- package/dist/src/BoxEmitter.d.ts +34 -0
- package/dist/src/BoxManager.d.ts +102 -0
- package/dist/src/BuiltinApps.d.ts +8 -0
- package/dist/src/Cursor/Cursor.d.ts +39 -0
- package/dist/src/Cursor/icons.d.ts +3 -0
- package/dist/src/Cursor/index.d.ts +46 -0
- package/dist/src/Helper.d.ts +19 -0
- package/dist/src/InternalEmitter.d.ts +38 -0
- package/dist/src/Page/PageController.d.ts +21 -0
- package/dist/src/Page/index.d.ts +3 -0
- package/dist/src/PageState.d.ts +9 -0
- package/dist/src/ReconnectRefresher.d.ts +24 -0
- package/dist/src/RedoUndo.d.ts +18 -0
- package/dist/src/Register/index.d.ts +28 -0
- package/dist/src/Register/loader.d.ts +4 -0
- package/dist/src/Register/storage.d.ts +8 -0
- package/dist/src/Utils/AppCreateQueue.d.ts +15 -0
- package/dist/src/Utils/Common.d.ts +23 -0
- package/dist/src/Utils/Reactive.d.ts +6 -0
- package/dist/src/Utils/RoomHacker.d.ts +3 -0
- package/dist/src/Utils/error.d.ts +27 -0
- package/dist/src/Utils/log.d.ts +1 -0
- package/dist/src/View/CameraSynchronizer.d.ts +17 -0
- package/dist/src/View/MainView.d.ts +59 -0
- package/dist/src/View/ViewManager.d.ts +13 -0
- package/dist/src/View/ViewSync.d.ts +24 -0
- package/dist/src/callback.d.ts +29 -0
- package/dist/src/constants.d.ts +51 -0
- package/dist/src/image.d.ts +19 -0
- package/dist/src/index.d.ts +267 -0
- package/dist/src/shim.d.ts +11 -0
- package/dist/src/typings.d.ts +88 -0
- package/dist/style.css +1 -1
- package/dist/typings.d.ts +6 -0
- package/docs/app-context.md +68 -26
- package/package.json +10 -5
- package/playwright.config.ts +28 -0
- package/pnpm-lock.yaml +516 -30
- package/src/App/AppContext.ts +14 -6
- package/src/App/AppProxy.ts +17 -7
- package/src/App/WhiteboardView.ts +23 -18
- package/src/AppListener.ts +1 -21
- package/src/AppManager.ts +2 -1
- package/src/BoxManager.ts +32 -24
- package/src/BuiltinApps.ts +5 -0
- package/src/Cursor/Cursor.ts +6 -2
- package/src/Cursor/index.ts +5 -5
- package/src/Helper.ts +23 -5
- package/src/View/CameraSynchronizer.ts +5 -9
- package/src/View/MainView.ts +3 -1
- package/src/callback.ts +1 -0
- package/src/constants.ts +0 -2
- package/src/index.ts +69 -45
- package/src/style.css +2 -45
- package/src/typings.ts +6 -0
- package/vite.config.js +5 -3
@@ -0,0 +1,78 @@
|
|
1
|
+
import { Storage } from "./Storage";
|
2
|
+
import { autorun, listenDisposed, listenUpdated, reaction, unlistenDisposed, unlistenUpdated, toJS } from "white-web-sdk";
|
3
|
+
import type { Room, SceneDefinition, View } from "white-web-sdk";
|
4
|
+
import type { ReadonlyTeleBox } from "@netless/telebox-insider";
|
5
|
+
import type Emittery from "emittery";
|
6
|
+
import type { AppEmitterEvent, Member } from "../index";
|
7
|
+
import type { AppManager } from "../AppManager";
|
8
|
+
import type { AppProxy } from "./AppProxy";
|
9
|
+
import type { MagixEventAddListener, MagixEventDispatcher, MagixEventRemoveListener } from "./MagixEvent";
|
10
|
+
import { WhiteBoardView } from "./WhiteboardView";
|
11
|
+
export declare type CreateWhiteBoardViewParams = {
|
12
|
+
size?: number;
|
13
|
+
syncCamera?: boolean;
|
14
|
+
};
|
15
|
+
export declare class AppContext<TAttributes = any, TMagixEventPayloads = any, TAppOptions = any> {
|
16
|
+
private manager;
|
17
|
+
appId: string;
|
18
|
+
private appProxy;
|
19
|
+
private appOptions?;
|
20
|
+
readonly emitter: Emittery<AppEmitterEvent<TAttributes>>;
|
21
|
+
readonly mobxUtils: {
|
22
|
+
autorun: typeof autorun;
|
23
|
+
reaction: typeof reaction;
|
24
|
+
toJS: typeof toJS;
|
25
|
+
};
|
26
|
+
readonly objectUtils: {
|
27
|
+
listenUpdated: typeof listenUpdated;
|
28
|
+
unlistenUpdated: typeof unlistenUpdated;
|
29
|
+
listenDisposed: typeof listenDisposed;
|
30
|
+
unlistenDisposed: typeof unlistenDisposed;
|
31
|
+
};
|
32
|
+
private store;
|
33
|
+
readonly isAddApp: boolean;
|
34
|
+
readonly isReplay: boolean;
|
35
|
+
whiteBoardView?: WhiteBoardView;
|
36
|
+
_viewWrapper?: HTMLElement;
|
37
|
+
constructor(manager: AppManager, appId: string, appProxy: AppProxy, appOptions?: TAppOptions | (() => TAppOptions) | undefined);
|
38
|
+
get displayer(): import("white-web-sdk").Displayer<import("white-web-sdk").DisplayerCallbacks>;
|
39
|
+
get destroyed(): boolean;
|
40
|
+
/** @deprecated Use context.storage.state instead. */
|
41
|
+
getAttributes: () => TAttributes | undefined;
|
42
|
+
getScenes: () => SceneDefinition[] | undefined;
|
43
|
+
get view(): View | undefined;
|
44
|
+
createWhiteBoardView: (params?: CreateWhiteBoardViewParams | undefined) => WhiteBoardView;
|
45
|
+
private ensurePageSize;
|
46
|
+
getInitScenePath: () => string | undefined;
|
47
|
+
/** Get App writable status. */
|
48
|
+
get isWritable(): boolean;
|
49
|
+
/** Get the App Window UI box. */
|
50
|
+
get box(): ReadonlyTeleBox;
|
51
|
+
get room(): Room | undefined;
|
52
|
+
get members(): Member[];
|
53
|
+
get currentMember(): Member;
|
54
|
+
/** @deprecated Use context.storage.setState instead. */
|
55
|
+
setAttributes: (attributes: TAttributes) => void;
|
56
|
+
/** @deprecated Use context.storage.setState instead. */
|
57
|
+
updateAttributes: (keys: string[], value: any) => void;
|
58
|
+
/** @deprecated Use Pages api instead. */
|
59
|
+
setScenePath: (scenePath: string) => Promise<void>;
|
60
|
+
/** Get the local App options. */
|
61
|
+
getAppOptions: () => TAppOptions | undefined;
|
62
|
+
private _storage?;
|
63
|
+
/** Main Storage for attributes. */
|
64
|
+
get storage(): Storage<TAttributes>;
|
65
|
+
/**
|
66
|
+
* Create separated storages for flexible state management.
|
67
|
+
* @param storeId Namespace for the storage. Storages of the same namespace share the same data.
|
68
|
+
* @param defaultState Default state for initial storage creation.
|
69
|
+
* @returns
|
70
|
+
*/
|
71
|
+
createStorage: <TState>(storeId: string, defaultState?: TState | undefined) => Storage<TState>;
|
72
|
+
/** Dispatch events to other clients (and self). */
|
73
|
+
dispatchMagixEvent: MagixEventDispatcher<TMagixEventPayloads>;
|
74
|
+
/** Listen to events from others clients (and self messages). */
|
75
|
+
addMagixEventListener: MagixEventAddListener<TMagixEventPayloads>;
|
76
|
+
/** Remove a Magix event listener. */
|
77
|
+
removeMagixEventListener: MagixEventRemoveListener<TMagixEventPayloads>;
|
78
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import type { Displayer, ScenesCallbacksNode, 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
|
+
sceneNode: ScenesCallbacksNode | null;
|
12
|
+
private scenePath?;
|
13
|
+
private view?;
|
14
|
+
constructor(params: AppPageStateParams);
|
15
|
+
createSceneNode: (scenePath: string) => ScenesCallbacksNode | null;
|
16
|
+
setView(view: View): void;
|
17
|
+
private onSceneChange;
|
18
|
+
getFullPath(index: number): string | undefined;
|
19
|
+
toObject(): PageState;
|
20
|
+
destroy(): void;
|
21
|
+
}
|
@@ -0,0 +1,98 @@
|
|
1
|
+
import Emittery from "emittery";
|
2
|
+
import { AppContext } from "./AppContext";
|
3
|
+
import { AppPageStateImpl } from "./AppPageStateImpl";
|
4
|
+
import { Val } from "value-enhancer";
|
5
|
+
import { SideEffectManager } from "side-effect-manager";
|
6
|
+
import type { ICamera, ISize } from "../AttributesDelegate";
|
7
|
+
import type { AppEmitterEvent, BaseInsertParams } from "../index";
|
8
|
+
import type { SceneState, View, SceneDefinition } from "white-web-sdk";
|
9
|
+
import type { AppManager } from "../AppManager";
|
10
|
+
import type { NetlessApp } from "../typings";
|
11
|
+
import type { ReadonlyTeleBox } from "@netless/telebox-insider";
|
12
|
+
import type { PageRemoveService, PageState } from "../Page";
|
13
|
+
import type { AppState } from "./type";
|
14
|
+
export declare type AppEmitter = Emittery<AppEmitterEvent>;
|
15
|
+
export declare class AppProxy implements PageRemoveService {
|
16
|
+
private params;
|
17
|
+
private manager;
|
18
|
+
kind: string;
|
19
|
+
id: string;
|
20
|
+
scenePath?: string;
|
21
|
+
private appScenePath;
|
22
|
+
appEmitter: AppEmitter;
|
23
|
+
scenes?: SceneDefinition[];
|
24
|
+
private appListener;
|
25
|
+
private boxManager;
|
26
|
+
private appProxies;
|
27
|
+
private viewManager;
|
28
|
+
private store;
|
29
|
+
uid: string;
|
30
|
+
isAddApp: boolean;
|
31
|
+
status: "normal" | "destroyed";
|
32
|
+
private stateKey;
|
33
|
+
_pageState: AppPageStateImpl;
|
34
|
+
appResult?: NetlessApp;
|
35
|
+
appContext?: AppContext;
|
36
|
+
sideEffectManager: SideEffectManager;
|
37
|
+
private valManager;
|
38
|
+
private fullPath$;
|
39
|
+
private viewSync?;
|
40
|
+
camera$: Val<{
|
41
|
+
id: string;
|
42
|
+
centerX: number | null;
|
43
|
+
centerY: number | null;
|
44
|
+
scale: number;
|
45
|
+
} | undefined, any>;
|
46
|
+
size$: Val<ISize | undefined, any>;
|
47
|
+
box$: Val<ReadonlyTeleBox | undefined, any>;
|
48
|
+
view$: Val<View | undefined, any>;
|
49
|
+
syncCamera$: Val<boolean, any>;
|
50
|
+
whiteBoardViewCreated$: Val<boolean, any>;
|
51
|
+
constructor(params: BaseInsertParams, manager: AppManager, appId: string, isAddApp: boolean);
|
52
|
+
fireMemberStateChange: () => void;
|
53
|
+
private onMemberStateChange;
|
54
|
+
private computedInitialRect;
|
55
|
+
createAppDir(): View;
|
56
|
+
private initScenes;
|
57
|
+
get view(): View | undefined;
|
58
|
+
get viewIndex(): number | undefined;
|
59
|
+
get isWritable(): boolean;
|
60
|
+
get attributes(): any;
|
61
|
+
get appAttributes(): import("../index").AppSyncAttributes;
|
62
|
+
getFullScenePath(): string | undefined;
|
63
|
+
private getFullScenePathFromScenes;
|
64
|
+
setFullPath(path: string): void;
|
65
|
+
baseInsertApp(skipUpdate?: boolean): Promise<{
|
66
|
+
appId: string;
|
67
|
+
app: NetlessApp;
|
68
|
+
}>;
|
69
|
+
get box(): ReadonlyTeleBox | undefined;
|
70
|
+
private setupApp;
|
71
|
+
private fixMobileSize;
|
72
|
+
onSeek(time: number): Promise<void>;
|
73
|
+
onReconnected(): Promise<void>;
|
74
|
+
onRemoveScene(scenePath: string): Promise<void>;
|
75
|
+
getAppInitState: (id: string) => AppState | undefined;
|
76
|
+
emitAppSceneStateChange(sceneState: SceneState): void;
|
77
|
+
emitAppIsWritableChange(): void;
|
78
|
+
private makeAppEventListener;
|
79
|
+
private appAttributesUpdateListener;
|
80
|
+
private setFocusScenePathHandler;
|
81
|
+
setScenePath(): void;
|
82
|
+
setViewFocusScenePath(): string | undefined;
|
83
|
+
private createView;
|
84
|
+
notifyPageStateChange: import("lodash").DebouncedFunc<() => void>;
|
85
|
+
get pageState(): PageState;
|
86
|
+
removeSceneByIndex(index: number): Promise<boolean>;
|
87
|
+
setSceneIndexWithoutSync(index: number): void;
|
88
|
+
setSceneIndex(index: number): void;
|
89
|
+
storeCamera: (camera: ICamera) => void;
|
90
|
+
storeSize: (size: ISize) => void;
|
91
|
+
updateSize: (width: number, height: number) => void;
|
92
|
+
moveCamera: (camera: Partial<ICamera>) => void;
|
93
|
+
destroy(needCloseBox: boolean, cleanAttrs: boolean, skipUpdate: boolean, error?: Error): Promise<void>;
|
94
|
+
private addCameraReaction;
|
95
|
+
private addSizeReaction;
|
96
|
+
onFocus: () => void;
|
97
|
+
close(): Promise<void>;
|
98
|
+
}
|
@@ -0,0 +1,29 @@
|
|
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 MagixEventListenerDisposer = () => void;
|
28
|
+
export declare type MagixEventAddListener<TPayloads = any> = <TEvent extends MagixEventTypes<TPayloads> = MagixEventTypes<TPayloads>>(event: TEvent, handler: MagixEventHandler<TPayloads, TEvent>, options?: MagixEventListenerOptions | undefined) => MagixEventListenerDisposer;
|
29
|
+
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,39 @@
|
|
1
|
+
import type { AppContext } from "../AppContext";
|
2
|
+
import type { Diff, StorageStateChangedListener, StorageStateChangedListenerDisposer } 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
|
+
addStateChangedListener(handler: StorageStateChangedListener<TState>): StorageStateChangedListenerDisposer;
|
21
|
+
ensureState(state: Partial<TState>): void;
|
22
|
+
setState(state: Partial<TState>): void;
|
23
|
+
/**
|
24
|
+
* Empty storage data.
|
25
|
+
*/
|
26
|
+
emptyStorage(): void;
|
27
|
+
/**
|
28
|
+
* Delete storage index with all of its data and destroy the Storage instance.
|
29
|
+
*/
|
30
|
+
deleteStorage(): void;
|
31
|
+
get destroyed(): boolean;
|
32
|
+
/**
|
33
|
+
* Destroy the Storage instance. The data will be kept.
|
34
|
+
*/
|
35
|
+
destroy(): void;
|
36
|
+
private _getRawState;
|
37
|
+
private _setRawState;
|
38
|
+
private _updateProperties;
|
39
|
+
}
|
@@ -0,0 +1,22 @@
|
|
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>>;
|
22
|
+
export declare type StorageStateChangedListenerDisposer = () => void;
|
@@ -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>;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import type { ReadonlyVal } from "value-enhancer";
|
2
|
+
import type { AddPageParams, PageController, PageState } from "../Page";
|
3
|
+
import type { AppProxy } from "./AppProxy";
|
4
|
+
import type { AppContext } from "./AppContext";
|
5
|
+
import type { View } from "white-web-sdk";
|
6
|
+
import type { TeleBoxRect } from "@netless/telebox-insider";
|
7
|
+
import type { ICamera, ISize } from "../AttributesDelegate";
|
8
|
+
export declare type WhiteBoardViewCamera = Omit<ICamera, "id">;
|
9
|
+
export declare type WhiteBoardViewRect = Omit<ISize, "id">;
|
10
|
+
export declare class WhiteBoardView implements PageController {
|
11
|
+
view: View;
|
12
|
+
protected appContext: AppContext;
|
13
|
+
protected appProxy: AppProxy;
|
14
|
+
ensureSize: (size: number) => void;
|
15
|
+
readonly pageState$: ReadonlyVal<PageState>;
|
16
|
+
readonly baseCamera$: ReadonlyVal<WhiteBoardViewCamera>;
|
17
|
+
readonly baseRect$: ReadonlyVal<WhiteBoardViewRect | undefined>;
|
18
|
+
constructor(view: View, appContext: AppContext, appProxy: AppProxy, ensureSize: (size: number) => void);
|
19
|
+
get pageState(): PageState;
|
20
|
+
moveCamera(camera: Partial<WhiteBoardViewCamera>): void;
|
21
|
+
nextPage: () => Promise<boolean>;
|
22
|
+
prevPage: () => Promise<boolean>;
|
23
|
+
jumpPage: (index: number) => Promise<boolean>;
|
24
|
+
addPage: (params?: AddPageParams | undefined) => Promise<void>;
|
25
|
+
removePage: (index?: number | undefined) => Promise<boolean>;
|
26
|
+
setBaseRect(rect: Omit<TeleBoxRect, "x" | "y">): void;
|
27
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
export declare type AppState = {
|
2
|
+
id: string;
|
3
|
+
focus?: boolean;
|
4
|
+
SceneIndex?: number;
|
5
|
+
draggable?: boolean;
|
6
|
+
position?: {
|
7
|
+
x: number;
|
8
|
+
y: number;
|
9
|
+
};
|
10
|
+
ratio?: number;
|
11
|
+
resizable?: boolean;
|
12
|
+
size?: {
|
13
|
+
width: number;
|
14
|
+
height: number;
|
15
|
+
};
|
16
|
+
stageRatio?: number;
|
17
|
+
visible?: boolean;
|
18
|
+
zIndex?: number;
|
19
|
+
maximized: boolean | null;
|
20
|
+
minimized: boolean | null;
|
21
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import type { AppManager } from "./AppManager";
|
2
|
+
export declare class AppListeners {
|
3
|
+
private manager;
|
4
|
+
private displayer;
|
5
|
+
constructor(manager: AppManager);
|
6
|
+
private get boxManager();
|
7
|
+
addListeners(): void;
|
8
|
+
removeListeners(): void;
|
9
|
+
private mainMagixEventListener;
|
10
|
+
private appMoveHandler;
|
11
|
+
private appResizeHandler;
|
12
|
+
private boxStateChangeHandler;
|
13
|
+
private setMainViewScenePathHandler;
|
14
|
+
private cursorMoveHandler;
|
15
|
+
private rootDirRemovedHandler;
|
16
|
+
private refreshHandler;
|
17
|
+
private initMainViewCameraHandler;
|
18
|
+
private setAppFocusViewIndexHandler;
|
19
|
+
}
|
@@ -0,0 +1,107 @@
|
|
1
|
+
import { AppStatus, Events } from "./constants";
|
2
|
+
import { AppProxy } from "./App";
|
3
|
+
import { MainViewProxy } from "./View/MainView";
|
4
|
+
import { WindowManager } from "./index";
|
5
|
+
import { ViewManager } from "./View/ViewManager";
|
6
|
+
import type { ReconnectRefresher } from "./ReconnectRefresher";
|
7
|
+
import type { BoxManager } from "./BoxManager";
|
8
|
+
import type { Displayer, Room, SceneState } from "white-web-sdk";
|
9
|
+
import type { AddAppParams, TeleBoxRect } from "./index";
|
10
|
+
import type { Member } from "./Helper";
|
11
|
+
export declare class AppManager {
|
12
|
+
windowManger: WindowManager;
|
13
|
+
displayer: Displayer;
|
14
|
+
viewManager: ViewManager;
|
15
|
+
appProxies: Map<string, AppProxy>;
|
16
|
+
appStatus: Map<string, AppStatus>;
|
17
|
+
store: import("./AttributesDelegate").AttributesDelegate;
|
18
|
+
mainViewProxy: MainViewProxy;
|
19
|
+
refresher: ReconnectRefresher;
|
20
|
+
isReplay: boolean;
|
21
|
+
mainViewScenesLength: number;
|
22
|
+
private appListeners;
|
23
|
+
boxManager?: BoxManager;
|
24
|
+
private callbacksNode;
|
25
|
+
private appCreateQueue;
|
26
|
+
private sceneIndex$;
|
27
|
+
private focused$;
|
28
|
+
private sideEffectManager;
|
29
|
+
sceneState: SceneState | null;
|
30
|
+
rootDirRemoving: boolean;
|
31
|
+
constructor(windowManger: WindowManager);
|
32
|
+
private onRemoveScenes;
|
33
|
+
/**
|
34
|
+
* 根目录被删除时所有的 scene 都会被删除.
|
35
|
+
* 所以需要关掉所有开启了 view 的 app
|
36
|
+
*/
|
37
|
+
onRootDirRemoved(needClose?: boolean): Promise<void>;
|
38
|
+
private onReadonlyChanged;
|
39
|
+
private onPlayerSeekStart;
|
40
|
+
private onPlayerSeekDone;
|
41
|
+
createRootDirScenesCallback: () => void;
|
42
|
+
removeSceneByIndex: (index: number) => Promise<boolean>;
|
43
|
+
setSceneIndexWithoutSync: (index: number) => void;
|
44
|
+
private onSceneChange;
|
45
|
+
private emitMainViewScenesChange;
|
46
|
+
private updateSceneState;
|
47
|
+
private get eventName();
|
48
|
+
get attributes(): import("./index").WindowMangerAttributes;
|
49
|
+
get canOperate(): boolean;
|
50
|
+
get room(): Room | undefined;
|
51
|
+
get mainView(): import("white-web-sdk").View;
|
52
|
+
get focusApp(): AppProxy | undefined;
|
53
|
+
get uid(): string;
|
54
|
+
get members(): Member[];
|
55
|
+
getMainViewSceneDir(): string;
|
56
|
+
private onCreated;
|
57
|
+
private onBoxMove;
|
58
|
+
private onBoxResize;
|
59
|
+
private onBoxFocus;
|
60
|
+
private onBoxClose;
|
61
|
+
private onBoxStateChange;
|
62
|
+
addAppsChangeListener: () => void;
|
63
|
+
addAppCloseListener: () => void;
|
64
|
+
private onMainViewIndexChange;
|
65
|
+
private onFocusChange;
|
66
|
+
attributesUpdateCallback: import("lodash").DebouncedFunc<(apps: any) => Promise<void>>;
|
67
|
+
/**
|
68
|
+
* 插件更新 apps 时的回调
|
69
|
+
*
|
70
|
+
* @param {*} apps
|
71
|
+
* @memberof WindowManager
|
72
|
+
*/
|
73
|
+
_attributesUpdateCallback(apps: any): Promise<void>;
|
74
|
+
private onRegisteredChange;
|
75
|
+
private onMinimized;
|
76
|
+
refresh(): void;
|
77
|
+
setBoxManager(boxManager: BoxManager): void;
|
78
|
+
resetMaximized(): void;
|
79
|
+
resetMinimized(): void;
|
80
|
+
private onAppDelete;
|
81
|
+
private closeAll;
|
82
|
+
bindMainView(divElement: HTMLDivElement, disableCameraTransform: boolean): void;
|
83
|
+
setMainViewFocusPath(scenePath?: string): boolean | undefined;
|
84
|
+
private resetScenePath;
|
85
|
+
addApp(params: AddAppParams, isDynamicPPT: boolean): Promise<string | undefined>;
|
86
|
+
private beforeAddApp;
|
87
|
+
private afterAddApp;
|
88
|
+
closeApp(appId: string, needClose?: boolean): Promise<void>;
|
89
|
+
private baseInsertApp;
|
90
|
+
private displayerStateListener;
|
91
|
+
displayerWritableListener: (isReadonly: boolean) => void;
|
92
|
+
safeSetAttributes(attributes: any): void;
|
93
|
+
safeUpdateAttributes(keys: string[], value: any): void;
|
94
|
+
setMainViewScenePath(scenePath: string): Promise<void>;
|
95
|
+
private _setMainViewScenePath;
|
96
|
+
private updateSceneIndex;
|
97
|
+
setMainViewSceneIndex(index: number): Promise<void>;
|
98
|
+
private dispatchSetMainViewScenePath;
|
99
|
+
getAppInitPath(appId: string): string | undefined;
|
100
|
+
safeDispatchMagixEvent(event: string, payload: any): void;
|
101
|
+
focusByAttributes(apps: any): void;
|
102
|
+
onReconnected(): Promise<void>;
|
103
|
+
notifyContainerRectUpdate(rect: TeleBoxRect): void;
|
104
|
+
updateRootDirRemoving: (removing: boolean) => void;
|
105
|
+
dispatchInternalEvent(event: Events, payload?: any): void;
|
106
|
+
destroy(): void;
|
107
|
+
}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import { AppAttributes } from "./constants";
|
2
|
+
import type { AddAppParams, AppSyncAttributes } from "./index";
|
3
|
+
import type { Size, View } from "white-web-sdk";
|
4
|
+
import type { Cursor } from "./Cursor/Cursor";
|
5
|
+
export declare enum Fields {
|
6
|
+
Apps = "apps",
|
7
|
+
Focus = "focus",
|
8
|
+
State = "state",
|
9
|
+
BoxState = "boxState",
|
10
|
+
MainViewCamera = "mainViewCamera",
|
11
|
+
MainViewSize = "mainViewSize",
|
12
|
+
Broadcaster = "broadcaster",
|
13
|
+
Cursors = "cursors",
|
14
|
+
Position = "position",
|
15
|
+
CursorState = "cursorState",
|
16
|
+
FullPath = "fullPath",
|
17
|
+
Registered = "registered",
|
18
|
+
Camera = "camera",
|
19
|
+
Size = "size"
|
20
|
+
}
|
21
|
+
export declare type Apps = {
|
22
|
+
[key: string]: AppSyncAttributes;
|
23
|
+
};
|
24
|
+
export declare type Position = {
|
25
|
+
x: number;
|
26
|
+
y: number;
|
27
|
+
type: PositionType;
|
28
|
+
id?: string;
|
29
|
+
};
|
30
|
+
export declare type PositionType = "main" | "app";
|
31
|
+
export declare type StoreContext = {
|
32
|
+
getAttributes: () => any;
|
33
|
+
safeUpdateAttributes: (keys: string[], value: any) => void;
|
34
|
+
safeSetAttributes: (attributes: any) => void;
|
35
|
+
};
|
36
|
+
export declare type ICamera = {
|
37
|
+
id: string;
|
38
|
+
centerX: number | null;
|
39
|
+
centerY: number | null;
|
40
|
+
scale: number;
|
41
|
+
};
|
42
|
+
export declare type ISize = Size & {
|
43
|
+
id: string;
|
44
|
+
};
|
45
|
+
export declare class AttributesDelegate {
|
46
|
+
private context;
|
47
|
+
constructor(context: StoreContext);
|
48
|
+
setContext(context: StoreContext): void;
|
49
|
+
get attributes(): any;
|
50
|
+
apps(): Apps;
|
51
|
+
get focus(): string | undefined;
|
52
|
+
getAppAttributes(id: string): AppSyncAttributes;
|
53
|
+
getAppState(id: string): any;
|
54
|
+
getMaximized(): any;
|
55
|
+
getMinimized(): any;
|
56
|
+
setupAppAttributes(params: AddAppParams, id: string, isDynamicPPT: boolean): void;
|
57
|
+
updateAppState(appId: string, stateName: AppAttributes, state: any): void;
|
58
|
+
updateAppAttributes(appId: string, key: string, value: any): void;
|
59
|
+
cleanAppAttributes(id: string): void;
|
60
|
+
cleanFocus(): void;
|
61
|
+
getAppSceneIndex(id: string): any;
|
62
|
+
getAppScenePath(id: string): any;
|
63
|
+
getMainViewScenePath(): string | undefined;
|
64
|
+
getMainViewSceneIndex(): any;
|
65
|
+
getBoxState(): any;
|
66
|
+
setMainViewScenePath(scenePath: string): void;
|
67
|
+
setMainViewSceneIndex(index: number): void;
|
68
|
+
getMainViewCamera(): ICamera;
|
69
|
+
getMainViewSize(): ISize;
|
70
|
+
setMainViewCamera(camera: ICamera): void;
|
71
|
+
setMainViewSize(size: ISize): void;
|
72
|
+
setMainViewCameraAndSize(camera: ICamera, size: ISize): void;
|
73
|
+
setAppFocus: (appId: string, focus: boolean) => void;
|
74
|
+
updateCursor(uid: string, position: Position): void;
|
75
|
+
updateCursorState(uid: string, cursorState: string | undefined): void;
|
76
|
+
getCursorState(uid: string): any;
|
77
|
+
cleanCursor(uid: string): void;
|
78
|
+
setMainViewFocusPath(mainView: View): void;
|
79
|
+
}
|
80
|
+
export declare type Cursors = {
|
81
|
+
[key: string]: Cursor;
|
82
|
+
};
|
83
|
+
export declare const store: AttributesDelegate;
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import type { TELE_BOX_STATE } from "@netless/telebox-insider";
|
2
|
+
import Emittery from "emittery";
|
3
|
+
export declare type BoxMovePayload = {
|
4
|
+
appId: string;
|
5
|
+
x: number;
|
6
|
+
y: number;
|
7
|
+
};
|
8
|
+
export declare type BoxFocusPayload = {
|
9
|
+
appId: string;
|
10
|
+
};
|
11
|
+
export declare type BoxResizePayload = {
|
12
|
+
appId: string;
|
13
|
+
width: number;
|
14
|
+
height: number;
|
15
|
+
x?: number;
|
16
|
+
y?: number;
|
17
|
+
};
|
18
|
+
export declare type BoxClosePayload = {
|
19
|
+
appId: string;
|
20
|
+
error?: Error;
|
21
|
+
};
|
22
|
+
export declare type BoxStateChangePayload = {
|
23
|
+
appId: string;
|
24
|
+
state: TELE_BOX_STATE;
|
25
|
+
};
|
26
|
+
export declare type BoxEvent = {
|
27
|
+
move: BoxMovePayload;
|
28
|
+
focus: BoxFocusPayload;
|
29
|
+
resize: BoxResizePayload;
|
30
|
+
close: BoxClosePayload;
|
31
|
+
boxStateChange: BoxStateChangePayload;
|
32
|
+
};
|
33
|
+
export declare type BoxEmitterType = Emittery<BoxEvent>;
|
34
|
+
export declare const boxEmitter: BoxEmitterType;
|