floating-live 0.16.0-alpha.13 → 0.16.0-alpha.15

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/app.js CHANGED
@@ -74,7 +74,7 @@ export class App extends CustomEventEmitter {
74
74
  });
75
75
  }
76
76
  getPluginExposes(pluginName) {
77
- this.pluginManager.getExposes(pluginName);
77
+ return this.pluginManager.getExposes(pluginName);
78
78
  }
79
79
  hasPlugin(pluginName) {
80
80
  return this.pluginManager.has(pluginName);
@@ -31,6 +31,8 @@ export declare abstract class LiveRoom extends CustomEventEmitter implements Liv
31
31
  abstract open(): void;
32
32
  /** 关闭连接 */
33
33
  abstract close(): void;
34
+ /** 重连 */
35
+ abstract reconnect?(): void;
34
36
  /** 更新房间数据 */
35
37
  abstract update(): Promise<LiveRoomData>;
36
38
  /** 从服务器获取房间数据 */
@@ -41,10 +43,11 @@ export declare abstract class LiveRoom extends CustomEventEmitter implements Liv
41
43
  destroy(): void;
42
44
  /** 销毁事件 */
43
45
  protected onDestroy?: () => void;
46
+ /** 发送消息 */
44
47
  protected emitMessage(msg: LiveMessage.All): void;
45
48
  /** 发送源消息 */
46
49
  protected emitRaw(msg: any): void;
47
- /** 获取数据 */
50
+ /** 生成房间数据 */
48
51
  toData(): LiveRoomData;
49
52
  get key(): string;
50
53
  }
@@ -119,15 +122,15 @@ export type LiveRoomStatus = EnumValue<typeof LiveRoomStatus>;
119
122
  /** 直播间状态 */
120
123
  export declare const LiveConnectionStatus: {
121
124
  /** 未连接 */
122
- off: number;
125
+ readonly off: 0;
123
126
  /** 连接中 */
124
- connecting: number;
127
+ readonly connecting: 1;
125
128
  /** 连接到服务器 */
126
- connected: number;
129
+ readonly connected: 2;
127
130
  /** 连接到房间 */
128
- entered: number;
131
+ readonly entered: 3;
129
132
  /** 连接失败或断开 */
130
- disconnected: number;
133
+ readonly disconnected: -1;
131
134
  };
132
135
  export type LiveConnectionStatus = EnumValue<typeof LiveConnectionStatus>;
133
136
  export interface LiveRoomEventMap {
package/dist/live/room.js CHANGED
@@ -19,7 +19,7 @@ export class LiveRoom extends CustomEventEmitter {
19
19
  this.close();
20
20
  this.onDestroy?.();
21
21
  }
22
- // 发送消息
22
+ /** 发送消息 */
23
23
  emitMessage(msg) {
24
24
  // 其他消息 => 先更改状态再发送消息
25
25
  // 直播结束消息 => 先发送消息再更改状态
@@ -59,7 +59,7 @@ export class LiveRoom extends CustomEventEmitter {
59
59
  emitRaw(msg) {
60
60
  this.emit("raw", { platform: this.platform, roomId: this.id, data: msg });
61
61
  }
62
- /** 获取数据 */
62
+ /** 生成房间数据 */
63
63
  toData() {
64
64
  return {
65
65
  platform: this.platform,
@@ -107,8 +107,11 @@ export class Room extends BasePlugin {
107
107
  const opt = typeof options == "boolean" ? { open: options } : options || {};
108
108
  const ctx = { platform, id, options: opt };
109
109
  const res = await this.ctx.callHook("room.add", ctx);
110
- if (!res.defaultPrevented) {
111
- this.ctx.throw(this.ctx.error("room:add_fail", { message: "无法添加房间" }));
110
+ if (res.defaultPrevented) {
111
+ this.ctx.throw(this.ctx.error("room:add_hook_prevented", {
112
+ message: "无法添加房间",
113
+ cause: "房间添加被钩子函数阻止",
114
+ }));
112
115
  }
113
116
  const room = await this.ctx.call(`${platform}.room.create`, id, opt);
114
117
  if (!room) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "floating-live",
3
- "version": "0.16.0-alpha.13",
3
+ "version": "0.16.0-alpha.15",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",