PageSourceSearch

https://cherry-collective.com/assets/PluginsPage-BVev-H6z.js

js cherry-collective.com collected 2026-10-07 23:55:56 UTC 6,121 bytes, 16 lines download raw bytes

1import{r as t,j as e,m as l}from"./vendor-ui-CQkUJbRj.js";import{s as u}from"./session-BhR1Jyos.js";import{C as k}from"./theme-DWTMOexw.js";import{C as T}from"./circle-alert-B2ioHjM7.js";import{o,a as f}from"./index-DuLY_NoB.js";import{B as j}from"./box-D3yWHtlv.js";import{T as $}from"./tag-Bcj6SHhU.js";import{U as P}from"./user-CAfKAMx5.js";/**
2 * @license lucide-react v1.7.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const S=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],C=o("hash",S);/**
7 * @license lucide-react v1.7.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const E=[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],_=o("power-off",E);/**
12 * @license lucide-react v1.7.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const H=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],M=o("power",H);function F(){const[c,d]=t.useState([]),[b,m]=t.useState(!0),[x,i]=t.useState(null),[g,h]=t.useState(null),[y,n]=t.useState(null);async function v(){m(!0),i(null);try{const s=await fetch("/api/plugins",{headers:u()});if(!s.ok)throw new Error(`HTTP ${s.status}: ${await s.text()}`);const a=await s.json();d(Array.isArray(a)?a:[])}catch(s){i(s instanceof Error?s.message:String(s))}finally{m(!1)}}t.useEffect(()=>{v()},[]);async function N(s){h(s.name),n(null);try{const a=await fetch(`/api/plugins/${encodeURIComponent(s.name)}/toggle`,{method:"POST",headers:{...u(),"Content-Type":"application/json"}});if(!a.ok)throw new Error(`HTTP ${a.status}: ${await a.text()}`);const r=await a.json();d(w=>w.map(p=>p.name===s.name?r.plugin:p)),n(`${s.name}: ${r.previous_active?"active → inactive":"inactive → active"}`+(r.reload_ok?" (registry reloaded)":` (reload failed: ${r.reload_error})`)),setTimeout(()=>n(null),4e3)}catch(a){i(a instanceof Error?a.message:String(a))}finally{h(null)}}return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-pink-50 via-white to-rose-50 p-6 md:p-10",children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsxs(l.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{duration:.3},className:"mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-2",style:{color:k},children:"Plugins"}),e.jsx("p",{className:"text-gray-600",children:"Installable tools registered against the Cherry OS plugin SDK. Toggle active to include/exclude a plugin in the live tool registry."})]}),y&&e.jsx(l.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},className:"mb-4 px-4 py-3 rounded-lg bg-green-50 border border-green-200 text-green-800 text-sm",children:y}),x&&e.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-red-50 border border-red-200 text-red-800 text-sm flex gap-2 items-start",children:[e.jsx(T,{className:"w-5 h-5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Couldn't load plugins"}),e.jsx("div",{className:"font-mono text-xs break-all mt-1",children:x})]})]}),b?e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 py-12 justify-center",children:[e.jsx(f,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading plugins…"})]}):c.length===0?e.jsxs("div",{className:"text-center py-12 text-gray-500",children:[e.jsx(j,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),e.jsx("div",{children:"No plugins registered yet."}),e.jsxs("div",{className:"text-xs mt-2",children:["Register via ",e.jsx("code",{className:"bg-gray-100 px-1.5 py-0.5 rounded",children:"POST /api/packages"})]})]}):e.jsx("div",{className:"space-y-3",children:c.map(s=>e.jsx(l.div,{initial:{opacity:0,y:8}
16,animate:{opacity:1,y:0},className:"bg-white rounded-xl border border-gray-200 p-5 hover:border-rose-200 transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:s.name}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${s.active?"bg-green-100 text-green-700":"bg-gray-100 text-gray-500"}`,children:s.active?"active":"inactive"})]}),s.description&&e.jsx("p",{className:"text-sm text-gray-600 mb-2",children:s.description}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(C,{className:"w-3 h-3"})," v",s.version||"?"]}),s.tier&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($,{className:"w-3 h-3"})," ",s.tier]}),s.category&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(j,{className:"w-3 h-3"})," ",s.category]}),s.author&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(P,{className:"w-3 h-3"})," ",s.author]})]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-2 font-mono break-all",children:["→ ",s.endpoint]})]}),e.jsx("button",{onClick:()=>N(s),disabled:g===s.name,className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors min-w-[110px] justify-center ${s.active?"bg-rose-50 text-rose-700 hover:bg-rose-100 border border-rose-200":"bg-green-600 text-white hover:bg-green-700"} disabled:opacity-50 disabled:cursor-not-allowed`,children:g===s.name?e.jsx(f,{className:"w-4 h-4 animate-spin"}):s.active?e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"w-4 h-4"})," Disable"]}):e.jsxs(e.Fragment,{children:[e.jsx(M,{className:"w-4 h-4"})," Enable"]})})]})},s.id))})]})})}export{F as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.