floating-live 0.17.0-alpha.1 → 0.17.0-alpha.10

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/LICENSE CHANGED
@@ -1,9 +1,9 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Minteea
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Minteea
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
9
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,36 +1,36 @@
1
- # Floating Live
2
-
3
- 一个用于处理和保存直播弹幕的 Web 小工具,开箱即用。
4
-
5
- 本体无弹幕获取功能,需要配合[floating-live-plugins](https://github.com/Minteea/floating-live-plugins)中的插件使用。
6
-
7
- 目前插件库支持 bilibili 和 AcFun 的直播弹幕,不同平台的弹幕会转换为同一种格式便于保存。
8
-
9
- 项目仍在开发中,功能尚未完善,目前除了记录保存直播弹幕外暂时没有别的用处啦,敬请期待。
10
-
11
- 注意:当前项目未进入正式版本阶段,程序结构及导出数据结构可能随时改动,**非常不建议用于正式项目中**。
12
-
13
- GUI 版本:[Minteea/floating-live-gui](https://github.com/Minteea/floating-live-gui)
14
-
15
- ## 使用方法
16
-
17
- ### npm 安装
18
-
19
- ```
20
- npm install floating-live
21
- ```
22
-
23
- ```javascript
24
- // 导入FloatingLive本体
25
- import { FloatingLive } from "floating-live";
26
- // 导入bilibili房间生成插件
27
- import bilibili from "@floating-live/bilibili";
28
-
29
- // 创建一个FloatingLive实例
30
- const live = new FloatingLive();
31
- // 注册插件
32
- live.plugin.register(bilibili);
33
-
34
- // 添加房间并自动打开
35
- live.room.add("bilibili", 6, true);
36
- ```
1
+ # Floating Live
2
+
3
+ 一个用于处理和保存直播弹幕的 Web 小工具,开箱即用。
4
+
5
+ 本体无弹幕获取功能,需要配合[floating-live-plugins](https://github.com/Minteea/floating-live-plugins)中的插件使用。
6
+
7
+ 目前插件库支持 bilibili 和 AcFun 的直播弹幕,不同平台的弹幕会转换为同一种格式便于保存。
8
+
9
+ 项目仍在开发中,功能尚未完善,目前除了记录保存直播弹幕外暂时没有别的用处啦,敬请期待。
10
+
11
+ 注意:当前项目未进入正式版本阶段,程序结构及导出数据结构可能随时改动,**非常不建议用于正式项目中**。
12
+
13
+ GUI 版本:[Minteea/floating-live-gui](https://github.com/Minteea/floating-live-gui)
14
+
15
+ ## 使用方法
16
+
17
+ ### npm 安装
18
+
19
+ ```
20
+ npm install floating-live
21
+ ```
22
+
23
+ ```javascript
24
+ // 导入FloatingLive本体
25
+ import { FloatingLive } from "floating-live";
26
+ // 导入bilibili房间生成插件
27
+ import bilibili from "@floating-live/bilibili";
28
+
29
+ // 创建一个FloatingLive实例
30
+ const live = new FloatingLive();
31
+ // 注册插件
32
+ live.plugin.register(bilibili);
33
+
34
+ // 添加房间并自动打开
35
+ live.room.add("bilibili", 6, true);
36
+ ```
@@ -1,17 +1,17 @@
1
1
  import { LiveRoom } from "./index.js";
2
2
  import { App } from "./app.js";
3
- import { Room } from "./plugins/room/index.js";
3
+ import { Room, RoomCreateOptions } from "./plugins/room/index.js";
4
4
  import { Platform } from "./plugins/platform/index.js";
5
5
  export declare class FloatingLive extends App {
6
6
  room: Room;
7
7
  platform: Platform;
8
8
  constructor();
9
9
  /** 添加房间 */
10
- add(platform: string, id: number, options?: boolean | Record<string, any>): Promise<void>;
10
+ add(platform: string, id: number, options?: boolean | RoomCreateOptions): Promise<void>;
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
  }
@@ -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,10 @@
1
1
  import { CommandOptions, CommandCallOptions, AppCommandMap, CommandFunction } from "./command/index.js";
2
2
  import { CommandManager } from "./command/manager.js";
3
- import { AppError } from "./error/index.js";
4
3
  import { AppEventDetailMap, AppEventEmitOptions, AppEventListener } from "./event/index.js";
5
4
  import { AppHookMap, HookCallOptions, HookContext, HookFunction, HookUseOptions } from "./hook/index.js";
6
5
  import { HookManager } from "./hook/manager.js";
7
- import { PluginConstructor, PluginContext, PluginInitOptions, PluginItem, PluginRegisterOptions } from "./plugin/index.js";
8
- import { PluginManager, WhenRegisterCallback } from "./plugin/manager.js";
6
+ import { PluginConstructor, PluginContext, PluginInitOptions, PluginItem, PluginRegisterOptions, WhenRegisterCallback } from "./plugin/index.js";
7
+ import { PluginManager } from "./plugin/manager.js";
9
8
  import { CustomEventEmitter } from "./utils/EventEmitter.js";
10
9
  import { AppValueMap, ValueOptions } from "./value/index.js";
11
10
  import { ValueManager } from "./value/manager.js";
@@ -20,9 +19,6 @@ export declare class App extends CustomEventEmitter implements PluginContext {
20
19
  once<K extends keyof AppEventDetailMap>(type: K, listener: AppEventListener<AppEventDetailMap[K]>, signal?: AbortSignal): void;
21
20
  off<K extends keyof AppEventDetailMap>(type: K, listener: AppEventListener<AppEventDetailMap[K]>): void;
22
21
  emit<K extends keyof AppEventDetailMap>(type: K, detail: AppEventDetailMap[K], options?: AppEventEmitOptions & EventInit): void;
23
- /** 发送错误 */
24
- throw(err?: Error): void;
25
- error(id: string, detail?: Record<string, any>): AppError;
26
22
  /** 注册插件 */
27
23
  register<P extends PluginItem>(plugin: PluginConstructor<P>, options?: PluginInitOptions, registerOptions?: PluginRegisterOptions): Promise<P>;
28
24
  /** 同步注册插件 */
package/dist/app.js CHANGED
@@ -1,13 +1,16 @@
1
1
  import { CommandManager } from "./command/manager.js";
2
- import { AppError } from "./error/index.js";
3
2
  import { HookManager } from "./hook/manager.js";
4
3
  import { PluginManager } from "./plugin/manager.js";
5
4
  import { CustomEventEmitter } from "./utils/EventEmitter.js";
6
5
  import { ValueManager } from "./value/manager.js";
7
6
  export class App extends CustomEventEmitter {
7
+ hookManager;
8
+ pluginManager;
9
+ commandManager;
10
+ valueManager;
11
+ abortController = new AbortController();
8
12
  constructor() {
9
13
  super();
10
- this.abortController = new AbortController();
11
14
  this.commandManager = new CommandManager(this);
12
15
  this.hookManager = new HookManager(this);
13
16
  this.valueManager = new ValueManager(this);
@@ -31,14 +34,6 @@ export class App extends CustomEventEmitter {
31
34
  super.emit(type, { ...detail, source, remote }, options);
32
35
  super.emit("event", { name: type, detail: { ...detail, source, remote } });
33
36
  }
34
- //--- 错误机制 ---//
35
- /** 发送错误 */
36
- throw(err) {
37
- throw err;
38
- }
39
- error(id, detail) {
40
- return new AppError(id, detail || {});
41
- }
42
37
  //--- 插件机制 ---//
43
38
  /** 注册插件 */
44
39
  register(plugin, options, registerOptions) {
@@ -1,8 +1,9 @@
1
- import { AppError } from "../error/index.js";
1
+ import { appError } 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 AppError("command:call_unexist", {
28
+ throw appError("command:call_unexist", {
28
29
  message: `命令不存在: ${name}`,
29
30
  target: `command/${name}`,
30
31
  });
@@ -1,13 +1,24 @@
1
- import { ErrorOptions } from "./types.js";
2
1
  export * from "./types.js";
3
- export declare class AppError extends Error {
4
- /** 错误id */
5
- id: string;
6
- /** 错误来源 */
7
- source?: string;
8
- /** 错误目标 */
2
+ export interface AppError extends Error {
3
+ /** 错误发生信息 */
4
+ cause: {
5
+ /** 错误id */
6
+ id: string;
7
+ /** 错误目标对象 */
8
+ target?: string;
9
+ /** 错误原因 */
10
+ reason?: string | Error | AppError;
11
+ };
12
+ }
13
+ export interface AppErrorOptions {
14
+ /** 错误消息 */
15
+ message: string;
16
+ /** 错误目标对象 */
9
17
  target?: string;
10
18
  /** 错误原因 */
11
- cause?: Error | string;
12
- constructor(id: string, options: ErrorOptions);
19
+ reason?: string | Error | AppError;
20
+ /** 错误构造函数 */
21
+ errorConstructor?: ErrorConstructor;
22
+ [key: string]: unknown;
13
23
  }
24
+ export declare function appError(id: string, { message, target, reason, errorConstructor }: AppErrorOptions): Error;
@@ -1,10 +1,10 @@
1
1
  export * from "./types.js";
2
- export class AppError extends Error {
3
- constructor(id, options) {
4
- super(options.message);
5
- this.id = id;
6
- this.source = options?.source;
7
- this.cause = options?.cause;
8
- this.target = options?.target;
9
- }
2
+ export function appError(id, { message, target, reason, errorConstructor = Error }) {
3
+ return new errorConstructor(message, {
4
+ cause: {
5
+ id,
6
+ target,
7
+ reason,
8
+ },
9
+ });
10
10
  }
@@ -1,8 +1,7 @@
1
1
  export class EventManager {
2
- constructor(app) {
3
- this.registerMap = new Map();
4
- this.generalRegisterSet = new Set();
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("事件名已注册");
@@ -1,3 +1,4 @@
1
+ import { PluginInfo } from "../plugin/index.js";
1
2
  export interface AppEventEmitOptions {
2
3
  /** 事件来源 */
3
4
  source?: string;
@@ -19,11 +20,10 @@ export interface AppEventDetailMap {
19
20
  "command:unregister": {
20
21
  name: string;
21
22
  };
22
- "plugin:register": {
23
- pluginName: string;
24
- };
23
+ "plugin:register": PluginInfo;
25
24
  "plugin:unregister": {
26
25
  pluginName: string;
26
+ role: string;
27
27
  };
28
28
  "value:register": {
29
29
  name: string;
@@ -1,8 +1,9 @@
1
- import { AppError } from "../error/index.js";
1
+ import { appError } 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,9 +16,9 @@ export class HookManager {
15
16
  this.list.set(name, hooks);
16
17
  }
17
18
  else if (hooks.includes(call)) {
18
- throw new AppError("hook:use_duplicate", {
19
+ throw appError("hook:use_duplicate", {
19
20
  message: `钩子函数挂载失败: ${name}`,
20
- cause: "重复挂载同一函数",
21
+ reason: "重复挂载同一函数",
21
22
  target: `hook/${name}`,
22
23
  });
23
24
  }
@@ -28,9 +29,9 @@ 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 AppError("hook:unuse_unexist", {
32
+ throw appError("hook:unuse_unexist", {
32
33
  message: `钩子函数卸载失败: ${name}`,
33
- cause: "卸载不存在的钩子函数",
34
+ reason: "卸载不存在的钩子函数",
34
35
  target: `hook/${name}`,
35
36
  });
36
37
  hooks.splice(index, 1);
@@ -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(): boolean;
8
+ get valid(): true;
9
+ get serviceId(): string;
9
10
  /** 平台 */
10
11
  abstract readonly platform: string;
12
+ /** api服务 */
13
+ 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 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,38 @@ 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
+ /** api服务 */
14
+ service = "";
15
+ /** 统计信息 */
16
+ stats;
17
+ /** 直播状态 */
18
+ status = LiveRoomStatus.off;
19
+ /** 时间戳 */
20
+ timestamp = 0;
21
+ /** 当前直播id */
22
+ liveId;
23
+ /** 房间连接状态 */
24
+ connectionStatus = LiveConnectionStatus.off;
25
+ /** 房间开启状态 */
26
+ openStatus = 0;
19
27
  get opened() {
20
28
  return this.openStatus == 2;
21
29
  }
22
- /** 销毁 */
30
+ available = false;
31
+ /** 销毁
32
+ * @internal 请勿在继承 LiveRoom 的子类中声明该方法,应使用 onDestroy 钩子
33
+ */
23
34
  destroy() {
35
+ // 关闭房间
24
36
  this.close();
37
+ // 调用 onDestory 钩子
25
38
  this.onDestroy?.();
26
39
  }
27
40
  /** 发送消息 */
@@ -69,6 +82,61 @@ export class LiveRoom extends CustomEventEmitter {
69
82
  return {
70
83
  valid: this.valid,
71
84
  platform: this.platform,
85
+ service: this.service,
86
+ id: this.id,
87
+ detail: this.detail,
88
+ stats: this.stats,
89
+ anchor: this.anchor,
90
+ timestamp: this.timestamp,
91
+ status: this.status,
92
+ liveId: this.liveId,
93
+ openStatus: this.openStatus,
94
+ opened: this.opened,
95
+ available: this.available,
96
+ connectionStatus: this.connectionStatus,
97
+ key: this.key,
98
+ serviceId: this.serviceId,
99
+ };
100
+ }
101
+ get key() {
102
+ return `${this.serviceId}:${this.id}`;
103
+ }
104
+ }
105
+ /** 无效房间 */
106
+ export class InvalidLiveRoom {
107
+ get valid() {
108
+ return false;
109
+ }
110
+ get serviceId() {
111
+ return this.service ? `${this.platform}.${this.service}` : this.platform;
112
+ }
113
+ constructor(serviceId, id) {
114
+ const [platform, ...serviceIdArr] = serviceId.split(".");
115
+ this.platform = platform;
116
+ this.id = id;
117
+ this.service = serviceIdArr.join(".");
118
+ }
119
+ platform;
120
+ id;
121
+ service;
122
+ detail = {};
123
+ stats;
124
+ anchor = { name: "", id: 0 };
125
+ status = LiveRoomStatus.off;
126
+ timestamp = 0;
127
+ connectionStatus = LiveConnectionStatus.off;
128
+ openStatus = 0;
129
+ liveId;
130
+ get opened() {
131
+ return this.openStatus == 2;
132
+ }
133
+ available = false;
134
+ /** 生成房间数据 */
135
+ toData() {
136
+ return {
137
+ valid: this.valid,
138
+ platform: this.platform,
139
+ service: this.service,
72
140
  id: this.id,
73
141
  detail: this.detail,
74
142
  stats: this.stats,
@@ -80,11 +148,12 @@ export class LiveRoom extends CustomEventEmitter {
80
148
  opened: this.opened,
81
149
  available: this.available,
82
150
  connectionStatus: this.connectionStatus,
151
+ serviceId: this.serviceId,
83
152
  key: this.key,
84
153
  };
85
154
  }
86
155
  get key() {
87
- return `${this.platform}:${this.id}`;
156
+ return `${this.serviceId}:${this.id}`;
88
157
  }
89
158
  }
90
159
  /** 直播间状态 */
@@ -122,44 +191,3 @@ export const LiveRoomOpenStatus = {
122
191
  /** 已开启 */
123
192
  opened: 2,
124
193
  };
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,9 @@
1
1
  import { App } from "../../app.js";
2
2
  import type { CommandOptions, CommandCallOptions, CommandFunction, AppCommandMap } from "../../command/index.js";
3
- import { AppError, ErrorOptions } from "../../error/index.js";
4
3
  import { AppEventListener, AppEventEmitOptions, AppEventDetailMap } from "../../event/index.js";
5
4
  import { HookUseOptions, HookCallOptions, AppHookMap, HookFunction, HookContext } from "../../hook/index.js";
6
5
  import { AppValueMap, ValueContext, ValueOptions } from "../../value/index.js";
7
- import { WhenRegisterCallback } from "../manager.js";
8
- import type { PluginContext, PluginConstructor, PluginInitOptions, AppPluginExposesMap, PluginItem } from "../types.js";
6
+ import type { PluginContext, PluginConstructor, PluginInitOptions, AppPluginExposesMap, PluginItem, WhenRegisterCallback } from "../types.js";
9
7
  export declare class CommonPluginContext implements PluginContext {
10
8
  #private;
11
9
  get safe(): boolean;
@@ -16,12 +14,6 @@ export declare class CommonPluginContext implements PluginContext {
16
14
  constructor(app: App, pluginName: string, options?: {
17
15
  accessApp?: boolean;
18
16
  });
19
- /** 抛出错误
20
- *
21
- * 一般用于自身导致的错误,若非插件本身导致的错误,使用throw语句即可
22
- */
23
- throw(err: AppError): void;
24
- error(id: string, options: ErrorOptions): AppError;
25
17
  register<P extends PluginItem>(plugin: PluginConstructor<P>, options?: PluginInitOptions): Promise<P>;
26
18
  unregister(pluginName: string): void;
27
19
  getPluginExposes<K extends keyof AppPluginExposesMap>(pluginName: K): AppPluginExposesMap[K];