@netless/window-manager 0.4.0-canary.4 → 0.4.0-canary.8
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/Storage/StorageEvent.d.ts +8 -0
- package/dist/App/Storage/index.d.ts +26 -0
- package/dist/App/Storage/typings.d.ts +21 -0
- package/dist/App/Storage/utils.d.ts +5 -0
- package/dist/AppContext.d.ts +2 -0
- package/dist/AppListener.d.ts +0 -1
- package/dist/AppManager.d.ts +4 -5
- package/dist/AppProxy.d.ts +2 -3
- package/dist/Base/Context.d.ts +0 -1
- package/dist/BoxManager.d.ts +2 -1
- package/dist/BuiltinApps.d.ts +6 -0
- package/dist/ContainerResizeObserver.d.ts +10 -0
- package/dist/Helper.d.ts +6 -0
- package/dist/Utils/Common.d.ts +3 -1
- package/dist/Utils/Reactive.d.ts +1 -1
- package/dist/{MainView.d.ts → View/MainView.d.ts} +2 -4
- package/dist/View/ViewManager.d.ts +13 -0
- package/dist/constants.d.ts +0 -5
- package/dist/index.d.ts +3 -9
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/typings.d.ts +1 -0
- package/package.json +3 -3
- package/src/App/Storage/StorageEvent.ts +21 -0
- package/src/App/Storage/index.ts +243 -0
- package/src/App/Storage/typings.ts +21 -0
- package/src/App/Storage/utils.ts +17 -0
- package/src/AppContext.ts +9 -1
- package/src/AppListener.ts +0 -8
- package/src/AppManager.ts +32 -26
- package/src/AppProxy.ts +14 -36
- package/src/Base/Context.ts +0 -4
- package/src/BoxManager.ts +9 -7
- package/src/BuiltinApps.ts +24 -0
- package/src/ContainerResizeObserver.ts +62 -0
- package/src/Helper.ts +30 -0
- package/src/ReconnectRefresher.ts +0 -1
- package/src/Utils/Common.ts +35 -13
- package/src/Utils/Reactive.ts +9 -3
- package/src/{MainView.ts → View/MainView.ts} +7 -25
- package/src/View/ViewManager.ts +53 -0
- package/src/constants.ts +0 -2
- package/src/index.ts +17 -70
- package/src/shim.d.ts +4 -0
- package/src/style.css +6 -0
- package/src/typings.ts +1 -0
- package/vite.config.js +4 -1
- package/dist/Utils/CameraStore.d.ts +0 -15
- package/dist/ViewManager.d.ts +0 -29
- package/dist/sdk.d.ts +0 -14
- package/src/Utils/CameraStore.ts +0 -72
- package/src/sdk.ts +0 -39
- package/src/viewManager.ts +0 -177
@@ -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,26 @@
|
|
1
|
+
import type { AppContext } from "../../AppContext";
|
2
|
+
import type { Diff } from "./typings";
|
3
|
+
import { StorageEvent } from "./StorageEvent";
|
4
|
+
export * from './typings';
|
5
|
+
export declare class Storage<TState = any> implements Storage<TState> {
|
6
|
+
readonly id: string;
|
7
|
+
private readonly _context;
|
8
|
+
private readonly _sideEffect;
|
9
|
+
private _state;
|
10
|
+
private _destroyed;
|
11
|
+
private _refMap;
|
12
|
+
/**
|
13
|
+
* `setState` alters local state immediately before sending to server. This will cache the old value for onStateChanged diffing.
|
14
|
+
*/
|
15
|
+
private _lastValue;
|
16
|
+
constructor(context: AppContext<any>, id: string, defaultState?: TState);
|
17
|
+
get state(): Readonly<TState>;
|
18
|
+
readonly onStateChanged: StorageEvent<Diff<TState>>;
|
19
|
+
ensureState(state: Partial<TState>): void;
|
20
|
+
setState(state: Partial<TState>): void;
|
21
|
+
emptyStore(): void;
|
22
|
+
deleteStore(): void;
|
23
|
+
get destroyed(): boolean;
|
24
|
+
destroy(): void;
|
25
|
+
private _updateProperties;
|
26
|
+
}
|
@@ -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>;
|
package/dist/AppContext.d.ts
CHANGED
@@ -6,6 +6,7 @@ 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
|
+
import { Storage } from './App/Storage';
|
9
10
|
export declare class AppContext<TAttrs extends Record<string, any>, AppOptions = any> {
|
10
11
|
private manager;
|
11
12
|
private boxManager;
|
@@ -41,4 +42,5 @@ export declare class AppContext<TAttrs extends Record<string, any>, AppOptions =
|
|
41
42
|
setScenePath(scenePath: string): Promise<void>;
|
42
43
|
mountView(dom: HTMLDivElement): void;
|
43
44
|
getAppOptions(): AppOptions | undefined;
|
45
|
+
createStorage<TState>(storeId: string, defaultState?: TState): Storage<TState>;
|
44
46
|
}
|
package/dist/AppListener.d.ts
CHANGED
@@ -9,7 +9,6 @@ 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;
|
15
14
|
private moveCameraToContainHandler;
|
package/dist/AppManager.d.ts
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
import { AppStatus, Events } from "./constants";
|
2
2
|
import { AppProxy } from "./AppProxy";
|
3
3
|
import { WindowManager } from "./index";
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import { ViewManager } from "./ViewManager";
|
4
|
+
import { MainViewProxy } from "./View/MainView";
|
5
|
+
import { ViewManager } from "./View/ViewManager";
|
7
6
|
import type { ReconnectRefresher } from "./ReconnectRefresher";
|
8
7
|
import type { BoxManager } from "./BoxManager";
|
9
8
|
import type { Displayer, Room } from "white-web-sdk";
|
@@ -11,7 +10,6 @@ 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>;
|
@@ -36,13 +34,14 @@ export declare class AppManager {
|
|
36
34
|
resetMinimized(): void;
|
37
35
|
private onAppDelete;
|
38
36
|
bindMainView(divElement: HTMLDivElement, disableCameraTransform: boolean): void;
|
37
|
+
setMainViewFocusPath(): void;
|
39
38
|
addApp(params: AddAppParams, isDynamicPPT: boolean): Promise<string | undefined>;
|
40
39
|
private beforeAddApp;
|
41
40
|
private afterAddApp;
|
42
41
|
closeApp(appId: string): Promise<void>;
|
43
42
|
private baseInsertApp;
|
44
43
|
private displayerStateListener;
|
45
|
-
|
44
|
+
displayerWritableListener: (isReadonly: boolean) => void;
|
46
45
|
private get eventName();
|
47
46
|
get attributes(): import("./index").WindowMangerAttributes;
|
48
47
|
get canOperate(): boolean;
|
package/dist/AppProxy.d.ts
CHANGED
@@ -15,7 +15,6 @@ 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;
|
@@ -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
|
33
|
+
baseInsertApp(skipUpdate?: boolean): Promise<{
|
34
34
|
appId: string;
|
35
35
|
app: NetlessApp;
|
36
36
|
}>;
|
@@ -42,7 +42,6 @@ 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;
|
package/dist/Base/Context.d.ts
CHANGED
@@ -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;
|
package/dist/BoxManager.d.ts
CHANGED
@@ -56,9 +56,10 @@ 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
|
-
get boxState(): "
|
62
|
+
get boxState(): "minimized" | "maximized" | "normal";
|
62
63
|
get maximized(): boolean;
|
63
64
|
get minimized(): boolean;
|
64
65
|
get darkMode(): boolean;
|
@@ -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
|
+
}
|
package/dist/Helper.d.ts
ADDED
package/dist/Utils/Common.d.ts
CHANGED
@@ -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;
|
package/dist/Utils/Reactive.d.ts
CHANGED
@@ -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
|
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,9 +1,8 @@
|
|
1
|
-
import { Base } from "
|
1
|
+
import { Base } from "../Base";
|
2
2
|
import type { Camera, Size, View } from "white-web-sdk";
|
3
|
-
import type { AppManager } from "
|
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;
|
@@ -35,7 +34,6 @@ export declare class MainViewProxy extends Base {
|
|
35
34
|
private addCameraListener;
|
36
35
|
private removeCameraListener;
|
37
36
|
private onCameraOrSizeUpdated;
|
38
|
-
switchViewModeToWriter(): void;
|
39
37
|
moveCameraToContian(size: Size): void;
|
40
38
|
moveCamera(camera: Camera): void;
|
41
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;
|
package/dist/constants.d.ts
CHANGED
@@ -35,9 +35,4 @@ export declare const REQUIRE_VERSION = "2.13.16";
|
|
35
35
|
export declare const MIN_WIDTH: number;
|
36
36
|
export declare const MIN_HEIGHT: number;
|
37
37
|
export declare const SET_SCENEPATH_DELAY = 100;
|
38
|
-
export declare const DEFAULT_COLLECTOR_STYLE: {
|
39
|
-
right: string;
|
40
|
-
bottom: string;
|
41
|
-
position: string;
|
42
|
-
};
|
43
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";
|
@@ -11,7 +12,6 @@ import type { AppListeners } from "./AppListener";
|
|
11
12
|
import type { NetlessApp, RegisterParams } from "./typings";
|
12
13
|
import type { TeleBoxColorScheme, TeleBoxState } from "@netless/telebox-insider";
|
13
14
|
import type { AppProxy } from "./AppProxy";
|
14
|
-
import { ReconnectRefresher } from "./ReconnectRefresher";
|
15
15
|
export declare type WindowMangerAttributes = {
|
16
16
|
modelValue?: string;
|
17
17
|
boxState: TELE_BOX_STATE;
|
@@ -140,6 +140,7 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
|
|
140
140
|
isReplay: boolean;
|
141
141
|
private boxManager?;
|
142
142
|
private static params?;
|
143
|
+
private containerResizeObserver?;
|
143
144
|
constructor(context: InvisiblePluginContext);
|
144
145
|
static mount(params: MountParams): Promise<WindowManager>;
|
145
146
|
private static initManager;
|
@@ -226,13 +227,6 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
|
|
226
227
|
private isDynamicPPT;
|
227
228
|
private static checkVersion;
|
228
229
|
private ensureAttributes;
|
229
|
-
private containerResizeObserver?;
|
230
|
-
private observePlaygroundSize;
|
231
|
-
private updateSizer;
|
232
230
|
}
|
233
|
-
export declare const BuiltinApps: {
|
234
|
-
DocsViewer: string;
|
235
|
-
MediaPlayer: string;
|
236
|
-
};
|
237
231
|
export * from "./typings";
|
238
|
-
export {
|
232
|
+
export { BuiltinApps } from "./BuiltinApps";
|