dsh-game-material-master 0.9.0 → 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 CHANGED
@@ -12,7 +12,14 @@ third-party service.
12
12
  [![npm](https://img.shields.io/npm/v/dsh-game-material-master?color=blue)](https://www.npmjs.com/package/dsh-game-material-master)
13
13
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
14
14
 
15
- > **🆕 What's new in 0.9.0**: an eighth module, [**Sound effects**](#-sound-effects-volcengine-seed-audio)
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 · ⏳"
20
+ > stuck forever), and Volcengine network errors include the underlying cause instead of a bare `fetch failed`.
21
+ >
22
+ > **0.9.0 update**: an eighth module, [**Sound effects**](#-sound-effects-volcengine-seed-audio)
16
23
  > (Volcengine Seed-Audio: one prompt → sound effects / ambience / character voices, with an optional reference
17
24
  > image or audio; every run is billed; up to 120 seconds). The 0.8.0 **music generation / compose mode**,
18
25
  > map editor **Generate with AI / stamps**, **local ComfyUI** backend and **DSH 0.2.1** support remain.
@@ -359,7 +366,7 @@ dsh plugin --profile web add /path/to/dsh-game-material-master
359
366
  ```
360
367
 
361
368
  The package is published to npm: [dsh-game-material-master](https://www.npmjs.com/package/dsh-game-material-master)
362
- (currently `0.9.0`, `latest`). It has no runtime dependencies, so `dsh plugin add` is all you need.
369
+ (currently `0.9.2`, `latest`). It has no runtime dependencies, so `dsh plugin add` is all you need.
363
370
 
364
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).
365
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,13 @@
10
10
  [![npm](https://img.shields.io/npm/v/dsh-game-material-master?color=blue)](https://www.npmjs.com/package/dsh-game-material-master)
11
11
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
12
12
 
13
- > **🆕 0.9.0 更新**:新增第八个模块 [**音效生成**](#-音效生成火山引擎-seed-audio)(火山引擎 Seed-Audio:
13
+ > **🆕 0.9.2 修复**:火山引擎调用遇到「TLS 握手尚未建立就断开」时会**自动重试最多 3 次**
14
+ > (只重试握手前错误,已发出的请求不重试,避免重复计费);失败日志会写明尝试次数。
15
+ >
16
+ > **0.9.1 修复**:音效生成任务在轮询完成后会同步刷新左侧列表(不再停在「0 条 · ⏳」);
17
+ > 火山引擎网络错误会带出底层原因,不再是只有一句 `fetch failed`。
18
+ >
19
+ > **0.9.0 更新**:新增第八个模块 [**音效生成**](#-音效生成火山引擎-seed-audio)(火山引擎 Seed-Audio:
14
20
  > 一句话描述 → 音效 / 环境音 / 角色配音,可带参考图或参考音频,每次生成真实计费,单次最长 120 秒)。
15
21
  > 上一版 0.8.0 的 **音乐生成编辑 / 谱曲模式**、地图编辑器 **AI 生成素材 / 整图**、**本地 ComfyUI**
16
22
  > 与 **DSH 0.2.1** 适配继续保留。
@@ -296,7 +302,7 @@ dsh plugin --profile web add /path/to/dsh-game-material-master
296
302
  ```
297
303
 
298
304
  包已发布到 npm:[dsh-game-material-master](https://www.npmjs.com/package/dsh-game-material-master)
299
- (当前 `0.9.0`,`latest`)。本包没有运行时依赖,`dsh plugin add` 拉下来即可用。
305
+ (当前 `0.9.2`,`latest`)。本包没有运行时依赖,`dsh plugin add` 拉下来即可用。
300
306
 
301
307
  **DSH 版本**:`>=0.2.0-rc.2 <0.3.0`(`package.json` 的 `engines.dsh`;DSH 0.2.1 起插件管理器优先按它判断兼容性)。
302
308
  Web 部署用 `--public-url https://host/prefix/` 时,深链接与产物地址会跟着补路径前缀。
package/lib/client.js CHANGED
@@ -10619,6 +10619,28 @@ window.__ModuleLoader__.load({
10619
10619
  return undefined;
10620
10620
  setJob(next);
10621
10621
  setJobId(id);
10622
+ // 左侧列表也要跟着轮询更新:只刷新详情的话,生成完成后列表会一直停在
10623
+ // 「0 条 · ⏳」,用户会以为任务没跑完。
10624
+ setJobs((current) => {
10625
+ const takes = Array.isArray(next.takes) ? next.takes : [];
10626
+ const latest = takes[takes.length - 1];
10627
+ const summary = {
10628
+ id: next.id,
10629
+ name: next.name,
10630
+ createdAt: next.createdAt,
10631
+ updatedAt: next.updatedAt,
10632
+ status: next.status,
10633
+ busy: next.busy === true,
10634
+ takes: takes.length,
10635
+ latestDuration: latest?.duration ?? null,
10636
+ format: latest?.format ?? null,
10637
+ reviewMode: next.reviewMode ?? null
10638
+ };
10639
+ const exists = current.some((entry) => entry.id === next.id);
10640
+ return exists
10641
+ ? current.map((entry) => (entry.id === next.id ? { ...entry, ...summary } : entry))
10642
+ : [summary, ...current];
10643
+ });
10622
10644
  const force = loadedDraft.current.jobId !== next.id;
10623
10645
  const nextPrompt = typeof next.prompt === "string" ? next.prompt : "";
10624
10646
  const nextSettings = sfxSettingsOf(next);
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,28 +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
- try {
294
- response = await fetch(endpoint, {
295
- method: "POST",
296
- headers: {
297
- "Content-Type": "application/json",
298
- "X-Api-Key": apiKey,
299
- "X-Api-Request-Id": requestId
300
- },
301
- body: JSON.stringify(body),
302
- signal: composed
303
- });
304
- }
305
- catch (error) {
306
- if (timeout.aborted) {
307
- throw new SfxApiError(`生成超时(${Math.round(config.timeoutMs / 1000)} 秒):音频生成较慢,可以调大超时后再试;失败重试会再计费,先问用户。`);
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
- if (composed.aborted)
310
- throw new SfxApiError("生成已取消(远端可能仍会完成并计费)");
311
- throw new SfxApiError(`请求火山引擎失败:${error instanceof Error ? error.message : String(error)}`);
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}`);
312
346
  }
313
347
  const logId = response.headers.get("x-tt-logid") ?? undefined;
314
348
  if (!response.ok)
@@ -357,7 +391,8 @@ export async function generateSfx(config, request, signal) {
357
391
  duration: Number.isFinite(duration) && duration > 0 ? duration : undefined,
358
392
  originalDuration: Number.isFinite(originalDuration) && originalDuration > 0 ? originalDuration : undefined,
359
393
  remoteUrl,
360
- logId
394
+ logId,
395
+ attempts
361
396
  };
362
397
  }
363
398
  /**
@@ -386,6 +421,7 @@ export async function testSfxConnection(config) {
386
421
  duration: result.duration ?? null,
387
422
  originalDuration: result.originalDuration ?? null,
388
423
  format: result.ext,
424
+ attempts: result.attempts ?? 1,
389
425
  message: `连接正常:返回 ${result.bytes.length} 字节音频${result.duration === undefined ? "" : `,${result.duration.toFixed(2)} 秒`}`
390
426
  };
391
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.0",
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",