@napuketto/adapter 0.13.1 → 0.13.2

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.
@@ -1,5 +1,5 @@
1
1
  import { y as BaseProtocolAdapter } from "../core-CMqpb5-m.mjs";
2
- import { t as forEachRawMessage } from "../raw-message-C1E7jbjl.mjs";
2
+ import { t as forEachRawMessage } from "../raw-message-D2vA27kj.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { ChatType, toCanonicalElements } from "@napuketto/kernel";
5
5
  import { z } from "zod";
@@ -1,7 +1,7 @@
1
1
  import { S as ActionRegistry, a as extractSysMsgEnvelope, c as narrowSysMsgBlobs, d as textOf, f as toHex, l as nodeAt, m as varintOf, p as varintAt, r as decodeProtoTree, u as recognizeSysMsg, y as BaseProtocolAdapter } from "../core-CMqpb5-m.mjs";
2
2
  import { a as MS_TO_SEC$2, i as narrowBuddyReqs, n as extractEssenceSetSysMsg, o as resolveUin, r as narrowEssenceGroupArg, t as diffEssenceList } from "../essence-DzYnP60o.mjs";
3
3
  import { n as firstUntranslatedGrayTip, t as collectGrayTipUids } from "../gray-tip-ByF-MKeV.mjs";
4
- import { n as subscribeRawMessages, t as forEachRawMessage } from "../raw-message-C1E7jbjl.mjs";
4
+ import { r as subscribeRawMessages, t as forEachRawMessage } from "../raw-message-D2vA27kj.mjs";
5
5
  import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, isKernelError, kernelError, toCanonicalElements } from "@napuketto/kernel";
6
6
  import { mkdir, rename, writeFile } from "node:fs/promises";
7
7
  import { join } from "node:path";
@@ -1268,7 +1268,7 @@ function toMessageReceiveEvent(msg, ctx) {
1268
1268
  }
1269
1269
  /** 撤回 grayTip → message_recall 事件(非撤回 grayTip 返回 null)。 */
