Skip to content

Releases: HildebrandYu/dsh-open-with

v0.2.2 — 規則比對合成同一支 sameApp(架構審查 3)

Choose a tag to compare

@HildebrandYu HildebrandYu released this 29 Oct 04:15

0.2.2

照 30-CodingSkills/審查-架構-20261029.html 的建議(候選 3):同一條規則,只剩一個接縫。

問題

matchesApp(設定頁:關聯 app 清單,有顯示名稱)與 applicationMatches(從選單點回來:
只有 id 字串)回答同一個問題卻各有一支實作,答案會不一樣 —— 規則寫在地化名稱
(例如 文字編輯)時,設定頁說「已綁定」,選單再點同一支 app 卻判定「不是它」。

解法

合成 sameApp(candidate, spec),兩個呼叫端共用:

  • 規則值是路徑(/ 開頭)→ 比 id 全等。
  • 其餘(顯示名稱)→ 先比顯示名稱,再退 id 的檔名(文字編輯.app ↔ TextEdit)。

候選端的形狀由呼叫端決定:關聯清單給 {id, name}、選單只給 id 字串。字串沒有顯示名稱
可比,所以手寫的在地化名稱規則在選單那條路上只比得到檔名 —— 這是資料限制,不是兩套
規則;設定頁存的一律是路徑,正常操作不會產生這種規則。限制已寫進函式註解與測試。

測試

node --test test/ 13 項全過。新增:

  • sameApp 的兩種候選形狀({id,name} 與字串)與壞值。
  • openFileApplication 在「選單點回規則指定的 app」時確實由規則接手 —— 原本只有
    程式路徑證據、沒有端到端測試。

tarball:dsh-open-with-0.2.2.tgz(版本檔名)與 dsh-open-with.tgz(固定檔名)。

v0.2.1 — 選「用系統預設」不再讓那一列消失

Choose a tag to compare

@HildebrandYu HildebrandYu released this 20 Oct 11:16

修正回報:在設定頁把某個副檔名改成「— 用系統預設 —」時,那一列會整條消失,使用者得重新輸入副檔名才找得回來。

現在改成存空字串 "":列留著、開啟行為等於沒有規則(走回 macOS 系統預設)。要整列刪掉請按右邊的「移除」。

  • parseRules / sanitizeApps 保留 ""(也接受 null)
  • specFor 對 "" 回 undefined;reorder 不動關聯清單
  • 設定頁下拉選 "" 不再刪除鍵,改存 ""
  • 測試 12 項全過(新增:空值保留、reorder 不動、sanitizeApps)

v0.2.0 — 初版:DSH 專用的副檔名→app,含設定頁

Choose a tag to compare

@HildebrandYu HildebrandYu released this 18 Oct 16:07

第一個公開版本。

  • 宿主半接管 sessionController 的 openPath/fileApplications/openFileApplication:有規則時改用 open -a <app>,不動 macOS 系統預設。
  • 規則檔 ~/.dsh/open-with.json,每次開啟前看 mtime 重讀,存檔即生效。
  • 設定頁:Settings → 檔案開啟方式(新增/移除/換 app,即時寫回)。
  • 診斷路由 GET /local/open-with(可加 ?path=…&apps=1 乾跑)與 GET/POST /local/open-with/config。
  • dsh.bundle manifest(cordis.patch.yml)+ dsh.client。
  • 測試:node --test test/ 10 項。

安裝:dsh plugin --profile web add github:HildebrandYu/dsh-open-with,或在市場安裝(收錄後)。