floating-live 0.14.3 → 0.14.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "floating-live",
3
- "version": "0.14.3",
3
+ "version": "0.14.5",
4
4
  "type": "commonjs",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -36,7 +36,7 @@ declare class acfunLive extends LiveRoom {
36
36
  /** 直播间是否可用 */
37
37
  get available(): boolean;
38
38
  constructor(id: number, open?: boolean);
39
- getInfo(): Promise<import("../..").RoomInfo>;
39
+ getInfo(): Promise<void>;
40
40
  /** 开启直播间监听 */
41
41
  open(): Promise<void>;
42
42
  /** 初始化直播服务端监听 */
@@ -77,14 +77,13 @@ class acfunLive extends __1.LiveRoom {
77
77
  let { headUrl, name } = res.profile;
78
78
  this.anchor.avatar = headUrl;
79
79
  this.anchor.name = name;
80
- this.emit("info");
80
+ this.emit("info", this.info);
81
81
  })
82
82
  .catch((error) => {
83
- console.error(error);
83
+ this.emit("info_error", error);
84
84
  });
85
85
  }
86
86
  // 暂不能在连接房间后更新信息
87
- return this.info;
88
87
  }
89
88
  /** 开启直播间监听 */
90
89
  async open() {
@@ -42,7 +42,7 @@ declare class RoomBilibili extends LiveRoom {
42
42
  connectInterval?: number;
43
43
  });
44
44
  /** 获取房间信息 */
45
- getInfo(): Promise<import("../..").RoomInfo>;
45
+ getInfo(): Promise<void>;
46
46
  /** 开启直播间监听 */
47
47
  open(): Promise<void>;
48
48
  /** 设置登录凭据 */
@@ -109,9 +109,8 @@ class RoomBilibili extends LiveRoom_1.LiveRoom {
109
109
  this.emit("info", this.info);
110
110
  })
111
111
  .catch((error) => {
112
- console.error(error);
112
+ this.emit("info_error", error);
113
113
  });
114
- return this.info;
115
114
  }
116
115
  /** 开启直播间监听 */
117
116
  async open() {
@@ -32,7 +32,7 @@ export declare abstract class LiveRoom extends EventEmitter implements RoomInfo
32
32
  /** 关闭连接 */
33
33
  abstract close(): void;
34
34
  /** 从服务器获取信息 */
35
- abstract getInfo(): Promise<RoomInfo>;
35
+ abstract getInfo(): Promise<void>;
36
36
  /** 销毁事件 */
37
37
  protected onDestory?(): void;
38
38
  /** 销毁 */
@@ -14,7 +14,7 @@ export declare class ModPlugin<T extends FloatingLive> {
14
14
  /** 访问插件操作对象 */
15
15
  access(name: string): object | undefined;
16
16
  /** 注册插件 */
17
- register(pluginFunc: FloatingLivePlugin<T>): object | undefined;
17
+ register(pluginFunc: FloatingLivePlugin<T>, pluginConfig?: object): object | undefined;
18
18
  /** 移除插件 */
19
19
  unregister(name: string): void;
20
20
  }
@@ -27,7 +27,7 @@ class ModPlugin {
27
27
  return this.exports.get(name);
28
28
  }
29
29
  /** 注册插件 */
30
- register(pluginFunc) {
30
+ register(pluginFunc, pluginConfig) {
31
31
  // 执行插件函数
32
32
  const plugin = pluginFunc();
33
33
  const name = plugin.name;
@@ -38,7 +38,7 @@ class ModPlugin {
38
38
  this.list.set(name, plugin);
39
39
  this.current = name;
40
40
  // 调用register函数,并保存获取值
41
- let pluginExpose = plugin.register?.(this.main) || {};
41
+ let pluginExpose = plugin.register?.(this.main, pluginConfig) || {};
42
42
  this.exports.set(name, pluginExpose);
43
43
  this.main.emit("plugin:add", name);
44
44
  this.current = null;
@@ -3,6 +3,6 @@ import { FloatingLive } from "..";
3
3
  export declare type FloatingLivePlugin<T extends FloatingLive> = () => {
4
4
  /** 插件名称 */
5
5
  name: string;
6
- register: (ctx: T) => object | void;
6
+ register: (ctx: T, config?: object) => object | void;
7
7
  destroy?: (ctx: T) => void;
8
8
  };