plugins: Discover is one market, with this week's picks on top
The owner asked for one market instead of three (magpie's community, other npm authors and repositories tagged magpie-plugin on GitHub) and approved the mockup: every plugin is the same card, its source said under its name, a strip picks the kind and a menu the source. The top is the week's picks: one a day from the community's most downloaded not installed yet, the most downloaded and the most starred. A search looks through every source at once, most used first. GitHub's slower answer shows a word that it is being asked, and a failed ask a quiet line with another go. The GUI tests that named the three sections now find the cards by source. plugin-manual-float picks Subscriptions so all 40 cards draw (Discover's shelves cap at 6). plugin-github waits for WebKit's wheel scroll to come to rest after reaching a card: it went on after the last wheel, and the scroll that was measured as the click's was its own (logged before, settled, open and closed: it moved before the click, never after). Run at 563b3dd92, the pushed head's tree (only messages changed since), on origin/main40fbec705: - mote: gofmt -l internal/gui empty; go vet ./internal/gui, GOOS=linux go vet -tags nogui, GOOS=windows go vet; go build, GOOS=linux go build -tags nogui, GOOS=windows go build: ok. go test ./internal/gui ./internal/plugin ok (TestCoreScriptBudget in it). - mote GUI, plugin*, old-webkit, market*, builtins, skill-edit, i18n*, gui-*, about*, agent-plugin* files: 1,283 ok, 50 not ok, in plugin-move-unserved (#4410), market-have (#5997), old-webkit's app.css :has() (#5919), gui-ja's {model} (#5943), plugin-signin-no-url (#5938), plugin-signed-out-account (#5998) and plugin-card-update once; each red the same alone at origin/main90f9f01a2, where plugin-card-update was red too. - Rebased onto459405960(c4da9a97d's title-bar drag in app.js and app.css among it): gofmt, go vet ./internal/gui and the Budget and Script tests of internal/gui again: ok. - Before the rebase (on783cd0f84): the whole GUI suite on magpie-desktop (WSL), its 132 red files again beside main: 95 red the same on main (#4600, commented), key-replace red 3 of 3 alone on main too; old-webkit's color-mix and plugin-github were this change's and are fixed; library-hooks, -items, -loading and -subagents red the same alone on main (#5997). Not tried: the real app; screenshots come from the GUI test pages.
This commit is contained in:
@@ -3529,19 +3529,19 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; }
|
||||
which #929 left widening the whole page until its last agent's
|
||||
filter was only reachable by dragging the page sideways, and Plugins'
|
||||
kinds on GitHub, wider than a 420px window in Japanese */
|
||||
.segs.regions, .connect .segs, .pm-ghbar .segs { max-width: 100%; overflow-x: auto; }
|
||||
.segs.regions, .connect .segs, .pm-bar .segs { max-width: 100%; overflow-x: auto; }
|
||||
/* no scrollbar-width here: Chromium (WebView2) then drops every
|
||||
::-webkit-scrollbar rule and draws Windows' classic bar, arrows and all,
|
||||
under the strip; the app's thin thumb instead, slimmer still */
|
||||
:where(body:not(.mac)) :is(.segs.regions, .connect .segs, .pm-ghbar .segs)::-webkit-scrollbar { height: 6px; }
|
||||
:where(body:not(.mac)) :is(.segs.regions, .connect .segs, .pm-ghbar .segs)::-webkit-scrollbar-thumb { border-width: 1px; }
|
||||
:where(body:not(.mac)) :is(.segs.regions, .connect .segs, .pm-bar .segs)::-webkit-scrollbar { height: 6px; }
|
||||
:where(body:not(.mac)) :is(.segs.regions, .connect .segs, .pm-bar .segs)::-webkit-scrollbar-thumb { border-width: 1px; }
|
||||
/* on a Mac they scroll with no bar, as a Mac's own tab strips do: the
|
||||
system's overlay bar showed over the options' lower half for a moment
|
||||
after each scroll, and a click there went to the bar, which paged the
|
||||
strip sideways and picked nothing (#1620) */
|
||||
:where(body.mac) :is(.segs.regions, .connect .segs, .pm-ghbar .segs) { scrollbar-width: none; }
|
||||
:where(body.mac) :is(.segs.regions, .connect .segs, .pm-ghbar .segs)::-webkit-scrollbar { display: none; }
|
||||
.segs.regions .opt, .connect .segs .opt, .pm-ghbar .segs .opt { flex: none; }
|
||||
:where(body.mac) :is(.segs.regions, .connect .segs, .pm-bar .segs) { scrollbar-width: none; }
|
||||
:where(body.mac) :is(.segs.regions, .connect .segs, .pm-bar .segs)::-webkit-scrollbar { display: none; }
|
||||
.segs.regions .opt, .connect .segs .opt, .pm-bar .segs .opt { flex: none; }
|
||||
/* a custom provider's five Base URL APIs wrap to a second row where the
|
||||
editor is too narrow for them (#1346); the thumb follows the row */
|
||||
.segs.base-apis { max-width: 100%; flex-wrap: wrap; }
|
||||
@@ -4377,7 +4377,7 @@ body.panel .modal { padding: 16px 12px; }
|
||||
body.web .segs .thumb { border-radius: 6px; }
|
||||
body.web .segs .opt { height: 28px; padding: 0 11px; font-size: 13px; }
|
||||
body.web .segs .opt::after { content: ""; position: absolute; left: 0; right: 0; top: -8px; bottom: -8px; }
|
||||
body.web :is(.segs.regions, .connect .segs, .pm-ghbar .segs, .ctx-contents-head .segs, .editor.importapps .approw .segs) { overflow-y: hidden; }
|
||||
body.web :is(.segs.regions, .connect .segs, .pm-bar .segs, .ctx-contents-head .segs, .editor.importapps .approw .segs) { overflow-y: hidden; }
|
||||
body.web .text { padding: 8px 10px; }
|
||||
body.web .copy { min-width: 44px; }
|
||||
body.web .fields { width: 100%; grid-template-columns: minmax(0, 1fr) minmax(0, 124px); }
|
||||
|
||||
@@ -34,6 +34,22 @@ const I18N = {
|
||||
"Restored": "已恢复",
|
||||
"Remember": "记住",
|
||||
"Remembered": "已记住",
|
||||
"Today's pick": "今日推荐",
|
||||
"This week": "本周",
|
||||
"Most downloaded": "下载最多",
|
||||
"last week, on npm": "npm 上周",
|
||||
"Most starred": "星标最多",
|
||||
"on GitHub": "GitHub 上",
|
||||
"Downloads last week": "上周下载",
|
||||
"See all": "查看全部",
|
||||
"Sort": "排序",
|
||||
"Origin": "来源",
|
||||
"All sources": "全部来源",
|
||||
"Other authors": "第三方",
|
||||
"Not installed only": "只看未安装",
|
||||
"Most popular": "最热",
|
||||
"Unreviewed": "未审核",
|
||||
"No plugin matches": "没有符合的插件",
|
||||
"At least: {n} answer tokens in {ms} after the first token, the {r} reasoning tokens left out. No first text was recorded, so reasoning after the first token is counted too": "下限:首字后 {ms} 输出 {n} 个正文 token,{r} 个推理 token 不计。没有记录首个正文的时间,首字后的推理时间也算在里面",
|
||||
"At least: {n} output tokens in {ms}, from the request to its last token, the wait for the first one counted too": "下限:从收到请求到最后一个 token,{ms} 输出 {n} 个 token,等首字的时间也算在里面",
|
||||
"Collapse all": "全部收起",
|
||||
@@ -5001,6 +5017,22 @@ const I18N = {
|
||||
"Restored": "已還原",
|
||||
"Remember": "記住",
|
||||
"Remembered": "已記住",
|
||||
"Today's pick": "今日推薦",
|
||||
"This week": "本週",
|
||||
"Most downloaded": "下載最多",
|
||||
"last week, on npm": "npm 上週",
|
||||
"Most starred": "星標最多",
|
||||
"on GitHub": "GitHub 上",
|
||||
"Downloads last week": "上週下載",
|
||||
"See all": "查看全部",
|
||||
"Sort": "排序",
|
||||
"Origin": "來源",
|
||||
"All sources": "全部來源",
|
||||
"Other authors": "第三方",
|
||||
"Not installed only": "只看未安裝",
|
||||
"Most popular": "最熱門",
|
||||
"Unreviewed": "未審核",
|
||||
"No plugin matches": "沒有符合的外掛",
|
||||
"At least: {n} answer tokens in {ms} after the first token, the {r} reasoning tokens left out. No first text was recorded, so reasoning after the first token is counted too": "下限:首字後 {ms} 輸出 {n} 個正文 token,{r} 個推理 token 不計。沒有記錄首個正文的時間,首字後的推理時間也算在裡面",
|
||||
"At least: {n} output tokens in {ms}, from the request to its last token, the wait for the first one counted too": "下限:從收到請求到最後一個 token,{ms} 輸出 {n} 個 token,等首字的時間也算在裡面",
|
||||
"Collapse all": "全部收起",
|
||||
@@ -9953,6 +9985,22 @@ const I18N = {
|
||||
"Restored": "元に戻しました",
|
||||
"Remember": "覚える",
|
||||
"Remembered": "覚えました",
|
||||
"Today's pick": "今日のおすすめ",
|
||||
"This week": "今週",
|
||||
"Most downloaded": "ダウンロード数上位",
|
||||
"last week, on npm": "npm・先週",
|
||||
"Most starred": "スター数上位",
|
||||
"on GitHub": "GitHub",
|
||||
"Downloads last week": "先週のダウンロード",
|
||||
"See all": "すべて表示",
|
||||
"Sort": "並べ替え",
|
||||
"Origin": "提供元",
|
||||
"All sources": "すべての提供元",
|
||||
"Other authors": "他の作者",
|
||||
"Not installed only": "未インストールのみ",
|
||||
"Most popular": "人気順",
|
||||
"Unreviewed": "未審査",
|
||||
"No plugin matches": "該当するプラグインはありません",
|
||||
"At least: {n} answer tokens in {ms} after the first token, the {r} reasoning tokens left out. No first text was recorded, so reasoning after the first token is counted too": "下限:最初のトークン後 {ms} で回答 {n} トークン(推論 {r} トークンは含めず)。最初の本文の時刻が記録されていないため、最初のトークン後の推論の時間も含まれます",
|
||||
"At least: {n} output tokens in {ms}, from the request to its last token, the wait for the first one counted too": "下限:リクエストを受けてから最後のトークンまで {ms} で {n} トークンを出力。最初のトークンを待つ時間も含まれます",
|
||||
"Collapse all": "すべて折りたたむ",
|
||||
@@ -14907,6 +14955,22 @@ const I18N = {
|
||||
"Restored": "Wiederhergestellt",
|
||||
"Remember": "Merken",
|
||||
"Remembered": "Gemerkt",
|
||||
"Today's pick": "Tipp des Tages",
|
||||
"This week": "Diese Woche",
|
||||
"Most downloaded": "Am meisten geladen",
|
||||
"last week, on npm": "letzte Woche, auf npm",
|
||||
"Most starred": "Die meisten Sterne",
|
||||
"on GitHub": "auf GitHub",
|
||||
"Downloads last week": "Downloads letzte Woche",
|
||||
"See all": "Alle zeigen",
|
||||
"Sort": "Sortierung",
|
||||
"Origin": "Herkunft",
|
||||
"All sources": "Alle Herkünfte",
|
||||
"Other authors": "Andere Autoren",
|
||||
"Not installed only": "Nur nicht installierte",
|
||||
"Most popular": "Beliebteste",
|
||||
"Unreviewed": "Ungeprüft",
|
||||
"No plugin matches": "Kein Plugin passt",
|
||||
"At least: {n} answer tokens in {ms} after the first token, the {r} reasoning tokens left out. No first text was recorded, so reasoning after the first token is counted too": "Mindestens: {n} Antwort-Token in {ms} nach dem ersten Token, ohne die {r} Reasoning-Token. Kein erster Text aufgezeichnet, also zählt Reasoning nach dem ersten Token mit",
|
||||
"At least: {n} output tokens in {ms}, from the request to its last token, the wait for the first one counted too": "Mindestens: {n} Ausgabe-Token in {ms}, von der Anfrage bis zu ihrem letzten Token, das Warten auf das erste mitgezählt",
|
||||
"Collapse all": "Alle einklappen",
|
||||
|
||||
@@ -19,23 +19,72 @@
|
||||
.pm-find input::-webkit-search-cancel-button { cursor: default; }
|
||||
.pm-body { gap: 18px; padding: 10px 0 18px; }
|
||||
|
||||
/* the opening: what plugins are, and a few of the subscriptions they bring */
|
||||
.pm-intro {
|
||||
position: relative; overflow: hidden; display: flex; align-items: center; gap: 18px;
|
||||
padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line);
|
||||
background:
|
||||
radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 60%),
|
||||
var(--card);
|
||||
/* the week's picks: the day's plugin, the most downloaded, the most starred */
|
||||
.pm-recs { gap: 10px; }
|
||||
.pm-rectitle { display: flex; align-items: baseline; gap: 8px; padding: 0 2px; }
|
||||
.pm-rectitle h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
|
||||
.pm-rectitle span { font-size: 11.5px; color: var(--muted); }
|
||||
.pm-rec { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; align-items: stretch; }
|
||||
.pm-rec.two { grid-template-columns: 1.3fr 1fr; }
|
||||
.pm-hero, .pm-rank { min-width: 0; border-radius: 14px; border: 1px solid var(--line); background: var(--card); }
|
||||
.pm-hero { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; cursor: pointer; transition: border-color .14s ease, box-shadow .14s ease; }
|
||||
.pm-hero:hover { border-color: color-mix(in srgb, var(--fg) 16%, var(--line)); box-shadow: 0 4px 14px rgba(20, 22, 30, .07); }
|
||||
.pm-hero:focus-visible, .pm-rrow:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent); }
|
||||
.pm-eyebrow { font-size: 11px; font-weight: 600; color: var(--accent); }
|
||||
.pm-htop { display: flex; align-items: center; gap: 12px; min-width: 0; }
|
||||
.pm-logo.hero { width: 52px; height: 52px; border-radius: 14px; }
|
||||
.pm-logo.hero .ic { width: 30px; height: 30px; }
|
||||
.pm-htop .pm-name b { font-size: 15px; }
|
||||
.pm-hsum { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--fg-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
||||
.pm-stats { display: flex; gap: 22px; margin-top: auto; padding-top: 2px; }
|
||||
.pm-stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
|
||||
.pm-stat b { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
||||
.pm-stat span { font-size: 11px; color: var(--muted); white-space: nowrap; }
|
||||
.pm-hact { display: flex; align-items: center; gap: 8px; }
|
||||
.pm-act.ghost { background: none; box-shadow: inset 0 0 0 1px var(--line); color: var(--fg-2); }
|
||||
.pm-act.ghost:hover { background: var(--pill); color: var(--fg); }
|
||||
.pm-rank { display: flex; flex-direction: column; padding: 12px 8px 8px; }
|
||||
.pm-rhead { display: flex; align-items: baseline; gap: 7px; padding: 0 8px 6px; }
|
||||
.pm-rhead b { font-size: 12.5px; font-weight: 650; }
|
||||
.pm-rhead span { font-size: 11px; color: var(--muted); }
|
||||
.pm-rrow { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 9px; cursor: pointer; transition: background .14s ease; }
|
||||
.pm-rrow:hover { background: var(--pill); }
|
||||
.pm-rnum { flex: none; width: 14px; text-align: center; font-size: 11.5px; font-weight: 600; color: var(--faint); font-variant-numeric: tabular-nums; }
|
||||
.pm-rrow .pm-logo { width: 28px; height: 28px; border-radius: 8px; }
|
||||
.pm-rrow .pm-logo .ic { width: 16px; height: 16px; }
|
||||
.pm-rwho { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
|
||||
.pm-rwho b { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.pm-rwho span { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.pm-rec.ghost .pm-hero, .pm-rec.ghost .pm-rank { cursor: default; gap: 10px; padding: 16px; min-height: 196px; }
|
||||
.pm-rec.ghost .sk { height: 10px; border-radius: 5px; background: var(--pill); animation: pm-pulse 1.4s linear infinite; }
|
||||
.pm-rec.ghost .sk:first-child { width: 40%; }
|
||||
.pm-rec.ghost .sk:nth-child(2n) { width: 75%; }
|
||||
|
||||
/* the strip of kinds, then where from and in which order */
|
||||
.pm-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
||||
.pm-bar .segs { flex: none; max-width: 100%; }
|
||||
.pm-bar .segs .opt em { margin-left: 5px; font-style: normal; font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
|
||||
.pm-bar .segs .opt.on em { color: var(--muted); }
|
||||
.pm-bar .grow { flex: 1; }
|
||||
.pm-pop { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border: 0; border-radius: 7px; background: none; box-shadow: inset 0 0 0 1px var(--line); font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; transition: background .14s ease, color .14s ease; }
|
||||
.pm-pop b { font-weight: 500; color: var(--fg); }
|
||||
.pm-pop:hover { background: var(--pill); }
|
||||
.pm-pop:active { transform: scale(.97); }
|
||||
.pm-sechead .pm-n { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
|
||||
.pm-sechead .grow { flex: 1; }
|
||||
.pm-more { display: inline-flex; align-items: center; gap: 2px; padding: 1px 4px; border: 0; border-radius: 5px; background: none; font: inherit; font-size: 11.5px; color: var(--accent); cursor: pointer; }
|
||||
.pm-more:hover { background: var(--accent-soft); }
|
||||
.pm-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px 14px; flex-wrap: wrap; padding: 0 2px; }
|
||||
.pm-foot .pm-trust { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 11.5px; color: var(--muted); }
|
||||
.pm-foot .pm-trust svg { flex: none; color: var(--green); }
|
||||
.pm-foot .pm-write { font-size: 12px; }
|
||||
@media (max-width: 1180px) {
|
||||
.pm-rec, .pm-rec.two { grid-template-columns: 1fr 1fr; }
|
||||
.pm-rec .pm-hero { grid-column: 1 / -1; }
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.pm-rec, .pm-rec.two { grid-template-columns: 1fr; }
|
||||
}
|
||||
.pm-introtext { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
|
||||
.pm-intro h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; text-wrap: balance; }
|
||||
.pm-intro p { margin: 0; font-size: 12px; line-height: 1.55; color: var(--fg-2); max-width: 560px; }
|
||||
.pm-intro .pm-trust { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 11.5px; color: var(--muted); }
|
||||
.pm-intro .pm-trust svg { flex: none; color: var(--green); }
|
||||
.pm-art { flex: none; display: grid; grid-template-columns: repeat(3, 34px); gap: 8px; transform: rotate(-6deg); margin-right: 6px; }
|
||||
.pm-art .pm-logo { width: 34px; height: 34px; border-radius: 10px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 0 0 1px var(--line-2); background: var(--card); }
|
||||
.pm-art .pm-logo:nth-child(4) { grid-column: 2; }
|
||||
.pm-art .pm-logo:nth-child(odd) { transform: translateY(4px); }
|
||||
|
||||
/* sections of cards */
|
||||
.pm-sec { display: flex; flex-direction: column; gap: 9px; }
|
||||
@@ -43,14 +92,6 @@
|
||||
.pm-sechead h3 { margin: 0; font-size: 12.5px; font-weight: 650; }
|
||||
.pm-sechead span { font-size: 11.5px; color: var(--muted); }
|
||||
.pm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(262px, 1fr)); gap: 10px; }
|
||||
/* the GitHub section's kinds, what's installed and its own field, on one
|
||||
line while they fit; the field goes under them, the whole width, when
|
||||
they don't */
|
||||
.pm-ghbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
||||
.pm-ghbar .segs { flex: none; max-width: 100%; }
|
||||
/* it takes a share of the room the strips leave, up to what its
|
||||
placeholder needs, so "Filter by name, author or description" isn't cut */
|
||||
.pm-ghfind { flex: 4 0 auto; width: min(240px, 100%); max-width: min(320px, 100%); }
|
||||
.pm-ghnone { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 12px; border-radius: 12px; border: 1px dashed var(--line); font-size: 12px; color: var(--muted); text-align: center; }
|
||||
/* what GitHub couldn't give, over the cards it could: a quiet line, its
|
||||
reason wrapping anywhere (a URL in it is one long word) */
|
||||
@@ -173,7 +214,7 @@ button.pm-chip:disabled { cursor: default; opacity: .6; }
|
||||
@keyframes pm-pulse { 50% { opacity: .5; } }
|
||||
@keyframes pm-sheen { from { background-position: 100% 0; } to { background-position: 0 0; } }
|
||||
/* the GitHub section looking: three dots breathing in turn, and the word */
|
||||
.pm-sechead .pm-ghlook { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; font-size: 11px; color: var(--faint); animation: pm-fade .26s var(--ease) both .08s; }
|
||||
.pm-ghlook { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; font-size: 11px; color: var(--faint); animation: pm-fade .26s var(--ease) both .08s; }
|
||||
.pm-ghlook .dots { display: inline-flex; gap: 3px; }
|
||||
.pm-ghlook .dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); opacity: .25; animation: pm-breathe 1.2s ease-in-out infinite; }
|
||||
.pm-ghlook .dots i:nth-child(2) { animation-delay: .16s; }
|
||||
@@ -308,11 +349,13 @@ body.window .pm-manual { --bleed-l: 16px; }
|
||||
@media (max-width: 560px) {
|
||||
.pm-head { flex-wrap: wrap; }
|
||||
.pm-find { width: 100%; order: 3; }
|
||||
.pm-ghfind { max-width: 100%; }
|
||||
.pm-art { display: none; }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.pm-card { transition: none; }
|
||||
.pm-card.ghost .sk, .pm-ghlook, .pm-ghlook .dots i, .pm-arrive .pm-card { animation: none; }
|
||||
.pm-card.ghost .sk, .pm-rec.ghost .sk, .pm-ghlook, .pm-ghlook .dots i, .pm-arrive .pm-card { animation: none; }
|
||||
.pm-ghlook .dots i { opacity: .5; }
|
||||
}
|
||||
/* Discover's own menus use the app's: plugins' .pm-name and .pm-note don't reach them */
|
||||
.proto-menu.pm-srcmenu .pm-name, .proto-menu.pm-sortmenu .pm-name { display: block; }
|
||||
.proto-menu.pm-srcmenu .pm-note:empty, .proto-menu.pm-sortmenu .pm-note:empty { display: none; }
|
||||
.proto-menu.pm-srcmenu .pm-item:last-child { margin-top: 4px; box-shadow: 0 -1px 0 var(--line-2); }
|
||||
|
||||
+240
-175
@@ -195,14 +195,16 @@
|
||||
// what npm says of the plugins suggested and those installed: drawn
|
||||
// when it comes, never waited on
|
||||
let npmTries = 0;
|
||||
let npmAnswered = false; // npm was asked once: no downloads then means none to rank by
|
||||
async function askNPM(only) {
|
||||
const names = [...new Set([...(listings || []).map((l) => l.package), ...(mine?.plugins || []).filter((e) => onNPM(e.spec)).map((e) => name(e.spec))])]
|
||||
.filter((n) => !only || !npm[n]);
|
||||
if (!names.length) return;
|
||||
if (!names.length) { if (!npmAnswered) { npmAnswered = true; drawBody(); } return; }
|
||||
try {
|
||||
const r = await api("plugins/npm?names=" + encodeURIComponent(names.join(",")));
|
||||
Object.assign(npm, r.npm || {});
|
||||
} catch {}
|
||||
npmAnswered = true;
|
||||
merge();
|
||||
// one npm said nothing of: unknown (Install), asked again
|
||||
let u = 0;
|
||||
@@ -260,6 +262,10 @@
|
||||
tab = "discover";
|
||||
clearTimeout(searchTimer);
|
||||
hits = null;
|
||||
// Agents alone, whoever wrote them
|
||||
kindPick = "ag";
|
||||
srcPick = "";
|
||||
onlyNew = false;
|
||||
agentsFor = ev;
|
||||
draw();
|
||||
};
|
||||
@@ -553,14 +559,7 @@
|
||||
const nm = el("div", "pm-name");
|
||||
nm.append(el("b", "", l.name));
|
||||
who.append(nm);
|
||||
const by = el("div", "pm-by");
|
||||
if (l.community) {
|
||||
const v = el("span", "pm-verified");
|
||||
v.append(glyph(SHIELD, 11, 1.5), el("span", "", t("magpie community")));
|
||||
v.title = t("Written for magpie by its community, in github.com/magpie-community/plugins");
|
||||
by.append(v);
|
||||
} else by.append(el("span", "", l.npm?.publisher || l.package));
|
||||
who.append(by);
|
||||
who.append(byline(l));
|
||||
if (l.github) c.classList.add("gh");
|
||||
const go = actionFor(l.package, l.name, l);
|
||||
top.append(logo(l.icon || l.npm?.icon, false, kindOf(l)), who, go);
|
||||
@@ -637,44 +636,184 @@
|
||||
return box;
|
||||
}
|
||||
|
||||
// GitHub's section: its own kinds, an installed strip and a field, each
|
||||
// counting what the others leave; only the section redraws (#1055)
|
||||
let ghKind = ""; // "" (all) | "pv" | "mw" | "ag"
|
||||
let ghHave = ""; // "" (all) | "have" | "none"
|
||||
let ghQuery = "";
|
||||
let ghList = []; // what the page's search left of the repositories
|
||||
const ghSec = el("section", "pm-sec pm-ghsec");
|
||||
const ghHead = el("div", "pm-sechead");
|
||||
const ghBar = el("div", "pm-ghbar");
|
||||
const ghGrid = el("div", "pm-grid");
|
||||
const ghFind = el("label", "pm-find pm-ghfind");
|
||||
const ghQ = el("input");
|
||||
ghQ.type = "search";
|
||||
ghQ.spellcheck = false;
|
||||
ghQ.autocomplete = "off";
|
||||
ghQ.oninput = () => { ghQuery = ghQ.value; drawGh(); };
|
||||
ghQ.onkeydown = (ev) => { ev.stopPropagation(); if (ev.key === "Escape" && ghQ.value) { ghQ.value = ""; ghQ.oninput(); } };
|
||||
ghFind.append(glyph(SEARCH, 13, 1.6), ghQ);
|
||||
const ghMatch = (l) => {
|
||||
const f = ghQuery.trim().toLowerCase();
|
||||
return !f || [l.name, l.github.repo, l.github.owner, l.package, summary(l)].join(" ").toLowerCase().includes(f);
|
||||
// Discover is one market (#owner, 11-09): every plugin, whoever wrote
|
||||
// it (magpie's community, another author on npm, a repository its
|
||||
// author tagged on GitHub), is the same card, its source said under its
|
||||
// name. A strip picks the kind, a menu the source; the top is the
|
||||
// week's picks: one a day, the most downloaded, the most starred.
|
||||
const ORDER = ["pv", "mw", "ag", "tl", "pg"];
|
||||
const SHELVES = { pv: "Subscriptions", mw: "Gateway middleware", ag: "Agents", tl: "Tools for agents", pg: "Pages" };
|
||||
const SHORT = { pv: "Subscriptions", mw: "Middleware", ag: "Agents", tl: "Tools", pg: "Pages" };
|
||||
const SHELF_N = { pv: 6 };
|
||||
const SOURCES = [["", "All sources"], ["ours", "magpie community"], ["third", "Other authors"], ["gh", "Unofficial, on GitHub"]];
|
||||
const SORTS = [["hot", "Most popular"], ["name", "Name"]];
|
||||
let kindPick = "", srcPick = "", onlyNew = false, sortPick = "hot";
|
||||
const srcOf = (l) => l.github ? "gh" : l.community ? "ours" : "third";
|
||||
const hotOf = (l) => l.npm?.weekly || 0;
|
||||
const nameOrder = (a, b) => a.name.localeCompare(b.name, intlLang());
|
||||
const byHot = (a, b) => hotOf(b) - hotOf(a) || (b.github?.stars || 0) - (a.github?.stars || 0) || nameOrder(a, b);
|
||||
const ranked = (list, how = sortPick) => [...list].sort(how === "name" ? nameOrder : byHot);
|
||||
// the day in the reader's own calendar, which the daily pick turns on
|
||||
const today = () => { const d = new Date(); return Math.floor((d.getTime() - d.getTimezoneOffset() * 6e4) / 864e5); };
|
||||
|
||||
// every plugin the market can show: the list's, and the repositories
|
||||
// tagged on GitHub it doesn't list already
|
||||
function everything(match) {
|
||||
const listed = new Set((listings || []).map((l) => l.package));
|
||||
const gh = (tagged || []).filter((l) => !(l.github.package && listed.has(l.github.package)));
|
||||
return [...(listings || []), ...gh].filter(match);
|
||||
}
|
||||
|
||||
// who it is from, under its name: magpie's community, its author, or
|
||||
// its author and that nobody reviewed it
|
||||
function byline(l) {
|
||||
const by = el("div", "pm-by");
|
||||
if (l.community) {
|
||||
const v = el("span", "pm-verified");
|
||||
v.append(glyph(SHIELD, 11, 1.5), el("span", "", t("magpie community")));
|
||||
v.title = t("Written for magpie by its community, in github.com/magpie-community/plugins");
|
||||
by.append(v);
|
||||
return by;
|
||||
}
|
||||
by.append(el("span", "", l.npm?.publisher || l.github?.owner || l.package));
|
||||
if (l.github) {
|
||||
const u = el("span", "pm-chip warn");
|
||||
u.append(el("span", "dot"), el("span", "", t("Unreviewed")));
|
||||
u.title = t("repositories their authors tagged {topic} — nobody has reviewed them; read the code before you install one", { topic });
|
||||
by.append(u);
|
||||
}
|
||||
return by;
|
||||
}
|
||||
|
||||
const opens = (box, l) => {
|
||||
box.tabIndex = 0;
|
||||
box.setAttribute("role", "button");
|
||||
box.dataset.pkg = l.package;
|
||||
box.onclick = () => detail(l);
|
||||
box.onkeydown = (ev) => { if (ev.target === box && (ev.key === "Enter" || ev.key === " ")) { ev.preventDefault(); detail(l); } };
|
||||
};
|
||||
const ghTitle = () => [el("h3", "", t("Unofficial, on GitHub")), el("span", "", t("repositories their authors tagged {topic} — nobody has reviewed them; read the code before you install one", { topic }))];
|
||||
// until GitHub answers, its section stands in place, saying it is looking
|
||||
let ghArrive = false;
|
||||
function ghWaiting() {
|
||||
|
||||
// the week's picks: null till npm has said how often each is downloaded
|
||||
function picks(all) {
|
||||
const listed = ranked(all.filter((l) => !l.github && hotOf(l) > 0), "hot");
|
||||
if (!listed.length) return null;
|
||||
// the day's: one of the community's most downloaded not installed
|
||||
// yet, a different one each day
|
||||
let pool = listed.filter((l) => l.community && !entryOf(l.package)).slice(0, 14);
|
||||
if (!pool.length) pool = listed.slice(0, 14);
|
||||
const day = pool[today() % pool.length];
|
||||
const starred = all.filter((l) => l.github?.stars > 0).sort((a, b) => b.github.stars - a.github.stars || nameOrder(a, b)).slice(0, 5);
|
||||
return { day, top: listed.slice(0, 5), starred };
|
||||
}
|
||||
function hero(l) {
|
||||
const box = el("article", "pm-hero");
|
||||
opens(box, l);
|
||||
const top = el("div", "pm-htop");
|
||||
const who = el("div", "pm-who");
|
||||
const nm = el("div", "pm-name");
|
||||
nm.append(el("b", "", l.name));
|
||||
who.append(nm, byline(l));
|
||||
const lg = logo(l.icon || l.npm?.icon, true, kindOf(l));
|
||||
lg.classList.add("hero");
|
||||
top.append(lg, who);
|
||||
const stats = el("div", "pm-stats");
|
||||
const stat = (v, k) => { const s = el("div", "pm-stat"); s.append(el("b", "", v), el("span", "", k)); stats.append(s); };
|
||||
stat(count(hotOf(l)), t("Downloads last week"));
|
||||
stat(t(SHORT[kindOf(l)]), t("Kind"));
|
||||
if (l.npm?.version) stat("v" + l.npm.version, t("Version"));
|
||||
const acts = el("div", "pm-hact");
|
||||
const more = el("button", "pm-act ghost", t("Details"));
|
||||
more.type = "button";
|
||||
more.onclick = (ev) => { ev.stopPropagation(); detail(l); };
|
||||
acts.append(actionFor(l.package, l.name, l), more);
|
||||
box.append(el("div", "pm-eyebrow", t("Today's pick")), top, el("p", "pm-hsum", summary(l)), stats, acts);
|
||||
return box;
|
||||
}
|
||||
function rankList(title, note, list, line) {
|
||||
const box = el("div", "pm-rank");
|
||||
const h = el("div", "pm-rhead");
|
||||
h.append(el("b", "", title), el("span", "", note));
|
||||
box.append(h);
|
||||
list.forEach((l, i) => {
|
||||
const row = el("div", "pm-rrow");
|
||||
opens(row, l);
|
||||
const who = el("div", "pm-rwho");
|
||||
who.append(el("b", "", l.name), el("span", "", line(l)));
|
||||
row.append(el("span", "pm-rnum", String(i + 1)), logo(l.icon || l.npm?.icon, false, kindOf(l)), who, actionFor(l.package, l.name, l));
|
||||
box.append(row);
|
||||
});
|
||||
return box;
|
||||
}
|
||||
function recSection(all) {
|
||||
const p = picks(all);
|
||||
if (!p && npmAnswered) return null;
|
||||
const sec = el("section", "pm-sec pm-recs");
|
||||
const h = el("div", "pm-rectitle");
|
||||
h.append(el("h2", "", t("This week")), el("span", "", new Date().toLocaleDateString(intlLang(), { month: "long", day: "numeric" })));
|
||||
const grid = el("div", "pm-rec");
|
||||
if (!p) {
|
||||
grid.classList.add("ghost");
|
||||
grid.setAttribute("aria-hidden", "true");
|
||||
for (const c of ["pm-hero", "pm-rank", "pm-rank"]) {
|
||||
const g = el("div", c + " ghost");
|
||||
for (let i = 0; i < 5; i++) g.append(el("div", "sk"));
|
||||
grid.append(g);
|
||||
}
|
||||
} else {
|
||||
grid.append(hero(p.day), rankList(t("Most downloaded"), t("last week, on npm"), p.top, (l) => t(SHORT[kindOf(l)]) + " · ↓" + t("{n}/week", { n: count(hotOf(l)) })));
|
||||
if (p.starred.length) grid.append(rankList(t("Most starred"), t("on GitHub"), p.starred, (l) => "★ " + count(l.github.stars) + " · " + l.github.owner));
|
||||
else grid.classList.add("two");
|
||||
}
|
||||
sec.append(h, grid);
|
||||
return sec;
|
||||
}
|
||||
|
||||
// a pop-up button: its name, and what is picked now
|
||||
function popButton(name, now, open) {
|
||||
const b = el("button", "pm-pop");
|
||||
b.type = "button";
|
||||
b.setAttribute("aria-haspopup", "menu");
|
||||
b.setAttribute("aria-expanded", "false");
|
||||
b.append(el("span", "", name), el("b", "", now), glyph("M4.5 6.5 8 10l3.5-3.5", 10, 1.8));
|
||||
b.onclick = (ev) => { ev.stopPropagation(); open(b); };
|
||||
return b;
|
||||
}
|
||||
function browseBar(all, base) {
|
||||
const bar = el("div", "pm-bar");
|
||||
const kinds = ORDER.filter((k) => all.some((l) => kindOf(l) === k));
|
||||
if (kindPick && !kinds.includes(kindPick)) kindPick = "";
|
||||
const n = (k) => base.filter((l) => !k || kindOf(l) === k).length;
|
||||
const ids = ["", ...kinds];
|
||||
const pick = segs(ids.map((k) => [k, k ? t(SHORT[k]) : t("All")]), kindPick, (k) => { kindPick = k; drawBody(); });
|
||||
pick.classList.add("pm-kinds");
|
||||
pick.setAttribute("role", "group");
|
||||
pick.setAttribute("aria-label", t("Kind of plugin"));
|
||||
[...pick.querySelectorAll(".opt")].forEach((b, i) => b.append(el("em", "", String(n(ids[i])))));
|
||||
bar.append(pick, el("span", "grow"));
|
||||
if (ghLooking()) bar.append(ghLook());
|
||||
const srcName = (srcPick ? t(SOURCES.find(([v]) => v === srcPick)[1]) : t("All")) + (onlyNew ? " · " + t("Not installed") : "");
|
||||
bar.append(popButton(t("Origin"), srcName, (b) => openProtoMenu(b,
|
||||
[...SOURCES.map(([v, name]) => ({ v, name, note: "" })), { v: "\x01", name: "Not installed only", note: "", ticked: onlyNew }],
|
||||
srcPick, (v) => { if (v === "\x01") onlyNew = !onlyNew; else srcPick = v; drawBody(); }, "Origin", "pm-srcmenu", "right")));
|
||||
bar.append(popButton(t("Sort"), t(SORTS.find(([v]) => v === sortPick)[1]), (b) => openProtoMenu(b,
|
||||
SORTS.map(([v, name]) => ({ v, name, note: "" })), sortPick, (v) => { sortPick = v; drawBody(); }, "Sort", "pm-sortmenu", "right")));
|
||||
return bar;
|
||||
}
|
||||
|
||||
// GitHub answers seconds after the rest on a slow line: till it does,
|
||||
// a word that it is being asked, so its plugins aren't read as none
|
||||
let ghAsking = false;
|
||||
const ghLooking = () => !tagged || ghAsking;
|
||||
function ghLook() {
|
||||
const look = el("span", "pm-ghlook");
|
||||
look.setAttribute("role", "status");
|
||||
const dots = el("span", "dots");
|
||||
dots.setAttribute("aria-hidden", "true");
|
||||
dots.append(el("i"), el("i"), el("i"));
|
||||
look.append(dots, el("span", "", t("Looking on GitHub")));
|
||||
ghHead.replaceChildren(...ghTitle(), look);
|
||||
ghSec.setAttribute("aria-busy", "true");
|
||||
ghArrive = true;
|
||||
replaceKeeping(ghSec, [ghHead, skeleton(3)]);
|
||||
return ghSec;
|
||||
return look;
|
||||
}
|
||||
|
||||
// why the list isn't GitHub's whole answer; kept: cards are shown. A
|
||||
// known kind in the reader's words, the raw error as its hover
|
||||
const ghWhy = (kept) => {
|
||||
@@ -685,111 +824,62 @@
|
||||
if (error !== taggedErr) s.title = taggedErr;
|
||||
return s;
|
||||
};
|
||||
// and one GitHub couldn't be asked of says so, with another go
|
||||
function ghFailed() {
|
||||
ghHead.replaceChildren(...ghTitle());
|
||||
ghSec.removeAttribute("aria-busy");
|
||||
const box = el("div", "pm-ghnone");
|
||||
const again = el("button", "text", t("Try again"));
|
||||
again.type = "button";
|
||||
again.onclick = () => {
|
||||
tagged = null;
|
||||
taggedErr = "";
|
||||
taggedMissing = 0;
|
||||
drawBody();
|
||||
loadTagged(true).then(drawBody);
|
||||
};
|
||||
box.append(ghWhy(false), again);
|
||||
replaceKeeping(ghSec, [ghHead, box]);
|
||||
return ghSec;
|
||||
}
|
||||
// the cards GitHub could give, and a line saying what it couldn't, with
|
||||
// another go that keeps them until it answers
|
||||
// what GitHub couldn't give, a quiet line under the strip, with another
|
||||
// go that keeps what it gave until it answers
|
||||
function ghNote() {
|
||||
const note = el("div", "pm-ghwarn");
|
||||
note.setAttribute("role", "status");
|
||||
const again = el("button", "text", t("Try again"));
|
||||
again.type = "button";
|
||||
again.onclick = () => {
|
||||
again.disabled = true;
|
||||
loadTagged(true).then(drawBody);
|
||||
ghAsking = true;
|
||||
drawBody();
|
||||
loadTagged(true).then(() => { ghAsking = false; drawBody(); });
|
||||
};
|
||||
note.append(ghWhy(true), again);
|
||||
note.append(ghWhy(!!tagged?.length), again);
|
||||
return note;
|
||||
}
|
||||
function ghSection(list) {
|
||||
ghList = list;
|
||||
ghHead.replaceChildren(...ghTitle());
|
||||
ghSec.removeAttribute("aria-busy");
|
||||
drawGh();
|
||||
// the first cards after the wait come in, one after the other; the
|
||||
// grid drawn again for a pick doesn't
|
||||
if (ghArrive) {
|
||||
ghArrive = false;
|
||||
ghSec.classList.add("pm-arrive");
|
||||
[...ghGrid.children].forEach((c, i) => c.style.setProperty("--i", Math.min(i, 9)));
|
||||
setTimeout(() => ghSec.classList.remove("pm-arrive"), 900);
|
||||
|
||||
function shelf(k, list, all) {
|
||||
const box = el("section", "pm-sec" + (k === "ag" ? " pm-agents" : ""));
|
||||
box.dataset.kind = k;
|
||||
const h = el("div", "pm-sechead");
|
||||
h.append(el("h3", "", t(SHELVES[k])), el("span", "pm-n", String(list.length)));
|
||||
const limit = all ? list.length : SHELF_N[k] || 3;
|
||||
if (list.length > limit) {
|
||||
const more = el("button", "pm-more");
|
||||
more.type = "button";
|
||||
more.append(el("span", "", t("See all")), glyph("M6 3.5 10.5 8 6 12.5", 11, 1.7));
|
||||
more.onclick = () => { kindPick = k; drawBody(); page.scrollTo({ top: 0 }); };
|
||||
h.append(el("span", "grow"), more);
|
||||
}
|
||||
return ghSec;
|
||||
const g = el("div", "pm-grid");
|
||||
for (const l of list.slice(0, limit)) g.append(card(l));
|
||||
box.append(h, g);
|
||||
return box;
|
||||
}
|
||||
function drawGh() {
|
||||
const head = taggedErr ? [ghHead, ghNote()] : [ghHead];
|
||||
if ((tagged || []).length <= 6) {
|
||||
ghGrid.replaceChildren(...ghList.map(card));
|
||||
replaceKeeping(ghSec, [...head, ghGrid]);
|
||||
return;
|
||||
function market(all) {
|
||||
const base = all.filter((l) => (!srcPick || srcOf(l) === srcPick) && (!onlyNew || !entryOf(l.package)));
|
||||
const out = [browseBar(all, base)];
|
||||
if (taggedErr && !ghAsking) out.push(ghNote());
|
||||
const kinds = kindPick ? [kindPick] : ORDER;
|
||||
let shown = 0;
|
||||
for (const k of kinds) {
|
||||
const list = ranked(base.filter((l) => kindOf(l) === k));
|
||||
if (!list.length) continue;
|
||||
out.push(shelf(k, list, !!kindPick));
|
||||
shown++;
|
||||
}
|
||||
// the kinds there are, in the market's order, each with how many the
|
||||
// field leaves of it; one kind alone needs no picking
|
||||
const found = ghList.filter(ghMatch);
|
||||
const kinds = ["pv", "mw", "ag", "tl", "pg"].filter((k) => ghList.some((l) => kindOf(l) === k));
|
||||
if (!kinds.includes(ghKind)) ghKind = "";
|
||||
// which of them are here, asked once each: the counts below would ask
|
||||
// it again for every pick in both strips. Like a kind alone, a list
|
||||
// that is all installed or all not has nothing to pick out, and a pick
|
||||
// that can no longer be seen doesn't go on narrowing the grid.
|
||||
const here = new Map(ghList.map((l) => [l, !!entryOf(l.package)]));
|
||||
const have = (l) => here.get(l);
|
||||
const both = ghList.some(have) && ghList.some((l) => !have(l));
|
||||
if (!both) ghHave = "";
|
||||
// the field and the other strip narrow it, so each count is what a
|
||||
// pick in this strip would leave; the kind's own pick is the one left
|
||||
// out, or every count but All would be the picked kind's alone
|
||||
const n = (k, h) => found.filter((l) => (!k || kindOf(l) === k) && (!h || have(l) === (h === "have"))).length;
|
||||
const bar = [];
|
||||
if (kinds.length > 1) {
|
||||
const pick = segs([["", t("All") + " · " + n("", ghHave)], ...kinds.map((k) => [k, t(KINDS[k][1]) + " · " + n(k, ghHave)])], ghKind, (k) => { ghKind = k; drawGh(); });
|
||||
pick.classList.add("pm-ghkinds");
|
||||
pick.setAttribute("role", "group");
|
||||
pick.setAttribute("aria-label", t("Kind of plugin"));
|
||||
bar.push(pick);
|
||||
if (!shown && ghLooking() && srcPick === "gh") out.push(skeleton(3));
|
||||
else if (!shown && (kindPick || srcPick || onlyNew)) {
|
||||
const none = el("div", "pm-ghnone");
|
||||
const every = el("button", "text", t("Show all"));
|
||||
every.type = "button";
|
||||
every.onclick = () => { kindPick = ""; srcPick = ""; onlyNew = false; drawBody(); };
|
||||
none.append(el("span", "", t("No plugin matches")), every);
|
||||
out.push(none);
|
||||
}
|
||||
// what's installed, on both sides of it: a reader looks for what to
|
||||
// add as much as for what they have
|
||||
if (both) {
|
||||
const pick = segs([["", t("All")], ["have", t("Installed") + " · " + n(ghKind, "have")], ["none", t("Not installed") + " · " + n(ghKind, "none")]], ghHave, (h) => { ghHave = h; drawGh(); });
|
||||
pick.classList.add("pm-ghhave");
|
||||
pick.setAttribute("role", "group");
|
||||
pick.setAttribute("aria-label", t("Installed or not"));
|
||||
bar.push(pick);
|
||||
}
|
||||
bar.push(el("span", "grow"), ghFind);
|
||||
ghQ.placeholder = t("Filter by name, author or description");
|
||||
ghQ.setAttribute("aria-label", t("Filter the plugins on GitHub"));
|
||||
if (ghQ.value !== ghQuery) ghQ.value = ghQuery;
|
||||
replaceKeeping(ghBar, bar);
|
||||
const shown = found.filter((l) => (!ghKind || kindOf(l) === ghKind) && (!ghHave || have(l) === (ghHave === "have")));
|
||||
if (shown.length) {
|
||||
ghGrid.replaceChildren(...shown.map(card));
|
||||
replaceKeeping(ghSec, [...head, ghBar, ghGrid]);
|
||||
return;
|
||||
}
|
||||
const none = el("div", "pm-ghnone");
|
||||
const all = el("button", "text", t("Show all"));
|
||||
all.type = "button";
|
||||
all.onclick = () => { ghKind = ""; ghHave = ""; ghQuery = ""; drawGh(); ghQ.focus(); };
|
||||
none.append(el("span", "", t("No plugin on GitHub matches")), all);
|
||||
replaceKeeping(ghSec, [...head, ghBar, none]);
|
||||
return out;
|
||||
}
|
||||
|
||||
// the head and its search field are made once and drawn again in
|
||||
@@ -917,41 +1007,24 @@
|
||||
return;
|
||||
}
|
||||
if (!listings) {
|
||||
body.append(intro(), skeleton(6));
|
||||
body.append(skeleton(6));
|
||||
return;
|
||||
}
|
||||
const f = query.trim().toLowerCase();
|
||||
const match = (l) => !f || [l.name, l.package, summary(l), (l.providers || []).join(" "), l.npm?.publisher || ""].join(" ").toLowerCase().includes(f);
|
||||
const ls = listings.filter(match);
|
||||
// a tagged repository the market already lists is the market's card
|
||||
const listed = new Set(listings.map((l) => l.package));
|
||||
const gh = (tagged || []).filter((l) => !(l.github.package && listed.has(l.github.package)) && match(l));
|
||||
// put in place around the GitHub section, which stays in the page
|
||||
const match = (l) => !f || [l.name, l.package, summary(l), (l.providers || []).join(" "), l.npm?.publisher || "", l.github?.owner || ""].join(" ").toLowerCase().includes(f);
|
||||
const all = everything(match);
|
||||
const out = [];
|
||||
if (!f) {
|
||||
out.push(intro());
|
||||
// magpie's community's alone: others' plugins are found by a search
|
||||
const ours = ls.filter((l) => l.community && kindOf(l) === "pv");
|
||||
const mws = ls.filter((l) => l.community && kindOf(l) === "mw");
|
||||
const ags = ls.filter((l) => l.community && kindOf(l) === "ag");
|
||||
const tls = ls.filter((l) => l.community && kindOf(l) === "tl");
|
||||
const pgs = ls.filter((l) => l.community && kindOf(l) === "pg");
|
||||
if (ours.length) out.push(section(t("Subscriptions"), t("written for magpie, checked against its own sign-ins"), ours));
|
||||
if (mws.length) out.push(section(t("Gateway middleware"), t("runs in magpie's gateway on what every agent sends and gets back, whichever provider serves it"), mws));
|
||||
const agSec = ags.length ? section(t("Agents"), t("agents magpie has no setup of its own for, connected to it as its own are"), ags) : null;
|
||||
if (agSec) { agSec.classList.add("pm-agents"); out.push(agSec); }
|
||||
if (tls.length) out.push(section(t("Tools for agents"), t("tools every agent can call, through magpie's MCP server"), tls));
|
||||
if (pgs.length) out.push(section(t("Pages"), t("pages of their own in magpie's window, each shut off from the rest and reading only what it lists"), pgs));
|
||||
if (gh.length) out.push(ghSection(gh));
|
||||
else if (!tagged) out.push(ghWaiting());
|
||||
else if (taggedErr && !tagged.length) out.push(ghFailed());
|
||||
out.push(manual());
|
||||
const rec = !kindPick && recSection(all);
|
||||
if (rec) out.push(rec);
|
||||
out.push(...market(all));
|
||||
out.push(manual(), footer());
|
||||
if (mine?.registry) {
|
||||
out.push(regBox = regBox || el("div", "pm-registry"));
|
||||
import("./registry.js").then(() => pmRegistry(regBox, mine, askNPM), statusTErr);
|
||||
}
|
||||
replaceKeeping(body, out);
|
||||
if (agentsFor && agSec) {
|
||||
if (agentsFor && body.querySelector(".pm-agents")) {
|
||||
// after the view is put back where the reader was, as showing it
|
||||
// does; the section then is the one drawn last (npm's answers draw
|
||||
// it again)
|
||||
@@ -960,14 +1033,15 @@
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (ls.length) out.push(section(t("Suggested"), "", ls));
|
||||
if (gh.length) out.push(ghSection(gh));
|
||||
else if (!tagged) out.push(ghWaiting());
|
||||
else if (taggedErr && !tagged.length) out.push(ghFailed());
|
||||
// a search looks through every source at once, most used first
|
||||
if (all.length) out.push(section(t("Plugins"), "", ranked(all, "hot")));
|
||||
if (ghLooking()) out.push(ghLook());
|
||||
else if (taggedErr) out.push(ghNote());
|
||||
// npm's card goes where a card above is its package (a listing, or a
|
||||
// tagged repository npm has), not where a repository's package.json
|
||||
// only names it (#3685)
|
||||
const known = new Set([...listings.map((l) => l.package), ...(tagged || []).map((l) => l.package)]);
|
||||
const ls = all;
|
||||
const box = el("section", "pm-sec");
|
||||
const h = el("div", "pm-sechead");
|
||||
h.append(el("h3", "", t("On npm")), el("span", "", t("OpenCode plugins and pi packages anyone published — read what one does before you install it")));
|
||||
@@ -986,27 +1060,18 @@
|
||||
replaceKeeping(body, out);
|
||||
}
|
||||
|
||||
function intro() {
|
||||
const box = el("div", "pm-intro");
|
||||
const text = el("div", "pm-introtext");
|
||||
text.append(el("h2", "", t("Plugins extend magpie")));
|
||||
text.append(el("p", "", t("Plugins sign in to coding plans and make their requests; the models then work in every agent, like any provider's. They're OpenCode's provider plugins or pi's packages, run on Bun.")));
|
||||
const mw = el("p", "");
|
||||
mw.append(document.createTextNode(t("A plugin can also run in magpie's gateway on what agents send and get back, pick which account a routing asks, give every agent tools, connect an agent, or add a page of its own.") + " "));
|
||||
// what a plugin is to the reader, and how one is written, under the list
|
||||
function footer() {
|
||||
const box = el("div", "pm-foot");
|
||||
const trust = el("p", "pm-trust");
|
||||
trust.append(glyph(SHIELD, 12, 1.5), el("span", "", t("A plugin is someone else's code with your sign-in or your requests: install the ones you trust.")));
|
||||
// the docs in the reader's language: the site has en, zh and ja, and
|
||||
// Chinese is nearer a zh-TW reader than English is
|
||||
const how = el("a", "pm-link pm-write", "");
|
||||
how.href = "https://usemagpie.ai/docs/" + ({ zh: "zh/", "zh-TW": "zh/", ja: "ja/" }[lang()] || "") + "plugins";
|
||||
how.append(el("span", "", t("Write a plugin")), glyph(OUTL, 11, 1.5));
|
||||
how.onclick = (ev) => { ev.preventDefault(); api("open", { url: how.href }).catch(() => {}); };
|
||||
mw.append(how);
|
||||
text.append(mw);
|
||||
const trust = el("p", "pm-trust");
|
||||
trust.append(glyph(SHIELD, 12, 1.5), el("span", "", t("A plugin is someone else's code with your sign-in or your requests: install the ones you trust.")));
|
||||
text.append(trust);
|
||||
const art = el("div", "pm-art");
|
||||
for (const ic of ["zcode", "githubcopilot", "gemini-color", "zed", "kiro-color"]) art.append(logo(ic));
|
||||
box.append(text, art);
|
||||
box.append(trust, how);
|
||||
return box;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert(await noSideScroll(page), "the page scrolls sideways");
|
||||
await page.screenshot({ path: path.join(process.env.SHOTS || "/tmp", `plugin-agents-${engine}-${lang}-${width}.png`), fullPage: true }).catch(() => {});
|
||||
|
||||
// to Plugins, Discover, its Agents in sight at the top
|
||||
// to Plugins, Discover, Agents alone, in sight at the top
|
||||
await more.click();
|
||||
const view = page.locator("#view-plugins");
|
||||
await view.waitFor();
|
||||
@@ -115,7 +115,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.waitForFunction(() => {
|
||||
const v = document.querySelector("#view-plugins");
|
||||
const s = [...v.querySelectorAll(".pm-sec")].find((x) => x.querySelector(".pm-card .pm-chip.kind.ag"));
|
||||
return v.scrollTop > 0 && s && Math.abs(s.getBoundingClientRect().top - v.getBoundingClientRect().top) < 80;
|
||||
return s && Math.abs(s.getBoundingClientRect().top - v.getBoundingClientRect().top) < 80;
|
||||
});
|
||||
assert.equal(await agents.locator(".pm-card").count(), AGENTS.length);
|
||||
// it stays there once the page has what it loads
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// A plugin its author publishes from their own repository is listed in
|
||||
// registry.json without "community": true (the owner on
|
||||
// magpie-community/plugins#479). Discover doesn't browse it: not in
|
||||
// Agents, nor any section. A search finds it, by its name or its
|
||||
// publisher, under its publisher's name and never with the magpie
|
||||
// community badge, on its card and on its page. PinK's listing is
|
||||
// magpie-community/plugins#479). Discover browses it with the rest
|
||||
// (yetone: 社区插件、非官方插件散落的太厉害了,你要把它统筹起来): in Agents,
|
||||
// and alone under the Other authors origin. Browsed or found by a search,
|
||||
// by its name or its publisher, it is under its publisher's name and never
|
||||
// with the magpie community badge, on its card and on its page. PinK's listing is
|
||||
// registry.json's before plugins#617. Every language, both engines, at a
|
||||
// narrow width too; the API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
@@ -90,14 +91,23 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const card = (pkg) => view.locator(`.pm-card[data-pkg="${pkg}"]`);
|
||||
const shot = (name) => process.env.ARTIFACT_DIR && view.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `plugin-authors-${name}-${engine}-${lang}-${width}.png`) });
|
||||
|
||||
// browsed: the community's agent in Agents, PinK nowhere, after
|
||||
// npm has answered too (a redraw)
|
||||
// browsed: the community's agent and PinK in Agents, PinK under
|
||||
// its publisher, after npm has answered too (a redraw)
|
||||
const agents = view.locator(".pm-sec.pm-agents");
|
||||
await agents.locator(".pm-sechead h3", { hasText: new RegExp("^" + w.agents + "$") }).waitFor();
|
||||
await card(KILO).locator(".pm-ver").waitFor();
|
||||
await card(RIVER).waitFor();
|
||||
assert.equal(await card(PINK).count(), 0, "PinK is browsed");
|
||||
assert.doesNotMatch(await view.innerText(), /PinK/);
|
||||
assert.equal(await agents.locator(`.pm-card[data-pkg="${PINK}"]`).count(), 1, "PinK is in Agents");
|
||||
assert.equal(await card(PINK).locator(".pm-verified").count(), 0);
|
||||
assert.equal((await card(PINK).locator(".pm-by").innerText()).trim(), "zhouzhenzhou");
|
||||
// the Other authors origin: PinK alone
|
||||
await view.locator(".pm-bar .pm-pop").first().click();
|
||||
await page.locator(".proto-menu .pm-item", { hasText: await page.evaluate(() => t("Other authors")) }).click();
|
||||
await page.locator(".proto-menu").waitFor({ state: "hidden" }).catch(() => {});
|
||||
assert.deepEqual(await view.locator(".pm-sec[data-kind] .pm-card").evaluateAll((cs) => cs.map((c) => c.dataset.pkg)), [PINK]);
|
||||
await view.locator(".pm-bar .pm-pop").first().click();
|
||||
await page.locator(".proto-menu .pm-item").first().click();
|
||||
await page.locator(".proto-menu").waitFor({ state: "hidden" }).catch(() => {});
|
||||
assert.equal(await card(RIVER).locator(".pm-verified").count(), 1);
|
||||
assert.equal((await card(RIVER).locator(".pm-verified").innerText()).trim(), w.community);
|
||||
await shot("browse");
|
||||
@@ -114,10 +124,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await card(RIVER).count(), 0);
|
||||
await shot("search");
|
||||
|
||||
// the search cleared: browsed again, PinK gone
|
||||
// the search cleared: browsed again, PinK with them
|
||||
await q.fill("");
|
||||
await card(KILO).waitFor();
|
||||
assert.equal(await card(PINK).count(), 0);
|
||||
assert.equal(await card(PINK).count(), 1);
|
||||
|
||||
// found by its publisher's name too
|
||||
await q.fill("zhouzhen");
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// The repositories tagged magpie-plugin on GitHub are many and of every
|
||||
// kind (the owner: 这里应该有分类以及搜索框方便用户筛选), so their section
|
||||
// has its kinds to pick from, each with how many there are, and a field of
|
||||
// its own that narrows them by name, author or description as it is typed.
|
||||
// Both narrow what the page's search already found, the field keeps its
|
||||
// focus and its node while the page is drawn again under it (npm's answer
|
||||
// comes while typing), nothing is left over at 420px, and a filter that
|
||||
// leaves nothing says so with a Show all. What's installed is the other
|
||||
// question the section is read with (the owner: 加一个未安装), so a second
|
||||
// strip beside the kinds picks it out, its counts following the kinds and
|
||||
// the field as they are picked, and the two narrow the grid together; a
|
||||
// list with nothing installed, or nothing else, has no such strip. The
|
||||
// repositories are the dev instance's real /api/plugins/github answer of
|
||||
// 2026-10-13 (31: 27 providers, 3 middleware, an agent); the API is faked
|
||||
// and no request leaves the page. English, Chinese, Traditional Chinese, Japanese and
|
||||
// German, 1100px, 980px and 420px.
|
||||
// Discover is one market: magpie's community, other authors and the
|
||||
// repositories tagged magpie-plugin on GitHub, browsed with one bar
|
||||
// (yetone: 社区插件、非官方插件散落的太厉害了,你要把它统筹起来). The bar's
|
||||
// kinds say how many of each there are under what Origin leaves; Origin
|
||||
// picks a source and, beside it, what isn't installed yet (the owner:
|
||||
// 加一个未安装); a shelf's See all opens its kind whole; Sort puts them by
|
||||
// name; a pick that leaves nothing says so with Show all, which puts back
|
||||
// every pick. The page's search field keeps its node, focus and every
|
||||
// key while npm's answer redraws the page under it, and nothing is left
|
||||
// over at 420px. The repositories are the dev instance's real
|
||||
// /api/plugins/github answer of 2026-10-13 (31: 27 providers, 3
|
||||
// middleware, an agent); the API is faked and no request leaves the page.
|
||||
// English, Chinese, Traditional Chinese, Japanese and German, 1100px,
|
||||
// 980px and 420px.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -55,40 +53,16 @@ function server(lang, fetched, installed = INSTALLED) {
|
||||
};
|
||||
}
|
||||
|
||||
const kindOf = (r) => r.kind === "middleware" ? "Middleware" : r.kind === "agent" ? "Agent" : "Provider";
|
||||
const names = (rs) => rs.map((r) => r.repo.split("/")[1]).sort();
|
||||
const kindOf = (r) => r.kind === "middleware" ? "mw" : r.kind === "agent" ? "ag" : "pv";
|
||||
const has = (r, s) => [r.repo, r.owner, r.package || "", r.description || ""].join(" ").toLowerCase().includes(s.toLowerCase());
|
||||
// the two the fixture installs; that the page tells them apart the same
|
||||
// way is checked against its own cards
|
||||
const here = (r) => HERE.includes(r.repo);
|
||||
const count = (rs, k) => rs.filter((r) => !k || kindOf(r) === k).length;
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
test(engine + ": the plugins on GitHub are narrowed by kind and by a field of their own", async (t) => {
|
||||
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
// nothing from GitHub installed: Not installed would be All again, so
|
||||
// there is no strip to pick it from, only the kinds and the field
|
||||
await t.test("nothing installed", async () => {
|
||||
const ctx = await browser.newContext({ viewport: { width: 980, height: 860 } });
|
||||
const page = await ctx.newPage();
|
||||
page.setDefaultTimeout(6000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [], fetched = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server("en", fetched, []));
|
||||
try {
|
||||
await page.goto("http://magpie.test/?view=plugins");
|
||||
const sec = page.locator("#view-plugins .pm-ghsec");
|
||||
await sec.locator(".pm-card").first().waitFor();
|
||||
assert.equal(await sec.locator(".pm-ghkinds").count(), 1);
|
||||
assert.equal(await sec.locator(".pm-ghhave").count(), 0);
|
||||
assert.equal(await sec.locator(".pm-card").count(), GH.repos.length);
|
||||
assert.deepEqual(errors, []);
|
||||
} finally {
|
||||
await ctx.close();
|
||||
}
|
||||
});
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) for (const width of [1100, 980, 420]) {
|
||||
await t.test(`${lang} ${width}px`, async () => {
|
||||
const ctx = await browser.newContext({ viewport: { width, height: 860 } });
|
||||
@@ -100,132 +74,99 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.route("**/*", server(lang, fetched));
|
||||
try {
|
||||
await page.goto("http://magpie.test/?view=plugins");
|
||||
const sec = page.locator("#view-plugins .pm-ghsec");
|
||||
const cards = sec.locator(".pm-card");
|
||||
await cards.first().waitFor();
|
||||
assert.equal(await cards.count(), 31);
|
||||
const view = page.locator("#view-plugins");
|
||||
const bar = view.locator(".pm-bar");
|
||||
await bar.waitFor();
|
||||
await view.locator(".pm-ghlook").waitFor({ state: "detached" });
|
||||
const tr = (s) => page.evaluate((s) => t(s), s);
|
||||
if (lang !== "en") for (const s of ["Kind of plugin", "Installed or not", "Not installed", "Filter by name, author or description", "Filter the plugins on GitHub", "No plugin on GitHub matches"]) assert.notEqual(await tr(s), s, `${s} in ${lang}`);
|
||||
const want = async (rs) => [await tr("All") + " · " + rs.length, ...(await Promise.all(["Provider", "Middleware", "Agent"].map(async (k) => (await tr(k)) + " · " + rs.filter((r) => kindOf(r) === k).length)))];
|
||||
const kinds = sec.locator(".pm-ghkinds .opt");
|
||||
assert.deepEqual(await kinds.allTextContents(), await want(GH.repos));
|
||||
// and beside them what's installed, over the very repositories:
|
||||
// two of them, a provider and a middleware, are already here, as
|
||||
// the page's own cards say
|
||||
const have = sec.locator(".pm-ghhave .opt");
|
||||
const wantHave = async (rs) => [await tr("All"), await tr("Installed") + " · " + rs.filter(here).length, await tr("Not installed") + " · " + rs.filter((r) => !here(r)).length];
|
||||
assert.deepEqual(await have.allTextContents(), await wantHave(GH.repos));
|
||||
assert.equal(await sec.locator(".pm-ghhave .opt.on").textContent(), (await wantHave(GH.repos))[0]);
|
||||
assert.deepEqual((await sec.locator(".pm-card.have .pm-name b").allInnerTexts()).sort(), names(GH.repos.filter(here)));
|
||||
// both strips and the field, nothing left over at this width: the
|
||||
// kinds in Japanese are wider than the bar at 420px
|
||||
if (lang !== "en") for (const s of ["Kind of plugin", "Origin", "Sort", "Not installed only", "Other authors", "See all", "No plugin matches", "Most popular"]) assert.notEqual(await tr(s), s, `${s} in ${lang}`);
|
||||
const cards = view.locator(".pm-sec[data-kind] .pm-card");
|
||||
const kinds = bar.locator(".pm-kinds .opt");
|
||||
const said = () => kinds.evaluateAll((bs) => bs.map((b) => [b.firstChild.textContent, b.querySelector("em").textContent]));
|
||||
const want = async (rs) => Promise.all([["", "All"], ["pv", "Subscriptions"], ["mw", "Middleware"], ["ag", "Agents"]].map(async ([k, n]) => [await tr(n), String(count(rs, k))]));
|
||||
// Zed, from magpie's community, is a subscription too
|
||||
const ZED = { kind: undefined, repo: "z/zed" };
|
||||
assert.deepEqual(await said(), await want([...GH.repos, ZED]));
|
||||
// nothing left over at this width: the kinds in Japanese are wide
|
||||
const overflow = () => page.evaluate(() => {
|
||||
const bar = document.querySelector("#view-plugins .pm-ghbar");
|
||||
const bar = document.querySelector("#view-plugins .pm-bar");
|
||||
const v = document.querySelector("#view-plugins");
|
||||
return [bar.scrollWidth - bar.clientWidth, v.scrollWidth - v.clientWidth, document.documentElement.scrollWidth - innerWidth];
|
||||
});
|
||||
assert.deepEqual((await overflow()).map((x) => Math.max(0, x)), [0, 0, 0], JSON.stringify(await overflow()));
|
||||
// a reader scrolls to what's under the footer with the wheel; a
|
||||
// scroll by code, as a click's own scrolling into view, is put
|
||||
// back (no unasked scroll), and the footer took WebKit's click
|
||||
const press = async (b) => {
|
||||
await page.mouse.move(width / 2, 400);
|
||||
for (let i = 0; i < 12; i++) {
|
||||
const [at, foot] = [await b.boundingBox(), await page.locator(".foot").boundingBox()];
|
||||
if (at && (!foot || at.y + at.height <= foot.y)) break;
|
||||
await page.mouse.wheel(0, 200);
|
||||
await page.waitForTimeout(80);
|
||||
}
|
||||
await b.click();
|
||||
const pops = bar.locator(".pm-pop");
|
||||
const choose = async (i, name) => {
|
||||
await pops.nth(i).click();
|
||||
await page.locator(".proto-menu .pm-item", { hasText: await tr(name) }).first().click();
|
||||
if (await page.locator(".proto-menu").isVisible().catch(() => false)) await page.keyboard.press("Escape");
|
||||
await page.locator(".proto-menu").waitFor({ state: "hidden" }).catch(() => {});
|
||||
};
|
||||
const field = sec.locator(".pm-ghfind input");
|
||||
assert.equal(await field.getAttribute("placeholder"), await tr("Filter by name, author or description"));
|
||||
|
||||
// not installed: the 29 nobody has, both strips counting the
|
||||
// other as it is picked
|
||||
await have.nth(2).click();
|
||||
assert.equal(await cards.count(), GH.repos.filter((r) => !here(r)).length);
|
||||
assert.equal(await sec.locator(".pm-card.have").count(), 0);
|
||||
assert.deepEqual(await kinds.allTextContents(), await want(GH.repos.filter((r) => !here(r))));
|
||||
// a kind on top of it: the middleware nobody has, its own kind
|
||||
// strip counting what's left of it
|
||||
// Origin GitHub: the kinds count the 31 alone
|
||||
await choose(0, "Unofficial, on GitHub");
|
||||
assert.deepEqual(await said(), await want(GH.repos));
|
||||
assert.equal((await pops.nth(0).locator("b").textContent()).trim(), await tr("Unofficial, on GitHub"));
|
||||
// a kind on top: its shelf alone, whole
|
||||
await kinds.nth(2).click();
|
||||
assert.equal(await cards.count(), GH.repos.filter((r) => kindOf(r) === "Middleware" && !here(r)).length);
|
||||
assert.deepEqual(await have.allTextContents(), await wantHave(GH.repos.filter((r) => kindOf(r) === "Middleware")));
|
||||
// installed: the two here, the middleware among them
|
||||
await have.nth(1).click();
|
||||
assert.deepEqual(await cards.locator(".pm-name b").allInnerTexts(), names(GH.repos.filter((r) => kindOf(r) === "Middleware" && here(r))));
|
||||
// the field narrows both strips' counts, as it does the kinds'
|
||||
await field.fill("doubao");
|
||||
const doubao0 = GH.repos.filter((r) => has(r, "doubao"));
|
||||
assert.deepEqual(await have.allTextContents(), await wantHave(doubao0.filter((r) => kindOf(r) === "Middleware")));
|
||||
assert.deepEqual(await kinds.allTextContents(), await want(doubao0.filter(here)));
|
||||
assert.equal(await cards.count(), count(GH.repos, "mw"));
|
||||
assert.equal(await cards.locator(".pm-chip.kind.mw").count(), count(GH.repos, "mw"));
|
||||
// and only what isn't here yet: the middleware installed goes,
|
||||
// the kinds count what is left
|
||||
await choose(0, "Not installed only");
|
||||
const fresh = GH.repos.filter((r) => !here(r));
|
||||
assert.equal(await cards.count(), count(fresh, "mw"));
|
||||
assert.equal(await view.locator(".pm-card.have").count(), 0);
|
||||
assert.deepEqual(await said(), await want(fresh));
|
||||
assert.equal((await pops.nth(0).locator("b").textContent()).trim(), await tr("Unofficial, on GitHub") + " · " + await tr("Not installed"));
|
||||
|
||||
// magpie's community has no middleware: said so, and Show all
|
||||
// puts back every pick
|
||||
await choose(0, "magpie community");
|
||||
assert.equal(await cards.count(), 0);
|
||||
const none0 = sec.locator(".pm-ghnone");
|
||||
assert.equal((await none0.locator("span").textContent()).trim(), await tr("No plugin on GitHub matches"));
|
||||
// Show all puts back both strips and the field
|
||||
await press(none0.locator("button"));
|
||||
assert.equal(await field.inputValue(), "");
|
||||
assert.equal(await cards.count(), GH.repos.length);
|
||||
assert.equal(await sec.locator(".pm-ghhave .opt.on").textContent(), (await wantHave(GH.repos))[0]);
|
||||
assert.equal(await sec.locator(".pm-ghkinds .opt.on").textContent(), (await want(GH.repos))[0]);
|
||||
const none = view.locator(".pm-ghnone");
|
||||
assert.equal((await none.locator("span").textContent()).trim(), await tr("No plugin matches"));
|
||||
await none.locator("button").click();
|
||||
assert.equal((await bar.locator(".pm-kinds .opt.on").evaluate((b) => b.firstChild.textContent)), await tr("All"));
|
||||
assert.equal((await pops.nth(0).locator("b").textContent()).trim(), await tr("All"));
|
||||
assert.deepEqual(await said(), await want([...GH.repos, ZED]));
|
||||
|
||||
// a kind: its cards alone, each saying so
|
||||
await kinds.nth(2).click();
|
||||
assert.equal(await cards.count(), 3);
|
||||
assert.deepEqual([...new Set(await cards.locator(".pm-chip.kind").allTextContents())], [await tr("Middleware")]);
|
||||
// a shelf's See all: its kind whole
|
||||
await choose(0, "Unofficial, on GitHub");
|
||||
const pv = view.locator('.pm-sec[data-kind="pv"]');
|
||||
assert.ok(await pv.locator(".pm-card").count() < count(GH.repos, "pv"));
|
||||
await pv.locator(".pm-more").click();
|
||||
assert.equal(await cards.count(), count(GH.repos, "pv"));
|
||||
assert.equal((await bar.locator(".pm-kinds .opt.on").evaluate((b) => b.firstChild.textContent)), await tr("Subscriptions"));
|
||||
// Sort by name
|
||||
await choose(1, "Name");
|
||||
const shown = await cards.locator(".pm-name b").allInnerTexts();
|
||||
assert.deepEqual(shown, await page.evaluate((a) => [...a].sort((x, y) => x.localeCompare(y, intlLang())), shown));
|
||||
assert.equal(shown.length, count(GH.repos, "pv"));
|
||||
|
||||
// the field, typed in while npm's answer redraws the page: the same
|
||||
// node keeps its focus and every key; the kinds count what it leaves
|
||||
await field.evaluate((x) => { window.__field = x; });
|
||||
await field.click();
|
||||
// the page's search, typed while npm's answer redraws the page:
|
||||
// the same node keeps its focus and every key
|
||||
const q = view.locator(".pm-head .pm-find input");
|
||||
await q.evaluate((x) => { window.__field = x; });
|
||||
await q.click();
|
||||
await page.keyboard.type("doubao", { delay: 120 });
|
||||
await page.waitForTimeout(800);
|
||||
assert(await field.evaluate((x) => x === window.__field && document.activeElement === x && x.value === "doubao"), "the field kept its node, focus and text");
|
||||
assert(await q.evaluate((x) => x === window.__field && document.activeElement === x && x.value === "doubao"), "the field kept its node, focus and text");
|
||||
const doubao = GH.repos.filter((r) => has(r, "doubao"));
|
||||
assert.deepEqual(await kinds.allTextContents(), await want(doubao));
|
||||
// no middleware is about doubao: said so, with Show all
|
||||
assert.equal(await cards.count(), 0);
|
||||
const none = sec.locator(".pm-ghnone");
|
||||
assert.equal((await none.locator("span").textContent()).trim(), await tr("No plugin on GitHub matches"));
|
||||
await kinds.nth(0).click();
|
||||
assert.deepEqual((await cards.locator(".pm-who").allTextContents()).length, doubao.length);
|
||||
|
||||
// an author, then words of a description
|
||||
await page.waitForFunction((n) => document.querySelector("#view-plugins .pm-sec")?.querySelectorAll(".pm-card").length === n, doubao.length);
|
||||
for (const s of ["mu-zi-lee", "Cloudflare AI Gateway"]) {
|
||||
await field.fill(s);
|
||||
await q.fill(s);
|
||||
const rs = GH.repos.filter((r) => has(r, s));
|
||||
assert(rs.length > 0);
|
||||
assert.equal(await cards.count(), rs.length, s);
|
||||
await page.waitForFunction((n) => document.querySelector("#view-plugins .pm-sec")?.querySelectorAll(".pm-card").length === n, rs.length);
|
||||
}
|
||||
|
||||
// Show all puts back every kind and every card
|
||||
await kinds.nth(3).click();
|
||||
await field.fill("zzz-nothing");
|
||||
await press(none.locator("button"));
|
||||
assert.equal(await field.inputValue(), "");
|
||||
assert.equal(await cards.count(), 31);
|
||||
assert.equal(await sec.locator(".pm-ghkinds .opt.on").textContent(), (await want(GH.repos))[0]);
|
||||
|
||||
// the page's search narrows first, the section's within it; what
|
||||
// it leaves has nothing installed, so the strip goes and so does
|
||||
// its pick, rather than narrowing the grid out of sight
|
||||
await have.nth(1).click();
|
||||
assert.equal(await cards.count(), GH.repos.filter(here).length);
|
||||
const q = page.locator("#view-plugins .pm-head .pm-find input");
|
||||
await q.fill("translate");
|
||||
const tl = GH.repos.filter((r) => has(r, "translate"));
|
||||
await page.waitForFunction((n) => document.querySelectorAll("#view-plugins .pm-ghsec .pm-card").length === n, tl.length);
|
||||
assert.deepEqual(await kinds.count(), 0, "one kind alone needs no picking");
|
||||
assert.equal(tl.some(here), false);
|
||||
assert.equal(await have.count(), 0, "nothing installed is left to pick out");
|
||||
await field.fill("seed");
|
||||
assert.equal(await cards.count(), tl.filter((r) => has(r, "seed")).length);
|
||||
await q.fill("");
|
||||
await bar.waitFor();
|
||||
|
||||
// nothing left over at any width
|
||||
const over = await overflow();
|
||||
assert.deepEqual(over.map((x) => Math.max(0, x)), [0, 0, 0], JSON.stringify(over));
|
||||
assert.deepEqual(errors, []);
|
||||
assert.deepEqual(fetched, []);
|
||||
} finally {
|
||||
await ctx.close();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// A repository tagged magpie-plugin that is gateway hooks alone
|
||||
// (package.json's magpie.hooks and no entry of its own; MengXiangxi,
|
||||
// #3821) is in "Unofficial, on GitHub" as an installed one's row has it:
|
||||
// #3821) is in Discover as an installed one's row has it:
|
||||
// the gateway's chip saying Request hook, never Provider, and picked out
|
||||
// under Middleware, as it runs in the gateway too. The repositories are
|
||||
// seven of /api/plugins/github's real answer of 2026-10-27, from a magpie
|
||||
// built at this change: two providers, three middleware and two of hooks
|
||||
// alone (past six, the section has its kinds to pick from).
|
||||
// alone.
|
||||
// The API is faked here and no request leaves the page. English, Chinese,
|
||||
// Traditional Chinese, Japanese and German, 980px and 420px.
|
||||
const assert = require("node:assert/strict");
|
||||
@@ -69,32 +69,32 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.addInitScript(() => { try { localStorage.setItem("magpie.pluginTab", "discover"); } catch {} });
|
||||
try {
|
||||
await page.goto("http://magpie.test/?view=plugins");
|
||||
const sec = page.locator("#view-plugins .pm-ghsec");
|
||||
const cards = sec.locator(".pm-card");
|
||||
const sec = page.locator("#view-plugins");
|
||||
const cards = sec.locator(".pm-sec[data-kind] .pm-card");
|
||||
await cards.first().waitFor();
|
||||
assert.deepEqual(await cards.locator(".pm-name b").allInnerTexts(), REPOS.map(name), "every one listed, in GitHub's order");
|
||||
const tr = (s) => page.evaluate((s) => t(s), s);
|
||||
const hook = await tr("Request hook");
|
||||
if (lang !== "en") assert.notEqual(hook, "Request hook", "Request hook in " + lang);
|
||||
const kinds = sec.locator(".pm-bar .pm-kinds .opt");
|
||||
assert.deepEqual(await kinds.evaluateAll((bs) => bs.map((b) => [b.firstChild.textContent, b.querySelector("em").textContent])),
|
||||
[[await tr("All"), "7"], [await tr("Subscriptions"), "2"], [await tr("Middleware"), "5"]]);
|
||||
|
||||
// each card's one chip: the gateway's for middleware and hooks,
|
||||
// which say Request hook, as an installed one's row does
|
||||
for (const r of REPOS) {
|
||||
const chip = cards.filter({ has: page.locator(".pm-name b", { hasText: new RegExp("^" + name(r) + "$") }) }).locator(".pm-chip.kind");
|
||||
assert.equal(await chip.count(), 1, r.repo);
|
||||
const want = r.kind === "hooks" ? hook : await tr(r.kind === "middleware" ? "Middleware" : "Provider");
|
||||
assert.equal((await chip.innerText()).trim(), want, r.repo);
|
||||
assert.equal(await chip.evaluate((e) => e.classList.contains("mw")), !!r.kind, r.repo + "'s chip is the gateway's");
|
||||
// picked out under Middleware, with the middleware; each card's
|
||||
// one chip the gateway's, which says Request hook for hooks, as
|
||||
// an installed one's row does
|
||||
for (const [i, of] of [[2, (r) => !!r.kind], [1, (r) => !r.kind]]) {
|
||||
await kinds.nth(i).click();
|
||||
const rs = REPOS.filter(of);
|
||||
assert.deepEqual((await cards.locator(".pm-name b").allInnerTexts()).sort(), rs.map(name).sort());
|
||||
for (const r of rs) {
|
||||
const chip = cards.filter({ has: page.locator(".pm-name b", { hasText: new RegExp("^" + name(r) + "$") }) }).locator(".pm-chip.kind");
|
||||
assert.equal(await chip.count(), 1, r.repo);
|
||||
const want = r.kind === "hooks" ? hook : await tr(r.kind === "middleware" ? "Middleware" : "Provider");
|
||||
assert.equal((await chip.innerText()).trim(), want, r.repo);
|
||||
assert.equal(await chip.evaluate((e) => e.classList.contains("mw")), !!r.kind, r.repo + "'s chip is the gateway's");
|
||||
}
|
||||
}
|
||||
|
||||
// picked out under Middleware, with the middleware
|
||||
const kinds = sec.locator(".pm-ghkinds .opt");
|
||||
assert.deepEqual(await kinds.allTextContents(), [await tr("All") + " · 7", await tr("Provider") + " · 2", await tr("Middleware") + " · 5"]);
|
||||
await kinds.nth(2).click();
|
||||
assert.deepEqual(await cards.locator(".pm-name b").allInnerTexts(), REPOS.filter((r) => r.kind).map(name));
|
||||
await kinds.nth(1).click();
|
||||
assert.deepEqual(await cards.locator(".pm-name b").allInnerTexts(), REPOS.filter((r) => !r.kind).map(name));
|
||||
|
||||
const over = await page.evaluate(() => [document.querySelector("#view-plugins").scrollWidth - document.querySelector("#view-plugins").clientWidth, document.documentElement.scrollWidth - innerWidth]);
|
||||
assert.deepEqual(over.map((x) => Math.max(0, x)), [0, 0], "scrolls sideways: " + over);
|
||||
if (process.env.ARTIFACT_DIR) await sec.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `plugin-github-hooks-${engine}-${lang}-${width}.png`) });
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// GitHub answers after the rest of the plugins page, seconds after on a
|
||||
// slow line, and the Unofficial section wasn't drawn until it did, so it
|
||||
// read as there being no unofficial plugins (yetone: 当还没加载完的时候,
|
||||
// 压根就不显示,会让那些网慢的用户以为没有非官方插件). While
|
||||
// /api/plugins/github is held here, Discover shows the section in its
|
||||
// place, before the field, with its head, a word that it is looking and
|
||||
// cards still to come; let go, its cards come in where those were and the
|
||||
// word goes. A search while it waits shows the same. When the ask fails,
|
||||
// the section says so with Try again, which asks again. magpie answering
|
||||
// with an error beside the list (GitHub unreachable from the reader's
|
||||
// desktop: till on Discord, where the section just wasn't there) is said
|
||||
// too: with no list, in the section's place with why and Try again, which
|
||||
// has magpie ask GitHub at once (?again=1); with the cards it could give,
|
||||
// a line over them saying how many more couldn't be read, and why. English, Chinese,
|
||||
// Japanese and German, wide and 440px, in Chromium and WebKit; nothing
|
||||
// scrolls on a click. MAGPIE_WAIT_ASSETS names an older assets directory,
|
||||
// to see this fail on the code before it.
|
||||
// slow line, and its plugins weren't shown until it did, so it read as
|
||||
// there being no unofficial plugins (yetone: 当还没加载完的时候,压根就不显示,
|
||||
// 会让那些网慢的用户以为没有非官方插件). While /api/plugins/github is held
|
||||
// here, Discover's browse bar says it is looking on GitHub, and picking
|
||||
// the GitHub origin shows cards still to come; let go, its cards come in
|
||||
// and the word goes. A search while it waits says the same. When the ask
|
||||
// fails, a line says so with Try again, which asks again. magpie
|
||||
// answering with an error beside the list (GitHub unreachable from the
|
||||
// reader's desktop: till on Discord) is said too: with no list, why and
|
||||
// Try again, which has magpie ask GitHub at once (?again=1); with the
|
||||
// cards it could give, how many more couldn't be read, and why. English,
|
||||
// Chinese, Japanese and German, wide and 440px, in Chromium and WebKit;
|
||||
// nothing scrolls on a click. MAGPIE_WAIT_ASSETS names an older assets
|
||||
// directory, to see this fail on the code before it.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -99,100 +97,99 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const view = page.locator("#view-plugins");
|
||||
await view.waitFor({ state: "visible" });
|
||||
await view.locator(".pm-card", { hasText: "Zed" }).waitFor();
|
||||
const sec = view.locator(".pm-sec", { has: page.locator("h3", { hasText: w.section }) });
|
||||
return { ctx, page, view, sec, errors };
|
||||
return { ctx, page, view, errors };
|
||||
};
|
||||
// the unofficial cards: each says it is unreviewed
|
||||
const ghCards = (view) => view.locator(".pm-card:not(.ghost)", { has: view.page().locator(".pm-by .pm-chip.warn") });
|
||||
const scrolls = (page) => page.evaluate(() => [window.scrollY, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop > 0).map((e) => (e.id || e.className) + ":" + e.scrollTop)].join());
|
||||
|
||||
// held: the section is there, before the field, looking
|
||||
// held: the bar says it is looking
|
||||
const wait = held();
|
||||
const { ctx, page, view, sec, errors } = await open([wait]);
|
||||
const { ctx, page, view, errors } = await open([wait]);
|
||||
t.after(() => ctx.close());
|
||||
await sec.waitFor();
|
||||
const order = await view.locator(".pm-body > *").evaluateAll((es) => es.map((e) => e.className));
|
||||
assert.ok(order.findIndex((c) => c.includes("pm-ghsec")) < order.findIndex((c) => c.includes("pm-manual")), "before the field: " + order);
|
||||
assert.equal(await sec.getAttribute("aria-busy"), "true");
|
||||
assert.match(await sec.locator(".pm-sechead > span").first().innerText(), /magpie-plugin/);
|
||||
const look = sec.locator(".pm-ghlook");
|
||||
const look = view.locator(".pm-bar .pm-ghlook");
|
||||
await look.waitFor();
|
||||
assert.equal((await look.innerText()).trim(), w.look);
|
||||
assert.equal(await look.getAttribute("role"), "status");
|
||||
assert.equal(await sec.locator(".pm-card.ghost").count(), 3);
|
||||
// the GitHub origin picked: cards still to come
|
||||
await view.locator(".pm-bar .pm-pop").first().click();
|
||||
await page.locator(".proto-menu .pm-item", { hasText: w.section }).click();
|
||||
await view.locator(".pm-card.ghost").first().waitFor();
|
||||
assert.equal(await view.locator(".pm-card.ghost").count(), 3);
|
||||
// the light moves: a ghost's bar is animated, and each card a beat after the last
|
||||
const anim = await sec.locator(".pm-card.ghost .sk").evaluateAll((es) => es.map((e) => [getComputedStyle(e).animationName, getComputedStyle(e).animationDelay]));
|
||||
const anim = await view.locator(".pm-card.ghost .sk").evaluateAll((es) => es.map((e) => [getComputedStyle(e).animationName, getComputedStyle(e).animationDelay]));
|
||||
assert.ok(anim.every(([n]) => n === "pm-sheen"), "sheen: " + JSON.stringify(anim));
|
||||
assert.notEqual(anim[0][1], anim.at(-1)[1], "a beat apart");
|
||||
// a ghost is laid out as a card: nothing spills at this width
|
||||
for (const g of await sec.locator(".pm-card.ghost").all()) {
|
||||
for (const g of await view.locator(".pm-card.ghost").all()) {
|
||||
assert.ok(await g.evaluate((e) => e.scrollWidth <= e.clientWidth + 1 && e.getBoundingClientRect().height > 70), "ghost fits");
|
||||
}
|
||||
await shot(sec, `wait-${engine}-${lang}-${width}`);
|
||||
await shot(view, `wait-${engine}-${lang}-${width}`);
|
||||
|
||||
// a search while it waits: the same section, waiting
|
||||
// a search while it waits: still looking
|
||||
const q = view.locator(".pm-head .pm-find input");
|
||||
await q.fill("claude");
|
||||
await sec.locator(".pm-ghlook").waitFor();
|
||||
assert.equal(await sec.locator(".pm-card.ghost").count(), 3);
|
||||
await view.locator(".pm-ghlook").waitFor();
|
||||
await q.fill("");
|
||||
await sec.locator(".pm-ghlook").waitFor();
|
||||
await look.waitFor();
|
||||
|
||||
// let go: its cards in the ghosts' place, the word gone
|
||||
wait.go();
|
||||
await sec.locator(".pm-card:not(.ghost)").first().waitFor();
|
||||
assert.equal(await sec.locator(".pm-card.ghost").count(), 0);
|
||||
assert.equal(await sec.locator(".pm-ghlook").count(), 0);
|
||||
assert.equal(await sec.getAttribute("aria-busy"), null);
|
||||
assert.deepEqual(await sec.locator(".pm-card .pm-name b").allInnerTexts(), ["opencode-claude-auth", "agy-staff"]);
|
||||
await ghCards(view).first().waitFor();
|
||||
assert.equal(await view.locator(".pm-card.ghost").count(), 0);
|
||||
assert.equal(await view.locator(".pm-ghlook").count(), 0);
|
||||
assert.deepEqual((await ghCards(view).locator(".pm-name b").allInnerTexts()).sort(), ["agy-staff", "opencode-claude-auth"]);
|
||||
await page.waitForFunction(() => !document.querySelector(".pm-arrive"));
|
||||
await shot(sec, `came-${engine}-${lang}-${width}`);
|
||||
await shot(view, `came-${engine}-${lang}-${width}`);
|
||||
assert.deepEqual(errors, []);
|
||||
|
||||
// failed: said so, and Try again asks again
|
||||
const again = held();
|
||||
const f = await open(["fail", again]);
|
||||
t.after(() => f.ctx.close());
|
||||
await f.sec.locator(".pm-ghnone").waitFor();
|
||||
assert.match(await f.sec.locator(".pm-ghnone").innerText(), w.failed);
|
||||
assert.equal(await f.sec.locator(".pm-card").count(), 0);
|
||||
await shot(f.sec, `failed-${engine}-${lang}-${width}`);
|
||||
const before = await f.page.evaluate(() => [window.scrollY, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop > 0).map((e) => (e.id || e.className) + ":" + e.scrollTop)].join());
|
||||
await f.sec.getByRole("button", { name: w.again }).click();
|
||||
await f.sec.locator(".pm-ghlook").waitFor();
|
||||
assert.equal(await f.page.evaluate(() => [window.scrollY, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop > 0).map((e) => (e.id || e.className) + ":" + e.scrollTop)].join()), before, "nothing scrolls on Try again");
|
||||
const fLine = f.view.locator(".pm-ghwarn");
|
||||
await fLine.waitFor();
|
||||
assert.match(await fLine.innerText(), w.failed);
|
||||
assert.equal(await ghCards(f.view).count(), 0);
|
||||
await shot(f.view, `failed-${engine}-${lang}-${width}`);
|
||||
const before = await scrolls(f.page);
|
||||
await fLine.getByRole("button", { name: w.again }).click();
|
||||
await f.view.locator(".pm-bar .pm-ghlook").waitFor();
|
||||
assert.equal(await scrolls(f.page), before, "nothing scrolls on Try again");
|
||||
again.go();
|
||||
await f.sec.locator(".pm-card:not(.ghost)").first().waitFor();
|
||||
assert.equal(await f.sec.locator(".pm-ghnone").count(), 0);
|
||||
await ghCards(f.view).first().waitFor();
|
||||
assert.equal(await f.view.locator(".pm-ghwarn").count(), 0);
|
||||
assert.deepEqual(f.errors, []);
|
||||
|
||||
// magpie answers, but GitHub couldn't give it the list: said in
|
||||
// the section's place with why, never the section gone
|
||||
// magpie answers, but GitHub couldn't give it the list: said
|
||||
// with why
|
||||
const why = 'http://raw.githubusercontent.com/a/b/main/package.json: Get "https://raw.githubusercontent.com/a/b/main/package.json": dial tcp: i/o timeout';
|
||||
const urls = [];
|
||||
const later = held();
|
||||
const e = await open([{ json: { repos: [], topic: "magpie-plugin", error: why, missing: 12 } }, later], urls);
|
||||
t.after(() => e.ctx.close());
|
||||
await e.sec.locator(".pm-ghnone").waitFor();
|
||||
const said = await e.sec.locator(".pm-ghnone").innerText();
|
||||
const eLine = e.view.locator(".pm-ghwarn");
|
||||
await eLine.waitFor();
|
||||
const said = await eLine.innerText();
|
||||
assert.match(said, w.none);
|
||||
assert.ok(said.includes("i/o timeout"), said);
|
||||
// its reason wraps: nothing spills at this width
|
||||
assert.ok(await e.sec.evaluate((s) => s.scrollWidth <= s.clientWidth + 1), "the reason fits");
|
||||
await shot(e.sec, `unread-${engine}-${lang}-${width}`);
|
||||
assert.ok(await eLine.evaluate((s) => s.scrollWidth <= s.clientWidth + 1), "the reason fits");
|
||||
assert.ok(await e.view.evaluate((s) => s.scrollWidth <= s.clientWidth + 1), "the page fits");
|
||||
await shot(e.view, `unread-${engine}-${lang}-${width}`);
|
||||
// the search field's results say it too
|
||||
const eq = e.view.locator(".pm-head .pm-find input");
|
||||
await eq.fill("claude");
|
||||
await e.sec.locator(".pm-ghnone").waitFor();
|
||||
await eLine.waitFor();
|
||||
await eq.fill("");
|
||||
await e.sec.locator(".pm-ghnone").waitFor();
|
||||
// Try again has magpie ask GitHub at once (wheeled into sight
|
||||
// first, clear of the window's footer, as a reader would)
|
||||
const eAgain = e.sec.getByRole("button", { name: w.again });
|
||||
await e.page.mouse.move(width / 2, 300);
|
||||
for (let i = 0; i < 4; i++) await e.page.mouse.wheel(0, 400);
|
||||
await eAgain.click();
|
||||
await e.sec.locator(".pm-ghlook").waitFor();
|
||||
await eLine.waitFor();
|
||||
// Try again has magpie ask GitHub at once
|
||||
await eLine.getByRole("button", { name: w.again }).click();
|
||||
await e.view.locator(".pm-ghlook").waitFor();
|
||||
later.go();
|
||||
await e.sec.locator(".pm-card:not(.ghost)").first().waitFor();
|
||||
await ghCards(e.view).first().waitFor();
|
||||
assert.deepEqual(urls, ["/api/plugins/github", "/api/plugins/github?again=1"]);
|
||||
assert.equal(await e.sec.locator(".pm-ghwarn, .pm-ghnone").count(), 0);
|
||||
assert.equal(await e.view.locator(".pm-ghwarn").count(), 0);
|
||||
assert.deepEqual(e.errors, []);
|
||||
|
||||
// some came, some couldn't be read: the cards, and a line over
|
||||
@@ -201,30 +198,29 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const later2 = held();
|
||||
const m = await open([{ json: { repos: REPOS, topic: "magpie-plugin", error: why, missing: 12 } }, later2], urls2);
|
||||
t.after(() => m.ctx.close());
|
||||
await m.sec.locator(".pm-ghwarn").waitFor();
|
||||
assert.match(await m.sec.locator(".pm-ghwarn").innerText(), w.more);
|
||||
assert.equal(await m.sec.locator(".pm-card:not(.ghost)").count(), 2);
|
||||
assert.ok(await m.sec.evaluate((s) => s.scrollWidth <= s.clientWidth + 1), "the line fits");
|
||||
await shot(m.sec, `partial-${engine}-${lang}-${width}`);
|
||||
const mAgain = m.sec.locator(".pm-ghwarn").getByRole("button", { name: w.again });
|
||||
await m.page.mouse.move(width / 2, 300);
|
||||
for (let i = 0; i < 4; i++) await m.page.mouse.wheel(0, 400);
|
||||
await mAgain.click();
|
||||
assert.equal(await m.sec.locator(".pm-card:not(.ghost)").count(), 2, "cards kept while asking");
|
||||
const mLine = m.view.locator(".pm-ghwarn");
|
||||
await mLine.waitFor();
|
||||
assert.match(await mLine.innerText(), w.more);
|
||||
assert.equal(await ghCards(m.view).count(), 2);
|
||||
assert.ok(await mLine.evaluate((s) => s.scrollWidth <= s.clientWidth + 1), "the line fits");
|
||||
await shot(m.view, `partial-${engine}-${lang}-${width}`);
|
||||
await mLine.getByRole("button", { name: w.again }).click();
|
||||
await m.view.locator(".pm-bar .pm-ghlook").waitFor();
|
||||
assert.equal(await ghCards(m.view).count(), 2, "cards kept while asking");
|
||||
later2.go();
|
||||
await m.sec.locator(".pm-ghwarn").waitFor({ state: "detached" });
|
||||
assert.equal(await m.sec.locator(".pm-card:not(.ghost)").count(), 2);
|
||||
await m.view.locator(".pm-ghwarn").waitFor({ state: "detached" });
|
||||
await m.view.locator(".pm-ghlook").waitFor({ state: "detached" });
|
||||
assert.equal(await ghCards(m.view).count(), 2);
|
||||
assert.deepEqual(urls2, ["/api/plugins/github", "/api/plugins/github?again=1"]);
|
||||
assert.deepEqual(m.errors, []);
|
||||
|
||||
// GitHub too slow, as magpie tells it (why: "slow"): the line
|
||||
// says so in the reader's language, not Go's "no answer in 8s"
|
||||
// in the middle of the page, and the error as it came is its
|
||||
// hover (the Kiko03O1 reply on X: ui 设计能不能好看点); Try
|
||||
// again reads as a button, in the accent
|
||||
// says so in the reader's language, not Go's "no answer in 8s",
|
||||
// and the error as it came is its hover (the Kiko03O1 reply on
|
||||
// X: ui 设计能不能好看点); Try again reads as a button, in the accent
|
||||
const s = await open([{ json: { repos: REPOS, topic: "magpie-plugin", error: "no answer in 8s", why: "slow", missing: 7 } }]);
|
||||
t.after(() => s.ctx.close());
|
||||
const sLine = s.sec.locator(".pm-ghwarn");
|
||||
const sLine = s.view.locator(".pm-ghwarn");
|
||||
await sLine.waitFor();
|
||||
assert.match(await sLine.innerText(), w.slow);
|
||||
assert.doesNotMatch(await sLine.innerText(), /no answer/);
|
||||
@@ -237,11 +233,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
// line says it is from before
|
||||
const k = await open([{ json: { repos: REPOS, topic: "magpie-plugin" } }, { json: { repos: [], topic: "magpie-plugin", error: "GitHub's search: 403 rate limit" } }]);
|
||||
t.after(() => k.ctx.close());
|
||||
await k.sec.locator(".pm-card:not(.ghost)").first().waitFor();
|
||||
await ghCards(k.view).first().waitFor();
|
||||
await k.page.evaluate(() => window.loadPlugins());
|
||||
await k.sec.locator(".pm-ghwarn").waitFor();
|
||||
assert.match(await k.sec.locator(".pm-ghwarn").innerText(), /403 rate limit/);
|
||||
assert.equal(await k.sec.locator(".pm-card:not(.ghost)").count(), 2);
|
||||
await k.view.locator(".pm-ghwarn").waitFor();
|
||||
assert.match(await k.view.locator(".pm-ghwarn").innerText(), /403 rate limit/);
|
||||
assert.equal(await ghCards(k.view).count(), 2);
|
||||
assert.deepEqual(k.errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// Repositories their authors tagged magpie-plugin on GitHub (yetone: 在插件页
|
||||
//能否自动识别打了 magpie-plugin 的 github repo 来显示为非官方插件): Discover
|
||||
// shows them in a section of their own after the community's, each card
|
||||
// saying Unofficial, its owner and its stars. One whose package the market
|
||||
// shows them among the community's, by kind (Origin picks them alone),
|
||||
// each card saying Unreviewed, its owner and its stars. One whose package the market
|
||||
// already lists is the market's card alone. Install sends the spec magpie
|
||||
// gave: the npm name of one its author published there from the
|
||||
// repository, else github:owner/repo; one installed by any spec naming the
|
||||
@@ -110,32 +110,43 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const view = page.locator("#view-plugins");
|
||||
await view.waitFor({ state: "visible" });
|
||||
|
||||
// a section of their own, after the community's, before the field
|
||||
const sec = view.locator(".pm-sec", { has: page.locator("h3", { hasText: w.section }) });
|
||||
await sec.waitFor();
|
||||
// one market with the community's (the owner: 统筹起来): Origin
|
||||
// picks GitHub's alone, and they are shelved by kind like any
|
||||
await view.locator(".pm-card", { hasText: "agy-staff" }).waitFor();
|
||||
const order = await view.locator(".pm-body > *").evaluateAll((es) => es.map((e) => e.className.split(" ")[0]));
|
||||
assert.ok(order.indexOf("pm-manual") > order.lastIndexOf("pm-sec"), "the field stays last: " + order);
|
||||
assert.match(await sec.locator(".pm-sechead span").innerText(), /magpie-plugin/);
|
||||
const cards = sec.locator(".pm-card");
|
||||
assert.deepEqual(await cards.locator(".pm-name b").allInnerTexts(), ["opencode-claude-auth", "opencode-quota", "agy-staff"], "the market's own package is its card alone");
|
||||
await view.locator(".pm-bar .pm-pop").first().click();
|
||||
await page.locator(".proto-menu .pm-item", { hasText: w.section }).click();
|
||||
await page.waitForFunction(() => document.querySelectorAll("#view-plugins .pm-sec[data-kind] .pm-card").length === 3);
|
||||
const sec = view.locator(".pm-sec[data-kind]").first();
|
||||
const cards = view.locator(".pm-sec[data-kind] .pm-card");
|
||||
assert.deepEqual((await cards.locator(".pm-name b").allInnerTexts()).sort(), ["agy-staff", "opencode-claude-auth", "opencode-quota"], "the market's own package is its card alone");
|
||||
await view.locator(".pm-bar .pm-pop").first().click();
|
||||
await page.locator(".proto-menu .pm-item").first().click();
|
||||
await page.waitForFunction(() => document.querySelectorAll("#view-plugins .pm-sec[data-kind] .pm-card").length === 4);
|
||||
assert.equal(await view.locator(".pm-card", { hasText: "Open Cursor" }).count(), 1);
|
||||
await view.locator(".pm-bar .pm-pop").first().click();
|
||||
await page.locator(".proto-menu .pm-item", { hasText: w.section }).click();
|
||||
await page.waitForFunction(() => document.querySelectorAll("#view-plugins .pm-sec[data-kind] .pm-card").length === 3);
|
||||
|
||||
const c = cards.first();
|
||||
assert.equal((await c.locator(".pm-by").innerText()).trim(), "griffinmartin");
|
||||
const c = cards.filter({ hasText: "opencode-claude-auth" });
|
||||
assert.equal((await c.locator(".pm-by > span").first().innerText()).trim(), "griffinmartin");
|
||||
// the picture its package.json gives (magpie.icon), as magpie keeps it; one that gives none, the puzzle
|
||||
assert.equal(await c.locator(".pm-logo img").getAttribute("src"), "/api/icons/claude-auth.svg");
|
||||
assert.equal(await cards.nth(2).locator(".pm-logo img").count(), 0);
|
||||
assert.equal(await cards.filter({ hasText: "agy-staff" }).locator(".pm-logo img").count(), 0);
|
||||
// a provider and a middleware part by hue (yetone: 中间件和供应商稍微有点区分吧)
|
||||
assert.equal(await c.locator(".pm-chip.kind.pv").count(), 1);
|
||||
// unofficial is said by the section's head, once, not by a chip on
|
||||
// every card in it (the Kiko03O1 reply on X: ui 设计能不能好看点)
|
||||
assert.equal(await sec.locator(".pm-chip.warn").count(), 0);
|
||||
assert.equal(await sec.locator(".pm-meta", { hasText: w.chip }).count(), 0);
|
||||
// among the community's, each says nobody reviewed it: a quiet
|
||||
// outlined word by its author, not a chip in its facts (the
|
||||
// Kiko03O1 reply on X: ui 设计能不能好看点)
|
||||
assert.equal(await cards.locator(".pm-by .pm-chip.warn").count(), 3);
|
||||
assert.equal(await cards.locator(".pm-meta", { hasText: w.chip }).count(), 0);
|
||||
assert.equal((await c.locator(".pm-dl").innerText()).trim(), "1.3k");
|
||||
assert.equal((await c.locator(".pm-ver").innerText()).trim(), "v2.2.1");
|
||||
// installed by its page's URL: Installed all the same
|
||||
await cards.nth(1).locator(".pm-act.done").waitFor();
|
||||
assert.match(await cards.nth(1).locator(".pm-act").innerText(), new RegExp(w.installed));
|
||||
const quota = cards.filter({ hasText: "opencode-quota" });
|
||||
await quota.locator(".pm-act.done").waitFor();
|
||||
assert.match(await quota.locator(".pm-act").innerText(), new RegExp(w.installed));
|
||||
// nothing cut or spilling at this width
|
||||
for (const card of await cards.all()) {
|
||||
const fit = await card.evaluate((e) => [e.scrollWidth <= e.clientWidth + 1, ...[...e.querySelectorAll(".pm-chip, .pm-act, .pm-name b")].map((x) => x.getBoundingClientRect().width > 8 && x.getBoundingClientRect().right <= e.getBoundingClientRect().right + 1)]);
|
||||
@@ -154,6 +165,14 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.mouse.wheel(0, 80);
|
||||
await page.waitForTimeout(15);
|
||||
}
|
||||
// WebKit's wheel scroll goes on after the last wheel: wait for it
|
||||
// to come to rest, so what is measured next is the click's own
|
||||
for (let last = "", i = 0; i < 100; i++) {
|
||||
const now = await scrolls(page);
|
||||
if (now === last) break;
|
||||
last = now;
|
||||
await page.waitForTimeout(50);
|
||||
}
|
||||
};
|
||||
// and clicks it where it is: Playwright's own click scrolls a card
|
||||
// already in sight in Chromium at this width, as a reader's doesn't
|
||||
@@ -187,26 +206,27 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
};
|
||||
await install("opencode-claude-auth");
|
||||
assert.equal(await scrolls(page), before, "a click scrolls nothing");
|
||||
await cards.first().locator(".pm-act.done").waitFor();
|
||||
await c.locator(".pm-act.done").waitFor();
|
||||
|
||||
// one npm hasn't from its repository: GitHub's, installed from there
|
||||
await reach(cards.nth(2));
|
||||
await press(cards.nth(2));
|
||||
const agy = cards.filter({ hasText: "agy-staff" });
|
||||
await reach(agy);
|
||||
await press(agy);
|
||||
await dlg.locator(".pm-md", { hasText: "Hire agy as a staffer." }).waitFor();
|
||||
assert.deepEqual(asked.filter(([k]) => k === "page").pop(), ["page", "github:keli-wen/agy-staff"]);
|
||||
assert.match(await dlg.locator(".pm-note.warn").innerText(), w.fromGit);
|
||||
assert.equal(await dlg.locator(".pm-links a", { hasText: "npm" }).count(), 0, "npm has no page for it");
|
||||
assert.equal(await dlg.locator(".pm-links a", { hasText: "GitHub" }).getAttribute("href"), "https://github.com/keli-wen/agy-staff");
|
||||
await install("github:keli-wen/agy-staff");
|
||||
await cards.nth(2).locator(".pm-act.done").waitFor();
|
||||
await agy.locator(".pm-act.done").waitFor();
|
||||
|
||||
// a search finds them too
|
||||
await view.locator(".pm-find input").fill("quota");
|
||||
const found = view.locator(".pm-sec", { has: page.locator("h3", { hasText: w.section }) });
|
||||
const found = view.locator(".pm-sec").first();
|
||||
await page.waitForFunction(() => document.querySelectorAll("#view-plugins .pm-sec .pm-card").length === 1);
|
||||
assert.deepEqual(await found.locator(".pm-name b").allInnerTexts(), ["opencode-quota"]);
|
||||
await view.locator(".pm-find input").fill("nothing-like-it");
|
||||
await page.waitForFunction(() => !document.querySelector("#view-plugins .pm-ghsec .pm-card"));
|
||||
await page.waitForFunction(() => !document.querySelector("#view-plugins .pm-card"));
|
||||
|
||||
assert.equal(asked.filter(([k]) => k === "fetched").length, 0, "nothing fetched from outside: " + JSON.stringify(asked.filter(([k]) => k === "fetched")));
|
||||
assert.deepEqual(errors, []);
|
||||
|
||||
@@ -87,7 +87,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual(await kinds(pg), [w.page]);
|
||||
|
||||
// the way to write one: the docs in the window's language, opened outside
|
||||
const how = view.locator(".pm-intro .pm-write");
|
||||
const how = view.locator(".pm-foot .pm-write");
|
||||
assert.equal((await how.innerText()).trim(), w.write);
|
||||
assert.equal(await how.getAttribute("href"), w.docs);
|
||||
opened.length = 0;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Plugins › Discover's "Have one in mind?" box (install by name) floats at
|
||||
// the foot of the view while the cards scroll under it (0x3108 on X: with
|
||||
// many plugins it was found only after scrolling to the very end). With
|
||||
// many cards it is in sight at the top of the list and mid-way, on a strip
|
||||
// many cards (a kind picked, shown whole) it is in sight at the top of the list and mid-way, on a strip
|
||||
// that hides the cards passing under it; at the end of the list every card
|
||||
// is above it and the npm registry line is below it, as before. A card
|
||||
// reached with Tab is not left under it, and the search field still takes
|
||||
@@ -110,6 +110,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.goto("http://magpie.test/?view=plugins");
|
||||
const view = page.locator("#view-plugins");
|
||||
await view.locator(".pm-manual").waitFor();
|
||||
// Discover shows a shelf of each kind; the kind picked shows it
|
||||
// whole, the many cards this is about
|
||||
await view.locator(".pm-bar .pm-kinds .opt").nth(1).click();
|
||||
await page.waitForFunction((n) => document.querySelectorAll("#view-plugins .pm-card").length >= n, listings.length);
|
||||
await view.locator(".pm-registry").waitFor();
|
||||
|
||||
|
||||
@@ -141,10 +141,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await page.locator('#nav button[data-view="plugins"]').getAttribute("class"), "on");
|
||||
assert.match(page.url(), /view=plugins/);
|
||||
|
||||
// Discover: magpie's community's plugins alone, others' only found by a search
|
||||
// Discover: magpie's community's plugins and others' together, in
|
||||
// one shelf of their kind; another author's under their own name
|
||||
await view.locator(".pm-sechead h3", { hasText: w.ours }).waitFor();
|
||||
assert.equal(await view.locator(".pm-sec").count(), 1);
|
||||
assert.equal(await view.locator('.pm-card[data-pkg="opencode-copilot-auth"]').count(), 0);
|
||||
assert.equal(await view.locator(".pm-sec[data-kind]").count(), 1);
|
||||
assert.equal((await view.locator('.pm-sec[data-kind] .pm-card[data-pkg="opencode-copilot-auth"] .pm-by').innerText()).trim(), "thdxr");
|
||||
assert.doesNotMatch(await view.innerText(), /OpenCode 社区|OpenCode's community/);
|
||||
assert.equal(await view.locator('.pm-card[data-pkg="@magpie-community/opencode-qoder-auth"] .pm-act').innerText(), w.soon);
|
||||
assert.ok(await view.locator('.pm-card[data-pkg="@magpie-community/opencode-qoder-auth"] .pm-act').isDisabled());
|
||||
|
||||
@@ -98,14 +98,15 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
}
|
||||
});
|
||||
|
||||
// Discover says plugins can be middleware too, not only subscriptions,
|
||||
// and links to how one is written in the reader's language
|
||||
test(engine + ": Discover's intro names what a plugin can be, and how to write one", async (t) => {
|
||||
// Discover's strip of kinds says plugins can be middleware too, not only
|
||||
// subscriptions, and its foot links to how one is written in the
|
||||
// reader's language, under what installing one means
|
||||
test(engine + ": Discover names what a plugin can be, and how to write one", async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const I = {
|
||||
en: { h: "Plugins extend magpie", p: /run in magpie's gateway .* give every agent tools, connect an agent, or add a page of its own/, a: "Write a plugin", url: "https://usemagpie.ai/docs/plugins", trust: /sign-in or your requests/ },
|
||||
zh: { h: "插件扩展 magpie", p: /在 magpie 网关里处理.*给每个 Agent 提供工具.*加一个自己的页面/, a: "编写插件", url: "https://usemagpie.ai/docs/zh/plugins", trust: /登录或看到你的请求/ },
|
||||
en: { kinds: ["All", "Subscriptions", "Middleware"], a: "Write a plugin", url: "https://usemagpie.ai/docs/plugins", trust: /sign-in or your requests/ },
|
||||
zh: { kinds: ["全部", "订阅", "中间件"], a: "编写插件", url: "https://usemagpie.ai/docs/zh/plugins", trust: /登录或看到你的请求/ },
|
||||
};
|
||||
for (const lang of ["en", "zh"]) {
|
||||
await t.test(lang, async () => {
|
||||
@@ -117,18 +118,24 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server(lang));
|
||||
await page.route("**/api/open", (r) => { opened.push(r.request().postDataJSON()); return r.fulfill({ json: {} }); });
|
||||
await page.route("**/api/plugins/listings", (r) => r.fulfill({ json: { listings: [
|
||||
{ package: "@magpie-community/provider-x", name: "X plan", community: true, providers: ["x"], summary: { en: "Signs in to X" } },
|
||||
{ package: "@magpie-community/mw-alias", name: "Alias", kind: "middleware", community: true, summary: { en: "Renames models" } },
|
||||
] } }));
|
||||
await page.goto("http://magpie.test/?view=plugins");
|
||||
const intro = page.locator("#view-plugins .pm-intro");
|
||||
await intro.waitFor();
|
||||
assert.equal((await intro.locator("h2").innerText()).trim(), w.h);
|
||||
assert.match(await intro.innerText(), w.p);
|
||||
const strip = page.locator("#view-plugins .pm-bar .pm-kinds .opt");
|
||||
await strip.first().waitFor();
|
||||
// each kind with how many there are: the name before its count
|
||||
assert.deepEqual((await strip.evaluateAll((os) => os.map((o) => o.firstChild.textContent))).slice(0, 3), w.kinds);
|
||||
const intro = page.locator("#view-plugins .pm-foot");
|
||||
assert.match(await intro.locator(".pm-trust").innerText(), w.trust);
|
||||
await intro.locator("a.pm-link").scrollIntoViewIfNeeded();
|
||||
const y = await page.evaluate(() => [document.scrollingElement.scrollTop, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop).map((e) => e.scrollTop)].join());
|
||||
await intro.locator("a.pm-link", { hasText: w.a }).click();
|
||||
await page.waitForTimeout(100);
|
||||
assert.deepEqual(opened, [{ url: w.url }]);
|
||||
assert.equal(await page.evaluate(() => [document.scrollingElement.scrollTop, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop).map((e) => e.scrollTop)].join()), y, "the click scrolled nothing");
|
||||
if (process.env.ARTIFACT_DIR) await intro.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `plugin-intro-${engine}-${lang}.png`) });
|
||||
if (process.env.ARTIFACT_DIR) await intro.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `plugin-foot-${engine}-${lang}.png`) });
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await dlg.locator("h2").innerText(), w.title(old, now));
|
||||
return { dlg, before };
|
||||
};
|
||||
const ghCard = (page, owner) => page.locator("#view-plugins .pm-sec", { has: page.locator("h3", { hasText: w.section }) }).locator(".pm-card", { has: page.locator(".pm-by", { hasText: owner }) });
|
||||
const ghCard = (page, owner) => page.locator("#view-plugins .pm-sec[data-kind] .pm-card", { has: page.locator(".pm-by", { hasText: owner }) });
|
||||
|
||||
// npm's package installed: the repository's card asks
|
||||
{
|
||||
@@ -239,7 +239,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const asked = [];
|
||||
const { page, errors } = await open({ installed: [{ spec: MINE, package: PKG, off: true }], repos: [], hits: [HIT] }, asked);
|
||||
try {
|
||||
await page.locator("#view-plugins .pm-find:not(.pm-ghfind) input").fill("free-model");
|
||||
await page.locator("#view-plugins .pm-head .pm-find input").fill("free-model");
|
||||
const card = page.locator("#view-plugins .pm-sec", { has: page.locator("h3", { hasText: w.onNpm }) }).locator(".pm-card", { hasText: PKG });
|
||||
await card.locator(".pm-act.get").waitFor();
|
||||
const now = "npm:" + PKG;
|
||||
@@ -315,7 +315,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server(lang, { installed: [{ spec, package: PKG }], repos: [OWN, NAMESAKE] }, asked));
|
||||
await page.goto("http://magpie.test/?view=plugins", { timeout: 30000 });
|
||||
const sec = page.locator("#view-plugins .pm-sec", { has: page.locator("h3", { hasText: w.section }) });
|
||||
const sec = page.locator("#view-plugins .pm-sec[data-kind]");
|
||||
const own = sec.locator(".pm-card", { has: page.locator(".pm-by", { hasText: "mu-zi-lee" }) });
|
||||
const theirs = sec.locator(".pm-card", { has: page.locator(".pm-by", { hasText: "Gyarados4157" }) });
|
||||
await own.locator(".pm-act.done").waitFor();
|
||||
@@ -367,12 +367,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const view = page.locator("#view-plugins");
|
||||
await view.waitFor({ state: "visible" });
|
||||
await settled(page);
|
||||
await view.locator(".pm-find:not(.pm-ghfind) input").fill("free-model");
|
||||
await view.locator(".pm-head .pm-find input").fill("free-model");
|
||||
const npm = view.locator(".pm-sec", { has: page.locator("h3", { hasText: w.onNpm }) });
|
||||
await npm.locator(".pm-card .pm-act.get").waitFor();
|
||||
await settled(page);
|
||||
assert.deepEqual(await npm.locator(".pm-card .pm-name b").allInnerTexts(), [PKG], "npm's package of the name, and not npm's card of a repository on the page");
|
||||
assert.equal(await view.locator(".pm-sec", { has: page.locator("h3", { hasText: w.section }) }).locator(".pm-card.have").count(), 1);
|
||||
assert.equal(await view.locator(".pm-sec").first().locator(".pm-card.have").count(), 1);
|
||||
assert.deepEqual(errors, []);
|
||||
} finally { await page.close(); }
|
||||
});
|
||||
|
||||
@@ -68,7 +68,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.goto("http://magpie.test/?view=plugins");
|
||||
const [own, tip] = await page.evaluate(([l, a, b]) => l === "en" ? [a, b] : [I18N[l][a], I18N[l][b]], [lang, OWN, TIP]);
|
||||
assert.ok(own && tip, "both words are translated");
|
||||
const card = (repo) => page.locator(`#view-plugins .pm-ghsec .pm-card[data-pkg="github:someone/${repo}"]`).first();
|
||||
const card = (repo) => page.locator(`#view-plugins .pm-card[data-pkg="github:someone/${repo}"]`).first();
|
||||
|
||||
const office = card("magpie-officeace");
|
||||
await office.waitFor();
|
||||
|
||||
Reference in New Issue
Block a user