1270
1270
  function toMessageRecallEvent(msg, ctx) {
1271
- const revoke = (msg.elements.find((el) => el.grayTipElement !== void 0)?.grayTipElement)?.revokeElement;
1271
+ const revoke = (msg.elements.find((el) => el.grayTipElement != null)?.grayTipElement)?.revokeElement;
1272
1272
  if (revoke === void 0) return null;
1273
1273
  const scene = chatTypeToScene(msg.chatType);
1274
1274
  const operatorUin = ctx.uidToUin?.get(revoke.operatorUid) ?? revoke.operatorUid;
@@ -1289,7 +1289,7 @@ function toMessageRecallEvent(msg, ctx) {
1289
1289
  /** 群文件上传事件(群场景文件消息 → group_file_upload,替代 message_receive)。 */
1290
1290
  function toGroupFileUploadEvent(msg, selfUin) {
1291
1291
  if (msg.chatType !== ChatType.GROUP) return null;
1292
- const file = msg.elements.find((el) => el.fileElement !== void 0)?.fileElement;
1292
+ const file = msg.elements.find((el) => el.fileElement != null)?.fileElement;
1293
1293
  if (file === void 0) return null;
1294
1294
  return {
1295
1295
  time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$1),
@@ -1618,7 +1618,7 @@ const peerMessageFields = {
1618
1618
  /** 单条消息 → 接收段(canonical 映射 + forward 段注入,forward 不经 canonical)。 */
1619
1619
  function receiveSegmentsOf(msg, uidToUin) {
1620
1620
  const segments = canonicalToIncomingSegments(toCanonicalElements(msg), { ...uidToUin.size > 0 ? { uidToUin } : {} });
1621
- const fwd = msg.elements.find((el) => el.multiForwardMsgElement !== void 0)?.multiForwardMsgElement;
1621
+ const fwd = msg.elements.find((el) => el.multiForwardMsgElement != null)?.multiForwardMsgElement;
1622
1622
  if (fwd !== void 0) segments.push(incomingForwardSegment(fwd.resId, fwd.fileName));
1623
1623
  return segments;
1624
1624
  }
@@ -1674,7 +1674,7 @@ async function sendFileMessage(api, peer, path, fileName) {
1674
1674
  name: fileName
1675
1675
  }]);
1676
1676
  const [sent] = await api.msgApi.fetchMsgsByMsgId(peer, [msgId]);
1677
- const uuid = (sent?.elements.find((e) => e.fileElement !== void 0))?.fileElement?.fileUuid;
1677
+ const uuid = (sent?.elements.find((e) => e.fileElement != null))?.fileElement?.fileUuid;
1678
1678
  return uuid !== void 0 && uuid !== "" ? uuid : msgId;
1679
1679
  }
1680
1680
  // src/milky/action/group-file.ts
@@ -2248,7 +2248,7 @@ function createMilkyActionRegistry(opts) {
2248
2248
  /** 单条 C2C 文件消息 → 事件载荷(非 C2C / 无 fileElement / 无 fileUuid → null)。 */
2249
2249
  function toFriendFileUploadData(msg, selfUin, uidToUin) {
2250
2250
  if (msg.chatType !== ChatType.C2C) return null;
2251
- const file = msg.elements.find((el) => el.fileElement !== void 0)?.fileElement;
2251
+ const file = msg.elements.find((el) => el.fileElement != null)?.fileElement;
2252
2252
  if (file === void 0 || typeof file.fileUuid !== "string" || file.fileUuid === "") return null;
2253
2253
  const isSelf = msg.sendType === 2 || String(msg.senderUin) === selfUin;
2254
2254
  const userUin = msg.senderUin !== "" ? Number(msg.senderUin) : resolveUin(msg.senderUid, uidToUin);
@@ -2280,7 +2280,7 @@ function envelope(msg, ctx, eventType, data) {
2280
2280
  }
2281
2281
  /** 单个 grayTip → Milky notice 事件(null = 不可翻译)。 */
2282
2282
  function translateGrayTip(msg, g, ctx) {
2283
- if (g.aioOpGrayTipElement !== void 0) return aioOpToEvent(msg, g, ctx);
2283
+ if (g.aioOpGrayTipElement != null) return aioOpToEvent(msg, g, ctx);
2284
2284
  if (g.subElementType === GrayTipSubType.GROUP) return groupElementToEvent(msg, g.groupElement, ctx);
2285
2285
  return null;
2286
2286
  }
@@ -3037,7 +3037,7 @@ var NapukettoMilkyAdapter = class extends BaseProtocolAdapter {
3037
3037
  await this.fillMentionUids(elements, ctx);
3038
3038
  this.fillReplyMeta(elements, ctx);
3039
3039
  await this.fillGroupEntities(msg, ctx);
3040
- const forward = msg.elements.find((el) => el.multiForwardMsgElement !== void 0)?.multiForwardMsgElement;
3040
+ const forward = msg.elements.find((el) => el.multiForwardMsgElement != null)?.multiForwardMsgElement;
3041
3041
  if (forward !== void 0) ctx.forwardSegments = [incomingForwardSegment(forward.resId, forward.fileName)];
3042
3042
  return toMessageReceiveEvent(msg, ctx);
3043
3043
  }
@@ -3064,7 +3064,7 @@ var NapukettoMilkyAdapter = class extends BaseProtocolAdapter {
3064
3064
  }
3065
3065
  /** 转发 resId → 定位登记(get_forwarded_messages 反查用)。 */
3066
3066
  recordForward(msg) {
3067
- const forward = msg.elements.find((el) => el.multiForwardMsgElement !== void 0)?.multiForwardMsgElement;
3067
+ const forward = msg.elements.find((el) => el.multiForwardMsgElement != null)?.multiForwardMsgElement;
3068
3068
  if (forward !== void 0 && forward.resId !== "") this.seqIndex.recordForward(forward.resId, {
3069
3069
  chatType: msg.chatType,
3070
3070
  peerUid: msg.peerUid,
@@ -3274,11 +3274,11 @@ var NapukettoMilkyAdapter = class extends BaseProtocolAdapter {
3274
3274
  };
3275
3275
  /** 是否含 grayTip 元素(与 OB11 收链路同判据)。 */
3276
3276
  function hasGrayTip(msg) {
3277
- return msg.elements.some((el) => el.grayTipElement !== void 0);
3277
+ return msg.elements.some((el) => el.grayTipElement != null);
3278
3278
  }
3279
3279
  /** 撤回 grayTip 元素(非撤回消息返回 undefined)。 */
3280
3280
  function findRevokeElement(msg) {
3281
- return msg.elements.find((el) => el.grayTipElement?.revokeElement !== void 0)?.grayTipElement?.revokeElement;
3281
+ return msg.elements.find((el) => el.grayTipElement?.revokeElement != null)?.grayTipElement?.revokeElement;
3282
3282
  }
3283
3283
  /** 字符串截断(raw 日志防刷屏)。 */
3284
3284
  function truncate(raw) {