@netless/window-manager 0.4.8-canary.0 → 0.4.9-canary.1
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/CHANGELOG.md +5 -0
- package/README.md +1 -0
- package/dist/AppContext.d.ts +4 -4
- package/dist/AppManager.d.ts +5 -2
- package/dist/BoxManager.d.ts +3 -1
- package/dist/ContainerResizeObserver.d.ts +1 -1
- package/dist/InternalEmitter.d.ts +41 -0
- package/dist/ReconnectRefresher.d.ts +1 -1
- package/dist/Utils/AppCreateQueue.d.ts +2 -0
- package/dist/Utils/Common.d.ts +1 -1
- package/dist/callback.d.ts +22 -0
- package/dist/index.d.ts +5 -58
- package/dist/index.es.js +5 -5
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/docs/advanced.md +13 -0
- package/docs/api.md +16 -1
- package/docs/develop-app.md +50 -0
- package/package.json +2 -2
- package/src/AppContext.ts +51 -33
- package/src/AppListener.ts +2 -1
- package/src/AppManager.ts +46 -12
- package/src/AppProxy.ts +1 -1
- package/src/BoxManager.ts +3 -1
- package/src/ContainerResizeObserver.ts +1 -1
- package/src/Cursor/index.ts +4 -2
- package/src/InternalEmitter.ts +27 -0
- package/src/ReconnectRefresher.ts +1 -1
- package/src/RedoUndo.ts +2 -1
- package/src/Register/index.ts +1 -0
- package/src/Register/loader.ts +1 -1
- package/src/Utils/AppCreateQueue.ts +10 -0
- package/src/Utils/Common.ts +2 -2
- package/src/Utils/RoomHacker.ts +3 -3
- package/src/View/MainView.ts +2 -1
- package/src/callback.ts +24 -0
- package/src/index.ts +22 -59
package/src/AppManager.ts
CHANGED
@@ -4,15 +4,18 @@ import { AppListeners } from "./AppListener";
|
|
4
4
|
import { AppProxy } from "./AppProxy";
|
5
5
|
import { appRegister } from "./Register";
|
6
6
|
import { autorun, isPlayer, isRoom, ScenePathType } from "white-web-sdk";
|
7
|
-
import { callbacks
|
7
|
+
import { callbacks } from "./callback";
|
8
|
+
import { emitter } from "./InternalEmitter";
|
8
9
|
import { get, isInteger, orderBy } from "lodash";
|
9
10
|
import { log } from "./Utils/log";
|
10
11
|
import { MainViewProxy } from "./View/MainView";
|
11
12
|
import { onObjectRemoved, safeListenPropsUpdated } from "./Utils/Reactive";
|
13
|
+
import { reconnectRefresher, WindowManager } from "./index";
|
12
14
|
import { RedoUndo } from "./RedoUndo";
|
13
15
|
import { SideEffectManager } from "side-effect-manager";
|
14
16
|
import { store } from "./AttributesDelegate";
|
15
17
|
import { ViewManager } from "./View/ViewManager";
|
18
|
+
import type { EmitterEvent } from "./InternalEmitter";
|
16
19
|
import {
|
17
20
|
entireScenes,
|
18
21
|
genAppId,
|
@@ -23,9 +26,14 @@ import {
|
|
23
26
|
} from "./Utils/Common";
|
24
27
|
import type { ReconnectRefresher } from "./ReconnectRefresher";
|
25
28
|
import type { BoxManager } from "./BoxManager";
|
26
|
-
import type {
|
27
|
-
|
28
|
-
|
29
|
+
import type {
|
30
|
+
Displayer,
|
31
|
+
DisplayerState,
|
32
|
+
Room,
|
33
|
+
ScenesCallbacksNode,
|
34
|
+
SceneState,
|
35
|
+
} from "white-web-sdk";
|
36
|
+
import type { AddAppParams, BaseInsertParams, TeleBoxRect } from "./index";
|
29
37
|
export class AppManager {
|
30
38
|
public displayer: Displayer;
|
31
39
|
public viewManager: ViewManager;
|
@@ -47,6 +55,8 @@ export class AppManager {
|
|
47
55
|
|
48
56
|
private sideEffectManager = new SideEffectManager();
|
49
57
|
|
58
|
+
public sceneState: SceneState | null = null;
|
59
|
+
|
50
60
|
constructor(public windowManger: WindowManager) {
|
51
61
|
this.displayer = windowManger.displayer;
|
52
62
|
this.store.setContext({
|
@@ -126,16 +136,11 @@ export class AppManager {
|
|
126
136
|
isRecreate = true;
|
127
137
|
}
|
128
138
|
this.callbacksNode = this.displayer.createScenesCallback(ROOT_DIR, {
|
129
|
-
onAddScene:
|
130
|
-
|
131
|
-
callbacks.emit("mainViewScenesLengthChange", this.mainViewScenesLength);
|
132
|
-
},
|
133
|
-
onRemoveScene: scenesCallback => {
|
134
|
-
this.mainViewScenesLength = scenesCallback.scenes.length;
|
135
|
-
callbacks.emit("mainViewScenesLengthChange", this.mainViewScenesLength);
|
136
|
-
},
|
139
|
+
onAddScene: this.onSceneChange,
|
140
|
+
onRemoveScene: this.onSceneChange,
|
137
141
|
});
|
138
142
|
if (this.callbacksNode) {
|
143
|
+
this.updateSceneState(this.callbacksNode);
|
139
144
|
this.mainViewScenesLength = this.callbacksNode.scenes.length;
|
140
145
|
if (isRecreate) {
|
141
146
|
callbacks.emit("mainViewScenesLengthChange", this.callbacksNode.scenes.length);
|
@@ -143,6 +148,29 @@ export class AppManager {
|
|
143
148
|
}
|
144
149
|
};
|
145
150
|
|
151
|
+
private onSceneChange = (node: ScenesCallbacksNode) => {
|
152
|
+
this.mainViewScenesLength = node.scenes.length;
|
153
|
+
this.updateSceneState(node);
|
154
|
+
callbacks.emit("mainViewScenesLengthChange", this.mainViewScenesLength);
|
155
|
+
};
|
156
|
+
|
157
|
+
private updateSceneState = (node: ScenesCallbacksNode) => {
|
158
|
+
const currentIndex = this.store.getMainViewSceneIndex() || 0;
|
159
|
+
const sceneName = node.scenes[currentIndex];
|
160
|
+
this.sceneState = {
|
161
|
+
scenePath: `${ROOT_DIR}${sceneName}`,
|
162
|
+
contextPath: node.path,
|
163
|
+
index: currentIndex,
|
164
|
+
scenes: node.scenes.map(scene => {
|
165
|
+
return {
|
166
|
+
name: scene,
|
167
|
+
};
|
168
|
+
}),
|
169
|
+
sceneName: sceneName,
|
170
|
+
};
|
171
|
+
callbacks.emit("sceneStateChange", this.sceneState);
|
172
|
+
};
|
173
|
+
|
146
174
|
private get eventName() {
|
147
175
|
return isRoom(this.displayer) ? "onRoomStateChanged" : "onPlayerStateChanged";
|
148
176
|
}
|
@@ -223,6 +251,9 @@ export class AppManager {
|
|
223
251
|
const mainSceneIndex = get(this.attributes, "_mainSceneIndex");
|
224
252
|
if (mainSceneIndex !== undefined && this._prevSceneIndex !== mainSceneIndex) {
|
225
253
|
callbacks.emit("mainViewSceneIndexChange", mainSceneIndex);
|
254
|
+
if (this.callbacksNode) {
|
255
|
+
this.updateSceneState(this.callbacksNode);
|
256
|
+
}
|
226
257
|
this._prevSceneIndex = mainSceneIndex;
|
227
258
|
}
|
228
259
|
});
|
@@ -278,6 +309,9 @@ export class AppManager {
|
|
278
309
|
public async attributesUpdateCallback(apps: any) {
|
279
310
|
if (apps && WindowManager.container) {
|
280
311
|
const appIds = Object.keys(apps);
|
312
|
+
if (appIds.length === 0) {
|
313
|
+
this.appCreateQueue.emitReady();
|
314
|
+
}
|
281
315
|
const appsWithCreatedAt = appIds.map(appId => {
|
282
316
|
return {
|
283
317
|
id: appId,
|
package/src/AppProxy.ts
CHANGED
@@ -5,7 +5,7 @@ import { appRegister } from "./Register";
|
|
5
5
|
import { autorun } from "white-web-sdk";
|
6
6
|
import { BoxManagerNotFoundError } from "./Utils/error";
|
7
7
|
import { debounce, get } from "lodash";
|
8
|
-
import { emitter } from "./
|
8
|
+
import { emitter } from "./InternalEmitter";
|
9
9
|
import { Fields } from "./AttributesDelegate";
|
10
10
|
import { entireScenes, getScenePath, removeScenes, setScenePath, setViewFocusScenePath } from "./Utils/Common";
|
11
11
|
import { log } from "./Utils/log";
|
package/src/BoxManager.ts
CHANGED
@@ -2,7 +2,7 @@ import { AppAttributes, Events, MIN_HEIGHT, MIN_WIDTH } from "./constants";
|
|
2
2
|
import { debounce } from "lodash";
|
3
3
|
import { TELE_BOX_STATE, TeleBoxCollector, TeleBoxManager } from "@netless/telebox-insider";
|
4
4
|
import { WindowManager } from "./index";
|
5
|
-
import type { AddAppOptions, AppInitState
|
5
|
+
import type { AddAppOptions, AppInitState } from "./index";
|
6
6
|
import type {
|
7
7
|
TeleBoxManagerUpdateConfig,
|
8
8
|
TeleBoxManagerCreateConfig,
|
@@ -15,6 +15,8 @@ import type {
|
|
15
15
|
import type Emittery from "emittery";
|
16
16
|
import type { NetlessApp } from "./typings";
|
17
17
|
import type { View } from "white-web-sdk";
|
18
|
+
import type { CallbacksType } from "./callback";
|
19
|
+
import type { EmitterType } from "./InternalEmitter";
|
18
20
|
|
19
21
|
export { TELE_BOX_STATE };
|
20
22
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { ResizeObserver as ResizeObserverPolyfill } from "@juggle/resize-observer";
|
2
2
|
import { WindowManager } from "./index";
|
3
|
-
import type { EmitterType } from "./
|
3
|
+
import type { EmitterType } from "./InternalEmitter";
|
4
4
|
|
5
5
|
const ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill;
|
6
6
|
|
package/src/Cursor/index.ts
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
import { ApplianceNames } from "white-web-sdk";
|
2
2
|
import { Cursor } from "./Cursor";
|
3
3
|
import { CursorState, Events } from "../constants";
|
4
|
-
import { emitter
|
4
|
+
import { emitter } from "../InternalEmitter";
|
5
5
|
import { SideEffectManager } from "side-effect-manager";
|
6
6
|
import { throttle } from "lodash";
|
7
|
+
import { WindowManager } from "../index";
|
7
8
|
import type { CursorMovePayload } from "../index";
|
8
9
|
import type { PositionType } from "../AttributesDelegate";
|
9
10
|
import type { Point, RoomMember, View } from "white-web-sdk";
|
@@ -65,7 +66,8 @@ export class CursorManager {
|
|
65
66
|
};
|
66
67
|
|
67
68
|
private canMoveCursor(member: RoomMember | undefined) {
|
68
|
-
const isLaserPointer =
|
69
|
+
const isLaserPointer =
|
70
|
+
member?.memberState.currentApplianceName === ApplianceNames.laserPointer;
|
69
71
|
// 激光笔教具在不开启光标的情况下也要显示
|
70
72
|
return this.enableCursor || isLaserPointer;
|
71
73
|
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import Emittery from "emittery";
|
2
|
+
import type { AppInitState, CursorMovePayload } from "./index";
|
3
|
+
|
4
|
+
|
5
|
+
export type EmitterEvent = {
|
6
|
+
onCreated: undefined;
|
7
|
+
InitReplay: AppInitState;
|
8
|
+
move: { appId: string; x: number; y: number };
|
9
|
+
focus: { appId: string };
|
10
|
+
close: { appId: string };
|
11
|
+
resize: { appId: string; width: number; height: number; x?: number; y?: number };
|
12
|
+
error: Error;
|
13
|
+
seek: number;
|
14
|
+
mainViewMounted: undefined;
|
15
|
+
observerIdChange: number;
|
16
|
+
boxStateChange: string;
|
17
|
+
playgroundSizeChange: DOMRect;
|
18
|
+
onReconnected: void;
|
19
|
+
removeScenes: string;
|
20
|
+
cursorMove: CursorMovePayload;
|
21
|
+
updateManagerRect: undefined;
|
22
|
+
focusedChange: { focused: string | undefined; prev: string | undefined };
|
23
|
+
rootDirRemoved: undefined;
|
24
|
+
};
|
25
|
+
|
26
|
+
export type EmitterType = Emittery<EmitterEvent>;
|
27
|
+
export const emitter: EmitterType = new Emittery();
|
@@ -2,7 +2,7 @@ import { debounce, isFunction } from "lodash";
|
|
2
2
|
import { log } from "./Utils/log";
|
3
3
|
import { RoomPhase } from "white-web-sdk";
|
4
4
|
import type { Room } from "white-web-sdk";
|
5
|
-
import type { EmitterType } from "./
|
5
|
+
import type { EmitterType } from "./InternalEmitter";
|
6
6
|
|
7
7
|
export type ReconnectRefresherContext = {
|
8
8
|
emitter: EmitterType;
|
package/src/RedoUndo.ts
CHANGED
package/src/Register/index.ts
CHANGED
@@ -15,6 +15,7 @@ class AppRegister {
|
|
15
15
|
public appClasses: Map<string, () => Promise<NetlessApp>> = new Map();
|
16
16
|
|
17
17
|
public async register(params: RegisterParams): Promise<void> {
|
18
|
+
this.appClassesCache.delete(params.kind);
|
18
19
|
this.registered.set(params.kind, params);
|
19
20
|
|
20
21
|
const srcOrAppOrFunction = params.src;
|
package/src/Register/loader.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { callbacks } from "../callback";
|
1
2
|
import type { AppProxy } from "../AppProxy";
|
2
3
|
|
3
4
|
export type Invoker = () => Promise<AppProxy | undefined>;
|
@@ -6,6 +7,7 @@ export class AppCreateQueue {
|
|
6
7
|
private list: Invoker[] = [];
|
7
8
|
private currentInvoker: Invoker | undefined;
|
8
9
|
private timer: number | undefined;
|
10
|
+
public isEmit = false;
|
9
11
|
|
10
12
|
private initInterval() {
|
11
13
|
return setInterval(() => {
|
@@ -37,6 +39,7 @@ export class AppCreateQueue {
|
|
37
39
|
this.currentInvoker = undefined;
|
38
40
|
if (this.list.length === 0) {
|
39
41
|
clearInterval(this.timer);
|
42
|
+
this.emitReady();
|
40
43
|
}
|
41
44
|
})
|
42
45
|
.catch(error => {
|
@@ -46,6 +49,13 @@ export class AppCreateQueue {
|
|
46
49
|
}
|
47
50
|
}
|
48
51
|
|
52
|
+
public emitReady() {
|
53
|
+
if (!this.isEmit) {
|
54
|
+
callbacks.emit("ready");
|
55
|
+
}
|
56
|
+
this.isEmit = true;
|
57
|
+
}
|
58
|
+
|
49
59
|
public destroy() {
|
50
60
|
if (this.timer) {
|
51
61
|
clearInterval(this.timer);
|
package/src/Utils/Common.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import { appRegister } from "../Register";
|
2
2
|
import { debounce } from "lodash";
|
3
|
-
import { emitter } from "../
|
3
|
+
import { emitter } from "../InternalEmitter";
|
4
4
|
import { ScenePathType } from "white-web-sdk";
|
5
5
|
import { v4 } from "uuid";
|
6
|
-
import type { PublicEvent } from "../
|
6
|
+
import type { PublicEvent } from "../callback";
|
7
7
|
import type { Displayer, ViewVisionMode, Room, View } from "white-web-sdk";
|
8
8
|
import type Emittery from "emittery";
|
9
9
|
import { ROOT_DIR } from "../constants";
|
package/src/Utils/RoomHacker.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { emitter } from "../
|
1
|
+
import { emitter } from "../InternalEmitter";
|
2
2
|
import { isPlayer } from "white-web-sdk";
|
3
3
|
import type { WindowManager } from "../index";
|
4
4
|
import type { Camera, Room, Player, PlayerSeekingResult } from "white-web-sdk";
|
@@ -23,13 +23,13 @@ export const replaceRoomFunction = (room: Room | Player, manager: WindowManager)
|
|
23
23
|
|
24
24
|
Object.defineProperty(room, "canUndoSteps", {
|
25
25
|
get() {
|
26
|
-
return manager.
|
26
|
+
return manager.canUndoSteps;
|
27
27
|
},
|
28
28
|
});
|
29
29
|
|
30
30
|
Object.defineProperty(room, "canRedoSteps", {
|
31
31
|
get() {
|
32
|
-
return manager.
|
32
|
+
return manager.canRedoSteps;
|
33
33
|
},
|
34
34
|
});
|
35
35
|
|
package/src/View/MainView.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
import { AnimationMode, reaction } from "white-web-sdk";
|
2
|
-
import { callbacks
|
2
|
+
import { callbacks } from "../callback";
|
3
3
|
import { createView } from "./ViewManager";
|
4
4
|
import { debounce, isEmpty, isEqual } from "lodash";
|
5
|
+
import { emitter } from "../InternalEmitter";
|
5
6
|
import { Fields } from "../AttributesDelegate";
|
6
7
|
import { setViewFocusScenePath } from "../Utils/Common";
|
7
8
|
import { SideEffectManager } from "side-effect-manager";
|
package/src/callback.ts
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
import Emittery from "emittery";
|
2
|
+
import type { TeleBoxColorScheme, TELE_BOX_STATE } from "@netless/telebox-insider";
|
3
|
+
import type { CameraState, SceneState, ViewVisionMode } from "white-web-sdk";
|
4
|
+
import type { LoadAppEvent } from "./Register";
|
5
|
+
|
6
|
+
export type PublicEvent = {
|
7
|
+
mainViewModeChange: ViewVisionMode;
|
8
|
+
boxStateChange: `${TELE_BOX_STATE}`;
|
9
|
+
darkModeChange: boolean;
|
10
|
+
prefersColorSchemeChange: TeleBoxColorScheme;
|
11
|
+
cameraStateChange: CameraState;
|
12
|
+
mainViewScenePathChange: string;
|
13
|
+
mainViewSceneIndexChange: number;
|
14
|
+
focusedChange: string | undefined;
|
15
|
+
mainViewScenesLengthChange: number;
|
16
|
+
canRedoStepsChange: number;
|
17
|
+
canUndoStepsChange: number;
|
18
|
+
loadApp: LoadAppEvent;
|
19
|
+
ready: undefined; // 所有 APP 创建完毕时触发
|
20
|
+
sceneStateChange: SceneState;
|
21
|
+
};
|
22
|
+
|
23
|
+
export type CallbacksType = Emittery<PublicEvent>;
|
24
|
+
export const callbacks: CallbacksType = new Emittery();
|
package/src/index.ts
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
import Emittery from "emittery";
|
2
1
|
import pRetry from "p-retry";
|
3
2
|
import { AppManager } from "./AppManager";
|
4
3
|
import { appRegister } from "./Register";
|
4
|
+
import { callbacks } from "./callback";
|
5
5
|
import { checkVersion, setupWrapper } from "./Helper";
|
6
6
|
import { ContainerResizeObserver } from "./ContainerResizeObserver";
|
7
7
|
import { createBoxManager } from "./BoxManager";
|
8
8
|
import { CursorManager } from "./Cursor";
|
9
9
|
import { DEFAULT_CONTAINER_RATIO, Events, ROOT_DIR } from "./constants";
|
10
|
+
import { emitter } from "./InternalEmitter";
|
10
11
|
import { Fields } from "./AttributesDelegate";
|
11
12
|
import { initDb } from "./Register/storage";
|
12
13
|
import { InvisiblePlugin, isPlayer, isRoom, RoomPhase, ViewMode } from "white-web-sdk";
|
@@ -18,7 +19,6 @@ import { setupBuiltin } from "./BuiltinApps";
|
|
18
19
|
import "video.js/dist/video-js.css";
|
19
20
|
import "./style.css";
|
20
21
|
import "@netless/telebox-insider/dist/style.css";
|
21
|
-
import type { LoadAppEvent } from "./Register";
|
22
22
|
import {
|
23
23
|
addEmitterOnceListener,
|
24
24
|
ensureValidScenePath,
|
@@ -45,15 +45,17 @@ import type {
|
|
45
45
|
CameraBound,
|
46
46
|
Point,
|
47
47
|
Rectangle,
|
48
|
-
ViewVisionMode,
|
49
48
|
CameraState,
|
50
49
|
Player,
|
51
50
|
ImageInformation,
|
51
|
+
SceneState,
|
52
52
|
} from "white-web-sdk";
|
53
53
|
import type { AppListeners } from "./AppListener";
|
54
54
|
import type { NetlessApp, RegisterParams } from "./typings";
|
55
55
|
import type { TeleBoxColorScheme, TeleBoxState } from "@netless/telebox-insider";
|
56
56
|
import type { AppProxy } from "./AppProxy";
|
57
|
+
import type { PublicEvent } from "./Callback";
|
58
|
+
import type Emittery from "emittery";
|
57
59
|
|
58
60
|
export type WindowMangerAttributes = {
|
59
61
|
modelValue?: string;
|
@@ -122,45 +124,6 @@ export type AppInitState = {
|
|
122
124
|
|
123
125
|
export type CursorMovePayload = { uid: string; state?: "leave"; position: Position };
|
124
126
|
|
125
|
-
export type EmitterEvent = {
|
126
|
-
onCreated: undefined;
|
127
|
-
InitReplay: AppInitState;
|
128
|
-
move: { appId: string; x: number; y: number };
|
129
|
-
focus: { appId: string };
|
130
|
-
close: { appId: string };
|
131
|
-
resize: { appId: string; width: number; height: number; x?: number; y?: number };
|
132
|
-
error: Error;
|
133
|
-
seek: number;
|
134
|
-
mainViewMounted: undefined;
|
135
|
-
observerIdChange: number;
|
136
|
-
boxStateChange: string;
|
137
|
-
playgroundSizeChange: DOMRect;
|
138
|
-
onReconnected: void;
|
139
|
-
removeScenes: string;
|
140
|
-
cursorMove: CursorMovePayload;
|
141
|
-
updateManagerRect: undefined;
|
142
|
-
focusedChange: { focused: string | undefined, prev: string | undefined };
|
143
|
-
rootDirRemoved: undefined;
|
144
|
-
};
|
145
|
-
|
146
|
-
export type EmitterType = Emittery<EmitterEvent>;
|
147
|
-
export const emitter: EmitterType = new Emittery();
|
148
|
-
|
149
|
-
export type PublicEvent = {
|
150
|
-
mainViewModeChange: ViewVisionMode;
|
151
|
-
boxStateChange: `${TELE_BOX_STATE}`;
|
152
|
-
darkModeChange: boolean;
|
153
|
-
prefersColorSchemeChange: TeleBoxColorScheme;
|
154
|
-
cameraStateChange: CameraState;
|
155
|
-
mainViewScenePathChange: string;
|
156
|
-
mainViewSceneIndexChange: number;
|
157
|
-
focusedChange: string | undefined;
|
158
|
-
mainViewScenesLengthChange: number;
|
159
|
-
canRedoStepsChange: number;
|
160
|
-
canUndoStepsChange: number;
|
161
|
-
loadApp: LoadAppEvent;
|
162
|
-
};
|
163
|
-
|
164
127
|
export type MountParams = {
|
165
128
|
room: Room | Player;
|
166
129
|
container?: HTMLElement;
|
@@ -177,15 +140,12 @@ export type MountParams = {
|
|
177
140
|
prefersColorScheme?: TeleBoxColorScheme;
|
178
141
|
};
|
179
142
|
|
180
|
-
export type CallbacksType = Emittery<PublicEvent>;
|
181
|
-
export const callbacks: CallbacksType = new Emittery();
|
182
|
-
|
183
143
|
export const reconnectRefresher = new ReconnectRefresher({ emitter });
|
184
144
|
|
185
145
|
export type AddPageParams = {
|
186
146
|
after?: boolean;
|
187
147
|
scene?: SceneDefinition;
|
188
|
-
}
|
148
|
+
};
|
189
149
|
|
190
150
|
export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
191
151
|
public static kind = "WindowManager";
|
@@ -350,6 +310,10 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
350
310
|
return mainViewElement;
|
351
311
|
}
|
352
312
|
|
313
|
+
public static get registered() {
|
314
|
+
return appRegister.registered;
|
315
|
+
}
|
316
|
+
|
353
317
|
public bindContainer(container: HTMLElement) {
|
354
318
|
if (WindowManager.isCreated && WindowManager.container) {
|
355
319
|
if (WindowManager.container.firstChild) {
|
@@ -495,10 +459,10 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
495
459
|
public async nextPage(): Promise<boolean> {
|
496
460
|
if (this.appManager) {
|
497
461
|
const nextIndex = this.mainViewSceneIndex + 1;
|
498
|
-
if (nextIndex >= this.mainViewScenesLength)
|
462
|
+
if (nextIndex >= this.mainViewScenesLength) {
|
499
463
|
console.warn(`[WindowManager]: current page is the last page`);
|
500
464
|
return false;
|
501
|
-
}
|
465
|
+
}
|
502
466
|
await this.appManager.setMainViewSceneIndex(nextIndex);
|
503
467
|
return true;
|
504
468
|
} else {
|
@@ -512,7 +476,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
512
476
|
if (prevIndex < 0) {
|
513
477
|
console.warn(`[WindowManager]: current page is the first page`);
|
514
478
|
return false;
|
515
|
-
}
|
479
|
+
}
|
516
480
|
await this.appManager.setMainViewSceneIndex(prevIndex);
|
517
481
|
return true;
|
518
482
|
} else {
|
@@ -690,20 +654,19 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
690
654
|
}
|
691
655
|
|
692
656
|
public get canRedoSteps(): number {
|
693
|
-
|
694
|
-
if (focused) {
|
695
|
-
return this.appManager?.focusApp?.view?.canRedoSteps || 0;
|
696
|
-
} else {
|
697
|
-
return this.mainView.canRedoSteps;
|
698
|
-
}
|
657
|
+
return this.focusedView?.canRedoSteps || 0;
|
699
658
|
}
|
700
659
|
|
701
660
|
public get canUndoSteps(): number {
|
702
|
-
|
703
|
-
|
704
|
-
|
661
|
+
return this.focusedView?.canUndoSteps || 0;
|
662
|
+
}
|
663
|
+
|
664
|
+
public get sceneState(): SceneState {
|
665
|
+
if (this.appManager) {
|
666
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
667
|
+
return this.appManager.sceneState!;
|
705
668
|
} else {
|
706
|
-
|
669
|
+
throw new AppManagerNotInitError();
|
707
670
|
}
|
708
671
|
}
|
709
672
|
|