@netless/window-manager 0.4.0-canary.9 → 0.4.0
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/.idea/inspectionProfiles/Project_Default.xml +7 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/window-manager.iml +12 -0
- package/.vscode/settings.json +1 -0
- package/CHANGELOG.md +39 -2
- package/README.md +3 -0
- package/dist/App/MagixEvent/index.d.ts +29 -0
- package/dist/App/Storage/index.d.ts +19 -6
- package/dist/App/Storage/typings.d.ts +1 -0
- package/dist/AppContext.d.ts +39 -17
- package/dist/AppListener.d.ts +2 -0
- package/dist/AppManager.d.ts +22 -8
- package/dist/AppProxy.d.ts +5 -5
- package/dist/AttributesDelegate.d.ts +2 -2
- package/dist/BoxManager.d.ts +6 -4
- package/dist/BuiltinApps.d.ts +0 -1
- package/dist/Cursor/Cursor.d.ts +10 -12
- package/dist/Cursor/index.d.ts +6 -16
- package/dist/Helper.d.ts +1 -0
- package/dist/Register/storage.d.ts +5 -1
- package/dist/Utils/AppCreateQueue.d.ts +11 -0
- package/dist/Utils/Common.d.ts +4 -1
- package/dist/Utils/RoomHacker.d.ts +3 -3
- package/dist/View/MainView.d.ts +4 -3
- package/dist/constants.d.ts +5 -2
- package/dist/index.d.ts +30 -6
- package/dist/index.es.js +41 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +41 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/typings.d.ts +2 -2
- package/docs/advanced.md +39 -0
- package/docs/api.md +69 -6
- package/docs/concept.md +9 -0
- package/docs/replay.md +40 -0
- package/package.json +7 -6
- package/src/App/MagixEvent/index.ts +68 -0
- package/src/App/Storage/index.ts +89 -43
- package/src/App/Storage/typings.ts +4 -2
- package/src/AppContext.ts +61 -24
- package/src/AppListener.ts +27 -8
- package/src/AppManager.ts +231 -70
- package/src/AppProxy.ts +40 -29
- package/src/AttributesDelegate.ts +2 -2
- package/src/BoxManager.ts +33 -19
- package/src/BuiltinApps.ts +0 -1
- package/src/ContainerResizeObserver.ts +3 -3
- package/src/Cursor/Cursor.svelte +25 -21
- package/src/Cursor/Cursor.ts +25 -38
- package/src/Cursor/icons.ts +2 -0
- package/src/Cursor/index.ts +45 -139
- package/src/Helper.ts +12 -1
- package/src/Register/index.ts +25 -16
- package/src/Register/loader.ts +2 -2
- package/src/Register/storage.ts +6 -1
- package/src/Utils/AppCreateQueue.ts +54 -0
- package/src/Utils/Common.ts +35 -2
- package/src/Utils/RoomHacker.ts +33 -18
- package/src/View/MainView.ts +19 -12
- package/src/View/ViewManager.ts +1 -2
- package/src/constants.ts +6 -2
- package/src/image/laser-pointer-cursor.svg +17 -0
- package/src/index.ts +148 -33
- package/src/shim.d.ts +2 -1
- package/src/style.css +6 -1
- package/src/typings.ts +2 -2
- package/vite.config.js +5 -2
- package/dist/Base/Context.d.ts +0 -12
- package/dist/Base/index.d.ts +0 -7
- package/src/Base/Context.ts +0 -45
- package/src/Base/index.ts +0 -10
package/src/View/MainView.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import { AnimationMode, reaction } from "white-web-sdk";
|
2
|
-
import { Base } from "../Base";
|
3
2
|
import { callbacks, emitter } from "../index";
|
4
3
|
import { createView } from "./ViewManager";
|
5
4
|
import { debounce, isEmpty, isEqual } from "lodash";
|
@@ -9,20 +8,20 @@ import { SideEffectManager } from "side-effect-manager";
|
|
9
8
|
import type { Camera, Size, View } from "white-web-sdk";
|
10
9
|
import type { AppManager } from "../AppManager";
|
11
10
|
|
12
|
-
export class MainViewProxy
|
11
|
+
export class MainViewProxy {
|
13
12
|
private scale?: number;
|
14
13
|
private started = false;
|
15
14
|
private mainViewIsAddListener = false;
|
16
15
|
private mainView: View;
|
17
|
-
private
|
16
|
+
private store = this.manager.store;
|
18
17
|
|
19
18
|
private sideEffectManager = new SideEffectManager();
|
20
19
|
|
21
|
-
constructor(manager: AppManager) {
|
22
|
-
super(manager);
|
20
|
+
constructor(private manager: AppManager) {
|
23
21
|
this.mainView = this.createMainView();
|
24
22
|
this.moveCameraSizeByAttributes();
|
25
23
|
emitter.once("mainViewMounted").then(() => {
|
24
|
+
this.addMainViewListener();
|
26
25
|
setTimeout(() => {
|
27
26
|
this.start();
|
28
27
|
if (!this.mainViewCamera || !this.mainViewSize) {
|
@@ -61,15 +60,15 @@ export class MainViewProxy extends Base {
|
|
61
60
|
}
|
62
61
|
|
63
62
|
public setCameraAndSize(): void {
|
64
|
-
this.store.setMainViewCamera({ ...this.mainView.camera, id: this.
|
65
|
-
this.store.setMainViewSize({ ...this.mainView.size, id: this.
|
63
|
+
this.store.setMainViewCamera({ ...this.mainView.camera, id: this.manager.uid });
|
64
|
+
this.store.setMainViewSize({ ...this.mainView.size, id: this.manager.uid });
|
66
65
|
}
|
67
66
|
|
68
67
|
private cameraReaction = () => {
|
69
68
|
return reaction(
|
70
69
|
() => this.mainViewCamera,
|
71
70
|
camera => {
|
72
|
-
if (camera && camera.id !== this.
|
71
|
+
if (camera && camera.id !== this.manager.uid) {
|
73
72
|
this.moveCameraToContian(this.mainViewSize);
|
74
73
|
this.moveCamera(camera);
|
75
74
|
}
|
@@ -104,9 +103,16 @@ export class MainViewProxy extends Base {
|
|
104
103
|
return mainView;
|
105
104
|
}
|
106
105
|
|
106
|
+
public onReconnect(): void {
|
107
|
+
const mainViewScenePath = this.store.getMainViewScenePath();
|
108
|
+
if (mainViewScenePath) {
|
109
|
+
setViewFocusScenePath(this.view, mainViewScenePath);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
107
113
|
private onCameraUpdatedByDevice = (camera: Camera) => {
|
108
|
-
this.store.setMainViewCamera({ ...camera, id: this.
|
109
|
-
if (!isEqual(this.mainViewSize, { ...this.mainView.size, id: this.
|
114
|
+
this.store.setMainViewCamera({ ...camera, id: this.manager.uid });
|
115
|
+
if (!isEqual(this.mainViewSize, { ...this.mainView.size, id: this.manager.uid })) {
|
110
116
|
this.setMainViewSize(this.view.size);
|
111
117
|
}
|
112
118
|
};
|
@@ -134,11 +140,11 @@ export class MainViewProxy extends Base {
|
|
134
140
|
public async mainViewClickHandler(): Promise<void> {
|
135
141
|
if (!this.manager.canOperate) return;
|
136
142
|
this.store.cleanFocus();
|
137
|
-
this.
|
143
|
+
this.manager.boxManager?.blurAllBox();
|
138
144
|
}
|
139
145
|
|
140
146
|
public setMainViewSize = debounce(size => {
|
141
|
-
this.store.setMainViewSize({ ...size, id: this.
|
147
|
+
this.store.setMainViewSize({ ...size, id: this.manager.uid });
|
142
148
|
}, 50);
|
143
149
|
|
144
150
|
private addCameraListener() {
|
@@ -185,6 +191,7 @@ export class MainViewProxy extends Base {
|
|
185
191
|
}
|
186
192
|
|
187
193
|
public stop() {
|
194
|
+
this.removeMainViewListener();
|
188
195
|
this.removeCameraListener();
|
189
196
|
this.manager.refresher?.remove(Fields.MainViewCamera);
|
190
197
|
this.manager.refresher?.remove(Fields.MainViewSize);
|
package/src/View/ViewManager.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { View
|
1
|
+
import type { View, Displayer } from "white-web-sdk";
|
2
2
|
|
3
3
|
export class ViewManager {
|
4
4
|
public views: Map<string, View> = new Map();
|
@@ -38,7 +38,6 @@ export class ViewManager {
|
|
38
38
|
}
|
39
39
|
}
|
40
40
|
|
41
|
-
|
42
41
|
export const createView = (displayer: Displayer): View => {
|
43
42
|
const view = displayer.views.createView();
|
44
43
|
setDefaultCameraBound(view);
|
package/src/constants.ts
CHANGED
@@ -10,7 +10,9 @@ export enum Events {
|
|
10
10
|
SetMainViewScenePath = "SetMainViewScenePath",
|
11
11
|
SetMainViewSceneIndex = "SetMainViewSceneIndex",
|
12
12
|
SwitchViewsToFreedom = "SwitchViewsToFreedom",
|
13
|
-
|
13
|
+
MoveCamera = "MoveCamera",
|
14
|
+
MoveCameraToContain = "MoveCameraToContain",
|
15
|
+
CursorMove = "CursorMove",
|
14
16
|
}
|
15
17
|
|
16
18
|
export const MagixEventName = "__WindowManger";
|
@@ -37,7 +39,7 @@ export enum CursorState {
|
|
37
39
|
Normal = "normal",
|
38
40
|
}
|
39
41
|
|
40
|
-
export const REQUIRE_VERSION = "2.16.
|
42
|
+
export const REQUIRE_VERSION = "2.16.1";
|
41
43
|
|
42
44
|
export const MIN_WIDTH = 340 / 720;
|
43
45
|
export const MIN_HEIGHT = 340 / 720;
|
@@ -45,3 +47,5 @@ export const MIN_HEIGHT = 340 / 720;
|
|
45
47
|
export const SET_SCENEPATH_DELAY = 100; // 设置 scenePath 的延迟事件
|
46
48
|
|
47
49
|
export const DEFAULT_CONTAINER_RATIO = 9 / 16;
|
50
|
+
|
51
|
+
export const ROOT_DIR = "/";
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<svg width="28px" height="28px" viewBox="0 0 28 28" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
3
|
+
<!-- Generator: Sketch 55.1 (78136) - https://sketchapp.com -->
|
4
|
+
<title>编组 2</title>
|
5
|
+
<desc>Created with Sketch.</desc>
|
6
|
+
<defs>
|
7
|
+
<filter x="-120.0%" y="-120.0%" width="340.0%" height="340.0%" filterUnits="objectBoundingBox" id="filter-1">
|
8
|
+
<feGaussianBlur stdDeviation="4" in="SourceGraphic"></feGaussianBlur>
|
9
|
+
</filter>
|
10
|
+
</defs>
|
11
|
+
<g id="页面1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
12
|
+
<g id="编组-2" transform="translate(9.000000, 9.000000)" fill="#FF0100">
|
13
|
+
<circle id="椭圆形" filter="url(#filter-1)" cx="5" cy="5" r="5"></circle>
|
14
|
+
<path d="M5,8 C6.65685425,8 8,6.65685425 8,5 C8,3.34314575 6.65685425,2 5,2 C3.34314575,2 2,3.34314575 2,5 C2,6.65685425 3.34314575,8 5,8 Z M5,6.28571429 C4.28991961,6.28571429 3.71428571,5.71008039 3.71428571,5 C3.71428571,4.28991961 4.28991961,3.71428571 5,3.71428571 C5.71008039,3.71428571 6.28571429,4.28991961 6.28571429,5 C6.28571429,5.71008039 5.71008039,6.28571429 5,6.28571429 Z" id="椭圆形" fill-rule="nonzero"></path>
|
15
|
+
</g>
|
16
|
+
</g>
|
17
|
+
</svg>
|
package/src/index.ts
CHANGED
@@ -2,24 +2,25 @@ import Emittery from "emittery";
|
|
2
2
|
import pRetry from "p-retry";
|
3
3
|
import { AppManager } from "./AppManager";
|
4
4
|
import { appRegister } from "./Register";
|
5
|
+
import { checkVersion, setupWrapper } from "./Helper";
|
5
6
|
import { ContainerResizeObserver } from "./ContainerResizeObserver";
|
6
7
|
import { createBoxManager } from "./BoxManager";
|
7
8
|
import { CursorManager } from "./Cursor";
|
8
|
-
import { DEFAULT_CONTAINER_RATIO, Events
|
9
|
+
import { DEFAULT_CONTAINER_RATIO, Events } from "./constants";
|
9
10
|
import { Fields } from "./AttributesDelegate";
|
10
11
|
import { initDb } from "./Register/storage";
|
11
|
-
import {
|
12
|
+
import { InvisiblePlugin, isPlayer, isRoom, RoomPhase, ViewMode } from "white-web-sdk";
|
13
|
+
import { isEqual, isNull, isObject, omit } from "lodash";
|
12
14
|
import { log } from "./Utils/log";
|
13
15
|
import { ReconnectRefresher } from "./ReconnectRefresher";
|
14
16
|
import { replaceRoomFunction } from "./Utils/RoomHacker";
|
15
17
|
import { setupBuiltin } from "./BuiltinApps";
|
16
|
-
import { setupWrapper } from "./Helper";
|
17
18
|
import "./style.css";
|
18
19
|
import "@netless/telebox-insider/dist/style.css";
|
19
20
|
import {
|
20
21
|
addEmitterOnceListener,
|
21
22
|
ensureValidScenePath,
|
22
|
-
|
23
|
+
entireScenes,
|
23
24
|
isValidScenePath,
|
24
25
|
wait,
|
25
26
|
} from "./Utils/Common";
|
@@ -29,17 +30,8 @@ import {
|
|
29
30
|
AppManagerNotInitError,
|
30
31
|
InvalidScenePath,
|
31
32
|
ParamsInvalidError,
|
32
|
-
WhiteWebSDKInvalidError,
|
33
33
|
} from "./Utils/error";
|
34
|
-
import type { Apps } from "./AttributesDelegate";
|
35
|
-
import {
|
36
|
-
InvisiblePlugin,
|
37
|
-
isPlayer,
|
38
|
-
isRoom,
|
39
|
-
RoomPhase,
|
40
|
-
ViewMode,
|
41
|
-
WhiteVersion,
|
42
|
-
} from "white-web-sdk";
|
34
|
+
import type { Apps, Position } from "./AttributesDelegate";
|
43
35
|
import type {
|
44
36
|
Displayer,
|
45
37
|
SceneDefinition,
|
@@ -53,6 +45,7 @@ import type {
|
|
53
45
|
Rectangle,
|
54
46
|
ViewVisionMode,
|
55
47
|
CameraState,
|
48
|
+
Player,
|
56
49
|
} from "white-web-sdk";
|
57
50
|
import type { AppListeners } from "./AppListener";
|
58
51
|
import type { NetlessApp, RegisterParams } from "./typings";
|
@@ -124,6 +117,8 @@ export type AppInitState = {
|
|
124
117
|
zIndex?: number;
|
125
118
|
};
|
126
119
|
|
120
|
+
export type CursorMovePayload = { uid: string; state?: "leave"; position: Position };
|
121
|
+
|
127
122
|
export type EmitterEvent = {
|
128
123
|
onCreated: undefined;
|
129
124
|
InitReplay: AppInitState;
|
@@ -138,6 +133,8 @@ export type EmitterEvent = {
|
|
138
133
|
boxStateChange: string;
|
139
134
|
playgroundSizeChange: DOMRect;
|
140
135
|
onReconnected: void;
|
136
|
+
removeScenes: string;
|
137
|
+
cursorMove: CursorMovePayload;
|
141
138
|
};
|
142
139
|
|
143
140
|
export type EmitterType = Emittery<EmitterEvent>;
|
@@ -151,10 +148,14 @@ export type PublicEvent = {
|
|
151
148
|
cameraStateChange: CameraState;
|
152
149
|
mainViewScenePathChange: string;
|
153
150
|
mainViewSceneIndexChange: number;
|
151
|
+
focusedChange: string | undefined;
|
152
|
+
mainViewScenesLengthChange: number;
|
153
|
+
canRedoStepsChange: number;
|
154
|
+
canUndoStepsChange: number;
|
154
155
|
};
|
155
156
|
|
156
157
|
export type MountParams = {
|
157
|
-
room: Room;
|
158
|
+
room: Room | Player;
|
158
159
|
container?: HTMLElement;
|
159
160
|
/** 白板高宽比例, 默认为 9 / 16 */
|
160
161
|
containerSizeRatio?: number;
|
@@ -185,6 +186,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
185
186
|
private static isCreated = false;
|
186
187
|
|
187
188
|
public version = __APP_VERSION__;
|
189
|
+
public dependencies = __APP_DEPENDENCIES__;
|
188
190
|
|
189
191
|
public appListeners?: AppListeners;
|
190
192
|
|
@@ -203,6 +205,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
203
205
|
constructor(context: InvisiblePluginContext) {
|
204
206
|
super(context);
|
205
207
|
WindowManager.displayer = context.displayer;
|
208
|
+
(window as any).NETLESS_DEPS = __APP_DEPENDENCIES__;
|
206
209
|
}
|
207
210
|
|
208
211
|
public static async mount(params: MountParams): Promise<WindowManager> {
|
@@ -214,16 +217,22 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
214
217
|
const cursor = params.cursor;
|
215
218
|
WindowManager.params = params;
|
216
219
|
|
217
|
-
|
220
|
+
checkVersion();
|
221
|
+
let manager: WindowManager | undefined = undefined;
|
218
222
|
if (isRoom(room)) {
|
219
223
|
if (room.phase !== RoomPhase.Connected) {
|
220
224
|
throw new Error("[WindowManager]: Room only Connected can be mount");
|
221
225
|
}
|
226
|
+
if (room.phase === RoomPhase.Connected && room.isWritable) {
|
227
|
+
// redo undo 需要设置这个属性
|
228
|
+
room.disableSerialization = false;
|
229
|
+
}
|
230
|
+
manager = await this.initManager(room);
|
222
231
|
}
|
223
232
|
if (WindowManager.isCreated) {
|
224
233
|
throw new Error("[WindowManager]: Already created cannot be created again");
|
225
234
|
}
|
226
|
-
|
235
|
+
|
227
236
|
this.debug = Boolean(debug);
|
228
237
|
log("Already insert room", manager);
|
229
238
|
|
@@ -234,7 +243,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
234
243
|
} else {
|
235
244
|
await pRetry(
|
236
245
|
async count => {
|
237
|
-
manager = await
|
246
|
+
manager = (await room.getInvisiblePlugin(WindowManager.kind)) as WindowManager;
|
238
247
|
if (!manager) {
|
239
248
|
log(`manager is empty. retrying ${count}`);
|
240
249
|
throw new Error();
|
@@ -244,16 +253,17 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
244
253
|
);
|
245
254
|
}
|
246
255
|
|
256
|
+
if (!manager) {
|
257
|
+
throw new Error("[WindowManager]: create manager failed");
|
258
|
+
}
|
259
|
+
|
247
260
|
if (containerSizeRatio) {
|
248
261
|
WindowManager.containerSizeRatio = containerSizeRatio;
|
249
262
|
}
|
250
263
|
await manager.ensureAttributes();
|
251
264
|
|
252
265
|
manager.appManager = new AppManager(manager);
|
253
|
-
|
254
|
-
if (cursor) {
|
255
|
-
manager.cursorManager = new CursorManager(manager.appManager);
|
256
|
-
}
|
266
|
+
manager.cursorManager = new CursorManager(manager.appManager, Boolean(cursor));
|
257
267
|
|
258
268
|
if (params.container) {
|
259
269
|
manager.bindContainer(params.container);
|
@@ -359,6 +369,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
359
369
|
this.appManager?.refresh();
|
360
370
|
this.appManager?.resetMaximized();
|
361
371
|
this.appManager?.resetMinimized();
|
372
|
+
this.appManager?.displayerWritableListener(!this.room.isWritable);
|
362
373
|
WindowManager.container = container;
|
363
374
|
}
|
364
375
|
|
@@ -422,6 +433,12 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
422
433
|
const appScenePath = appManager.store.getAppScenePath(appId);
|
423
434
|
if (appScenePath && appScenePath === scenePath) {
|
424
435
|
console.warn(`[WindowManager]: ScenePath ${scenePath} Already opened`);
|
436
|
+
if (this.boxManager) {
|
437
|
+
const topBox = this.boxManager.getTopBox();
|
438
|
+
if (topBox) {
|
439
|
+
this.boxManager.setZIndex(appId, topBox.zIndex + 1, false);
|
440
|
+
}
|
441
|
+
}
|
425
442
|
return;
|
426
443
|
}
|
427
444
|
}
|
@@ -429,11 +446,11 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
429
446
|
if (scenePath && scenes && scenes.length > 0) {
|
430
447
|
if (this.isDynamicPPT(scenes)) {
|
431
448
|
isDynamicPPT = true;
|
432
|
-
if (!this.displayer
|
449
|
+
if (!entireScenes(this.displayer)[scenePath]) {
|
433
450
|
this.room?.putScenes(scenePath, scenes);
|
434
451
|
}
|
435
452
|
} else {
|
436
|
-
if (!this.displayer
|
453
|
+
if (!entireScenes(this.displayer)[scenePath]) {
|
437
454
|
this.room?.putScenes(scenePath, [{ name: scenes[0].name }]);
|
438
455
|
}
|
439
456
|
}
|
@@ -466,7 +483,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
466
483
|
/**
|
467
484
|
* 返回 mainView 的 ScenePath
|
468
485
|
*/
|
469
|
-
public getMainViewScenePath(): string {
|
486
|
+
public getMainViewScenePath(): string | undefined {
|
470
487
|
return this.appManager?.store.getMainViewScenePath();
|
471
488
|
}
|
472
489
|
|
@@ -514,6 +531,35 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
514
531
|
this.viewMode = mode;
|
515
532
|
}
|
516
533
|
|
534
|
+
public setBoxState(boxState: TeleBoxState): void {
|
535
|
+
if (!this.canOperate) return;
|
536
|
+
switch (boxState) {
|
537
|
+
case "normal":
|
538
|
+
this.setMaximized(false);
|
539
|
+
this.setMinimized(false);
|
540
|
+
break;
|
541
|
+
case "maximized":
|
542
|
+
this.setMaximized(true);
|
543
|
+
this.setMinimized(false);
|
544
|
+
break;
|
545
|
+
case "minimized":
|
546
|
+
this.setMinimized(true);
|
547
|
+
break;
|
548
|
+
default:
|
549
|
+
break;
|
550
|
+
}
|
551
|
+
}
|
552
|
+
|
553
|
+
public setMaximized(maximized: boolean): void {
|
554
|
+
if (!this.canOperate) return;
|
555
|
+
this.boxManager?.setMaximized(maximized, false);
|
556
|
+
}
|
557
|
+
|
558
|
+
public setMinimized(minimized: boolean): void {
|
559
|
+
if (!this.canOperate) return;
|
560
|
+
this.boxManager?.setMinimized(minimized, false);
|
561
|
+
}
|
562
|
+
|
517
563
|
public get mainView(): View {
|
518
564
|
if (this.appManager) {
|
519
565
|
return this.appManager.mainViewProxy.view;
|
@@ -562,6 +608,48 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
562
608
|
}
|
563
609
|
}
|
564
610
|
|
611
|
+
public get focused(): string | undefined {
|
612
|
+
return this.attributes.focus;
|
613
|
+
}
|
614
|
+
|
615
|
+
public get mainViewSceneIndex(): number {
|
616
|
+
return this.appManager?.store.getMainViewSceneIndex();
|
617
|
+
}
|
618
|
+
|
619
|
+
public get mainViewSceneDir(): string {
|
620
|
+
if (this.appManager) {
|
621
|
+
return this.appManager?.getMainViewSceneDir();
|
622
|
+
} else {
|
623
|
+
throw new AppManagerNotInitError();
|
624
|
+
}
|
625
|
+
}
|
626
|
+
|
627
|
+
public get topApp(): string | undefined {
|
628
|
+
return this.boxManager?.getTopBox()?.id;
|
629
|
+
}
|
630
|
+
|
631
|
+
public get mainViewScenesLength(): number {
|
632
|
+
return this.appManager?.mainViewScenesLength || 0;
|
633
|
+
}
|
634
|
+
|
635
|
+
public get canRedoSteps(): number {
|
636
|
+
const focused = this.focused;
|
637
|
+
if (focused) {
|
638
|
+
return this.appManager?.focusApp?.view?.canRedoSteps || 0;
|
639
|
+
} else {
|
640
|
+
return this.mainView.canRedoSteps;
|
641
|
+
}
|
642
|
+
}
|
643
|
+
|
644
|
+
public get canUndoSteps(): number {
|
645
|
+
const focused = this.focused;
|
646
|
+
if (focused) {
|
647
|
+
return this.appManager?.focusApp?.view?.canUndoSteps || 0;
|
648
|
+
} else {
|
649
|
+
return this.mainView.canUndoSteps;
|
650
|
+
}
|
651
|
+
}
|
652
|
+
|
565
653
|
/**
|
566
654
|
* 查询所有的 App
|
567
655
|
*/
|
@@ -586,7 +674,14 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
586
674
|
public moveCamera(
|
587
675
|
camera: Partial<Camera> & { animationMode?: AnimationMode | undefined }
|
588
676
|
): void {
|
677
|
+
const pureCamera = omit(camera, ["animationMode"]);
|
678
|
+
const mainViewCamera = { ...this.mainView.camera };
|
679
|
+
if (isEqual({ ...mainViewCamera, ...pureCamera }, mainViewCamera)) return;
|
589
680
|
this.mainView.moveCamera(camera);
|
681
|
+
this.appManager?.dispatchInternalEvent(Events.MoveCamera, camera);
|
682
|
+
setTimeout(() => {
|
683
|
+
this.appManager?.mainViewProxy.setCameraAndSize();
|
684
|
+
}, 100);
|
590
685
|
}
|
591
686
|
|
592
687
|
public moveCameraToContain(
|
@@ -599,7 +694,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
599
694
|
this.appManager?.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
|
600
695
|
setTimeout(() => {
|
601
696
|
this.appManager?.mainViewProxy.setCameraAndSize();
|
602
|
-
},
|
697
|
+
}, 100);
|
603
698
|
}
|
604
699
|
|
605
700
|
public convertToPointInWorld(point: Point): Point {
|
@@ -670,18 +765,38 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
670
765
|
this.appManager?.boxManager?.setPrefersColorScheme(scheme);
|
671
766
|
}
|
672
767
|
|
673
|
-
|
674
|
-
const
|
675
|
-
|
768
|
+
public cleanCurrentScene(): void {
|
769
|
+
const focused = this.focused;
|
770
|
+
if (focused) {
|
771
|
+
this.appManager?.focusApp?.view?.cleanCurrentScene();
|
772
|
+
} else {
|
773
|
+
this.mainView.cleanCurrentScene();
|
774
|
+
}
|
775
|
+
}
|
776
|
+
|
777
|
+
public redo(): number {
|
778
|
+
const focused = this.focused;
|
779
|
+
if (focused) {
|
780
|
+
return this.appManager?.focusApp?.view?.redo() || 0;
|
781
|
+
} else {
|
782
|
+
return this.mainView.redo();
|
783
|
+
}
|
676
784
|
}
|
677
785
|
|
678
|
-
|
679
|
-
const
|
680
|
-
if (
|
681
|
-
|
786
|
+
public undo(): number {
|
787
|
+
const focused = this.focused;
|
788
|
+
if (focused) {
|
789
|
+
return this.appManager?.focusApp?.view?.undo() || 0;
|
790
|
+
} else {
|
791
|
+
return this.mainView.undo();
|
682
792
|
}
|
683
793
|
}
|
684
794
|
|
795
|
+
private isDynamicPPT(scenes: SceneDefinition[]) {
|
796
|
+
const sceneSrc = scenes[0]?.ppt?.src;
|
797
|
+
return sceneSrc?.startsWith("pptx://");
|
798
|
+
}
|
799
|
+
|
685
800
|
private async ensureAttributes() {
|
686
801
|
if (isNull(this.attributes)) {
|
687
802
|
await wait(50);
|
package/src/shim.d.ts
CHANGED
package/src/style.css
CHANGED
@@ -122,7 +122,7 @@
|
|
122
122
|
left: 0;
|
123
123
|
top: 0;
|
124
124
|
will-change: transform;
|
125
|
-
transition: transform 0.
|
125
|
+
transition: transform 0.1s;
|
126
126
|
transform-origin: 0 0;
|
127
127
|
user-select: none;
|
128
128
|
}
|
@@ -153,6 +153,11 @@
|
|
153
153
|
margin-top: 12px;
|
154
154
|
}
|
155
155
|
|
156
|
+
.netless-window-manager-cursor-laserPointer-image {
|
157
|
+
margin-left: -22px;
|
158
|
+
margin-top: 3px;
|
159
|
+
}
|
160
|
+
|
156
161
|
.netless-window-manager-cursor-name {
|
157
162
|
width: 100%;
|
158
163
|
height: 48px;
|
package/src/typings.ts
CHANGED
@@ -12,7 +12,7 @@ import type {
|
|
12
12
|
import type { AppContext } from "./AppContext";
|
13
13
|
import type { ReadonlyTeleBox, TeleBoxRect } from "@netless/telebox-insider";
|
14
14
|
|
15
|
-
export interface NetlessApp<Attributes = any,
|
15
|
+
export interface NetlessApp<Attributes = any, MagixEventPayloads = any, AppOptions = any, SetupResult = any> {
|
16
16
|
kind: string;
|
17
17
|
config?: {
|
18
18
|
/** Box width relative to whiteboard. 0~1. Default 0.5. */
|
@@ -28,7 +28,7 @@ export interface NetlessApp<Attributes = any, SetupResult = any, AppOptions = an
|
|
28
28
|
/** App only single instance. */
|
29
29
|
singleton?: boolean;
|
30
30
|
};
|
31
|
-
setup: (context: AppContext<Attributes, AppOptions>) => SetupResult;
|
31
|
+
setup: (context: AppContext<Attributes, MagixEventPayloads, AppOptions>) => SetupResult;
|
32
32
|
}
|
33
33
|
|
34
34
|
export type AppEmitterEvent<T = any> = {
|
package/vite.config.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import path from "path";
|
2
2
|
import { defineConfig } from "vite";
|
3
3
|
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
4
|
-
import { dependencies
|
4
|
+
import { dependencies, peerDependencies, version, devDependencies } from "./package.json"
|
5
5
|
|
6
6
|
|
7
7
|
export default defineConfig(({ mode }) => {
|
@@ -10,6 +10,9 @@ export default defineConfig(({ mode }) => {
|
|
10
10
|
return {
|
11
11
|
define: {
|
12
12
|
__APP_VERSION__: JSON.stringify(version),
|
13
|
+
__APP_DEPENDENCIES__: JSON.stringify({
|
14
|
+
dependencies, peerDependencies, devDependencies
|
15
|
+
}),
|
13
16
|
},
|
14
17
|
plugins: [
|
15
18
|
svelte({
|
@@ -23,7 +26,7 @@ export default defineConfig(({ mode }) => {
|
|
23
26
|
lib: {
|
24
27
|
// eslint-disable-next-line no-undef
|
25
28
|
entry: path.resolve(__dirname, "src/index.ts"),
|
26
|
-
formats: ["es","umd"], // TODO cjs 版本待修复
|
29
|
+
formats: ["es", "umd"], // TODO cjs 版本待修复
|
27
30
|
name: "WindowManager",
|
28
31
|
fileName: "index"
|
29
32
|
},
|
package/dist/Base/Context.d.ts
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
import type { AppManager } from "../AppManager";
|
2
|
-
export declare class Context {
|
3
|
-
private manager;
|
4
|
-
observerId: number;
|
5
|
-
constructor(manager: AppManager);
|
6
|
-
get uid(): string;
|
7
|
-
findMember: (memberId: number) => import("white-web-sdk").RoomMember | undefined;
|
8
|
-
findMemberByUid: (uid: string) => import("white-web-sdk").RoomMember | undefined;
|
9
|
-
updateManagerRect(): void;
|
10
|
-
blurFocusBox(): void;
|
11
|
-
}
|
12
|
-
export declare const createContext: (manager: AppManager) => Context;
|
package/dist/Base/index.d.ts
DELETED
package/src/Base/Context.ts
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
import { emitter } from "../index";
|
2
|
-
import type { AppManager } from "../AppManager";
|
3
|
-
|
4
|
-
export class Context {
|
5
|
-
public observerId: number;
|
6
|
-
|
7
|
-
constructor(private manager: AppManager) {
|
8
|
-
this.observerId = manager.displayer.observerId;
|
9
|
-
|
10
|
-
emitter.on("observerIdChange", id => {
|
11
|
-
this.observerId = id;
|
12
|
-
});
|
13
|
-
};
|
14
|
-
|
15
|
-
public get uid() {
|
16
|
-
return this.manager.room?.uid || "";
|
17
|
-
}
|
18
|
-
|
19
|
-
public findMember = (memberId: number) => {
|
20
|
-
const roomMembers = this.manager.room?.state.roomMembers;
|
21
|
-
return roomMembers?.find(member => member.memberId === memberId);
|
22
|
-
}
|
23
|
-
|
24
|
-
public findMemberByUid = (uid: string) => {
|
25
|
-
const roomMembers = this.manager.room?.state.roomMembers;
|
26
|
-
return roomMembers?.find(member => member.payload?.uid === uid);
|
27
|
-
}
|
28
|
-
|
29
|
-
public updateManagerRect() {
|
30
|
-
this.manager.boxManager?.updateManagerRect();
|
31
|
-
}
|
32
|
-
|
33
|
-
public blurFocusBox() {
|
34
|
-
this.manager.boxManager?.blurAllBox();
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
|
-
let context: Context;
|
39
|
-
|
40
|
-
export const createContext = (manager: AppManager) => {
|
41
|
-
if (!context) {
|
42
|
-
context = new Context(manager);
|
43
|
-
}
|
44
|
-
return context;
|
45
|
-
};
|
package/src/Base/index.ts
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { AppManager } from "../AppManager";
|
2
|
-
import { store } from "../AttributesDelegate";
|
3
|
-
import { createContext } from "./Context";
|
4
|
-
|
5
|
-
export class Base {
|
6
|
-
public store = store;
|
7
|
-
public context = createContext(this.manager);
|
8
|
-
|
9
|
-
constructor(public manager: AppManager) {}
|
10
|
-
}
|