diff --git a/biome.json b/biome.json
index 4fab0c6..897c2a7 100644
--- a/biome.json
+++ b/biome.json
@@ -2,8 +2,7 @@
"formatter": {
"enabled": true,
"indentStyle": "space",
- "indentSize": 2,
- "lineWidth": 180
+ "indentWidth": 2
},
"javascript": {
"formatter": {
@@ -16,9 +15,6 @@
"enabled": true,
"rules": {
"recommended": true,
- "style": {
- "noImplicitBoolean": "off"
- },
"suspicious": {
"noExplicitAny": "off"
}
diff --git a/example/browser/src.ts b/example/browser/src.ts
index e7cfbed..9dafcec 100644
--- a/example/browser/src.ts
+++ b/example/browser/src.ts
@@ -2,20 +2,24 @@ import { startListen } from 'blive-message-listener/browser'
import type { MsgHandler } from 'blive-message-listener'
const logDom = document.getElementById('log')
+if (!logDom) {
+ throw new Error('log dom not found')
+}
const handler: MsgHandler = {
onStartListen: () => {
console.log('start listen')
- logDom!.innerHTML += 'start listen
'
+ logDom.innerHTML += 'start listen
'
},
onIncomeDanmu: (msg) => {
console.log(msg)
- logDom!.innerHTML += `${JSON.stringify(msg.body)}
`
+ logDom.innerHTML += `${JSON.stringify(msg.body)}
`
},
raw: {
+
INTERACT_WORD: (msg) => {
console.log(msg)
- logDom!.innerHTML += `${JSON.stringify(msg)}
`
+ logDom.innerHTML += `${JSON.stringify(msg)}
`
},
},
}
diff --git a/src/listener/index.ts b/src/listener/index.ts
index 84a1cb6..edf700c 100644
--- a/src/listener/index.ts
+++ b/src/listener/index.ts
@@ -306,9 +306,9 @@ export const listenAll = (instance: KeepLiveTCP | KeepLiveWS | KeepLiveWSB, room
}
// Rest raw events
- rawHandlerNames.forEach((eventName) => {
+ for (const eventName of rawHandlerNames) {
instance.on(eventName as any, (data: WSMessage) => {
- rawHandler[eventName](data.data)
+ rawHandler[eventName]?.(data.data)
})
- })
+ }
}
diff --git a/src/parser/INTERACT_WORD_ENTRY_EFFECT.ts b/src/parser/INTERACT_WORD_ENTRY_EFFECT.ts
index 53dcec2..573ac53 100644
--- a/src/parser/INTERACT_WORD_ENTRY_EFFECT.ts
+++ b/src/parser/INTERACT_WORD_ENTRY_EFFECT.ts
@@ -106,12 +106,12 @@ const parser = (data: any, roomId: number): UserActionMsg => {
const msgType = data.cmd
if (msgType === 'ENTRY_EFFECT') {
return parserGuard(data, roomId)
- } else if (msgType === 'LIKE_INFO_V3_CLICK') {
+ }
+ if (msgType === 'LIKE_INFO_V3_CLICK') {
return parserLike(data, roomId)
- } else {
- // INTERACT_WORD
- return parserNormal(data, roomId)
}
+ // INTERACT_WORD
+ return parserNormal(data, roomId)
}
export const INTERACT_WORD = {