floating-live 0.15.0-beta.3 → 0.15.0-beta.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/dist/enums.d.ts +3 -1
- package/dist/enums.js +2 -0
- package/dist/live.d.ts +9 -9
- package/dist/live.js +11 -14
- package/dist/module/command.d.ts +2 -2
- package/dist/module/command.js +3 -2
- package/dist/module/manifest.d.ts +15 -0
- package/dist/module/{store.js → manifest.js} +8 -8
- package/dist/module/room.d.ts +1 -1
- package/dist/module/room.js +2 -2
- package/dist/module/{values.d.ts → value.d.ts} +3 -3
- package/dist/module/{values.js → value.js} +7 -5
- package/dist/types/command.d.ts +1 -1
- package/dist/types/events.d.ts +5 -4
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +3 -0
- package/dist/types/{store.d.ts → manifest.d.ts} +1 -1
- package/dist/types/message.d.ts +43 -5
- package/dist/types/room.d.ts +5 -2
- package/package.json +1 -1
- package/dist/module/store.d.ts +0 -15
- /package/dist/types/{store.js → manifest.js} +0 -0
- /package/dist/types/{values.d.ts → value.d.ts} +0 -0
- /package/dist/types/{values.js → value.js} +0 -0
package/dist/enums.d.ts
CHANGED
package/dist/enums.js
CHANGED
|
@@ -12,6 +12,8 @@ var RoomStatus;
|
|
|
12
12
|
RoomStatus[RoomStatus["round"] = 2] = "round";
|
|
13
13
|
/** 被封禁 */
|
|
14
14
|
RoomStatus[RoomStatus["banned"] = -1] = "banned";
|
|
15
|
+
/** 已上锁 */
|
|
16
|
+
RoomStatus[RoomStatus["locked"] = -2] = "locked";
|
|
15
17
|
})(RoomStatus = exports.RoomStatus || (exports.RoomStatus = {}));
|
|
16
18
|
/** 图片大小 */
|
|
17
19
|
var ImageSize;
|
package/dist/live.d.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { EventEmitter } from "events";
|
|
3
3
|
import { ModPlugin } from "./module/plugin";
|
|
4
4
|
import { ModRoom } from "./module/room";
|
|
5
|
-
import {
|
|
6
|
-
import ModCommand from "./module/command";
|
|
7
|
-
import {
|
|
5
|
+
import { ModManifest } from "./module/manifest";
|
|
6
|
+
import { ModCommand } from "./module/command";
|
|
7
|
+
import { ModValue } from "./module/value";
|
|
8
8
|
import { ModHook } from "./module/hook";
|
|
9
9
|
import { FloatingEventMap } from "./types/events";
|
|
10
10
|
import { FloatingCommandMap } from "./types";
|
|
@@ -15,10 +15,10 @@ export declare class FloatingLive extends EventEmitter {
|
|
|
15
15
|
plugin: ModPlugin;
|
|
16
16
|
/** 命令模块 */
|
|
17
17
|
command: ModCommand;
|
|
18
|
-
/**
|
|
19
|
-
|
|
18
|
+
/** Manifest模块 */
|
|
19
|
+
manifest: ModManifest;
|
|
20
20
|
/** 数值模块 */
|
|
21
|
-
|
|
21
|
+
value: ModValue;
|
|
22
22
|
/** 钩子模块 */
|
|
23
23
|
hook: ModHook;
|
|
24
24
|
constructor();
|
|
@@ -26,10 +26,10 @@ export declare class FloatingLive extends EventEmitter {
|
|
|
26
26
|
on<T extends keyof FloatingEventMap>(eventName: T, listener: FloatingEventMap[T]): this;
|
|
27
27
|
emit<T extends keyof FloatingEventMap>(eventName: T, ...args: Parameters<FloatingEventMap[T]>): boolean;
|
|
28
28
|
throw(err: Error): void;
|
|
29
|
-
|
|
29
|
+
getSnapshot(): {
|
|
30
30
|
room: import("./types").RoomInfo[];
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
value: Record<string, any>;
|
|
32
|
+
manifest: Record<string, Record<string, any>>;
|
|
33
33
|
command: string[];
|
|
34
34
|
};
|
|
35
35
|
}
|
package/dist/live.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.FloatingLive = void 0;
|
|
7
4
|
const events_1 = require("events");
|
|
8
5
|
const plugin_1 = require("./module/plugin");
|
|
9
6
|
const room_1 = require("./module/room");
|
|
10
|
-
const
|
|
11
|
-
const command_1 =
|
|
12
|
-
const
|
|
7
|
+
const manifest_1 = require("./module/manifest");
|
|
8
|
+
const command_1 = require("./module/command");
|
|
9
|
+
const value_1 = require("./module/value");
|
|
13
10
|
const hook_1 = require("./module/hook");
|
|
14
11
|
class FloatingLive extends events_1.EventEmitter {
|
|
15
12
|
constructor() {
|
|
16
13
|
super();
|
|
17
|
-
this.command = new command_1.
|
|
18
|
-
this.
|
|
14
|
+
this.command = new command_1.ModCommand(this);
|
|
15
|
+
this.manifest = new manifest_1.ModManifest(this);
|
|
19
16
|
this.plugin = new plugin_1.ModPlugin(this);
|
|
20
17
|
this.room = new room_1.ModRoom(this);
|
|
21
|
-
this.
|
|
18
|
+
this.value = new value_1.ModValue(this);
|
|
22
19
|
this.hook = new hook_1.ModHook(this);
|
|
23
20
|
}
|
|
24
21
|
call(name, ...args) {
|
|
@@ -33,12 +30,12 @@ class FloatingLive extends events_1.EventEmitter {
|
|
|
33
30
|
throw(err) {
|
|
34
31
|
this.emit("error", err);
|
|
35
32
|
}
|
|
36
|
-
|
|
33
|
+
getSnapshot() {
|
|
37
34
|
return {
|
|
38
|
-
room: this.room.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
command: this.command.
|
|
35
|
+
room: this.room.getSnapshot(),
|
|
36
|
+
value: this.value.getSnapshot(),
|
|
37
|
+
manifest: this.manifest.getSnapshot(),
|
|
38
|
+
command: this.command.getSnapshot(),
|
|
42
39
|
};
|
|
43
40
|
}
|
|
44
41
|
}
|
package/dist/module/command.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FloatingLive } from "../live";
|
|
2
2
|
import { FloatingCommandMap } from "../types";
|
|
3
|
-
export
|
|
3
|
+
export declare class ModCommand {
|
|
4
4
|
/** 功能列表 */
|
|
5
5
|
private readonly list;
|
|
6
6
|
protected readonly main: FloatingLive;
|
|
@@ -12,5 +12,5 @@ export default class ModCommand {
|
|
|
12
12
|
/** 调用命令 */
|
|
13
13
|
call<T extends keyof FloatingCommandMap>(name: T, ...args: Parameters<FloatingCommandMap[T]>): any;
|
|
14
14
|
/** 获取快照 */
|
|
15
|
-
|
|
15
|
+
getSnapshot(): string[];
|
|
16
16
|
}
|
package/dist/module/command.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModCommand = void 0;
|
|
3
4
|
class ModCommand {
|
|
4
5
|
constructor(main) {
|
|
5
6
|
/** 功能列表 */
|
|
@@ -21,8 +22,8 @@ class ModCommand {
|
|
|
21
22
|
return this.list.get(name)?.(...args);
|
|
22
23
|
}
|
|
23
24
|
/** 获取快照 */
|
|
24
|
-
|
|
25
|
+
getSnapshot() {
|
|
25
26
|
return [...this.list].map(([key]) => key);
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
|
-
exports.
|
|
29
|
+
exports.ModCommand = ModCommand;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FloatingLive } from "../live";
|
|
2
|
+
import { FloatingManifestMap } from "../types/manifest";
|
|
3
|
+
export declare class ModManifest {
|
|
4
|
+
private list;
|
|
5
|
+
protected readonly main: FloatingLive;
|
|
6
|
+
constructor(main: FloatingLive);
|
|
7
|
+
/** 注册manifest */
|
|
8
|
+
register<T extends keyof FloatingManifestMap>(name: T, id: string, value: FloatingManifestMap[T]): void;
|
|
9
|
+
/** 取消注册manifest */
|
|
10
|
+
unregister<T extends keyof FloatingManifestMap>(name: T, id: string): void;
|
|
11
|
+
/** 获取值 */
|
|
12
|
+
get(name: string): Map<string, any> | undefined;
|
|
13
|
+
/** 获取快照 */
|
|
14
|
+
getSnapshot(): Record<string, Record<string, any>>;
|
|
15
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
class
|
|
3
|
+
exports.ModManifest = void 0;
|
|
4
|
+
class ModManifest {
|
|
5
5
|
constructor(main) {
|
|
6
6
|
this.list = new Map();
|
|
7
7
|
this.main = main;
|
|
8
8
|
}
|
|
9
|
-
/** 注册
|
|
9
|
+
/** 注册manifest */
|
|
10
10
|
register(name, id, value) {
|
|
11
11
|
let store = this.list.get(name);
|
|
12
12
|
if (!store) {
|
|
@@ -14,14 +14,14 @@ class ModStore {
|
|
|
14
14
|
this.list.set(name, store);
|
|
15
15
|
}
|
|
16
16
|
store.set(id, value);
|
|
17
|
-
this.main.emit("
|
|
17
|
+
this.main.emit("manifest:add", name, id, value);
|
|
18
18
|
}
|
|
19
|
-
/** 取消注册
|
|
19
|
+
/** 取消注册manifest */
|
|
20
20
|
unregister(name, id) {
|
|
21
21
|
let store = this.list.get(name);
|
|
22
22
|
if (store) {
|
|
23
23
|
store.delete(id);
|
|
24
|
-
this.main.emit("
|
|
24
|
+
this.main.emit("manifest:remove", name, id);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
/** 获取值 */
|
|
@@ -29,7 +29,7 @@ class ModStore {
|
|
|
29
29
|
return this.list.get(name);
|
|
30
30
|
}
|
|
31
31
|
/** 获取快照 */
|
|
32
|
-
|
|
32
|
+
getSnapshot() {
|
|
33
33
|
const map = {};
|
|
34
34
|
this.list.forEach((store, name) => {
|
|
35
35
|
const part = {};
|
|
@@ -41,4 +41,4 @@ class ModStore {
|
|
|
41
41
|
return map;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
exports.
|
|
44
|
+
exports.ModManifest = ModManifest;
|
package/dist/module/room.d.ts
CHANGED
package/dist/module/room.js
CHANGED
|
@@ -77,7 +77,7 @@ class ModRoom {
|
|
|
77
77
|
if (typeof config == "boolean") {
|
|
78
78
|
config = { open: config };
|
|
79
79
|
}
|
|
80
|
-
const room = this.main.call(
|
|
80
|
+
const room = this.main.call(`${platform}.room.create`, id, config);
|
|
81
81
|
room && this.addRoom(room);
|
|
82
82
|
}
|
|
83
83
|
/** 移除房间 */
|
|
@@ -132,7 +132,7 @@ class ModRoom {
|
|
|
132
132
|
this.list = new Map(arr);
|
|
133
133
|
}
|
|
134
134
|
/** 获取快照 */
|
|
135
|
-
|
|
135
|
+
getSnapshot() {
|
|
136
136
|
return [...this.list].map(([key, room]) => room.info);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FloatingLive } from "../live";
|
|
2
|
-
import { FloatingValueMap } from "../types/
|
|
2
|
+
import { FloatingValueMap } from "../types/value";
|
|
3
3
|
interface ValueConfig<T> {
|
|
4
4
|
get: () => T;
|
|
5
5
|
set?: (value: T) => void;
|
|
6
6
|
}
|
|
7
|
-
export declare class
|
|
7
|
+
export declare class ModValue {
|
|
8
8
|
private list;
|
|
9
9
|
protected readonly main: FloatingLive;
|
|
10
10
|
constructor(main: FloatingLive);
|
|
@@ -17,7 +17,7 @@ export declare class ModValues {
|
|
|
17
17
|
/** 设置值 */
|
|
18
18
|
set(name: string, value: any): boolean;
|
|
19
19
|
/** 获取注册的所有值 */
|
|
20
|
-
|
|
20
|
+
getSnapshot(): Record<string, any>;
|
|
21
21
|
emit<T extends keyof FloatingValueMap>(name: T, value: FloatingValueMap[T]): void;
|
|
22
22
|
watch<T extends keyof FloatingValueMap>(name: T, listener: (value: FloatingValueMap[T]) => void): void;
|
|
23
23
|
unwatch<T extends keyof FloatingValueMap>(name: T, listener: (value: FloatingValueMap[T]) => void): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
class
|
|
3
|
+
exports.ModValue = void 0;
|
|
4
|
+
class ModValue {
|
|
5
5
|
constructor(main) {
|
|
6
6
|
this.list = new Map();
|
|
7
7
|
this.main = main;
|
|
@@ -9,10 +9,12 @@ class ModValues {
|
|
|
9
9
|
/** 注册值 */
|
|
10
10
|
register(name, config) {
|
|
11
11
|
this.list.set(name, config);
|
|
12
|
+
this.main.emit("value:add", name);
|
|
12
13
|
}
|
|
13
14
|
/** 取消注册 */
|
|
14
15
|
unregister(name) {
|
|
15
16
|
this.list.delete(name);
|
|
17
|
+
this.main.emit("value:remove", name);
|
|
16
18
|
}
|
|
17
19
|
/** 获取值 */
|
|
18
20
|
get(name) {
|
|
@@ -30,7 +32,7 @@ class ModValues {
|
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
/** 获取注册的所有值 */
|
|
33
|
-
|
|
35
|
+
getSnapshot() {
|
|
34
36
|
const map = {};
|
|
35
37
|
this.list.forEach((config, name) => {
|
|
36
38
|
map[name] = config.get();
|
|
@@ -38,8 +40,8 @@ class ModValues {
|
|
|
38
40
|
return map;
|
|
39
41
|
}
|
|
40
42
|
emit(name, value) {
|
|
41
|
-
this.main.emit("values:change", name, value);
|
|
42
43
|
this.main.emit(`change:${name}`, value);
|
|
44
|
+
this.main.emit("value:change", name, value);
|
|
43
45
|
}
|
|
44
46
|
watch(name, listener) {
|
|
45
47
|
this.main.on(`change:${name}`, listener);
|
|
@@ -48,4 +50,4 @@ class ModValues {
|
|
|
48
50
|
this.main.off(`change:${name}`, listener);
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
|
-
exports.
|
|
53
|
+
exports.ModValue = ModValue;
|
package/dist/types/command.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ export interface FloatingCommandMap {
|
|
|
5
5
|
open: (key: string) => void;
|
|
6
6
|
close: (key: string) => void;
|
|
7
7
|
update: (key: string) => void;
|
|
8
|
-
[name:
|
|
8
|
+
[name: `${string}.room.create`]: (id: string | number, config?: Record<string, any>) => LiveRoom;
|
|
9
9
|
}
|
package/dist/types/events.d.ts
CHANGED
|
@@ -25,10 +25,11 @@ export interface FloatingEventMap {
|
|
|
25
25
|
"plugin:remove": (name: string) => void;
|
|
26
26
|
"command:add": (name: string) => void;
|
|
27
27
|
"command:remove": (name: string) => void;
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
28
|
+
"manifest:add": (name: string, id: string, value: any) => void;
|
|
29
|
+
"manifest:remove": (name: string, id: string) => void;
|
|
30
|
+
"value:add": (name: string) => void;
|
|
31
|
+
"value:remove": (name: string) => void;
|
|
32
|
+
"value:change": (name: string, value: any) => void;
|
|
32
33
|
[name: `change:${string}`]: (value: any) => void;
|
|
33
34
|
error: (err: Error) => void;
|
|
34
35
|
}
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -19,3 +19,6 @@ __exportStar(require("./plugin"), exports);
|
|
|
19
19
|
__exportStar(require("./room"), exports);
|
|
20
20
|
__exportStar(require("./command"), exports);
|
|
21
21
|
__exportStar(require("./events"), exports);
|
|
22
|
+
__exportStar(require("./manifest"), exports);
|
|
23
|
+
__exportStar(require("./hook"), exports);
|
|
24
|
+
__exportStar(require("./value"), exports);
|
package/dist/types/message.d.ts
CHANGED
|
@@ -16,9 +16,9 @@ export declare namespace Message {
|
|
|
16
16
|
/** 其他属性 */
|
|
17
17
|
[attr: string]: any;
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
20
|
-
interface
|
|
21
|
-
type: "
|
|
19
|
+
/** 聊天消息 */
|
|
20
|
+
interface Comment extends Base {
|
|
21
|
+
type: "comment";
|
|
22
22
|
info: {
|
|
23
23
|
/** 用户信息 */
|
|
24
24
|
user: UserInfo;
|
|
@@ -140,7 +140,43 @@ export declare namespace Message {
|
|
|
140
140
|
type: "live_detail";
|
|
141
141
|
info: RoomDetail;
|
|
142
142
|
}
|
|
143
|
-
|
|
143
|
+
interface Lottery extends Base {
|
|
144
|
+
type: "lottery";
|
|
145
|
+
info: {
|
|
146
|
+
id: number;
|
|
147
|
+
award: GiftInfo;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
interface LotteryResult extends Base {
|
|
151
|
+
type: "lottery_result";
|
|
152
|
+
info: {
|
|
153
|
+
id: number;
|
|
154
|
+
award: GiftInfo;
|
|
155
|
+
result: UserInfo[];
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
interface Redpacket extends Base {
|
|
159
|
+
type: "redpacket";
|
|
160
|
+
info: {
|
|
161
|
+
id: number;
|
|
162
|
+
gifts?: GiftInfo[];
|
|
163
|
+
value?: number;
|
|
164
|
+
currency?: string | number;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
interface RedpacketResult extends Base {
|
|
168
|
+
type: "redpacket_result";
|
|
169
|
+
info: {
|
|
170
|
+
id: number;
|
|
171
|
+
result: {
|
|
172
|
+
user: UserInfo;
|
|
173
|
+
gift?: GiftInfo;
|
|
174
|
+
value?: number;
|
|
175
|
+
currency?: string | number;
|
|
176
|
+
}[];
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
type All = Comment | Gift | Interact | Membership | Superchat | Block | LiveStart | LiveEnd | LiveCut | LiveDetail | LiveStats | Lottery | LotteryResult | Redpacket | RedpacketResult;
|
|
144
180
|
}
|
|
145
181
|
/** 用户信息 */
|
|
146
182
|
export interface UserInfo {
|
|
@@ -200,11 +236,13 @@ export interface GiftInfo {
|
|
|
200
236
|
/** 礼物连击id */
|
|
201
237
|
comboId?: string;
|
|
202
238
|
/** 人民币价值 */
|
|
203
|
-
|
|
239
|
+
money?: number;
|
|
204
240
|
/** 行为 */
|
|
205
241
|
action?: string;
|
|
206
242
|
/** 随机礼物信息 */
|
|
207
243
|
blindGift?: GiftInfo;
|
|
208
244
|
/** 图片信息 */
|
|
209
245
|
image?: string;
|
|
246
|
+
/** 单位 */
|
|
247
|
+
unit?: string;
|
|
210
248
|
}
|
package/dist/types/room.d.ts
CHANGED
|
@@ -79,15 +79,18 @@ export interface PlatformInfo {
|
|
|
79
79
|
};
|
|
80
80
|
/** 礼物信息 */
|
|
81
81
|
gift?: {
|
|
82
|
+
/** 默认送出礼物行为 */
|
|
82
83
|
action: string;
|
|
83
84
|
};
|
|
85
|
+
/** 统计信息 */
|
|
86
|
+
stats?: Record<string, string>;
|
|
84
87
|
/** 货币信息 */
|
|
85
88
|
currency?: Record<string, {
|
|
86
89
|
/** 货币名称 */
|
|
87
90
|
name: string;
|
|
88
91
|
/** 1货币面值等值value (1面值/1数值) */
|
|
89
92
|
ratio: number;
|
|
90
|
-
/** 1
|
|
91
|
-
|
|
93
|
+
/** 1单位消费金额等值value (1.00CNY/1数值) (若为0则为免费货币) */
|
|
94
|
+
money?: number;
|
|
92
95
|
}>;
|
|
93
96
|
}
|
package/package.json
CHANGED
package/dist/module/store.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FloatingLive } from "../live";
|
|
2
|
-
import { FloatingStoreMap } from "../types/store";
|
|
3
|
-
export declare class ModStore {
|
|
4
|
-
private list;
|
|
5
|
-
protected readonly main: FloatingLive;
|
|
6
|
-
constructor(main: FloatingLive);
|
|
7
|
-
/** 注册store */
|
|
8
|
-
register<T extends keyof FloatingStoreMap>(name: T, id: string, value: FloatingStoreMap[T]): void;
|
|
9
|
-
/** 取消注册store */
|
|
10
|
-
unregister<T extends keyof FloatingStoreMap>(name: T, id: string): void;
|
|
11
|
-
/** 获取值 */
|
|
12
|
-
get(name: string): Map<string, any> | undefined;
|
|
13
|
-
/** 获取快照 */
|
|
14
|
-
snapshot(): Record<string, Record<string, any>>;
|
|
15
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|