mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-29 05:29:45 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8903d451e7 |
No files matched your search
+1
-37
@@ -17,7 +17,7 @@
|
||||
|
||||
<p align="center">
|
||||
Electron、React、xterm.js で構築された機能豊富な SSH ワークスペース。<br/>
|
||||
🔥 内蔵 AI Agent · 🧩 プラグインシステム · 分割ターミナル · Vault ビュー · SFTP ワークフロー · カスタムテーマ — すべてが一つに。
|
||||
🔥 内蔵 AI Agent · 分割ターミナル · Vault ビュー · SFTP ワークフロー · カスタムテーマ — すべてが一つに。
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -38,8 +38,6 @@
|
||||
<a href="https://github.com/sponsors/binaricat"><img src="https://img.shields.io/badge/GitHub-Sponsors-ea4aaa?style=for-the-badge&logo=githubsponsors&logoColor=white" height="28" alt="GitHub でスポンサーになる"></a>
|
||||
|
||||
<a href="https://ko-fi.com/binaricat"><img src="https://img.shields.io/badge/Ko--fi-Support-29abe0?style=for-the-badge&logo=kofi&logoColor=white" height="28" alt="Ko-fi でサポート"></a>
|
||||
|
||||
<a href="docs/assets/readme/wechat-group.jpg"><img src="https://img.shields.io/badge/WeChat-Official%20Group-07C160?style=for-the-badge&logo=wechat&logoColor=white" height="28" alt="公式 WeChat グループに参加"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -81,31 +79,9 @@ Catty Agent にサーバーの健全性チェックを依頼すると、適切
|
||||
|
||||
---
|
||||
|
||||
<a name="plugin-system"></a>
|
||||
# 🧩 プラグインシステム — Netcatty を安全に拡張
|
||||
|
||||
> **SSH 鍵やホストレンダラーを公開することなく機能を追加できます。** Netcatty のセキュリティ優先プラグイン基盤は、通常プラグインをオフラインのサンドボックス内で実行し、**ホストレンダリング UI**(Closed Shadow DOM + ネイティブ Monaco、DataGrid、BI/メトリクスチャート、Vault SSH トンネルプロキシ)のみで画面を描画します。
|
||||
|
||||
### ✨ 主な特徴
|
||||
|
||||
- 🔒 **オフラインサンドボックス & 最小権限モデル** — プラグインは SSH パスワードや秘密鍵に直接アクセスできず、すべての機能はホスト管理の **許可 / 毎回確認 / 拒否** ポリシーを経由します。
|
||||
- 🖥️ **ホストネイティブ IDE コンポーネント** — `@netcatty/plugin-sdk` を使い、React または DOM で Vault ページ、ターミナルサイドバー、モーダルを構築できます。
|
||||
- 🗄️ **公式プラグインをすぐ導入** — **設定 → プラグイン** から [**Netcatty Database**](https://netcatty.app/en/plugins/netcatty-database)(113 エンジン対応 SQL IDE・Catty Agent・BI ダッシュボード)や [**Netcatty Monitor**](https://netcatty.app/en/plugins/netcatty-monitor)(エージェントレス SSH サーバー監視・Monaco ライブ可視化ログ)をワンクリック導入できます。
|
||||
- 🚀 **柔軟な配布と自動更新チェック** — 内蔵の**公式マーケットプレイス**(`plugins.netcatty.app`)、GitHub Release からの直接インストール、ローカル `.ncpkg` インポート、自社ホスト静的ソースに対応します。
|
||||
|
||||
### 🔗 関連リンク & ガイド
|
||||
|
||||
- 🛒 [**公式プラグインマーケットプレイス**](https://netcatty.app/en/plugins) — 公式・コミュニティプラグインを閲覧
|
||||
- 📖 [**プラグイン基盤概要**](https://netcatty.app/en/docs/plugins-overview) — サンドボックス設計・ホストレンダリング UI・権限モデル
|
||||
- 🛠️ [**プラグイン開発ガイド**](https://netcatty.app/en/docs/plugins-development) — プロジェクト作成・UI 実装・権限宣言・`.ncpkg` パッケージング
|
||||
- 📤 [**マーケットプレイス公開・提出ガイド**](https://netcatty.app/en/docs/plugins-marketplace) — GitHub Release 規約と公式カタログ PR 手順([`binaricat/netcatty-plugins`](https://github.com/binaricat/netcatty-plugins))
|
||||
|
||||
---
|
||||
|
||||
# 目次 <!-- omit in toc -->
|
||||
|
||||
- [🔥 Catty Agent — AI パートナー](#catty-agent)
|
||||
- [🧩 プラグインシステム](#plugin-system)
|
||||
- [Netcatty とは](#netcatty-とは)
|
||||
- [なぜ Netcatty](#なぜ-netcatty)
|
||||
- [機能](#機能)
|
||||
@@ -118,7 +94,6 @@ Catty Agent にサーバーの健全性チェックを依頼すると、適切
|
||||
- [はじめに](#はじめに)
|
||||
- [ビルドとパッケージ](#ビルドとパッケージ)
|
||||
- [技術スタック](#技術スタック)
|
||||
- [コミュニティ](#コミュニティ)
|
||||
- [コントリビューション](#コントリビューション)
|
||||
- [コントリビューター](#コントリビューター)
|
||||
- [Star 履歴](#star-履歴)
|
||||
@@ -351,17 +326,6 @@ npm run pack:linux # Linux (AppImage + DEB + RPM)
|
||||
|
||||
---
|
||||
|
||||
<a name="コミュニティ"></a>
|
||||
# 💬 コミュニティ
|
||||
|
||||
WeChat で QR コードをスキャンして **Netcatty 公式ユーザーグループ** に参加し、フィードバックやプラグインの話題を共有しましょう:
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/assets/readme/wechat-group.jpg" alt="Netcatty 公式 WeChat グループ QR コード" width="260" />
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
<a name="コントリビューション"></a>
|
||||
# コントリビューション
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
<p align="center">
|
||||
A beautiful, feature-rich SSH workspace built with Electron, React, and xterm.js.<br/>
|
||||
🔥 Built-in AI Agent · 🧩 Plugin System · Split terminals · Vault views · SFTP workflows · Custom themes — all in one.
|
||||
🔥 Built-in AI Agent · Split terminals · Vault views · SFTP workflows · Custom themes — all in one.
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -38,8 +38,6 @@
|
||||
<a href="https://github.com/sponsors/binaricat"><img src="https://img.shields.io/badge/GitHub-Sponsors-ea4aaa?style=for-the-badge&logo=githubsponsors&logoColor=white" height="28" alt="Sponsor on GitHub"></a>
|
||||
|
||||
<a href="https://ko-fi.com/binaricat"><img src="https://img.shields.io/badge/Ko--fi-Support-29abe0?style=for-the-badge&logo=kofi&logoColor=white" height="28" alt="Support on Ko-fi"></a>
|
||||
|
||||
<a href="docs/assets/readme/wechat-group.jpg"><img src="https://img.shields.io/badge/WeChat-Official%20Group-07C160?style=for-the-badge&logo=wechat&logoColor=white" height="28" alt="Join Official WeChat Group"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -81,33 +79,11 @@ Watch Catty Agent orchestrate a Docker Swarm cluster across two servers in one c
|
||||
<img width="3294" height="1974" alt="image" src="docs/assets/readme/catty-multi-host.webp" />
|
||||
|
||||
|
||||
---
|
||||
|
||||
<a name="plugin-system"></a>
|
||||
# 🧩 Plugin System — Extend Netcatty Safely
|
||||
|
||||
> **Build and install rich extensions without exposing your SSH keys or host renderer.** Netcatty's security-first plugin platform runs ordinary extensions inside an offline, sandboxed runtime and renders custom views exclusively through **Host-Rendered UI** (closed Shadow DOM + native Monaco, DataGrid, BI/Metric charts, and Vault SSH tunnel brokers).
|
||||
|
||||
### ✨ Highlights
|
||||
|
||||
- 🔒 **Offline Sandbox & Least-Privilege Permissions** — Plugins never touch SSH passwords, private keys, or the host renderer; every capability goes through host-mediated **Allow / Ask / Deny** brokers.
|
||||
- 🖥️ **Host-Rendered IDE Components** — Build native-feeling Vault pages, terminal sidebars, and modals with React or DOM via `@netcatty/plugin-sdk`.
|
||||
- 🗄️ **Official Plugins Out of the Box** — Install [**Netcatty Database**](https://netcatty.app/en/plugins/netcatty-database) (113 database profiles, SQL IDE, Catty Agent sidebar & BI Dashboard) and [**Netcatty Monitor**](https://netcatty.app/en/plugins/netcatty-monitor) (agentless cross-OS SSH fleet observability, Monaco live logs & multi-host compare) directly in **Settings → Plugins**.
|
||||
- 🚀 **Flexible Distribution** — Install from the built-in **Official Marketplace** (`plugins.netcatty.app`), directly from any public GitHub Release (**Install from GitHub**), via local `.ncpkg` import, or self-hosted static market sources.
|
||||
|
||||
### 🔗 Resources & Guides
|
||||
|
||||
- 🛒 [**Official Plugin Marketplace**](https://netcatty.app/en/plugins) — Browse official and curated plugins
|
||||
- 📖 [**Plugin Platform Overview**](https://netcatty.app/en/docs/plugins-overview) — Sandbox architecture, host-rendered UI, and permission model
|
||||
- 🛠️ [**Plugin Development Guide**](https://netcatty.app/en/docs/plugins-development) — Scaffold, build host-rendered views, declare permissions, and pack `.ncpkg`
|
||||
- 📤 [**Marketplace Submission & Publishing Guide**](https://netcatty.app/en/docs/plugins-marketplace) — GitHub Release contract & official catalog PR workflow ([`binaricat/netcatty-plugins`](https://github.com/binaricat/netcatty-plugins))
|
||||
|
||||
---
|
||||
|
||||
# Contents <!-- omit in toc -->
|
||||
|
||||
- [🔥 Catty Agent — AI Partner](#catty-agent)
|
||||
- [🧩 Plugin System](#plugin-system)
|
||||
- [What is Netcatty](#what-is-netcatty)
|
||||
- [Why Netcatty](#why-netcatty)
|
||||
- [Features](#features)
|
||||
@@ -120,7 +96,6 @@ Watch Catty Agent orchestrate a Docker Swarm cluster across two servers in one c
|
||||
- [Open a local terminal from the command line](#open-a-local-terminal-from-the-command-line)
|
||||
- [Build & Package](#build--package)
|
||||
- [Tech Stack](#tech-stack)
|
||||
- [Community](#community)
|
||||
- [Contributing](#contributing)
|
||||
- [Contributors](#contributors)
|
||||
- [Star History](#star-history)
|
||||
@@ -384,17 +359,6 @@ npm run pack:linux # Linux (AppImage + DEB + RPM)
|
||||
|
||||
---
|
||||
|
||||
<a name="community"></a>
|
||||
# 💬 Community
|
||||
|
||||
Scan the QR code with WeChat to join the **Netcatty Official User Group** for feedback, tips, and plugin discussions:
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/assets/readme/wechat-group.jpg" alt="Netcatty Official WeChat Group QR Code" width="260" />
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
<a name="contributing"></a>
|
||||
# Contributing
|
||||
|
||||
|
||||
+1
-37
@@ -17,7 +17,7 @@
|
||||
|
||||
<p align="center">
|
||||
一个基于 Electron、React 和 xterm.js 构建的功能丰富的 SSH 工作空间。<br/>
|
||||
🔥 内置 AI Agent · 🧩 插件系统 · 分屏终端 · Vault 多视图 · SFTP 工作流 · 自定义主题 —— 一应俱全。
|
||||
🔥 内置 AI Agent · 分屏终端 · Vault 多视图 · SFTP 工作流 · 自定义主题 —— 一应俱全。
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -38,8 +38,6 @@
|
||||
<a href="https://github.com/sponsors/binaricat"><img src="https://img.shields.io/badge/GitHub-Sponsors-ea4aaa?style=for-the-badge&logo=githubsponsors&logoColor=white" height="28" alt="通过 GitHub 赞助我"></a>
|
||||
|
||||
<a href="https://ko-fi.com/binaricat"><img src="https://img.shields.io/badge/Ko--fi-Support-29abe0?style=for-the-badge&logo=kofi&logoColor=white" height="28" alt="在 Ko-fi 上支持我"></a>
|
||||
|
||||
<a href="docs/assets/readme/wechat-group.jpg"><img src="https://img.shields.io/badge/%E5%BE%AE%E4%BF%A1%E7%BE%A4-%E5%AE%98%E6%96%B9%E4%BA%A4%E6%B5%81%E7%BE%A4-07C160?style=for-the-badge&logo=wechat&logoColor=white" height="28" alt="加入官方微信交流群"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -81,31 +79,9 @@
|
||||
|
||||
---
|
||||
|
||||
<a name="plugin-system"></a>
|
||||
# 🧩 插件系统 — 安全扩展你的工作台
|
||||
|
||||
> **在不暴露 SSH 密钥与主进程渲染器的前提下自由扩展 Netcatty。** Netcatty 的安全优先插件平台将普通插件隔离在离线沙箱中运行,并通过**宿主渲染 UI**(Closed Shadow DOM + 原生 Monaco 编辑器、虚拟化数据网格、实时监控/BI 图表与 Vault SSH 隧道代理)呈现原生手感界面。
|
||||
|
||||
### ✨ 核心亮点
|
||||
|
||||
- 🔒 **离线沙箱与最小权限控制** —— 插件永远无法读取 SSH 密码或私钥,所有宿主能力均受 **允许 / 询问 / 拒绝** 三态权限代理与审计保护。
|
||||
- 🖥️ **宿主原生 IDE 组件** —— 通过 `@netcatty/plugin-sdk` 使用 React 或原生 DOM 构建 Vault 页面、终端侧栏与弹窗,无缝复用宿主主题。
|
||||
- 🗄️ **官方插件开箱即用** —— 在 **设置 → 插件** 一键安装 [**Netcatty 数据库**](https://netcatty.app/zh/plugins/netcatty-database)(覆盖 113 种数据库配置、SQL IDE、Catty Agent 侧栏与 BI 看板)和 [**Netcatty 监控**](https://netcatty.app/zh/plugins/netcatty-monitor)(无 Agent 跨平台 SSH 集群监控、Monaco 实时日志与多机对比)。
|
||||
- 🚀 **多渠道分发与自动检查更新** —— 支持内置**官方插件市场**(`plugins.netcatty.app`)、**从 GitHub 安装**公开 Release、本地导入 `.ncpkg` 以及自建第三方静态市场源。
|
||||
|
||||
### 🔗 相关链接与指南
|
||||
|
||||
- 🛒 [**官方插件市场**](https://netcatty.app/zh/plugins) —— 浏览官方与社区插件
|
||||
- 📖 [**插件平台概览**](https://netcatty.app/zh/docs/plugins-overview) —— 隔离架构、宿主渲染 UI 与权限安全模型
|
||||
- 🛠️ [**插件开发指南**](https://netcatty.app/zh/docs/plugins-development) —— 脚手架初始化、UI 开发、权限声明与 `.ncpkg` 打包调试
|
||||
- 📤 [**插件市场发布与提交指南**](https://netcatty.app/zh/docs/plugins-marketplace) —— GitHub Release 契约与官方市场 PR 提交流程([`binaricat/netcatty-plugins`](https://github.com/binaricat/netcatty-plugins))
|
||||
|
||||
---
|
||||
|
||||
# 目录 <!-- omit in toc -->
|
||||
|
||||
- [🔥 Catty Agent — AI 搭档](#catty-agent)
|
||||
- [🧩 插件系统](#plugin-system)
|
||||
- [Netcatty 是什么](#netcatty-是什么)
|
||||
- [为什么是 Netcatty](#为什么是-netcatty)
|
||||
- [功能特性](#功能特性)
|
||||
@@ -118,7 +94,6 @@
|
||||
- [快速开始](#快速开始)
|
||||
- [构建与打包](#构建与打包)
|
||||
- [技术栈](#技术栈)
|
||||
- [社区交流](#社区交流)
|
||||
- [参与贡献](#参与贡献)
|
||||
- [贡献者](#贡献者)
|
||||
- [Star 历史](#star-历史)
|
||||
@@ -351,17 +326,6 @@ npm run pack:linux # Linux (AppImage + DEB + RPM)
|
||||
|
||||
---
|
||||
|
||||
<a name="社区交流"></a>
|
||||
# 💬 社区交流
|
||||
|
||||
欢迎使用微信扫码加入 **Netcatty 官方用户交流群**,交流使用技巧、插件开发与反馈建议:
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/assets/readme/wechat-group.jpg" alt="Netcatty 官方用户交流群二维码" width="260" />
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
<a name="参与贡献"></a>
|
||||
# 参与贡献
|
||||
|
||||
|
||||
+1
-37
@@ -17,7 +17,7 @@
|
||||
|
||||
<p align="center">
|
||||
以 Electron、React 與 xterm.js 打造,介面精緻、功能完整的 SSH 工作區。<br/>
|
||||
🔥 內建 AI Agent · 🧩 外掛系統 · 分割終端 · Vault 檢視 · SFTP 工作流 · 自訂主題 —— 全部整合在一起。
|
||||
🔥 內建 AI Agent · 分割終端 · Vault 檢視 · SFTP 工作流 · 自訂主題 —— 全部整合在一起。
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -38,8 +38,6 @@
|
||||
<a href="https://github.com/sponsors/binaricat"><img src="https://img.shields.io/badge/GitHub-Sponsors-ea4aaa?style=for-the-badge&logo=githubsponsors&logoColor=white" height="28" alt="透過 GitHub 贊助我"></a>
|
||||
|
||||
<a href="https://ko-fi.com/binaricat"><img src="https://img.shields.io/badge/Ko--fi-Support-29abe0?style=for-the-badge&logo=kofi&logoColor=white" height="28" alt="Support on Ko-fi"></a>
|
||||
|
||||
<a href="docs/assets/readme/wechat-group.jpg"><img src="https://img.shields.io/badge/%E5%BE%AE%E4%BF%A1%E7%BE%A4-%E5%AE%98%E6%96%B9%E4%BA%A4%E6%B5%81%E7%BE%A4-07C160?style=for-the-badge&logo=wechat&logoColor=white" height="28" alt="加入官方微信交流群"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -81,31 +79,9 @@
|
||||
|
||||
---
|
||||
|
||||
<a name="plugin-system"></a>
|
||||
# 🧩 外掛系統 —— 安全擴充你的工作台
|
||||
|
||||
> **在不暴露 SSH 金鑰與宿主渲染器的前提下自由擴充 Netcatty。** Netcatty 的安全優先外掛平台將一般外掛隔離於離線沙箱中執行,並透過**宿主渲染 UI**(Closed Shadow DOM + 原生 Monaco 編輯器、虛擬化資料格、即時監控/BI 圖表與 Vault SSH 通道代理)呈現原生體驗。
|
||||
|
||||
### ✨ 核心亮點
|
||||
|
||||
- 🔒 **離線沙箱與最小權限控制** —— 外掛永遠無法讀取 SSH 密碼或私鑰,所有宿主能力均受 **允許 / 詢問 / 拒絕** 三態權限代理保護。
|
||||
- 🖥️ **宿主原生 IDE 元件** —— 透過 `@netcatty/plugin-sdk` 以 React 或原生 DOM 開發 Vault 頁面、終端側欄與視窗,無縫跟隨宿主主題。
|
||||
- 🗄️ **官方外掛開箱即用** —— 在 **設定 → 外掛** 一鍵安裝 [**Netcatty 資料庫**](https://netcatty.app/zh/plugins/netcatty-database)(113 種資料庫設定、SQL IDE、Catty Agent 側欄與 BI 看板)與 [**Netcatty 監控**](https://netcatty.app/zh/plugins/netcatty-monitor)(無 Agent 跨平台 SSH 叢集監控、Monaco 即時日誌與多機對比)。
|
||||
- 🚀 **多元分發與自動檢查更新** —— 支援內建**官方外掛市場**(`plugins.netcatty.app`)、**從 GitHub 安裝**公開 Release、本機匯入 `.ncpkg` 以及自建第三方靜態市場源。
|
||||
|
||||
### 🔗 相關連結與指南
|
||||
|
||||
- 🛒 [**官方外掛市場**](https://netcatty.app/zh/plugins) —— 瀏覽官方與社群外掛
|
||||
- 📖 [**外掛平台概覽**](https://netcatty.app/zh/docs/plugins-overview) —— 隔離架構、宿主渲染 UI 與權限安全模型
|
||||
- 🛠️ [**外掛開發指南**](https://netcatty.app/zh/docs/plugins-development) —— 初始化專案、UI 開發、權限宣告與 `.ncpkg` 打包除錯
|
||||
- 📤 [**外掛市場發布與提交指南**](https://netcatty.app/zh/docs/plugins-marketplace) —— GitHub Release 契約與官方市場 PR 提交流程([`binaricat/netcatty-plugins`](https://github.com/binaricat/netcatty-plugins))
|
||||
|
||||
---
|
||||
|
||||
# 目錄 <!-- omit in toc -->
|
||||
|
||||
- [🔥 Catty Agent —— AI 夥伴](#catty-agent)
|
||||
- [🧩 外掛系統](#plugin-system)
|
||||
- [Netcatty 是什麼](#netcatty-是什麼)
|
||||
- [為什麼選 Netcatty](#為什麼選-netcatty)
|
||||
- [功能特色](#功能特色)
|
||||
@@ -118,7 +94,6 @@
|
||||
- [快速開始](#快速開始)
|
||||
- [建置與打包](#建置與打包)
|
||||
- [技術堆疊](#技術堆疊)
|
||||
- [社群交流](#社群交流)
|
||||
- [參與貢獻](#參與貢獻)
|
||||
- [貢獻者](#貢獻者)
|
||||
- [Star 紀錄](#star-紀錄)
|
||||
@@ -350,17 +325,6 @@ npm run pack:linux # Linux (AppImage + DEB + RPM)
|
||||
|
||||
---
|
||||
|
||||
<a name="社群交流"></a>
|
||||
# 💬 社群交流
|
||||
|
||||
歡迎使用微信掃描下方 QR Code 加入 **Netcatty 官方用戶交流群**,交流使用技巧、外掛開發與回饋建議:
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/assets/readme/wechat-group.jpg" alt="Netcatty 官方用戶交流群 QR Code" width="260" />
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
<a name="參與貢獻"></a>
|
||||
# 參與貢獻
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { checkPluginUpdates, type PluginUpdateCandidate, type PluginUpdateCheckResult } from '../../infrastructure/services/pluginUpdateCheck';
|
||||
import { netcattyBridge } from '../../infrastructure/services/netcattyBridge';
|
||||
|
||||
/** Automatic update checks on plugin view entry and package changes; explicit installUpdate runs only on user click. */
|
||||
/** Manual catalog checks only; no scheduler. Explicit installUpdate runs only on user click. */
|
||||
export function usePluginUpdateCheck(plugins: readonly NetcattyInstalledPlugin[], onUpdated?: () => Promise<unknown> | void) {
|
||||
const [result, setResult] = useState<PluginUpdateCheckResult | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -16,17 +16,32 @@ export function usePluginUpdateCheck(plugins: readonly NetcattyInstalledPlugin[]
|
||||
onUpdatedRef.current = onUpdated;
|
||||
useEffect(() => { mounted.current = true; return () => { mounted.current = false; }; }, []);
|
||||
const generation = useRef(0);
|
||||
const pluginsCount = plugins.length;
|
||||
const identityKey = useMemo(() => JSON.stringify(plugins.map((plugin) => [
|
||||
plugin.id, plugin.activeVersion, plugin.archiveSha256, plugin.source?.id,
|
||||
plugin.source?.kind, plugin.source?.origin,
|
||||
])), [plugins]);
|
||||
const check = useCallback(async (options?: { silent?: boolean }) => {
|
||||
useEffect(() => {
|
||||
generation.current++;
|
||||
setResult(null);
|
||||
setError(null);
|
||||
const requests = generation;
|
||||
return () => { requests.current++; };
|
||||
}, [identityKey]);
|
||||
useEffect(() => {
|
||||
const invalidate = () => {
|
||||
generation.current++;
|
||||
setResult(null);
|
||||
setError(null);
|
||||
};
|
||||
const unsubscribe = netcattyBridge.get()?.onPluginContributionsChanged?.(invalidate);
|
||||
window.addEventListener('netcatty:plugin-packages-changed', invalidate);
|
||||
return () => { unsubscribe?.(); window.removeEventListener('netcatty:plugin-packages-changed', invalidate); };
|
||||
}, []);
|
||||
const check = useCallback(async () => {
|
||||
if (pending.current) return;
|
||||
pending.current = true;
|
||||
const current = generation.current;
|
||||
setBusy(true); setError(null); setUpdateError(null);
|
||||
if (!options?.silent) setResult(null);
|
||||
setBusy(true); setError(null); setUpdateError(null); setResult(null);
|
||||
try {
|
||||
const value = await checkPluginUpdates(netcattyBridge.require());
|
||||
if (mounted.current && current === generation.current) setResult(value);
|
||||
@@ -38,26 +53,6 @@ export function usePluginUpdateCheck(plugins: readonly NetcattyInstalledPlugin[]
|
||||
if (mounted.current) setBusy(false);
|
||||
}
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
generation.current++;
|
||||
setResult(null);
|
||||
setError(null);
|
||||
const requests = generation;
|
||||
if (pluginsCount > 0 && netcattyBridge.get()?.listPluginCatalog) {
|
||||
void check();
|
||||
}
|
||||
return () => { requests.current++; };
|
||||
}, [identityKey, pluginsCount, check]);
|
||||
useEffect(() => {
|
||||
const invalidate = () => {
|
||||
generation.current++;
|
||||
setResult(null);
|
||||
setError(null);
|
||||
};
|
||||
const unsubscribe = netcattyBridge.get()?.onPluginContributionsChanged?.(invalidate);
|
||||
window.addEventListener('netcatty:plugin-packages-changed', invalidate);
|
||||
return () => { unsubscribe?.(); window.removeEventListener('netcatty:plugin-packages-changed', invalidate); };
|
||||
}, []);
|
||||
const installUpdate = useCallback(async (candidate: PluginUpdateCandidate, wasEnabled = false) => {
|
||||
if (updating.current) return;
|
||||
updating.current = true;
|
||||
|
||||
@@ -82,12 +82,7 @@ test('catalog keeps search during selection/back, switches detail, and displays
|
||||
});
|
||||
|
||||
|
||||
test('README renders before Compatibility and permissions, and README failure still leaves permissions and source visible below', () => {
|
||||
const readyHtml = renderToStaticMarkup(<I18nProvider locale="en"><PluginMarketplaceContent
|
||||
catalog={catalog}
|
||||
selected={entries[0].id} onSelect={() => {}} installed={[]} /></I18nProvider>);
|
||||
assert.ok(readyHtml.indexOf('Author documentation') < readyHtml.indexOf('Compatibility and permissions'), 'README content renders before Compatibility and permissions');
|
||||
|
||||
test('README failure leaves the permissions and source visible, before the failure message', () => {
|
||||
const html = renderToStaticMarkup(<I18nProvider locale="en"><PluginMarketplaceContent
|
||||
catalog={{ ...catalog, readmeStatus: 'error', readme: null, readmeError: 'Network unavailable' }}
|
||||
selected={entries[0].id} onSelect={() => {}} installed={[]} /></I18nProvider>);
|
||||
@@ -99,7 +94,7 @@ test('README renders before Compatibility and permissions, and README failure st
|
||||
assert.match(html, /Host validation and the selected permission mode still apply/);
|
||||
assert.doesNotMatch(html, /Check the actual scope in the permission prompt/);
|
||||
assert.match(html, /Source example/);
|
||||
assert.ok(html.indexOf('Network unavailable') < html.indexOf('settings.read'), 'README section stays above Compatibility and permissions');
|
||||
assert.ok(html.indexOf('settings.read') < html.indexOf('Network unavailable'));
|
||||
assert.match(html, /Retry/);
|
||||
assert.doesNotMatch(html, /<details/);
|
||||
});
|
||||
|
||||
@@ -11,7 +11,7 @@ import { usePluginCatalog } from '../../../application/state/usePluginCatalog';
|
||||
import { Input } from '../../ui/input';
|
||||
import { Button } from '../../ui/button';
|
||||
import { PluginPackageDetails } from './PluginPackageManager';
|
||||
import { PluginReadmeSection } from './PluginReadmeSection';
|
||||
import { PluginReadme } from './PluginReadme';
|
||||
|
||||
export function PluginMarketplace({ installed = [], toolbarContainer, noVault, source, onToggleEnabled, managerBusy }: { source?: NetcattyPluginSource; noVault?: boolean; installed?: NetcattyInstalledPlugin[]; toolbarContainer?: HTMLElement | null; onToggleEnabled?: (pluginId: string, enabled: boolean) => Promise<unknown> | void; managerBusy?: boolean }) {
|
||||
const [selected, setSelected] = useState<string | null>(null);
|
||||
@@ -104,17 +104,11 @@ export function PluginMarketplaceContent({ catalog, installed, selected, onSelec
|
||||
<a className="block break-all text-xs text-primary underline underline-offset-4" href={`https://github.com/${entry.repository}/tree/${entry.commit}`} target="_blank" rel="noopener noreferrer">{entry.repository} @ {entry.commit.slice(0, 12)}</a>
|
||||
{conflictingInstall && <p role="status" className="text-xs text-muted-foreground">{t('settings.plugins.sources.conflict')} {conflictingInstall.source?.origin ?? t('settings.plugins.sources.local')}</p>}
|
||||
{entry.artifact ? <div className="space-y-2">{isUpdateAvailable && <p className="text-xs text-muted-foreground">{t('settings.plugins.market.installNote')}</p>}{!isSameVersionInstalled && catalog.listError && <p role="status" className="text-xs text-muted-foreground">{t('settings.plugins.market.offlineShort')}</p>}<div className="flex flex-wrap items-center gap-2">{!isSameVersionInstalled && <Button ref={installButtonRef} size="sm" aria-busy={catalog.busy} className={isUpdateAvailable ? 'bg-emerald-600 text-white hover:bg-emerald-500 dark:bg-emerald-600 dark:hover:bg-emerald-500' : undefined} disabled={catalog.busy || managerBusy || Boolean(catalog.listError) || Boolean(conflictingInstall)} onClick={() => { if (marketSource?.kind === 'third-party' || (catalog.sourceBinding && catalog.sourceBinding.id !== (marketSource?.id ?? 'official'))) { setClearPreviousSource(false); setConfirmInstall(true); } else void catalog.install(entry.id); }}>{catalog.busy ? <Loader2 size={14} className="mr-1.5 animate-spin" aria-hidden="true" /> : isUpdateAvailable ? <ArrowUpCircle size={14} className="mr-1.5" aria-hidden="true" /> : null}{t(isUpdateAvailable ? (catalog.busy ? 'settings.plugins.market.updating' : 'settings.plugins.market.update') : (catalog.busy ? 'settings.plugins.market.installing' : 'settings.plugins.market.install'))}</Button>}{installedEntry && onToggleEnabled && <Button variant={installedEntry.enabled ? 'secondary' : 'default'} size="sm" aria-pressed={installedEntry.enabled} aria-busy={managerBusy} title={t(installedEntry.enabled ? 'settings.plugins.manager.disable' : 'settings.plugins.manager.enable')} className={installedEntry.enabled ? 'bg-primary/15 text-primary hover:bg-primary/20' : undefined} disabled={catalog.busy || managerBusy} onClick={() => void onToggleEnabled(installedEntry.id, !installedEntry.enabled)}>{managerBusy ? <Loader2 size={14} className="mr-1.5 animate-spin" aria-hidden="true" /> : installedEntry.enabled ? <Check size={14} className="mr-1.5" aria-hidden="true" /> : null}{t(installedEntry.enabled ? 'settings.plugins.manager.enabled' : 'settings.plugins.manager.enable')}</Button>}</div></div> : <div className="flex items-center gap-1 text-xs text-muted-foreground"><span>{t('settings.plugins.market.sourceBadge')}</span><PluginInfo label={t('settings.plugins.market.sourceBadge')}>{t(marketSource?.kind === 'third-party' ? 'settings.plugins.sources.sourceOnly' : 'settings.plugins.market.sourceOnly')}</PluginInfo></div>}
|
||||
<PluginReadmeSection
|
||||
status={catalog.readmeStatus}
|
||||
markdown={catalog.readme}
|
||||
images={catalog.readmeImages}
|
||||
error={catalog.readmeError}
|
||||
onRetry={catalog.retryReadme}
|
||||
/>
|
||||
<section data-plugin-permissions-section="" className="border-t border-border/60 pt-4">
|
||||
<h4 className="mb-3 text-sm font-semibold">{t('settings.plugins.market.manifest')}</h4>
|
||||
<PluginPackageDetails plugin={{ id: entry.id, activeVersion: entry.version, enabled: false, manifest: entry.manifest, archiveSha256: entry.artifact?.sha256, runtime: { status: 'stopped', kind: null, lastError: null, quarantinedAt: null } }} />
|
||||
</section>
|
||||
<section><h4 className="mb-3 text-sm font-semibold">{t('settings.plugins.market.manifest')}</h4><PluginPackageDetails plugin={{ id: entry.id, activeVersion: entry.version, enabled: false, manifest: entry.manifest, archiveSha256: entry.artifact?.sha256, runtime: { status: 'stopped', kind: null, lastError: null, quarantinedAt: null } }} /></section>
|
||||
<div className="min-w-0 border-t pt-4"><div className="flex items-center gap-1"><h4 className="text-sm font-semibold">README</h4><PluginInfo label={t('settings.plugins.market.readmeInfo')}>{t('settings.plugins.market.readmeNote')}</PluginInfo></div>{catalog.readmeStatus === 'loading' && <p className="mt-3 text-xs text-muted-foreground">{t('settings.plugins.loading')}</p>}
|
||||
{catalog.readmeStatus === 'error' && <div role="alert" className="mt-3 space-y-2 text-xs text-destructive"><p>{catalog.readmeError}</p><Button variant="outline" size="sm" onClick={catalog.retryReadme}>{t('settings.plugins.market.retry')}</Button></div>}
|
||||
{catalog.readmeStatus === 'ready' && (catalog.readme?.trim() ? <PluginReadme markdown={catalog.readme} images={catalog.readmeImages} /> : <p className="mt-3 text-xs text-muted-foreground">{t('settings.plugins.market.emptyReadme')}</p>)}
|
||||
</div>
|
||||
</article>}
|
||||
</div>
|
||||
<Dialog open={confirmInstall && Boolean(entry)} onOpenChange={setConfirmInstall}><DialogContent className="max-h-[85vh] overflow-y-auto" onCloseAutoFocus={(event) => { event.preventDefault(); installButtonRef.current?.focus(); }}>
|
||||
|
||||
@@ -76,10 +76,4 @@ test('installed cards and detail header expose one-click emerald Update action w
|
||||
assert.match(detailHtml, /data-plugin-detail-update="com\.example\.synthetic"/);
|
||||
assert.match(detailHtml, /bg-emerald-600/);
|
||||
assert.ok(detailHtml.indexOf('Update 1.2.0') < detailHtml.indexOf('>Enabled</button>'));
|
||||
assert.match(detailHtml, /data-plugin-readme-section=""/);
|
||||
assert.match(detailHtml, /data-plugin-permissions-section=""/);
|
||||
assert.ok(
|
||||
detailHtml.indexOf('data-plugin-readme-section=""') < detailHtml.indexOf('data-plugin-permissions-section=""'),
|
||||
'installed marketplace plugin detail renders README before Compatibility and permissions',
|
||||
);
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describePluginPermission } from '@/domain/pluginPermissionDescriptions.cjs';
|
||||
import { describePluginRuntime } from '@/domain/pluginRuntimePolicy.cjs';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { PluginPermissionPanel } from './PluginPermissionPanel';
|
||||
import { PluginBrandIcon } from '../../plugins/PluginBrandIcon';
|
||||
import { PluginAuthorRow } from '../../plugins/PluginAuthorRow';
|
||||
@@ -11,7 +11,6 @@ import { useI18n } from '../../../application/i18n/I18nProvider';
|
||||
import { Button } from '../../ui/button';
|
||||
import { Input } from '../../ui/input';
|
||||
import { PluginInfo } from './PluginInfo';
|
||||
import { PluginInstalledReadme } from './PluginReadmeSection';
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '../../ui/dialog';
|
||||
|
||||
export function PluginPackageDetails({ plugin }: { plugin: NetcattyInstalledPlugin }) {
|
||||
@@ -64,11 +63,6 @@ export function PluginPackageManager({ manager, updates, onSelectionChange, init
|
||||
const scrollTop = useRef(0);
|
||||
const lastSelection = useRef<string | null>(null);
|
||||
const selectedPlugin = manager.plugins.find((plugin) => plugin.id === selected);
|
||||
const checkUpdates = updates?.check;
|
||||
useEffect(() => {
|
||||
if (!checkUpdates || !manager.available || manager.statusKnown === false || manager.plugins.length === 0) return;
|
||||
void checkUpdates({ silent: true });
|
||||
}, [checkUpdates, manager.available, manager.statusKnown, manager.plugins.length, selected]);
|
||||
const nameOf = (plugin: NetcattyInstalledPlugin) => typeof plugin.manifest?.displayName === 'string' ? plugin.manifest.displayName : plugin.manifest?.displayName?.[resolvedLocale] ?? plugin.manifest?.displayName?.en ?? plugin.manifest?.name ?? plugin.id;
|
||||
const descriptionOf = (plugin: NetcattyInstalledPlugin) => {
|
||||
const value = plugin.manifest?.description;
|
||||
@@ -102,12 +96,12 @@ export function PluginPackageManager({ manager, updates, onSelectionChange, init
|
||||
{visible.map((plugin) => {
|
||||
const availableUpdate = updates?.result?.updates.find((item) => item.pluginId === plugin.id && item.sourceId === plugin.source?.id);
|
||||
const isUpdating = updates?.updatingId === plugin.id;
|
||||
return <article key={plugin.id} data-plugin-detail={selectedPlugin ? true : undefined} tabIndex={selectedPlugin ? -1 : undefined} aria-label={nameOf(plugin)} className={`min-w-0 rounded-lg focus:outline-none ${selectedPlugin ? 'mx-auto w-full max-w-[920px] space-y-6' : 'plugin-card flex min-h-[200px] flex-col gap-3 bg-card p-4'}`}>
|
||||
return <article key={plugin.id} data-plugin-detail={selectedPlugin ? true : undefined} tabIndex={selectedPlugin ? -1 : undefined} aria-label={nameOf(plugin)} className={`min-w-0 rounded-lg focus:outline-none ${selectedPlugin ? 'space-y-4' : 'plugin-card flex min-h-[200px] flex-col gap-3 bg-card p-4'}`}>
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
{!selectedPlugin ? <button type="button" aria-label={`${t('settings.plugins.manager.details')} ${nameOf(plugin)}`} onClick={() => choose(plugin.id)} className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition-opacity hover:opacity-85 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"><PluginBrandIcon plugin={plugin} size={32} /></button> : <div className="flex h-12 w-12 shrink-0 items-center justify-center"><PluginBrandIcon plugin={plugin} size={48} /></div>}
|
||||
{!selectedPlugin ? <button type="button" aria-label={`${t('settings.plugins.manager.details')} ${nameOf(plugin)}`} onClick={() => choose(plugin.id)} className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition-opacity hover:opacity-85 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"><PluginBrandIcon plugin={plugin} size={32} /></button> : <div className="flex h-12 w-12 shrink-0 items-center justify-center"><PluginBrandIcon plugin={plugin} size={40} /></div>}
|
||||
<div className="flex min-w-0 flex-1 items-center gap-1">
|
||||
<button type="button" data-plugin-card={plugin.id} className="min-w-0 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" aria-expanded={selected === plugin.id} onClick={() => choose(selected === plugin.id ? null : plugin.id)}>
|
||||
<div className={`break-words ${selectedPlugin ? 'text-xl font-semibold' : 'text-sm font-medium'}`}>{nameOf(plugin)}</div>
|
||||
<div className="break-words text-sm font-medium">{nameOf(plugin)}</div>
|
||||
|
||||
</button>
|
||||
{plugin.runtime.lastError && <PluginInfo variant="error" label={`${t('settings.plugins.manager.lastError')} — ${nameOf(plugin)}`}>
|
||||
@@ -154,11 +148,7 @@ export function PluginPackageManager({ manager, updates, onSelectionChange, init
|
||||
<Button variant="ghost" size="sm" className="h-7 px-2 text-xs" onClick={() => choose(plugin.id)} aria-label={`${t('settings.plugins.manager.details')} ${nameOf(plugin)}`}>{t('settings.plugins.manager.details')}</Button>
|
||||
</div> : <p className="text-xs text-muted-foreground">{plugin.activeVersion}{plugin.manifest?.license ? ` · ${plugin.manifest.license}` : ''}</p>}
|
||||
{selected === plugin.id && <>
|
||||
<PluginInstalledReadme plugin={plugin} />
|
||||
<section data-plugin-permissions-section="" className="border-t border-border/60 pt-4">
|
||||
<h4 className="mb-3 text-sm font-semibold">{t('settings.plugins.market.manifest')}</h4>
|
||||
<PluginPackageDetails plugin={plugin} />
|
||||
</section>
|
||||
<PluginPackageDetails plugin={plugin} />
|
||||
<PluginPermissionPanel key={plugin.id} pluginId={plugin.id} onChanged={async () => { await manager.refresh(); }}
|
||||
actions={<Dialog open={removing === plugin.id} onOpenChange={(open) => {
|
||||
if (manager.busy) return;
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
import React from 'react';
|
||||
import { useI18n } from '../../../application/i18n/I18nProvider';
|
||||
import { usePluginCatalog } from '../../../application/state/usePluginCatalog';
|
||||
import { Button } from '../../ui/button';
|
||||
import { PluginInfo } from './PluginInfo';
|
||||
import { PluginReadme } from './PluginReadme';
|
||||
|
||||
export function PluginReadmeSection({
|
||||
status,
|
||||
markdown,
|
||||
images,
|
||||
error,
|
||||
onRetry,
|
||||
}: {
|
||||
status: 'idle' | 'loading' | 'ready' | 'error';
|
||||
markdown: string | null;
|
||||
images: Record<string, string>;
|
||||
error: string | null;
|
||||
onRetry: () => void;
|
||||
}) {
|
||||
const { t } = useI18n();
|
||||
return (
|
||||
<section data-plugin-readme-section="" className="min-w-0 border-t border-border/60 pt-4">
|
||||
<div className="flex items-center gap-1">
|
||||
<h4 className="text-sm font-semibold">README</h4>
|
||||
<PluginInfo label={t('settings.plugins.market.readmeInfo')}>
|
||||
{t('settings.plugins.market.readmeNote')}
|
||||
</PluginInfo>
|
||||
</div>
|
||||
{status === 'loading' && (
|
||||
<p className="mt-3 text-xs text-muted-foreground">{t('settings.plugins.loading')}</p>
|
||||
)}
|
||||
{status === 'error' && (
|
||||
<div role="alert" className="mt-3 space-y-2 text-xs text-destructive">
|
||||
<p>{error}</p>
|
||||
<Button variant="outline" size="sm" onClick={onRetry}>
|
||||
{t('settings.plugins.market.retry')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{status === 'ready' && (
|
||||
markdown?.trim() ? (
|
||||
<PluginReadme markdown={markdown} images={images} />
|
||||
) : (
|
||||
<p className="mt-3 text-xs text-muted-foreground">{t('settings.plugins.market.emptyReadme')}</p>
|
||||
)
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function PluginCatalogBackedReadme({ pluginId, sourceId }: { pluginId: string; sourceId: string }) {
|
||||
const catalog = usePluginCatalog(pluginId, sourceId);
|
||||
const entry = catalog.entries.find((item) => item.id === pluginId);
|
||||
// Hide cleanly if the source is loaded and no longer lists this plugin.
|
||||
if (catalog.listStatus === 'ready' && !entry) return null;
|
||||
if (catalog.listStatus === 'error' && !entry) return null;
|
||||
const status = catalog.listStatus === 'loading' ? 'loading' : catalog.readmeStatus;
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{entry?.repository && entry?.commit && (
|
||||
<a
|
||||
className="block break-all text-xs text-primary underline underline-offset-4"
|
||||
href={`https://github.com/${entry.repository}/tree/${entry.commit}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{entry.repository} @ {entry.commit.slice(0, 12)}
|
||||
</a>
|
||||
)}
|
||||
<PluginReadmeSection
|
||||
status={status}
|
||||
markdown={catalog.readme}
|
||||
images={catalog.readmeImages}
|
||||
error={catalog.readmeError}
|
||||
onRetry={catalog.retryReadme}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function PluginInstalledReadme({ plugin }: { plugin: NetcattyInstalledPlugin }) {
|
||||
const source = plugin.source;
|
||||
if (!source || (source.kind !== 'official' && source.kind !== 'third-party')) {
|
||||
return null;
|
||||
}
|
||||
return <PluginCatalogBackedReadme key={`${source.id}:${plugin.id}`} pluginId={plugin.id} sourceId={source.id} />;
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { JSDOM } from 'jsdom';
|
||||
|
||||
test('update check runs automatically on plugin view entry and detail navigation, coalesces concurrent requests, and reports incomplete source checks honestly', async () => {
|
||||
test('manual update action coalesces clicks, never runs on mount, and reports incomplete source checks honestly', async () => {
|
||||
const dom = new JSDOM('<!doctype html><html><body><div id="root"></div></body></html>', { pretendToBeVisual: true, url: 'http://localhost' });
|
||||
const previous = new Map<string, PropertyDescriptor | undefined>();
|
||||
const install = (key: string, value: unknown) => {
|
||||
@@ -10,13 +10,11 @@ test('update check runs automatically on plugin view entry and detail navigation
|
||||
Object.defineProperty(globalThis, key, { configurable: true, writable: true, value });
|
||||
};
|
||||
for (const key of ['window', 'document', 'navigator', 'HTMLElement', 'Element', 'Node', 'Event', 'MouseEvent']) install(key, key === 'window' ? dom.window : dom.window[key as keyof typeof dom.window]);
|
||||
install('requestAnimationFrame', (callback: FrameRequestCallback) => { callback(0); return 0; });
|
||||
install('IS_REACT_ACT_ENVIRONMENT', true);
|
||||
const { default: React, act, useState } = await import('react');
|
||||
const { default: React, act } = await import('react');
|
||||
const { createRoot } = await import('react-dom/client');
|
||||
const { I18nProvider } = await import('../../../application/i18n/I18nProvider');
|
||||
const { PluginSettingsLanding } = await import('./PluginSettingsLanding');
|
||||
const { PluginPackageManager } = await import('./PluginPackageManager');
|
||||
const { usePluginUpdateCheck } = await import('../../../application/state/usePluginUpdateCheck');
|
||||
const root = createRoot(document.getElementById('root')!);
|
||||
const source: NetcattyPluginSource = { id: 'official', kind: 'official', name: 'Official source', origin: 'https://plugins.example.com', enabled: true };
|
||||
@@ -31,29 +29,17 @@ test('update check runs automatically on plugin view entry and detail navigation
|
||||
Object.assign(dom.window, { netcatty: {
|
||||
async listPlugins() { return plugins; }, async listPluginSources() { return [source]; },
|
||||
async listPluginCatalog(id: string) { assert.equal(id, source.id); catalogReads++; await gate; return { entries: [{ id: plugin.id, version: '1.1.0', artifact: { url: 'https://plugins.example.com/synthetic.ncpkg', sha256: 'b'.repeat(64) } }], source: offline ? 'cached' : 'registry', error: offline ? 'synthetic offline' : null }; },
|
||||
async getPluginCatalogReadme() { return '# Alpha'; },
|
||||
async getPluginCatalogReadmeImages() { return {}; },
|
||||
async getPluginPermissions() { return { pluginId: plugin.id, policies: [], grants: [], audit: [] }; },
|
||||
async getPluginLogStatus() { return { saveToDisk: false, verbose: false, droppedRecords: 0, writeErrors: 0, pendingBytes: 0, maxBytes: 3145728, retentionDays: 7 }; },
|
||||
async installCatalogPlugin() { mutations++; }, async setPluginEnabled() { mutations++; }, async checkForUpdates() { mutations++; },
|
||||
} });
|
||||
let showManagerView!: (next: boolean) => void;
|
||||
function Page() {
|
||||
const updates = usePluginUpdateCheck(plugins);
|
||||
const [showManager, setShowManager] = useState(false);
|
||||
showManagerView = setShowManager;
|
||||
return showManager
|
||||
? <PluginPackageManager manager={manager} updates={updates} />
|
||||
: <PluginSettingsLanding manager={manager} updates={updates} settingsAvailable={new Set()} onManage={() => {}} />;
|
||||
}
|
||||
function Page() { const updates = usePluginUpdateCheck(plugins); return <PluginSettingsLanding manager={manager} updates={updates} settingsAvailable={new Set()} onManage={() => {}} />; }
|
||||
const check = () => [...document.querySelectorAll<HTMLButtonElement>('button')].find((button) => button.textContent === 'Check for updates')!;
|
||||
try {
|
||||
await act(async () => root.render(<I18nProvider locale="en"><Page /></I18nProvider>));
|
||||
assert.equal(catalogReads, 1, 'entering plugin settings automatically checks for updates once');
|
||||
const checkingButton = [...document.querySelectorAll<HTMLButtonElement>('button')].find((button) => button.textContent === 'Checking…')!;
|
||||
assert.equal(checkingButton.disabled, true);
|
||||
await act(async () => { checkingButton.click(); });
|
||||
assert.equal(catalogReads, 1, 'concurrent clicks coalesce with the in-flight automatic check');
|
||||
assert.equal(catalogReads, 0, 'rendering settings does not schedule checks');
|
||||
await act(async () => { const button = check(); button.click(); button.click(); });
|
||||
assert.equal(catalogReads, 1);
|
||||
assert.equal([...document.querySelectorAll<HTMLButtonElement>('button')].find((button) => button.textContent === 'Checking…')!.disabled, true);
|
||||
await act(async () => release());
|
||||
assert.match(document.body.textContent!, /Published updates: 1/);
|
||||
assert.match(document.body.textContent!, /Version 1.1.0 available/);
|
||||
@@ -61,18 +47,6 @@ test('update check runs automatically on plugin view entry and detail navigation
|
||||
const quickUpdate = document.querySelector<HTMLButtonElement>('[data-plugin-quick-update="com.example.alpha"]');
|
||||
assert.ok(quickUpdate, 'quick update pill renders beside installed version');
|
||||
assert.match(quickUpdate.textContent!, /Update 1\.1\.0/);
|
||||
|
||||
// Navigating to Installed list and then Detail page also triggers silent update checks while preserving the update pill.
|
||||
await act(async () => showManagerView(true));
|
||||
assert.equal(catalogReads, 2, 'entering installed list triggers an update check');
|
||||
assert.ok(document.querySelector('[data-plugin-card-update="com.example.alpha"]'));
|
||||
await act(async () => {
|
||||
document.querySelector<HTMLButtonElement>('[data-plugin-card="com.example.alpha"]')!.click();
|
||||
});
|
||||
assert.ok(catalogReads >= 3, 'opening plugin detail triggers an update check');
|
||||
assert.ok(document.querySelector('[data-plugin-detail-update="com.example.alpha"]'));
|
||||
|
||||
await act(async () => showManagerView(false));
|
||||
await act(async () => window.dispatchEvent(new Event('netcatty:plugin-packages-changed')));
|
||||
assert.doesNotMatch(document.body.textContent!, /Version 1.1.0 available/, 'source/package changes invalidate prior results');
|
||||
offline = true;
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
GripVertical,
|
||||
Pin,
|
||||
RotateCcw,
|
||||
SlidersHorizontal,
|
||||
} from 'lucide-react';
|
||||
import React, { useCallback, useRef, useState } from 'react';
|
||||
|
||||
@@ -13,7 +14,7 @@ import type {
|
||||
} from '../../domain/vaultNavConfig';
|
||||
import { cn } from '../../lib/utils';
|
||||
import { Button } from '../ui/button';
|
||||
import { Popover, PopoverAnchor, PopoverContent } from '../ui/popover';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
|
||||
import { primaryOnlyDragHandlers } from '../ui/primaryOnlyDrag';
|
||||
import { Switch } from '../ui/switch';
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip';
|
||||
@@ -33,6 +34,7 @@ export interface VaultNavCustomizeItem {
|
||||
export interface VaultNavCustomizePopoverProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
collapsed: boolean;
|
||||
items: VaultNavCustomizeItem[];
|
||||
isCustomized: boolean;
|
||||
onToggleVisible: (id: VaultNavItemId) => void;
|
||||
@@ -49,6 +51,7 @@ export interface VaultNavCustomizePopoverProps {
|
||||
export const VaultNavCustomizePopover: React.FC<VaultNavCustomizePopoverProps> = ({
|
||||
open,
|
||||
onOpenChange,
|
||||
collapsed,
|
||||
items,
|
||||
isCustomized,
|
||||
onToggleVisible,
|
||||
@@ -78,13 +81,41 @@ export const VaultNavCustomizePopover: React.FC<VaultNavCustomizePopoverProps> =
|
||||
|
||||
return (
|
||||
<Popover open={open} onOpenChange={onOpenChange}>
|
||||
<PopoverAnchor asChild>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
data-vault-nav-customize-anchor="true"
|
||||
className="pointer-events-none h-0 w-full"
|
||||
/>
|
||||
</PopoverAnchor>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
type="button"
|
||||
variant={open ? 'secondary' : 'ghost'}
|
||||
aria-label={t('vault.nav.customize')}
|
||||
data-vault-nav-customize-trigger="true"
|
||||
className={cn(
|
||||
'w-full',
|
||||
collapsed ? 'justify-center p-0' : 'justify-start gap-3',
|
||||
open && 'bg-foreground/10 text-foreground hover:bg-foreground/15',
|
||||
)}
|
||||
>
|
||||
<span className="relative flex-shrink-0">
|
||||
<SlidersHorizontal size={16} />
|
||||
{isCustomized && (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="absolute -top-0.5 -right-0.5 h-1.5 w-1.5 rounded-full bg-primary"
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
{!collapsed && (
|
||||
<span className="truncate">{t('vault.nav.customize')}</span>
|
||||
)}
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
</TooltipTrigger>
|
||||
{collapsed && !open && (
|
||||
<TooltipContent side="right">
|
||||
{t('vault.nav.customize')}
|
||||
</TooltipContent>
|
||||
)}
|
||||
</Tooltip>
|
||||
|
||||
<PopoverContent
|
||||
side="right"
|
||||
|
||||
@@ -57,7 +57,6 @@ test('VaultNavSidebar supports drag-and-drop reorder (expanded + collapsed), sho
|
||||
'Event',
|
||||
'KeyboardEvent',
|
||||
'MouseEvent',
|
||||
'DOMRect',
|
||||
'ResizeObserver',
|
||||
]) {
|
||||
if (key === 'ResizeObserver') {
|
||||
@@ -181,6 +180,7 @@ test('VaultNavSidebar supports drag-and-drop reorder (expanded + collapsed), sho
|
||||
<VaultNavCustomizePopover
|
||||
open={customizeOpen}
|
||||
onOpenChange={setCustomizeOpen}
|
||||
collapsed={collapsed}
|
||||
items={customizeItems}
|
||||
isCustomized={nav.isCustomized}
|
||||
onToggleVisible={handleToggle}
|
||||
@@ -271,12 +271,7 @@ test('VaultNavSidebar supports drag-and-drop reorder (expanded + collapsed), sho
|
||||
});
|
||||
assert.equal(getVisibleOrder()[1], 'logs', 'Logs moved after Hosts in collapsed mode');
|
||||
|
||||
// 4. Select Logs, verify no standalone Customize button exists, open Customize via right-click context menu on a normal nav button, and toggle Logs off -> active section auto-falls back to Hosts.
|
||||
assert.equal(
|
||||
document.querySelector('[data-vault-nav-customize-trigger="true"]'),
|
||||
null,
|
||||
'sidebar must not render a standalone Customize button',
|
||||
);
|
||||
// 4. Select Logs, open Customize popover, toggle Logs off -> active section auto-falls back to Hosts.
|
||||
await act(async () => {
|
||||
document.querySelector<HTMLButtonElement>('[data-vault-nav-item="logs"] button')!.click();
|
||||
await settle();
|
||||
@@ -284,15 +279,7 @@ test('VaultNavSidebar supports drag-and-drop reorder (expanded + collapsed), sho
|
||||
assert.equal(currentSectionRef, 'logs');
|
||||
|
||||
await act(async () => {
|
||||
document
|
||||
.querySelector<HTMLElement>('[data-vault-nav-item="logs"]')!
|
||||
.dispatchEvent(new dom.window.MouseEvent('contextmenu', { bubbles: true, cancelable: true, button: 2 }));
|
||||
await settle();
|
||||
});
|
||||
const contextCustomizeItem = document.querySelector<HTMLElement>('[data-vault-nav-context-customize="true"]');
|
||||
assert.ok(contextCustomizeItem, 'right-clicking a nav button opens the Customize Sidebar context menu item');
|
||||
await act(async () => {
|
||||
contextCustomizeItem.click();
|
||||
document.querySelector<HTMLButtonElement>('[data-vault-nav-customize-trigger="true"]')!.click();
|
||||
await settle();
|
||||
});
|
||||
assert.ok(document.querySelector('[data-vault-nav-customize-popover="true"]'));
|
||||
@@ -417,7 +404,6 @@ test('VaultNavSidebar renders plugin view badges in expanded and collapsed modes
|
||||
'Event',
|
||||
'KeyboardEvent',
|
||||
'MouseEvent',
|
||||
'DOMRect',
|
||||
'ResizeObserver',
|
||||
]) {
|
||||
if (key === 'ResizeObserver') {
|
||||
|
||||
@@ -83,7 +83,6 @@ export const VaultNavSidebarList: React.FC<VaultNavSidebarListProps> = ({
|
||||
t,
|
||||
}) => {
|
||||
const draggedIdRef = useRef<VaultNavItemId | null>(null);
|
||||
const openingCustomizeRef = useRef(false);
|
||||
const [draggedId, setDraggedId] = useState<VaultNavItemId | null>(null);
|
||||
const [dropTarget, setDropTarget] = useState<{
|
||||
id: VaultNavItemId;
|
||||
@@ -248,15 +247,7 @@ export const VaultNavSidebarList: React.FC<VaultNavSidebarListProps> = ({
|
||||
</div>
|
||||
</ContextMenuTrigger>
|
||||
|
||||
<ContextMenuContent
|
||||
className="min-w-[12rem]"
|
||||
onCloseAutoFocus={(event) => {
|
||||
if (openingCustomizeRef.current) {
|
||||
openingCustomizeRef.current = false;
|
||||
event.preventDefault();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<ContextMenuContent className="min-w-[12rem]">
|
||||
{!item.locked && (
|
||||
<ContextMenuItem
|
||||
disabled={!itemCanHide}
|
||||
@@ -286,14 +277,7 @@ export const VaultNavSidebarList: React.FC<VaultNavSidebarListProps> = ({
|
||||
<span>{t('vault.nav.moveDown')}</span>
|
||||
</ContextMenuItem>
|
||||
<ContextMenuSeparator />
|
||||
<ContextMenuItem
|
||||
data-vault-nav-context-customize="true"
|
||||
onSelect={() => {
|
||||
openingCustomizeRef.current = true;
|
||||
onOpenCustomize();
|
||||
}}
|
||||
className="gap-2"
|
||||
>
|
||||
<ContextMenuItem onSelect={onOpenCustomize} className="gap-2">
|
||||
<SlidersHorizontal size={14} className="shrink-0 text-muted-foreground" />
|
||||
<span>{t('vault.nav.customize')}</span>
|
||||
</ContextMenuItem>
|
||||
|
||||
@@ -868,13 +868,14 @@ export function VaultViewLayout({ ctx }: { ctx: VaultViewLayoutContext }) {
|
||||
|
||||
<div
|
||||
className={cn(
|
||||
"mt-auto shrink-0 pb-4",
|
||||
"mt-auto shrink-0 pb-4 space-y-1",
|
||||
sidebarCollapsed ? "px-1.5" : "px-2.5",
|
||||
)}
|
||||
>
|
||||
<VaultNavCustomizePopover
|
||||
open={isNavCustomizeOpen}
|
||||
onOpenChange={setIsNavCustomizeOpen}
|
||||
collapsed={sidebarCollapsed}
|
||||
items={customizeNavItems}
|
||||
isCustomized={Boolean(vaultNavConfig?.isCustomized)}
|
||||
onToggleVisible={handleToggleVaultNavItemVisible}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 145 KiB |
@@ -77,10 +77,6 @@ const POSIX_PROMPT_PATTERN = /^(?:[^\s@]+@[^\s:]+(?::[^\n\r]*)?|\[[^\s@\]]+@[^\s
|
||||
// Require HH:MM:SS so loose `[word]$` output cannot count as idle.
|
||||
const BRACKET_TIME_POSIX_PROMPT_PATTERN = /^\[[^\s@\]]+\s+\d{2}:\d{2}:\d{2}(?:\s+[^\n\r\]]+)?\][#$]$/;
|
||||
|
||||
// Home Assistant / bash `[\h \W]$` or `[\u \W]$` prompts (#4527).
|
||||
// Require a path field, not a time field, to keep loose `[word]$` rejected as in #4276.
|
||||
const BRACKET_PATH_POSIX_PROMPT_PATTERN = /^\[[^\s@\]]+\s+[^\n\r\]]+\][#$]$/;
|
||||
|
||||
// Space-separated bash PS1 `\u@\h \w $ ` renders as `user@host ~ $`.
|
||||
// macOS ships zsh with `%n@%m %1~ %#`, which renders as
|
||||
// `user@host ~ %` / `user@host My Project %`; privileged shells end in `#`.
|
||||
@@ -188,7 +184,6 @@ function isDefaultPosixPromptLine(line) {
|
||||
(prompt) => (
|
||||
POSIX_PROMPT_PATTERN.test(prompt) ||
|
||||
BRACKET_TIME_POSIX_PROMPT_PATTERN.test(prompt) ||
|
||||
BRACKET_PATH_POSIX_PROMPT_PATTERN.test(prompt) ||
|
||||
PAREN_POSIX_PROMPT_PATTERN.test(prompt) ||
|
||||
ALPINE_PROMPT_PATTERN.test(prompt) ||
|
||||
MACOS_ROOT_PROMPT_PATTERN.test(prompt) ||
|
||||
|
||||
@@ -204,26 +204,11 @@ test("recognizes bracketed time prompts without a hostname and preserves trailin
|
||||
}
|
||||
});
|
||||
|
||||
test("recognizes bracketed host/path prompts without a time field and preserves trailing space", () => {
|
||||
for (const prompt of [
|
||||
"[core-ssh ~]$",
|
||||
"[core-ssh ~]$ ",
|
||||
"[core-ssh /config]$",
|
||||
"[core-ssh homeassistant]$",
|
||||
"[core-ssh ~]#",
|
||||
"[root ~]$",
|
||||
]) {
|
||||
assert.equal(isDefaultPosixPromptLine(prompt), true, prompt);
|
||||
assert.equal(extractTrailingIdlePrompt(`welcome\r\n${prompt}`), prompt, prompt);
|
||||
}
|
||||
});
|
||||
|
||||
test("bracketed prompt recognition rejects pending input and loose single-word output", () => {
|
||||
test("bracketed time prompt recognition rejects pending input and prompts without time", () => {
|
||||
for (const line of [
|
||||
"[root 12:04:23 ~]$ hostname",
|
||||
"[root 12:04:23 ~]$ echo $",
|
||||
"[core-ssh ~]$ date",
|
||||
"[core-ssh ~]$ echo $",
|
||||
"[root ~]$",
|
||||
"[word]$",
|
||||
]) {
|
||||
assert.equal(isDefaultPosixPromptLine(line), false, line);
|
||||
@@ -614,13 +599,6 @@ test("extractTrailingIdlePrompt recognizes an ANSI-colored bracketed time prompt
|
||||
);
|
||||
});
|
||||
|
||||
test("extractTrailingIdlePrompt recognizes an ANSI-colored bracketed host/path prompt", () => {
|
||||
assert.equal(
|
||||
extractTrailingIdlePrompt("welcome\r\n[\x1b[1;34mcore-ssh \x1b[1;32m~\x1b[0m]$ "),
|
||||
"[core-ssh ~]$ ",
|
||||
);
|
||||
});
|
||||
|
||||
test("extractTrailingIdlePrompt recognizes a two-line user@host then bare $/# PS1", () => {
|
||||
// export PS1="\u@\h: \w\n$ " paints the host line, then a lone "$ ".
|
||||
// The cached prompt must keep both lines so a lone "$" cannot satisfy endsWith.
|
||||
@@ -1444,14 +1422,6 @@ test("trackSessionIdlePrompt and getFreshIdlePrompt accept a bracketed time prom
|
||||
assert.equal(getFreshIdlePrompt(session), prompt);
|
||||
});
|
||||
|
||||
test("trackSessionIdlePrompt and getFreshIdlePrompt accept a bracketed host/path prompt", () => {
|
||||
const session = {};
|
||||
const prompt = "[core-ssh ~]$ ";
|
||||
assert.equal(trackSessionIdlePrompt(session, `Last login...\r\n${prompt}`), prompt);
|
||||
assert.equal(session.lastIdlePrompt, prompt);
|
||||
assert.equal(getFreshIdlePrompt(session), prompt);
|
||||
});
|
||||
|
||||
test("visible idle prompt survives a PSReadLine erase that leaves the raw tail dirty", () => {
|
||||
// PSReadLine echoes the pending-input clear prefix (`ggd2147483647d` / `i`),
|
||||
// then homes the cursor and erases those keys with CSI. stripAnsi drops the
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
[
|
||||
{
|
||||
"id": "com.binaricat.netcatty-database",
|
||||
"version": "0.3.2",
|
||||
"version": "0.3.1",
|
||||
"name": "Netcatty Database",
|
||||
"description": "Enterprise-grade multi-database IDE inside Netcatty covering 113 engine profiles (76 live pure-TS drivers across 13 families incl. SQL, CQL, Redis, MongoDB, Neo4j, Search/Vector, KV, RabbitMQ/Pulsar/MQTT/Kafka + 37 catalog entries), BI Dashboard across 53 engines (SQL/CQL/HTTP-SQL + MongoDB Aggregation), Catty Agent tools, Server Monitor, Users Admin, Data Compare, Mock Data, Data Dictionary/Model Codegen, Global Search, Dolt VC, and Vault SSH tunnels.",
|
||||
"author": "Netcatty",
|
||||
"repository": "binaricat/netcatty-database-plugin",
|
||||
"commit": "81c3dd7ad9193b0d3a44df1531daeb6c758b4ee8",
|
||||
"commit": "84928ba5ca9638e509a11b7a578c400c0a320d06",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"readme": "README.md",
|
||||
"manifest": {
|
||||
@@ -21,7 +21,7 @@
|
||||
"en": "Enterprise-grade multi-database IDE inside Netcatty covering 113 engine profiles (76 live pure-TS drivers across 13 families incl. SQL, CQL, Redis, MongoDB, Neo4j, Search/Vector, KV, RabbitMQ/Pulsar/MQTT/Kafka + 37 catalog entries), BI Dashboard across 53 engines (SQL/CQL/HTTP-SQL + MongoDB Aggregation), Catty Agent tools, Server Monitor, Users Admin, Data Compare, Mock Data, Data Dictionary/Model Codegen, Global Search, Dolt VC, and Vault SSH tunnels.",
|
||||
"zh-CN": "内置于 Netcatty 的全功能企业级多数据库 IDE,覆盖 113 种引擎配置(76 个跨 13 大协议族原生驱动,含 SQL/CQL/Redis/MongoDB/Neo4j/检索向量/KV/RabbitMQ/Pulsar/MQTT/Kafka + 37 个目录引擎),支持 53 种引擎 BI 看板(SQL/CQL/HTTP-SQL + MongoDB 聚合)、Catty Agent 工具、服务监控、用户权限、数据对比、测试数据生成、数据字典与代码生成、全局搜索、Dolt 版本控制与 Vault SSH 隧道。"
|
||||
},
|
||||
"version": "0.3.2",
|
||||
"version": "0.3.1",
|
||||
"publisher": "binaricat",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"engines": {
|
||||
@@ -136,8 +136,8 @@
|
||||
}
|
||||
},
|
||||
"artifact": {
|
||||
"url": "https://plugins.netcatty.app/assets/2897fedee8e6f5090622a99e08192ea34c7fd3d8a13bf465df4f169370b13cca.ncpkg",
|
||||
"sha256": "2897fedee8e6f5090622a99e08192ea34c7fd3d8a13bf465df4f169370b13cca"
|
||||
"url": "https://plugins.netcatty.app/assets/fd3d464d92aaf2e8a08b8c7b8b2601a17853ff7832427d60507f13f0683532a4.ncpkg",
|
||||
"sha256": "fd3d464d92aaf2e8a08b8c7b8b2601a17853ff7832427d60507f13f0683532a4"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -7,34 +7,19 @@ const os = require("node:os");
|
||||
const path = require("node:path");
|
||||
const { PluginCatalogService, validateCatalog, fetchBounded } = require("./catalogService.cjs");
|
||||
const { assertCatalogManifest } = require("./catalogPolicy.cjs");
|
||||
const { OFFICIAL_SOURCE, LOCAL_SOURCE, thirdPartySource, githubSource, isOfficialMaintained } = require("./sourceIdentity.cjs");
|
||||
const { OFFICIAL_SOURCE, isOfficialMaintained } = require("./sourceIdentity.cjs");
|
||||
const entries = require("./catalog.json");
|
||||
|
||||
test("curated catalog uses pinned public first-party source and rejects advanced manifests", () => {
|
||||
assert.equal(validateCatalog(entries).length, 2);
|
||||
const database = entries.find((item) => item.id === "com.binaricat.netcatty-database");
|
||||
assert.ok(database, "catalog should include official com.binaricat.netcatty-database");
|
||||
assert.equal(database.version, "0.3.2");
|
||||
assert.equal(database.version, "0.3.1");
|
||||
assert.equal(isOfficialMaintained(database, OFFICIAL_SOURCE), true);
|
||||
const monitor = entries.find((item) => item.id === "com.binaricat.netcatty-monitor");
|
||||
assert.ok(monitor, "catalog should include official com.binaricat.netcatty-monitor");
|
||||
assert.equal(monitor.version, "0.2.2");
|
||||
assert.equal(isOfficialMaintained(monitor, OFFICIAL_SOURCE), true);
|
||||
|
||||
// Future binaricat official plugins are auto-recognized from the official source without an app release.
|
||||
const futureOfficial = {
|
||||
id: "com.binaricat.netcatty-docker",
|
||||
repository: "binaricat/netcatty-docker-plugin",
|
||||
manifest: { publisher: "binaricat" },
|
||||
};
|
||||
assert.equal(isOfficialMaintained(futureOfficial, OFFICIAL_SOURCE), true);
|
||||
assert.equal(isOfficialMaintained({ ...futureOfficial, id: "com.netcatty.k8s", manifest: { publisher: "netcatty" } }, OFFICIAL_SOURCE), true);
|
||||
assert.equal(isOfficialMaintained(futureOfficial, LOCAL_SOURCE), false);
|
||||
assert.equal(isOfficialMaintained(futureOfficial, thirdPartySource("Mirror", "https://mirror.example.com")), false);
|
||||
assert.equal(isOfficialMaintained(futureOfficial, githubSource("binaricat/netcatty-docker-plugin")), false);
|
||||
assert.equal(isOfficialMaintained({ ...futureOfficial, repository: "other/netcatty-docker-plugin" }, OFFICIAL_SOURCE), false);
|
||||
assert.equal(isOfficialMaintained({ ...futureOfficial, id: "com.other.netcatty-docker" }, OFFICIAL_SOURCE), false);
|
||||
assert.equal(isOfficialMaintained({ ...futureOfficial, manifest: { publisher: "other" } }, OFFICIAL_SOURCE), false);
|
||||
for (const main of [{ node: "index.js" }, { browser: "index.js", node: "node.js" }]) {
|
||||
const entry = structuredClone(entries[0]); entry.manifest.main = main;
|
||||
assert.throws(() => validateCatalog([entry]), /browser-only packages/);
|
||||
|
||||
@@ -6,13 +6,13 @@ const { isIP } = require("node:net");
|
||||
const OFFICIAL_ORIGIN = "https://plugins.netcatty.app";
|
||||
const OFFICIAL_SOURCE = Object.freeze({ id: "official", kind: "official", name: "Netcatty marketplace", origin: OFFICIAL_ORIGIN });
|
||||
const LOCAL_SOURCE = Object.freeze({ id: "local", kind: "local", name: "Local import", origin: null });
|
||||
// Host-owned first-party maintenance authority, derived from the trusted official
|
||||
// marketplace source + official GitHub owner + official plugin ID namespace + publisher.
|
||||
// Adding a new official plugin under binaricat/* no longer requires updating the app binary.
|
||||
const OFFICIAL_REPOSITORY_OWNERS = Object.freeze(["binaricat"]);
|
||||
const OFFICIAL_ID_PREFIXES = Object.freeze(["com.binaricat.", "com.netcatty."]);
|
||||
const OFFICIAL_PUBLISHERS = Object.freeze(["binaricat", "netcatty"]);
|
||||
const REPOSITORY_PATTERN = /^([A-Za-z0-9-]+)\/([A-Za-z0-9._-]+)$/;
|
||||
// Curated first-party maintenance authority, independent of manifest publisher text.
|
||||
const FIRST_PARTY_PLUGINS = Object.freeze([
|
||||
Object.freeze({ id: "com.netcatty.starter", repository: "binaricat/Netcatty" }),
|
||||
Object.freeze({ id: "com.netcatty.hello", repository: "binaricat/Netcatty" }),
|
||||
Object.freeze({ id: "com.binaricat.netcatty-database", repository: "binaricat/netcatty-database-plugin" }),
|
||||
Object.freeze({ id: "com.binaricat.netcatty-monitor", repository: "binaricat/netcatty-monitor-plugin" }),
|
||||
]);
|
||||
const hash = (value) => createHash("sha256").update(value).digest("hex");
|
||||
const { parsePluginGitHubRepository } = require("../../domain/pluginGitHubRepository.cjs");
|
||||
|
||||
@@ -63,22 +63,9 @@ function privateOwner(source, pluginId) {
|
||||
|
||||
function isOfficialMaintained(entry, source) {
|
||||
const trusted = assertSource(source);
|
||||
if (trusted.id !== OFFICIAL_SOURCE.id || trusted.kind !== OFFICIAL_SOURCE.kind
|
||||
|| trusted.origin !== OFFICIAL_SOURCE.origin) {
|
||||
return false;
|
||||
}
|
||||
if (!entry || typeof entry.id !== "string" || typeof entry.repository !== "string") {
|
||||
return false;
|
||||
}
|
||||
const repoMatch = REPOSITORY_PATTERN.exec(entry.repository);
|
||||
if (!repoMatch || !OFFICIAL_REPOSITORY_OWNERS.includes(repoMatch[1].toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
if (!OFFICIAL_ID_PREFIXES.some((prefix) => entry.id.startsWith(prefix))) {
|
||||
return false;
|
||||
}
|
||||
const publisher = entry.manifest?.publisher;
|
||||
return typeof publisher === "string" && OFFICIAL_PUBLISHERS.includes(publisher.toLowerCase());
|
||||
return trusted.id === OFFICIAL_SOURCE.id && trusted.kind === OFFICIAL_SOURCE.kind
|
||||
&& trusted.origin === OFFICIAL_SOURCE.origin
|
||||
&& FIRST_PARTY_PLUGINS.some((pair) => pair.id === entry.id && pair.repository === entry.repository);
|
||||
}
|
||||
|
||||
module.exports = { OFFICIAL_SOURCE, LOCAL_SOURCE, canonicalSourceOrigin, thirdPartySource, githubSource, assertSource, privateOwner, isOfficialMaintained };
|
||||
Reference in new issue
Block a user