@napuketto/adapter 0.0.12 → 0.0.13
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/README.md +3 -2
- package/dist/core/index.d.mts +2 -2
- package/dist/core/index.mjs +2 -2
- package/dist/{core-DE2jZQR7.mjs → core-of7sLiQX.mjs} +36 -2
- package/dist/core-of7sLiQX.mjs.map +1 -0
- package/dist/{index-Dv6QGLkY.d.mts → index-CDKj-jus.d.mts} +9 -2
- package/dist/index-CDKj-jus.d.mts.map +1 -0
- package/dist/onebot11/index.d.mts +1 -1
- package/dist/onebot11/index.mjs +12 -1
- package/dist/onebot11/index.mjs.map +1 -1
- package/dist/satori/index.d.mts +1 -1
- package/dist/satori/index.mjs +3 -24
- package/dist/satori/index.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/core-DE2jZQR7.mjs.map +0 -1
- package/dist/index-Dv6QGLkY.d.mts.map +0 -1
package/dist/satori/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as ProtocolConfig, n as BaseProtocolAdapter, s as ActionRegistry } from "../index-CDKj-jus.mjs";
|
|
2
2
|
import "../gray-tip-CcpfI1Og.mjs";
|
|
3
3
|
import { CanonicalElement, FriendApi, GroupApi, GroupCache, GroupNotifyApi, KernelErrorCode, MsgApi, MsgEventChannel, Peer, ProfileApi } from "@napuketto/kernel";
|
|
4
4
|
import { ZodType, z } from "zod";
|
package/dist/satori/index.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as ActionRegistry, r as BaseProtocolAdapter, t as ensureSilk } from "../core-of7sLiQX.mjs";
|
|
2
2
|
import { i as createWsServerSchema, n as collectGrayTipUids, r as createHttpServerSchema, t as forEachRawMessage } from "../raw-message-DfHdOVHi.mjs";
|
|
3
3
|
import { ChatType, GrayTipSubType, NTGroupRequestOperateTypes, TipGroupElementType, isKernelError, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
4
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
4
5
|
import { z } from "zod";
|
|
5
6
|
import { join } from "node:path";
|
|
6
7
|
import { HttpServer, WsServer } from "@napuketto/network";
|
|
7
|
-
import { mkdir, open, writeFile } from "node:fs/promises";
|
|
8
|
-
import { encodePcmToSilk } from "@napuketto/media";
|
|
9
8
|
//#region src/satori/helper/config.ts
|
|
10
9
|
/**
|
|
11
10
|
* Satori 协议配置(zod schema,归属本包,ADR-012)
|
|
@@ -538,7 +537,7 @@ function renderElement(el) {
|
|
|
538
537
|
* Satori 发方向资源处理(从 element-convert.ts 拆分,2026-08-08 FTA 优化)
|
|
539
538
|
*
|
|
540
539
|
* - resolveAsset:internal: 路径 / http(s) 下载 / 本地路径原样
|
|
541
|
-
* - ensureSilk
|
|
540
|
+
* - ensureSilk 已上移到 adapter core(core/media.ts,onebot11/satori 共用)
|
|
542
541
|
*/
|
|
543
542
|
/** internal:{platform}/{user.id}/{path} → 本地路径(取 _tmp 之后的路径,回落 cacheDir)。 */
|
|
544
543
|
function resolveInternalPath(src) {
|
|
@@ -576,26 +575,6 @@ async function downloadAsset(url, cacheDir) {
|
|
|
576
575
|
await writeFile(filePath, buf);
|
|
577
576
|
return filePath;
|
|
578
577
|
}
|
|
579
|
-
/** 语音转码:非 silk 输入(任意音频格式,经 media 归一化)转 silk(QQ 语音格式)。 */
|
|
580
|
-
async function ensureSilk(path) {
|
|
581
|
-
try {
|
|
582
|
-
if ((await readFileHead(path)).startsWith("#!SILK")) return path;
|
|
583
|
-
return await encodePcmToSilk(path);
|
|
584
|
-
} catch {
|
|
585
|
-
return path;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
/** 读文件头 8 字节(判断格式)。 */
|
|
589
|
-
async function readFileHead(path) {
|
|
590
|
-
const handle = await open(path, "r");
|
|
591
|
-
try {
|
|
592
|
-
const buf = Buffer.alloc(8);
|
|
593
|
-
await handle.read(buf, 0, 8, 0);
|
|
594
|
-
return buf.toString("utf8");
|
|
595
|
-
} finally {
|
|
596
|
-
await handle.close();
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
578
|
//#endregion
|
|
600
579
|
//#region src/satori/helper/element/media-convert.ts
|
|
601
580
|
/** 解析元素媒体 src(空 → null 忽略),返回本地路径。 */
|