floating-live 0.8.0 → 0.8.2

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.8.0",
3
+ "version": "0.8.2",
4
4
  "type": "commonjs",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -67,7 +67,7 @@ class Room {
67
67
  if (open) {
68
68
  room.open();
69
69
  }
70
- this.main.emit("room_add", { key: key, room: (0, getRoomInfo_1.default)(room) });
70
+ this.main.emit("room_add", key, (0, getRoomInfo_1.default)(room));
71
71
  }
72
72
  /** 移除房间 */
73
73
  remove(roomKey) {
@@ -20,7 +20,7 @@ export default class Controller {
20
20
  /** 添加房间 */
21
21
  addRoom({ platform, id }: {
22
22
  platform: string;
23
- id: number;
23
+ id: string | number;
24
24
  }, open?: boolean): void;
25
25
  /** 移除房间 */
26
26
  removeRoom(roomKey: string): void;
@@ -22,13 +22,13 @@ class Controller {
22
22
  start() {
23
23
  this.started = true;
24
24
  this.timestamp = new Date().valueOf();
25
- this.main.emit("start");
25
+ this.main.emit("start", this.timestamp);
26
26
  }
27
27
  /** 结束 */
28
28
  end() {
29
29
  this.closeAllRooms();
30
30
  this.started = false;
31
- this.main.emit("end");
31
+ this.main.emit("end", this.timestamp);
32
32
  this.timestamp = 0;
33
33
  }
34
34
  /** 添加房间 */
package/src/index.js CHANGED
@@ -21,10 +21,14 @@ class FloatingLive extends events_1.EventEmitter {
21
21
  }
22
22
  /** 添加插件 */
23
23
  registerPlugin(name, pluginFunc) {
24
+ if (this.plugin.has(name)) {
25
+ this.emit("plugin_duplicate");
26
+ return;
27
+ }
24
28
  Registerable_1.Registerable.currentPlugin = name;
25
29
  let pluginObject = pluginFunc(this); // 获取插件操作对象
26
30
  this.plugin.set(name, pluginObject);
27
- this.emit("addPlugin", name);
31
+ this.emit("plugin_add", name);
28
32
  console.log(`已添加插件: ${name}`);
29
33
  Registerable_1.Registerable.currentPlugin = null;
30
34
  return pluginObject;
@@ -36,7 +40,7 @@ class FloatingLive extends events_1.EventEmitter {
36
40
  /** 移除插件 */
37
41
  removePlugin(name) {
38
42
  if (!this.plugin.has(name)) {
39
- this.emit("pluginUnexist", name);
43
+ this.emit("plugin_unexist", name);
40
44
  return;
41
45
  }
42
46
  let pluginObject = this.plugin.get(name);
@@ -44,7 +48,7 @@ class FloatingLive extends events_1.EventEmitter {
44
48
  this.helper.roomGenerator.unregister(name);
45
49
  this.helper.messageHandler.unregister(name);
46
50
  pluginObject?.destory && pluginObject.destory();
47
- this.emit("removePlugin", name);
51
+ this.emit("plugin_remove", name);
48
52
  }
49
53
  }
50
54
  exports.default = FloatingLive;
@@ -1,3 +1,3 @@
1
1
  import FloatingLive from "../..";
2
2
  /** 插件模块, 加载时调用 */
3
- export declare type FLivePlugin<T = void> = (ctx: FloatingLive) => T;
3
+ export declare type FloatingLivePlugin<T = void> = (ctx: FloatingLive) => T;
@@ -3,7 +3,7 @@ interface LiveRoom extends RoomInfo {
3
3
  /** 直播平台 */
4
4
  readonly platform: string;
5
5
  /** 房间id */
6
- readonly id: number;
6
+ readonly id: number | string;
7
7
  /** 打开连接 */
8
8
  open: () => void;
9
9
  /** 关闭连接 */
@@ -4,7 +4,7 @@ export default interface RoomInfo {
4
4
  /** 平台id */
5
5
  platform: string;
6
6
  /** 房间id */
7
- id: number;
7
+ id: number | string;
8
8
  /** 直播信息 */
9
9
  live: LiveInfo;
10
10
  /** 主播信息 */