dsh-game-material-master 0.9.1 → 0.9.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/README.en.md +6 -2
- package/README.md +5 -2
- package/lib/sfxapi.js +56 -21
- package/lib/sfxgen.js +1 -1
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -12,7 +12,11 @@ third-party service.
|
|
|
12
12
|
[](https://www.npmjs.com/package/dsh-game-material-master)
|
|
13
13
|
[](LICENSE)
|
|
14
14
|
|
|
15
|
-
> **🆕 0.9.
|
|
15
|
+
> **🆕 0.9.2 fix**: when Volcengine aborts before the TLS handshake completes, the plugin now retries up to
|
|
16
|
+
> 3 times (handshake-only errors; requests that were already sent are not retried, so billing is not duplicated),
|
|
17
|
+
> and the failure log states how many attempts were made.
|
|
18
|
+
>
|
|
19
|
+
> **0.9.1 fixes**: the sound-effect job list now refreshes after polling completes (no more "0 takes · ⏳"
|
|
16
20
|
> stuck forever), and Volcengine network errors include the underlying cause instead of a bare `fetch failed`.
|
|
17
21
|
>
|
|
18
22
|
> **0.9.0 update**: an eighth module, [**Sound effects**](#-sound-effects-volcengine-seed-audio)
|
|
@@ -362,7 +366,7 @@ dsh plugin --profile web add /path/to/dsh-game-material-master
|
|
|
362
366
|
```
|
|
363
367
|
|
|
364
368
|
The package is published to npm: [dsh-game-material-master](https://www.npmjs.com/package/dsh-game-material-master)
|
|
365
|
-
(currently `0.9.
|
|
369
|
+
(currently `0.9.2`, `latest`). It has no runtime dependencies, so `dsh plugin add` is all you need.
|
|
366
370
|
|
|
367
371
|
**DSH version**: `>=0.2.0-rc.2 <0.3.0` (the `engines.dsh` field; since DSH 0.2.1 the plugin manager checks it first).
|
|
368
372
|
When a Web deployment uses `--public-url https://host/prefix/`, deep links and asset URLs include that path prefix.
|
package/README.md
CHANGED
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
[](https://www.npmjs.com/package/dsh-game-material-master)
|
|
11
11
|
[](LICENSE)
|
|
12
12
|
|
|
13
|
-
> **🆕 0.9.
|
|
13
|
+
> **🆕 0.9.2 修复**:火山引擎调用遇到「TLS 握手尚未建立就断开」时会**自动重试最多 3 次**
|
|
14
|
+
> (只重试握手前错误,已发出的请求不重试,避免重复计费);失败日志会写明尝试次数。
|
|
15
|
+
>
|
|
16
|
+
> **0.9.1 修复**:音效生成任务在轮询完成后会同步刷新左侧列表(不再停在「0 条 · ⏳」);
|
|
14
17
|
> 火山引擎网络错误会带出底层原因,不再是只有一句 `fetch failed`。
|
|
15
18
|
>
|
|
16
19
|
> **0.9.0 更新**:新增第八个模块 [**音效生成**](#-音效生成火山引擎-seed-audio)(火山引擎 Seed-Audio:
|
|
@@ -299,7 +302,7 @@ dsh plugin --profile web add /path/to/dsh-game-material-master
|
|
|
299
302
|
```
|
|
300
303
|
|
|
301
304
|
包已发布到 npm:[dsh-game-material-master](https://www.npmjs.com/package/dsh-game-material-master)
|
|
302
|
-
(当前 `0.9.
|
|
305
|
+
(当前 `0.9.2`,`latest`)。本包没有运行时依赖,`dsh plugin add` 拉下来即可用。
|
|
303
306
|
|
|
304
307
|
**DSH 版本**:`>=0.2.0-rc.2 <0.3.0`(`package.json` 的 `engines.dsh`;DSH 0.2.1 起插件管理器优先按它判断兼容性)。
|
|
305
308
|
Web 部署用 `--public-url https://host/prefix/` 时,深链接与产物地址会跟着补路径前缀。
|
package/lib/sfxapi.js
CHANGED
|
@@ -275,6 +275,25 @@ function decodeBase64Audio(value) {
|
|
|
275
275
|
throw new SfxApiError("返回的 audio 不是合法 base64");
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* 只对**还没完成 TLS 握手**的网络错误自动重试。
|
|
280
|
+
*
|
|
281
|
+
* 这类错误说明请求根本没发出去(例如 Clash / TUN 节点抖动时的
|
|
282
|
+
* `Client network socket disconnected before secure TLS connection was established`),
|
|
283
|
+
* 重试不会重复计费。已经在握手后断开的连接不重试——那有可能远端已经收到并计费。
|
|
284
|
+
*/
|
|
285
|
+
export function isRetryableHandshakeError(error) {
|
|
286
|
+
const cause = error instanceof Error && error.cause instanceof Error ? error.cause : undefined;
|
|
287
|
+
const text = [
|
|
288
|
+
error instanceof Error ? error.message : "",
|
|
289
|
+
cause?.message,
|
|
290
|
+
cause?.code
|
|
291
|
+
].filter(Boolean).join(" ");
|
|
292
|
+
return /before secure TLS connection was established|socket disconnected before secure TLS|UND_ERR_CONNECT_TIMEOUT|EAI_AGAIN|ENOTFOUND|ECONNREFUSED|connect ETIMEDOUT/iu.test(text);
|
|
293
|
+
}
|
|
294
|
+
function sleep(ms) {
|
|
295
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
296
|
+
}
|
|
278
297
|
/**
|
|
279
298
|
* 调一次生成。`signal` 用于取消;超时由 `config.timeoutMs` 控制。
|
|
280
299
|
*
|
|
@@ -287,29 +306,43 @@ export async function generateSfx(config, request, signal) {
|
|
|
287
306
|
throw new SfxApiError(sfxBlocker({ sfxApiKey: "" }) ?? "尚未配置语音 API Key");
|
|
288
307
|
const endpoint = sfxEndpoint(config.baseUrl);
|
|
289
308
|
const body = buildSfxBody(request, config.model);
|
|
290
|
-
const requestId = randomUUID();
|
|
291
309
|
const { signal: composed, timeout } = combinedSignal(config.timeoutMs, signal);
|
|
292
310
|
let response;
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
"
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
311
|
+
let attempts = 0;
|
|
312
|
+
let lastError;
|
|
313
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
314
|
+
attempts += 1;
|
|
315
|
+
try {
|
|
316
|
+
response = await fetch(endpoint, {
|
|
317
|
+
method: "POST",
|
|
318
|
+
headers: {
|
|
319
|
+
"Content-Type": "application/json",
|
|
320
|
+
"X-Api-Key": apiKey,
|
|
321
|
+
"X-Api-Request-Id": randomUUID()
|
|
322
|
+
},
|
|
323
|
+
body: JSON.stringify(body),
|
|
324
|
+
signal: composed
|
|
325
|
+
});
|
|
326
|
+
break;
|
|
308
327
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
328
|
+
catch (error) {
|
|
329
|
+
lastError = error;
|
|
330
|
+
if (timeout.aborted) {
|
|
331
|
+
throw new SfxApiError(`生成超时(${Math.round(config.timeoutMs / 1000)} 秒):音频生成较慢,可以调大超时后再试;失败重试会再计费,先问用户。`);
|
|
332
|
+
}
|
|
333
|
+
if (composed.aborted)
|
|
334
|
+
throw new SfxApiError("生成已取消(远端可能仍会完成并计费)");
|
|
335
|
+
if (!isRetryableHandshakeError(error) || attempt === 2) {
|
|
336
|
+
const cause = error instanceof Error && error.cause instanceof Error ? `(${error.cause.message})` : "";
|
|
337
|
+
const retried = attempts > 1 ? `(网络握手失败,已尝试 ${attempts} 次)` : "";
|
|
338
|
+
throw new SfxApiError(`请求火山引擎失败${retried}:${error instanceof Error ? error.message : String(error)}${cause}`);
|
|
339
|
+
}
|
|
340
|
+
await sleep(350 * (attempt + 1));
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (response === undefined) {
|
|
344
|
+
const cause = lastError instanceof Error && lastError.cause instanceof Error ? `(${lastError.cause.message})` : "";
|
|
345
|
+
throw new SfxApiError(`请求火山引擎失败(已尝试 ${attempts} 次):${lastError instanceof Error ? lastError.message : String(lastError)}${cause}`);
|
|
313
346
|
}
|
|
314
347
|
const logId = response.headers.get("x-tt-logid") ?? undefined;
|
|
315
348
|
if (!response.ok)
|
|
@@ -358,7 +391,8 @@ export async function generateSfx(config, request, signal) {
|
|
|
358
391
|
duration: Number.isFinite(duration) && duration > 0 ? duration : undefined,
|
|
359
392
|
originalDuration: Number.isFinite(originalDuration) && originalDuration > 0 ? originalDuration : undefined,
|
|
360
393
|
remoteUrl,
|
|
361
|
-
logId
|
|
394
|
+
logId,
|
|
395
|
+
attempts
|
|
362
396
|
};
|
|
363
397
|
}
|
|
364
398
|
/**
|
|
@@ -387,6 +421,7 @@ export async function testSfxConnection(config) {
|
|
|
387
421
|
duration: result.duration ?? null,
|
|
388
422
|
originalDuration: result.originalDuration ?? null,
|
|
389
423
|
format: result.ext,
|
|
424
|
+
attempts: result.attempts ?? 1,
|
|
390
425
|
message: `连接正常:返回 ${result.bytes.length} 字节音频${result.duration === undefined ? "" : `,${result.duration.toFixed(2)} 秒`}`
|
|
391
426
|
};
|
|
392
427
|
}
|
package/lib/sfxgen.js
CHANGED
|
@@ -615,7 +615,7 @@ async function runSfxGeneration(id, refs) {
|
|
|
615
615
|
...(result.logId === undefined ? {} : { logId: result.logId })
|
|
616
616
|
});
|
|
617
617
|
current.stages.generate = { status: "done", approved: false, at: now() };
|
|
618
|
-
sfxLog(current, "info", `生成完成:${relative}(${result.bytes.length} 字节${duration === undefined ? "" : `,${duration.toFixed(2)} 秒`}
|
|
618
|
+
sfxLog(current, "info", `生成完成:${relative}(${result.bytes.length} 字节${duration === undefined ? "" : `,${duration.toFixed(2)} 秒`})${(result.attempts ?? 1) > 1 ? ` · 网络握手重试后成功(第 ${result.attempts} 次)` : ""}`);
|
|
619
619
|
});
|
|
620
620
|
}
|
|
621
621
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-game-material-master",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "游戏素材大师:DSH 插件,包含八方向图生成、图片生成、序列帧生成、地图编辑器、音乐生成编辑、音效生成六个正式模块(地图编辑器参考 AsLib 的 RPG Map Maker 重做:一屏、纯图标、零术语,地图四周环绕、素材自动识别与自动连接、动画地块、内置素材、一键生成,全本地零计费;音乐生成编辑接谱乐 AI:灵感/歌词 → 不挂靠项目的新对话 → agent 扩写/选引擎生成 → 回界面裁剪/音量/淡入淡出/标准化/导出,生成按平台积分计费;另有谱曲模式:先给方案 → scoremill 本地写 MIDI → 渲染试听 → 逐版修改 → 可选交 Suno,谱曲/试听/导出本地免费;音效生成接火山引擎 Seed-Audio:一句话描述 → 音效/环境音/角色配音,可带参考图或参考音频,每次生成真实计费),以及实验性的 45° 地图地块生成与骨骼动画生成模块。界面与内置提示词跟随 DSH 语言设置(中 / 英)。八方向图默认「转圈截帧」(一段原地匀速转一圈的绿幕视频 → 按时间轴截出八个方向),也可逐方向生图;45° 地图地块用「几何交给代码、内容交给 AI」的方式拼成整张地图。生图后端可选火山方舟 Seedream,或自定义生图模型(OpenAI API / ComfyUI API / Stable Diffusion WebUI API 三种协议);图生视频走 MiniMax;抠绿幕合成与音乐后期全部在本地。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|