dsh-video-insight 0.11.1 → 0.12.1
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/CHANGELOG.md +15 -0
- package/README.en.md +1 -1
- package/README.md +3 -1
- package/client/client.js +338 -73
- package/lib/index.js +116 -13
- package/lib/installer.js +295 -0
- package/lib/jobs.js +12 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
本项目的版本号与 `package.json` 保持一致;面板是单文件客户端,刷新页面即生效。
|
|
4
4
|
|
|
5
|
+
## v0.12.1 (2026-11-19)
|
|
6
|
+
|
|
7
|
+
- **Windows 修复**:分析缓存/历史文件名不再含冒号(`youtube:` → `youtube_`),修复 Windows 上 `EINVAL: invalid argument, rename ...` 解析失败;旧缓存自动兼容读取,文件改名失败时退避重试。
|
|
8
|
+
- **本机组件一键安装**:`GET /install/plan` + `POST /install`(SSE 进度/取消),设置里每项可「自动安装」,首页「环境准备」卡可一键装齐 ffmpeg / ffprobe / yt-dlp / Whisper / SenseVoice(macOS 上 Whisper 走 Homebrew 提示)。
|
|
9
|
+
- **本地模型一键下载**:`GET /asr/models` + `POST /asr/models`,Whisper(574 MB)与 SenseVoice(≈240 MB)可直接下载到 `~/.dsh/video-models`。
|
|
10
|
+
- **卸载安全**:插件热重载/升级时主动中止后台队列与打开的 SSE 连接,避免残留回调触发未处理的 rejection 让宿主退出。
|
|
11
|
+
- **多语言**:界面跟随 DSH 语言、设置可切换;AI 输出按所选语言生成,分析缓存按语言隔离(0.11.0/0.11.1 内容一并包含在本版)。
|
|
12
|
+
|
|
13
|
+
## v0.12.0(2026-11-19)
|
|
14
|
+
|
|
15
|
+
- 新增:**本机组件一键安装**(`GET /install/plan`、`POST /install` SSE)——ffmpeg / ffprobe / yt-dlp / whisper-cli(Windows)/ sherpa-onnx 直接下载便携版到 `~/.dsh/video-tools/`,装完自动写回路径配置,不用再手动填。
|
|
16
|
+
- 改进:设置里缺组件时可直接点「自动安装」,带进度与取消;macOS 的 whisper.cpp 仍推荐 Homebrew(给出命令与复制按钮)。
|
|
17
|
+
- 改进:英文界面设置里的 ASR 区块完全本地化(OCR / 画面理解 / 语音转写字段、hints、引擎名),英文界面不再出现中文残留。
|
|
18
|
+
- 改进:组件探测覆盖 Windows(`.exe`、winget/scoop 目录、sherpa-onnx 解压目录递归查找)。
|
|
19
|
+
|
|
5
20
|
## v0.11.1(2026-11-19)
|
|
6
21
|
|
|
7
22
|
- 修复:Windows 上分析缓存文件名含 `:` 导致 `EINVAL rename` 失败(`youtube:xxx` 的缓存文件改成 `youtube_xxx.json`,旧文件自动兼容读取)。
|
package/README.en.md
CHANGED
|
@@ -5,7 +5,7 @@ English | [中文](./README.md)
|
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
[](https://github.com/deepseek-ai)
|
|
7
7
|
[](#known-limitations)
|
|
8
|
-
[](package.json)
|
|
9
9
|
|
|
10
10
|

|
|
11
11
|
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
[](https://github.com/deepseek-ai)
|
|
7
7
|
[](#已知限制)
|
|
8
|
-
[](package.json)
|
|
9
9
|
|
|
10
10
|

|
|
11
11
|
|
|
@@ -186,6 +186,8 @@ host 半零外部依赖(只用 Node 内置 `fetch`/`crypto`),不写锁文
|
|
|
186
186
|
| POST | `/dsh-video/api/asr/config` | `{enabled?,engine?,threads?,maxSeconds?,keepAudio?,autoTranscribe?,crossCheck?,ocrFallback?,ocrIntervalSeconds?,ocrMaxFrames?,frameSampling?:cuts\|uniform,cutThreshold?,frameMode?:auto\|ocr\|vision,visionModel?,visionMaxFrames?,visionPack?:sheet\|frames,sheetCols?}` → 新状态 |
|
|
187
187
|
| GET | `/dsh-video/api/asr/models` | 本地模型(Whisper / SenseVoice)文件状态:每个文件的路径、期望/实际大小、是否存在 |
|
|
188
188
|
| POST | `/dsh-video/api/asr/models` | SSE 下载模型:`{id:"whisper"\|"sensevoice"\|"all", force?}`,帧 `phase` / `progress{percent,received,total}` / `done` / `error{code}` |
|
|
189
|
+
| GET | `/dsh-video/api/install/plan` | 本机组件(ffmpeg/ffprobe/yt-dlp/whisper-cli/sherpa-onnx)是否已装、安装方式与预计大小 |
|
|
190
|
+
| POST | `/dsh-video/api/install` | SSE 一键安装组件:`{id:"ffmpeg"\|"ffprobe"\|"ytdlp"\|"whisper"\|"sherpa"\|"all"}`,帧 `phase` / `progress{component,stage,percent}` / `installed{component,path}` / `done` / `error{code}` |
|
|
189
191
|
| POST | `/dsh-video/api/transcribe` | SSE:`{url?/docId?, force?}`,帧 `phase` / `progress{percent,stage}` / `done{docId,transcript,cached?}` / `error{code,message}`;无语音时自动兜底 OCR / 画面理解(stage 含 `vision`) |
|
|
190
192
|
| POST | `/dsh-video/api/analyze` | SSE:`{mode:'summary'\|'ask', url?/docId?, question?, history?}`,帧 `phase` / `delta` / `done` / `error` |
|
|
191
193
|
| POST | `/dsh-video/api/chapters` | `{url?/docId?}` → `{ok,value:{chapters:[{start,title,gist}],duration}}` |
|
package/client/client.js
CHANGED
|
@@ -289,7 +289,7 @@ window.__ModuleLoader__.load({
|
|
|
289
289
|
'toast.noSegments': ['没有可复制的字幕', 'No captions to copy'],
|
|
290
290
|
'setup.title': ['环境准备', 'Setup required'],
|
|
291
291
|
'setup.body': ['本地转写组件还没就绪:缺 ffmpeg / yt-dlp / 模型时,没字幕的视频会退回只按标题和简介分析。', 'Local transcription is not ready yet: without ffmpeg / yt-dlp / models, videos without captions fall back to title and description only.'],
|
|
292
|
-
'setup.go': ['
|
|
292
|
+
'setup.go': ['去设置里手动安装/填写路径 →', 'Open settings to install manually or set paths →'],
|
|
293
293
|
'setup.dismiss': ['关闭提示', 'Dismiss'],
|
|
294
294
|
'asr.comp.title': ['本机组件', 'Local tools'],
|
|
295
295
|
'asr.comp.refresh': ['重新检测', 'Re-check'],
|
|
@@ -298,6 +298,24 @@ window.__ModuleLoader__.load({
|
|
|
298
298
|
'asr.comp.save': ['保存路径', 'Save path'],
|
|
299
299
|
'asr.comp.saved': ['路径已保存(留空 = 使用默认路径)', 'Path saved (empty = default)'],
|
|
300
300
|
'asr.comp.placeholder': ['留空 = 使用默认路径', 'Empty = default path'],
|
|
301
|
+
'asr.comp.all': ['全部自动安装', 'Install all'],
|
|
302
|
+
'asr.comp.install': ['自动安装', 'Install'],
|
|
303
|
+
'asr.comp.brewInstall': ['用 Homebrew 安装', 'Install via Homebrew'],
|
|
304
|
+
'asr.comp.brewHint': ['需要本机已安装 Homebrew;也可以直接在上面填路径', 'Needs Homebrew on this machine; you can also type a path above'],
|
|
305
|
+
'asr.comp.installing': ['安装中…', 'Installing…'],
|
|
306
|
+
'asr.comp.extracting': ['正在解压…', 'Extracting…'],
|
|
307
|
+
'asr.comp.installPlanError': ['读取安装信息失败:{message}', 'Failed to read install plan: {message}'],
|
|
308
|
+
'asr.installFailed': ['安装失败:{message}', 'Install failed: {message}'],
|
|
309
|
+
'asr.installedPath': ['已安装到 {path}', 'Installed at {path}'],
|
|
310
|
+
'setup.installAll': ['一键安装缺失组件', 'Install missing components'],
|
|
311
|
+
'toast.installDone': ['已安装 {name}', 'Installed {name}'],
|
|
312
|
+
'toast.installAllDone': ['已安装 {count} 个组件', 'Installed {count} components'],
|
|
313
|
+
'toast.installCancelled': ['已取消安装', 'Install cancelled'],
|
|
314
|
+
'error.install-needs-brew': ['需要先在本机安装 Homebrew 才能用 brew 安装这个组件', 'Homebrew is required on this machine to install this component'],
|
|
315
|
+
'error.install-download-failed': ['下载失败:网络或镜像不可用,稍后重试或手动安装', 'Download failed: network or mirror unavailable; retry later or install manually'],
|
|
316
|
+
'error.install-extract-failed': ['解压或校验失败:下载文件可能不完整,稍后重试', 'Extract/verify failed: the download may be incomplete; retry later'],
|
|
317
|
+
'error.install-unavailable': ['当前平台没有可自动安装的包,请手动安装', 'No prebuilt installer for this platform; install manually'],
|
|
318
|
+
'error.bad-component': ['未知组件', 'Unknown component'],
|
|
301
319
|
'asr.comp.ffmpeg': ['ffmpeg', 'ffmpeg'],
|
|
302
320
|
'asr.comp.ytdlp': ['yt-dlp', 'yt-dlp'],
|
|
303
321
|
'asr.comp.whisper': ['whisper-cli', 'whisper-cli'],
|
|
@@ -332,6 +350,65 @@ window.__ModuleLoader__.load({
|
|
|
332
350
|
'transcribe.retry': ['重试转写', 'Retry transcription'],
|
|
333
351
|
'transcribe.start': ['本地转写', 'Transcribe locally'],
|
|
334
352
|
'transcribe.working': ['转写中…', 'Transcribing…'],
|
|
353
|
+
'asr.title': ['本地语音转写', 'Local transcription'],
|
|
354
|
+
'asr.saving': ['保存中…', 'Saving…'],
|
|
355
|
+
'asr.loading': ['正在读取本地转写状态…', 'Loading local transcription status…'],
|
|
356
|
+
'asr.loadError': ['本地转写状态读取失败:{message}(点右上角「刷新状态」重试)', 'Failed to read local transcription status: {message} (click Refresh in the top-right to retry)'],
|
|
357
|
+
'asr.privacy': ['语音转写与画面文字识别完全在本机运行;画面理解会把抽样的画面图片发给当前模型(会离开本机);摘要使用当前配置的模型。', 'Speech transcription and on-screen OCR run entirely on this machine; visual understanding sends sampled frames to the current model (they leave this machine); summaries use the configured model.'],
|
|
358
|
+
'asr.notReady': ['本机转写组件还没装好:{reason}。装好后点「重新检测」重新检测。', 'Local transcription tools are not ready: {reason}. Click "Re-check" after installing them.'],
|
|
359
|
+
'asr.notReadyFallback': ['缺少 ffmpeg / whisper / sherpa 之一', 'missing ffmpeg / whisper / sherpa'],
|
|
360
|
+
'asr.downloadNote': ['提示:下载视频音轨需要 yt-dlp;ffmpeg 用于提取与转换音频。', 'Note: yt-dlp is required to download audio; ffmpeg extracts and converts it.'],
|
|
361
|
+
'asr.enabledOn': ['已开启:无字幕视频可以在这台电脑上转写', 'Enabled: videos without captions can be transcribed on this machine'],
|
|
362
|
+
'asr.enabledOff': ['已关闭:无字幕视频不会转写', 'Disabled: videos without captions are not transcribed'],
|
|
363
|
+
'asr.autoCheck': ['无字幕视频自动转写(解析到没有字幕的视频时自动在本地跑一次转写,长视频可能要等一会儿)', 'Auto-transcribe videos without captions (runs once locally; long videos may take a while)'],
|
|
364
|
+
'asr.crossCheck': ['语音与画面并行分析', 'Run speech and vision analysis in parallel'],
|
|
365
|
+
'asr.crossNote': ['和语音转写同时跑画面分析,两路结果互相印证(多花一次视觉模型调用)。', 'Runs visual analysis alongside transcription so both results corroborate each other (one extra vision-model call).'],
|
|
366
|
+
'asr.ocrAvailable': ['没有语音时识别画面文字(OCR):可用(纯音乐/无声视频也能出文字稿)', 'Recognize on-screen text when there is no speech (OCR): available (also works for silent videos)'],
|
|
367
|
+
'asr.ocrUnavailable': ['没有语音时识别画面文字(OCR):不可用{reason}', 'Recognize on-screen text when there is no speech (OCR): unavailable{reason}'],
|
|
368
|
+
'asr.ocrFallbackReason': ['暂不支持', 'not supported here'],
|
|
369
|
+
'asr.ocrInterval': ['抽帧间隔(秒)', 'Frame interval (seconds)'],
|
|
370
|
+
'asr.ocrIntervalHint': ['越小越细但更慢', 'Smaller = finer but slower'],
|
|
371
|
+
'asr.ocrFrames': ['最多识别帧数', 'Max OCR frames'],
|
|
372
|
+
'asr.ocrFramesHint': ['默认 120 帧', '120 frames by default'],
|
|
373
|
+
'asr.ocrPrivacy': ['画面文字识别用系统自带的 Vision 框架离线完成,视频和画面都不会上传。', 'On-screen OCR uses the built-in Vision framework offline; neither the video nor the frames are uploaded.'],
|
|
374
|
+
'asr.visionTitle': ['画面理解(视觉模型)', 'Visual understanding (vision model)'],
|
|
375
|
+
'asr.visionMode': ['画面理解模式', 'Visual understanding mode'],
|
|
376
|
+
'asr.frameAuto': ['自动', 'Auto'],
|
|
377
|
+
'asr.frameOcr': ['仅画面文字', 'OCR only'],
|
|
378
|
+
'asr.frameVision': ['画面理解', 'Vision'],
|
|
379
|
+
'asr.frameAutoDesc': ['自动(推荐):先在本机识别画面文字,文字太少时再让视觉模型看画面。', 'Auto (recommended): OCR on-device first; the vision model steps in only when there is little text.'],
|
|
380
|
+
'asr.frameOcrDesc': ['仅画面文字(OCR):完全在本机运行,抽帧与识别都不会联网。', 'OCR only: runs entirely on-device; no frames or text leave this machine.'],
|
|
381
|
+
'asr.frameVisionDesc': ['画面理解(视觉模型):会抽取画面图片发给当前模型(图片会离开本机)。', 'Vision: sampled frames are sent to the configured model (images leave this machine).'],
|
|
382
|
+
'asr.visionReady': ['画面理解可用 · {route}{actual}', 'Visual understanding ready · {route}{actual}'],
|
|
383
|
+
'asr.visionActual': ['(当前实际:{mode})', ' (currently using {mode})'],
|
|
384
|
+
'asr.visionUnavailable': ['画面理解不可用:{reason}', 'Visual understanding unavailable: {reason}'],
|
|
385
|
+
'asr.visionFallbackReason': ['当前没有可用的视觉模型或附件服务', 'no vision model or attachment service is available'],
|
|
386
|
+
'asr.visionTry': ['可切换为 {list}', 'Try: {list}'],
|
|
387
|
+
'asr.visionNoImage': ['当前模型不支持图片输入:请改用「自动」或「仅画面文字」。', 'The current model does not support image input: switch to Auto or OCR only.'],
|
|
388
|
+
'asr.visionModel': ['视觉模型', 'Vision model'],
|
|
389
|
+
'asr.visionModelHint': ['留空 = 使用会话默认模型;可填 provider/model 覆盖', 'Empty = use the session default model; provider/model overrides it'],
|
|
390
|
+
'asr.visionFrames': ['画面理解最多帧数', 'Max vision frames'],
|
|
391
|
+
'asr.visionFramesHint': ['每帧约 2-4 秒;可填 8–160 帧', 'About 2–4 s per frame; 8–160 allowed'],
|
|
392
|
+
'asr.visionPrivacy': ['画面理解会把抽出来的画面图片交给当前模型(会离开本机);OCR 仍然完全在本机运行。', 'Visual understanding sends sampled frames to the current model (they leave this machine); OCR still runs entirely on-device.'],
|
|
393
|
+
'asr.engine': ['识别引擎', 'Engine'],
|
|
394
|
+
'asr.engineAuto': ['自动选择', 'Auto'],
|
|
395
|
+
'asr.engineWhisper': ['Whisper(whisper.cpp)', 'Whisper (whisper.cpp)'],
|
|
396
|
+
'asr.engineSenseVoice': ['SenseVoice(sherpa-onnx)', 'SenseVoice (sherpa-onnx)'],
|
|
397
|
+
'asr.engineNotReady': ['(未就绪)', ' (not ready)'],
|
|
398
|
+
'asr.engineUnknown': ['未知', 'unknown'],
|
|
399
|
+
'asr.engineCurrent': ['当前使用:{engine}', 'In use: {engine}'],
|
|
400
|
+
'asr.threads': ['线程数', 'Threads'],
|
|
401
|
+
'asr.threadsHint': ['0 = 自动', '0 = auto'],
|
|
402
|
+
'asr.maxSeconds': ['最长处理时长(秒)', 'Max duration (seconds)'],
|
|
403
|
+
'asr.maxSecondsHint': ['0 = 不限制;只处理前 N 秒可以明显加速', '0 = unlimited; limiting to the first N seconds speeds things up'],
|
|
404
|
+
'asr.keepAudio': ['保留临时音频(~/.dsh/video-models/last-audio.*,默认不保留)', 'Keep temporary audio (~/.dsh/video-models/last-audio.*, off by default)'],
|
|
405
|
+
'asr.hintPrefix': ['提示:', 'Tip: '],
|
|
406
|
+
'asr.hintGeneric': ['部分组件缺失或未就绪,请检查下方安装提示与路径配置。', 'Some components are missing or not ready; check the installation hints and paths below.'],
|
|
407
|
+
'asr.unnamedModel': ['未命名模型', 'unnamed model'],
|
|
408
|
+
'asr.modelWhisper': ['Whisper', 'Whisper'],
|
|
409
|
+
'asr.modelSenseVoice': ['SenseVoice', 'SenseVoice'],
|
|
410
|
+
'asr.stageVision': ['画面理解中', 'Understanding frames'],
|
|
411
|
+
'asr.stageOcr': ['画面文字识别中', 'Reading on-screen text'],
|
|
335
412
|
'error.model-load': ['读取模型信息失败:{message}', 'Failed to load model info: {message}'],
|
|
336
413
|
'error.model-download': ['下载模型失败:{message}', 'Model download failed: {message}'],
|
|
337
414
|
'error.model-cancelled': ['已取消下载模型', 'Model download cancelled'],
|
|
@@ -417,6 +494,7 @@ window.__ModuleLoader__.load({
|
|
|
417
494
|
const VISION_MODEL_PLACEHOLDER = 'opencode-go/deepseek-v4.1-flash';
|
|
418
495
|
/** 分镜:host 生成的分镜拼图(GET 读缓存 / POST SSE 生成),格子带秒数可 seek。 */
|
|
419
496
|
const EMPTY_STORYBOARD = { data: null, loading: false, phase: '', percent: null, error: '', code: '' };
|
|
497
|
+
const EMPTY_INSTALL = { id: '', loading: false, phase: '', percent: null, received: 0, total: 0 };
|
|
420
498
|
/** 大纲:host 按「思维导图一级节点 → 章节 → 均匀切分」给出,章节与关键画面共用同一份数据与画面描述缓存。 */
|
|
421
499
|
const EMPTY_OUTLINE = { docId: '', loading: false, loaded: false, error: '', code: '', data: null, genLoading: false, genPhase: '', genPercent: null, genError: '' };
|
|
422
500
|
const OUTLINE_SOURCE_LABEL = { mindmap: '按思维导图切分', chapters: '按视频章节切分', uniform: '按时长均匀切分' };
|
|
@@ -891,6 +969,13 @@ window.__ModuleLoader__.load({
|
|
|
891
969
|
return `${text} ${units[index]}`;
|
|
892
970
|
}
|
|
893
971
|
|
|
972
|
+
function friendlyInstallError(error) {
|
|
973
|
+
const localized = codeText(error);
|
|
974
|
+
if (localized) return localized;
|
|
975
|
+
const message = String((error && error.message) || '').trim();
|
|
976
|
+
return t('asr.installFailed', { message: message || t('common.unknown') });
|
|
977
|
+
}
|
|
978
|
+
|
|
894
979
|
function friendlyModelError(error) {
|
|
895
980
|
const code = String(error?.code || '');
|
|
896
981
|
const message = String(error?.message || '').trim();
|
|
@@ -966,6 +1051,8 @@ window.__ModuleLoader__.load({
|
|
|
966
1051
|
function stageText(stage) {
|
|
967
1052
|
const key = String(stage ?? '').trim();
|
|
968
1053
|
if (!key) return '';
|
|
1054
|
+
if (key === 'vision') return t('asr.stageVision');
|
|
1055
|
+
if (key === 'ocr') return t('asr.stageOcr');
|
|
969
1056
|
return STAGE_LABEL[key] || key;
|
|
970
1057
|
}
|
|
971
1058
|
|
|
@@ -2774,7 +2861,7 @@ window.__ModuleLoader__.load({
|
|
|
2774
2861
|
};
|
|
2775
2862
|
return h('input', {
|
|
2776
2863
|
className: 'dvv-input', type: 'text', value: draft, placeholder: VISION_MODEL_PLACEHOLDER,
|
|
2777
|
-
'aria-label': '
|
|
2864
|
+
'aria-label': t('asr.visionModel'), spellCheck: false,
|
|
2778
2865
|
onChange: (event) => setDraft(event.target.value),
|
|
2779
2866
|
onBlur: commit,
|
|
2780
2867
|
onKeyDown: (event) => { if (event.key === 'Enter') { event.preventDefault(); commit(); } },
|
|
@@ -2816,6 +2903,12 @@ window.__ModuleLoader__.load({
|
|
|
2816
2903
|
* 模型卡片:Whisper / SenseVoice 的文件路径、大小与下载按钮(SSE 进度)。
|
|
2817
2904
|
*/
|
|
2818
2905
|
function AsrModelsBlock({ models, error, downloading, saving, onDownload, onCancel, onSavePath }) {
|
|
2906
|
+
const uiEn = activeUiLang === 'en';
|
|
2907
|
+
const modelLabel = (id, meta) => {
|
|
2908
|
+
const label = String((meta && meta.label) || '');
|
|
2909
|
+
if (!uiEn || !/[㐀-鿿]/.test(label)) return label || String(id);
|
|
2910
|
+
return id === 'sensevoice' ? t('asr.modelSenseVoice') : t('asr.modelWhisper');
|
|
2911
|
+
};
|
|
2819
2912
|
const rows = [h('div', { key: 'head', className: 'dvv-asr-head' }, h('span', { className: 'dvv-label' }, t('asr.models.title')))];
|
|
2820
2913
|
if (!models) {
|
|
2821
2914
|
rows.push(h('div', { key: 'loading', className: 'dvv-note' }, error ? t('error.model-load', { message: error }) : t('asr.models.loading')));
|
|
@@ -2843,7 +2936,7 @@ window.__ModuleLoader__.load({
|
|
|
2843
2936
|
});
|
|
2844
2937
|
return h('div', { key: `m-${id}`, className: 'dvv-model-card' }, [
|
|
2845
2938
|
h('div', { key: 'h', className: 'dvv-model-head' }, [
|
|
2846
|
-
h('span', { key: 't', className: 'dvv-label' },
|
|
2939
|
+
h('span', { key: 't', className: 'dvv-label' }, modelLabel(id, meta)),
|
|
2847
2940
|
h('span', {
|
|
2848
2941
|
key: 's', className: 'dvv-mini', 'data-ok': meta.available ? 'true' : 'false',
|
|
2849
2942
|
}, meta.available ? t('asr.models.ready') : t('asr.models.missing')),
|
|
@@ -2899,12 +2992,26 @@ window.__ModuleLoader__.load({
|
|
|
2899
2992
|
}
|
|
2900
2993
|
|
|
2901
2994
|
/** 首页「环境准备」提示卡:本地转写没就绪时引导去设置,可手动关闭。 */
|
|
2902
|
-
function SetupCard({ onOpen, onDismiss }) {
|
|
2995
|
+
function SetupCard({ onOpen, onDismiss, onInstallAll, onCancelInstall, installing }) {
|
|
2996
|
+
const busy = Boolean(installing && installing.loading);
|
|
2997
|
+
const percent = busy && Number.isFinite(installing.percent) ? installing.percent : null;
|
|
2998
|
+
const phase = busy ? String(installing.phase || t('asr.comp.installing')) : '';
|
|
2903
2999
|
return h('div', { className: 'dvv-setup-card' }, [
|
|
2904
3000
|
h('div', { key: 'main', className: 'dvv-setup-main' }, [
|
|
2905
3001
|
h('div', { key: 't', className: 'dvv-label' }, t('setup.title')),
|
|
2906
3002
|
h('div', { key: 'b', className: 'dvv-note' }, t('setup.body')),
|
|
2907
|
-
|
|
3003
|
+
busy
|
|
3004
|
+
? h('div', { key: 'prog', className: 'dvv-setup-progress' }, [
|
|
3005
|
+
h(AsrProgress, { key: 'bar', percent }),
|
|
3006
|
+
h('div', { key: 'row', className: 'dvv-install-line' }, [
|
|
3007
|
+
h('span', { key: 'p', className: 'dvv-note' }, percent === null ? phase : `${phase} · ${Math.round(percent)}%`),
|
|
3008
|
+
h('button', { key: 'c', type: 'button', className: 'dvv-btn dvv-btn-sm', onClick: onCancelInstall }, t('common.cancel')),
|
|
3009
|
+
]),
|
|
3010
|
+
])
|
|
3011
|
+
: h('div', { key: 'go', className: 'dvv-setup-actions' }, [
|
|
3012
|
+
h('button', { key: 'a', type: 'button', className: 'dvv-btn dvv-btn-sm dvv-btn-primary', onClick: onInstallAll }, t('setup.installAll')),
|
|
3013
|
+
h('button', { key: 'g', type: 'button', className: 'dvv-btn dvv-btn-sm', onClick: onOpen }, t('setup.go')),
|
|
3014
|
+
]),
|
|
2908
3015
|
]),
|
|
2909
3016
|
h('button', {
|
|
2910
3017
|
key: 'x', type: 'button', className: 'dvv-btn dvv-btn-sm dvv-setup-close',
|
|
@@ -2913,78 +3020,87 @@ window.__ModuleLoader__.load({
|
|
|
2913
3020
|
]);
|
|
2914
3021
|
}
|
|
2915
3022
|
|
|
2916
|
-
function AsrSection({ asr, saving, note, error, onConfig, onRefresh, models, modelsError, downloading, onDownloadModel, onCancelDownload, onCopied }) {
|
|
3023
|
+
function AsrSection({ asr, saving, note, error, onConfig, onRefresh, models, modelsError, downloading, onDownloadModel, onCancelDownload, onCopied, plan, planError, installing, onInstallAll, onInstall, onCancelInstall }) {
|
|
2917
3024
|
if (!asr) {
|
|
2918
3025
|
return h('div', { className: 'dvv-asr-box' }, [
|
|
2919
|
-
h('div', { key: 't', className: 'dvv-label' }, '
|
|
2920
|
-
h('div', { key: 'e', className: 'dvv-note' }, error ?
|
|
3026
|
+
h('div', { key: 't', className: 'dvv-label' }, t('asr.title')),
|
|
3027
|
+
h('div', { key: 'e', className: 'dvv-note' }, error ? t('asr.loadError', { message: error }) : t('asr.loading')),
|
|
2921
3028
|
]);
|
|
2922
3029
|
}
|
|
2923
3030
|
const config = asr.config || {};
|
|
2924
3031
|
const tools = asr.tools || {};
|
|
2925
3032
|
const modelsInfo = asr.models || {};
|
|
2926
3033
|
const engines = asr.engines || {};
|
|
2927
|
-
const hints = Array.isArray(asr.hints) ? asr.hints.filter(Boolean)
|
|
2928
|
-
const
|
|
2929
|
-
const
|
|
2930
|
-
const
|
|
2931
|
-
const
|
|
2932
|
-
|
|
3034
|
+
const hints = (Array.isArray(asr.hints) ? asr.hints : []).filter(Boolean);
|
|
3035
|
+
const uiEn = activeUiLang === 'en';
|
|
3036
|
+
const hasCjk = (text) => /[\u3400-\u9fff]/.test(String(text || ''));
|
|
3037
|
+
const safeText = (text, fallbackKey) => {
|
|
3038
|
+
const value = String(text || '').trim();
|
|
3039
|
+
if (!value) return '';
|
|
3040
|
+
return uiEn && hasCjk(value) ? t(fallbackKey) : value;
|
|
3041
|
+
};
|
|
3042
|
+
const engineKeys = { auto: 'asr.engineAuto', whisper: 'asr.engineWhisper', sensevoice: 'asr.engineSenseVoice' };
|
|
3043
|
+
const engineName = (key) => (engineKeys[key] ? t(engineKeys[key]) : String(key));
|
|
3044
|
+
const engineLabel = (key) => `${engineName(key)}${engines[key] && engines[key].available === false ? t('asr.engineNotReady') : ''}`;
|
|
3045
|
+
const frameModes = [
|
|
3046
|
+
['auto', 'asr.frameAuto', 'asr.frameAutoDesc'],
|
|
3047
|
+
['ocr', 'asr.frameOcr', 'asr.frameOcrDesc'],
|
|
3048
|
+
['vision', 'asr.frameVision', 'asr.frameVisionDesc'],
|
|
3049
|
+
];
|
|
3050
|
+
const frameName = (key) => {
|
|
3051
|
+
const item = frameModes.filter((entry) => entry[0] === key)[0];
|
|
3052
|
+
return item ? t(item[1]) : String(key);
|
|
2933
3053
|
};
|
|
2934
3054
|
const rows = [
|
|
2935
3055
|
h('div', { key: 'head', className: 'dvv-asr-head' }, [
|
|
2936
|
-
h('span', { key: 't', className: 'dvv-label' }, '
|
|
2937
|
-
saving ? h('span', { key: 'saving', className: 'dvv-note' }, '
|
|
3056
|
+
h('span', { key: 't', className: 'dvv-label' }, t('asr.title')),
|
|
3057
|
+
saving ? h('span', { key: 'saving', className: 'dvv-note' }, t('asr.saving')) : null,
|
|
2938
3058
|
].filter(Boolean)),
|
|
3059
|
+
h('div', { key: 'privacy', className: 'dvv-asr-privacy' }, t('asr.privacy')),
|
|
2939
3060
|
];
|
|
2940
|
-
if (asr.privacy) rows.push(h('div', { key: 'privacy', className: 'dvv-asr-privacy' }, String(asr.privacy)));
|
|
2941
3061
|
if (asr.ready === false) {
|
|
2942
|
-
rows.push(h('div', { key: 'miss', className: 'dvv-warn' },
|
|
2943
|
-
}
|
|
2944
|
-
if (asr.downloadReady === false) {
|
|
2945
|
-
rows.push(h('div', { key: 'dl', className: 'dvv-note' }, '提示:下载视频音轨需要 yt-dlp;ffmpeg 用于提取与转换音频。'));
|
|
3062
|
+
rows.push(h('div', { key: 'miss', className: 'dvv-warn' }, t('asr.notReady', { reason: uiEn ? t('asr.notReadyFallback') : (hints[0] || t('asr.notReadyFallback')) })));
|
|
2946
3063
|
}
|
|
3064
|
+
if (asr.downloadReady === false) rows.push(h('div', { key: 'dl', className: 'dvv-note' }, t('asr.downloadNote')));
|
|
2947
3065
|
rows.push(h('label', { key: 'enabled', className: 'dvv-check' }, [
|
|
2948
3066
|
h('input', { key: 'c', type: 'checkbox', checked: Boolean(asr.enabled), onChange: () => onConfig({ enabled: !asr.enabled }) }),
|
|
2949
|
-
h('span', { key: 't' }, asr.enabled ? '
|
|
3067
|
+
h('span', { key: 't' }, asr.enabled ? t('asr.enabledOn') : t('asr.enabledOff')),
|
|
2950
3068
|
]));
|
|
2951
3069
|
rows.push(h('label', { key: 'auto', className: 'dvv-check' }, [
|
|
2952
3070
|
h('input', {
|
|
2953
3071
|
key: 'c', type: 'checkbox', checked: config.autoTranscribe !== false,
|
|
2954
3072
|
onChange: () => onConfig({ autoTranscribe: config.autoTranscribe === false }),
|
|
2955
3073
|
}),
|
|
2956
|
-
h('span', { key: 't' }, '
|
|
3074
|
+
h('span', { key: 't' }, t('asr.autoCheck')),
|
|
2957
3075
|
]));
|
|
2958
3076
|
rows.push(h('label', { key: 'cross', className: 'dvv-check' }, [
|
|
2959
3077
|
h('input', {
|
|
2960
3078
|
key: 'c', type: 'checkbox', checked: config.crossCheck !== false,
|
|
2961
3079
|
onChange: () => onConfig({ crossCheck: config.crossCheck === false }),
|
|
2962
3080
|
}),
|
|
2963
|
-
h('span', { key: 't' }, '
|
|
3081
|
+
h('span', { key: 't' }, t('asr.crossCheck')),
|
|
2964
3082
|
]));
|
|
2965
|
-
rows.push(h('div', { key: 'cross-note', className: 'dvv-note' }, '
|
|
3083
|
+
rows.push(h('div', { key: 'cross-note', className: 'dvv-note' }, t('asr.crossNote')));
|
|
2966
3084
|
const ocr = asr.ocr || {};
|
|
3085
|
+
const ocrReason = ocr.reason ? safeText(ocr.reason, 'asr.ocrFallbackReason') : '';
|
|
2967
3086
|
rows.push(h('label', { key: 'ocr', className: 'dvv-check' }, [
|
|
2968
3087
|
h('input', {
|
|
2969
3088
|
key: 'c', type: 'checkbox', checked: config.ocrFallback !== false,
|
|
2970
3089
|
onChange: () => onConfig({ ocrFallback: config.ocrFallback === false }),
|
|
2971
3090
|
}),
|
|
2972
|
-
h('span', { key: 't' },
|
|
3091
|
+
h('span', { key: 't' }, ocr.available ? t('asr.ocrAvailable') : t('asr.ocrUnavailable', { reason: ocrReason ? ` · ${ocrReason}` : '' })),
|
|
2973
3092
|
]));
|
|
2974
|
-
if (ocr.available && ocr.note) {
|
|
2975
|
-
rows.push(h('div', { key: 'ocr-note', className: 'dvv-note' }, String(ocr.note)));
|
|
2976
|
-
}
|
|
2977
3093
|
rows.push(h('div', { key: 'ocr-numbers', className: 'dvv-asr-grid' }, [
|
|
2978
3094
|
h(AsrNumberField, {
|
|
2979
|
-
key: 'ocr-interval', label: '
|
|
2980
|
-
hint: '
|
|
3095
|
+
key: 'ocr-interval', label: t('asr.ocrInterval'), value: config.ocrIntervalSeconds ?? 8, min: 3, max: 60,
|
|
3096
|
+
hint: t('asr.ocrIntervalHint'), onCommit: (number) => onConfig({ ocrIntervalSeconds: number }),
|
|
2981
3097
|
}),
|
|
2982
3098
|
h(AsrNumberField, {
|
|
2983
|
-
key: 'ocr-frames', label: '
|
|
2984
|
-
hint: '
|
|
3099
|
+
key: 'ocr-frames', label: t('asr.ocrFrames'), value: config.ocrMaxFrames ?? 120, min: 20, max: 240,
|
|
3100
|
+
hint: t('asr.ocrFramesHint'), onCommit: (number) => onConfig({ ocrMaxFrames: number }),
|
|
2985
3101
|
}),
|
|
2986
3102
|
]));
|
|
2987
|
-
rows.push(h('div', { key: 'ocr-privacy', className: 'dvv-note' }, '
|
|
3103
|
+
rows.push(h('div', { key: 'ocr-privacy', className: 'dvv-note' }, t('asr.ocrPrivacy')));
|
|
2988
3104
|
|
|
2989
3105
|
// 「画面理解」子区块:没有可用文字时,用视觉模型看抽样画面(图片会离开本机)。
|
|
2990
3106
|
const vision = asr.vision || {};
|
|
@@ -2996,86 +3112,122 @@ window.__ModuleLoader__.load({
|
|
|
2996
3112
|
const candidates = Array.isArray(vision.candidates) ? vision.candidates : [];
|
|
2997
3113
|
const candidateLabels = candidates
|
|
2998
3114
|
.map((item) => (typeof item === 'string' ? item : String((item && (item.routeLabel || item.label || item.model)) || '')))
|
|
2999
|
-
.filter(Boolean)
|
|
3000
|
-
|
|
3001
|
-
rows.push(h('div', { key: 'vision-
|
|
3002
|
-
|
|
3115
|
+
.filter(Boolean)
|
|
3116
|
+
.filter((label) => !uiEn || !hasCjk(label));
|
|
3117
|
+
rows.push(h('div', { key: 'vision-head', className: 'dvv-label' }, t('asr.visionTitle')));
|
|
3118
|
+
rows.push(h('div', { key: 'vision-mode', className: 'dvv-vseg', role: 'group', 'aria-label': t('asr.visionMode') },
|
|
3119
|
+
frameModes.map(([key, labelKey, descKey]) => h('button', {
|
|
3003
3120
|
key, type: 'button', className: 'dvv-vseg-btn',
|
|
3004
3121
|
'data-active': frameMode === key ? 'true' : undefined,
|
|
3005
3122
|
'aria-pressed': frameMode === key ? 'true' : 'false',
|
|
3006
|
-
title:
|
|
3123
|
+
title: t(descKey),
|
|
3007
3124
|
onClick: () => onConfig({ frameMode: key }),
|
|
3008
|
-
},
|
|
3009
|
-
|
|
3125
|
+
}, t(labelKey)))));
|
|
3126
|
+
const frameDesc = () => { const item = frameModes.filter((entry) => entry[0] === frameMode)[0] || frameModes[0]; return t(item[2]); };
|
|
3127
|
+
rows.push(h('div', { key: 'vision-mode-desc', className: 'dvv-note' }, frameDesc()));
|
|
3010
3128
|
if (vision.available) {
|
|
3011
|
-
const route =
|
|
3129
|
+
const route = safeText(vision.routeLabel || [vision.provider, vision.model].filter(Boolean).join('/'), 'asr.unnamedModel') || t('asr.unnamedModel');
|
|
3130
|
+
const actual = visionMode && visionMode !== frameMode ? t('asr.visionActual', { mode: frameName(visionMode) }) : '';
|
|
3012
3131
|
rows.push(h('div', { key: 'vision-state', className: 'dvv-cap' }, [
|
|
3013
3132
|
h('span', { key: 'd', className: 'dvv-cap-dot', 'data-ok': 'true' }),
|
|
3014
|
-
h('span', { key: 't', className: 'dvv-cap-text' },
|
|
3133
|
+
h('span', { key: 't', className: 'dvv-cap-text' }, t('asr.visionReady', { route, actual })),
|
|
3015
3134
|
]));
|
|
3016
3135
|
} else {
|
|
3136
|
+
const reason = safeText(vision.reason, 'asr.visionFallbackReason') || t('asr.visionFallbackReason');
|
|
3137
|
+
const list = candidateLabels.slice(0, 2).join(uiEn ? ', ' : '、');
|
|
3017
3138
|
rows.push(h('div', { key: 'vision-state', className: 'dvv-warn' },
|
|
3018
|
-
[
|
|
3019
|
-
`画面理解不可用${vision.reason ? `:${vision.reason}` : ':当前没有可用的视觉模型或附件服务'}`,
|
|
3020
|
-
candidateLabels.length ? `可切换为 ${candidateLabels.slice(0, 2).join('、')}` : '',
|
|
3021
|
-
].filter(Boolean).join(';')));
|
|
3139
|
+
[t('asr.visionUnavailable', { reason }), list ? t('asr.visionTry', { list }) : ''].filter(Boolean).join(uiEn ? '; ' : ';')));
|
|
3022
3140
|
}
|
|
3023
3141
|
if (vision.supportsImage === false) {
|
|
3024
|
-
rows.push(h('div', { key: 'vision-image', className: 'dvv-note' }, '
|
|
3142
|
+
rows.push(h('div', { key: 'vision-image', className: 'dvv-note' }, t('asr.visionNoImage')));
|
|
3025
3143
|
}
|
|
3026
3144
|
rows.push(h('div', { key: 'vision-model', className: 'dvv-asr-field' }, [
|
|
3027
|
-
h('span', { key: 'l', className: 'dvv-label' }, '
|
|
3145
|
+
h('span', { key: 'l', className: 'dvv-label' }, t('asr.visionModel')),
|
|
3028
3146
|
h(VisionModelField, { key: 'i', value: visionModelValue, onCommit: (text) => onConfig({ visionModel: text }) }),
|
|
3029
|
-
h('span', { key: 'h', className: 'dvv-note' }, '
|
|
3147
|
+
h('span', { key: 'h', className: 'dvv-note' }, t('asr.visionModelHint')),
|
|
3030
3148
|
]));
|
|
3031
3149
|
rows.push(h('div', { key: 'vision-numbers', className: 'dvv-asr-grid' }, [
|
|
3032
3150
|
h(AsrNumberField, {
|
|
3033
|
-
key: 'vision-frames', label: '
|
|
3034
|
-
hint: '
|
|
3151
|
+
key: 'vision-frames', label: t('asr.visionFrames'), value: visionMaxFrames, min: 8, max: 160,
|
|
3152
|
+
hint: t('asr.visionFramesHint'), onCommit: (number) => onConfig({ visionMaxFrames: number }),
|
|
3035
3153
|
}),
|
|
3036
3154
|
]));
|
|
3037
|
-
|
|
3038
|
-
rows.push(h('div', { key: 'vision-privacy', className: 'dvv-note' }, String(vision.privacy)));
|
|
3039
|
-
}
|
|
3155
|
+
rows.push(h('div', { key: 'vision-privacy', className: 'dvv-note' }, t('asr.visionPrivacy')));
|
|
3040
3156
|
rows.push(h('div', { key: 'engine', className: 'dvv-asr-row' }, [
|
|
3041
|
-
h('span', { key: 'l', className: 'dvv-label' }, '
|
|
3157
|
+
h('span', { key: 'l', className: 'dvv-label' }, t('asr.engine')),
|
|
3042
3158
|
h('select', {
|
|
3043
|
-
key: 's', className: 'dvv-select', value: String(asr.engine || 'auto'), 'aria-label': '
|
|
3159
|
+
key: 's', className: 'dvv-select', value: String(asr.engine || 'auto'), 'aria-label': t('asr.engine'),
|
|
3044
3160
|
onChange: (event) => onConfig({ engine: event.target.value }),
|
|
3045
|
-
},
|
|
3161
|
+
}, ['auto', 'whisper', 'sensevoice'].map((key) => h('option', {
|
|
3046
3162
|
key, value: key, disabled: Boolean(engines[key] && engines[key].available === false),
|
|
3047
|
-
},
|
|
3048
|
-
h('span', { key: 'cur', className: 'dvv-note' },
|
|
3163
|
+
}, engineName(key)))),
|
|
3164
|
+
h('span', { key: 'cur', className: 'dvv-note' }, t('asr.engineCurrent', { engine: asr.activeEngine ? engineLabel(asr.activeEngine) : t('asr.engineUnknown') })),
|
|
3049
3165
|
]));
|
|
3050
3166
|
rows.push(h('div', { key: 'numbers', className: 'dvv-asr-grid' }, [
|
|
3051
3167
|
h(AsrNumberField, {
|
|
3052
|
-
key: 'threads', label: '
|
|
3053
|
-
hint: '
|
|
3168
|
+
key: 'threads', label: t('asr.threads'), value: config.threads ?? 0, min: 0, max: 32,
|
|
3169
|
+
hint: t('asr.threadsHint'), onCommit: (number) => onConfig({ threads: number }),
|
|
3054
3170
|
}),
|
|
3055
3171
|
h(AsrNumberField, {
|
|
3056
|
-
key: 'seconds', label: '
|
|
3057
|
-
hint: '
|
|
3172
|
+
key: 'seconds', label: t('asr.maxSeconds'), value: config.maxSeconds ?? 0, min: 0, max: 7200,
|
|
3173
|
+
hint: t('asr.maxSecondsHint'), onCommit: (number) => onConfig({ maxSeconds: number }),
|
|
3058
3174
|
}),
|
|
3059
3175
|
]));
|
|
3060
3176
|
rows.push(h('label', { key: 'keep', className: 'dvv-check' }, [
|
|
3061
3177
|
h('input', { key: 'c', type: 'checkbox', checked: Boolean(config.keepAudio), onChange: () => onConfig({ keepAudio: !config.keepAudio }) }),
|
|
3062
|
-
h('span', { key: 't' }, '
|
|
3178
|
+
h('span', { key: 't' }, t('asr.keepAudio')),
|
|
3063
3179
|
]));
|
|
3180
|
+
const installList = plan && Array.isArray(plan.plan) ? plan.plan : [];
|
|
3181
|
+
const planEntry = (key) => installList.find((item) => item && item.id === key) || null;
|
|
3182
|
+
const busyId = installing && installing.loading ? String(installing.id || '') : '';
|
|
3183
|
+
const installProgress = (key) => {
|
|
3184
|
+
const percent = Number.isFinite(installing.percent) ? installing.percent : null;
|
|
3185
|
+
const phase = String(installing.phase || t('asr.comp.installing'));
|
|
3186
|
+
return h('div', { key: `inst-${key}`, className: 'dvv-install-line' }, [
|
|
3187
|
+
h(AsrProgress, { key: 'bar', percent }),
|
|
3188
|
+
h('span', { key: 'p', className: 'dvv-note' }, percent === null ? phase : `${phase} · ${Math.round(percent)}%`),
|
|
3189
|
+
h('button', { key: 'c', type: 'button', className: 'dvv-btn dvv-btn-sm', onClick: onCancelInstall }, t('common.cancel')),
|
|
3190
|
+
]);
|
|
3191
|
+
};
|
|
3064
3192
|
rows.push(h('div', { key: 'tools-head', className: 'dvv-asr-head' }, [
|
|
3065
3193
|
h('span', { key: 't', className: 'dvv-label' }, t('asr.comp.title')),
|
|
3194
|
+
h('span', { key: 'sp', className: 'dvv-asr-spacer' }),
|
|
3195
|
+
h('button', {
|
|
3196
|
+
key: 'all', type: 'button', className: 'dvv-btn dvv-btn-sm',
|
|
3197
|
+
disabled: Boolean(busyId),
|
|
3198
|
+
onClick: () => { if (onInstallAll) onInstallAll(); },
|
|
3199
|
+
}, t('asr.comp.all')),
|
|
3066
3200
|
h('button', { key: 'r', type: 'button', className: 'dvv-btn dvv-btn-sm', onClick: () => { if (onRefresh) onRefresh(); } }, t('asr.comp.refresh')),
|
|
3067
3201
|
]));
|
|
3202
|
+
if (busyId === 'all') rows.push(installProgress('all'));
|
|
3203
|
+
if (planError) rows.push(h('div', { key: 'plan-error', className: 'dvv-note' }, String(planError)));
|
|
3068
3204
|
ASR_BINARIES.forEach(([key, labelKey, configKey]) => {
|
|
3069
3205
|
const tool = tools[key] || {};
|
|
3070
3206
|
const available = Boolean(tool.available);
|
|
3071
|
-
|
|
3207
|
+
const entry = planEntry(key);
|
|
3208
|
+
const busy = busyId === key;
|
|
3209
|
+
const cells = [
|
|
3072
3210
|
h('span', { key: 'd', className: 'dvv-cap-dot', 'data-ok': available ? 'true' : 'false' }),
|
|
3073
3211
|
h('span', { key: 'l', className: 'dvv-label dvv-path-label' }, `${t(labelKey)} · ${available ? t('asr.comp.available') : t('asr.comp.missing')}`),
|
|
3074
3212
|
h(AsrPathRow, {
|
|
3075
3213
|
key: 'p', value: String(config[configKey] || ''), placeholder: String(tool.path || t('asr.comp.placeholder')),
|
|
3076
3214
|
saving: Boolean(saving), onSave: (text) => onConfig({ [configKey]: text }),
|
|
3077
3215
|
}),
|
|
3078
|
-
]
|
|
3216
|
+
];
|
|
3217
|
+
if (!available && entry && !busy) {
|
|
3218
|
+
const isBrew = entry.method === 'brew';
|
|
3219
|
+
cells.push(h('button', {
|
|
3220
|
+
key: 'inst', type: 'button', className: 'dvv-btn dvv-btn-sm',
|
|
3221
|
+
disabled: Boolean(busyId) || Boolean(saving),
|
|
3222
|
+
title: isBrew ? t('asr.comp.brewHint') : '',
|
|
3223
|
+
onClick: () => { if (onInstall) onInstall(key); },
|
|
3224
|
+
}, isBrew ? t('asr.comp.brewInstall') : t('asr.comp.install')));
|
|
3225
|
+
}
|
|
3226
|
+
rows.push(h('div', { key: `tool-${key}`, className: 'dvv-path-line' }, cells));
|
|
3227
|
+
if (!available && entry && entry.method === 'brew' && !busy) {
|
|
3228
|
+
rows.push(h('div', { key: `brew-${key}`, className: 'dvv-note' }, t('asr.comp.brewHint')));
|
|
3229
|
+
}
|
|
3230
|
+
if (busy) rows.push(installProgress(key));
|
|
3079
3231
|
});
|
|
3080
3232
|
rows.push(h(AsrModelsBlock, {
|
|
3081
3233
|
key: 'model-cards', models: models || null, error: modelsError || '',
|
|
@@ -3088,8 +3240,9 @@ window.__ModuleLoader__.load({
|
|
|
3088
3240
|
key: 'install', platform: String(tools.platform || ''),
|
|
3089
3241
|
onCopied: () => { if (onCopied) onCopied(); },
|
|
3090
3242
|
}));
|
|
3091
|
-
|
|
3092
|
-
|
|
3243
|
+
const hintLines = uiEn ? [t('asr.hintGeneric')] : hints;
|
|
3244
|
+
hintLines.forEach((hint, index) => {
|
|
3245
|
+
rows.push(h('div', { key: `hint-${index}`, className: 'dvv-note' }, `${t('asr.hintPrefix')}${hint}`));
|
|
3093
3246
|
});
|
|
3094
3247
|
if (note) rows.push(h('div', { key: 'note', className: 'dvv-note' }, note));
|
|
3095
3248
|
if (error) rows.push(h('div', { key: 'error', className: 'dvv-error' }, error));
|
|
@@ -3098,7 +3251,7 @@ window.__ModuleLoader__.load({
|
|
|
3098
3251
|
|
|
3099
3252
|
/* -------------------------------------------------------------- 设置弹层 */
|
|
3100
3253
|
|
|
3101
|
-
function SettingsModal({ status, cookie, saving, note, onCookie, onSave, onClear, onClose, onRefresh, asr, asrSaving, asrNote, asrError, onAsrConfig, doc, onClearAnalysis, onClearChat, lang, onLang, asrModels, asrModelsError, modelDownloading, onDownloadModel, onCancelDownload, onRefreshAsr }) {
|
|
3254
|
+
function SettingsModal({ status, cookie, saving, note, onCookie, onSave, onClear, onClose, onRefresh, asr, asrSaving, asrNote, asrError, onAsrConfig, doc, onClearAnalysis, onClearChat, lang, onLang, asrModels, asrModelsError, modelDownloading, onDownloadModel, onCancelDownload, onRefreshAsr, asrPlan, installPlanError, installJob, onInstallComponent, onCancelInstall }) {
|
|
3102
3255
|
// 「清空本视频分析缓存」的二次确认只影响当前打开的视频。
|
|
3103
3256
|
const [confirmCache, setConfirmCache] = useState(false);
|
|
3104
3257
|
const model = status && status.model ? `${status.model.provider ?? '?'} · ${status.model.model ?? '?'}` : '未获取到(插件主机可能还没就绪)';
|
|
@@ -3182,6 +3335,10 @@ window.__ModuleLoader__.load({
|
|
|
3182
3335
|
models: asrModels && asrModels.models ? asrModels.models : null, modelsError: asrModelsError, downloading: modelDownloading,
|
|
3183
3336
|
onDownloadModel, onCancelDownload,
|
|
3184
3337
|
onCopied: () => {},
|
|
3338
|
+
plan: asrPlan, planError: installPlanError, installing: installJob,
|
|
3339
|
+
onInstallAll: () => { if (onInstallComponent) onInstallComponent('all'); },
|
|
3340
|
+
onInstall: (id) => { if (onInstallComponent) onInstallComponent(id); },
|
|
3341
|
+
onCancelInstall: () => { if (onCancelInstall) onCancelInstall(); },
|
|
3185
3342
|
}),
|
|
3186
3343
|
]),
|
|
3187
3344
|
]));
|
|
@@ -3229,6 +3386,9 @@ window.__ModuleLoader__.load({
|
|
|
3229
3386
|
const [asrModelsError, setAsrModelsError] = useState('');
|
|
3230
3387
|
const [modelDl, setModelDl] = useState({ id: '', loading: false, phase: '', percent: null });
|
|
3231
3388
|
const [setupDismissed, setSetupDismissed] = useState(() => readSetupDismissed());
|
|
3389
|
+
const [asrPlan, setAsrPlan] = useState(null);
|
|
3390
|
+
const [asrPlanError, setAsrPlanError] = useState('');
|
|
3391
|
+
const [installJob, setInstallJob] = useState(EMPTY_INSTALL);
|
|
3232
3392
|
const [transcribe, setTranscribe] = useState(EMPTY_TRANSCRIBE);
|
|
3233
3393
|
const [mindmap, setMindmap] = useState(EMPTY_MINDMAP);
|
|
3234
3394
|
const [titlesLoading, setTitlesLoading] = useState(false);
|
|
@@ -3384,6 +3544,8 @@ window.__ModuleLoader__.load({
|
|
|
3384
3544
|
}, []);
|
|
3385
3545
|
|
|
3386
3546
|
const modelAbort = useRef(null);
|
|
3547
|
+
const installAbort = useRef(null);
|
|
3548
|
+
const installJobRef = useRef(EMPTY_INSTALL);
|
|
3387
3549
|
|
|
3388
3550
|
/** 一键下载模型(POST /asr/models SSE,进度/取消)。 */
|
|
3389
3551
|
const downloadAsrModels = useCallback((id, force) => {
|
|
@@ -3443,6 +3605,98 @@ window.__ModuleLoader__.load({
|
|
|
3443
3605
|
if (modelAbort.current) { try { modelAbort.current.abort(); } catch { /* ignore */ } }
|
|
3444
3606
|
}, []);
|
|
3445
3607
|
|
|
3608
|
+
/* ---- 本机组件一键安装:GET /install/plan、POST /install(SSE) ---- */
|
|
3609
|
+
|
|
3610
|
+
const loadInstallPlan = useCallback(async () => {
|
|
3611
|
+
try {
|
|
3612
|
+
const value = await call('install/plan');
|
|
3613
|
+
if (!mounted.current) return;
|
|
3614
|
+
setAsrPlan(value || null);
|
|
3615
|
+
setAsrPlanError('');
|
|
3616
|
+
} catch (caught) {
|
|
3617
|
+
if (!mounted.current || (caught && caught.name === 'AbortError')) return;
|
|
3618
|
+
const message = String((caught && caught.message) || t('common.unknown'));
|
|
3619
|
+
setAsrPlanError(t('asr.comp.installPlanError', { message }));
|
|
3620
|
+
}
|
|
3621
|
+
}, []);
|
|
3622
|
+
|
|
3623
|
+
const cancelInstall = useCallback(() => {
|
|
3624
|
+
if (installAbort.current) { try { installAbort.current.abort(); } catch { /* ignore */ } }
|
|
3625
|
+
}, []);
|
|
3626
|
+
|
|
3627
|
+
const installComponents = useCallback((id) => {
|
|
3628
|
+
const target = String(id || '');
|
|
3629
|
+
if (!target || installJobRef.current.loading) return;
|
|
3630
|
+
if (installAbort.current) { try { installAbort.current.abort(); } catch { /* ignore */ } }
|
|
3631
|
+
const controller = new AbortController();
|
|
3632
|
+
installAbort.current = controller;
|
|
3633
|
+
const start = { id: target, loading: true, phase: t('asr.comp.installing'), percent: null, received: 0, total: 0 };
|
|
3634
|
+
installJobRef.current = start;
|
|
3635
|
+
setInstallJob(start);
|
|
3636
|
+
void (async () => {
|
|
3637
|
+
let finished = false;
|
|
3638
|
+
let failure = null;
|
|
3639
|
+
const names = [];
|
|
3640
|
+
try {
|
|
3641
|
+
await streamSSE('install', { id: target }, {
|
|
3642
|
+
signal: controller.signal,
|
|
3643
|
+
onEvent(event) {
|
|
3644
|
+
if (!mounted.current) return 'stop';
|
|
3645
|
+
const current = installJobRef.current;
|
|
3646
|
+
if (!current.loading) return 'stop';
|
|
3647
|
+
if (event.type === 'phase') {
|
|
3648
|
+
const next = { ...current, phase: String(event.text || current.phase) };
|
|
3649
|
+
installJobRef.current = next;
|
|
3650
|
+
setInstallJob(next);
|
|
3651
|
+
} else if (event.type === 'progress') {
|
|
3652
|
+
const raw = event.percent;
|
|
3653
|
+
const percent = raw === null || raw === undefined || raw === '' ? null : Math.max(0, Math.min(100, Number(raw)));
|
|
3654
|
+
const phase = event.stage === 'extract' ? t('asr.comp.extracting') : current.phase;
|
|
3655
|
+
const next = {
|
|
3656
|
+
...current,
|
|
3657
|
+
percent: Number.isFinite(percent) ? percent : null,
|
|
3658
|
+
phase,
|
|
3659
|
+
received: Number(event.received) || current.received,
|
|
3660
|
+
total: Number(event.total) || current.total,
|
|
3661
|
+
};
|
|
3662
|
+
installJobRef.current = next;
|
|
3663
|
+
setInstallJob(next);
|
|
3664
|
+
} else if (event.type === 'installed') {
|
|
3665
|
+
if (event.component && !names.includes(String(event.component))) names.push(String(event.component));
|
|
3666
|
+
} else if (event.type === 'done') {
|
|
3667
|
+
finished = true;
|
|
3668
|
+
return 'stop';
|
|
3669
|
+
} else if (event.type === 'error') {
|
|
3670
|
+
failure = { code: event.code, message: event.message };
|
|
3671
|
+
return 'stop';
|
|
3672
|
+
}
|
|
3673
|
+
return undefined;
|
|
3674
|
+
},
|
|
3675
|
+
});
|
|
3676
|
+
if (failure) throw failure;
|
|
3677
|
+
} catch (caught) {
|
|
3678
|
+
if (caught && caught.name === 'AbortError') {
|
|
3679
|
+
if (mounted.current) showToast(t('toast.installCancelled'));
|
|
3680
|
+
} else if (mounted.current) {
|
|
3681
|
+
showToast(friendlyInstallError(caught));
|
|
3682
|
+
}
|
|
3683
|
+
} finally {
|
|
3684
|
+
if (installAbort.current === controller) installAbort.current = null;
|
|
3685
|
+
installJobRef.current = EMPTY_INSTALL;
|
|
3686
|
+
if (mounted.current) {
|
|
3687
|
+
setInstallJob(EMPTY_INSTALL);
|
|
3688
|
+
if (finished) {
|
|
3689
|
+
if (target === 'all') showToast(t('toast.installAllDone', { count: names.length }));
|
|
3690
|
+
else showToast(t('toast.installDone', { name: names[0] || target }));
|
|
3691
|
+
void refreshAsr(true);
|
|
3692
|
+
void loadAsrModels();
|
|
3693
|
+
void loadInstallPlan();
|
|
3694
|
+
}
|
|
3695
|
+
}
|
|
3696
|
+
}
|
|
3697
|
+
})();
|
|
3698
|
+
}, [loadAsrModels, loadInstallPlan, refreshAsr, showToast]);
|
|
3699
|
+
|
|
3446
3700
|
/* ---- 历史:host 持久化(GET /history、POST /history/clear|remove) ---- */
|
|
3447
3701
|
|
|
3448
3702
|
const refreshHistory = useCallback(async () => {
|
|
@@ -4545,7 +4799,7 @@ window.__ModuleLoader__.load({
|
|
|
4545
4799
|
try { if (active.current && active.current.controller) active.current.controller.abort(); } catch { /* ignore */ }
|
|
4546
4800
|
}, []);
|
|
4547
4801
|
|
|
4548
|
-
useEffect(() => { void refreshStatus(); void refreshHistory(); void refreshAsr(); }, [refreshStatus, refreshHistory, refreshAsr]);
|
|
4802
|
+
useEffect(() => { void refreshStatus(); void refreshHistory(); void refreshAsr(); void loadInstallPlan(); }, [refreshStatus, refreshHistory, refreshAsr, loadInstallPlan]);
|
|
4549
4803
|
|
|
4550
4804
|
// 后台解析队列轮询:挂载立即拉一次;有任务 2s、空闲 10s;页面隐藏时暂停(保持 10s 心跳)。
|
|
4551
4805
|
useEffect(() => {
|
|
@@ -4602,7 +4856,7 @@ window.__ModuleLoader__.load({
|
|
|
4602
4856
|
|
|
4603
4857
|
/* ---------------------------------------------------------------- 渲染 */
|
|
4604
4858
|
|
|
4605
|
-
const openSettings = () => { setOverlay('settings'); setCookieNote(''); setAsrNote(''); void refreshAsr(); void loadAsrModels(); };
|
|
4859
|
+
const openSettings = () => { setOverlay('settings'); setCookieNote(''); setAsrNote(''); void refreshAsr(); void loadAsrModels(); void loadInstallPlan(); };
|
|
4606
4860
|
|
|
4607
4861
|
/** 历史项点击:host 记录里 url 是原链接,优先用 url 重新解析。 */
|
|
4608
4862
|
const openHistoryItem = (item) => {
|
|
@@ -4783,6 +5037,9 @@ window.__ModuleLoader__.load({
|
|
|
4783
5037
|
? h(SetupCard, {
|
|
4784
5038
|
key: 'setup', onOpen: openSettings,
|
|
4785
5039
|
onDismiss: () => { writeSetupDismissed(); setSetupDismissed(true); },
|
|
5040
|
+
onInstallAll: () => installComponents('all'),
|
|
5041
|
+
onCancelInstall: cancelInstall,
|
|
5042
|
+
installing: installJob,
|
|
4786
5043
|
})
|
|
4787
5044
|
: null,
|
|
4788
5045
|
historyItems.length
|
|
@@ -4904,7 +5161,10 @@ window.__ModuleLoader__.load({
|
|
|
4904
5161
|
asrModels, asrModelsError, modelDownloading: modelDl,
|
|
4905
5162
|
onDownloadModel: (id, force) => downloadAsrModels(id, force),
|
|
4906
5163
|
onCancelDownload: cancelModelDownload,
|
|
4907
|
-
onRefreshAsr: () => { void refreshAsr(true); void loadAsrModels(); },
|
|
5164
|
+
onRefreshAsr: () => { void refreshAsr(true); void loadAsrModels(); void loadInstallPlan(); },
|
|
5165
|
+
asrPlan, installPlanError: asrPlanError, installJob,
|
|
5166
|
+
onInstallComponent: (id) => installComponents(id),
|
|
5167
|
+
onCancelInstall: cancelInstall,
|
|
4908
5168
|
onAsrConfig: (patch) => { void submitAsrConfig(patch); },
|
|
4909
5169
|
doc, lang: langSetting, onLang: changeLang,
|
|
4910
5170
|
onClearAnalysis: (video) => { void clearAnalysisCache(video); },
|
|
@@ -5308,6 +5568,11 @@ a.dvv-toolbar-title:hover{color:var(--dsw-alias-brand-primary)}
|
|
|
5308
5568
|
.dvv-cmd{flex:1;min-width:0;overflow:auto;padding:6px 8px;border-radius:8px;background:var(--dsw-alias-bg-layer-2);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;white-space:nowrap}
|
|
5309
5569
|
.dvv-setup-card{display:flex;gap:8px;align-items:flex-start;margin:0 0 14px;padding:12px 14px;border:1px solid var(--dsw-alias-border-l1);border-left:3px solid var(--dsw-alias-brand-primary);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}
|
|
5310
5570
|
.dvv-setup-main{display:flex;flex-direction:column;gap:6px;flex:1;min-width:0}
|
|
5571
|
+
.dvv-setup-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:4px}
|
|
5572
|
+
.dvv-setup-progress{display:flex;flex-direction:column;gap:6px;margin-top:4px}
|
|
5573
|
+
.dvv-install-line{display:flex;align-items:center;gap:8px;margin:2px 0 6px}
|
|
5574
|
+
.dvv-install-line .dvv-progress{flex:1}
|
|
5575
|
+
.dvv-asr-spacer{flex:1}
|
|
5311
5576
|
.dvv-setup-close{flex:none;padding:2px 8px;font-size:14px;line-height:1.2}
|
|
5312
5577
|
@media (max-width:979px){
|
|
5313
5578
|
/* 单列:播放器 → 页签(含字幕提示条) → 追问对话框,整页滚动。
|
package/lib/index.js
CHANGED
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
} from './analysis.js';
|
|
41
41
|
import { ASR_DEFAULTS, asrSettings, asrStatus, readLocalTranscript, transcribeVideo } from './asr.js';
|
|
42
42
|
import { MODEL_CATALOG, MODEL_IDS, downloadModel, modelsStatus } from './models.js';
|
|
43
|
+
import { componentPlan, configPatchFor, installComponent, refreshToolchainCache } from './installer.js';
|
|
43
44
|
import { cleanupWorkdir, createWorkdir, detectToolchain } from './media.js';
|
|
44
45
|
import { captureFrames } from './ocr.js';
|
|
45
46
|
import { buildContactSheet } from './sheet.js';
|
|
@@ -66,7 +67,7 @@ export const name = 'dsh-video-insight';
|
|
|
66
67
|
/** Route prefix the panel calls; same origin as the GUI, so no CORS preflight. */
|
|
67
68
|
export const API_PREFIX = '/dsh-video/api';
|
|
68
69
|
|
|
69
|
-
const VERSION = '0.
|
|
70
|
+
const VERSION = '0.12.1';
|
|
70
71
|
const CREDENTIALS_FILE = join(homedir(), '.dsh', 'video-credentials.json');
|
|
71
72
|
|
|
72
73
|
const DEFAULTS = {
|
|
@@ -791,8 +792,18 @@ function createApiHandler(aiCtx, config) {
|
|
|
791
792
|
execute: (job, helpers) => runFullJob(job, helpers, { aiCtx, config, resolverFor }),
|
|
792
793
|
});
|
|
793
794
|
|
|
795
|
+
// 插件卸载/热重载时统一收尾:还在跑的 SSE 请求要 abort,后台队列要停。
|
|
796
|
+
// 否则卸载后仍有回调写响应/发请求,在 Node 24 上会变成未处理的 rejection,
|
|
797
|
+
// 直接把宿主进程带走(Windows 上启用/升级插件时最容易触发)。
|
|
798
|
+
const openControllers = new Set();
|
|
799
|
+
function trackController(controller) {
|
|
800
|
+
openControllers.add(controller);
|
|
801
|
+
controller.signal.addEventListener('abort', () => openControllers.delete(controller), { once: true });
|
|
802
|
+
return controller;
|
|
803
|
+
}
|
|
804
|
+
|
|
794
805
|
|
|
795
|
-
|
|
806
|
+
const handler = async (req, res) => {
|
|
796
807
|
const url = new URL(req.url ?? '/', 'http://127.0.0.1');
|
|
797
808
|
const route = url.pathname.slice(API_PREFIX.length) || '/';
|
|
798
809
|
const saved = await readSavedCredentials();
|
|
@@ -846,6 +857,81 @@ function createApiHandler(aiCtx, config) {
|
|
|
846
857
|
return;
|
|
847
858
|
}
|
|
848
859
|
|
|
860
|
+
// 本机组件:安装计划 + 一键安装(SSE 带进度)
|
|
861
|
+
if (req.method === 'GET' && route === '/install/plan') {
|
|
862
|
+
const asr = asrSettings(settings);
|
|
863
|
+
const tools = await asrStatus(settings, { fresh: true });
|
|
864
|
+
const plan = componentPlan(asr).map((item) => {
|
|
865
|
+
const tool = tools.tools?.[item.id === 'ytdlp' ? 'ytdlp' : item.id];
|
|
866
|
+
return {
|
|
867
|
+
...item,
|
|
868
|
+
installed: Boolean(tool?.available),
|
|
869
|
+
detectedPath: tool?.path ?? '',
|
|
870
|
+
};
|
|
871
|
+
});
|
|
872
|
+
json(res, 200, { ok: true, value: { platform: tools.tools?.platform ?? process.platform, plan } });
|
|
873
|
+
return;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
if (req.method === 'POST' && route === '/install') {
|
|
877
|
+
const body = await readBody(req);
|
|
878
|
+
sseOpen(res);
|
|
879
|
+
const controller = trackController(new AbortController());
|
|
880
|
+
const onClose = () => {
|
|
881
|
+
if (!res.writableEnded) controller.abort();
|
|
882
|
+
};
|
|
883
|
+
res.on('close', onClose);
|
|
884
|
+
try {
|
|
885
|
+
const requested = String(body?.id ?? 'all');
|
|
886
|
+
const ids = requested === 'all' ? ['ffmpeg', 'ffprobe', 'ytdlp', 'whisper', 'sherpa'] : [requested];
|
|
887
|
+
for (const id of ids) {
|
|
888
|
+
if (!['ffmpeg', 'ffprobe', 'ytdlp', 'whisper', 'sherpa'].includes(id)) {
|
|
889
|
+
throw new VideoError('bad-component', `未知组件:${id}`);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
let savedNext = saved;
|
|
893
|
+
const installed = [];
|
|
894
|
+
for (const id of ids) {
|
|
895
|
+
if (controller.signal.aborted) throw new VideoError('aborted', '已取消。');
|
|
896
|
+
sseSend(res, { type: 'phase', text: `开始安装 ${id}…` });
|
|
897
|
+
const result = await installComponent({
|
|
898
|
+
id,
|
|
899
|
+
asr: asrSettings(settings),
|
|
900
|
+
signal: controller.signal,
|
|
901
|
+
onProgress: (event) => sseSend(res, {
|
|
902
|
+
type: 'progress',
|
|
903
|
+
component: event.component ?? id,
|
|
904
|
+
stage: event.stage ?? 'download',
|
|
905
|
+
percent: event.percent ?? null,
|
|
906
|
+
received: event.received ?? 0,
|
|
907
|
+
total: event.total ?? 0,
|
|
908
|
+
}),
|
|
909
|
+
});
|
|
910
|
+
const patch = configPatchFor(id, result.path);
|
|
911
|
+
savedNext = { ...savedNext, asr: sanitizeAsr(patch, sanitizeAsr(savedNext?.asr, sanitizeAsr(DEFAULTS.asr))) };
|
|
912
|
+
await writeSavedCredentials(savedNext);
|
|
913
|
+
installed.push(result);
|
|
914
|
+
sseSend(res, { type: 'installed', component: id, path: result.path });
|
|
915
|
+
}
|
|
916
|
+
refreshToolchainCache();
|
|
917
|
+
sseSend(res, {
|
|
918
|
+
type: 'done',
|
|
919
|
+
installed,
|
|
920
|
+
status: await asrStatus(settingsFrom(config, savedNext), { fresh: true }),
|
|
921
|
+
});
|
|
922
|
+
} catch (error) {
|
|
923
|
+
sseSend(res, {
|
|
924
|
+
type: 'error',
|
|
925
|
+
code: controller.signal.aborted ? 'aborted' : (error?.code ?? 'install-failed'),
|
|
926
|
+
message: controller.signal.aborted ? '已取消' : String(error?.message ?? error),
|
|
927
|
+
});
|
|
928
|
+
} finally {
|
|
929
|
+
res.off?.('close', onClose);
|
|
930
|
+
sseClose(res);
|
|
931
|
+
}
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
|
|
849
935
|
// 本地模型:状态 + 一键下载(SSE 带进度)
|
|
850
936
|
if (req.method === 'GET' && route === '/asr/models') {
|
|
851
937
|
const asr = asrSettings(settings);
|
|
@@ -866,7 +952,7 @@ function createApiHandler(aiCtx, config) {
|
|
|
866
952
|
if (req.method === 'POST' && route === '/asr/models') {
|
|
867
953
|
const body = await readBody(req);
|
|
868
954
|
sseOpen(res);
|
|
869
|
-
const controller = new AbortController();
|
|
955
|
+
const controller = trackController(new AbortController());
|
|
870
956
|
const onClose = () => {
|
|
871
957
|
if (!res.writableEnded) controller.abort();
|
|
872
958
|
};
|
|
@@ -1026,7 +1112,7 @@ function createApiHandler(aiCtx, config) {
|
|
|
1026
1112
|
const body = await readBody(req);
|
|
1027
1113
|
sseOpen(res);
|
|
1028
1114
|
|
|
1029
|
-
const controller = new AbortController();
|
|
1115
|
+
const controller = trackController(new AbortController());
|
|
1030
1116
|
const onClose = () => {
|
|
1031
1117
|
if (!res.writableEnded) controller.abort();
|
|
1032
1118
|
};
|
|
@@ -1300,7 +1386,7 @@ function createApiHandler(aiCtx, config) {
|
|
|
1300
1386
|
return;
|
|
1301
1387
|
}
|
|
1302
1388
|
sseOpen(res);
|
|
1303
|
-
const controller = new AbortController();
|
|
1389
|
+
const controller = trackController(new AbortController());
|
|
1304
1390
|
res.on('close', () => {
|
|
1305
1391
|
if (!res.writableEnded) controller.abort();
|
|
1306
1392
|
});
|
|
@@ -1390,7 +1476,7 @@ function createApiHandler(aiCtx, config) {
|
|
|
1390
1476
|
if (req.method === 'POST' && route === '/storyboard') {
|
|
1391
1477
|
const body = await readBody(req);
|
|
1392
1478
|
sseOpen(res);
|
|
1393
|
-
const controller = new AbortController();
|
|
1479
|
+
const controller = trackController(new AbortController());
|
|
1394
1480
|
const onClose = () => {
|
|
1395
1481
|
if (!res.writableEnded) controller.abort();
|
|
1396
1482
|
};
|
|
@@ -1461,7 +1547,7 @@ function createApiHandler(aiCtx, config) {
|
|
|
1461
1547
|
if (req.method === 'POST' && route === '/translate') {
|
|
1462
1548
|
const body = await readBody(req);
|
|
1463
1549
|
sseOpen(res);
|
|
1464
|
-
const controller = new AbortController();
|
|
1550
|
+
const controller = trackController(new AbortController());
|
|
1465
1551
|
const onClose = () => {
|
|
1466
1552
|
if (!res.writableEnded) controller.abort();
|
|
1467
1553
|
};
|
|
@@ -1586,7 +1672,7 @@ function createApiHandler(aiCtx, config) {
|
|
|
1586
1672
|
const body = await readBody(req);
|
|
1587
1673
|
sseOpen(res);
|
|
1588
1674
|
|
|
1589
|
-
const controller = new AbortController();
|
|
1675
|
+
const controller = trackController(new AbortController());
|
|
1590
1676
|
const onClose = () => {
|
|
1591
1677
|
if (!res.writableEnded) controller.abort();
|
|
1592
1678
|
};
|
|
@@ -1737,6 +1823,17 @@ function createApiHandler(aiCtx, config) {
|
|
|
1737
1823
|
json(res, 200, { ok: false, code: error?.code ?? 'internal', error: String(error?.message ?? error) });
|
|
1738
1824
|
}
|
|
1739
1825
|
};
|
|
1826
|
+
|
|
1827
|
+
// 卸载时由 apply() 的 effect 清理函数调用。
|
|
1828
|
+
handler.dispose = () => {
|
|
1829
|
+
try { jobQueue.abortAll(); } catch { /* ignore */ }
|
|
1830
|
+
for (const controller of [...openControllers]) {
|
|
1831
|
+
try { controller.abort(); } catch { /* ignore */ }
|
|
1832
|
+
}
|
|
1833
|
+
openControllers.clear();
|
|
1834
|
+
};
|
|
1835
|
+
|
|
1836
|
+
return handler;
|
|
1740
1837
|
}
|
|
1741
1838
|
|
|
1742
1839
|
/* --------------------------------- apply --------------------------------- */
|
|
@@ -1764,11 +1861,17 @@ export function apply(ctx, config) {
|
|
|
1764
1861
|
// 1. the panel's JSON/SSE API, on the profile's web server
|
|
1765
1862
|
ctx.inject(['webServer'], (webCtx) => {
|
|
1766
1863
|
const handler = createApiHandler(ai, config);
|
|
1767
|
-
webCtx.effect(() =>
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1864
|
+
webCtx.effect(() => {
|
|
1865
|
+
const unregister = webCtx.webServer.register({
|
|
1866
|
+
kind: 'prefix',
|
|
1867
|
+
path: API_PREFIX,
|
|
1868
|
+
handler,
|
|
1869
|
+
});
|
|
1870
|
+
return () => {
|
|
1871
|
+
try { handler.dispose?.(); } catch { /* ignore */ }
|
|
1872
|
+
unregister?.();
|
|
1873
|
+
};
|
|
1874
|
+
}, 'dsh-video: panel api');
|
|
1772
1875
|
});
|
|
1773
1876
|
|
|
1774
1877
|
// 2. the agent-facing tools(自己一份解析缓存,和面板互不影响)。
|
package/lib/installer.js
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-video host 半 · 本机组件「一键安装」
|
|
3
|
+
*
|
|
4
|
+
* 只下载「便携版」二进制到 `~/.dsh/video-tools/` 下,不碰系统包管理器:
|
|
5
|
+
* - ffmpeg / ffprobe:ffmpeg-static 的预编译包(macOS arm64/x64、Windows x64)
|
|
6
|
+
* - yt-dlp:官方单文件二进制
|
|
7
|
+
* - whisper-cli:whisper.cpp 的 Windows 预编译包(macOS/Linux 用 Homebrew 更省事,这里只给提示)
|
|
8
|
+
* - sherpa-onnx:官方 static-no-tts 预编译包
|
|
9
|
+
*
|
|
10
|
+
* 下载完自动把路径写进 asr 配置(ffmpegPath / ffprobePath / ytdlpPath /
|
|
11
|
+
* whisperBinaryPath / sherpaBinaryPath),面板不用再手填。
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { createGunzip } from 'node:zlib';
|
|
15
|
+
import { createWriteStream } from 'node:fs';
|
|
16
|
+
import { chmod, mkdir, readdir, rename, rm, stat } from 'node:fs/promises';
|
|
17
|
+
import { dirname, join } from 'node:path';
|
|
18
|
+
import { Readable } from 'node:stream';
|
|
19
|
+
import { pipeline } from 'node:stream/promises';
|
|
20
|
+
import { homedir } from 'node:os';
|
|
21
|
+
import { VideoError } from './util.js';
|
|
22
|
+
import { invalidateToolchain, runProcess, TOOLS_DIR } from './media.js';
|
|
23
|
+
|
|
24
|
+
const WIN = process.platform === 'win32';
|
|
25
|
+
const EXE = WIN ? '.exe' : '';
|
|
26
|
+
const ARCH = process.arch === 'arm64' ? 'arm64' : 'x64';
|
|
27
|
+
|
|
28
|
+
export const INSTALL_DIR = join(TOOLS_DIR, 'bin');
|
|
29
|
+
const SHERPA_DIR = join(TOOLS_DIR, 'sherpa-onnx');
|
|
30
|
+
const WHISPER_DIR = join(TOOLS_DIR, 'whisper');
|
|
31
|
+
|
|
32
|
+
/** 已知可用的兜底版本(GitHub API 不可达时用)。 */
|
|
33
|
+
const FALLBACK = {
|
|
34
|
+
ffmpegStatic: 'b6.1.1',
|
|
35
|
+
whisper: 'b5454',
|
|
36
|
+
sherpa: 'v2.0.2',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
function platformTag() {
|
|
40
|
+
if (WIN) return `win32-${ARCH}`;
|
|
41
|
+
if (process.platform === 'darwin') return `darwin-${ARCH}`;
|
|
42
|
+
return `linux-${ARCH}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function sherpaAssetPattern() {
|
|
46
|
+
if (WIN) return new RegExp(`sherpa-onnx-v[\\d.]+-win-${ARCH}-static-MT-Release-no-tts\\.tar\\.bz2$`);
|
|
47
|
+
if (process.platform === 'darwin') return new RegExp(`sherpa-onnx-v[\\d.]+-osx-${ARCH}-static-no-tts\\.tar\\.bz2$`);
|
|
48
|
+
return new RegExp(`sherpa-onnx-v[\\d.]+-linux-${ARCH}-static-no-tts\\.tar\\.bz2$`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function ghLatestAsset(repo, matcher, fallbackUrl) {
|
|
52
|
+
try {
|
|
53
|
+
const response = await fetch(`https://api.github.com/repos/${repo}/releases?per_page=10`, {
|
|
54
|
+
headers: { accept: 'application/vnd.github+json', 'user-agent': 'dsh-video-insight' },
|
|
55
|
+
});
|
|
56
|
+
if (response.ok) {
|
|
57
|
+
const releases = await response.json();
|
|
58
|
+
for (const release of Array.isArray(releases) ? releases : []) {
|
|
59
|
+
for (const asset of release.assets ?? []) {
|
|
60
|
+
if (matcher(asset.name)) {
|
|
61
|
+
return { url: asset.browser_download_url, name: asset.name, size: asset.size, tag: release.tag_name };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} catch {
|
|
67
|
+
// 忽略:下面用兜底地址
|
|
68
|
+
}
|
|
69
|
+
return fallbackUrl ? { url: fallbackUrl, name: '', size: 0 } : null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function downloadToFile({ url, dest, onProgress, signal }) {
|
|
73
|
+
await mkdir(dirname(dest), { recursive: true });
|
|
74
|
+
const part = `${dest}.part`;
|
|
75
|
+
await rm(part, { force: true });
|
|
76
|
+
let response;
|
|
77
|
+
try {
|
|
78
|
+
response = await fetch(url, { redirect: 'follow', signal });
|
|
79
|
+
} catch (error) {
|
|
80
|
+
throw new VideoError('install-download-failed', `下载失败:${error?.message ?? error}`);
|
|
81
|
+
}
|
|
82
|
+
if (!response.ok || !response.body) throw new VideoError('install-download-failed', `下载失败:HTTP ${response.status}`);
|
|
83
|
+
const total = Number(response.headers.get('content-length')) || 0;
|
|
84
|
+
let received = 0;
|
|
85
|
+
const reader = response.body.getReader();
|
|
86
|
+
const source = new Readable({
|
|
87
|
+
async read() {
|
|
88
|
+
try {
|
|
89
|
+
const { done, value } = await reader.read();
|
|
90
|
+
if (done) {
|
|
91
|
+
this.push(null);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
received += value.length;
|
|
95
|
+
onProgress?.({ received, total, percent: total ? Math.min(100, Math.round((received / total) * 100)) : null });
|
|
96
|
+
this.push(Buffer.from(value));
|
|
97
|
+
} catch (error) {
|
|
98
|
+
this.destroy(error);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
try {
|
|
103
|
+
await pipeline(source, createWriteStream(part, { mode: 0o600 }));
|
|
104
|
+
} catch (error) {
|
|
105
|
+
await rm(part, { force: true }).catch(() => {});
|
|
106
|
+
if (signal?.aborted) throw new VideoError('aborted', '已取消。');
|
|
107
|
+
throw new VideoError('install-download-failed', `下载中断:${error?.message ?? error}`);
|
|
108
|
+
}
|
|
109
|
+
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
110
|
+
try {
|
|
111
|
+
await rename(part, dest);
|
|
112
|
+
return received;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (attempt === 4) {
|
|
115
|
+
await rm(dest, { force: true }).catch(() => {});
|
|
116
|
+
try {
|
|
117
|
+
await rename(part, dest);
|
|
118
|
+
return received;
|
|
119
|
+
} catch {
|
|
120
|
+
await rm(part, { force: true }).catch(() => {});
|
|
121
|
+
throw new VideoError('install-download-failed', `保存失败:${error?.message ?? error}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
await new Promise((resolve) => setTimeout(resolve, 200 * (attempt + 1)));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
throw new VideoError('install-download-failed', '保存失败。');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function gunzip({ src, dest, onProgress, signal }) {
|
|
131
|
+
await mkdir(dirname(dest), { recursive: true });
|
|
132
|
+
const total = (await stat(src)).size;
|
|
133
|
+
let received = 0;
|
|
134
|
+
const source = createWriteStream(dest, { mode: 0o755 });
|
|
135
|
+
const reader = (await import('node:fs')).createReadStream(src);
|
|
136
|
+
reader.on('data', (chunk) => {
|
|
137
|
+
received += chunk.length;
|
|
138
|
+
onProgress?.({ received, total, percent: total ? Math.min(100, Math.round((received / total) * 100)) : null });
|
|
139
|
+
});
|
|
140
|
+
await pipeline(reader, createGunzip(), source);
|
|
141
|
+
await chmod(dest, 0o755).catch(() => {});
|
|
142
|
+
if (signal?.aborted) throw new VideoError('aborted', '已取消。');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function extractArchive({ archive, dest, signal }) {
|
|
146
|
+
await mkdir(dest, { recursive: true });
|
|
147
|
+
try {
|
|
148
|
+
await runProcess('tar', ['-xf', archive, '-C', dest], {
|
|
149
|
+
timeoutMs: 10 * 60_000,
|
|
150
|
+
label: `解压 ${archive.split(/[\\/]/).pop()}`,
|
|
151
|
+
code: 'install-extract-failed',
|
|
152
|
+
signal,
|
|
153
|
+
});
|
|
154
|
+
} catch (error) {
|
|
155
|
+
if (signal?.aborted) throw new VideoError('aborted', '已取消。');
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async function findExecutable(dir, names, depth = 3) {
|
|
161
|
+
const queue = [{ dir, depth: 0 }];
|
|
162
|
+
while (queue.length) {
|
|
163
|
+
const item = queue.shift();
|
|
164
|
+
if (item.depth > depth) continue;
|
|
165
|
+
for (const name of names) {
|
|
166
|
+
const candidate = join(item.dir, name);
|
|
167
|
+
try {
|
|
168
|
+
const info = await stat(candidate);
|
|
169
|
+
if (info.isFile()) {
|
|
170
|
+
await chmod(candidate, 0o755).catch(() => {});
|
|
171
|
+
return candidate;
|
|
172
|
+
}
|
|
173
|
+
} catch {
|
|
174
|
+
// 继续找
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
let entries = [];
|
|
178
|
+
try {
|
|
179
|
+
entries = await readdir(item.dir, { withFileTypes: true });
|
|
180
|
+
} catch {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
for (const entry of entries) {
|
|
184
|
+
if (entry.isDirectory()) queue.push({ dir: join(item.dir, entry.name), depth: item.depth + 1 });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return '';
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function ffmpegStaticUrl(kind) {
|
|
191
|
+
const tag = FALLBACK.ffmpegStatic;
|
|
192
|
+
const plat = WIN ? `win32-${ARCH}` : `darwin-${ARCH}`;
|
|
193
|
+
return `https://github.com/eugeneware/ffmpeg-static/releases/download/${tag}/${kind}-${plat}.gz`;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** 每个组件在当前平台上的安装方式(供面板展示 + 执行)。 */
|
|
197
|
+
export function componentPlan(asr = {}) {
|
|
198
|
+
const items = [
|
|
199
|
+
{ id: 'ffmpeg', label: 'ffmpeg', method: 'download', bytes: WIN ? 29_000_000 : 19_000_000, path: asr.ffmpegPath || '' },
|
|
200
|
+
{ id: 'ffprobe', label: 'ffprobe', method: 'download', bytes: WIN ? 29_000_000 : 19_000_000, path: asr.ffprobePath || '' },
|
|
201
|
+
{ id: 'ytdlp', label: 'yt-dlp', method: 'download', bytes: 37_000_000, path: asr.ytdlpPath || '' },
|
|
202
|
+
{ id: 'whisper', label: 'whisper-cli', method: WIN ? 'download' : 'brew', bytes: WIN ? 8_000_000 : 0, path: asr.whisperBinaryPath || '' },
|
|
203
|
+
{ id: 'sherpa', label: 'sherpa-onnx', method: 'download', bytes: WIN ? 240_000_000 : 246_000_000, path: asr.sherpaBinaryPath || '' },
|
|
204
|
+
];
|
|
205
|
+
return items.map((item) => ({
|
|
206
|
+
...item,
|
|
207
|
+
platform: platformTag(),
|
|
208
|
+
hint: item.method === 'brew'
|
|
209
|
+
? 'macOS/Linux 上推荐 `brew install whisper.cpp`(或改用 SenseVoice 引擎)'
|
|
210
|
+
: '',
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* 安装一个组件。返回 `{ id, path }`,调用方负责把 path 写进 asr 配置。
|
|
216
|
+
*/
|
|
217
|
+
export async function installComponent({ id, asr = {}, onProgress, signal }) {
|
|
218
|
+
if (!['ffmpeg', 'ffprobe', 'ytdlp', 'whisper', 'sherpa'].includes(id)) {
|
|
219
|
+
throw new VideoError('bad-component', `未知组件:${id}`);
|
|
220
|
+
}
|
|
221
|
+
if (id === 'whisper' && !WIN) {
|
|
222
|
+
throw new VideoError('install-needs-brew', 'macOS/Linux 请用 Homebrew 安装:brew install whisper.cpp');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const progress = (event) => onProgress?.({ component: id, ...event });
|
|
226
|
+
|
|
227
|
+
if (id === 'ffmpeg' || id === 'ffprobe') {
|
|
228
|
+
const dest = join(INSTALL_DIR, `${id}${EXE}`);
|
|
229
|
+
const gz = `${dest}.gz`;
|
|
230
|
+
await downloadToFile({ url: ffmpegStaticUrl(id), dest: gz, signal, onProgress: (event) => progress({ stage: 'download', ...event }) });
|
|
231
|
+
await gunzip({ src: gz, dest, signal, onProgress: (event) => progress({ stage: 'extract', ...event }) });
|
|
232
|
+
await rm(gz, { force: true });
|
|
233
|
+
return { id, path: dest };
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (id === 'ytdlp') {
|
|
237
|
+
const dest = join(INSTALL_DIR, `yt-dlp${EXE}`);
|
|
238
|
+
const url = WIN
|
|
239
|
+
? 'https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe'
|
|
240
|
+
: process.platform === 'darwin'
|
|
241
|
+
? 'https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_macos'
|
|
242
|
+
: 'https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux';
|
|
243
|
+
await downloadToFile({ url, dest, signal, onProgress: (event) => progress({ stage: 'download', ...event }) });
|
|
244
|
+
await chmod(dest, 0o755).catch(() => {});
|
|
245
|
+
return { id, path: dest };
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (id === 'whisper') {
|
|
249
|
+
const asset = await ghLatestAsset(
|
|
250
|
+
'ggml-org/whisper.cpp',
|
|
251
|
+
(name) => name === `whisper-bin-${ARCH === 'arm64' ? 'win-cpu-arm64' : 'x64'}.zip` || name === 'whisper-bin-x64.zip',
|
|
252
|
+
`https://github.com/ggml-org/whisper.cpp/releases/download/${FALLBACK.whisper}/whisper-bin-x64.zip`,
|
|
253
|
+
);
|
|
254
|
+
const zip = join(INSTALL_DIR, 'whisper-bin.zip');
|
|
255
|
+
await downloadToFile({ url: asset.url, dest: zip, signal, onProgress: (event) => progress({ stage: 'download', ...event }) });
|
|
256
|
+
await rm(WHISPER_DIR, { recursive: true, force: true }).catch(() => {});
|
|
257
|
+
await extractArchive({ archive: zip, dest: WHISPER_DIR, signal });
|
|
258
|
+
await rm(zip, { force: true });
|
|
259
|
+
const found = await findExecutable(WHISPER_DIR, ['whisper-cli.exe', 'whisper-cli', 'main.exe']);
|
|
260
|
+
if (!found) throw new VideoError('install-extract-failed', '压缩包里没找到 whisper-cli');
|
|
261
|
+
return { id, path: found };
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// sherpa-onnx
|
|
265
|
+
const asset = await ghLatestAsset(
|
|
266
|
+
'k2-fsa/sherpa-onnx',
|
|
267
|
+
(name) => sherpaAssetPattern().test(name),
|
|
268
|
+
`https://github.com/k2-fsa/sherpa-onnx/releases/download/${FALLBACK.sherpa}/${process.platform === 'darwin' ? `sherpa-onnx-${FALLBACK.sherpa}-osx-${ARCH}-static-no-tts` : `sherpa-onnx-${FALLBACK.sherpa}-win-${ARCH}-static-MT-Release-no-tts`}.tar.bz2`,
|
|
269
|
+
);
|
|
270
|
+
if (!asset) throw new VideoError('install-unavailable', '当前平台没有找到 sherpa-onnx 预编译包');
|
|
271
|
+
const archive = join(INSTALL_DIR, 'sherpa-onnx.tar.bz2');
|
|
272
|
+
await downloadToFile({ url: asset.url, dest: archive, signal, onProgress: (event) => progress({ stage: 'download', ...event }) });
|
|
273
|
+
await rm(SHERPA_DIR, { recursive: true, force: true }).catch(() => {});
|
|
274
|
+
await extractArchive({ archive, dest: SHERPA_DIR, signal });
|
|
275
|
+
await rm(archive, { force: true });
|
|
276
|
+
const found = await findExecutable(SHERPA_DIR, [`sherpa-onnx-offline${EXE}`, 'sherpa-onnx-offline']);
|
|
277
|
+
if (!found) throw new VideoError('install-extract-failed', '压缩包里没找到 sherpa-onnx-offline');
|
|
278
|
+
return { id, path: found };
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** 组件装完把路径写回 asr 配置(只写该组件对应的键)。 */
|
|
282
|
+
export function configPatchFor(id, path) {
|
|
283
|
+
if (id === 'ffmpeg') return { ffmpegPath: path };
|
|
284
|
+
if (id === 'ffprobe') return { ffprobePath: path };
|
|
285
|
+
if (id === 'ytdlp') return { ytdlpPath: path };
|
|
286
|
+
if (id === 'whisper') return { whisperBinaryPath: path };
|
|
287
|
+
if (id === 'sherpa') return { sherpaBinaryPath: path };
|
|
288
|
+
return {};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export function refreshToolchainCache() {
|
|
292
|
+
invalidateToolchain();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export const HOME_TOOLS = TOOLS_DIR || join(homedir(), '.dsh', 'video-tools');
|
package/lib/jobs.js
CHANGED
|
@@ -122,7 +122,19 @@ export function createJobQueue({ concurrency = DEFAULT_CONCURRENCY, execute } =
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
// 插件被卸载/热重载时把还在跑的任务全部停掉:卸载后仍有异步回调会变成
|
|
126
|
+
// 未处理的 rejection,Node 24 默认直接让宿主进程退出(Windows 上启用/升级插件时尤其危险)。
|
|
127
|
+
function abortAll() {
|
|
128
|
+
for (const job of jobs.values()) {
|
|
129
|
+
if (job.controller && !job.controller.signal.aborted) {
|
|
130
|
+
try { job.controller.abort(); } catch { /* 已结束 */ }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
queue.length = 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
125
136
|
return {
|
|
137
|
+
abortAll,
|
|
126
138
|
concurrency: limit,
|
|
127
139
|
/** 启动一个任务;同一视频已有排队/运行中的任务时直接返回那一个。 */
|
|
128
140
|
start({ docId = '', url = '', title = '', describe = true, lang = '' } = {}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-video-insight",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "在 DeepSeek Harness 里快速分析视频:左侧栏「视频解析」面板,粘贴 YouTube / 哔哩哔哩链接,自动抓字幕并生成总结、章节、要点、原文与追问;无字幕时可用本机 Whisper / SenseVoice 转写兜底(音频不出本机),纯无声视频还能用画面文字识别(OCR)或视觉模型描述画面;右栏有 AI 思维导图;追问是基于转写稿的 RAG 问答(回答带「依据」时间戳);分析结果按视频缓存,历史记录可回看。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jerry (Azerz)",
|