diff --git a/script.js b/script.js index 8bd32be..988cede 100644 --- a/script.js +++ b/script.js @@ -93,4 +93,4 @@ Error generating stack: `+o.message+` * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vd=Ze("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);function Bd(){const[e,t]=b.useState(()=>{const r=localStorage.getItem("theme");return r==="dark"||r==="light"?r:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"});return b.useEffect(()=>{const r=window.document.documentElement;r.classList.remove("light","dark"),r.classList.add(e),localStorage.setItem("theme",e)},[e]),{theme:e,toggleTheme:()=>{t(r=>r==="light"?"dark":"light")}}}function Hd(){const{theme:e,toggleTheme:t}=Bd();return w.jsx("button",{onClick:t,className:"p-3 rounded-full bg-nord-8/10 dark:bg-nord-8/20 hover:bg-nord-8/20 dark:hover:bg-nord-8/30 transition-all ease-in-out duration-300","aria-label":"Toggle theme",children:e==="dark"?w.jsx(Ad,{className:"h-6 w-6 text-nord-4 transition-transform transform rotate-0 dark:rotate-180"}):w.jsx(Ud,{className:"h-6 w-6 text-nord-4 transition-transform transform rotate-360 dark:rotate-360"})})}function Wd(){return w.jsxs("div",{className:"flex items-center gap-3",children:[w.jsx("div",{className:"p-3 bg-white/10 rounded-lg",children:w.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100",className:"h-10 w-10",fill:"currentColor",children:[w.jsx("circle",{cx:"50",cy:"50",r:"48",stroke:"currentColor",strokeWidth:"4",fill:"none"}),w.jsx("path",{d:"M50 20L70 50L50 80L30 50Z",fill:"currentColor",className:"text-nord-7"})]})}),w.jsxs("div",{children:[w.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Snigdha OS Package List"}),w.jsx("p",{className:"text-nord-4 text-sm mt-1",children:"Browse and search through the official Snigdha OS package repository"})]})]})}function Qd(){return w.jsx("header",{className:"bg-gradient-to-r from-nord-9 to-nord-8 via-nord-10 text-nord-6 shadow-lg",children:w.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4",children:w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsx("div",{className:"flex items-center gap-4",children:w.jsx(Wd,{})}),w.jsx(Hd,{})]})})})}function Kd({value:e,onChange:t}){return w.jsxs("div",{className:"relative w-full max-w-md mx-auto",children:[w.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:w.jsx($d,{className:"h-5 w-5 text-nord-6 dark:text-nord-5"})}),w.jsx("input",{type:"text",value:e,onChange:n=>t(n.target.value),placeholder:"Search packages...",className:"block w-full pl-10 pr-4 py-3 border-2 border-nord-4 dark:border-nord-2 rounded-xl bg-nord-5 dark:bg-nord-1 focus:ring-2 focus:ring-nord-8 focus:border-transparent text-nord-0 dark:text-nord-6 placeholder-nord-3 dark:placeholder-nord-4 transition-all ease-in-out duration-200 shadow-md hover:shadow-lg"})]})}function Yd({packageName:e}){const[t,n]=wc.useState(!1),r=`sudo pacman -S ${e}`,l=()=>{navigator.clipboard.writeText(r),n(!0),setTimeout(()=>n(!1),2e3)};return w.jsxs("div",{className:"bg-nord-0 dark:bg-nord-3 rounded-xl p-5 shadow-md transition-all",children:[w.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[w.jsx(Vd,{className:"h-5 w-5 text-nord-9 dark:text-nord-7"}),w.jsx("span",{className:"text-nord-2 dark:text-nord-5 text-sm font-semibold uppercase tracking-wide",children:"Installation Command"})]}),w.jsxs("div",{className:"flex items-center justify-between bg-nord-4 dark:bg-nord-2 rounded-lg px-5 py-3",children:[w.jsx("code",{className:"text-nord-8 dark:text-nord-6 font-mono text-sm truncate",children:r}),w.jsx("button",{onClick:l,className:"flex items-center justify-center w-8 h-8 rounded-full bg-nord-3 hover:bg-nord-7 dark:bg-nord-5 dark:hover:bg-nord-8 transition-colors",title:t?"Copied!":"Copy to clipboard","aria-label":t?"Copied":"Copy command",children:t?w.jsx(Od,{className:"h-4 w-4 text-nord-6 dark:text-nord-0"}):w.jsx(Fd,{className:"h-4 w-4 text-nord-6 dark:text-nord-0"})})]})]})}function Xd({package:e}){const[t,n]=b.useState(!1);return w.jsxs("div",{className:"bg-nord-5 dark:bg-nord-1 rounded-xl shadow-md border border-nord-4 dark:border-nord-2 hover:shadow-lg transition-all overflow-hidden",children:[w.jsxs("div",{className:"p-5 flex items-start gap-4",children:[w.jsx("div",{className:"flex-shrink-0 p-3 bg-nord-7/10 dark:bg-nord-7/20 rounded-xl shadow-sm",children:w.jsx(Md,{className:"h-6 w-6 text-nord-7 dark:text-nord-6"})}),w.jsxs("div",{className:"flex-1",children:[w.jsxs("div",{className:"flex items-center justify-between",children:[w.jsx("h3",{className:"text-lg font-semibold text-nord-0 dark:text-nord-6",children:e.name}),w.jsx("span",{className:"text-sm font-medium text-nord-3 dark:text-nord-4",children:e.version})]}),w.jsx("p",{className:"mt-2 text-sm text-nord-2 dark:text-nord-4",children:e.description}),w.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[w.jsx("span",{className:"inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-nord-8/10 dark:bg-nord-8/20 text-nord-10 dark:text-nord-8",children:e.repository}),w.jsx("button",{onClick:()=>n(!t),className:"text-nord-9 dark:text-nord-8 hover:text-nord-10 dark:hover:text-nord-7 flex items-center gap-2 text-sm font-medium",children:t?w.jsxs(w.Fragment,{children:[w.jsx(Id,{className:"h-4 w-4"}),"Hide Installation"]}):w.jsxs(w.Fragment,{children:[w.jsx(Dd,{className:"h-4 w-4"}),"Show Installation"]})})]})]})]}),t&&w.jsx("div",{className:"border-t border-nord-4 dark:border-nord-2 p-5 bg-nord-6 dark:bg-nord-0",children:w.jsx(Yd,{packageName:e.name})})]})}function Gd({packages:e,loading:t}){return t?w.jsx("div",{className:"flex items-center justify-center h-64",children:w.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"})}):w.jsx("div",{className:"grid gap-4",children:e.map(n=>w.jsx(Xd,{package:n},n.name))})}const Zd=["https://raw.githubusercontent.com/Snigdha-OS/snigdhaos-core/refs/heads/master/packages.txt","https://raw.githubusercontent.com/Snigdha-OS/snigdhaos-extra/refs/heads/master/packages.txt"];async function Jd(e){return(await(await fetch(e)).text()).split(` -`).filter(Boolean).map(r=>{const[l,o,...i]=r.split(" ");return{name:l,version:o,description:i.join(" "),repository:"core"}})}async function qd(){for(const e of Zd)try{return await Jd(e)}catch(t){console.warn(`Failed to fetch from mirror ${e}:`,t);continue}throw new Error("All mirrors failed to respond")}function bd(){const[e,t]=b.useState([]),[n,r]=b.useState(!0),[l,o]=b.useState(null),[i,u]=b.useState(0),s=b.useCallback(async()=>{try{r(!0),o(null);const h=await qd();t(h)}catch(h){console.error("Failed to fetch packages:",h),o("Failed to load packages. Please try again later."),i<3&&u(m=>m+1)}finally{r(!1)}},[i]);return b.useEffect(()=>{s()},[s]),{packages:e,loading:n,error:l,retryLoading:()=>{u(0),s()}}}function ep(){const{packages:e,loading:t,error:n}=bd(),[r,l]=b.useState(""),o=e.filter(i=>i.name.toLowerCase().includes(r.toLowerCase())||i.description.toLowerCase().includes(r.toLowerCase()));return w.jsxs("div",{className:"min-h-screen bg-nord-6 dark:bg-nord-0 transition-colors",role:"main",children:[w.jsx(Qd,{}),w.jsxs("main",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[w.jsx("div",{className:"mb-8",children:w.jsx(Kd,{value:r,onChange:l})}),w.jsx("div",{className:"mb-4 flex items-center justify-between",children:w.jsxs("p",{className:"text-sm text-nord-3 dark:text-nord-4","aria-live":"polite",children:["Showing ",o.length," package",o.length!==1?"s":""]})}),n?w.jsxs("div",{className:"rounded-lg bg-nord-11/10 dark:bg-nord-11/20 p-4 text-nord-11",role:"alert",children:[w.jsxs("p",{children:["An error occurred while fetching packages: ",n]}),w.jsx("button",{onClick:()=>window.location.reload(),className:"mt-2 inline-block text-sm text-nord-10 hover:underline",children:"Retry"})]}):o.length===0?w.jsx("div",{className:"text-center text-nord-3 dark:text-nord-4 mt-12",children:w.jsx("p",{children:"No packages found matching your search."})}):w.jsx(Gd,{packages:o,loading:t})]}),w.jsx("footer",{className:"bg-nord-5 dark:bg-nord-1 border-t border-nord-4 dark:border-nord-2 mt-12 transition-colors",children:w.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6",children:w.jsxs("p",{className:"text-center text-sm text-nord-3 dark:text-nord-4",children:["Data Source:"," ",w.jsx("a",{href:"https://github.com/Snigdha-OS/snigdhaos-core",className:"text-nord-10 hover:text-nord-9 dark:text-nord-8 dark:hover:text-nord-7",target:"_blank",rel:"noopener noreferrer",children:"Snigdha OS Package Repository"})]})})})]})}tc(document.getElementById("root")).render(w.jsx(b.StrictMode,{children:w.jsx(ep,{})})); +`).filter(Boolean).map(r=>{const[l,o,...i]=r.split(" ");return{name:l,version:o,description:i.join(" "),repository:"core"}})}async function qd(){let e=[];for(const t of Zd)try{const n=await Jd(t);e=e.concat(n)}catch(n){console.warn(`Failed to fetch from mirror ${t}:`,n);continue}if(e.length===0)throw new Error("All mirrors failed to respond");return e}function bd(){const[e,t]=b.useState([]),[n,r]=b.useState(!0),[l,o]=b.useState(null),[i,u]=b.useState(0),s=b.useCallback(async()=>{try{r(!0),o(null);const h=await qd();t(h)}catch(h){console.error("Failed to fetch packages:",h),o("Failed to load packages. Please try again later."),i<3&&u(m=>m+1)}finally{r(!1)}},[i]);return b.useEffect(()=>{s()},[s]),{packages:e,loading:n,error:l,retryLoading:()=>{u(0),s()}}}function ep(){const{packages:e,loading:t,error:n}=bd(),[r,l]=b.useState(""),o=e.filter(i=>i.name.toLowerCase().includes(r.toLowerCase())||i.description.toLowerCase().includes(r.toLowerCase()));return w.jsxs("div",{className:"min-h-screen bg-nord-6 dark:bg-nord-0 transition-colors",role:"main",children:[w.jsx(Qd,{}),w.jsxs("main",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[w.jsx("div",{className:"mb-8",children:w.jsx(Kd,{value:r,onChange:l})}),w.jsx("div",{className:"mb-4 flex items-center justify-between",children:w.jsxs("p",{className:"text-sm text-nord-3 dark:text-nord-4","aria-live":"polite",children:["Showing ",o.length," package",o.length!==1?"s":""]})}),n?w.jsxs("div",{className:"rounded-lg bg-nord-11/10 dark:bg-nord-11/20 p-4 text-nord-11",role:"alert",children:[w.jsxs("p",{children:["An error occurred while fetching packages: ",n]}),w.jsx("button",{onClick:()=>window.location.reload(),className:"mt-2 inline-block text-sm text-nord-10 hover:underline",children:"Retry"})]}):o.length===0?w.jsx("div",{className:"text-center text-nord-3 dark:text-nord-4 mt-12",children:w.jsx("p",{children:"No packages found matching your search."})}):w.jsx(Gd,{packages:o,loading:t})]}),w.jsx("footer",{className:"bg-nord-5 dark:bg-nord-1 border-t border-nord-4 dark:border-nord-2 mt-12 transition-colors",children:w.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6",children:w.jsxs("p",{className:"text-center text-sm text-nord-3 dark:text-nord-4",children:["Data Source:"," ",w.jsx("a",{href:"https://github.com/Snigdha-OS/snigdhaos-core",className:"text-nord-10 hover:text-nord-9 dark:text-nord-8 dark:hover:text-nord-7",target:"_blank",rel:"noopener noreferrer",children:"Snigdha OS Package Repository"})]})})})]})}tc(document.getElementById("root")).render(w.jsx(b.StrictMode,{children:w.jsx(ep,{})}));