@netless/window-manager 0.4.30-canary.0 → 0.4.31
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 +11 -2
- package/dist/AppManager.d.ts +5 -1
- package/dist/BoxEmitter.d.ts +34 -0
- package/dist/BoxManager.d.ts +3 -1
- package/dist/InternalEmitter.d.ts +0 -18
- package/dist/Utils/AppCreateQueue.d.ts +2 -3
- package/dist/constants.d.ts +1 -0
- package/dist/index.cjs.js +12 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +70 -58
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +12 -12
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -2
- package/pnpm-lock.yaml +66 -36
- package/src/App/AppProxy.ts +7 -1
- package/src/AppManager.ts +67 -59
- package/src/BoxEmitter.ts +19 -0
- package/src/BoxManager.ts +10 -6
- package/src/InternalEmitter.ts +0 -4
- package/src/ReconnectRefresher.ts +18 -4
- package/src/Utils/AppCreateQueue.ts +2 -3
- package/src/constants.ts +1 -0
- package/src/index.ts +3 -2
- package/dist/ScenePath/index.d.ts +0 -12
- package/src/ScenePath/index.ts +0 -47
@@ -3,6 +3,7 @@ import { log } from "./Utils/log";
|
|
3
3
|
import { RoomPhase } from "white-web-sdk";
|
4
4
|
import type { Room } from "white-web-sdk";
|
5
5
|
import type { EmitterType } from "./InternalEmitter";
|
6
|
+
import { EnsureReconnectEvent } from "./constants";
|
6
7
|
|
7
8
|
export type ReconnectRefresherContext = {
|
8
9
|
emitter: EmitterType;
|
@@ -20,8 +21,20 @@ export class ReconnectRefresher {
|
|
20
21
|
public setRoom(room: Room | undefined) {
|
21
22
|
this.room = room;
|
22
23
|
this.phase = room?.phase;
|
23
|
-
room
|
24
|
-
|
24
|
+
if (room) {
|
25
|
+
room.callbacks.off("onPhaseChanged", this.onPhaseChanged);
|
26
|
+
room.callbacks.on("onPhaseChanged", this.onPhaseChanged);
|
27
|
+
// 重连成功之后向服务发送一次消息, 确认当前的状态是最新的
|
28
|
+
room.addMagixEventListener(
|
29
|
+
EnsureReconnectEvent,
|
30
|
+
payload => {
|
31
|
+
if (payload.authorId === room.observerId) {
|
32
|
+
this.onReconnected();
|
33
|
+
}
|
34
|
+
},
|
35
|
+
{ fireSelfEventAfterCommit: true }
|
36
|
+
);
|
37
|
+
}
|
25
38
|
}
|
26
39
|
|
27
40
|
public setContext(ctx: ReconnectRefresherContext) {
|
@@ -33,7 +46,7 @@ export class ReconnectRefresher {
|
|
33
46
|
this.ctx.emitter.emit("startReconnect");
|
34
47
|
}
|
35
48
|
if (phase === RoomPhase.Connected && this.phase === RoomPhase.Reconnecting) {
|
36
|
-
this.
|
49
|
+
this.room?.dispatchMagixEvent(EnsureReconnectEvent, {});
|
37
50
|
}
|
38
51
|
this.phase = phase;
|
39
52
|
};
|
@@ -51,7 +64,7 @@ export class ReconnectRefresher {
|
|
51
64
|
}
|
52
65
|
});
|
53
66
|
this.ctx.emitter.emit("onReconnected");
|
54
|
-
}
|
67
|
+
};
|
55
68
|
|
56
69
|
private releaseDisposers() {
|
57
70
|
this.disposers.forEach(disposer => {
|
@@ -96,6 +109,7 @@ export class ReconnectRefresher {
|
|
96
109
|
|
97
110
|
public destroy() {
|
98
111
|
this.room?.callbacks.off("onPhaseChanged", this.onPhaseChanged);
|
112
|
+
this.room?.removeMagixEventListener(EnsureReconnectEvent, this.onReconnected);
|
99
113
|
this.releaseDisposers();
|
100
114
|
}
|
101
115
|
}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import { callbacks } from "../callback";
|
2
2
|
import { SETUP_APP_DELAY } from "../constants";
|
3
|
-
import type { AppProxy } from "../App";
|
4
3
|
|
5
|
-
export type Invoker = () => Promise<
|
4
|
+
export type Invoker<T = any> = () => Promise<T | undefined>;
|
6
5
|
|
7
6
|
export class AppCreateQueue {
|
8
7
|
private list: Invoker[] = [];
|
@@ -16,7 +15,7 @@ export class AppCreateQueue {
|
|
16
15
|
}, 50);
|
17
16
|
}
|
18
17
|
|
19
|
-
public push(item: Invoker) {
|
18
|
+
public push<T>(item: Invoker<T>) {
|
20
19
|
this.list.push(item);
|
21
20
|
this.invoke();
|
22
21
|
if (this.timer === undefined && this.list.length > 0) {
|
package/src/constants.ts
CHANGED
package/src/index.ts
CHANGED
@@ -60,6 +60,7 @@ import type { AppProxy } from "./App";
|
|
60
60
|
import type { PublicEvent } from "./callback";
|
61
61
|
import type Emittery from "emittery";
|
62
62
|
import type { PageController, AddPageParams, PageState } from "./Page";
|
63
|
+
import { boxEmitter } from "./BoxEmitter";
|
63
64
|
|
64
65
|
export type WindowMangerAttributes = {
|
65
66
|
modelValue?: string;
|
@@ -320,7 +321,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
320
321
|
}
|
321
322
|
|
322
323
|
public bindContainer(container: HTMLElement) {
|
323
|
-
if (this.room.phase !== RoomPhase.Connected) {
|
324
|
+
if (isRoom(this.displayer) && this.room.phase !== RoomPhase.Connected) {
|
324
325
|
throw new BindContainerRoomPhaseInvalidError();
|
325
326
|
}
|
326
327
|
if (WindowManager.isCreated && WindowManager.container) {
|
@@ -339,7 +340,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> imple
|
|
339
340
|
if (this.boxManager) {
|
340
341
|
this.boxManager.destroy();
|
341
342
|
}
|
342
|
-
const boxManager = createBoxManager(this, callbacks, emitter, {
|
343
|
+
const boxManager = createBoxManager(this, callbacks, emitter, boxEmitter, {
|
343
344
|
collectorContainer: params.collectorContainer,
|
344
345
|
collectorStyles: params.collectorStyles,
|
345
346
|
prefersColorScheme: params.prefersColorScheme,
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import type { ScenesCallbacks, ScenesCallbacksNode } from "white-web-sdk";
|
2
|
-
import type { AppManager } from "../AppManager";
|
3
|
-
export declare class ScenesCallbackManager {
|
4
|
-
private manager;
|
5
|
-
private nodes;
|
6
|
-
constructor(manager: AppManager);
|
7
|
-
createNode(path: string, callbacks?: Partial<ScenesCallbacks>): ScenesCallbacksNode | null;
|
8
|
-
getScenes(path: string): readonly string[] | undefined;
|
9
|
-
getScenesOnce(path: string): readonly string[] | undefined;
|
10
|
-
removeNode(path: string): void;
|
11
|
-
destroy(): void;
|
12
|
-
}
|
package/src/ScenePath/index.ts
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
import type { ScenesCallbacks, ScenesCallbacksNode } from "white-web-sdk";
|
2
|
-
import type { AppManager } from "../AppManager";
|
3
|
-
|
4
|
-
export class ScenesCallbackManager {
|
5
|
-
|
6
|
-
private nodes: Map<string, ScenesCallbacksNode> = new Map();
|
7
|
-
|
8
|
-
constructor(private manager: AppManager) {}
|
9
|
-
|
10
|
-
public createNode(path: string, callbacks?: Partial<ScenesCallbacks>): ScenesCallbacksNode | null {
|
11
|
-
const node = this.manager.displayer.createScenesCallback(path, callbacks);
|
12
|
-
if (node) {
|
13
|
-
this.nodes.set(path, node);
|
14
|
-
}
|
15
|
-
return node;
|
16
|
-
}
|
17
|
-
|
18
|
-
public getScenes(path: string) {
|
19
|
-
const node = this.nodes.get(path);
|
20
|
-
return node?.scenes;
|
21
|
-
}
|
22
|
-
|
23
|
-
public getScenesOnce(path: string) {
|
24
|
-
let node = this.nodes.get(path);
|
25
|
-
if (!node) {
|
26
|
-
const created = this.createNode(path);
|
27
|
-
if (created) {
|
28
|
-
node = created;
|
29
|
-
}
|
30
|
-
}
|
31
|
-
const scenes = node?.scenes;
|
32
|
-
this.removeNode(path);
|
33
|
-
return scenes;
|
34
|
-
}
|
35
|
-
|
36
|
-
public removeNode(path: string) {
|
37
|
-
const node = this.nodes.get(path);
|
38
|
-
if (node) {
|
39
|
-
node.dispose();
|
40
|
-
this.nodes.delete(path);
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
public destroy(): void {
|
45
|
-
this.nodes.forEach(node => node.dispose());
|
46
|
-
}
|
47
|
-
}
|