floating-live 0.15.0-beta.7 → 0.15.0-beta.9

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.
@@ -22,7 +22,7 @@ export declare abstract class LiveRoom extends EventEmitter implements RoomInfo
22
22
  /** 当前直播id */
23
23
  liveId?: string;
24
24
  /** 房间是否打开 */
25
- get opened(): boolean;
25
+ opened: boolean;
26
26
  /** 是否连接上房间 */
27
27
  connection: ConnectStatus;
28
28
  /** 房间是否可用 */
@@ -10,13 +10,11 @@ class LiveRoom extends events_1.EventEmitter {
10
10
  this.status = enums_1.RoomStatus.off;
11
11
  /** 时间戳 */
12
12
  this.timestamp = 0;
13
+ /** 房间是否打开 */
14
+ this.opened = false;
13
15
  /** 是否连接上房间 */
14
16
  this.connection = enums_1.ConnectStatus.off;
15
17
  }
16
- /** 房间是否打开 */
17
- get opened() {
18
- return !!this.connection;
19
- }
20
18
  /** 销毁 */
21
19
  destroy() {
22
20
  this.close();
@@ -9,7 +9,7 @@ export declare class ModPlugin {
9
9
  /** 获取当前安装插件 */
10
10
  get currentPlugin(): string | null;
11
11
  /** 注册插件 */
12
- register(pluginFunc: PluginConstructor, config?: any): void;
12
+ register(pluginFunc: PluginConstructor, options?: any): void;
13
13
  /** 移除插件 */
14
14
  unregister(name: string): void;
15
15
  }
@@ -13,7 +13,7 @@ class ModPlugin {
13
13
  return this.current;
14
14
  }
15
15
  /** 注册插件 */
16
- register(pluginFunc, config) {
16
+ register(pluginFunc, options) {
17
17
  const name = pluginFunc.name;
18
18
  if (!name) {
19
19
  this.main.throw(Object.assign(new TypeError("缺少插件id"), {
@@ -30,7 +30,7 @@ class ModPlugin {
30
30
  return;
31
31
  }
32
32
  // 执行插件函数
33
- const plugin = new pluginFunc(this.main, config);
33
+ const plugin = new pluginFunc(this.main, options);
34
34
  this.list.set(name, plugin);
35
35
  this.main.emit("plugin:add", name);
36
36
  this.current = null;
@@ -9,7 +9,7 @@ export declare class ModRoom {
9
9
  /** 添加房间监听实例 */
10
10
  addRoom(room: LiveRoom, open?: boolean): void;
11
11
  /** 添加房间 */
12
- add(platform: string, id: number, config?: boolean | Record<string, any>): void;
12
+ add(platform: string, id: number, options?: boolean | Record<string, any>): void;
13
13
  /** 移除房间 */
14
14
  remove(roomKey: string): void;
15
15
  /** 获取房间 */
@@ -81,12 +81,15 @@ class ModRoom {
81
81
  this.main.emit("room:add", key, room.info);
82
82
  }
83
83
  /** 添加房间 */
84
- add(platform, id, config) {
85
- if (typeof config == "boolean") {
86
- config = { open: config };
87
- }
88
- const room = this.main.call(`${platform}.room.create`, id, config);
89
- room && this.addRoom(room);
84
+ add(platform, id, options) {
85
+ const opt = typeof options == "boolean" ? { open: options } : options;
86
+ const ctx = { platform, id, options: opt || {} };
87
+ this.main.hook.call("add", ctx).then((res) => {
88
+ if (!res)
89
+ return;
90
+ const room = this.main.call(`${platform}.room.create`, id, opt);
91
+ room && this.addRoom(room);
92
+ });
90
93
  }
91
94
  /** 移除房间 */
92
95
  remove(roomKey) {
@@ -1,9 +1,9 @@
1
1
  import { LiveRoom } from "../core";
2
2
  export interface FloatingCommandMap {
3
- add: (platform: string, id: number, config?: boolean | Record<string, any>) => void;
3
+ add: (platform: string, id: number, options?: boolean | Record<string, any>) => void;
4
4
  remove: (key: string) => void;
5
5
  open: (key: string) => void;
6
6
  close: (key: string) => void;
7
7
  update: (key: string) => void;
8
- [name: `${string}.room.create`]: (id: string | number, config?: Record<string, any>) => LiveRoom;
8
+ [name: `${string}.room.create`]: (id: string | number, options?: Record<string, any>) => LiveRoom;
9
9
  }
@@ -1,5 +1,9 @@
1
1
  import { Message } from "./message";
2
2
  export interface FloatingHookMap {
3
3
  message: Message.All;
4
- add: Record<string, any>;
4
+ add: {
5
+ platform: string;
6
+ id: string | number;
7
+ options: Record<string, any>;
8
+ };
5
9
  }
@@ -3,13 +3,13 @@ import { FloatingLive } from "../live";
3
3
  export declare type FloatingLivePlugin<C extends object = object> = () => {
4
4
  /** 插件名称 */
5
5
  name: string;
6
- register: (ctx: FloatingLive, config?: C) => void;
6
+ register: (ctx: FloatingLive, options?: C) => void;
7
7
  destroy?: (ctx: FloatingLive) => void;
8
8
  };
9
9
  export interface IPlugin {
10
- destroy: () => void;
10
+ destroy?(): void;
11
11
  }
12
12
  export interface PluginConstructor {
13
13
  pluginName: string;
14
- new (ctx: FloatingLive, config: any): IPlugin;
14
+ new (ctx: FloatingLive, options: any): IPlugin;
15
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "floating-live",
3
- "version": "0.15.0-beta.7",
3
+ "version": "0.15.0-beta.9",
4
4
  "type": "commonjs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",