@netless/window-manager 0.4.0-canary.3 → 0.4.0-canary.33
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 +32 -1
- package/README.md +3 -0
- package/dist/App/MagixEvent/index.d.ts +29 -0
- package/dist/App/Storage/StorageEvent.d.ts +8 -0
- package/dist/App/Storage/index.d.ts +39 -0
- package/dist/App/Storage/typings.d.ts +22 -0
- package/dist/App/Storage/utils.d.ts +5 -0
- package/dist/AppContext.d.ts +40 -16
- package/dist/AppListener.d.ts +2 -1
- package/dist/AppManager.d.ts +26 -12
- package/dist/AppProxy.d.ts +7 -8
- package/dist/AttributesDelegate.d.ts +2 -2
- package/dist/BoxManager.d.ts +6 -3
- package/dist/BuiltinApps.d.ts +5 -0
- package/dist/ContainerResizeObserver.d.ts +10 -0
- package/dist/Cursor/Cursor.d.ts +10 -12
- package/dist/Cursor/index.d.ts +6 -16
- package/dist/Helper.d.ts +7 -0
- package/dist/ReconnectRefresher.d.ts +0 -1
- package/dist/Register/storage.d.ts +5 -1
- package/dist/Utils/AppCreateQueue.d.ts +11 -0
- package/dist/Utils/Common.d.ts +7 -2
- package/dist/Utils/Reactive.d.ts +1 -1
- package/dist/Utils/RoomHacker.d.ts +3 -3
- package/dist/{MainView.d.ts → View/MainView.d.ts} +5 -6
- package/dist/View/ViewManager.d.ts +13 -0
- package/dist/constants.d.ts +5 -7
- package/dist/index.d.ts +36 -14
- 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 +3 -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/StorageEvent.ts +21 -0
- package/src/App/Storage/index.ts +289 -0
- package/src/App/Storage/typings.ts +23 -0
- package/src/App/Storage/utils.ts +17 -0
- package/src/AppContext.ts +69 -24
- package/src/AppListener.ts +28 -16
- package/src/AppManager.ts +261 -83
- package/src/AppProxy.ts +53 -64
- package/src/AttributesDelegate.ts +2 -2
- package/src/BoxManager.ts +40 -24
- package/src/BuiltinApps.ts +23 -0
- package/src/ContainerResizeObserver.ts +62 -0
- 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 +41 -0
- package/src/ReconnectRefresher.ts +0 -5
- 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 +69 -14
- package/src/Utils/Reactive.ts +9 -3
- package/src/Utils/RoomHacker.ts +44 -14
- package/src/{MainView.ts → View/MainView.ts} +25 -36
- package/src/View/ViewManager.ts +52 -0
- package/src/constants.ts +6 -4
- package/src/image/laser-pointer-cursor.svg +17 -0
- package/src/index.ts +168 -101
- package/src/shim.d.ts +5 -0
- package/src/style.css +7 -1
- package/src/typings.ts +3 -2
- package/vite.config.js +8 -2
- package/dist/Base/Context.d.ts +0 -13
- package/dist/Base/index.d.ts +0 -7
- package/dist/Utils/CameraStore.d.ts +0 -15
- package/dist/ViewManager.d.ts +0 -29
- package/dist/sdk.d.ts +0 -14
- package/src/Base/Context.ts +0 -49
- package/src/Base/index.ts +0 -10
- package/src/Utils/CameraStore.ts +0 -72
- package/src/sdk.ts +0 -39
- package/src/viewManager.ts +0 -177
package/src/Utils/Common.ts
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
import { appRegister } from
|
2
|
-
import { debounce } from
|
3
|
-
import { emitter } from
|
4
|
-
import {
|
1
|
+
import { appRegister } from "../Register";
|
2
|
+
import { debounce } from "lodash";
|
3
|
+
import { emitter } from "../index";
|
4
|
+
import { ScenePathType } from "white-web-sdk";
|
5
|
+
import { v4 } from "uuid";
|
5
6
|
import type { PublicEvent } from "../index";
|
6
7
|
import type { Displayer, ViewVisionMode, Room, View } from "white-web-sdk";
|
7
8
|
import type Emittery from "emittery";
|
9
|
+
import { ROOT_DIR } from "../constants";
|
8
10
|
|
9
11
|
export const genAppId = async (kind: string) => {
|
10
12
|
const impl = await appRegister.appClasses.get(kind)?.();
|
@@ -17,6 +19,14 @@ export const genAppId = async (kind: string) => {
|
|
17
19
|
export const setViewFocusScenePath = (view: View, focusScenePath: string) => {
|
18
20
|
if (view.focusScenePath !== focusScenePath) {
|
19
21
|
view.focusScenePath = focusScenePath;
|
22
|
+
return view;
|
23
|
+
}
|
24
|
+
};
|
25
|
+
|
26
|
+
export const setViewSceneIndex = (view: View, index: number) => {
|
27
|
+
if (view.focusSceneIndex !== index) {
|
28
|
+
view.focusSceneIndex = index;
|
29
|
+
return view;
|
20
30
|
}
|
21
31
|
};
|
22
32
|
|
@@ -26,7 +36,30 @@ export const setScenePath = (room: Room | undefined, scenePath: string) => {
|
|
26
36
|
room.setScenePath(scenePath);
|
27
37
|
}
|
28
38
|
}
|
29
|
-
}
|
39
|
+
};
|
40
|
+
|
41
|
+
export const getScenePath = (
|
42
|
+
room: Room | undefined,
|
43
|
+
dir: string | undefined,
|
44
|
+
index: number
|
45
|
+
): string | undefined => {
|
46
|
+
if (room && dir) {
|
47
|
+
const scenes = entireScenes(room);
|
48
|
+
const scene = scenes[dir]?.[index];
|
49
|
+
if (scene) {
|
50
|
+
return `${dir}/${scene.name}`;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
};
|
54
|
+
|
55
|
+
export const removeScenes = (room: Room | undefined, scenePath: string) => {
|
56
|
+
if (room) {
|
57
|
+
const type = room.scenePathType(scenePath);
|
58
|
+
if (type !== ScenePathType.None) {
|
59
|
+
room.removeScenes(scenePath);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
};
|
30
63
|
|
31
64
|
export const setViewMode = (view: View, mode: ViewVisionMode) => {
|
32
65
|
if (!(view as any).didRelease && view.mode !== mode) {
|
@@ -44,7 +77,7 @@ export const emitError = (error: Error) => {
|
|
44
77
|
|
45
78
|
export const addEmitterOnceListener = (event: any, listener: any) => {
|
46
79
|
emitter.once(event).then(listener);
|
47
|
-
}
|
80
|
+
};
|
48
81
|
|
49
82
|
export const notifyMainViewModeChange = debounce(
|
50
83
|
(callbacks: Emittery<PublicEvent>, mode: ViewVisionMode) => {
|
@@ -53,19 +86,38 @@ export const notifyMainViewModeChange = debounce(
|
|
53
86
|
200
|
54
87
|
);
|
55
88
|
|
56
|
-
export const makeValidScenePath = (displayer: Displayer, scenePath: string) => {
|
57
|
-
const scenes =
|
58
|
-
|
59
|
-
|
89
|
+
export const makeValidScenePath = (displayer: Displayer, scenePath: string, index = 0) => {
|
90
|
+
const scenes = entireScenes(displayer)[scenePath];
|
91
|
+
if (!scenes) return;
|
92
|
+
const scene = scenes[index];
|
93
|
+
if (!scene) return;
|
94
|
+
const firstSceneName = scene.name;
|
95
|
+
if (scenePath === ROOT_DIR) {
|
60
96
|
return `/${firstSceneName}`;
|
61
97
|
} else {
|
62
98
|
return `${scenePath}/${firstSceneName}`;
|
63
99
|
}
|
64
100
|
};
|
65
101
|
|
102
|
+
export const entireScenes = (displayer: Displayer) => {
|
103
|
+
return displayer.entireScenes();
|
104
|
+
};
|
105
|
+
|
106
|
+
|
66
107
|
export const isValidScenePath = (scenePath: string) => {
|
67
108
|
return scenePath.startsWith("/");
|
68
|
-
}
|
109
|
+
};
|
110
|
+
|
111
|
+
export const parseSceneDir = (scenePath: string) => {
|
112
|
+
const sceneList = scenePath.split("/");
|
113
|
+
sceneList.pop();
|
114
|
+
let sceneDir = sceneList.join("/");
|
115
|
+
// "/page1" 的 dir 为 "/"
|
116
|
+
if (sceneDir === "") {
|
117
|
+
sceneDir = "/";
|
118
|
+
}
|
119
|
+
return sceneDir;
|
120
|
+
};
|
69
121
|
|
70
122
|
export const ensureValidScenePath = (scenePath: string) => {
|
71
123
|
if (scenePath.endsWith("/")) {
|
@@ -73,11 +125,14 @@ export const ensureValidScenePath = (scenePath: string) => {
|
|
73
125
|
} else {
|
74
126
|
return scenePath;
|
75
127
|
}
|
76
|
-
}
|
128
|
+
};
|
77
129
|
|
78
130
|
export const getVersionNumber = (version: string) => {
|
79
|
-
const versionString = version
|
131
|
+
const versionString = version
|
132
|
+
.split(".")
|
133
|
+
.map(s => s.padStart(2, "0"))
|
134
|
+
.join("");
|
80
135
|
return parseInt(versionString);
|
81
136
|
};
|
82
137
|
|
83
|
-
export const wait = (time: number) => new Promise(
|
138
|
+
export const wait = (time: number) => new Promise(resolve => setTimeout(resolve, time));
|
package/src/Utils/Reactive.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { listenUpdated, unlistenUpdated, reaction, UpdateEventKind } from "white-web-sdk";
|
2
2
|
import type { AkkoObjectUpdatedProperty , AkkoObjectUpdatedListener } from "white-web-sdk";
|
3
|
+
import { isObject } from "lodash";
|
3
4
|
|
4
5
|
// 兼容 13 和 14 版本 SDK
|
5
6
|
export const onObjectByEvent = (event: UpdateEventKind) => {
|
@@ -30,7 +31,8 @@ export const onObjectByEvent = (event: UpdateEventKind) => {
|
|
30
31
|
|
31
32
|
export const safeListenPropsUpdated = <T>(
|
32
33
|
getProps: () => T,
|
33
|
-
callback: AkkoObjectUpdatedListener<T
|
34
|
+
callback: AkkoObjectUpdatedListener<T>,
|
35
|
+
onDestroyed?: (props: unknown) => void
|
34
36
|
) => {
|
35
37
|
let disposeListenUpdated: (() => void) | null = null;
|
36
38
|
const disposeReaction = reaction(
|
@@ -41,8 +43,12 @@ export const safeListenPropsUpdated = <T>(
|
|
41
43
|
disposeListenUpdated = null;
|
42
44
|
}
|
43
45
|
const props = getProps();
|
44
|
-
|
45
|
-
|
46
|
+
if (isObject(props)) {
|
47
|
+
disposeListenUpdated = () => unlistenUpdated(props, callback);
|
48
|
+
listenUpdated(props, callback);
|
49
|
+
} else {
|
50
|
+
onDestroyed?.(props);
|
51
|
+
}
|
46
52
|
},
|
47
53
|
{ fireImmediately: true }
|
48
54
|
);
|
package/src/Utils/RoomHacker.ts
CHANGED
@@ -1,23 +1,15 @@
|
|
1
1
|
import { emitter } from "../index";
|
2
2
|
import { isPlayer } from "white-web-sdk";
|
3
|
-
import type { WindowManager } from
|
4
|
-
import type { Camera, Room
|
3
|
+
import type { WindowManager } from "../index";
|
4
|
+
import type { Camera, Room, Player, PlayerSeekingResult } from "white-web-sdk";
|
5
5
|
|
6
6
|
// 修改多窗口状态下一些失效的方法实现到 manager 的 mainview 上, 降低迁移成本
|
7
|
-
export const replaceRoomFunction = (room: Room, manager: WindowManager) => {
|
7
|
+
export const replaceRoomFunction = (room: Room | Player, manager: WindowManager) => {
|
8
8
|
if (isPlayer(room)) {
|
9
9
|
const player = room as unknown as Player;
|
10
|
-
|
11
|
-
// eslint-disable-next-line no-inner-declarations
|
12
|
-
async function newSeek(time: number): Promise<PlayerSeekingResult> {
|
13
|
-
const seekResult = await originSeek.call(player, time);
|
14
|
-
if (seekResult === "success") {
|
15
|
-
emitter.emit("seek", time);
|
16
|
-
}
|
17
|
-
return seekResult;
|
18
|
-
}
|
19
|
-
player.seekToProgressTime = newSeek;
|
10
|
+
delegateSeekToProgressTime(player);
|
20
11
|
} else {
|
12
|
+
room = room as unknown as Room;
|
21
13
|
const descriptor = Object.getOwnPropertyDescriptor(room, "disableCameraTransform");
|
22
14
|
if (descriptor) return;
|
23
15
|
Object.defineProperty(room, "disableCameraTransform", {
|
@@ -29,6 +21,18 @@ export const replaceRoomFunction = (room: Room, manager: WindowManager) => {
|
|
29
21
|
},
|
30
22
|
});
|
31
23
|
|
24
|
+
Object.defineProperty(room, "canUndoSteps", {
|
25
|
+
get() {
|
26
|
+
return manager.mainView.canUndoSteps;
|
27
|
+
},
|
28
|
+
});
|
29
|
+
|
30
|
+
Object.defineProperty(room, "canRedoSteps", {
|
31
|
+
get() {
|
32
|
+
return manager.mainView.canRedoSteps;
|
33
|
+
},
|
34
|
+
});
|
35
|
+
|
32
36
|
room.moveCamera = (camera: Camera) => manager.mainView.moveCamera(camera);
|
33
37
|
room.moveCameraToContain = (...args) => manager.moveCameraToContain(...args);
|
34
38
|
room.convertToPointInWorld = (...args) => manager.mainView.convertToPointInWorld(...args);
|
@@ -36,6 +40,32 @@ export const replaceRoomFunction = (room: Room, manager: WindowManager) => {
|
|
36
40
|
room.scenePreview = (...args) => manager.mainView.scenePreview(...args);
|
37
41
|
room.fillSceneSnapshot = (...args) => manager.mainView.fillSceneSnapshot(...args);
|
38
42
|
room.generateScreenshot = (...args) => manager.mainView.generateScreenshot(...args);
|
43
|
+
room.setMemberState = (...args) => manager.mainView.setMemberState(...args);
|
44
|
+
room.redo = () => manager.redo();
|
45
|
+
room.undo = () => manager.undo();
|
46
|
+
room.cleanCurrentScene = () => manager.cleanCurrentScene();
|
47
|
+
delegateRemoveScenes(room);
|
39
48
|
}
|
49
|
+
};
|
40
50
|
|
41
|
-
|
51
|
+
const delegateRemoveScenes = (room: Room) => {
|
52
|
+
const originRemoveScenes = room.removeScenes;
|
53
|
+
room.removeScenes = (scenePath: string) => {
|
54
|
+
const result = originRemoveScenes.call(room, scenePath);
|
55
|
+
emitter.emit("removeScenes", scenePath);
|
56
|
+
return result;
|
57
|
+
};
|
58
|
+
};
|
59
|
+
|
60
|
+
const delegateSeekToProgressTime = (player: Player) => {
|
61
|
+
const originSeek = player.seekToProgressTime;
|
62
|
+
// eslint-disable-next-line no-inner-declarations
|
63
|
+
async function newSeek(time: number): Promise<PlayerSeekingResult> {
|
64
|
+
const seekResult = await originSeek.call(player, time);
|
65
|
+
if (seekResult === "success") {
|
66
|
+
emitter.emit("seek", time);
|
67
|
+
}
|
68
|
+
return seekResult;
|
69
|
+
}
|
70
|
+
player.seekToProgressTime = newSeek;
|
71
|
+
};
|
@@ -1,30 +1,27 @@
|
|
1
|
-
import { AnimationMode, reaction
|
2
|
-
import {
|
3
|
-
import { callbacks, emitter } from "./index";
|
1
|
+
import { AnimationMode, reaction } from "white-web-sdk";
|
2
|
+
import { callbacks, emitter } from "../index";
|
4
3
|
import { createView } from "./ViewManager";
|
5
4
|
import { debounce, isEmpty, isEqual } from "lodash";
|
6
|
-
import { Fields } from "
|
7
|
-
import {
|
5
|
+
import { Fields } from "../AttributesDelegate";
|
6
|
+
import { setViewFocusScenePath } from "../Utils/Common";
|
8
7
|
import { SideEffectManager } from "side-effect-manager";
|
9
8
|
import type { Camera, Size, View } from "white-web-sdk";
|
10
|
-
import type { AppManager } from "
|
9
|
+
import type { AppManager } from "../AppManager";
|
11
10
|
|
12
|
-
export class MainViewProxy
|
11
|
+
export class MainViewProxy {
|
13
12
|
private scale?: number;
|
14
|
-
private cameraStore = this.manager.cameraStore;
|
15
13
|
private started = false;
|
16
14
|
private mainViewIsAddListener = false;
|
17
15
|
private mainView: View;
|
18
|
-
private
|
16
|
+
private store = this.manager.store;
|
19
17
|
|
20
18
|
private sideEffectManager = new SideEffectManager();
|
21
19
|
|
22
|
-
constructor(manager: AppManager) {
|
23
|
-
super(manager);
|
20
|
+
constructor(private manager: AppManager) {
|
24
21
|
this.mainView = this.createMainView();
|
25
22
|
this.moveCameraSizeByAttributes();
|
26
|
-
this.cameraStore.register(this.viewId, this.mainView);
|
27
23
|
emitter.once("mainViewMounted").then(() => {
|
24
|
+
this.addMainViewListener();
|
28
25
|
setTimeout(() => {
|
29
26
|
this.start();
|
30
27
|
if (!this.mainViewCamera || !this.mainViewSize) {
|
@@ -34,7 +31,7 @@ export class MainViewProxy extends Base {
|
|
34
31
|
});
|
35
32
|
const playgroundSizeChangeListener = () => {
|
36
33
|
this.sizeChangeHandler(this.mainViewSize);
|
37
|
-
}
|
34
|
+
};
|
38
35
|
this.sideEffectManager.add(() => {
|
39
36
|
emitter.on("playgroundSizeChange", playgroundSizeChangeListener);
|
40
37
|
return () => emitter.off("playgroundSizeChange", playgroundSizeChangeListener);
|
@@ -63,15 +60,15 @@ export class MainViewProxy extends Base {
|
|
63
60
|
}
|
64
61
|
|
65
62
|
public setCameraAndSize(): void {
|
66
|
-
this.store.setMainViewCamera({ ...this.mainView.camera, id: this.
|
67
|
-
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 });
|
68
65
|
}
|
69
66
|
|
70
67
|
private cameraReaction = () => {
|
71
68
|
return reaction(
|
72
69
|
() => this.mainViewCamera,
|
73
70
|
camera => {
|
74
|
-
if (camera && camera.id !== this.
|
71
|
+
if (camera && camera.id !== this.manager.uid) {
|
75
72
|
this.moveCameraToContian(this.mainViewSize);
|
76
73
|
this.moveCamera(camera);
|
77
74
|
}
|
@@ -103,15 +100,19 @@ export class MainViewProxy extends Base {
|
|
103
100
|
if (mainViewScenePath) {
|
104
101
|
setViewFocusScenePath(mainView, mainViewScenePath);
|
105
102
|
}
|
106
|
-
if (!this.store.focus) {
|
107
|
-
this.switchViewModeToWriter();
|
108
|
-
}
|
109
103
|
return mainView;
|
110
104
|
}
|
111
105
|
|
106
|
+
public onReconnect(): void {
|
107
|
+
const mainViewScenePath = this.store.getMainViewScenePath();
|
108
|
+
if (mainViewScenePath) {
|
109
|
+
setViewFocusScenePath(this.view, mainViewScenePath);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
112
113
|
private onCameraUpdatedByDevice = (camera: Camera) => {
|
113
|
-
this.store.setMainViewCamera({ ...camera, id: this.
|
114
|
-
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 })) {
|
115
116
|
this.setMainViewSize(this.view.size);
|
116
117
|
}
|
117
118
|
};
|
@@ -138,13 +139,12 @@ export class MainViewProxy extends Base {
|
|
138
139
|
|
139
140
|
public async mainViewClickHandler(): Promise<void> {
|
140
141
|
if (!this.manager.canOperate) return;
|
141
|
-
if (this.view.mode === ViewVisionMode.Writable) return;
|
142
142
|
this.store.cleanFocus();
|
143
|
-
this.
|
143
|
+
this.manager.boxManager?.blurAllBox();
|
144
144
|
}
|
145
145
|
|
146
146
|
public setMainViewSize = debounce(size => {
|
147
|
-
this.store.setMainViewSize({ ...size, id: this.
|
147
|
+
this.store.setMainViewSize({ ...size, id: this.manager.uid });
|
148
148
|
}, 50);
|
149
149
|
|
150
150
|
private addCameraListener() {
|
@@ -163,17 +163,6 @@ export class MainViewProxy extends Base {
|
|
163
163
|
callbacks.emit("cameraStateChange", this.cameraState);
|
164
164
|
};
|
165
165
|
|
166
|
-
public switchViewModeToWriter(): void {
|
167
|
-
if (!this.manager.canOperate) return;
|
168
|
-
if (this.view) {
|
169
|
-
if (this.view.mode === ViewVisionMode.Writable) return;
|
170
|
-
this.cameraStore.switchView(this.viewId, this.mainView, () => {
|
171
|
-
notifyMainViewModeChange(callbacks, ViewVisionMode.Writable);
|
172
|
-
setViewMode(this.view, ViewVisionMode.Writable);
|
173
|
-
});
|
174
|
-
}
|
175
|
-
}
|
176
|
-
|
177
166
|
public moveCameraToContian(size: Size): void {
|
178
167
|
if (!isEmpty(size)) {
|
179
168
|
this.view.moveCameraToContain({
|
@@ -202,6 +191,7 @@ export class MainViewProxy extends Base {
|
|
202
191
|
}
|
203
192
|
|
204
193
|
public stop() {
|
194
|
+
this.removeMainViewListener();
|
205
195
|
this.removeCameraListener();
|
206
196
|
this.manager.refresher?.remove(Fields.MainViewCamera);
|
207
197
|
this.manager.refresher?.remove(Fields.MainViewSize);
|
@@ -210,7 +200,6 @@ export class MainViewProxy extends Base {
|
|
210
200
|
|
211
201
|
public destroy() {
|
212
202
|
this.stop();
|
213
|
-
this.cameraStore.unregister(this.viewId, this.mainView);
|
214
203
|
this.sideEffectManager.flushAll();
|
215
204
|
}
|
216
205
|
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import type { View, Displayer } from "white-web-sdk";
|
2
|
+
|
3
|
+
export class ViewManager {
|
4
|
+
public views: Map<string, View> = new Map();
|
5
|
+
|
6
|
+
constructor(private displayer: Displayer) {}
|
7
|
+
|
8
|
+
public createView(id: string): View {
|
9
|
+
const view = createView(this.displayer);
|
10
|
+
this.views.set(id, view);
|
11
|
+
return view;
|
12
|
+
}
|
13
|
+
|
14
|
+
public getView(id: string): View | undefined {
|
15
|
+
return this.views.get(id);
|
16
|
+
}
|
17
|
+
|
18
|
+
public destroyView(id: string): void {
|
19
|
+
const view = this.views.get(id);
|
20
|
+
if (view) {
|
21
|
+
view.release();
|
22
|
+
this.views.delete(id);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
public setViewScenePath(id: string, scenePath: string): void {
|
27
|
+
const view = this.views.get(id);
|
28
|
+
if (view) {
|
29
|
+
view.focusScenePath = scenePath;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
public destroy() {
|
34
|
+
this.views.forEach(view => {
|
35
|
+
view.release();
|
36
|
+
});
|
37
|
+
this.views.clear();
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
export const createView = (displayer: Displayer): View => {
|
42
|
+
const view = displayer.views.createView();
|
43
|
+
setDefaultCameraBound(view);
|
44
|
+
return view;
|
45
|
+
};
|
46
|
+
|
47
|
+
export const setDefaultCameraBound = (view: View) => {
|
48
|
+
view.setCameraBound({
|
49
|
+
maxContentMode: () => 10,
|
50
|
+
minContentMode: () => 0.1,
|
51
|
+
});
|
52
|
+
};
|
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,13 +39,13 @@ export enum CursorState {
|
|
37
39
|
Normal = "normal",
|
38
40
|
}
|
39
41
|
|
40
|
-
export const REQUIRE_VERSION = "2.
|
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;
|
44
46
|
|
45
47
|
export const SET_SCENEPATH_DELAY = 100; // 设置 scenePath 的延迟事件
|
46
48
|
|
47
|
-
export const DEFAULT_COLLECTOR_STYLE = { right: "10px", bottom: "15px", position: "absolute" };
|
48
|
-
|
49
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>
|