@netless/window-manager 0.4.73-beta.0 → 0.4.73
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/index.d.ts +1093 -40
- package/dist/index.js +15 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +266 -164
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
- package/src/App/AppContext.ts +13 -8
- package/src/App/AppProxy.ts +3 -8
- package/src/App/MagixEvent/index.ts +38 -38
- package/src/App/Storage/StorageEvent.ts +13 -13
- package/src/App/Storage/index.ts +265 -242
- package/src/App/Storage/typings.ts +4 -2
- package/src/App/Storage/utils.ts +3 -3
- package/src/AppListener.ts +5 -5
- package/src/AppManager.ts +6 -19
- package/src/AttributesDelegate.ts +5 -7
- package/src/BoxEmitter.ts +12 -6
- package/src/BoxManager.ts +1 -1
- package/src/ContainerResizeObserver.ts +1 -1
- package/src/Cursor/Cursor.svelte +3 -1
- package/src/Cursor/Cursor.ts +1 -0
- package/src/Cursor/index.ts +1 -1
- package/src/Helper.ts +67 -15
- package/src/InternalEmitter.ts +4 -3
- package/src/Page/index.ts +1 -1
- package/src/Register/index.ts +5 -7
- package/src/Register/loader.ts +1 -1
- package/src/Register/storage.ts +13 -13
- package/src/Utils/Common.ts +10 -5
- package/src/Utils/Reactive.ts +26 -25
- package/src/Utils/RoomHacker.ts +1 -1
- package/src/Utils/error.ts +0 -1
- package/src/View/IframeBridge.ts +627 -583
- package/src/View/MainView.ts +8 -6
- package/src/callback.ts +7 -1
- package/src/index.ts +34 -24
- package/src/typings.ts +11 -6
- package/dist/App/AppContext.d.ts +0 -79
- package/dist/App/AppPageStateImpl.d.ts +0 -17
- package/dist/App/AppProxy.d.ts +0 -67
- package/dist/App/MagixEvent/index.d.ts +0 -29
- package/dist/App/Storage/StorageEvent.d.ts +0 -8
- package/dist/App/Storage/index.d.ts +0 -39
- package/dist/App/Storage/typings.d.ts +0 -22
- package/dist/App/Storage/utils.d.ts +0 -5
- package/dist/App/index.d.ts +0 -2
- package/dist/AppListener.d.ts +0 -21
- package/dist/AppManager.d.ts +0 -110
- package/dist/AttributesDelegate.d.ts +0 -91
- package/dist/BoxEmitter.d.ts +0 -34
- package/dist/BoxManager.d.ts +0 -98
- package/dist/BuiltinApps.d.ts +0 -5
- package/dist/ContainerResizeObserver.d.ts +0 -11
- package/dist/Cursor/Cursor.d.ts +0 -43
- package/dist/Cursor/icons.d.ts +0 -3
- package/dist/Cursor/icons2.d.ts +0 -4
- package/dist/Cursor/index.d.ts +0 -55
- package/dist/Helper.d.ts +0 -11
- package/dist/InternalEmitter.d.ts +0 -34
- package/dist/Page/PageController.d.ts +0 -21
- package/dist/Page/index.d.ts +0 -3
- package/dist/PageState.d.ts +0 -9
- package/dist/ReconnectRefresher.d.ts +0 -24
- package/dist/RedoUndo.d.ts +0 -18
- package/dist/Register/index.d.ts +0 -28
- package/dist/Register/loader.d.ts +0 -4
- package/dist/Register/storage.d.ts +0 -8
- package/dist/Utils/AppCreateQueue.d.ts +0 -15
- package/dist/Utils/Common.d.ts +0 -22
- package/dist/Utils/Reactive.d.ts +0 -6
- package/dist/Utils/RoomHacker.d.ts +0 -3
- package/dist/Utils/error.d.ts +0 -27
- package/dist/Utils/log.d.ts +0 -1
- package/dist/View/IframeBridge.d.ts +0 -146
- package/dist/View/MainView.d.ts +0 -58
- package/dist/View/ViewManager.d.ts +0 -13
- package/dist/callback.d.ts +0 -38
- package/dist/constants.d.ts +0 -48
- package/dist/typings.d.ts +0 -84
package/src/View/MainView.ts
CHANGED
@@ -9,7 +9,6 @@ import { SideEffectManager } from "side-effect-manager";
|
|
9
9
|
import type { Camera, Room, Size, View } from "white-web-sdk";
|
10
10
|
import type { AppManager } from "../AppManager";
|
11
11
|
import { Events } from "../constants";
|
12
|
-
import { WindowManager } from "..";
|
13
12
|
|
14
13
|
export class MainViewProxy {
|
15
14
|
/** Refresh the view's camera in an interval of 1.5s. */
|
@@ -187,9 +186,7 @@ export class MainViewProxy {
|
|
187
186
|
this.mainView.divElement = divElement;
|
188
187
|
this.addMainViewListener();
|
189
188
|
this.start();
|
190
|
-
|
191
|
-
callbacks.emit("onMainViewRebind", this.mainView);
|
192
|
-
}
|
189
|
+
callbacks.emit("onMainViewRebind", this.mainView);
|
193
190
|
}
|
194
191
|
|
195
192
|
private onCameraUpdatedByDevice = (camera: Camera) => {
|
@@ -256,8 +253,13 @@ export class MainViewProxy {
|
|
256
253
|
};
|
257
254
|
|
258
255
|
private ensureMainViewSize() {
|
259
|
-
if (
|
260
|
-
this.
|
256
|
+
if (
|
257
|
+
(!this.mainViewSize ||
|
258
|
+
this.mainViewSize.width === 0 ||
|
259
|
+
this.mainViewSize.height === 0) &&
|
260
|
+
this.mainView.size.width > 0 &&
|
261
|
+
this.mainView.size.height > 0
|
262
|
+
) {
|
261
263
|
this.setMainViewSize(this.mainView.size);
|
262
264
|
}
|
263
265
|
}
|
package/src/callback.ts
CHANGED
@@ -3,7 +3,13 @@ import type { TeleBoxColorScheme, TELE_BOX_STATE } from "@netless/telebox-inside
|
|
3
3
|
import type { CameraState, SceneState, View, ViewVisionMode } from "white-web-sdk";
|
4
4
|
import type { LoadAppEvent } from "./Register";
|
5
5
|
import type { PageState } from "./Page";
|
6
|
-
import type {
|
6
|
+
import type {
|
7
|
+
BoxClosePayload,
|
8
|
+
BoxFocusPayload,
|
9
|
+
BoxMovePayload,
|
10
|
+
BoxResizePayload,
|
11
|
+
BoxStateChangePayload,
|
12
|
+
} from "./BoxEmitter";
|
7
13
|
import type { AppPayload } from "./typings";
|
8
14
|
|
9
15
|
export type PublicEvent = {
|
package/src/index.ts
CHANGED
@@ -153,7 +153,7 @@ export type MountParams = {
|
|
153
153
|
applianceIcons?: ApplianceIcons;
|
154
154
|
fullscreen?: boolean;
|
155
155
|
polling?: boolean;
|
156
|
-
|
156
|
+
supportAppliancePlugin?: boolean;
|
157
157
|
};
|
158
158
|
|
159
159
|
export const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
|
@@ -170,8 +170,9 @@ export class WindowManager
|
|
170
170
|
public static container?: HTMLElement;
|
171
171
|
public static debug = false;
|
172
172
|
public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
|
173
|
-
public static
|
173
|
+
public static supportAppliancePlugin?: boolean;
|
174
174
|
private static isCreated = false;
|
175
|
+
private static _resolve = (_manager: WindowManager) => void 0;
|
175
176
|
|
176
177
|
public version = __APP_VERSION__;
|
177
178
|
public dependencies = __APP_DEPENDENCIES__;
|
@@ -186,6 +187,8 @@ export class WindowManager
|
|
186
187
|
public isReplay = isPlayer(this.displayer);
|
187
188
|
private _pageState?: PageStateImpl;
|
188
189
|
private _fullscreen?: boolean;
|
190
|
+
private _cursorUIDs: string[] = [];
|
191
|
+
private _cursorUIDsStyleDOM?: HTMLStyleElement;
|
189
192
|
|
190
193
|
private boxManager?: BoxManager;
|
191
194
|
private static params?: MountParams;
|
@@ -199,10 +202,14 @@ export class WindowManager
|
|
199
202
|
(window as any).NETLESS_DEPS = __APP_DEPENDENCIES__;
|
200
203
|
}
|
201
204
|
|
205
|
+
public static onCreate(manager: WindowManager) {
|
206
|
+
WindowManager._resolve(manager);
|
207
|
+
}
|
208
|
+
|
202
209
|
public static async mount(params: MountParams): Promise<WindowManager> {
|
203
210
|
const room = params.room;
|
204
211
|
WindowManager.container = params.container;
|
205
|
-
WindowManager.
|
212
|
+
WindowManager.supportAppliancePlugin = params.supportAppliancePlugin;
|
206
213
|
const containerSizeRatio = params.containerSizeRatio;
|
207
214
|
const debug = params.debug;
|
208
215
|
|
@@ -288,26 +295,8 @@ export class WindowManager
|
|
288
295
|
return manager;
|
289
296
|
}
|
290
297
|
|
291
|
-
private static
|
292
|
-
|
293
|
-
if (!manager) {
|
294
|
-
if (isRoom(room)) {
|
295
|
-
if (room.isWritable === false) {
|
296
|
-
try {
|
297
|
-
await room.setWritable(true);
|
298
|
-
} catch (error) {
|
299
|
-
throw new Error("[WindowManger]: room must be switched to be writable");
|
300
|
-
}
|
301
|
-
manager = await createInvisiblePlugin(room);
|
302
|
-
manager?.ensureAttributes();
|
303
|
-
await wait(500);
|
304
|
-
await room.setWritable(false);
|
305
|
-
} else {
|
306
|
-
manager = await createInvisiblePlugin(room);
|
307
|
-
}
|
308
|
-
}
|
309
|
-
}
|
310
|
-
return manager;
|
298
|
+
private static initManager(room: Room): Promise<WindowManager | undefined> {
|
299
|
+
return createInvisiblePlugin(room);
|
311
300
|
}
|
312
301
|
|
313
302
|
private static initContainer(
|
@@ -704,6 +693,27 @@ export class WindowManager
|
|
704
693
|
}
|
705
694
|
}
|
706
695
|
|
696
|
+
public get cursorUIDs(): string[] {
|
697
|
+
return this._cursorUIDs;
|
698
|
+
}
|
699
|
+
|
700
|
+
public setCursorUIDs(cursorUIDs?: string[] | null): void {
|
701
|
+
this._cursorUIDs = cursorUIDs || [];
|
702
|
+
if (this._cursorUIDs.length === 0) {
|
703
|
+
this._cursorUIDsStyleDOM?.remove();
|
704
|
+
} else {
|
705
|
+
if (!this._cursorUIDsStyleDOM) {
|
706
|
+
this._cursorUIDsStyleDOM = document.createElement("style");
|
707
|
+
}
|
708
|
+
WindowManager.playground?.appendChild(this._cursorUIDsStyleDOM);
|
709
|
+
let style = "[data-cursor-uid] { display: none }";
|
710
|
+
for (const uid of this._cursorUIDs) {
|
711
|
+
style += `\n[data-cursor-uid="${uid}"] { display: flex }`;
|
712
|
+
}
|
713
|
+
this._cursorUIDsStyleDOM.textContent = style;
|
714
|
+
}
|
715
|
+
}
|
716
|
+
|
707
717
|
public get mainView(): View {
|
708
718
|
if (this.appManager) {
|
709
719
|
return this.appManager.mainViewProxy.view;
|
@@ -1014,7 +1024,7 @@ export class WindowManager
|
|
1014
1024
|
this.appManager?.dispatchInternalEvent(Events.Refresh);
|
1015
1025
|
}
|
1016
1026
|
|
1017
|
-
/** @
|
1027
|
+
/** @internal */
|
1018
1028
|
public _refresh() {
|
1019
1029
|
this.appManager?.mainViewProxy.rebind();
|
1020
1030
|
if (WindowManager.container) {
|
package/src/typings.ts
CHANGED
@@ -14,7 +14,12 @@ import type { AppContext } from "./App";
|
|
14
14
|
import type { ReadonlyTeleBox, TeleBoxRect } from "@netless/telebox-insider";
|
15
15
|
import type { PageState } from "./Page";
|
16
16
|
|
17
|
-
export interface NetlessApp<
|
17
|
+
export interface NetlessApp<
|
18
|
+
Attributes extends {} = any,
|
19
|
+
MagixEventPayloads = any,
|
20
|
+
AppOptions = any,
|
21
|
+
SetupResult = any
|
22
|
+
> {
|
18
23
|
kind: string;
|
19
24
|
config?: {
|
20
25
|
/** Box width relative to whiteboard. 0~1. Default 0.5. */
|
@@ -52,7 +57,7 @@ export type AppEmitterEvent<T = any> = {
|
|
52
57
|
focus: boolean;
|
53
58
|
reconnected: void;
|
54
59
|
seek: number;
|
55
|
-
pageStateChange: PageState
|
60
|
+
pageStateChange: PageState;
|
56
61
|
};
|
57
62
|
|
58
63
|
export type RegisterEventData = {
|
@@ -60,7 +65,7 @@ export type RegisterEventData = {
|
|
60
65
|
};
|
61
66
|
|
62
67
|
export type RegisterEvents<SetupResult = any> = {
|
63
|
-
created: RegisterEventData & { result: SetupResult
|
68
|
+
created: RegisterEventData & { result: SetupResult };
|
64
69
|
destroy: RegisterEventData;
|
65
70
|
focus: RegisterEventData;
|
66
71
|
};
|
@@ -90,6 +95,6 @@ export * from "./Page";
|
|
90
95
|
export * from "./Utils/error";
|
91
96
|
|
92
97
|
export type AppPayload = {
|
93
|
-
appId: string
|
94
|
-
view: View
|
95
|
-
}
|
98
|
+
appId: string;
|
99
|
+
view: View;
|
100
|
+
};
|
package/dist/App/AppContext.d.ts
DELETED
@@ -1,79 +0,0 @@
|
|
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 { BoxManager } from "../BoxManager";
|
7
|
-
import type { AppEmitterEvent } from "../index";
|
8
|
-
import type { AppManager } from "../AppManager";
|
9
|
-
import type { AppProxy } from "./AppProxy";
|
10
|
-
import type { MagixEventAddListener, MagixEventDispatcher, MagixEventRemoveListener } from "./MagixEvent";
|
11
|
-
import type { AddPageParams, PageController, PageState } from "../Page";
|
12
|
-
export declare class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any, TAppOptions = any> implements PageController {
|
13
|
-
private manager;
|
14
|
-
private boxManager;
|
15
|
-
appId: string;
|
16
|
-
private appProxy;
|
17
|
-
private appOptions?;
|
18
|
-
readonly emitter: Emittery<AppEmitterEvent<TAttributes>>;
|
19
|
-
readonly mobxUtils: {
|
20
|
-
autorun: typeof autorun;
|
21
|
-
reaction: typeof reaction;
|
22
|
-
toJS: typeof toJS;
|
23
|
-
};
|
24
|
-
readonly objectUtils: {
|
25
|
-
listenUpdated: typeof listenUpdated;
|
26
|
-
unlistenUpdated: typeof unlistenUpdated;
|
27
|
-
listenDisposed: typeof listenDisposed;
|
28
|
-
unlistenDisposed: typeof unlistenDisposed;
|
29
|
-
};
|
30
|
-
private store;
|
31
|
-
readonly isAddApp: boolean;
|
32
|
-
readonly isReplay: boolean;
|
33
|
-
constructor(manager: AppManager, boxManager: BoxManager, appId: string, appProxy: AppProxy, appOptions?: TAppOptions | (() => TAppOptions) | undefined);
|
34
|
-
getDisplayer: () => import("white-web-sdk").Displayer<import("white-web-sdk").DisplayerCallbacks>;
|
35
|
-
/** @deprecated Use context.storage.state instead. */
|
36
|
-
getAttributes: () => TAttributes | undefined;
|
37
|
-
getScenes: () => SceneDefinition[] | undefined;
|
38
|
-
getView: () => View | undefined;
|
39
|
-
mountView: (dom: HTMLElement) => void;
|
40
|
-
getInitScenePath: () => string | undefined;
|
41
|
-
/** Get App writable status. */
|
42
|
-
getIsWritable: () => boolean;
|
43
|
-
/** Get the App Window UI box. */
|
44
|
-
getBox: () => ReadonlyTeleBox;
|
45
|
-
getRoom: () => Room | undefined;
|
46
|
-
/** @deprecated Use context.storage.setState instead. */
|
47
|
-
setAttributes: (attributes: TAttributes) => void;
|
48
|
-
/** @deprecated Use context.storage.setState instead. */
|
49
|
-
updateAttributes: (keys: string[], value: any) => void;
|
50
|
-
setScenePath: (scenePath: string) => Promise<void>;
|
51
|
-
/** Get the local App options. */
|
52
|
-
getAppOptions: () => TAppOptions | undefined;
|
53
|
-
private _storage?;
|
54
|
-
/** Main Storage for attributes. */
|
55
|
-
get storage(): Storage<TAttributes>;
|
56
|
-
/**
|
57
|
-
* Create separated storages for flexible state management.
|
58
|
-
* @param storeId Namespace for the storage. Storages of the same namespace share the same data.
|
59
|
-
* @param defaultState Default state for initial storage creation.
|
60
|
-
* @returns
|
61
|
-
*/
|
62
|
-
createStorage: <TState extends {}>(storeId: string, defaultState?: TState | undefined) => Storage<TState>;
|
63
|
-
/** Dispatch events to other clients (and self). */
|
64
|
-
dispatchMagixEvent: MagixEventDispatcher<TMagixEventPayloads>;
|
65
|
-
/** Listen to events from others clients (and self messages). */
|
66
|
-
addMagixEventListener: MagixEventAddListener<TMagixEventPayloads>;
|
67
|
-
/** Remove a Magix event listener. */
|
68
|
-
removeMagixEventListener: MagixEventRemoveListener<TMagixEventPayloads>;
|
69
|
-
/** PageController */
|
70
|
-
nextPage: () => Promise<boolean>;
|
71
|
-
jumpPage: (index: number) => Promise<boolean>;
|
72
|
-
prevPage: () => Promise<boolean>;
|
73
|
-
addPage: (params?: AddPageParams | undefined) => Promise<void>;
|
74
|
-
removePage: (index?: number | undefined) => Promise<boolean>;
|
75
|
-
get pageState(): PageState;
|
76
|
-
get kind(): string;
|
77
|
-
/** Dispatch a local event to `manager.onAppEvent()`. */
|
78
|
-
dispatchAppEvent(type: string, value?: any): void;
|
79
|
-
}
|
@@ -1,17 +0,0 @@
|
|
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
|
-
}
|
package/dist/App/AppProxy.d.ts
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
import Emittery from "emittery";
|
2
|
-
import { AppContext } from "./AppContext";
|
3
|
-
import type { AppEmitterEvent, AppInitState, BaseInsertParams } from "../index";
|
4
|
-
import type { SceneState, View, SceneDefinition } from "white-web-sdk";
|
5
|
-
import type { AppManager } from "../AppManager";
|
6
|
-
import type { NetlessApp } from "../typings";
|
7
|
-
import type { ReadonlyTeleBox } from "@netless/telebox-insider";
|
8
|
-
import type { PageRemoveService, PageState } from "../Page";
|
9
|
-
export declare type AppEmitter = Emittery<AppEmitterEvent>;
|
10
|
-
export declare class AppProxy implements PageRemoveService {
|
11
|
-
private params;
|
12
|
-
private manager;
|
13
|
-
kind: string;
|
14
|
-
id: string;
|
15
|
-
scenePath?: string;
|
16
|
-
appEmitter: AppEmitter;
|
17
|
-
scenes?: SceneDefinition[];
|
18
|
-
private appListener;
|
19
|
-
private boxManager;
|
20
|
-
private appProxies;
|
21
|
-
private viewManager;
|
22
|
-
private store;
|
23
|
-
isAddApp: boolean;
|
24
|
-
private status;
|
25
|
-
private stateKey;
|
26
|
-
private _pageState;
|
27
|
-
private _prevFullPath;
|
28
|
-
appResult?: NetlessApp<any>;
|
29
|
-
appContext?: AppContext<any, any>;
|
30
|
-
constructor(params: BaseInsertParams, manager: AppManager, appId: string, isAddApp: boolean);
|
31
|
-
private initScenes;
|
32
|
-
get view(): View | undefined;
|
33
|
-
get viewIndex(): number | undefined;
|
34
|
-
get isWritable(): boolean;
|
35
|
-
get attributes(): any;
|
36
|
-
get appAttributes(): import("../index").AppSyncAttributes;
|
37
|
-
getFullScenePath(): string | undefined;
|
38
|
-
private getFullScenePathFromScenes;
|
39
|
-
setFullPath(path: string): void;
|
40
|
-
baseInsertApp(skipUpdate?: boolean): Promise<{
|
41
|
-
appId: string;
|
42
|
-
app: NetlessApp;
|
43
|
-
}>;
|
44
|
-
get box(): ReadonlyTeleBox | undefined;
|
45
|
-
private setupApp;
|
46
|
-
private fixMobileSize;
|
47
|
-
private afterSetupApp;
|
48
|
-
onSeek(time: number): Promise<void>;
|
49
|
-
onReconnected(): Promise<void>;
|
50
|
-
onRemoveScene(scenePath: string): Promise<void>;
|
51
|
-
getAppInitState: (id: string) => AppInitState | undefined;
|
52
|
-
emitAppSceneStateChange(sceneState: SceneState): void;
|
53
|
-
emitAppIsWritableChange(): void;
|
54
|
-
private makeAppEventListener;
|
55
|
-
private appAttributesUpdateListener;
|
56
|
-
private setFocusScenePathHandler;
|
57
|
-
setScenePath(): void;
|
58
|
-
setViewFocusScenePath(): string | undefined;
|
59
|
-
private createView;
|
60
|
-
notifyPageStateChange: import("lodash").DebouncedFunc<() => void>;
|
61
|
-
get pageState(): PageState;
|
62
|
-
removeSceneByIndex(index: number): Promise<boolean>;
|
63
|
-
setSceneIndexWithoutSync(index: number): void;
|
64
|
-
setSceneIndex(index: number): void;
|
65
|
-
destroy(needCloseBox: boolean, cleanAttrs: boolean, skipUpdate: boolean, error?: Error): Promise<void>;
|
66
|
-
close(): Promise<void>;
|
67
|
-
}
|
@@ -1,29 +0,0 @@
|
|
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;
|
@@ -1,8 +0,0 @@
|
|
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
|
-
}
|
@@ -1,39 +0,0 @@
|
|
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
|
-
}
|
@@ -1,22 +0,0 @@
|
|
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;
|
@@ -1,5 +0,0 @@
|
|
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>;
|
package/dist/App/index.d.ts
DELETED
package/dist/AppListener.d.ts
DELETED
@@ -1,21 +0,0 @@
|
|
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 moveCameraHandler;
|
15
|
-
private moveCameraToContainHandler;
|
16
|
-
private cursorMoveHandler;
|
17
|
-
private rootDirRemovedHandler;
|
18
|
-
private refreshHandler;
|
19
|
-
private initMainViewCameraHandler;
|
20
|
-
private setAppFocusViewIndexHandler;
|
21
|
-
}
|
package/dist/AppManager.d.ts
DELETED
@@ -1,110 +0,0 @@
|
|
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, MemberState } from "white-web-sdk";
|
9
|
-
import type { AddAppParams, TeleBoxRect } from "./index";
|
10
|
-
export declare class AppManager {
|
11
|
-
windowManger: WindowManager;
|
12
|
-
displayer: Displayer;
|
13
|
-
viewManager: ViewManager;
|
14
|
-
appProxies: Map<string, AppProxy>;
|
15
|
-
appStatus: Map<string, AppStatus>;
|
16
|
-
store: import("./AttributesDelegate").AttributesDelegate;
|
17
|
-
mainViewProxy: MainViewProxy;
|
18
|
-
refresher: ReconnectRefresher;
|
19
|
-
isReplay: boolean;
|
20
|
-
mainViewScenesLength: number;
|
21
|
-
private appListeners;
|
22
|
-
boxManager?: BoxManager;
|
23
|
-
private _prevSceneIndex;
|
24
|
-
private _prevFocused;
|
25
|
-
private callbacksNode;
|
26
|
-
private appCreateQueue;
|
27
|
-
private sideEffectManager;
|
28
|
-
sceneState: SceneState | null;
|
29
|
-
rootDirRemoving: boolean;
|
30
|
-
constructor(windowManger: WindowManager);
|
31
|
-
getMemberState(): MemberState;
|
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 polling(): boolean;
|
53
|
-
set polling(b: boolean);
|
54
|
-
get focusApp(): AppProxy | undefined;
|
55
|
-
get uid(): string;
|
56
|
-
getMainViewSceneDir(): string;
|
57
|
-
private onCreated;
|
58
|
-
private onBoxMove;
|
59
|
-
private onBoxResize;
|
60
|
-
private onBoxFocus;
|
61
|
-
private onBoxClose;
|
62
|
-
private onBoxStateChange;
|
63
|
-
addAppsChangeListener: () => void;
|
64
|
-
addAppCloseListener: () => void;
|
65
|
-
private onMainViewIndexChange;
|
66
|
-
private onFocusChange;
|
67
|
-
attributesUpdateCallback: import("lodash").DebouncedFunc<(apps: any) => Promise<void>>;
|
68
|
-
private _appIds;
|
69
|
-
notifyAppsChange(appIds: string[]): void;
|
70
|
-
/**
|
71
|
-
* 插件更新 attributes 时的回调
|
72
|
-
*
|
73
|
-
* @param {*} attributes
|
74
|
-
* @memberof WindowManager
|
75
|
-
*/
|
76
|
-
_attributesUpdateCallback(apps: any): Promise<void>;
|
77
|
-
private onRegisteredChange;
|
78
|
-
private onMinimized;
|
79
|
-
refresh(): void;
|
80
|
-
setBoxManager(boxManager: BoxManager): void;
|
81
|
-
resetMaximized(): void;
|
82
|
-
resetMinimized(): void;
|
83
|
-
private onAppDelete;
|
84
|
-
private closeAll;
|
85
|
-
bindMainView(divElement: HTMLDivElement, disableCameraTransform: boolean): void;
|
86
|
-
setMainViewFocusPath(scenePath?: string): boolean | undefined;
|
87
|
-
private resetScenePath;
|
88
|
-
addApp(params: AddAppParams, isDynamicPPT: boolean): Promise<string | undefined>;
|
89
|
-
private beforeAddApp;
|
90
|
-
private afterAddApp;
|
91
|
-
closeApp(appId: string, needClose?: boolean): Promise<void>;
|
92
|
-
private baseInsertApp;
|
93
|
-
private displayerStateListener;
|
94
|
-
displayerWritableListener: (isReadonly: boolean) => void;
|
95
|
-
safeSetAttributes(attributes: any): void;
|
96
|
-
safeUpdateAttributes(keys: string[], value: any): void;
|
97
|
-
setMainViewScenePath(scenePath: string): Promise<void>;
|
98
|
-
private _setMainViewScenePath;
|
99
|
-
private updateSceneIndex;
|
100
|
-
setMainViewSceneIndex(index: number): Promise<void>;
|
101
|
-
private dispatchSetMainViewScenePath;
|
102
|
-
getAppInitPath(appId: string): string | undefined;
|
103
|
-
safeDispatchMagixEvent(event: string, payload: any): void;
|
104
|
-
focusByAttributes(apps: any): void;
|
105
|
-
onReconnected(): Promise<void>;
|
106
|
-
notifyContainerRectUpdate(rect: TeleBoxRect): void;
|
107
|
-
updateRootDirRemoving: (removing: boolean) => void;
|
108
|
-
dispatchInternalEvent(event: Events, payload?: any): void;
|
109
|
-
destroy(): void;
|
110
|
-
}
|