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 +2 -2
- package/dist/live.js +3 -1
- package/dist/module/command.d.ts +2 -0
- package/dist/module/command.js +4 -0
- package/dist/module/hook.d.ts +1 -1
- package/dist/module/hook.js +1 -1
- package/dist/module/plugin.d.ts +4 -0
- package/dist/module/plugin.js +5 -1
- package/dist/types/events.d.ts +1 -0
- package/dist/types/message.d.ts +1 -1
- package/dist/types/plugin.d.ts +2 -1
- package/dist/types/room.d.ts +10 -8
- package/package.json +2 -2
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
|
|
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
|
-
|
|
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);
|
package/dist/module/command.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/module/command.js
CHANGED
package/dist/module/hook.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FloatingLive } from "../live";
|
|
2
2
|
import { FloatingHookMap } from "../types/hook";
|
|
3
|
-
export
|
|
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;
|
package/dist/module/hook.js
CHANGED
package/dist/module/plugin.d.ts
CHANGED
package/dist/module/plugin.js
CHANGED
|
@@ -14,7 +14,7 @@ class ModPlugin {
|
|
|
14
14
|
}
|
|
15
15
|
/** 注册插件 */
|
|
16
16
|
register(pluginFunc, options) {
|
|
17
|
-
const name = pluginFunc.
|
|
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;
|
package/dist/types/events.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/types/message.d.ts
CHANGED
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { FloatingLive } from "../live";
|
|
2
2
|
/** 插件模块, 加载时调用 */
|
|
3
|
-
export
|
|
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 {
|
package/dist/types/room.d.ts
CHANGED
|
@@ -85,12 +85,14 @@ export interface PlatformInfo {
|
|
|
85
85
|
/** 统计信息 */
|
|
86
86
|
stats?: Record<string, string>;
|
|
87
87
|
/** 货币信息 */
|
|
88
|
-
currency?:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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.
|
|
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": "
|
|
8
|
+
"license": "MIT",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|