@napuketto/adapter 0.13.0 → 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.
- package/dist/core/index.d.mts +2 -2
- package/dist/core/index.mjs +1 -1
- package/dist/{core-DgDKwUWD.mjs → core-CMqpb5-m.mjs} +24 -2
- package/dist/core-CMqpb5-m.mjs.map +1 -0
- package/dist/{essence-DsSHdIZQ.mjs → essence-DzYnP60o.mjs} +2 -2
- package/dist/{essence-DsSHdIZQ.mjs.map → essence-DzYnP60o.mjs.map} +1 -1
- package/dist/{index-B5uhdmil.d.mts → index-DDPMbC_c.d.mts} +17 -2
- package/dist/index-DDPMbC_c.d.mts.map +1 -0
- package/dist/kurobot/index.d.mts +1 -1
- package/dist/kurobot/index.mjs +2 -2
- package/dist/milky/index.d.mts +1 -1
- package/dist/milky/index.mjs +13 -13
- package/dist/milky/index.mjs.map +1 -1
- package/dist/onebot11/index.d.mts +1 -1
- package/dist/onebot11/index.mjs +31 -27
- package/dist/onebot11/index.mjs.map +1 -1
- package/dist/raw-message-D2vA27kj.mjs +31 -0
- package/dist/raw-message-D2vA27kj.mjs.map +1 -0
- package/dist/satori/index.d.mts +1 -1
- package/dist/satori/index.mjs +4 -4
- package/dist/satori/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/core-DgDKwUWD.mjs.map +0 -1
- package/dist/index-B5uhdmil.d.mts.map +0 -1
- package/dist/raw-message-C1E7jbjl.mjs +0 -18
- package/dist/raw-message-C1E7jbjl.mjs.map +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/core/shared/raw-message.ts
|
|
2
|
+
/** 空串视为缺失(Linux 原生对象常给 "" 而不是省略字段)。 */
|
|
3
|
+
function firstNonEmpty(...values) {
|
|
4
|
+
for (const value of values) if (value !== void 0 && value !== "") return value;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 发送者显示名(跨平台字段名不同,2026-11-10 Linux 原生 wrapper 实测):
|
|
8
|
+
* - Windows:`sendNickName` = 昵称,`sendMemberName` = 群名片(可空);
|
|
9
|
+
* - Linux:`sendNickName` 为空串,显示名放在 `sendMemberName`。
|
|
10
|
+
* 优先昵称,空则回退群名片——否则 Linux 入站 `sender.nickname` 恒为空。
|
|
11
|
+
*/
|
|
12
|
+
function senderNickname(msg) {
|
|
13
|
+
return firstNonEmpty(msg.sendNickName, msg.sendMemberName) ?? "";
|
|
14
|
+
}
|
|
15
|
+
/** 逐条处理消息(自动规范化数组 + 过滤非对象项)。 */
|
|
16
|
+
function forEachRawMessage(msgs, handler) {
|
|
17
|
+
const list = Array.isArray(msgs) ? msgs : [msgs];
|
|
18
|
+
for (const msg of list) {
|
|
19
|
+
if (!msg || typeof msg !== "object") continue;
|
|
20
|
+
handler(msg);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** 订阅 Msg/onRecvMsg(回调参数数组规范化为逐条;返回退订函数,各协议适配器共用)。 */
|
|
24
|
+
function subscribeRawMessages(channel, handler) {
|
|
25
|
+
return channel.on("Msg/onRecvMsg", (msgs) => {
|
|
26
|
+
forEachRawMessage(msgs, handler);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export { senderNickname as n, subscribeRawMessages as r, forEachRawMessage as t };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=raw-message-D2vA27kj.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw-message-D2vA27kj.mjs","names":[],"sources":["../src/core/shared/raw-message.ts"],"sourcesContent":["/**\n * RawMessage 数组规范化(OB11 / Satori 共用,2026-08-08 克隆合并)\n *\n * onRecvMsg 回调参数运行时实证为消息数组(2026-08-07),但兼容单条对象\n * 传入——统一规范化为数组并过滤无效项后逐条回调。\n */\nimport type { MsgEventChannel, RawMessage } from \"@napuketto/kernel\";\n\n/** 空串视为缺失(Linux 原生对象常给 \"\" 而不是省略字段)。 */\nfunction firstNonEmpty(...values: (string | undefined)[]): string | undefined {\n for (const value of values) {\n if (value !== undefined && value !== \"\") {\n return value;\n }\n }\n return undefined;\n}\n\n/**\n * 发送者显示名(跨平台字段名不同,2026-11-10 Linux 原生 wrapper 实测):\n * - Windows:`sendNickName` = 昵称,`sendMemberName` = 群名片(可空);\n * - Linux:`sendNickName` 为空串,显示名放在 `sendMemberName`。\n * 优先昵称,空则回退群名片——否则 Linux 入站 `sender.nickname` 恒为空。\n */\nexport function senderNickname(msg: RawMessage): string {\n return firstNonEmpty(msg.sendNickName, msg.sendMemberName) ?? \"\";\n}\n\n/** 逐条处理消息(自动规范化数组 + 过滤非对象项)。 */\nexport function forEachRawMessage(msgs: unknown, handler: (msg: RawMessage) => void): void {\n const list = Array.isArray(msgs) ? msgs : [msgs];\n for (const msg of list) {\n if (!msg || typeof msg !== \"object\") {\n continue;\n }\n handler(msg as RawMessage);\n }\n}\n\n/** 订阅 Msg/onRecvMsg(回调参数数组规范化为逐条;返回退订函数,各协议适配器共用)。 */\nexport function subscribeRawMessages(\n channel: MsgEventChannel,\n handler: (msg: RawMessage) => void,\n): () => void {\n return channel.on(\"Msg/onRecvMsg\", (msgs) => {\n forEachRawMessage(msgs, handler);\n });\n}\n"],"mappings":";;AASA,SAAS,cAAc,GAAG,QAAoD;CAC1E,KAAK,MAAM,SAAS,QAChB,IAAI,UAAU,KAAA,KAAa,UAAU,IACjC,OAAO;AAInB;;;;;;;AAQA,SAAgB,eAAe,KAAyB;CACpD,OAAO,cAAc,IAAI,cAAc,IAAI,cAAc,KAAK;AAClE;;AAGA,SAAgB,kBAAkB,MAAe,SAA0C;CACvF,MAAM,OAAO,MAAM,QAAQ,IAAI,IAAI,OAAO,CAAC,IAAI;CAC/C,KAAK,MAAM,OAAO,MAAM;EACpB,IAAI,CAAC,OAAO,OAAO,QAAQ,UACvB;EAEJ,QAAQ,GAAiB;CAC7B;AACJ;;AAGA,SAAgB,qBACZ,SACA,SACU;CACV,OAAO,QAAQ,GAAG,kBAAkB,SAAS;EACzC,kBAAkB,MAAM,OAAO;CACnC,CAAC;AACL"}
|
package/dist/satori/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Satori 协议适配器(P5,2026-08-08)
|
|
3
3
|
* 公共面:类型 + 动作注册表 + 配置 schema + 传输装配 + 适配器。
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { D as ActionRegistry, S as BaseProtocolAdapter, w as ProtocolConfig } from "../index-DDPMbC_c.mjs";
|
|
6
6
|
import "../gray-tip-CcpfI1Og.mjs";
|
|
7
7
|
import { CanonicalElement, FriendApi, GroupApi, GroupCache, GroupNotifyApi, KernelErrorCode, MsgApi, MsgEventChannel, Peer, ProfileApi } from "@napuketto/kernel";
|
|
8
8
|
import { ZodType, z } from "zod";
|
package/dist/satori/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as forEachRawMessage } from "../raw-message-
|
|
1
|
+
import { S as ActionRegistry, g as ensureSilk, y as BaseProtocolAdapter } from "../core-CMqpb5-m.mjs";
|
|
2
|
+
import { t as forEachRawMessage } from "../raw-message-D2vA27kj.mjs";
|
|
3
3
|
import { t as collectGrayTipUids } from "../gray-tip-ByF-MKeV.mjs";
|
|
4
4
|
import { n as createWsServerSchema, t as createHttpServerSchema } from "../transport-schema-BEzr06W3.mjs";
|
|
5
5
|
import { ChatType, GrayTipSubType, NTGroupRequestOperateTypes, TipGroupElementType, isKernelError, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
@@ -1553,7 +1553,7 @@ async function toSatoriMessageEvent(raw, deps) {
|
|
|
1553
1553
|
function hasSatoriGrayTip(raw) {
|
|
1554
1554
|
for (const el of raw.elements) {
|
|
1555
1555
|
const g = el.grayTipElement;
|
|
1556
|
-
if (g
|
|
1556
|
+
if (g == null) continue;
|
|
1557
1557
|
if (g.subElementType === GrayTipSubType.REVOKE || g.subElementType === GrayTipSubType.GROUP) return true;
|
|
1558
1558
|
}
|
|
1559
1559
|
return false;
|
|
@@ -1568,7 +1568,7 @@ function isGroupMessage(raw) {
|
|
|
1568
1568
|
async function toSatoriGrayTipEvent(raw, uidToUinMap) {
|
|
1569
1569
|
for (const el of raw.elements) {
|
|
1570
1570
|
const g = el.grayTipElement;
|
|
1571
|
-
if (g
|
|
1571
|
+
if (g == null) continue;
|
|
1572
1572
|
if (g.subElementType === GrayTipSubType.REVOKE) {
|
|
1573
1573
|
const revoked = toRevokeEvent(raw, uidToUinMap);
|
|
1574
1574
|
if (revoked !== null) return revoked;
|