floating-live 0.15.0-beta.9 → 0.15.1

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/README.md CHANGED
@@ -17,10 +17,10 @@ GUI版本:[Minteea/floating-live-gui](https://github.com/Minteea/floating-live
17
17
  npm install floating-live
18
18
  ```
19
19
  ``` javascript
20
- // 导入FloatingLive
20
+ // 导入FloatingLive本体
21
21
  const { FloatingLive } = require("floating-live")
22
22
  // 导入bilibili房间生成插件
23
- const bilibili = require("@floating-live/bilibili/plugin")
23
+ const bilibili = require("@floating-live/bilibili")
24
24
 
25
25
  // 创建一个FloatingLive实例
26
26
  const live = new FloatingLive()
package/dist/live.js CHANGED
@@ -25,7 +25,9 @@ class FloatingLive extends events_1.EventEmitter {
25
25
  return super.on(eventName, listener);
26
26
  }
27
27
  emit(eventName, ...args) {
28
- return super.emit(eventName, ...args);
28
+ const emit = super.emit(eventName, ...args);
29
+ super.emit("event", eventName, ...args);
30
+ return emit;
29
31
  }
30
32
  throw(err) {
31
33
  this.emit("error", err);
@@ -11,6 +11,8 @@ export declare class ModCommand {
11
11
  unregister(name: string): void;
12
12
  /** 调用命令 */
13
13
  call<T extends keyof FloatingCommandMap>(name: T, ...args: Parameters<FloatingCommandMap[T]>): any;
14
+ /** 检测命令是否存在 */
15
+ has<T extends keyof FloatingCommandMap>(name: T): boolean;
14
16
  /** 获取快照 */
15
17
  getSnapshot(): string[];
16
18
  }
@@ -21,6 +21,10 @@ class ModCommand {
21
21
  call(name, ...args) {
22
22
  return this.list.get(name)?.(...args);
23
23
  }
24
+ /** 检测命令是否存在 */
25
+ has(name) {
26
+ return this.list.has(name);
27
+ }
24
28
  /** 获取快照 */
25
29
  getSnapshot() {
26
30
  return [...this.list].map(([key]) => key);
@@ -1,6 +1,6 @@
1
1
  import { FloatingLive } from "../live";
2
2
  import { FloatingHookMap } from "../types/hook";
3
- export declare type HookFunction<T> = (ctx: T) => boolean | void | Promise<boolean | void>;
3
+ export type HookFunction<T> = (ctx: T) => boolean | void | Promise<boolean | void>;
4
4
  export declare class ModHook {
5
5
  private list;
6
6
  protected readonly main: FloatingLive;
@@ -38,7 +38,7 @@ class ModHook {
38
38
  return false;
39
39
  }
40
40
  }
41
- return false;
41
+ return true;
42
42
  }
43
43
  }
44
44
  exports.ModHook = ModHook;
@@ -12,4 +12,8 @@ export declare class ModPlugin {
12
12
  register(pluginFunc: PluginConstructor, options?: any): void;
13
13
  /** 移除插件 */
14
14
  unregister(name: string): void;
15
+ /** 获取插件实例 */
16
+ get(name: string): {
17
+ [key: string]: any;
18
+ } | undefined;
15
19
  }
@@ -14,7 +14,7 @@ class ModPlugin {
14
14
  }
15
15
  /** 注册插件 */
16
16
  register(pluginFunc, options) {
17
- const name = pluginFunc.name;
17
+ const name = pluginFunc.pluginName;
18
18
  if (!name) {
19
19
  this.main.throw(Object.assign(new TypeError("缺少插件id"), {
20
20
  from: "plugin",
@@ -53,5 +53,9 @@ class ModPlugin {
53
53
  // 移除插件注册
54
54
  this.main.emit("plugin:remove", name);
55
55
  }
56
+ /** 获取插件实例 */
57
+ get(name) {
58
+ return this.list.get(name);
59
+ }
56
60
  }
57
61
  exports.ModPlugin = ModPlugin;
@@ -33,5 +33,6 @@ export interface FloatingEventMap {
33
33
  "value:remove": (name: string) => void;
34
34
  "value:change": (name: string, value: any) => void;
35
35
  [name: `change:${string}`]: (value: any) => void;
36
+ event: (eventName: string, ...args: any[]) => void;
36
37
  error: (err: Error) => void;
37
38
  }
@@ -230,7 +230,7 @@ export interface GiftInfo {
230
230
  /** 总价值 */
231
231
  value: number;
232
232
  /** 平台货币 */
233
- currency: string;
233
+ currency?: string | number;
234
234
  /** 礼物连击数 */
235
235
  combo?: string;
236
236
  /** 礼物连击id */
@@ -1,12 +1,13 @@
1
1
  import { FloatingLive } from "../live";
2
2
  /** 插件模块, 加载时调用 */
3
- export declare type FloatingLivePlugin<C extends object = object> = () => {
3
+ export type FloatingLivePlugin<C extends object = object> = () => {
4
4
  /** 插件名称 */
5
5
  name: string;
6
6
  register: (ctx: FloatingLive, options?: C) => void;
7
7
  destroy?: (ctx: FloatingLive) => void;
8
8
  };
9
9
  export interface IPlugin {
10
+ [key: string]: any;
10
11
  destroy?(): void;
11
12
  }
12
13
  export interface PluginConstructor {
@@ -85,12 +85,14 @@ export interface PlatformInfo {
85
85
  /** 统计信息 */
86
86
  stats?: Record<string, string>;
87
87
  /** 货币信息 */
88
- currency?: Record<string, {
89
- /** 货币名称 */
90
- name: string;
91
- /** 1货币面值等值value (1面值/1数值) */
92
- ratio: number;
93
- /** 1单位消费金额等值value (1.00CNY/1数值) (若为0则为免费货币) */
94
- money?: number;
95
- }>;
88
+ currency?: {
89
+ [key: string | number]: {
90
+ /** 货币名称 */
91
+ name: string;
92
+ /** 1货币面值等值value (1面值/1数值) */
93
+ ratio: number;
94
+ /** 1单位消费金额等值value (1.00CNY/1数值) (若为0则为免费货币) */
95
+ money?: number;
96
+ };
97
+ };
96
98
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "floating-live",
3
- "version": "0.15.0-beta.9",
3
+ "version": "0.15.1",
4
4
  "type": "commonjs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "author": "Minteea",
8
- "license": "GPLv3",
8
+ "license": "MIT",
9
9
  "exports": {
10
10
  ".": {
11
11
  "types": "./dist/index.d.ts",