feat(market): show all channels with Alpha tag, version picker, sorting, and title links (#176)
* feat(market): show all channels with Alpha tag, version picker, sorting, and title links * fix(market): merge multi-channel releases and default picker to card version
This commit is contained in:
14 files changed
+471
-20
No files matched your search
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"group": "improvements",
|
||||
"order": 0,
|
||||
"authors": ["Nwflower"],
|
||||
"zh": "插件市场不再隐藏 Alpha 通道插件(改为展示 `Alpha` 标签),安装与更新时弹出版本选择清单,支持按综合(发布日与下载量)、Star、下载量与最新发布排序,并将带主页的插件标题设为可跳转超链接。",
|
||||
"en": "Show Alpha plugins directly in the marketplace with an `Alpha` tag instead of hiding them, open a version picker when installing or updating, add sorting by Recommended (recency + downloads), Stars, Downloads, and Recently updated, and make plugin titles clickable links to their homepage."
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import { I18nKey, locText, t } from '../i18n'
|
||||
import { Locale, MarketBrowseResult, MarketCatalogItem, PluginInfo, ScanReport } from '../types'
|
||||
import { Button, Tip } from '../ui/controls'
|
||||
import { Modal } from '../ui/dialog'
|
||||
import { PopupSelect } from '../ui/settings'
|
||||
import { api, events, MarketInstallProgress } from '../wails'
|
||||
import { PluginAppIcon, PluginApprovalBody, PluginSearchInput, PluginTrustBadge, RiskList } from './PluginParts'
|
||||
import { WordmarkLoader } from './WordmarkLoader'
|
||||
@@ -25,12 +26,56 @@ const KIND_LABELS: Record<string, I18nKey> = {
|
||||
runtime: 'pluginMarketKindRuntime',
|
||||
}
|
||||
|
||||
type MarketSortMode = 'composite' | 'stars' | 'downloads' | 'recent'
|
||||
|
||||
function formatCompactCount(n: number): string {
|
||||
if (n >= 10000) return `${(n / 1000).toFixed(0)}k`
|
||||
if (n >= 1000) return `${(n / 1000).toFixed(1).replace(/\.0$/, '')}k`
|
||||
return String(n)
|
||||
}
|
||||
|
||||
function formatByteSize(bytes?: number): string {
|
||||
if (!bytes || bytes <= 0) return ''
|
||||
if (bytes >= 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`
|
||||
if (bytes >= 1024) return `${Math.max(1, Math.round(bytes / 1024))} KB`
|
||||
return `${bytes} B`
|
||||
}
|
||||
|
||||
function formatShortDate(iso?: string): string {
|
||||
if (!iso) return ''
|
||||
const ms = Date.parse(iso)
|
||||
if (Number.isNaN(ms)) return ''
|
||||
return new Date(ms).toISOString().slice(0, 10)
|
||||
}
|
||||
|
||||
function parseTimestamp(iso?: string): number {
|
||||
if (!iso) return 0
|
||||
const ms = Date.parse(iso)
|
||||
return Number.isNaN(ms) ? 0 : ms
|
||||
}
|
||||
|
||||
function compositeScore(item: MarketCatalogItem, nowMs: number): number {
|
||||
const ts = parseTimestamp(item.entry.updated_at)
|
||||
const ageDays = ts > 0 ? Math.max(0, (nowMs - ts) / 86400000) : 3650
|
||||
const recency = ts > 0 ? 10 / (1 + ageDays / 30) : 0
|
||||
const downloads = Math.log1p(Math.max(0, item.entry.downloads ?? 0)) * 2
|
||||
return recency + downloads
|
||||
}
|
||||
|
||||
function entryReleases(item: MarketCatalogItem) {
|
||||
const e = item.entry
|
||||
if (e.releases && e.releases.length > 0) return e.releases
|
||||
return [{
|
||||
version: e.version,
|
||||
channel: e.channel || 'stable',
|
||||
download_url: e.download_url,
|
||||
sha256: e.sha256,
|
||||
size_bytes: e.size_bytes,
|
||||
published_at: e.updated_at,
|
||||
changelog: e.changelog,
|
||||
}]
|
||||
}
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
safeMode?: boolean
|
||||
@@ -56,6 +101,8 @@ export const PluginMarket: React.FC<Props> = ({
|
||||
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
|
||||
const [query, setQuery] = useState('')
|
||||
const [kind, setKind] = useState('')
|
||||
const [sortBy, setSortBy] = useState<MarketSortMode>('composite')
|
||||
const [versionPick, setVersionPick] = useState<{ item: MarketCatalogItem; selected: string } | null>(null)
|
||||
const [result, setResult] = useState<MarketBrowseResult | null>(null)
|
||||
const [syncing, setSyncing] = useState(false)
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
@@ -85,7 +132,7 @@ export const PluginMarket: React.FC<Props> = ({
|
||||
const started = Date.now()
|
||||
if (force) setRefreshing(true)
|
||||
try {
|
||||
const res = await api.BrowsePluginMarket(q, k, false, force)
|
||||
const res = await api.BrowsePluginMarket(q, k, true, force)
|
||||
if (force) {
|
||||
const wait = MIN_REFRESH_MS - (Date.now() - started)
|
||||
if (wait > 0) await new Promise((r) => window.setTimeout(r, wait))
|
||||
@@ -152,7 +199,40 @@ export const PluginMarket: React.FC<Props> = ({
|
||||
setProgress((prev) => prev[p.id] ? { ...prev, [p.id]: p } : prev)
|
||||
}), [])
|
||||
|
||||
const items = result?.items ?? []
|
||||
const items = useMemo(() => {
|
||||
const raw = result?.items ?? []
|
||||
if (raw.length <= 1) return raw
|
||||
const nowMs = Date.now()
|
||||
return [...raw].sort((a, b) => {
|
||||
if (a.update_available !== b.update_available) return a.update_available ? -1 : 1
|
||||
switch (sortBy) {
|
||||
case 'stars': {
|
||||
const d = (b.entry.stars ?? 0) - (a.entry.stars ?? 0)
|
||||
if (d !== 0) return d
|
||||
break
|
||||
}
|
||||
case 'downloads': {
|
||||
const d = (b.entry.downloads ?? 0) - (a.entry.downloads ?? 0)
|
||||
if (d !== 0) return d
|
||||
break
|
||||
}
|
||||
case 'recent': {
|
||||
const d = parseTimestamp(b.entry.updated_at) - parseTimestamp(a.entry.updated_at)
|
||||
if (d !== 0) return d
|
||||
break
|
||||
}
|
||||
case 'composite':
|
||||
default: {
|
||||
const d = compositeScore(b, nowMs) - compositeScore(a, nowMs)
|
||||
if (Math.abs(d) > 1e-6) return d
|
||||
break
|
||||
}
|
||||
}
|
||||
const dl = (b.entry.downloads ?? 0) - (a.entry.downloads ?? 0)
|
||||
if (dl !== 0) return dl
|
||||
return a.entry.id.localeCompare(b.entry.id)
|
||||
})
|
||||
}, [result?.items, sortBy])
|
||||
const shown = items.slice(0, visible)
|
||||
const hasMore = items.length > visible
|
||||
|
||||
@@ -197,13 +277,22 @@ export const PluginMarket: React.FC<Props> = ({
|
||||
advancePrompt()
|
||||
}
|
||||
|
||||
const install = async (item: MarketCatalogItem) => {
|
||||
const openVersionPicker = (item: MarketCatalogItem) => {
|
||||
const list = entryReleases(item)
|
||||
const defaultVer = list.find((r) => r.version === item.entry.version)?.version ?? list[0]?.version ?? item.entry.version
|
||||
setVersionPick({ item, selected: defaultVer })
|
||||
}
|
||||
|
||||
const install = async (item: MarketCatalogItem, version?: string) => {
|
||||
const id = item.entry.id
|
||||
if (installingRef.current.has(id)) return
|
||||
installingRef.current.add(id)
|
||||
setProgress((prev) => ({ ...prev, [id]: { id, phase: 'download', done: 0, total: item.entry.size_bytes ?? 0 } }))
|
||||
const rel = entryReleases(item).find((r) => r.version === version)
|
||||
setProgress((prev) => ({ ...prev, [id]: { id, phase: 'download', done: 0, total: rel?.size_bytes ?? item.entry.size_bytes ?? 0 } }))
|
||||
try {
|
||||
const info = await api.InstallMarketPlugin(id, false)
|
||||
const info = version
|
||||
? await api.InstallMarketPluginVersion(id, version)
|
||||
: await api.InstallMarketPlugin(id, true)
|
||||
await onChanged({})
|
||||
if (info && !info.enabled) {
|
||||
if (promptTargetIDRef.current) {
|
||||
@@ -283,7 +372,7 @@ export const PluginMarket: React.FC<Props> = ({
|
||||
return (
|
||||
<Tip label={tr('pluginMarketVersionTip', { installed: item.installed_version ?? '', version: e.version })}>
|
||||
<span>
|
||||
<Button className="market-btn" variant="primary" disabled={!!safeMode} icon={<Download size={13} aria-hidden="true" />} onClick={() => void install(item)}>
|
||||
<Button className="market-btn" variant="primary" disabled={!!safeMode} icon={<Download size={13} aria-hidden="true" />} onClick={() => openVersionPicker(item)}>
|
||||
{tr('pluginMarketUpdateShort')}
|
||||
</Button>
|
||||
</span>
|
||||
@@ -291,7 +380,7 @@ export const PluginMarket: React.FC<Props> = ({
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Button className="market-btn" disabled={!!safeMode} icon={<Download size={13} aria-hidden="true" />} onClick={() => void install(item)}>
|
||||
<Button className="market-btn" disabled={!!safeMode} icon={<Download size={13} aria-hidden="true" />} onClick={() => openVersionPicker(item)}>
|
||||
{tr('pluginMarketInstall')}
|
||||
</Button>
|
||||
)
|
||||
@@ -305,12 +394,27 @@ export const PluginMarket: React.FC<Props> = ({
|
||||
return (
|
||||
<section className="section plugin-market">
|
||||
<div className="market-toolbar">
|
||||
<PluginSearchInput
|
||||
value={query}
|
||||
onChange={setQuery}
|
||||
placeholder={tr('pluginMarketSearchPlaceholder')}
|
||||
wide
|
||||
/>
|
||||
<div className="market-toolbar-top">
|
||||
<PluginSearchInput
|
||||
value={query}
|
||||
onChange={setQuery}
|
||||
placeholder={tr('pluginMarketSearchPlaceholder')}
|
||||
wide
|
||||
/>
|
||||
<div className="market-sort">
|
||||
<PopupSelect
|
||||
label={tr('pluginMarketSortLabel')}
|
||||
value={sortBy}
|
||||
onChange={(v) => setSortBy(v as MarketSortMode)}
|
||||
options={[
|
||||
{ value: 'composite', label: tr('pluginMarketSortComposite') },
|
||||
{ value: 'stars', label: tr('pluginMarketSortStars') },
|
||||
{ value: 'downloads', label: tr('pluginMarketSortDownloads') },
|
||||
{ value: 'recent', label: tr('pluginMarketSortRecent') },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{facets.length > 1 && (
|
||||
<div className="market-kinds" role="radiogroup" aria-label={tr('pluginMarketKindAll')}>
|
||||
{[{ kind: '', count: 0 }, ...facets].map((f) => (
|
||||
@@ -371,11 +475,34 @@ export const PluginMarket: React.FC<Props> = ({
|
||||
<div className="market-card-head">
|
||||
<PluginAppIcon plugin={e} size="lg" />
|
||||
<div className="market-card-titles">
|
||||
<h3 className="market-card-name" title={locText(e.name, locale, e.id)}>{locText(e.name, locale, e.id)}</h3>
|
||||
{(() => {
|
||||
const title = locText(e.name, locale, e.id)
|
||||
const rawHref = (e.homepage || e.readme_url || '').trim()
|
||||
const href = /^https:\/\//i.test(rawHref) ? rawHref : ''
|
||||
return (
|
||||
<h3 className="market-card-name" title={href || title}>
|
||||
{href ? (
|
||||
<a
|
||||
className="plugin-title-link"
|
||||
href={href}
|
||||
onClick={(ev) => {
|
||||
ev.preventDefault()
|
||||
void api.OpenURL(href).catch((err) => onError(tr('failGeneric'), err))
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</a>
|
||||
) : title}
|
||||
</h3>
|
||||
)
|
||||
})()}
|
||||
<div className="market-card-byline">
|
||||
<PluginTrustBadge locale={locale} trust={e.trust} publisher={e.publisher} />
|
||||
<span className="market-card-dot" aria-hidden="true">·</span>
|
||||
<span className="market-card-version">v{e.version}</span>
|
||||
{e.channel === 'alpha' && (
|
||||
<span className="market-alpha-badge">{tr('pluginMarketAlphaTag')}</span>
|
||||
)}
|
||||
{(e.stars ?? 0) > 0 && (
|
||||
<>
|
||||
<span className="market-card-dot" aria-hidden="true">·</span>
|
||||
@@ -409,6 +536,73 @@ export const PluginMarket: React.FC<Props> = ({
|
||||
</>
|
||||
)}
|
||||
|
||||
{versionPick && (
|
||||
<Modal
|
||||
title={tr('pluginMarketPickVersionTitle')}
|
||||
subtitle={locText(versionPick.item.entry.name, locale, versionPick.item.entry.id)}
|
||||
closeLabel={tr('close')}
|
||||
onClose={() => setVersionPick(null)}
|
||||
>
|
||||
<div className="dialog-body">
|
||||
<div className="market-version-list" role="radiogroup" aria-label={tr('pluginMarketPickVersionTitle')}>
|
||||
{entryReleases(versionPick.item).map((rel) => {
|
||||
const selected = versionPick.selected === rel.version
|
||||
const isCurrent = versionPick.item.installed && versionPick.item.installed_version === rel.version
|
||||
const notes = locText(rel.changelog, locale, '')
|
||||
const date = formatShortDate(rel.published_at)
|
||||
const size = formatByteSize(rel.size_bytes)
|
||||
return (
|
||||
<label
|
||||
key={rel.version}
|
||||
className={`market-version-opt${selected ? ' is-selected' : ''}`}
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
name="market-version"
|
||||
checked={selected}
|
||||
onChange={() => setVersionPick({ ...versionPick, selected: rel.version })}
|
||||
/>
|
||||
<div className="market-version-main">
|
||||
<div className="market-version-head">
|
||||
<span className="market-card-version">v{rel.version}</span>
|
||||
{rel.channel === 'alpha' && (
|
||||
<span className="market-alpha-badge">{tr('pluginMarketAlphaTag')}</span>
|
||||
)}
|
||||
{isCurrent && (
|
||||
<span className="market-version-current">{tr('pluginMarketCurrentVersion')}</span>
|
||||
)}
|
||||
<span className="market-version-meta">
|
||||
{[date, size].filter(Boolean).join(' · ')}
|
||||
</span>
|
||||
</div>
|
||||
{notes && <p className="market-version-notes">{notes}</p>}
|
||||
</div>
|
||||
</label>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<span />
|
||||
<span className="hstack">
|
||||
<Button variant="ghost" onClick={() => setVersionPick(null)}>{tr('cancel')}</Button>
|
||||
<Button
|
||||
variant="primary"
|
||||
disabled={!versionPick.selected || !!safeMode}
|
||||
icon={<Download size={13} aria-hidden="true" />}
|
||||
onClick={() => {
|
||||
const target = versionPick
|
||||
setVersionPick(null)
|
||||
void install(target.item, target.selected)
|
||||
}}
|
||||
>
|
||||
{tr('pluginMarketPickVersionInstall')}
|
||||
</Button>
|
||||
</span>
|
||||
</div>
|
||||
</Modal>
|
||||
)}
|
||||
|
||||
{prompt && (
|
||||
<Modal
|
||||
title={tr('pluginEnablePromptTitle', { name: locText(prompt.name, locale, prompt.id) })}
|
||||
|
||||
@@ -424,7 +424,26 @@ export const PluginsPage: React.FC<Props> = ({
|
||||
<PluginAppIcon plugin={p} size="md" />
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
<span className="plugin-row-name">{locText(p.name, locale, p.id)}</span>
|
||||
{(() => {
|
||||
const title = locText(p.name, locale, p.id)
|
||||
const rawHref = (p.homepage || '').trim()
|
||||
const href = /^https:\/\//i.test(rawHref) ? rawHref : ''
|
||||
return href ? (
|
||||
<a
|
||||
className="plugin-row-name plugin-title-link"
|
||||
href={href}
|
||||
title={href}
|
||||
onClick={(ev) => {
|
||||
ev.preventDefault()
|
||||
void api.OpenURL(href).catch((err) => onError(tr('failGeneric'), err))
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</a>
|
||||
) : (
|
||||
<span className="plugin-row-name">{title}</span>
|
||||
)
|
||||
})()}
|
||||
{stateBadge(p)}
|
||||
</div>
|
||||
{desc && <div className="row-sub plugin-row-desc" title={desc}>{desc}</div>}
|
||||
|
||||
@@ -50,6 +50,8 @@ export const pluginsZh: Record<string, string> = {
|
||||
"pluginLinkDevTitle": "链接本地开发插件目录",
|
||||
"pluginLogEmpty": "暂无日志记录",
|
||||
"pluginLogTitle": "{id} — 日志",
|
||||
"pluginMarketAlphaTag": "Alpha",
|
||||
"pluginMarketCurrentVersion": "当前已安装",
|
||||
"pluginMarketDownloading": "下载中",
|
||||
"pluginMarketEmpty": "当前插件市场暂无可用条目,你仍可导入本地 .zip 插件包或配置自定义市场索引地址",
|
||||
"pluginMarketFeedEnd": "共 {count} 个插件",
|
||||
@@ -65,8 +67,15 @@ export const pluginsZh: Record<string, string> = {
|
||||
"pluginMarketKindTheme": "主题",
|
||||
"pluginMarketKindTool": "工具",
|
||||
"pluginMarketLoading": "正在读取插件市场",
|
||||
"pluginMarketPickVersionInstall": "安装此版本",
|
||||
"pluginMarketPickVersionTitle": "选择安装版本",
|
||||
"pluginMarketRefresh": "刷新索引",
|
||||
"pluginMarketSearchPlaceholder": "搜索市场插件、作者或标签",
|
||||
"pluginMarketSortComposite": "综合排序",
|
||||
"pluginMarketSortDownloads": "最多下载",
|
||||
"pluginMarketSortLabel": "排序方式",
|
||||
"pluginMarketSortRecent": "最新发布",
|
||||
"pluginMarketSortStars": "最多 Star",
|
||||
"pluginMarketStaleBanner": "远程插件市场暂不可达,当前显示本地缓存或内置回退索引",
|
||||
"pluginMarketSyncing": "正在同步插件市场",
|
||||
"pluginMarketUpdateShort": "更新",
|
||||
@@ -173,6 +182,8 @@ export const pluginsEn: Record<string, string> = {
|
||||
"pluginLinkDevTitle": "Link local dev plugin folder",
|
||||
"pluginLogEmpty": "No log entries yet",
|
||||
"pluginLogTitle": "{id} — Log",
|
||||
"pluginMarketAlphaTag": "Alpha",
|
||||
"pluginMarketCurrentVersion": "Installed",
|
||||
"pluginMarketDownloading": "Downloading",
|
||||
"pluginMarketEmpty": "No plugins available in the market index yet. You can still import local .zip packages or configure a custom index URL.",
|
||||
"pluginMarketFeedEnd": "{count} plugins",
|
||||
@@ -188,8 +199,15 @@ export const pluginsEn: Record<string, string> = {
|
||||
"pluginMarketKindTheme": "Themes",
|
||||
"pluginMarketKindTool": "Tools",
|
||||
"pluginMarketLoading": "Loading the plugin market",
|
||||
"pluginMarketPickVersionInstall": "Install version",
|
||||
"pluginMarketPickVersionTitle": "Select version",
|
||||
"pluginMarketRefresh": "Refresh index",
|
||||
"pluginMarketSearchPlaceholder": "Search market plugins, publishers, or tags",
|
||||
"pluginMarketSortComposite": "Recommended",
|
||||
"pluginMarketSortDownloads": "Most downloads",
|
||||
"pluginMarketSortLabel": "Sort by",
|
||||
"pluginMarketSortRecent": "Recently updated",
|
||||
"pluginMarketSortStars": "Most stars",
|
||||
"pluginMarketStaleBanner": "Remote market index is unreachable; showing cached or offline fallback data",
|
||||
"pluginMarketSyncing": "Syncing the plugin market",
|
||||
"pluginMarketUpdateShort": "Update",
|
||||
|
||||
@@ -787,6 +787,8 @@ export type I18nKey =
|
||||
| "pluginLinkDevTitle"
|
||||
| "pluginLogEmpty"
|
||||
| "pluginLogTitle"
|
||||
| "pluginMarketAlphaTag"
|
||||
| "pluginMarketCurrentVersion"
|
||||
| "pluginMarketDownloading"
|
||||
| "pluginMarketEmpty"
|
||||
| "pluginMarketFeedEnd"
|
||||
@@ -802,8 +804,15 @@ export type I18nKey =
|
||||
| "pluginMarketKindTheme"
|
||||
| "pluginMarketKindTool"
|
||||
| "pluginMarketLoading"
|
||||
| "pluginMarketPickVersionInstall"
|
||||
| "pluginMarketPickVersionTitle"
|
||||
| "pluginMarketRefresh"
|
||||
| "pluginMarketSearchPlaceholder"
|
||||
| "pluginMarketSortComposite"
|
||||
| "pluginMarketSortDownloads"
|
||||
| "pluginMarketSortLabel"
|
||||
| "pluginMarketSortRecent"
|
||||
| "pluginMarketSortStars"
|
||||
| "pluginMarketStaleBanner"
|
||||
| "pluginMarketSyncing"
|
||||
| "pluginMarketUpdateShort"
|
||||
|
||||
@@ -1839,6 +1839,9 @@ button.status-issue + .status-metric { margin-left: 6px; }
|
||||
/* Plugin market: cache-first feed of cards in as many columns as fit */
|
||||
.plugin-market { gap: 12px; }
|
||||
.market-toolbar { display: flex; flex-direction: column; gap: 10px; }
|
||||
.market-toolbar-top { display: flex; align-items: center; gap: 8px; }
|
||||
.market-toolbar-top > :first-child { flex: 1; min-width: 0; }
|
||||
.market-sort { flex-shrink: 0; min-width: 124px; }
|
||||
.market-kinds { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
|
||||
|
||||
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
|
||||
@@ -1869,6 +1872,33 @@ button.status-issue + .status-metric { margin-left: 6px; }
|
||||
display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.market-alpha-badge {
|
||||
display: inline-flex; align-items: center; padding: 0 5px; height: 16px;
|
||||
border-radius: 4px; font-size: 10px; font-weight: 600; flex-shrink: 0;
|
||||
color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent);
|
||||
}
|
||||
.market-version-list { display: flex; flex-direction: column; gap: 8px; }
|
||||
.market-version-opt {
|
||||
display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
|
||||
border-radius: var(--r-md); border: 1px solid var(--border);
|
||||
background: var(--surface-1); cursor: pointer;
|
||||
}
|
||||
.market-version-opt.is-selected {
|
||||
border-color: var(--accent);
|
||||
background: color-mix(in srgb, var(--accent) 6%, var(--surface-1));
|
||||
}
|
||||
.market-version-opt input[type='radio'] { margin-top: 3px; flex-shrink: 0; }
|
||||
.market-version-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
|
||||
.market-version-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--fs-13); }
|
||||
.market-version-current {
|
||||
display: inline-flex; align-items: center; padding: 0 5px; height: 16px;
|
||||
border-radius: 4px; font-size: 10px; font-weight: 600;
|
||||
color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
|
||||
}
|
||||
.market-version-meta { margin-left: auto; font-size: var(--fs-12); color: var(--text-3); font-variant-numeric: tabular-nums; }
|
||||
.market-version-notes { margin: 0; font-size: var(--fs-12); color: var(--text-2); line-height: 1.45; }
|
||||
.plugin-title-link { color: inherit; text-decoration: none; }
|
||||
.plugin-title-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
|
||||
.market-card-action { flex-shrink: 0; }
|
||||
.market-card-action .btn.market-btn { height: 28px; padding: 0 12px; font-size: var(--fs-12); }
|
||||
.market-card-desc {
|
||||
|
||||
@@ -169,6 +169,7 @@ export const api = {
|
||||
BrowsePluginMarket: boundGo.BrowsePluginMarket as (query: string, kind: string, includeAlpha: boolean, forceRefresh: boolean) => Promise<MarketBrowseResult>,
|
||||
PeekPluginMarket: boundGo.PeekPluginMarket as (query: string, kind: string) => Promise<MarketBrowseResult>,
|
||||
InstallMarketPlugin: boundGo.InstallMarketPlugin as (id: string, includeAlpha: boolean) => Promise<PluginInfo>,
|
||||
InstallMarketPluginVersion: boundGo.InstallMarketPluginVersion as (id: string, version: string) => Promise<PluginInfo>,
|
||||
GetPluginUIContributions: boundGo.GetPluginUIContributions as () => Promise<PluginUIContributions>,
|
||||
GetActiveTheme: boundGo.GetActiveTheme as () => Promise<ActiveThemePayload>,
|
||||
ListDrivers: boundGo.ListDrivers as () => Promise<DriverSummary[] | null>,
|
||||
|
||||
Vendored
+2
@@ -152,6 +152,8 @@ export function InstallAppUpdate():Promise<void>;
|
||||
|
||||
export function InstallMarketPlugin(arg1:string,arg2:boolean):Promise<plugin.PluginInfo>;
|
||||
|
||||
export function InstallMarketPluginVersion(arg1:string,arg2:string):Promise<plugin.PluginInfo>;
|
||||
|
||||
export function InstallNpcap():Promise<void>;
|
||||
|
||||
export function InstallPluginArchive(arg1:string):Promise<plugin.PluginInfo>;
|
||||
|
||||
@@ -282,6 +282,10 @@ export function InstallMarketPlugin(arg1, arg2) {
|
||||
return window['go']['app']['App']['InstallMarketPlugin'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function InstallMarketPluginVersion(arg1, arg2) {
|
||||
return window['go']['app']['App']['InstallMarketPluginVersion'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function InstallNpcap() {
|
||||
return window['go']['app']['App']['InstallNpcap']();
|
||||
}
|
||||
|
||||
@@ -2071,6 +2071,48 @@ export namespace plugin {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
export class MarketRelease {
|
||||
version: string;
|
||||
channel?: string;
|
||||
download_url: string;
|
||||
sha256: string;
|
||||
size_bytes?: number;
|
||||
published_at?: string;
|
||||
changelog?: LocalizedText;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new MarketRelease(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.version = source["version"];
|
||||
this.channel = source["channel"];
|
||||
this.download_url = source["download_url"];
|
||||
this.sha256 = source["sha256"];
|
||||
this.size_bytes = source["size_bytes"];
|
||||
this.published_at = source["published_at"];
|
||||
this.changelog = this.convertValues(source["changelog"], LocalizedText);
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
export class MarketEntry {
|
||||
id: string;
|
||||
version: string;
|
||||
@@ -2093,6 +2135,7 @@ export namespace plugin {
|
||||
size_bytes?: number;
|
||||
signer?: string;
|
||||
changelog?: LocalizedText;
|
||||
releases?: MarketRelease[];
|
||||
tags?: string[];
|
||||
locales?: string[];
|
||||
stars?: number;
|
||||
@@ -2126,6 +2169,7 @@ export namespace plugin {
|
||||
this.size_bytes = source["size_bytes"];
|
||||
this.signer = source["signer"];
|
||||
this.changelog = this.convertValues(source["changelog"], LocalizedText);
|
||||
this.releases = this.convertValues(source["releases"], MarketRelease);
|
||||
this.tags = source["tags"];
|
||||
this.locales = source["locales"];
|
||||
this.stars = source["stars"];
|
||||
|
||||
@@ -1043,7 +1043,7 @@ func (a *App) PeekPluginMarket(query, kind string) plugin.MarketBrowseResult {
|
||||
if mgr != nil {
|
||||
installed = mgr.Registry().List()
|
||||
}
|
||||
return a.getPluginMarket().Peek(installed, plugin.MarketBrowseOptions{Query: query, Kind: kind})
|
||||
return a.getPluginMarket().Peek(installed, plugin.MarketBrowseOptions{Query: query, Kind: kind, IncludeAlpha: true})
|
||||
}
|
||||
|
||||
// SuggestLanguagePack looks up the market once for a language pack matching
|
||||
@@ -1094,6 +1094,16 @@ type MarketInstallProgress struct {
|
||||
// InstallMarketPlugin downloads, verifies SHA-256, static-scans, and installs
|
||||
// a plugin from the market index.
|
||||
func (a *App) InstallMarketPlugin(pluginID string, includeAlpha bool) (*plugin.PluginInfo, error) {
|
||||
return a.installMarketPlugin(pluginID, "", includeAlpha)
|
||||
}
|
||||
|
||||
// InstallMarketPluginVersion downloads, verifies SHA-256, static-scans, and
|
||||
// installs a specific version of a plugin from the market index.
|
||||
func (a *App) InstallMarketPluginVersion(pluginID, ver string) (*plugin.PluginInfo, error) {
|
||||
return a.installMarketPlugin(pluginID, ver, true)
|
||||
}
|
||||
|
||||
func (a *App) installMarketPlugin(pluginID, ver string, includeAlpha bool) (*plugin.PluginInfo, error) {
|
||||
a.mu.Lock()
|
||||
mgr := a.pluginMgr
|
||||
a.mu.Unlock()
|
||||
@@ -1109,6 +1119,7 @@ func (a *App) InstallMarketPlugin(pluginID string, includeAlpha bool) (*plugin.P
|
||||
a.emit("reims:plugin-install", p)
|
||||
}
|
||||
info, err := a.getPluginMarket().InstallFromMarket(context.Background(), mgr, pluginID, plugin.MarketInstallOptions{
|
||||
Version: ver,
|
||||
IncludeAlpha: includeAlpha,
|
||||
OnPhase: func(ph string) {
|
||||
progMu.Lock()
|
||||
|
||||
@@ -44,6 +44,17 @@ const (
|
||||
maxMarketIndexBytes = 4 << 20 // 4 MiB ceiling for lightweight index.json
|
||||
)
|
||||
|
||||
// MarketRelease describes one selectable release version of a plugin in the market index.
|
||||
type MarketRelease struct {
|
||||
Version string `json:"version"`
|
||||
Channel string `json:"channel,omitempty"` // "stable" | "alpha"
|
||||
DownloadURL string `json:"download_url"`
|
||||
SHA256 string `json:"sha256"`
|
||||
SizeBytes int64 `json:"size_bytes,omitempty"`
|
||||
PublishedAt string `json:"published_at,omitempty"`
|
||||
Changelog LocalizedText `json:"changelog,omitempty"`
|
||||
}
|
||||
|
||||
// MarketEntry describes one plugin published in the remote/embedded market index (§9).
|
||||
type MarketEntry struct {
|
||||
ID string `json:"id"`
|
||||
@@ -66,8 +77,9 @@ type MarketEntry struct {
|
||||
SHA256 string `json:"sha256"`
|
||||
SizeBytes int64 `json:"size_bytes,omitempty"`
|
||||
Signer string `json:"signer,omitempty"`
|
||||
Changelog LocalizedText `json:"changelog,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
Changelog LocalizedText `json:"changelog,omitempty"`
|
||||
Releases []MarketRelease `json:"releases,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
// Locales lists the UI languages a locale pack provides. When absent,
|
||||
// they are inferred from tags and translated names (MarketEntryLocales).
|
||||
Locales []string `json:"locales,omitempty"`
|
||||
@@ -154,6 +166,7 @@ const (
|
||||
|
||||
// MarketInstallOptions controls InstallFromMarket.
|
||||
type MarketInstallOptions struct {
|
||||
Version string
|
||||
IncludeAlpha bool
|
||||
ForceRefresh bool
|
||||
Keyring []SigningKey
|
||||
@@ -520,11 +533,44 @@ func (c *MarketClient) InstallFromMarket(ctx context.Context, mgr *Manager, plug
|
||||
}
|
||||
}
|
||||
|
||||
selected := selectChannelEntries(idx.Plugins, opts.IncludeAlpha)
|
||||
selected := selectChannelEntries(idx.Plugins, opts.IncludeAlpha || strings.TrimSpace(opts.Version) != "")
|
||||
entry, ok := selected[pluginID]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("plugin %q not found in market index", pluginID)
|
||||
}
|
||||
if reqVer := strings.TrimSpace(opts.Version); reqVer != "" && reqVer != entry.Version {
|
||||
matched := false
|
||||
for _, candidate := range idx.Plugins {
|
||||
if candidate.ID != pluginID {
|
||||
continue
|
||||
}
|
||||
if strings.TrimSpace(candidate.Version) == reqVer {
|
||||
entry = candidate
|
||||
matched = true
|
||||
break
|
||||
}
|
||||
for _, rel := range candidate.Releases {
|
||||
if strings.TrimSpace(rel.Version) == reqVer {
|
||||
entry = candidate
|
||||
entry.Version = rel.Version
|
||||
if rel.Channel != "" {
|
||||
entry.Channel = rel.Channel
|
||||
}
|
||||
entry.DownloadURL = rel.DownloadURL
|
||||
entry.SHA256 = rel.SHA256
|
||||
entry.SizeBytes = rel.SizeBytes
|
||||
matched = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if matched {
|
||||
break
|
||||
}
|
||||
}
|
||||
if !matched {
|
||||
return nil, fmt.Errorf("version %q of plugin %q not found in market index", reqVer, pluginID)
|
||||
}
|
||||
}
|
||||
|
||||
// Pre-download compatibility gate (engines + platform).
|
||||
if compat, reason := CheckMarketCompatibility(entry, c.hostVersion); !compat {
|
||||
@@ -711,6 +757,25 @@ func (c *MarketClient) writeDiskCache(idx MarketIndex) error {
|
||||
|
||||
func selectChannelEntries(entries []MarketEntry, includeAlpha bool) map[string]MarketEntry {
|
||||
out := make(map[string]MarketEntry, len(entries))
|
||||
mergedReleases := make(map[string][]MarketRelease, len(entries))
|
||||
seenVer := make(map[string]map[string]bool, len(entries))
|
||||
addRelease := func(id string, rel MarketRelease) {
|
||||
v := strings.TrimSpace(rel.Version)
|
||||
if v == "" {
|
||||
return
|
||||
}
|
||||
if seenVer[id] == nil {
|
||||
seenVer[id] = map[string]bool{}
|
||||
}
|
||||
if seenVer[id][v] {
|
||||
return
|
||||
}
|
||||
seenVer[id][v] = true
|
||||
if strings.TrimSpace(rel.Channel) == "" {
|
||||
rel.Channel = "stable"
|
||||
}
|
||||
mergedReleases[id] = append(mergedReleases[id], rel)
|
||||
}
|
||||
for _, e := range entries {
|
||||
if e.ID == "" || e.Version == "" {
|
||||
continue
|
||||
@@ -722,14 +787,43 @@ func selectChannelEntries(entries []MarketEntry, includeAlpha bool) map[string]M
|
||||
if ch != "stable" && !includeAlpha {
|
||||
continue
|
||||
}
|
||||
e.Channel = ch
|
||||
addRelease(e.ID, MarketRelease{
|
||||
Version: e.Version,
|
||||
Channel: ch,
|
||||
DownloadURL: e.DownloadURL,
|
||||
SHA256: e.SHA256,
|
||||
SizeBytes: e.SizeBytes,
|
||||
PublishedAt: e.UpdatedAt,
|
||||
Changelog: e.Changelog,
|
||||
})
|
||||
for _, r := range e.Releases {
|
||||
rch := strings.ToLower(strings.TrimSpace(r.Channel))
|
||||
if rch == "" {
|
||||
rch = ch
|
||||
}
|
||||
if rch != "stable" && !includeAlpha {
|
||||
continue
|
||||
}
|
||||
r.Channel = rch
|
||||
addRelease(e.ID, r)
|
||||
}
|
||||
if prev, exists := out[e.ID]; exists {
|
||||
if !isVersionNewer(e.Version, prev.Version) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
e.Channel = ch
|
||||
out[e.ID] = e
|
||||
}
|
||||
for id, e := range out {
|
||||
if rels := mergedReleases[id]; len(rels) > 1 {
|
||||
sort.Slice(rels, func(i, j int) bool {
|
||||
return isVersionNewer(rels[i].Version, rels[j].Version)
|
||||
})
|
||||
e.Releases = rels
|
||||
out[id] = e
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,15 @@
|
||||
"pluginMarketInstalling": "Installing",
|
||||
"pluginMarketDownloading": "Downloading",
|
||||
"pluginMarketVersionTip": "v{installed} installed, v{version} available",
|
||||
"pluginMarketSortLabel": "Sort by",
|
||||
"pluginMarketSortComposite": "Recommended",
|
||||
"pluginMarketSortStars": "Most stars",
|
||||
"pluginMarketSortDownloads": "Most downloads",
|
||||
"pluginMarketSortRecent": "Recently updated",
|
||||
"pluginMarketAlphaTag": "Alpha",
|
||||
"pluginMarketPickVersionTitle": "Select version",
|
||||
"pluginMarketPickVersionInstall": "Install version",
|
||||
"pluginMarketCurrentVersion": "Installed",
|
||||
"pluginEnablePromptTitle": "“{name}” is installed",
|
||||
"pluginEnablePromptBody": "Enable it now? Here is what it can do:",
|
||||
"pluginEnablePromptNoRisk": "This plugin declares no extra capabilities.",
|
||||
|
||||
@@ -109,6 +109,15 @@
|
||||
"pluginMarketInstalling": "安装中",
|
||||
"pluginMarketDownloading": "下载中",
|
||||
"pluginMarketVersionTip": "已安装 v{installed},可更新至 v{version}",
|
||||
"pluginMarketSortLabel": "排序方式",
|
||||
"pluginMarketSortComposite": "综合排序",
|
||||
"pluginMarketSortStars": "最多 Star",
|
||||
"pluginMarketSortDownloads": "最多下载",
|
||||
"pluginMarketSortRecent": "最新发布",
|
||||
"pluginMarketAlphaTag": "Alpha",
|
||||
"pluginMarketPickVersionTitle": "选择安装版本",
|
||||
"pluginMarketPickVersionInstall": "安装此版本",
|
||||
"pluginMarketCurrentVersion": "当前已安装",
|
||||
"pluginEnablePromptTitle": "「{name}」已安装",
|
||||
"pluginEnablePromptBody": "要现在启用吗?启用前请了解它会做什么:",
|
||||
"pluginEnablePromptNoRisk": "此插件没有声明额外能力,可以放心启用。",
|
||||
|
||||
Reference in new issue
Block a user