liangzimixin 0.3.36 → 0.3.37
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/index.cjs +63 -3
- package/dist/setup-entry.cjs +63 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -17956,6 +17956,56 @@ function detectFileType(fileName) {
|
|
|
17956
17956
|
if (VIDEO_EXTS.has(ext)) return "video";
|
|
17957
17957
|
return "file";
|
|
17958
17958
|
}
|
|
17959
|
+
var MIME_MAP = {
|
|
17960
|
+
// 图片
|
|
17961
|
+
".jpg": "image/jpeg",
|
|
17962
|
+
".jpeg": "image/jpeg",
|
|
17963
|
+
".png": "image/png",
|
|
17964
|
+
".gif": "image/gif",
|
|
17965
|
+
".bmp": "image/bmp",
|
|
17966
|
+
".webp": "image/webp",
|
|
17967
|
+
".svg": "image/svg+xml",
|
|
17968
|
+
".ico": "image/x-icon",
|
|
17969
|
+
".tiff": "image/tiff",
|
|
17970
|
+
".tif": "image/tiff",
|
|
17971
|
+
// 音频
|
|
17972
|
+
".mp3": "audio/mpeg",
|
|
17973
|
+
".wav": "audio/wav",
|
|
17974
|
+
".ogg": "audio/ogg",
|
|
17975
|
+
".opus": "audio/opus",
|
|
17976
|
+
".flac": "audio/flac",
|
|
17977
|
+
".aac": "audio/aac",
|
|
17978
|
+
".m4a": "audio/mp4",
|
|
17979
|
+
".wma": "audio/x-ms-wma",
|
|
17980
|
+
// 视频
|
|
17981
|
+
".mp4": "video/mp4",
|
|
17982
|
+
".mov": "video/quicktime",
|
|
17983
|
+
".avi": "video/x-msvideo",
|
|
17984
|
+
".mkv": "video/x-matroska",
|
|
17985
|
+
".wmv": "video/x-ms-wmv",
|
|
17986
|
+
".flv": "video/x-flv",
|
|
17987
|
+
".webm": "video/webm",
|
|
17988
|
+
".m4v": "video/mp4",
|
|
17989
|
+
// 文档
|
|
17990
|
+
".pdf": "application/pdf",
|
|
17991
|
+
".doc": "application/msword",
|
|
17992
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
17993
|
+
".xls": "application/vnd.ms-excel",
|
|
17994
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
17995
|
+
".ppt": "application/vnd.ms-powerpoint",
|
|
17996
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
17997
|
+
".txt": "text/plain",
|
|
17998
|
+
".csv": "text/csv",
|
|
17999
|
+
".json": "application/json",
|
|
18000
|
+
".zip": "application/zip",
|
|
18001
|
+
".rar": "application/x-rar-compressed",
|
|
18002
|
+
".7z": "application/x-7z-compressed",
|
|
18003
|
+
".gz": "application/gzip"
|
|
18004
|
+
};
|
|
18005
|
+
function inferMimeType(fileName) {
|
|
18006
|
+
const ext = path.extname(fileName).toLowerCase();
|
|
18007
|
+
return MIME_MAP[ext] || "application/octet-stream";
|
|
18008
|
+
}
|
|
17959
18009
|
async function resolveAndUploadMedia(params) {
|
|
17960
18010
|
const {
|
|
17961
18011
|
mediaUrl,
|
|
@@ -18005,12 +18055,14 @@ async function resolveAndUploadMedia(params) {
|
|
|
18005
18055
|
});
|
|
18006
18056
|
}
|
|
18007
18057
|
const fileType = detectFileType(fileName);
|
|
18008
|
-
|
|
18058
|
+
const mimeType = inferMimeType(fileName);
|
|
18059
|
+
log3.info("media:fileType", { fileName, fileType, mimeType });
|
|
18009
18060
|
let uploadResult;
|
|
18010
18061
|
try {
|
|
18011
18062
|
uploadResult = await uploadMedia({
|
|
18012
18063
|
file: buffer,
|
|
18013
18064
|
fileName,
|
|
18065
|
+
mimeType,
|
|
18014
18066
|
tokenManager,
|
|
18015
18067
|
serverUrl,
|
|
18016
18068
|
maxFileSizeMb,
|
|
@@ -18027,7 +18079,14 @@ async function resolveAndUploadMedia(params) {
|
|
|
18027
18079
|
};
|
|
18028
18080
|
}
|
|
18029
18081
|
const msgType = fileType;
|
|
18030
|
-
|
|
18082
|
+
let contentPayload;
|
|
18083
|
+
if (fileType === "file") {
|
|
18084
|
+
contentPayload = { fileId: uploadResult.fileKey, fileName, size: uploadResult.fileSize, mimeType };
|
|
18085
|
+
} else if (fileType === "image") {
|
|
18086
|
+
contentPayload = { fileId: uploadResult.fileKey };
|
|
18087
|
+
} else {
|
|
18088
|
+
contentPayload = { fileId: uploadResult.fileKey, mimeType };
|
|
18089
|
+
}
|
|
18031
18090
|
await messagePipe.sendMessage({
|
|
18032
18091
|
chatId,
|
|
18033
18092
|
senderId: chatId,
|
|
@@ -20311,6 +20370,7 @@ var ConnectionManager = class {
|
|
|
20311
20370
|
});
|
|
20312
20371
|
this.client.on("pong", () => {
|
|
20313
20372
|
this.pongReceived = true;
|
|
20373
|
+
log22.info("heartbeat: pong received");
|
|
20314
20374
|
});
|
|
20315
20375
|
}
|
|
20316
20376
|
/** 启动心跳保活 — 定时发送 WebSocket Ping 帧 */
|
|
@@ -20331,7 +20391,7 @@ var ConnectionManager = class {
|
|
|
20331
20391
|
}
|
|
20332
20392
|
this.pongReceived = false;
|
|
20333
20393
|
this.client.ping();
|
|
20334
|
-
log22.
|
|
20394
|
+
log22.info("heartbeat: ping sent");
|
|
20335
20395
|
}, this.options.heartbeatIntervalMs);
|
|
20336
20396
|
}
|
|
20337
20397
|
/** 停止心跳定时器 */
|
package/dist/setup-entry.cjs
CHANGED
|
@@ -4051,6 +4051,56 @@ function detectFileType(fileName) {
|
|
|
4051
4051
|
if (VIDEO_EXTS.has(ext)) return "video";
|
|
4052
4052
|
return "file";
|
|
4053
4053
|
}
|
|
4054
|
+
var MIME_MAP = {
|
|
4055
|
+
// 图片
|
|
4056
|
+
".jpg": "image/jpeg",
|
|
4057
|
+
".jpeg": "image/jpeg",
|
|
4058
|
+
".png": "image/png",
|
|
4059
|
+
".gif": "image/gif",
|
|
4060
|
+
".bmp": "image/bmp",
|
|
4061
|
+
".webp": "image/webp",
|
|
4062
|
+
".svg": "image/svg+xml",
|
|
4063
|
+
".ico": "image/x-icon",
|
|
4064
|
+
".tiff": "image/tiff",
|
|
4065
|
+
".tif": "image/tiff",
|
|
4066
|
+
// 音频
|
|
4067
|
+
".mp3": "audio/mpeg",
|
|
4068
|
+
".wav": "audio/wav",
|
|
4069
|
+
".ogg": "audio/ogg",
|
|
4070
|
+
".opus": "audio/opus",
|
|
4071
|
+
".flac": "audio/flac",
|
|
4072
|
+
".aac": "audio/aac",
|
|
4073
|
+
".m4a": "audio/mp4",
|
|
4074
|
+
".wma": "audio/x-ms-wma",
|
|
4075
|
+
// 视频
|
|
4076
|
+
".mp4": "video/mp4",
|
|
4077
|
+
".mov": "video/quicktime",
|
|
4078
|
+
".avi": "video/x-msvideo",
|
|
4079
|
+
".mkv": "video/x-matroska",
|
|
4080
|
+
".wmv": "video/x-ms-wmv",
|
|
4081
|
+
".flv": "video/x-flv",
|
|
4082
|
+
".webm": "video/webm",
|
|
4083
|
+
".m4v": "video/mp4",
|
|
4084
|
+
// 文档
|
|
4085
|
+
".pdf": "application/pdf",
|
|
4086
|
+
".doc": "application/msword",
|
|
4087
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
4088
|
+
".xls": "application/vnd.ms-excel",
|
|
4089
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
4090
|
+
".ppt": "application/vnd.ms-powerpoint",
|
|
4091
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
4092
|
+
".txt": "text/plain",
|
|
4093
|
+
".csv": "text/csv",
|
|
4094
|
+
".json": "application/json",
|
|
4095
|
+
".zip": "application/zip",
|
|
4096
|
+
".rar": "application/x-rar-compressed",
|
|
4097
|
+
".7z": "application/x-7z-compressed",
|
|
4098
|
+
".gz": "application/gzip"
|
|
4099
|
+
};
|
|
4100
|
+
function inferMimeType(fileName) {
|
|
4101
|
+
const ext = path.extname(fileName).toLowerCase();
|
|
4102
|
+
return MIME_MAP[ext] || "application/octet-stream";
|
|
4103
|
+
}
|
|
4054
4104
|
async function resolveAndUploadMedia(params) {
|
|
4055
4105
|
const {
|
|
4056
4106
|
mediaUrl,
|
|
@@ -4100,12 +4150,14 @@ async function resolveAndUploadMedia(params) {
|
|
|
4100
4150
|
});
|
|
4101
4151
|
}
|
|
4102
4152
|
const fileType = detectFileType(fileName);
|
|
4103
|
-
|
|
4153
|
+
const mimeType = inferMimeType(fileName);
|
|
4154
|
+
log3.info("media:fileType", { fileName, fileType, mimeType });
|
|
4104
4155
|
let uploadResult;
|
|
4105
4156
|
try {
|
|
4106
4157
|
uploadResult = await uploadMedia({
|
|
4107
4158
|
file: buffer,
|
|
4108
4159
|
fileName,
|
|
4160
|
+
mimeType,
|
|
4109
4161
|
tokenManager,
|
|
4110
4162
|
serverUrl,
|
|
4111
4163
|
maxFileSizeMb,
|
|
@@ -4122,7 +4174,14 @@ async function resolveAndUploadMedia(params) {
|
|
|
4122
4174
|
};
|
|
4123
4175
|
}
|
|
4124
4176
|
const msgType = fileType;
|
|
4125
|
-
|
|
4177
|
+
let contentPayload;
|
|
4178
|
+
if (fileType === "file") {
|
|
4179
|
+
contentPayload = { fileId: uploadResult.fileKey, fileName, size: uploadResult.fileSize, mimeType };
|
|
4180
|
+
} else if (fileType === "image") {
|
|
4181
|
+
contentPayload = { fileId: uploadResult.fileKey };
|
|
4182
|
+
} else {
|
|
4183
|
+
contentPayload = { fileId: uploadResult.fileKey, mimeType };
|
|
4184
|
+
}
|
|
4126
4185
|
await messagePipe.sendMessage({
|
|
4127
4186
|
chatId,
|
|
4128
4187
|
senderId: chatId,
|
|
@@ -19370,6 +19429,7 @@ var ConnectionManager = class {
|
|
|
19370
19429
|
});
|
|
19371
19430
|
this.client.on("pong", () => {
|
|
19372
19431
|
this.pongReceived = true;
|
|
19432
|
+
log13.info("heartbeat: pong received");
|
|
19373
19433
|
});
|
|
19374
19434
|
}
|
|
19375
19435
|
/** 启动心跳保活 — 定时发送 WebSocket Ping 帧 */
|
|
@@ -19390,7 +19450,7 @@ var ConnectionManager = class {
|
|
|
19390
19450
|
}
|
|
19391
19451
|
this.pongReceived = false;
|
|
19392
19452
|
this.client.ping();
|
|
19393
|
-
log13.
|
|
19453
|
+
log13.info("heartbeat: ping sent");
|
|
19394
19454
|
}, this.options.heartbeatIntervalMs);
|
|
19395
19455
|
}
|
|
19396
19456
|
/** 停止心跳定时器 */
|