floating-live 0.11.0 → 0.11.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/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  export { FloatingLive } from "./src";
2
- export * from "./src/types/message/AttributeInfo";
3
- export * from "./src/types/message/MessageData";
4
- export * from "./src/types/plugin";
5
- export * from "./src/types/room";
2
+ export * from "./src/types";
3
+ export * from "./src/enum";
6
4
  export * from "./src/lib/LiveRoom";
7
5
  export * from "./src/lib/Reglist";
package/index.js CHANGED
@@ -17,9 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.FloatingLive = void 0;
18
18
  var src_1 = require("./src");
19
19
  Object.defineProperty(exports, "FloatingLive", { enumerable: true, get: function () { return src_1.FloatingLive; } });
20
- __exportStar(require("./src/types/message/AttributeInfo"), exports);
21
- __exportStar(require("./src/types/message/MessageData"), exports);
22
- __exportStar(require("./src/types/plugin"), exports);
23
- __exportStar(require("./src/types/room"), exports);
20
+ __exportStar(require("./src/types"), exports);
21
+ __exportStar(require("./src/enum"), exports);
24
22
  __exportStar(require("./src/lib/LiveRoom"), exports);
25
23
  __exportStar(require("./src/lib/Reglist"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "floating-live",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "type": "commonjs",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,6 +1,6 @@
1
- import { MedalInfo, UserInfo } from "../../src/types/message/AttributeInfo";
1
+ import { MedalInfo, UserInfo } from "../..";
2
2
  import AcClient from "acfun-live-danmaku/client";
3
- import { LiveRoom, RoomStatsInfo, RoomViewInfo } from "../../src/lib/LiveRoom";
3
+ import { LiveRoom, RoomStatsInfo, RoomViewInfo } from "../..";
4
4
  declare type ZtLiveUserInfo = {
5
5
  userIdentity: {
6
6
  managerType?: number;
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const acfun_live_danmaku_1 = __importDefault(require("acfun-live-danmaku"));
7
- const LiveRoom_1 = require("../../src/lib/LiveRoom");
8
- const enum_1 = require("../../src/enum");
7
+ const __1 = require("../..");
8
+ const __2 = require("../..");
9
9
  // 获取当前时间戳,以替代无法从数据中获取时间戳的情况,精度为1s
10
10
  function getDateTimestamp() {
11
11
  return Math.floor(Date.now() / 1000) * 1000;
@@ -18,7 +18,7 @@ function stringToNumber(num) {
18
18
  return parseFloat(num);
19
19
  }
20
20
  }
21
- class acfunLive extends LiveRoom_1.LiveRoom {
21
+ class acfunLive extends __1.LiveRoom {
22
22
  constructor(id, open = false) {
23
23
  super();
24
24
  /** 平台id */
@@ -65,7 +65,7 @@ class acfunLive extends LiveRoom_1.LiveRoom {
65
65
  if (!this.client) {
66
66
  this.client = await (0, acfun_live_danmaku_1.default)(this.id) || null;
67
67
  if (this.client) {
68
- this.status = enum_1.RoomStatus.live;
68
+ this.status = __2.RoomStatus.live;
69
69
  this.timestamp = this.client.liveStartTime;
70
70
  this.view.title = this.client.caption; // bug
71
71
  this.view.cover = `https://tx2.a.kwimgs.com/bs2/ztlc/cover_${this.client.liveId}_raw.jpg`;
@@ -105,7 +105,7 @@ class acfunLive extends LiveRoom_1.LiveRoom {
105
105
  let client = this.client;
106
106
  client.on("EnterRoomAck", () => {
107
107
  console.log("[acfun-live-danmaku] 已连接AcFun直播间");
108
- this.status = enum_1.RoomStatus.live;
108
+ this.status = __2.RoomStatus.live;
109
109
  });
110
110
  client.on("RecentComment", (comments) => {
111
111
  //当前弹幕列表
@@ -153,10 +153,10 @@ class acfunLive extends LiveRoom_1.LiveRoom {
153
153
  getUser(user) {
154
154
  let identity = null;
155
155
  if (user.userIdentity?.managerType == 1) {
156
- identity = enum_1.UserAdmin.admin;
156
+ identity = __2.UserAdmin.admin;
157
157
  }
158
158
  else if (parseInt(user.userId) == this.anchor.id) {
159
- identity = enum_1.UserAdmin.anchor;
159
+ identity = __2.UserAdmin.anchor;
160
160
  }
161
161
  return {
162
162
  name: user.nickname,
@@ -220,7 +220,7 @@ class acfunLive extends LiveRoom_1.LiveRoom {
220
220
  type: "live_end",
221
221
  timestamp: getDateTimestamp(),
222
222
  info: {
223
- status: enum_1.RoomStatus.off
223
+ status: __2.RoomStatus.off
224
224
  }
225
225
  };
226
226
  this.client = null;
@@ -1,6 +1,6 @@
1
- import { UserInfo } from "../../src/types/message/AttributeInfo";
1
+ import { UserInfo } from "../..";
2
2
  import { KeepLiveWS } from "bilibili-live-ws";
3
- import { LiveRoom, RoomStatsInfo, RoomViewInfo } from "../../src/lib/LiveRoom";
3
+ import { LiveRoom, RoomStatsInfo, RoomViewInfo } from "../..";
4
4
  declare class bilibiliLive extends LiveRoom {
5
5
  /** 平台id */
6
6
  readonly platform: string;
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const enum_1 = require("./../../src/enum");
3
+ const __1 = require("../..");
4
4
  const bilibili_live_ws_1 = require("bilibili-live-ws");
5
- const LiveRoom_1 = require("../../src/lib/LiveRoom");
5
+ const __2 = require("../..");
6
6
  // utils
7
7
  // 获取当前时间戳,以替代无法从数据中获取时间戳的情况,精度为1s
8
8
  function getDateTimestamp() {
9
9
  return Math.floor(Date.now() / 1000) * 1000;
10
10
  }
11
- class bilibiliLive extends LiveRoom_1.LiveRoom {
11
+ class bilibiliLive extends __2.LiveRoom {
12
12
  constructor(id, // 房间id
13
13
  open = false, // 生成房间后是否打开
14
14
  config) {
@@ -58,8 +58,8 @@ class bilibiliLive extends LiveRoom_1.LiveRoom {
58
58
  .then((res) => {
59
59
  const { room_info, anchor_info } = res.data;
60
60
  this.roomid = room_info.room_id;
61
- this.status = room_info.live_status == 1 ? enum_1.RoomStatus.live : enum_1.RoomStatus.off;
62
- this.timestamp = this.status == enum_1.RoomStatus.live ? room_info.live_start_time * 1000 : refresh ? Date.now() : this.timestamp;
61
+ this.status = room_info.live_status == 1 ? __1.RoomStatus.live : __1.RoomStatus.off;
62
+ this.timestamp = this.status == __1.RoomStatus.live ? room_info.live_start_time * 1000 : refresh ? Date.now() : this.timestamp;
63
63
  this.view.title = room_info.title;
64
64
  this.view.area = [room_info.parent_area_name, room_info.area_name];
65
65
  this.view.cover = room_info.cover;
@@ -163,10 +163,10 @@ class bilibiliLive extends LiveRoom_1.LiveRoom {
163
163
  }
164
164
  }
165
165
  if (msg.info[2][2]) {
166
- identity = enum_1.UserAdmin.admin;
166
+ identity = __1.UserAdmin.admin;
167
167
  }
168
168
  else if (uid == this.anchor.id) {
169
- identity = enum_1.UserAdmin.anchor;
169
+ identity = __1.UserAdmin.anchor;
170
170
  }
171
171
  let danmaku = {
172
172
  platform: "bilibili",
@@ -181,7 +181,7 @@ class bilibiliLive extends LiveRoom_1.LiveRoom {
181
181
  name: content,
182
182
  id: msg.info[0][13].emoticon_unique,
183
183
  url: msg.info[0][13].url,
184
- size: msg.info[0][13].width == msg.info[0][13].height ? enum_1.ImageSize.large : enum_1.ImageSize.small,
184
+ size: msg.info[0][13].width == msg.info[0][13].height ? __1.ImageSize.large : __1.ImageSize.small,
185
185
  } : undefined,
186
186
  emoticon: emoticon,
187
187
  user: {
@@ -372,7 +372,7 @@ class bilibiliLive extends LiveRoom_1.LiveRoom {
372
372
  name: data.uname
373
373
  },
374
374
  operator: {
375
- admin: data.operator == 2 ? enum_1.UserAdmin.anchor : enum_1.UserAdmin.admin
375
+ admin: data.operator == 2 ? __1.UserAdmin.anchor : __1.UserAdmin.admin
376
376
  }
377
377
  },
378
378
  };
@@ -413,7 +413,7 @@ class bilibiliLive extends LiveRoom_1.LiveRoom {
413
413
  type: "live_end",
414
414
  timestamp: getDateTimestamp(),
415
415
  info: {
416
- status: msg.round ? enum_1.RoomStatus.round : enum_1.RoomStatus.off
416
+ status: msg.round ? __1.RoomStatus.round : __1.RoomStatus.off
417
417
  }
418
418
  };
419
419
  this.emitMsg(off);
@@ -1,4 +1,4 @@
1
- import { FloatingLive } from "../../src/index";
1
+ import { FloatingLive } from "../..";
2
2
  declare const _default: () => {
3
3
  register: (ctx: FloatingLive) => void;
4
4
  };
@@ -1,6 +1,6 @@
1
1
  import { FloatingLive } from "../..";
2
- import { UserInfo } from "../../src/types/message/AttributeInfo";
3
- import { MessageData } from "../../src/types/message/MessageData";
2
+ import { UserInfo } from "../..";
3
+ import { MessageData } from "../..";
4
4
  export declare class chatPrint {
5
5
  /** 主模块 */
6
6
  main: FloatingLive;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.chatPrint = void 0;
4
- const enum_1 = require("../../src/enum");
4
+ const __1 = require("../..");
5
5
  class chatPrint {
6
6
  constructor(main) {
7
7
  this.main = main;
@@ -15,7 +15,7 @@ class chatPrint {
15
15
  let name = `${"\x1b[33m"}${user.name}`; // 用户名
16
16
  let medal = user.medal ? `${"\x1b[32m"}[${user.medal.name}(${user.medal.level})] ` : ""; // 粉丝牌
17
17
  let membership = user.membership ? `${"\x1b[36m"}[${this.getPriviliegeName(message.platform, user.membership)}]` : ""; // 特权粉丝
18
- let admin = user.admin ? `${"\x1b[95m"}[${{ [enum_1.UserAdmin.admin]: "房管", [enum_1.UserAdmin.anchor]: "主播" }[user.admin]}]` : ""; // 房管
18
+ let admin = user.admin ? `${"\x1b[95m"}[${{ [__1.UserAdmin.admin]: "房管", [__1.UserAdmin.anchor]: "主播" }[user.admin]}]` : ""; // 房管
19
19
  return `${medal}${membership}${admin}${name}${"\x1b[0m"}`; //[粉丝牌(等级)] [特权][房管]用户名
20
20
  }
21
21
  /** 获取特权粉丝名称 */
@@ -81,7 +81,7 @@ class chatPrint {
81
81
  }
82
82
  case "block": {
83
83
  let user = this.getUserInfo(message);
84
- let operator = message.info.operator.admin ? { [enum_1.UserAdmin.admin]: "房管", [enum_1.UserAdmin.anchor]: "主播" }[message.info.operator.admin] : "管理员";
84
+ let operator = message.info.operator.admin ? { [__1.UserAdmin.admin]: "房管", [__1.UserAdmin.anchor]: "主播" }[message.info.operator.admin] : "管理员";
85
85
  console.log(`${user} 已被${operator}禁言`);
86
86
  break;
87
87
  }
@@ -1,4 +1,4 @@
1
- import { FloatingLive } from "../../src";
1
+ import { FloatingLive } from "../..";
2
2
  import { chatPrint } from "./chatPrint";
3
3
  declare const _default: () => {
4
4
  register: (ctx: FloatingLive) => chatPrint;
@@ -1,4 +1,4 @@
1
- import { FloatingLive } from "../../src";
1
+ import { FloatingLive } from "../..";
2
2
  declare const _default: () => {
3
3
  register: (ctx: FloatingLive) => void;
4
4
  };
@@ -1,5 +1,5 @@
1
- import { FloatingLive } from "../../src";
2
- import MsgSave from "../msgSave/msgSave";
1
+ import { FloatingLive } from "../..";
2
+ import MsgSave from "./msgSave";
3
3
  export declare const messageSave: () => {
4
4
  register: (ctx: FloatingLive) => MsgSave;
5
5
  };
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.messageSaveOrigin = exports.messageSave = void 0;
7
- const msgSave_1 = __importDefault(require("../msgSave/msgSave"));
7
+ const msgSave_1 = __importDefault(require("./msgSave"));
8
8
  const messageSave = () => {
9
9
  return {
10
10
  register: (ctx) => {
@@ -1,4 +1,4 @@
1
- import { RoomStatus } from './../../src/enum';
1
+ import { RoomStatus } from '../..';
2
2
  import { FloatingLive } from "../..";
3
3
  interface SaveInfoConfig {
4
4
  platform: string;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const enum_1 = require("./../../src/enum");
6
+ const __1 = require("../..");
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  function getTimeStr(timestamp) {
@@ -14,7 +14,7 @@ function getTimeStr(timestamp) {
14
14
  * S=直播开始 L=直播中 E=直播结束 O=未开播
15
15
  */
16
16
  function getRecordStatus(status, statusChanged) {
17
- if (status == enum_1.RoomStatus.live) {
17
+ if (status == __1.RoomStatus.live) {
18
18
  /** 已开播 */
19
19
  return statusChanged ? "S" : "L";
20
20
  }
@@ -110,7 +110,7 @@ class MsgSave {
110
110
  }
111
111
  /** 创建保存信息,用于记录信息可能不存在的情况 */
112
112
  createSaveInfo({ platform, room }) {
113
- const { status, timestamp } = this.main.room.get(`${platform}:${room}`)?.info || { status: enum_1.RoomStatus.off, timestamp: 0 };
113
+ const { status, timestamp } = this.main.room.get(`${platform}:${room}`)?.info || { status: __1.RoomStatus.off, timestamp: 0 };
114
114
  const saveInfoConfig = {
115
115
  platform,
116
116
  room, status,