floating-live 0.17.0-alpha.3 → 0.17.0-alpha.4
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/FloatingLive.d.ts +2 -2
- package/dist/FloatingLive.js +2 -0
- package/dist/app.d.ts +5 -5
- package/dist/app.js +7 -3
- package/dist/command/manager.js +5 -4
- package/dist/error/index.d.ts +24 -1
- package/dist/error/index.js +19 -1
- package/dist/event/manager.js +3 -4
- package/dist/hook/manager.js +6 -5
- package/dist/live/room.d.ts +35 -23
- package/dist/live/room.js +78 -52
- package/dist/plugin/context/CommonPluginContext.d.ts +4 -5
- package/dist/plugin/context/CommonPluginContext.js +76 -199
- package/dist/plugin/context/SafePluginContext.js +16 -29
- package/dist/plugin/index.d.ts +0 -3
- package/dist/plugin/index.js +2 -3
- package/dist/plugin/manager.d.ts +3 -18
- package/dist/plugin/manager.js +20 -17
- package/dist/plugin/types.d.ts +15 -6
- package/dist/plugins/platform/index.js +5 -8
- package/dist/plugins/room/index.d.ts +45 -13
- package/dist/plugins/room/index.js +159 -47
- package/dist/value/manager.js +4 -3
- package/package.json +7 -3
package/dist/FloatingLive.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare class FloatingLive extends App {
|
|
|
11
11
|
/** 移除房间 */
|
|
12
12
|
remove(key: string): void;
|
|
13
13
|
/** 获取房间 */
|
|
14
|
-
get(key: string): LiveRoom | undefined;
|
|
14
|
+
get(key: string): LiveRoom | import("./live/index.js").InvalidLiveRoom | undefined;
|
|
15
15
|
has(key: string): boolean;
|
|
16
16
|
/** 获取房间信息 */
|
|
17
17
|
data(key: string): import("./live/index.js").LiveRoomData | undefined;
|
|
@@ -22,5 +22,5 @@ export declare class FloatingLive extends App {
|
|
|
22
22
|
/** 关闭房间连接 */
|
|
23
23
|
close(key: string): void;
|
|
24
24
|
/** 获取房间列表 */
|
|
25
|
-
getList(): LiveRoom[];
|
|
25
|
+
getList(): (LiveRoom | import("./live/index.js").InvalidLiveRoom)[];
|
|
26
26
|
}
|
package/dist/FloatingLive.js
CHANGED
|
@@ -2,6 +2,8 @@ import { App } from "./app.js";
|
|
|
2
2
|
import { Room } from "./plugins/room/index.js";
|
|
3
3
|
import { Platform } from "./plugins/platform/index.js";
|
|
4
4
|
export class FloatingLive extends App {
|
|
5
|
+
room;
|
|
6
|
+
platform;
|
|
5
7
|
constructor() {
|
|
6
8
|
super();
|
|
7
9
|
this.room = this.registerSync(Room, {}, { unremovable: true, accessApp: true, pluginType: "core" });
|
package/dist/app.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CommandOptions, CommandCallOptions, AppCommandMap, CommandFunction } from "./command/index.js";
|
|
2
2
|
import { CommandManager } from "./command/manager.js";
|
|
3
|
-
import {
|
|
3
|
+
import { AppErrorLegacy } from "./error/index.js";
|
|
4
4
|
import { AppEventDetailMap, AppEventEmitOptions, AppEventListener } from "./event/index.js";
|
|
5
5
|
import { AppHookMap, HookCallOptions, HookContext, HookFunction, HookUseOptions } from "./hook/index.js";
|
|
6
6
|
import { HookManager } from "./hook/manager.js";
|
|
7
|
-
import { PluginConstructor, PluginContext, PluginInitOptions, PluginItem, PluginRegisterOptions } from "./plugin/index.js";
|
|
8
|
-
import { PluginManager
|
|
7
|
+
import { PluginConstructor, PluginContext, PluginInitOptions, PluginItem, PluginRegisterOptions, WhenRegisterCallback } from "./plugin/index.js";
|
|
8
|
+
import { PluginManager } from "./plugin/manager.js";
|
|
9
9
|
import { CustomEventEmitter } from "./utils/EventEmitter.js";
|
|
10
10
|
import { AppValueMap, ValueOptions } from "./value/index.js";
|
|
11
11
|
import { ValueManager } from "./value/manager.js";
|
|
@@ -21,8 +21,8 @@ export declare class App extends CustomEventEmitter implements PluginContext {
|
|
|
21
21
|
off<K extends keyof AppEventDetailMap>(type: K, listener: AppEventListener<AppEventDetailMap[K]>): void;
|
|
22
22
|
emit<K extends keyof AppEventDetailMap>(type: K, detail: AppEventDetailMap[K], options?: AppEventEmitOptions & EventInit): void;
|
|
23
23
|
/** 发送错误 */
|
|
24
|
-
throw(err?: Error):
|
|
25
|
-
error(id: string, detail?: Record<string, any>):
|
|
24
|
+
throw(err?: Error): never;
|
|
25
|
+
error(id: string, detail?: Record<string, any>): AppErrorLegacy;
|
|
26
26
|
/** 注册插件 */
|
|
27
27
|
register<P extends PluginItem>(plugin: PluginConstructor<P>, options?: PluginInitOptions, registerOptions?: PluginRegisterOptions): Promise<P>;
|
|
28
28
|
/** 同步注册插件 */
|
package/dist/app.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { CommandManager } from "./command/manager.js";
|
|
2
|
-
import {
|
|
2
|
+
import { AppErrorLegacy } from "./error/index.js";
|
|
3
3
|
import { HookManager } from "./hook/manager.js";
|
|
4
4
|
import { PluginManager } from "./plugin/manager.js";
|
|
5
5
|
import { CustomEventEmitter } from "./utils/EventEmitter.js";
|
|
6
6
|
import { ValueManager } from "./value/manager.js";
|
|
7
7
|
export class App extends CustomEventEmitter {
|
|
8
|
+
hookManager;
|
|
9
|
+
pluginManager;
|
|
10
|
+
commandManager;
|
|
11
|
+
valueManager;
|
|
12
|
+
abortController = new AbortController();
|
|
8
13
|
constructor() {
|
|
9
14
|
super();
|
|
10
|
-
this.abortController = new AbortController();
|
|
11
15
|
this.commandManager = new CommandManager(this);
|
|
12
16
|
this.hookManager = new HookManager(this);
|
|
13
17
|
this.valueManager = new ValueManager(this);
|
|
@@ -37,7 +41,7 @@ export class App extends CustomEventEmitter {
|
|
|
37
41
|
throw err;
|
|
38
42
|
}
|
|
39
43
|
error(id, detail) {
|
|
40
|
-
return new
|
|
44
|
+
return new AppErrorLegacy(id, detail || {});
|
|
41
45
|
}
|
|
42
46
|
//--- 插件机制 ---//
|
|
43
47
|
/** 注册插件 */
|
package/dist/command/manager.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppErrorLegacy } from "../error/index.js";
|
|
2
2
|
export class CommandManager {
|
|
3
|
+
/** 功能列表 */
|
|
4
|
+
list = new Map();
|
|
5
|
+
app;
|
|
3
6
|
constructor(app) {
|
|
4
|
-
/** 功能列表 */
|
|
5
|
-
this.list = new Map();
|
|
6
7
|
this.app = app;
|
|
7
8
|
}
|
|
8
9
|
/** 注册命令 */
|
|
@@ -24,7 +25,7 @@ export class CommandManager {
|
|
|
24
25
|
callWithOptions(name, options, ...args) {
|
|
25
26
|
const command = this.list.get(name);
|
|
26
27
|
if (!command) {
|
|
27
|
-
throw new
|
|
28
|
+
throw new AppErrorLegacy("command:call_unexist", {
|
|
28
29
|
message: `命令不存在: ${name}`,
|
|
29
30
|
target: `command/${name}`,
|
|
30
31
|
});
|
package/dist/error/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ErrorOptions } from "./types.js";
|
|
2
2
|
export * from "./types.js";
|
|
3
|
-
|
|
3
|
+
/** @deprecated 应使用 appError 函数代替 */
|
|
4
|
+
export declare class AppErrorLegacy extends Error {
|
|
4
5
|
/** 错误id */
|
|
5
6
|
id: string;
|
|
6
7
|
/** 错误来源 */
|
|
@@ -11,3 +12,25 @@ export declare class AppError extends Error {
|
|
|
11
12
|
cause?: Error | string;
|
|
12
13
|
constructor(id: string, options: ErrorOptions);
|
|
13
14
|
}
|
|
15
|
+
export interface AppError extends Error {
|
|
16
|
+
/** 错误发生信息 */
|
|
17
|
+
cause: {
|
|
18
|
+
/** 错误id */
|
|
19
|
+
id: string;
|
|
20
|
+
/** 错误目标对象 */
|
|
21
|
+
target?: string;
|
|
22
|
+
/** 错误原因 */
|
|
23
|
+
reason?: string | Error | AppError;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface AppErrorOptions {
|
|
27
|
+
/** 错误消息 */
|
|
28
|
+
message: string;
|
|
29
|
+
/** 错误目标对象 */
|
|
30
|
+
target?: string;
|
|
31
|
+
/** 错误原因 */
|
|
32
|
+
reason?: string | Error | AppError;
|
|
33
|
+
/** 错误构造函数 */
|
|
34
|
+
errorConstructor?: ErrorConstructor;
|
|
35
|
+
}
|
|
36
|
+
export declare function appError(id: string, { message, target, reason, errorConstructor }: AppErrorOptions): Error;
|
package/dist/error/index.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
export * from "./types.js";
|
|
2
|
-
|
|
2
|
+
/** @deprecated 应使用 appError 函数代替 */
|
|
3
|
+
export class AppErrorLegacy extends Error {
|
|
4
|
+
/** 错误id */
|
|
5
|
+
id;
|
|
6
|
+
/** 错误来源 */
|
|
7
|
+
source;
|
|
8
|
+
/** 错误目标 */
|
|
9
|
+
target;
|
|
10
|
+
/** 错误原因 */
|
|
11
|
+
cause;
|
|
3
12
|
constructor(id, options) {
|
|
4
13
|
super(options.message);
|
|
5
14
|
this.id = id;
|
|
@@ -8,3 +17,12 @@ export class AppError extends Error {
|
|
|
8
17
|
this.target = options?.target;
|
|
9
18
|
}
|
|
10
19
|
}
|
|
20
|
+
export function appError(id, { message, target, reason, errorConstructor = Error }) {
|
|
21
|
+
return new errorConstructor(message, {
|
|
22
|
+
cause: {
|
|
23
|
+
id,
|
|
24
|
+
target,
|
|
25
|
+
reason,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
package/dist/event/manager.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export class EventManager {
|
|
2
|
-
constructor(app) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
2
|
+
constructor(app) { }
|
|
3
|
+
registerMap = new Map();
|
|
4
|
+
generalRegisterSet = new Set();
|
|
6
5
|
register(eventName, pluginName) {
|
|
7
6
|
if (this.registerMap.has(eventName))
|
|
8
7
|
throw new Error("事件名已注册");
|
package/dist/hook/manager.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppErrorLegacy } from "../error/index.js";
|
|
2
2
|
export class HookManager {
|
|
3
|
+
list = new Map();
|
|
4
|
+
pluginMap = new Map();
|
|
5
|
+
app;
|
|
3
6
|
constructor(app) {
|
|
4
|
-
this.list = new Map();
|
|
5
|
-
this.pluginMap = new Map();
|
|
6
7
|
this.app = app;
|
|
7
8
|
app.registerCommand("hook.snapshot", () => this.toSnapshot());
|
|
8
9
|
}
|
|
@@ -15,7 +16,7 @@ export class HookManager {
|
|
|
15
16
|
this.list.set(name, hooks);
|
|
16
17
|
}
|
|
17
18
|
else if (hooks.includes(call)) {
|
|
18
|
-
throw new
|
|
19
|
+
throw new AppErrorLegacy("hook:use_duplicate", {
|
|
19
20
|
message: `钩子函数挂载失败: ${name}`,
|
|
20
21
|
cause: "重复挂载同一函数",
|
|
21
22
|
target: `hook/${name}`,
|
|
@@ -28,7 +29,7 @@ export class HookManager {
|
|
|
28
29
|
let hooks = this.list.get(name);
|
|
29
30
|
const index = hooks?.findIndex((item) => item.call == call) ?? -1;
|
|
30
31
|
if (!hooks || index < 0)
|
|
31
|
-
throw new
|
|
32
|
+
throw new AppErrorLegacy("hook:unuse_unexist", {
|
|
32
33
|
message: `钩子函数卸载失败: ${name}`,
|
|
33
34
|
cause: "卸载不存在的钩子函数",
|
|
34
35
|
target: `hook/${name}`,
|
package/dist/live/room.d.ts
CHANGED
|
@@ -5,9 +5,12 @@ import { UserInfo } from "./messageInfo.js";
|
|
|
5
5
|
/** 直播间信息流监听类 */
|
|
6
6
|
export declare abstract class LiveRoom extends CustomEventEmitter implements LiveRoomData {
|
|
7
7
|
constructor();
|
|
8
|
-
get valid():
|
|
8
|
+
get valid(): true;
|
|
9
|
+
get serviceId(): string;
|
|
9
10
|
/** 平台 */
|
|
10
11
|
abstract readonly platform: string;
|
|
12
|
+
/** api服务 */
|
|
13
|
+
abstract readonly service: string;
|
|
11
14
|
/** 房间id */
|
|
12
15
|
abstract readonly id: string | number;
|
|
13
16
|
/** 房间详情 */
|
|
@@ -40,10 +43,12 @@ export declare abstract class LiveRoom extends CustomEventEmitter implements Liv
|
|
|
40
43
|
abstract fetchData?(): Promise<LiveRoomData>;
|
|
41
44
|
/** 设置房间数据 */
|
|
42
45
|
abstract setData?(data: LiveRoomData): LiveRoomData;
|
|
43
|
-
/**
|
|
46
|
+
/** 销毁钩子 */
|
|
47
|
+
protected abstract onDestroy?(): void;
|
|
48
|
+
/** 销毁
|
|
49
|
+
* @internal 请勿在继承 LiveRoom 的子类中声明该方法,应使用 onDestroy 钩子
|
|
50
|
+
*/
|
|
44
51
|
destroy(): void;
|
|
45
|
-
/** 销毁事件 */
|
|
46
|
-
protected onDestroy?: () => void;
|
|
47
52
|
/** 发送消息 */
|
|
48
53
|
protected emitMessage(msg: LiveMessage.All): void;
|
|
49
54
|
/** 发送源消息 */
|
|
@@ -52,6 +57,28 @@ export declare abstract class LiveRoom extends CustomEventEmitter implements Liv
|
|
|
52
57
|
toData(): LiveRoomData;
|
|
53
58
|
get key(): string;
|
|
54
59
|
}
|
|
60
|
+
/** 无效房间 */
|
|
61
|
+
export declare class InvalidLiveRoom implements LiveRoomData {
|
|
62
|
+
get valid(): false;
|
|
63
|
+
get serviceId(): string;
|
|
64
|
+
constructor(serviceId: string, id: string | number);
|
|
65
|
+
readonly platform: string;
|
|
66
|
+
readonly id: string | number;
|
|
67
|
+
readonly service: string;
|
|
68
|
+
detail: LiveRoomDetailInfo;
|
|
69
|
+
stats?: LiveRoomStatsInfo;
|
|
70
|
+
anchor: UserInfo;
|
|
71
|
+
status: LiveRoomStatus;
|
|
72
|
+
timestamp: number;
|
|
73
|
+
connectionStatus: LiveConnectionStatus;
|
|
74
|
+
openStatus: LiveRoomOpenStatus;
|
|
75
|
+
liveId?: string;
|
|
76
|
+
get opened(): boolean;
|
|
77
|
+
available: boolean;
|
|
78
|
+
/** 生成房间数据 */
|
|
79
|
+
toData(): LiveRoomData;
|
|
80
|
+
get key(): string;
|
|
81
|
+
}
|
|
55
82
|
export interface LiveRoom {
|
|
56
83
|
on<K extends keyof LiveRoomEventMap>(type: K, listener: (e: LiveRoomEventMap[K]) => void, signal?: AbortSignal): void;
|
|
57
84
|
once<K extends keyof LiveRoomEventMap>(type: K, listener: (e: LiveRoomEventMap[K]) => void, signal?: AbortSignal): void;
|
|
@@ -65,8 +92,12 @@ export interface LiveRoomData {
|
|
|
65
92
|
valid: boolean;
|
|
66
93
|
/** 平台id */
|
|
67
94
|
platform: string;
|
|
95
|
+
/** API服务 */
|
|
96
|
+
service: string;
|
|
68
97
|
/** 房间id */
|
|
69
98
|
id: number | string;
|
|
99
|
+
/** API服务id */
|
|
100
|
+
serviceId: string;
|
|
70
101
|
/** 房间key */
|
|
71
102
|
key: string;
|
|
72
103
|
/** 基本信息 */
|
|
@@ -196,22 +227,3 @@ export interface LiveRoomEventMap {
|
|
|
196
227
|
/** 关闭直播间连接 */
|
|
197
228
|
close: {};
|
|
198
229
|
}
|
|
199
|
-
export declare class InvalidLiveRoom implements LiveRoomData {
|
|
200
|
-
get valid(): false;
|
|
201
|
-
constructor(platform: string, id: string | number);
|
|
202
|
-
readonly platform: string;
|
|
203
|
-
readonly id: string | number;
|
|
204
|
-
detail: LiveRoomDetailInfo;
|
|
205
|
-
stats?: LiveRoomStatsInfo;
|
|
206
|
-
anchor: UserInfo;
|
|
207
|
-
status: LiveRoomStatus;
|
|
208
|
-
timestamp: number;
|
|
209
|
-
connectionStatus: LiveConnectionStatus;
|
|
210
|
-
openStatus: LiveRoomOpenStatus;
|
|
211
|
-
liveId?: string;
|
|
212
|
-
get opened(): boolean;
|
|
213
|
-
available: boolean;
|
|
214
|
-
/** 生成房间数据 */
|
|
215
|
-
toData(): LiveRoomData;
|
|
216
|
-
get key(): string;
|
|
217
|
-
}
|
package/dist/live/room.js
CHANGED
|
@@ -3,25 +3,36 @@ import { CustomEventEmitter } from "../utils/EventEmitter.js";
|
|
|
3
3
|
export class LiveRoom extends CustomEventEmitter {
|
|
4
4
|
constructor() {
|
|
5
5
|
super();
|
|
6
|
-
/** 直播状态 */
|
|
7
|
-
this.status = LiveRoomStatus.off;
|
|
8
|
-
/** 时间戳 */
|
|
9
|
-
this.timestamp = 0;
|
|
10
|
-
/** 房间连接状态 */
|
|
11
|
-
this.connectionStatus = LiveConnectionStatus.off;
|
|
12
|
-
/** 房间开启状态 */
|
|
13
|
-
this.openStatus = 0;
|
|
14
|
-
this.available = false;
|
|
15
6
|
}
|
|
16
7
|
get valid() {
|
|
17
8
|
return true;
|
|
18
9
|
}
|
|
10
|
+
get serviceId() {
|
|
11
|
+
return this.service ? `${this.platform}.${this.service}` : this.platform;
|
|
12
|
+
}
|
|
13
|
+
/** 统计信息 */
|
|
14
|
+
stats;
|
|
15
|
+
/** 直播状态 */
|
|
16
|
+
status = LiveRoomStatus.off;
|
|
17
|
+
/** 时间戳 */
|
|
18
|
+
timestamp = 0;
|
|
19
|
+
/** 当前直播id */
|
|
20
|
+
liveId;
|
|
21
|
+
/** 房间连接状态 */
|
|
22
|
+
connectionStatus = LiveConnectionStatus.off;
|
|
23
|
+
/** 房间开启状态 */
|
|
24
|
+
openStatus = 0;
|
|
19
25
|
get opened() {
|
|
20
26
|
return this.openStatus == 2;
|
|
21
27
|
}
|
|
22
|
-
|
|
28
|
+
available = false;
|
|
29
|
+
/** 销毁
|
|
30
|
+
* @internal 请勿在继承 LiveRoom 的子类中声明该方法,应使用 onDestroy 钩子
|
|
31
|
+
*/
|
|
23
32
|
destroy() {
|
|
33
|
+
// 关闭房间
|
|
24
34
|
this.close();
|
|
35
|
+
// 调用 onDestory 钩子
|
|
25
36
|
this.onDestroy?.();
|
|
26
37
|
}
|
|
27
38
|
/** 发送消息 */
|
|
@@ -69,6 +80,61 @@ export class LiveRoom extends CustomEventEmitter {
|
|
|
69
80
|
return {
|
|
70
81
|
valid: this.valid,
|
|
71
82
|
platform: this.platform,
|
|
83
|
+
service: this.service,
|
|
84
|
+
id: this.id,
|
|
85
|
+
detail: this.detail,
|
|
86
|
+
stats: this.stats,
|
|
87
|
+
anchor: this.anchor,
|
|
88
|
+
timestamp: this.timestamp,
|
|
89
|
+
status: this.status,
|
|
90
|
+
liveId: this.liveId,
|
|
91
|
+
openStatus: this.openStatus,
|
|
92
|
+
opened: this.opened,
|
|
93
|
+
available: this.available,
|
|
94
|
+
connectionStatus: this.connectionStatus,
|
|
95
|
+
key: this.key,
|
|
96
|
+
serviceId: this.serviceId,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
get key() {
|
|
100
|
+
return `${this.serviceId}:${this.id}`;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** 无效房间 */
|
|
104
|
+
export class InvalidLiveRoom {
|
|
105
|
+
get valid() {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
get serviceId() {
|
|
109
|
+
return this.service ? `${this.platform}.${this.service}` : this.platform;
|
|
110
|
+
}
|
|
111
|
+
constructor(serviceId, id) {
|
|
112
|
+
const [platform, ...serviceIdArr] = serviceId.split(".");
|
|
113
|
+
this.platform = platform;
|
|
114
|
+
this.id = id;
|
|
115
|
+
this.service = serviceIdArr.join(".");
|
|
116
|
+
}
|
|
117
|
+
platform;
|
|
118
|
+
id;
|
|
119
|
+
service;
|
|
120
|
+
detail = {};
|
|
121
|
+
stats;
|
|
122
|
+
anchor = { name: "", id: 0 };
|
|
123
|
+
status = LiveRoomStatus.off;
|
|
124
|
+
timestamp = 0;
|
|
125
|
+
connectionStatus = LiveConnectionStatus.off;
|
|
126
|
+
openStatus = 0;
|
|
127
|
+
liveId;
|
|
128
|
+
get opened() {
|
|
129
|
+
return this.openStatus == 2;
|
|
130
|
+
}
|
|
131
|
+
available = false;
|
|
132
|
+
/** 生成房间数据 */
|
|
133
|
+
toData() {
|
|
134
|
+
return {
|
|
135
|
+
valid: this.valid,
|
|
136
|
+
platform: this.platform,
|
|
137
|
+
service: this.service,
|
|
72
138
|
id: this.id,
|
|
73
139
|
detail: this.detail,
|
|
74
140
|
stats: this.stats,
|
|
@@ -80,11 +146,12 @@ export class LiveRoom extends CustomEventEmitter {
|
|
|
80
146
|
opened: this.opened,
|
|
81
147
|
available: this.available,
|
|
82
148
|
connectionStatus: this.connectionStatus,
|
|
149
|
+
serviceId: this.serviceId,
|
|
83
150
|
key: this.key,
|
|
84
151
|
};
|
|
85
152
|
}
|
|
86
153
|
get key() {
|
|
87
|
-
return `${this.
|
|
154
|
+
return `${this.serviceId}:${this.id}`;
|
|
88
155
|
}
|
|
89
156
|
}
|
|
90
157
|
/** 直播间状态 */
|
|
@@ -122,44 +189,3 @@ export const LiveRoomOpenStatus = {
|
|
|
122
189
|
/** 已开启 */
|
|
123
190
|
opened: 2,
|
|
124
191
|
};
|
|
125
|
-
export class InvalidLiveRoom {
|
|
126
|
-
get valid() {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
constructor(platform, id) {
|
|
130
|
-
this.detail = {};
|
|
131
|
-
this.anchor = { name: "", id: 0 };
|
|
132
|
-
this.status = LiveRoomStatus.off;
|
|
133
|
-
this.timestamp = 0;
|
|
134
|
-
this.connectionStatus = LiveConnectionStatus.off;
|
|
135
|
-
this.openStatus = 0;
|
|
136
|
-
this.available = false;
|
|
137
|
-
this.platform = platform;
|
|
138
|
-
this.id = id;
|
|
139
|
-
}
|
|
140
|
-
get opened() {
|
|
141
|
-
return this.openStatus == 2;
|
|
142
|
-
}
|
|
143
|
-
/** 生成房间数据 */
|
|
144
|
-
toData() {
|
|
145
|
-
return {
|
|
146
|
-
valid: this.valid,
|
|
147
|
-
platform: this.platform,
|
|
148
|
-
id: this.id,
|
|
149
|
-
detail: this.detail,
|
|
150
|
-
stats: this.stats,
|
|
151
|
-
anchor: this.anchor,
|
|
152
|
-
timestamp: this.timestamp,
|
|
153
|
-
status: this.status,
|
|
154
|
-
liveId: this.liveId,
|
|
155
|
-
openStatus: this.openStatus,
|
|
156
|
-
opened: this.opened,
|
|
157
|
-
available: this.available,
|
|
158
|
-
connectionStatus: this.connectionStatus,
|
|
159
|
-
key: this.key,
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
get key() {
|
|
163
|
-
return `${this.platform}:${this.id}`;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { App } from "../../app.js";
|
|
2
2
|
import type { CommandOptions, CommandCallOptions, CommandFunction, AppCommandMap } from "../../command/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { AppErrorLegacy, ErrorOptions } from "../../error/index.js";
|
|
4
4
|
import { AppEventListener, AppEventEmitOptions, AppEventDetailMap } from "../../event/index.js";
|
|
5
5
|
import { HookUseOptions, HookCallOptions, AppHookMap, HookFunction, HookContext } from "../../hook/index.js";
|
|
6
6
|
import { AppValueMap, ValueContext, ValueOptions } from "../../value/index.js";
|
|
7
|
-
import { WhenRegisterCallback } from "../
|
|
8
|
-
import type { PluginContext, PluginConstructor, PluginInitOptions, AppPluginExposesMap, PluginItem } from "../types.js";
|
|
7
|
+
import type { PluginContext, PluginConstructor, PluginInitOptions, AppPluginExposesMap, PluginItem, WhenRegisterCallback } from "../types.js";
|
|
9
8
|
export declare class CommonPluginContext implements PluginContext {
|
|
10
9
|
#private;
|
|
11
10
|
get safe(): boolean;
|
|
@@ -20,8 +19,8 @@ export declare class CommonPluginContext implements PluginContext {
|
|
|
20
19
|
*
|
|
21
20
|
* 一般用于自身导致的错误,若非插件本身导致的错误,使用throw语句即可
|
|
22
21
|
*/
|
|
23
|
-
throw(err:
|
|
24
|
-
error(id: string, options: ErrorOptions):
|
|
22
|
+
throw(err: AppErrorLegacy): never;
|
|
23
|
+
error(id: string, options: ErrorOptions): AppErrorLegacy;
|
|
25
24
|
register<P extends PluginItem>(plugin: PluginConstructor<P>, options?: PluginInitOptions): Promise<P>;
|
|
26
25
|
unregister(pluginName: string): void;
|
|
27
26
|
getPluginExposes<K extends keyof AppPluginExposesMap>(pluginName: K): AppPluginExposesMap[K];
|