jbc-dssi 1.1.161 → 1.1.163
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/index.js +8 -7
- package/lib/tts.js +1 -11
- package/lib/workspace-bytes.js +22 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -29,7 +29,7 @@ import { createTtsEngine } from './lib/tts.js';
|
|
|
29
29
|
import { createEdgeTts, EDGE_VOICES } from './lib/edge-tts.js';
|
|
30
30
|
import { createAppReleaseWatch } from './lib/app-release-watch.js';
|
|
31
31
|
import { PLUGIN_FEATURES } from './lib/plugin-features.js';
|
|
32
|
-
import { MAX_FILE_BYTES, mimeOfFile, resolveWorkspaceFilePath } from './lib/workspace-bytes.js';
|
|
32
|
+
import { MAX_FILE_BYTES, mimeOfFile, mimeOfImage, resolveWorkspaceFilePath } from './lib/workspace-bytes.js';
|
|
33
33
|
|
|
34
34
|
/*
|
|
35
35
|
* ★ 协议层与瘦身层**直接引用 core**,本目录不再保有自己的副本。
|
|
@@ -149,13 +149,14 @@ export const inject = ['sessionController'];
|
|
|
149
149
|
const PROTOCOL_VERSION = 1;
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
|
-
* 手机"点了才传"的图片大小上限(2 MB
|
|
152
|
+
* 手机"点了才传"的图片大小上限(5 MB 原图,2026-11-27 老谢从 2 MB 调上来)。
|
|
153
153
|
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
154
|
+
* 帧上限 8 MB,base64 再胀 1.33 倍 —— 5 MB 原图 ≈ 6.7 MB 帧,仍在帧上限之内,
|
|
155
|
+
* 但已经接近:再往上加就会撞 8 MB 的帧上限,得先改协议分片,别直接调这个数。
|
|
156
|
+
* 超过上限的图先让电脑侧压缩,比让一帧把连接堵住好(大帧在 4G 上传要十几秒,
|
|
157
|
+
* 期间所有消息都排在它后面)。
|
|
157
158
|
*/
|
|
158
|
-
const MAX_IMAGE_BYTES =
|
|
159
|
+
const MAX_IMAGE_BYTES = 5 * 1024 * 1024;
|
|
159
160
|
|
|
160
161
|
/** 手机上没人回答时,最多等这么久就把审批交回浏览器处理。 */
|
|
161
162
|
const APPROVAL_TIMEOUT_MS = 5 * 60 * 1000;
|
|
@@ -3667,7 +3668,7 @@ class BridgeConnection {
|
|
|
3667
3668
|
const mb = (st.size / 1024 / 1024).toFixed(1);
|
|
3668
3669
|
this.send(FRAME.IMAGE_DATA, {
|
|
3669
3670
|
path: raw,
|
|
3670
|
-
error: `图片太大(${mb} MB),超过
|
|
3671
|
+
error: `图片太大(${mb} MB),超过 5 MB 先在电脑上压缩`,
|
|
3671
3672
|
});
|
|
3672
3673
|
return;
|
|
3673
3674
|
}
|
package/lib/tts.js
CHANGED
|
@@ -7,9 +7,7 @@ export const TTS_VOICES = [
|
|
|
7
7
|
];
|
|
8
8
|
|
|
9
9
|
const TTS_WS = 'wss://api.deepseek.com/v1/tools/tts';
|
|
10
|
-
|
|
11
|
-
const MAX_INFLIGHT = 2;
|
|
12
|
-
const CONNECT_TIMEOUT_MS = 15_000;
|
|
10
|
+
|
|
13
11
|
|
|
14
12
|
function voiceOf(id) {
|
|
15
13
|
return TTS_VOICES.some((v) => v.id === id) ? id : TTS_VOICES[0].id;
|
|
@@ -37,10 +35,6 @@ export function createTtsEngine({ log, resolveKey, WebSocketImpl = WebSocket })
|
|
|
37
35
|
|
|
38
36
|
async function open({ id, voice, onPage, onDone, onError }) {
|
|
39
37
|
if (typeof id !== 'string' || id === '') return;
|
|
40
|
-
if (sessions.size >= MAX_INFLIGHT) {
|
|
41
|
-
onError?.({ id, error: normalizeError('busy') });
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
38
|
const early = [];
|
|
45
39
|
let earlyEnd = false;
|
|
46
40
|
sessions.set(id, {
|
|
@@ -82,7 +76,6 @@ export function createTtsEngine({ log, resolveKey, WebSocketImpl = WebSocket })
|
|
|
82
76
|
};
|
|
83
77
|
sessions.set(id, session);
|
|
84
78
|
|
|
85
|
-
const timer = setTimeout(() => finish(session, id, { code: 'timeout' }), CONNECT_TIMEOUT_MS);
|
|
86
79
|
|
|
87
80
|
function flushPages(bytes) {
|
|
88
81
|
for (const chunk of bytes) {
|
|
@@ -94,7 +87,6 @@ export function createTtsEngine({ log, resolveKey, WebSocketImpl = WebSocket })
|
|
|
94
87
|
function finish(target, sessionId, error) {
|
|
95
88
|
if (target.settled) return;
|
|
96
89
|
target.settled = true;
|
|
97
|
-
clearTimeout(timer);
|
|
98
90
|
sessions.delete(sessionId);
|
|
99
91
|
try {
|
|
100
92
|
target.ws.close();
|
|
@@ -119,8 +111,6 @@ export function createTtsEngine({ log, resolveKey, WebSocketImpl = WebSocket })
|
|
|
119
111
|
session.pending.push(text);
|
|
120
112
|
return;
|
|
121
113
|
}
|
|
122
|
-
if (session.chars >= MAX_CHARS) return;
|
|
123
|
-
session.chars += text.length;
|
|
124
114
|
try {
|
|
125
115
|
ws.send(JSON.stringify({ event: 'text', text }));
|
|
126
116
|
} catch (err) {
|
package/lib/workspace-bytes.js
CHANGED
|
@@ -3,6 +3,28 @@ import { join, resolve, sep } from 'node:path';
|
|
|
3
3
|
|
|
4
4
|
export const MAX_FILE_BYTES = 5 * 1024 * 1024;
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* 按扩展名判「是不是图片」,是就返回 MIME,不是返回 null。
|
|
8
|
+
*
|
|
9
|
+
* ★ 2026-11-27 修:这个函数原本定义在 index.js 里,11-15 那次把 MIME 判断搬进本文件时
|
|
10
|
+
* 只搬了文件类型(mimeOfFile),`#readImage` 那处 `mimeOfImage(abs)` 调用忘了跟过来,
|
|
11
|
+
* 于是手机点正文图片 100% 抛 `mimeOfImage is not defined`、永远收不到图。
|
|
12
|
+
* 现在 MIME 知识统一放这里,两边都从这里取,别再各写一套。
|
|
13
|
+
*/
|
|
14
|
+
export function mimeOfImage(p) {
|
|
15
|
+
const m = /\.([a-z0-9]+)$/i.exec(String(p ?? ''));
|
|
16
|
+
if (!m) return null;
|
|
17
|
+
switch (m[1].toLowerCase()) {
|
|
18
|
+
case 'png': return 'image/png';
|
|
19
|
+
case 'jpg':
|
|
20
|
+
case 'jpeg': return 'image/jpeg';
|
|
21
|
+
case 'webp': return 'image/webp';
|
|
22
|
+
case 'gif': return 'image/gif';
|
|
23
|
+
case 'bmp': return 'image/bmp';
|
|
24
|
+
default: return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
6
28
|
export function mimeOfFile(p) {
|
|
7
29
|
const m = /\.([a-z0-9]+)$/i.exec(String(p ?? ''));
|
|
8
30
|
if (!m) return 'application/octet-stream';
|