import { useQuery } from '@tanstack/react-query'; import { CheckIcon, CopyIcon, PackageIcon } from 'lucide-react'; import { useState } from 'react'; import { Badge } from '#/components/atoms/badge.jsx'; import { Notice } from '#/components/atoms/notice.jsx'; import { RowIcon } from '#/components/atoms/row-icon.jsx'; import { EmptyState } from '#/components/molecules/empty-state.jsx'; import { ListRow } from '#/components/molecules/list-row.jsx'; import { TextLink } from '#/components/molecules/text-link.jsx'; import { get } from '#/lib/api.js'; import { bytes, timeAgo } from '#/lib/format.js'; import { queryKeys } from '#/lib/query.js'; /** One line summarizing a package's shape. */ function packageSummary(pkg) { if (pkg.versions.length === 0) return 'nothing published yet'; const parts = [ `${pkg.versions.length} ${pkg.versions.length === 1 ? 'version' : 'versions'}`, ]; parts.push(bytes(pkg.size)); if (pkg.updatedAt) parts.push(`published ${timeAgo(pkg.updatedAt)}`); return parts.join(' · '); } /** A command with a copy button beside it, shown in full where room allows. */ function CopyCommand({ command, compact }) { const [copied, setCopied] = useState(false); const copy = (event) => { event.preventDefault(); event.stopPropagation(); navigator.clipboard.writeText(command).then(() => { setCopied(true); setTimeout(() => setCopied(false), 1500); }); }; return ( ); } /** Every version of one package: number, size, when, its install command. */ function VersionList({ pkg, registryUrl }) { const rows = [...pkg.versions].reverse(); return (