Repository navigation
Conversation
`.mp4` had no viewer, so it fell through to the `code` catch-all, came back binary from fs.read and landed on the download pane. This adds: - a built-in `media` viewer (`fetchStrategy: 'mediaUrl'`): <audio> for the audio containers, <video> for everything else, `preload="metadata"`, and the download link kept as the escape hatch; - media MIME types on `/sidebar/file` (video/mp4, video/webm, audio/mpeg, ...); - HTTP Range on the same route (206 + content-range, suffix ranges, clamping past EOF, 416 + `bytes */size`, multi-range / non-bytes headers fall back to 200), so the player scrubs instead of buffering to EOF. Tests: Range cases on a real node:http server, byteRangeOf units, the media viewer's claim surface, the MIME table, and the 21-language key-set equality for the two new strings.
2 tasks done
Author
|
补一条服务端事实,供这个 PR 与 #1036 的取舍参考。
这不是只有「内置 viewer」才会踩到的问题。推荐目录里的 所以本 PR 可以拆开看:
我这边已先按插件路线落地(fork 了 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
动机
侧边栏打开
.mp4时没有任何 viewer 认领,文件落进code兜底:fsRead读到 NUL 判二进制 → 停在「此文件类型不支持预览 · 下载查看」。agent 刚产出的成片只能下载到外部播放器看。同时
/sidebar/file的两处缺口让任何<video>都难受:MEDIA_TYPES没有视频/音频条目,一律application/octet-stream——<video>靠 Content-Type 选 demuxer,等于让浏览器猜容器;方案
mediaviewer(fetchStrategy: 'mediaUrl'):音频走<audio>、视频走<video>,preload="metadata"不预下整片;解码失败或地址缺失时显示提示并保留「下载」链接。不把字节复制进 Blob,也不缓冲整份文件。MEDIA_TYPES补齐:mp4/m4v/webm/ogv/mov与mp3/m4a/aac/wav/flac/ogg/oga/opus。/sidebar/file增加accept-ranges: bytes与 Range 处理(src/file-stream.ts的byteRangeOf+streamFileToResponse(..., range)):单段答 206 +content-range;支持后缀区间(bytes=-500)与越界 end 钳制;起点越界答 416 +bytes */size;多段 / 非bytes头回退整份 200(无 Range 头时行为与现在完全一致)。?download=1的续传同享。与推荐插件的关系
src/client/plugins-viewers.ts里已推荐dsh-video-preview(自带/video路由)。本 PR 的定位不是替代它,而是补两件只有本插件能做、且对任何 viewer 都成立的事:自己的/sidebar/file此前既没有媒体 MIME 也没有 Range。内置 viewer 让"刚生成的成片"开箱可看(零安装);装了第三方 viewer 时按「同扩展名 + 更高 priority」覆盖即可。验证
Windows 11 / Node 24 / pnpm 11.8:
pnpm typecheck✅ |pnpm lint✅ |pnpm build✅pnpm exec vitest run tests/builtins.spec.ts tests/file-stream-route.spec.ts tests/locales.spec.ts tests/native-surface.spec.ts tests/file-open-claim.spec.ts tests/editor-large-file.spec.tsx tests/plugin-list.spec.ts tests/theme.spec.ts→ 168 通过 / 1 失败;唯一失败是serves a file reached through a symlink(本机无创建符号链接权限,改动前即失败,与本次改动无关)。node:http服务器)、byteRangeOf单测、media的认领面与mediaUrl策略、媒体 MIME 表、21 种语言的键集对齐。pnpm test:mount(需要 Playwright 与全新 scratch profile)与全量单 worker 套件。兼容
dsh-client-ui-primitives)。viewerMedia/mediaUnplayable),tests/locales.spec.ts的键集一致性与docs/external-plugin-guide.md§5 的清单同批更新。