@netless/window-manager 0.4.0-canary.15 → 0.4.0-canary.19
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 +29 -1
- package/dist/AppListener.d.ts +1 -0
- package/dist/AppManager.d.ts +8 -6
- package/dist/AppProxy.d.ts +3 -2
- package/dist/AttributesDelegate.d.ts +2 -2
- package/dist/BoxManager.d.ts +5 -3
- package/dist/BuiltinApps.d.ts +0 -1
- package/dist/Cursor/Cursor.d.ts +8 -11
- package/dist/Cursor/index.d.ts +5 -16
- package/dist/Register/storage.d.ts +5 -1
- package/dist/Utils/Common.d.ts +1 -0
- package/dist/Utils/RoomHacker.d.ts +1 -1
- package/dist/View/MainView.d.ts +4 -3
- package/dist/constants.d.ts +3 -2
- package/dist/index.d.ts +15 -2
- 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/docs/api.md +28 -0
- package/docs/concept.md +5 -0
- package/package.json +5 -5
- package/src/AppContext.ts +1 -4
- package/src/AppListener.ts +14 -6
- package/src/AppManager.ts +62 -33
- package/src/AppProxy.ts +13 -8
- package/src/AttributesDelegate.ts +2 -2
- package/src/BoxManager.ts +33 -19
- package/src/BuiltinApps.ts +0 -1
- package/src/Cursor/Cursor.ts +22 -36
- package/src/Cursor/index.ts +33 -139
- package/src/Register/index.ts +25 -16
- package/src/Register/loader.ts +1 -1
- package/src/Register/storage.ts +6 -1
- package/src/Utils/Common.ts +12 -2
- package/src/Utils/RoomHacker.ts +28 -15
- package/src/View/MainView.ts +17 -12
- package/src/constants.ts +3 -2
- package/src/index.ts +52 -3
- package/src/shim.d.ts +2 -1
- package/src/style.css +1 -1
- 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/constants.ts
CHANGED
@@ -10,7 +10,8 @@ export enum Events {
|
|
10
10
|
SetMainViewScenePath = "SetMainViewScenePath",
|
11
11
|
SetMainViewSceneIndex = "SetMainViewSceneIndex",
|
12
12
|
SwitchViewsToFreedom = "SwitchViewsToFreedom",
|
13
|
-
MoveCameraToContain = "MoveCameraToContain"
|
13
|
+
MoveCameraToContain = "MoveCameraToContain",
|
14
|
+
CursorMove = "CursorMove",
|
14
15
|
}
|
15
16
|
|
16
17
|
export const MagixEventName = "__WindowManger";
|
@@ -37,7 +38,7 @@ export enum CursorState {
|
|
37
38
|
Normal = "normal",
|
38
39
|
}
|
39
40
|
|
40
|
-
export const REQUIRE_VERSION = "2.16.
|
41
|
+
export const REQUIRE_VERSION = "2.16.1";
|
41
42
|
|
42
43
|
export const MIN_WIDTH = 340 / 720;
|
43
44
|
export const MIN_HEIGHT = 340 / 720;
|
package/src/index.ts
CHANGED
@@ -32,7 +32,7 @@ import {
|
|
32
32
|
ParamsInvalidError,
|
33
33
|
WhiteWebSDKInvalidError,
|
34
34
|
} from "./Utils/error";
|
35
|
-
import type { Apps } from "./AttributesDelegate";
|
35
|
+
import type { Apps, Position } from "./AttributesDelegate";
|
36
36
|
import {
|
37
37
|
InvisiblePlugin,
|
38
38
|
isPlayer,
|
@@ -125,6 +125,8 @@ export type AppInitState = {
|
|
125
125
|
zIndex?: number;
|
126
126
|
};
|
127
127
|
|
128
|
+
export type CursorMovePayload = { uid: string; state?: "leave"; position: Position };
|
129
|
+
|
128
130
|
export type EmitterEvent = {
|
129
131
|
onCreated: undefined;
|
130
132
|
InitReplay: AppInitState;
|
@@ -139,6 +141,8 @@ export type EmitterEvent = {
|
|
139
141
|
boxStateChange: string;
|
140
142
|
playgroundSizeChange: DOMRect;
|
141
143
|
onReconnected: void;
|
144
|
+
removeScenes: string;
|
145
|
+
cursorMove: CursorMovePayload;
|
142
146
|
};
|
143
147
|
|
144
148
|
export type EmitterType = Emittery<EmitterEvent>;
|
@@ -187,6 +191,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
187
191
|
private static isCreated = false;
|
188
192
|
|
189
193
|
public version = __APP_VERSION__;
|
194
|
+
public dependencies = __APP_DEPENDENCIES__;
|
190
195
|
|
191
196
|
public appListeners?: AppListeners;
|
192
197
|
|
@@ -205,6 +210,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
205
210
|
constructor(context: InvisiblePluginContext) {
|
206
211
|
super(context);
|
207
212
|
WindowManager.displayer = context.displayer;
|
213
|
+
(window as any).NETLESS_DEPS = __APP_DEPENDENCIES__;
|
208
214
|
}
|
209
215
|
|
210
216
|
public static async mount(params: MountParams): Promise<WindowManager> {
|
@@ -428,6 +434,12 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
428
434
|
const appScenePath = appManager.store.getAppScenePath(appId);
|
429
435
|
if (appScenePath && appScenePath === scenePath) {
|
430
436
|
console.warn(`[WindowManager]: ScenePath ${scenePath} Already opened`);
|
437
|
+
if (this.boxManager) {
|
438
|
+
const topBox = this.boxManager.getTopBox();
|
439
|
+
if (topBox) {
|
440
|
+
this.boxManager.setZIndex(appId, topBox.zIndex + 1, false);
|
441
|
+
}
|
442
|
+
}
|
431
443
|
return;
|
432
444
|
}
|
433
445
|
}
|
@@ -472,7 +484,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
472
484
|
/**
|
473
485
|
* 返回 mainView 的 ScenePath
|
474
486
|
*/
|
475
|
-
public getMainViewScenePath(): string {
|
487
|
+
public getMainViewScenePath(): string | undefined {
|
476
488
|
return this.appManager?.store.getMainViewScenePath();
|
477
489
|
}
|
478
490
|
|
@@ -520,6 +532,35 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
520
532
|
this.viewMode = mode;
|
521
533
|
}
|
522
534
|
|
535
|
+
public setBoxState(boxState: TeleBoxState): void {
|
536
|
+
if (!this.canOperate) return;
|
537
|
+
switch (boxState) {
|
538
|
+
case "normal":
|
539
|
+
this.setMaximized(false);
|
540
|
+
this.setMinimized(false);
|
541
|
+
break;
|
542
|
+
case "maximized":
|
543
|
+
this.setMaximized(true);
|
544
|
+
this.setMinimized(false);
|
545
|
+
break;
|
546
|
+
case "minimized":
|
547
|
+
this.setMinimized(true);
|
548
|
+
break;
|
549
|
+
default:
|
550
|
+
break;
|
551
|
+
}
|
552
|
+
}
|
553
|
+
|
554
|
+
public setMaximized(maximized: boolean): void {
|
555
|
+
if (!this.canOperate) return;
|
556
|
+
this.boxManager?.setMaximized(maximized, false);
|
557
|
+
}
|
558
|
+
|
559
|
+
public setMinimized(minimized: boolean): void {
|
560
|
+
if (!this.canOperate) return;
|
561
|
+
this.boxManager?.setMinimized(minimized, false);
|
562
|
+
}
|
563
|
+
|
523
564
|
public get mainView(): View {
|
524
565
|
if (this.appManager) {
|
525
566
|
return this.appManager.mainViewProxy.view;
|
@@ -583,7 +624,11 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
583
624
|
} else {
|
584
625
|
throw new Error("[WindowManager]: mainViewSceneDir not found");
|
585
626
|
}
|
586
|
-
}
|
627
|
+
}
|
628
|
+
|
629
|
+
public get topApp(): string | undefined {
|
630
|
+
return this.boxManager?.getTopBox()?.id;
|
631
|
+
}
|
587
632
|
|
588
633
|
/**
|
589
634
|
* 查询所有的 App
|
@@ -725,6 +770,10 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
|
|
725
770
|
}
|
726
771
|
}
|
727
772
|
}
|
773
|
+
|
774
|
+
private _removeScenes = (scenePath: string) => {
|
775
|
+
this.room.removeScenes(scenePath);
|
776
|
+
};
|
728
777
|
}
|
729
778
|
|
730
779
|
setupBuiltin();
|
package/src/shim.d.ts
CHANGED
package/src/style.css
CHANGED
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
|
-
}
|