Repository navigation
feat(captions): import SRT/WebVTT and export SRT/WebVTT in the browser build - #72
Closed
YueyuHoshizora wants to merge 2 commits into
Closed
YueyuHoshizora wants to merge 2 commits into
YueyuHoshizora wants to merge 2 commits into
Conversation
…r build Add node-free caption file parsing and serialization, an import action that adds all cues in one undoable batch, and browser-only export. Desktop export needs a native save channel and is not included. Refs Hao0321#60 Signed-off-by: Yueyu Hoshizora <yueyuhoshizora@gmail.com>
Hao0321
requested changes
Sep 30, 2026
Hao0321
left a comment
Owner
There was a problem hiding this comment.
The caption parser does not meet the bounded-input processing requirement. Maintainer validation of the actual compiled parser shows that admissible literal cue text below the stated size limit can exceed a one-second execution deadline; normal cue and timeout controls were verified. Replace the repeated suffix searches with genuinely bounded processing and retain literal-text correctness. Also preserve the already reviewed owner-only Pages workflow. Keep the new feature unmerged until these regressions and the native import path have meaningful coverage.
Owner
|
感謝你的貢獻!Editkin 已確定以本機桌面版為主,不再發展網頁版,GitHub Pages 部署也會移除(見 #87),所以這個 PR 先關閉。 SRT/WebVTT 的匯入匯出對桌面版也有價值。如果你願意,歡迎以桌面版為目標重新提交,並請:
Generated by Claude Code |
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.
Refs #60
What changed(變更內容)
src/application/captionFiles.ts(不含 node 依賴):serializeCaptions:輸出 SRT/WebVTT,依開始時間排序,cue 內空行移除,取整後不產生零長度 cue;WebVTT 跳脫& < >。parseCaptionFile:解析 SRT/WebVTT(BOM、CRLF、無序號、./,毫秒、MM:SS.mmm、NOTE/STYLE/REGION、cue settings、<v>/<i>標籤、ASS{\an8}、VTT entity;單獨的<保留為文字)。整份先驗證,任何一段不合法就整份不匯入,錯誤訊息指出第幾段。上限 5 MB、20,000 句。buildImportCaptionsCommand:以單一 batchadd_caption加入,時間對齊 fps,一次 Undo 全部移除。exportGraph.ts抽出downloadTextFile,downloadEditGraph改用,無重複程式。docs/BUILDING.md新增「Caption files」。無新增依賴。User journey and platform(使用者流程與平台)
使用者可把外部 SRT/VTT 匯入時間軸繼續編修,也可在網頁版把字幕匯出給其他軟體或網頁播放器。桌面版目前只有匯入:桌面沒有通用的存檔通道,blob 下載無法在該環境驗證,所以未放入;補上需要新增讓使用者選路徑的 IPC(會與 #42 的路徑綁定設計相關)。因此本 PR 使用
Refs,issue 保持開啟。Validation(驗證)
npm test:2009 passed、4 skipped;tsc --noEmit乾淨;npm run source:scanGREEN。captionFiles.test.ts(14 項):小時級時間戳、排序、零長度 cue、VTT 跳脫往返、SRT 往返、真實世界 SRT/VTT 寫法、6 種錯誤輸入(無時間軸、結束早於開始、分鐘超範圍、時間亂碼、無可匯入內容、空檔)、匯入後對齊 fps 且 id 唯一。dist):匯入無效檔顯示「第 1 段找不到…時間軸」且未加入字幕;匯入 2 句 SRT 成功;匯出的 SRT/VTT 內容正確(含3 < 5 & ok)。Security and provenance(安全與來源)
main分出,未含 feat(web): open, save, re-link media and autosave projects in the browser build #71,App.tsx、Toolbar.tsx、EditorShell.tsx會與其有相鄰改動,後合併者可能需要 rebase。DCO
Commit 已使用
git commit -s簽署。