@netless/window-manager 1.0.7-beta.7 → 1.0.7-beta.9
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/index.d.ts +9 -1
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/App/AppContext.ts +1 -0
- package/src/App/AppProxy.ts +1 -0
- package/src/AppManager.ts +22 -4
- package/src/AttributesDelegate.ts +1 -0
- package/src/BoxManager.ts +1 -0
- package/src/Cursor/index.ts +1 -0
- package/src/Utils/extendClass.ts +22 -19
- package/src/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netless/window-manager",
|
|
3
|
-
"version": "1.0.7-beta.
|
|
3
|
+
"version": "1.0.7-beta.9",
|
|
4
4
|
"description": "Multi-window mode for Netless Whiteboard",
|
|
5
5
|
"author": "l1shen <lishen1635@gmail.com> (https://github.com/l1shen)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@juggle/resize-observer": "^3.3.1",
|
|
35
|
-
"@netless/telebox-insider": "0.3.0-beta.
|
|
35
|
+
"@netless/telebox-insider": "0.3.0-beta.14",
|
|
36
36
|
"emittery": "^0.9.2",
|
|
37
37
|
"lodash": "^4.17.21",
|
|
38
38
|
"p-retry": "^4.6.1",
|
package/src/App/AppContext.ts
CHANGED
|
@@ -34,6 +34,7 @@ import { callbacks } from "../callback";
|
|
|
34
34
|
export class AppContext<TAttributes extends {} = any, TMagixEventPayloads = any, TAppOptions = any>
|
|
35
35
|
implements PageController
|
|
36
36
|
{
|
|
37
|
+
static readonly kind = "AppContext";
|
|
37
38
|
public readonly emitter: Emittery<AppEmitterEvent<TAttributes>>;
|
|
38
39
|
public readonly mobxUtils = {
|
|
39
40
|
autorun,
|
package/src/App/AppProxy.ts
CHANGED
|
@@ -38,6 +38,7 @@ import { getExtendClass } from "../Utils/extendClass";
|
|
|
38
38
|
export type AppEmitter = Emittery<AppEmitterEvent>;
|
|
39
39
|
|
|
40
40
|
export class AppProxy implements PageRemoveService {
|
|
41
|
+
static readonly kind = "AppProxy";
|
|
41
42
|
public kind: string;
|
|
42
43
|
public id: string;
|
|
43
44
|
public scenePath?: string;
|
package/src/AppManager.ts
CHANGED
|
@@ -53,6 +53,7 @@ import { getExtendClass } from "./Utils/extendClass";
|
|
|
53
53
|
import type { TeleBoxState } from "@netless/telebox-insider";
|
|
54
54
|
|
|
55
55
|
export class AppManager {
|
|
56
|
+
static readonly kind = "AppManager";
|
|
56
57
|
public displayer: Displayer;
|
|
57
58
|
public viewManager: ViewManager;
|
|
58
59
|
public appProxies: Map<string, AppProxy> = new Map();
|
|
@@ -71,7 +72,9 @@ export class AppManager {
|
|
|
71
72
|
private callbacksNode: ScenesCallbacksNode | null = null;
|
|
72
73
|
private appCreateQueue = new AppCreateQueue();
|
|
73
74
|
|
|
74
|
-
private _focusAppCreatedResolve?: (appProxy
|
|
75
|
+
private _focusAppCreatedResolve?: (appProxy?: AppProxy) => void;
|
|
76
|
+
private _focusAppId: string | undefined;
|
|
77
|
+
private _resolveTimer: number | undefined;
|
|
75
78
|
|
|
76
79
|
private sideEffectManager = new SideEffectManager();
|
|
77
80
|
|
|
@@ -341,9 +344,16 @@ export class AppManager {
|
|
|
341
344
|
|
|
342
345
|
private async onCreated() {
|
|
343
346
|
if (Object.keys(this.attributes.apps).length && this.store.focus) {
|
|
344
|
-
|
|
347
|
+
this._focusAppId = this.store.focus;
|
|
348
|
+
console.log("onCreated===>", this._focusAppId);
|
|
349
|
+
await new Promise<AppProxy | undefined>(resolve => {
|
|
345
350
|
this._focusAppCreatedResolve = resolve;
|
|
351
|
+
this._resolveTimer = setTimeout(() => {
|
|
352
|
+
console.log("onCreated===>3333", this._focusAppId);
|
|
353
|
+
resolve(this.appProxies.get(this._focusAppId || ''));
|
|
354
|
+
}, 500);
|
|
346
355
|
}).then(() => {
|
|
356
|
+
console.log("onCreated===>2222", this._focusAppId);
|
|
347
357
|
this.focusByAttributes(this.attributes.apps);
|
|
348
358
|
});
|
|
349
359
|
}
|
|
@@ -594,7 +604,7 @@ export class AppManager {
|
|
|
594
604
|
if (!appAttributes) {
|
|
595
605
|
throw new Error("appAttributes is undefined");
|
|
596
606
|
}
|
|
597
|
-
|
|
607
|
+
|
|
598
608
|
this.appCreateQueue.push<AppProxy>(async () => {
|
|
599
609
|
this.appStatus.set(id, AppStatus.StartCreate);
|
|
600
610
|
const appProxy = await this.baseInsertApp(
|
|
@@ -611,9 +621,13 @@ export class AppManager {
|
|
|
611
621
|
);
|
|
612
622
|
if (
|
|
613
623
|
appProxy &&
|
|
614
|
-
this.
|
|
624
|
+
this._focusAppId === id &&
|
|
615
625
|
this._focusAppCreatedResolve
|
|
616
626
|
) {
|
|
627
|
+
console.log("onCreated===>4444", this._focusAppId);
|
|
628
|
+
if (this._resolveTimer) {
|
|
629
|
+
clearTimeout(this._resolveTimer);
|
|
630
|
+
}
|
|
617
631
|
this._focusAppCreatedResolve(appProxy);
|
|
618
632
|
}
|
|
619
633
|
return appProxy;
|
|
@@ -940,6 +954,10 @@ export class AppManager {
|
|
|
940
954
|
this.sideEffectManager.flushAll();
|
|
941
955
|
this._prevFocused = undefined;
|
|
942
956
|
this._prevSceneIndex = undefined;
|
|
957
|
+
if (this._resolveTimer) {
|
|
958
|
+
clearTimeout(this._resolveTimer);
|
|
959
|
+
}
|
|
943
960
|
this._focusAppCreatedResolve = undefined;
|
|
961
|
+
this._resolveTimer = undefined;
|
|
944
962
|
}
|
|
945
963
|
}
|
|
@@ -53,6 +53,7 @@ export type ICamera = Camera & { id: string };
|
|
|
53
53
|
export type ISize = Size & { id: string };
|
|
54
54
|
|
|
55
55
|
export class AttributesDelegate {
|
|
56
|
+
static readonly kind = "AttributesDelegate";
|
|
56
57
|
constructor(private context: StoreContext) {}
|
|
57
58
|
|
|
58
59
|
public setContext(context: StoreContext) {
|
package/src/BoxManager.ts
CHANGED
package/src/Cursor/index.ts
CHANGED
|
@@ -26,6 +26,7 @@ export type MoveCursorParams = {
|
|
|
26
26
|
const LocalCursorSideEffectId = "local-cursor";
|
|
27
27
|
|
|
28
28
|
export class CursorManager {
|
|
29
|
+
static readonly kind = "CursorManager";
|
|
29
30
|
public containerRect?: DOMRect;
|
|
30
31
|
public wrapperRect?: DOMRect;
|
|
31
32
|
public cursorInstances: Map<string, Cursor> = new Map();
|
package/src/Utils/extendClass.ts
CHANGED
|
@@ -36,24 +36,27 @@ export function getExtendClass<T extends ExtendClassAble>(
|
|
|
36
36
|
baseClass: T,
|
|
37
37
|
extendClass?: ExtendClass
|
|
38
38
|
): T {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
39
|
+
if (baseClass.kind && extendClass && Object.keys(extendClass).includes(baseClass.kind)) {
|
|
40
|
+
switch (baseClass.kind) {
|
|
41
|
+
case "AppManager":
|
|
42
|
+
return (extendClass?.AppManager || AppManager) as T;
|
|
43
|
+
case "BoxManager":
|
|
44
|
+
return (extendClass?.BoxManager || BoxManager) as T;
|
|
45
|
+
case "AttributesDelegate":
|
|
46
|
+
return (extendClass?.AttributesDelegate || AttributesDelegate) as T;
|
|
47
|
+
case "CursorManager":
|
|
48
|
+
return (extendClass?.CursorManager || CursorManager) as T;
|
|
49
|
+
case "AppProxy":
|
|
50
|
+
return (extendClass?.AppProxy || AppProxy) as T;
|
|
51
|
+
case "AppContext":
|
|
52
|
+
return (extendClass?.AppContext || AppContext) as T;
|
|
53
|
+
case "TeleBoxManager":
|
|
54
|
+
return (extendClass?.TeleBoxManager || TeleBoxManager) as T;
|
|
55
|
+
case "TeleBoxCollector":
|
|
56
|
+
return (extendClass?.TeleBoxCollector || TeleBoxCollector) as T;
|
|
57
|
+
default:
|
|
58
|
+
return baseClass;
|
|
59
|
+
}
|
|
58
60
|
}
|
|
61
|
+
return baseClass;
|
|
59
62
|
}
|
package/src/index.ts
CHANGED
|
@@ -202,7 +202,7 @@ export class WindowManager
|
|
|
202
202
|
extends InvisiblePlugin<WindowMangerAttributes, any>
|
|
203
203
|
implements PageController
|
|
204
204
|
{
|
|
205
|
-
public static kind = "WindowManager";
|
|
205
|
+
public static readonly kind = "WindowManager";
|
|
206
206
|
public static displayer: Displayer;
|
|
207
207
|
public static wrapper?: HTMLElement;
|
|
208
208
|
public static sizer?: HTMLElement;
|