Skip to content

Commit 2541b89

Browse files
committed
refactor: type rename
1 parent bb00a21 commit 2541b89

9 files changed

+11
-11
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "blive-message-listener",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"description": "Bilibili-live danmu listener with type",
55
"type": "module",
66
"main": "dist/index.js",

src/listener/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ export type MsgHandler = Partial<
1818
& WatchedChangeHandler
1919
>
2020

21-
const normalizeDanmu = <T>(msgType: string, data: T): Message<T> => {
21+
const normalizeDanmu = <T>(msgType: string, body: T): Message<T> => {
2222
const timestamp = Date.now()
2323
// @ts-ignore
24-
const id = `${timestamp}_${msgType}_${data.user?.uid}`
24+
const id = `${timestamp}_${msgType}_${body.user?.uid}`
2525
return {
2626
id,
2727
timestamp,
2828
type: msgType,
29-
data,
29+
body,
3030
}
3131
}
3232

src/parser/DANMU_MSG.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ export const DANMU_MSG = {
5555
}
5656

5757
export type Handler = {
58-
onIncomeDanmu: (data: Message<DanmuMsg>) => void
58+
onIncomeDanmu: (msg: Message<DanmuMsg>) => void
5959
}

src/parser/GUARD_BUY.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ export const GUARD_BUY = {
3939
}
4040

4141
export type Handler = {
42-
onGuardBuy: (data: Message<GuardBuyMsg>) => void
42+
onGuardBuy: (msg: Message<GuardBuyMsg>) => void
4343
}

src/parser/HEARTBEAT.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ export const HEARTBEAT = {
1818
}
1919

2020
export type Handler = {
21-
onAttentionChange: (data: Message<AttentionChangeMsg>) => void
21+
onAttentionChange: (msg: Message<AttentionChangeMsg>) => void
2222
}

src/parser/SEND_GIFT.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ export const SEND_GIFT = {
5151
}
5252

5353
export type Handler = {
54-
onGift: (data: Message<GiftMsg>) => void
54+
onGift: (msg: Message<GiftMsg>) => void
5555
}

src/parser/SUPER_CHAT_MESSAGE.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ export const SUPER_CHAT_MESSAGE = {
5050
}
5151

5252
export type Handler = {
53-
onIncomeSuperChat: (data: Message<SuperChatMsg>) => void
53+
onIncomeSuperChat: (msg: Message<SuperChatMsg>) => void
5454
}

src/parser/WATCHED_CHANGE.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ export const WATCHED_CHANGE = {
2222
}
2323

2424
export type Handler = {
25-
onWatchedChange: (data: Message<WatchedChangeMsg>) => void
25+
onWatchedChange: (msg: Message<WatchedChangeMsg>) => void
2626
}

src/types/app.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export interface Message<T> {
4848
id: string,
4949
timestamp: number,
5050
type: string,
51-
data: T
51+
body: T
5252
}
5353

5454
export interface BaseMsg {

0 commit comments

Comments
 (0)