floating-live 0.16.0-alpha.1 → 0.16.0-alpha.3
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/live/messageInfo.d.ts +20 -17
- package/dist/live/messageInfo.js +16 -20
- package/dist/live/room.d.ts +17 -14
- package/dist/live/room.js +14 -16
- package/dist/plugin/context/CommonPluginContext.d.ts +2 -2
- package/dist/plugin/manager.js +3 -1
- package/dist/plugin/types.d.ts +7 -3
- package/dist/utils/types.d.ts +1 -0
- package/dist/utils/types.js +1 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EnumValue } from "../utils/types";
|
|
1
2
|
/** 用户信息 */
|
|
2
3
|
export interface UserInfo {
|
|
3
4
|
/** 用户名 */
|
|
@@ -66,28 +67,30 @@ export interface GiftInfo {
|
|
|
66
67
|
/** 单位 */
|
|
67
68
|
unit?: string;
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
-
export declare enum ImageSize {
|
|
70
|
+
export declare const ImageSize: {
|
|
71
71
|
/** 自定义大小 */
|
|
72
|
-
custom
|
|
72
|
+
readonly custom: 0;
|
|
73
73
|
/** 小表情(文字行高) */
|
|
74
|
-
small
|
|
74
|
+
readonly small: 1;
|
|
75
75
|
/** 大表情 */
|
|
76
|
-
large
|
|
77
|
-
}
|
|
76
|
+
readonly large: 2;
|
|
77
|
+
};
|
|
78
|
+
export type ImageSize = EnumValue<typeof ImageSize>;
|
|
78
79
|
/** 弹幕模式 */
|
|
79
|
-
export declare
|
|
80
|
-
left
|
|
81
|
-
bottom
|
|
82
|
-
top
|
|
83
|
-
right
|
|
84
|
-
}
|
|
80
|
+
export declare const DanmakuMode: {
|
|
81
|
+
readonly left: 1;
|
|
82
|
+
readonly bottom: 4;
|
|
83
|
+
readonly top: 5;
|
|
84
|
+
readonly right: 6;
|
|
85
|
+
};
|
|
86
|
+
export type DanmakuMode = EnumValue<typeof DanmakuMode>;
|
|
85
87
|
/** 用户类型 */
|
|
86
|
-
export declare
|
|
88
|
+
export declare const UserType: {
|
|
87
89
|
/** 普通观众 */
|
|
88
|
-
normal
|
|
90
|
+
readonly normal: 0;
|
|
89
91
|
/** 房管 */
|
|
90
|
-
admin
|
|
92
|
+
readonly admin: 1;
|
|
91
93
|
/** 主播 */
|
|
92
|
-
anchor
|
|
93
|
-
}
|
|
94
|
+
readonly anchor: 2;
|
|
95
|
+
};
|
|
96
|
+
export type UserType = EnumValue<typeof UserType>;
|
package/dist/live/messageInfo.js
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
export var ImageSize;
|
|
3
|
-
(function (ImageSize) {
|
|
1
|
+
export const ImageSize = {
|
|
4
2
|
/** 自定义大小 */
|
|
5
|
-
|
|
3
|
+
custom: 0,
|
|
6
4
|
/** 小表情(文字行高) */
|
|
7
|
-
|
|
5
|
+
small: 1,
|
|
8
6
|
/** 大表情 */
|
|
9
|
-
|
|
10
|
-
}
|
|
7
|
+
large: 2,
|
|
8
|
+
};
|
|
11
9
|
/** 弹幕模式 */
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})(DanmakuMode || (DanmakuMode = {}));
|
|
10
|
+
export const DanmakuMode = {
|
|
11
|
+
left: 1,
|
|
12
|
+
bottom: 4,
|
|
13
|
+
top: 5,
|
|
14
|
+
right: 6,
|
|
15
|
+
};
|
|
19
16
|
/** 用户类型 */
|
|
20
|
-
export
|
|
21
|
-
(function (UserType) {
|
|
17
|
+
export const UserType = {
|
|
22
18
|
/** 普通观众 */
|
|
23
|
-
|
|
19
|
+
normal: 0,
|
|
24
20
|
/** 房管 */
|
|
25
|
-
|
|
21
|
+
admin: 1,
|
|
26
22
|
/** 主播 */
|
|
27
|
-
|
|
28
|
-
}
|
|
23
|
+
anchor: 2,
|
|
24
|
+
};
|
package/dist/live/room.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CustomEventEmitter } from "../utils/EventEmitter";
|
|
2
|
+
import { EnumValue } from "../utils/types";
|
|
2
3
|
import { LiveMessage } from "./message";
|
|
3
4
|
import { UserInfo } from "./messageInfo";
|
|
4
5
|
export declare abstract class LiveRoom extends CustomEventEmitter implements LiveRoomData {
|
|
@@ -95,31 +96,33 @@ export interface LiveRoomStatsInfo {
|
|
|
95
96
|
popularity?: number;
|
|
96
97
|
}
|
|
97
98
|
/** 直播间状态 */
|
|
98
|
-
export declare
|
|
99
|
+
export declare const LiveRoomStatus: {
|
|
99
100
|
/** 未开播 */
|
|
100
|
-
off
|
|
101
|
+
readonly off: 0;
|
|
101
102
|
/** 正在直播 */
|
|
102
|
-
live
|
|
103
|
+
readonly live: 1;
|
|
103
104
|
/** 正在轮播 */
|
|
104
|
-
round
|
|
105
|
+
readonly round: 2;
|
|
105
106
|
/** 被封禁 */
|
|
106
|
-
banned
|
|
107
|
+
readonly banned: -1;
|
|
107
108
|
/** 已上锁 */
|
|
108
|
-
locked
|
|
109
|
-
}
|
|
109
|
+
readonly locked: -2;
|
|
110
|
+
};
|
|
111
|
+
export type LiveRoomStatus = EnumValue<typeof LiveRoomStatus>;
|
|
110
112
|
/** 直播间状态 */
|
|
111
|
-
export declare
|
|
113
|
+
export declare const LiveConnectionStatus: {
|
|
112
114
|
/** 未连接 */
|
|
113
|
-
off
|
|
115
|
+
off: number;
|
|
114
116
|
/** 连接中 */
|
|
115
|
-
connecting
|
|
117
|
+
connecting: number;
|
|
116
118
|
/** 连接到服务器 */
|
|
117
|
-
connected
|
|
119
|
+
connected: number;
|
|
118
120
|
/** 连接到房间 */
|
|
119
|
-
entered
|
|
121
|
+
entered: number;
|
|
120
122
|
/** 连接失败或断开 */
|
|
121
|
-
disconnected
|
|
122
|
-
}
|
|
123
|
+
disconnected: number;
|
|
124
|
+
};
|
|
125
|
+
export type LiveConnectionStatus = EnumValue<typeof LiveConnectionStatus>;
|
|
123
126
|
export interface LiveRoomEventMap {
|
|
124
127
|
status: {
|
|
125
128
|
status: LiveRoomStatus;
|
package/dist/live/room.js
CHANGED
|
@@ -91,30 +91,28 @@ export class LiveRoom extends CustomEventEmitter {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
/** 直播间状态 */
|
|
94
|
-
export
|
|
95
|
-
(function (LiveRoomStatus) {
|
|
94
|
+
export const LiveRoomStatus = {
|
|
96
95
|
/** 未开播 */
|
|
97
|
-
|
|
96
|
+
off: 0,
|
|
98
97
|
/** 正在直播 */
|
|
99
|
-
|
|
98
|
+
live: 1,
|
|
100
99
|
/** 正在轮播 */
|
|
101
|
-
|
|
100
|
+
round: 2,
|
|
102
101
|
/** 被封禁 */
|
|
103
|
-
|
|
102
|
+
banned: -1,
|
|
104
103
|
/** 已上锁 */
|
|
105
|
-
|
|
106
|
-
}
|
|
104
|
+
locked: -2,
|
|
105
|
+
};
|
|
107
106
|
/** 直播间状态 */
|
|
108
|
-
export
|
|
109
|
-
(function (LiveConnectionStatus) {
|
|
107
|
+
export const LiveConnectionStatus = {
|
|
110
108
|
/** 未连接 */
|
|
111
|
-
|
|
109
|
+
off: 0,
|
|
112
110
|
/** 连接中 */
|
|
113
|
-
|
|
111
|
+
connecting: 1,
|
|
114
112
|
/** 连接到服务器 */
|
|
115
|
-
|
|
113
|
+
connected: 2,
|
|
116
114
|
/** 连接到房间 */
|
|
117
|
-
|
|
115
|
+
entered: 3,
|
|
118
116
|
/** 连接失败或断开 */
|
|
119
|
-
|
|
120
|
-
}
|
|
117
|
+
disconnected: -1,
|
|
118
|
+
};
|
|
@@ -4,7 +4,7 @@ import { AppError, ErrorOptions } from "../../error";
|
|
|
4
4
|
import { AppEventListener, AppEventEmitOptions, AppEventDetailMap } from "../../event";
|
|
5
5
|
import { HookUseOptions, HookCallOptions, AppHookMap, HookFunction, HookContext } from "../../hook";
|
|
6
6
|
import { AppValueMap, ValueOptions } from "../../value";
|
|
7
|
-
import type { PluginContext, PluginConstructor, PluginRegisterOptions } from "../types";
|
|
7
|
+
import type { PluginContext, PluginConstructor, PluginRegisterOptions, AppPluginExposesMap } from "../types";
|
|
8
8
|
export declare class CommonPluginContext implements PluginContext {
|
|
9
9
|
#private;
|
|
10
10
|
get safe(): boolean;
|
|
@@ -20,7 +20,7 @@ export declare class CommonPluginContext implements PluginContext {
|
|
|
20
20
|
error(id: string, options: ErrorOptions): AppError;
|
|
21
21
|
register(plugin: PluginConstructor, options?: PluginRegisterOptions): void;
|
|
22
22
|
unregister(pluginName: string): void;
|
|
23
|
-
getPluginExposes<
|
|
23
|
+
getPluginExposes<K extends keyof AppPluginExposesMap>(pluginName: K): AppPluginExposesMap[K];
|
|
24
24
|
whenRegister<T>(pluginName: string, callback: (exposes: any) => (() => void) | undefined): (() => void) | void;
|
|
25
25
|
hasPlugin(pluginName: string): boolean;
|
|
26
26
|
registerValue<K extends keyof AppValueMap>(name: K, options: ValueOptions<AppValueMap[K]>): void;
|
package/dist/plugin/manager.js
CHANGED
|
@@ -40,7 +40,9 @@ export class PluginManager {
|
|
|
40
40
|
const plugin = new pluginConstructor(pluginCtx, registerCtx.options || {});
|
|
41
41
|
// 调用插件的register钩子
|
|
42
42
|
await plugin.register?.(pluginCtx, registerCtx.options || {});
|
|
43
|
-
|
|
43
|
+
// 调用插件的expose钩子
|
|
44
|
+
const exposes = await plugin.expose?.(pluginCtx);
|
|
45
|
+
this.list.set(pluginName, { plugin, context: pluginCtx, exposes });
|
|
44
46
|
this.app.emit("plugin:register", { pluginName });
|
|
45
47
|
return plugin;
|
|
46
48
|
})
|
package/dist/plugin/types.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ import { AppValueMap, ValueOptions } from "../value";
|
|
|
6
6
|
/** 插件对象 */
|
|
7
7
|
export interface PluginItem {
|
|
8
8
|
pluginName: string;
|
|
9
|
-
register?(ctx: PluginContext, options?: Record<string, any>): void
|
|
10
|
-
destroy?(ctx: PluginContext): void
|
|
9
|
+
register?(ctx: PluginContext, options?: Record<string, any>): void | Promise<void>;
|
|
10
|
+
destroy?(ctx: PluginContext): void | Promise<void>;
|
|
11
|
+
expose?(ctx: PluginContext): any;
|
|
11
12
|
}
|
|
12
13
|
/** 插件构造器 */
|
|
13
14
|
export interface PluginConstructor {
|
|
@@ -36,7 +37,7 @@ export interface PluginContext {
|
|
|
36
37
|
/** 取消注册插件 */
|
|
37
38
|
unregister(pluginName: string): void;
|
|
38
39
|
/** 获取插件暴露对象 */
|
|
39
|
-
getPluginExposes<
|
|
40
|
+
getPluginExposes<K extends keyof AppPluginExposesMap>(pluginName: K): AppPluginExposesMap[K];
|
|
40
41
|
/** 等待plugin注册 */
|
|
41
42
|
whenRegister(pluginName: string, callback: (exposes: any) => (() => void) | void): void;
|
|
42
43
|
/** 是否存在插件 */
|
|
@@ -71,3 +72,6 @@ export interface PluginContext {
|
|
|
71
72
|
setValue<K extends keyof AppValueMap>(name: K, value: AppValueMap[K]): void;
|
|
72
73
|
destroy(): void;
|
|
73
74
|
}
|
|
75
|
+
export interface AppPluginExposesMap {
|
|
76
|
+
"": {};
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type EnumValue<T> = T[keyof T];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
package/tsconfig.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["./src/floatinglive.ts","./src/app.ts","./src/index.ts","./src/command/index.ts","./src/command/manager.ts","./src/command/types.ts","./src/error/index.ts","./src/error/types.ts","./src/event/index.ts","./src/event/manager.ts","./src/event/types.ts","./src/hook/index.ts","./src/hook/manager.ts","./src/hook/types.ts","./src/live/index.ts","./src/live/message.ts","./src/live/messageinfo.ts","./src/live/platform.ts","./src/live/room.ts","./src/plugin/index.ts","./src/plugin/manager.ts","./src/plugin/types.ts","./src/plugin/context/commonplugincontext.ts","./src/plugin/context/safeplugincontext.ts","./src/plugins/room/index.ts","./src/utils/eventemitter.ts","./src/utils/index.ts","./src/value/index.ts","./src/value/manager.ts","./src/value/types.ts"],"version":"5.6.3"}
|