papersearch 0.4.9 → 0.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/NOTICE +23 -0
- package/README.en.md +136 -247
- package/README.md +136 -247
- package/assets/carsi-flow.en.png +0 -0
- package/assets/carsi-flow.png +0 -0
- package/assets/overview.en.png +0 -0
- package/assets/overview.png +0 -0
- package/assets/progress-capsule.en.png +0 -0
- package/assets/progress-capsule.png +0 -0
- package/carsi/README.md +6 -7
- package/carsi/paper_search_carsi/adapters/elsevier/__init__.py +1 -1
- package/carsi/paper_search_carsi/adapters/ieee/__init__.py +1 -1
- package/carsi/paper_search_carsi/adapters/iop/__init__.py +8 -2
- package/carsi/paper_search_carsi/adapters/jama/__init__.py +3 -1
- package/carsi/paper_search_carsi/adapters/karger/__init__.py +2 -1
- package/carsi/paper_search_carsi/adapters/lww/ovid.py +2 -2
- package/carsi/paper_search_carsi/adapters/oup/__init__.py +3 -4
- package/carsi/paper_search_carsi/adapters/platforms/silverchair/__init__.py +23 -0
- package/carsi/paper_search_carsi/adapters/world_scientific/__init__.py +5 -4
- package/carsi/paper_search_carsi/assets/capsule.html +134 -18
- package/carsi/paper_search_carsi/browser/backend.py +269 -233
- package/carsi/paper_search_carsi/browser/batch_session.py +42 -0
- package/carsi/paper_search_carsi/browser/challenge_interaction.py +28 -9
- package/carsi/paper_search_carsi/browser/cookies.py +8 -8
- package/carsi/paper_search_carsi/browser/driver.py +29 -0
- package/carsi/paper_search_carsi/browser/engine.py +17 -23
- package/carsi/paper_search_carsi/browser/foreground.py +21 -15
- package/carsi/paper_search_carsi/browser/login.py +12 -18
- package/carsi/paper_search_carsi/browser/preview.py +31 -12
- package/carsi/paper_search_carsi/browser/profiles.py +16 -23
- package/carsi/paper_search_carsi/browser/watchdog.py +113 -58
- package/carsi/paper_search_carsi/cli.py +22 -7
- package/carsi/paper_search_carsi/cold_start.py +65 -51
- package/carsi/paper_search_carsi/config.py +6 -4
- package/carsi/paper_search_carsi/download_diagnostics.py +2 -1
- package/carsi/paper_search_carsi/engine/batch.py +17 -7
- package/carsi/paper_search_carsi/engine/batch_capture.py +97 -31
- package/carsi/paper_search_carsi/engine/batch_common.py +56 -16
- package/carsi/paper_search_carsi/engine/batch_diagnostics.py +3 -0
- package/carsi/paper_search_carsi/engine/batch_institution.py +132 -13
- package/carsi/paper_search_carsi/engine/batch_login.py +151 -18
- package/carsi/paper_search_carsi/engine/batch_user.py +1 -1
- package/carsi/paper_search_carsi/engine/batch_waits.py +21 -7
- package/carsi/paper_search_carsi/engine/bridge.py +23 -13
- package/carsi/paper_search_carsi/engine/login_wait.py +1 -1
- package/carsi/paper_search_carsi/engine/supplements.py +36 -2
- package/carsi/paper_search_carsi/mcp_progress.py +13 -5
- package/carsi/paper_search_carsi/network.py +1 -1
- package/carsi/paper_search_carsi/progress_capsule.py +6 -2
- package/carsi/paper_search_carsi/progress_reporter.py +107 -9
- package/carsi/paper_search_carsi/progress_view.py +78 -1
- package/carsi/paper_search_carsi/server.py +53 -10
- package/carsi/paper_search_carsi/session_broker.py +1 -1
- package/carsi/pyproject.toml +7 -7
- package/dist/capabilities/journal-metrics/JournalMetricsService.d.ts.map +1 -1
- package/dist/capabilities/journal-metrics/JournalMetricsService.js +2 -1
- package/dist/capabilities/journal-metrics/JournalMetricsService.js.map +1 -1
- package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.js +6 -0
- package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.js.map +1 -1
- package/dist/capabilities/pdf-discovery/batch.d.ts +2 -0
- package/dist/capabilities/pdf-discovery/batch.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/batch.js +59 -14
- package/dist/capabilities/pdf-discovery/batch.js.map +1 -1
- package/dist/capabilities/pdf-discovery/batchSummary.d.ts +28 -0
- package/dist/capabilities/pdf-discovery/batchSummary.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/batchSummary.js +155 -0
- package/dist/capabilities/pdf-discovery/batchSummary.js.map +1 -0
- package/dist/capabilities/pdf-discovery/carsi/CarsiAttempt.d.ts +1 -0
- package/dist/capabilities/pdf-discovery/carsi/CarsiAttempt.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiAttempt.js +56 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiAttempt.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.d.ts +11 -4
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.js +114 -30
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.d.ts +6 -0
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.js +12 -0
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/index.d.ts +2 -2
- package/dist/capabilities/pdf-discovery/carsi/index.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/index.js +1 -1
- package/dist/capabilities/pdf-discovery/carsi/index.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/types.d.ts +48 -0
- package/dist/capabilities/pdf-discovery/carsi/types.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/handler.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/handler.js +11 -6
- package/dist/capabilities/pdf-discovery/handler.js.map +1 -1
- package/dist/capabilities/pdf-discovery/tiers/publisherApi.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/tiers/publisherApi.js +2 -1
- package/dist/capabilities/pdf-discovery/tiers/publisherApi.js.map +1 -1
- package/dist/capabilities/pdf-discovery/types.d.ts +3 -0
- package/dist/capabilities/pdf-discovery/types.d.ts.map +1 -1
- package/dist/cli.js +30 -15
- package/dist/cli.js.map +1 -1
- package/dist/config/ConfigService.d.ts.map +1 -1
- package/dist/config/ConfigService.js +28 -2
- package/dist/config/ConfigService.js.map +1 -1
- package/dist/config/apiKeySignup.d.ts +13 -0
- package/dist/config/apiKeySignup.d.ts.map +1 -0
- package/dist/config/apiKeySignup.js +32 -0
- package/dist/config/apiKeySignup.js.map +1 -0
- package/dist/infrastructure/runlog/failureClass.d.ts.map +1 -1
- package/dist/infrastructure/runlog/failureClass.js +4 -0
- package/dist/infrastructure/runlog/failureClass.js.map +1 -1
- package/dist/management/capability-profile/index.d.ts +7 -0
- package/dist/management/capability-profile/index.d.ts.map +1 -1
- package/dist/management/capability-profile/index.js +7 -0
- package/dist/management/capability-profile/index.js.map +1 -1
- package/dist/management/carsi/installer.d.ts +26 -14
- package/dist/management/carsi/installer.d.ts.map +1 -1
- package/dist/management/carsi/installer.js +118 -74
- package/dist/management/carsi/installer.js.map +1 -1
- package/dist/management/carsi/runtime.d.ts +12 -1
- package/dist/management/carsi/runtime.d.ts.map +1 -1
- package/dist/management/carsi/runtime.js +30 -1
- package/dist/management/carsi/runtime.js.map +1 -1
- package/dist/management/diagnostics/index.d.ts.map +1 -1
- package/dist/management/diagnostics/index.js +4 -1
- package/dist/management/diagnostics/index.js.map +1 -1
- package/dist/management/failures/exportReport.js +3 -3
- package/dist/management/reports/index.d.ts.map +1 -1
- package/dist/management/reports/index.js +6 -1
- package/dist/management/reports/index.js.map +1 -1
- package/dist/platforms/SemanticScholarSearcher.d.ts.map +1 -1
- package/dist/platforms/SemanticScholarSearcher.js +2 -1
- package/dist/platforms/SemanticScholarSearcher.js.map +1 -1
- package/package.json +3 -2
- package/skills/paper-search/SKILL.md +9 -9
- package/skills/paper-search/references/browser-download.md +7 -6
- package/skills/paper-search/references/capability-routing.md +3 -3
- package/skills/paper-search/references/carsi-setup.md +8 -7
- package/skills/paper-search/references/cli-contract.md +6 -6
- package/skills/paper-search/references/management-layer.md +3 -3
- package/skills/paper-search/references/publisher-support.md +2 -0
- package/skills/paper-search/references/troubleshooting.md +1 -2
- package/carsi/paper_search_carsi/assets/quiet-browser/api.js +0 -142
- package/carsi/paper_search_carsi/assets/quiet-browser/manifest.json +0 -24
- package/carsi/paper_search_carsi/assets/quiet-browser/schema.json +0 -1
- package/carsi/paper_search_carsi/browser/background.py +0 -68
|
@@ -8,7 +8,7 @@ import re
|
|
|
8
8
|
from typing import Any
|
|
9
9
|
from urllib.parse import urlparse
|
|
10
10
|
|
|
11
|
-
from ...engine.batch_common import _is_browser_error
|
|
11
|
+
from ...engine.batch_common import _is_browser_error, goto_retrying
|
|
12
12
|
|
|
13
13
|
HOSTS = {"ovid.com", "www.ovid.com"}
|
|
14
14
|
_ARTICLE = re.compile(r"/jnls/[^/]+/(?:abstract|fulltext|pdf)/")
|
|
@@ -47,7 +47,7 @@ class OvidSite:
|
|
|
47
47
|
if isinstance(href, str) and self.d._article_pdf_url_matches(href, result.doi):
|
|
48
48
|
self.d._event(result, "pdf_button_clicked", "ovid-article-pdf")
|
|
49
49
|
try:
|
|
50
|
-
page
|
|
50
|
+
goto_retrying(page, href, timeout_ms=self.d.pdf_timeout_ms, referer=article)
|
|
51
51
|
except Exception as exc:
|
|
52
52
|
if not _is_browser_error(exc):
|
|
53
53
|
raise
|
|
@@ -16,6 +16,7 @@ import time
|
|
|
16
16
|
from typing import Any
|
|
17
17
|
from urllib.parse import unquote, urlparse
|
|
18
18
|
|
|
19
|
+
from ...browser.driver import is_driver_error
|
|
19
20
|
from ...engine.batch_common import AWAY_WAIT_SEC, open_page
|
|
20
21
|
from ...engine.router import _append_oxford_candidates
|
|
21
22
|
from ..base import PublisherAdapter, SupplementLink, register
|
|
@@ -217,16 +218,14 @@ class OUPAdapter(PublisherAdapter):
|
|
|
217
218
|
def retryable_navigation_error(exc: Exception) -> bool:
|
|
218
219
|
if isinstance(exc, TimeoutError):
|
|
219
220
|
return True
|
|
220
|
-
if not
|
|
221
|
+
if not is_driver_error(exc):
|
|
221
222
|
return False
|
|
222
|
-
if
|
|
223
|
+
if is_driver_error(exc, "TimeoutError"):
|
|
223
224
|
return True
|
|
224
225
|
return any(marker in str(exc) for marker in (
|
|
225
226
|
"net::ERR_CONNECTION_TIMED_OUT", "net::ERR_TIMED_OUT",
|
|
226
227
|
"net::ERR_CONNECTION_RESET", "net::ERR_CONNECTION_CLOSED",
|
|
227
228
|
"net::ERR_NETWORK_CHANGED", "net::ERR_EMPTY_RESPONSE",
|
|
228
|
-
# Firefox's word for a navigation another one replaced (AJE 1985, 2026-11-02).
|
|
229
|
-
"NS_BINDING_ABORTED",
|
|
230
229
|
"Execution context was destroyed", "Frame was detached", "because of a navigation",
|
|
231
230
|
))
|
|
232
231
|
|
|
@@ -28,6 +28,29 @@ _SUPPLEMENT_ROWS_JS = """() => [...document.querySelectorAll('a[href]')].map(a =
|
|
|
28
28
|
in_section: !!a.closest('[class*="supplementary-material"], .dataSuppLink')}))"""
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
# The article toolbar's content filters ("Figures & tables", "Video", "Supplementary
|
|
32
|
+
# Material", ...): a kind the article has is marked "has-content", one it lacks "hide".
|
|
33
|
+
_CONTENT_FILTERS_JS = """() => ({
|
|
34
|
+
doi: document.querySelector('meta[name="citation_doi"]')?.content || '',
|
|
35
|
+
filters: [...document.querySelectorAll('li.article-content-filter')].map(li => ({
|
|
36
|
+
label: (li.textContent || '').replace(/\\s+/g, ' ').trim(),
|
|
37
|
+
hide: li.classList.contains('hide'), has: li.classList.contains('has-content')}))})"""
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def declares_no_supplements(page: Any, doi: str) -> bool:
|
|
41
|
+
"""This article's own Silverchair page says it has no supplementary material:
|
|
42
|
+
its "Supplementary Material" filter hidden while another kind is marked as
|
|
43
|
+
present (pubs.aip.org, whose files are otherwise found only through Figshare
|
|
44
|
+
links, 2026-11-08). Any other page says nothing."""
|
|
45
|
+
data = page.evaluate(_CONTENT_FILTERS_JS)
|
|
46
|
+
if not isinstance(data, dict) or str(data.get("doi") or "").lower() != (doi or "").lower():
|
|
47
|
+
return False
|
|
48
|
+
filters = [f for f in data.get("filters") or () if isinstance(f, dict)]
|
|
49
|
+
supplements = [f for f in filters if re.fullmatch(r"supplementary (?:material|data)", str(f.get("label") or ""), re.I)]
|
|
50
|
+
return (bool(supplements) and all(f.get("hide") and not f.get("has") for f in supplements)
|
|
51
|
+
and any(f.get("has") for f in filters))
|
|
52
|
+
|
|
53
|
+
|
|
31
54
|
def supplement_links(page: Any, doi: str, hosts: frozenset[str]) -> list[SupplementLink]:
|
|
32
55
|
"""This article's supplementary files on a Silverchair page: Silverchair's own
|
|
33
56
|
address ``/<journal>/article-supplement/<article id>/<type>/<name>/`` on the
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
(``platforms/atypon``): its pages carry Literatum's markers and cookies
|
|
3
3
|
(2026-11-03; no public announcement found).
|
|
4
4
|
|
|
5
|
-
Its
|
|
6
|
-
|
|
7
|
-
address without it is a redirect that stalled.
|
|
5
|
+
Its chooser at ``/action/ssostart`` shows either the institution search or
|
|
6
|
+
lists for the federation and the institution.
|
|
8
7
|
"""
|
|
9
8
|
from __future__ import annotations
|
|
10
9
|
|
|
@@ -22,6 +21,8 @@ class WorldScientificAdapter(AtyponAdapter):
|
|
|
22
21
|
def chooser_block_reason(self, page: Any, url: str, text: str) -> str | None:
|
|
23
22
|
if "worldscientific.com/action/ssostart" not in url:
|
|
24
23
|
return None
|
|
25
|
-
if "find your institution"
|
|
24
|
+
if any(label in text for label in ("find your institution", "type the name of your institution",
|
|
25
|
+
"select your federation", "select your institution",
|
|
26
|
+
"china cernet federation (carsi)")):
|
|
26
27
|
return ""
|
|
27
28
|
return "sso_redirect_stalled"
|
|
@@ -60,6 +60,8 @@ body.grow-up #root.animating > .surface { top: auto; bottom: 0; }
|
|
|
60
60
|
|
|
61
61
|
.attention-target { appearance: none; box-sizing: content-box; padding: 0; border: none; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
62
62
|
.pill-prompt { display: inline-flex; align-items: center; gap: 8px; }
|
|
63
|
+
.attention-countdown { font-variant-numeric: tabular-nums; }
|
|
64
|
+
.attention-countdown:empty { display: none; }
|
|
63
65
|
.attention-target:focus-visible { outline: 2px solid var(--warn-dot); outline-offset: -2px; border-radius: 8px; }
|
|
64
66
|
.pillrow { display: flex; align-items: center; gap: 8px; padding: 5px 14px 5px 6px; white-space: nowrap; height: 28px; }
|
|
65
67
|
.pillrow.icon-first { padding-left: 12px; }
|
|
@@ -84,6 +86,10 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
84
86
|
.paper .name { line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
|
85
87
|
.paper .where { color: var(--faint); font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
86
88
|
.paper .notice { color: var(--accent); font-size: 12px; margin-top: 3px; }
|
|
89
|
+
.paper-link { display: block; width: 100%; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; border-radius: 6px; }
|
|
90
|
+
.paper-link .name, .paper-link .where, .paper-link .notice { display: block; }
|
|
91
|
+
.paper-link:hover .name { text-decoration: underline; }
|
|
92
|
+
.paper-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
87
93
|
.steps { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
|
|
88
94
|
.steps .bars { display: flex; gap: 3px; flex: 1; }
|
|
89
95
|
.steps .bars span { flex: 1; height: 3px; border-radius: 2px; background: var(--track); }
|
|
@@ -136,6 +142,32 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
136
142
|
.attention-head { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; color: var(--fg); }
|
|
137
143
|
.attention-head b { flex: 1; font-size: 12px; }
|
|
138
144
|
#root.card.warn { background: var(--bg); }
|
|
145
|
+
|
|
146
|
+
/* The finished card: totals, failures by reason, what was saved. No text wraps. */
|
|
147
|
+
.done-stats { margin-top: 12px; }
|
|
148
|
+
.sec { margin-top: 14px; }
|
|
149
|
+
.sec-h { display: flex; align-items: baseline; gap: 6px; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
|
|
150
|
+
.sec-h b { color: var(--fg); font-weight: 600; font-size: 13px; }
|
|
151
|
+
.saved-line { font-size: 12px; color: var(--dim); line-height: 1.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
152
|
+
.grp { border-top: 0.5px solid var(--line); padding: 8px 0; }
|
|
153
|
+
.grp:last-child { border-bottom: 0.5px solid var(--line); }
|
|
154
|
+
.grp .row { display: flex; align-items: center; gap: 6px; width: 100%; padding: 0; border: none; background: none;
|
|
155
|
+
font: inherit; color: inherit; text-align: left; white-space: nowrap; cursor: pointer; }
|
|
156
|
+
.grp .row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
|
|
157
|
+
.grp .row .reason { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
158
|
+
.grp .row .n { font-weight: 600; }
|
|
159
|
+
.grp .row svg.i { width: 14px; height: 14px; color: var(--faint); }
|
|
160
|
+
.grp .m { font-size: 12px; color: var(--faint); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
161
|
+
.paper-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 196px; overflow-y: auto; }
|
|
162
|
+
.paper-list.scroll { -webkit-mask-image: linear-gradient(to bottom, #000 80%, transparent); mask-image: linear-gradient(to bottom, #000 80%, transparent); }
|
|
163
|
+
.paper-list li { font-size: 12px; padding: 3px 0; }
|
|
164
|
+
.paper-list .t, .paper-list .w { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
165
|
+
.paper-list .w, .paper-list .more { color: var(--faint); }
|
|
166
|
+
.tag { display: inline-block; font-size: 11px; line-height: 16px; padding: 0 6px; border-radius: 5px; flex: none; }
|
|
167
|
+
.tag.no_access, .tag.other { background: var(--hover); color: var(--fg); }
|
|
168
|
+
.tag.user_or_external { background: var(--warn-bg); color: var(--warn); }
|
|
169
|
+
.tag.unsupported { background: rgba(37, 99, 235, 0.12); color: var(--accent); }
|
|
170
|
+
.tag.unexplained { background: rgba(220, 38, 38, 0.12); color: var(--bad); }
|
|
139
171
|
</style>
|
|
140
172
|
</head>
|
|
141
173
|
<body>
|
|
@@ -155,6 +187,7 @@ const ICONS = {
|
|
|
155
187
|
dots: '<circle cx="6" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="18" cy="12" r="1"/>',
|
|
156
188
|
left: '<path d="M15 6l-6 6 6 6"/>',
|
|
157
189
|
right: '<path d="M9 6l6 6-6 6"/>',
|
|
190
|
+
down: '<path d="M6 9l6 6 6-6"/>',
|
|
158
191
|
gear: gearPath(),
|
|
159
192
|
};
|
|
160
193
|
function gearPath() {
|
|
@@ -193,7 +226,7 @@ function pill() {
|
|
|
193
226
|
const a = v.attention;
|
|
194
227
|
return '<div class="pillrow icon-first capsule-drag-region">' + icon(a.login ? "lock" : "shield")
|
|
195
228
|
+ '<button type="button" class="pill-prompt attention-target" data-act="show_browser" title="点击切到下载浏览器" aria-label="打开下载浏览器">'
|
|
196
|
-
+
|
|
229
|
+
+ '<b>' + esc(a.short) + '</b><span class="attention-countdown"></span></button></div>';
|
|
197
230
|
}
|
|
198
231
|
if (v.mode === "done") {
|
|
199
232
|
// "完成 38/40 2 篇失败": papers saved out of all; a check unless nothing was saved.
|
|
@@ -225,9 +258,14 @@ function header(title, sub, closable) {
|
|
|
225
258
|
function paperBlock() {
|
|
226
259
|
const v = V;
|
|
227
260
|
const note = flash.text && Date.now() < flash.until ? flash.text : v.notice;
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
261
|
+
// The paper being downloaded: a click shows its browser while it has one (user request, 2026-11-08).
|
|
262
|
+
const tag = v.browser ? "span" : "div";
|
|
263
|
+
let html = '<div class="paper">' + (v.browser
|
|
264
|
+
? '<button type="button" class="paper-link" data-act="show_browser" title="点击切到下载浏览器" aria-label="切到下载浏览器">' : "")
|
|
265
|
+
+ "<" + tag + ' class="name">' + esc(v.title || v.current || "") + "</" + tag + ">";
|
|
266
|
+
html += note ? "<" + tag + ' class="notice">' + esc(note) + "</" + tag + ">"
|
|
267
|
+
: (v.where ? "<" + tag + ' class="where">' + esc(v.where) + (v.title && v.current ? " · " + esc(v.current) : "") + "</" + tag + ">" : "");
|
|
268
|
+
if (v.browser) html += "</button>";
|
|
231
269
|
if (v.step) {
|
|
232
270
|
html += '<div class="steps"><div class="bars">' + v.steps.map((_, i) =>
|
|
233
271
|
"<span" + (i < v.step.index ? ' class="done"' : i === v.step.index ? ' class="now"' : "") + "></span>").join("")
|
|
@@ -275,12 +313,10 @@ function runningCard() {
|
|
|
275
313
|
function attentionCard() {
|
|
276
314
|
const a = V.attention;
|
|
277
315
|
const title = a.short;
|
|
278
|
-
const detail = [a.message, a.remaining ? "剩 " + a.remaining : "",
|
|
279
|
-
a.more ? "另有 " + a.more + " 项" : ""].filter(Boolean).join(" · ");
|
|
280
316
|
let html = '<div class="card-body"><div class="attention-head capsule-drag-region"><b>PaperSearch</b>'
|
|
281
317
|
+ '<button class="iconbtn" data-act="minimize" aria-label="最小化">' + icon("minimize") + '</button>'
|
|
282
318
|
+ '<button class="iconbtn" data-act="close" aria-label="关闭">' + icon("close") + '</button></div>'
|
|
283
|
-
+ '<button type="button" class="prompt attention-target" data-act="show_browser"
|
|
319
|
+
+ '<button type="button" class="prompt attention-target" data-act="show_browser" aria-label="打开下载浏览器">' + icon(a.login ? "lock" : "alert")
|
|
284
320
|
+ '<div class="attention-copy"><div class="t">' + esc(title) + '</div><div class="s">点击打开浏览器,查看并继续</div></div><span class="attention-arrow" aria-hidden="true">›</span></button>';
|
|
285
321
|
if (panel === "confirm") return html + actionsBlock() + "</div>";
|
|
286
322
|
html += '<div class="actions"><button class="iconbtn" data-act="settings" aria-label="设置">' + icon("gear")
|
|
@@ -292,12 +328,53 @@ function attentionCard() {
|
|
|
292
328
|
return html + "</div></div>";
|
|
293
329
|
}
|
|
294
330
|
|
|
331
|
+
const CLASS_TAGS = { no_access: "没权限", user_or_external: "外部原因", unsupported: "暂不支持", unexplained: "原因不明", other: "其他" };
|
|
332
|
+
let openGroups = null, groupsRun = ""; // null: each reason row as the view opens it
|
|
333
|
+
// Main-text rows first, then the supplementary files' rows, numbered on.
|
|
334
|
+
function allGroups() { return V.summary.groups.concat(V.summary.supplement_groups || []); }
|
|
335
|
+
function groupOpen(i) {
|
|
336
|
+
if (groupsRun !== V.run_id) { openGroups = null; groupsRun = V.run_id; }
|
|
337
|
+
return openGroups ? openGroups.has(i) : !!(allGroups()[i] || {}).open;
|
|
338
|
+
}
|
|
339
|
+
function toggleGroup(i) {
|
|
340
|
+
const opened = !groupOpen(i);
|
|
341
|
+
openGroups = new Set(opened ? [i] : []); // one reason open at a time
|
|
342
|
+
render(true);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function reasonRow(g, i, brief) {
|
|
346
|
+
const opened = groupOpen(i);
|
|
347
|
+
let html = '<div class="grp"><button type="button" class="row" data-act="group" data-group="' + i + '" aria-expanded="' + opened + '">'
|
|
348
|
+
+ '<span class="tag ' + esc(g.cls) + '">' + esc(CLASS_TAGS[g.cls] || "") + '</span><span class="reason">' + esc(g.reason) + "</span>"
|
|
349
|
+
+ '<span class="n">' + g.count + " 篇</span>" + icon(opened ? "down" : "right") + "</button>";
|
|
350
|
+
if (!opened) return html + (g.where && !brief ? '<div class="m">' + esc(g.where) + "</div>" : "") + "</div>";
|
|
351
|
+
return html + '<ul class="paper-list' + (g.papers.length > 5 ? " scroll" : "") + '">'
|
|
352
|
+
+ g.papers.map((p) => '<li><div class="t">' + esc(p.title) + "</div>" + (p.where ? '<div class="w">' + esc(p.where) + "</div>" : "") + "</li>").join("")
|
|
353
|
+
+ (g.more ? '<li class="more">另有 ' + g.more + " 篇未列出</li>" : "") + "</ul></div>";
|
|
354
|
+
}
|
|
355
|
+
|
|
295
356
|
function doneCard() {
|
|
296
|
-
const v = V;
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
+ (v.
|
|
300
|
-
+
|
|
357
|
+
const v = V, s = v.summary;
|
|
358
|
+
let html = '<div class="card-body">' + header(v.headline, v.total ? "共 " + v.total + " 篇" : "", true)
|
|
359
|
+
+ '<div class="stats done-stats"><div><b style="color:var(--ok)">' + v.ok + "</b><span>成功</span></div>"
|
|
360
|
+
+ '<div><b' + (v.bad ? ' style="color:var(--bad)"' : "") + ">" + v.bad + "</b><span>失败</span></div>"
|
|
361
|
+
+ "<div><b>" + esc(v.elapsed || "—") + "</b><span>用时</span></div></div>";
|
|
362
|
+
if (s && s.groups.length) {
|
|
363
|
+
const apart = s.supplement_groups && s.supplement_groups.length;
|
|
364
|
+
html += '<div class="sec"><div class="sec-h"><b>' + (apart ? "正文未下到 " : "未完成 ") + v.bad + " 篇</b><span>按原因</span></div>"
|
|
365
|
+
+ s.groups.map((g, i) => reasonRow(g, i)).join("") + "</div>";
|
|
366
|
+
}
|
|
367
|
+
// Main text and supplementary files apart, kept short: closed rows, no journal line (user, 2026-11-08).
|
|
368
|
+
if (s && s.supplement_groups && s.supplement_groups.length) {
|
|
369
|
+
html += '<div class="sec"><div class="sec-h"><b>附录未下全 ' + s.supplement_missing + " 篇</b><span>正文已保存</span></div>"
|
|
370
|
+
+ s.supplement_groups.map((g, i) => reasonRow(g, s.groups.length + i, true)).join("") + "</div>";
|
|
371
|
+
}
|
|
372
|
+
if (s && v.ok) {
|
|
373
|
+
html += '<div class="sec"><div class="sec-h"><b>已完成 ' + v.ok + " 篇</b></div>"
|
|
374
|
+
+ s.saved.map((line) => '<div class="saved-line">' + esc(line) + "</div>").join("") + "</div>";
|
|
375
|
+
}
|
|
376
|
+
if (v.completion_detail) html += '<div class="line">' + esc(v.completion_detail) + "</div>";
|
|
377
|
+
return html + (v.folder ? '<div class="actions"><button class="btn link" data-act="folder">' + icon("folder") + "打开文件夹</button></div>" : "")
|
|
301
378
|
+ "</div>";
|
|
302
379
|
}
|
|
303
380
|
|
|
@@ -329,6 +406,19 @@ function settingsCard() {
|
|
|
329
406
|
|
|
330
407
|
let lastCls = "", hovering = false, closing = false, dragging = false, endingDrag = false;
|
|
331
408
|
let dragReady = Promise.resolve();
|
|
409
|
+
let attentionPointer = null;
|
|
410
|
+
let renderedAttention = null;
|
|
411
|
+
|
|
412
|
+
function updateAttentionCountdown() {
|
|
413
|
+
const a = V.attention;
|
|
414
|
+
const card = root.querySelector(".prompt.attention-target");
|
|
415
|
+
if (card) card.title = [a.message, a.remaining ? "剩 " + a.remaining : "",
|
|
416
|
+
a.more ? "另有 " + a.more + " 项" : ""].filter(Boolean).join(" · ");
|
|
417
|
+
const countdown = root.querySelector(".attention-countdown");
|
|
418
|
+
if (!countdown || countdown.textContent === (a.remaining || "")) return false;
|
|
419
|
+
countdown.textContent = a.remaining || "";
|
|
420
|
+
return true;
|
|
421
|
+
}
|
|
332
422
|
|
|
333
423
|
function render(force) {
|
|
334
424
|
if (closing || dragging) return;
|
|
@@ -341,12 +431,21 @@ function render(force) {
|
|
|
341
431
|
else if (V.mode === "done") html = doneCard();
|
|
342
432
|
else html = idleCard();
|
|
343
433
|
const cls = shape + (V.mode === "attention" && panel !== "settings" ? " warn" : "");
|
|
344
|
-
|
|
434
|
+
const attention = V.mode === "attention" && panel !== "settings";
|
|
435
|
+
const sameTask = !attention || (renderedAttention?.current === V.current
|
|
436
|
+
&& renderedAttention?.run_id === V.run_id);
|
|
437
|
+
const unchanged = !force && sameTask && html === lastHtml && cls === lastCls;
|
|
438
|
+
// Keep the real button (and its pointer/focus target) through countdown ticks.
|
|
439
|
+
if (unchanged && (!attention || !updateAttentionCountdown())) return;
|
|
345
440
|
const previous = root.getBoundingClientRect();
|
|
346
441
|
root.style.width = ""; root.style.height = "";
|
|
347
442
|
root.style.removeProperty("--content-max-height");
|
|
348
|
-
|
|
349
|
-
|
|
443
|
+
if (!unchanged) {
|
|
444
|
+
root.className = cls + " capsule-drag-region" + (cls !== lastCls ? " fade" : "");
|
|
445
|
+
root.innerHTML = '<div class="surface">' + html + "</div>";
|
|
446
|
+
if (attention) updateAttentionCountdown();
|
|
447
|
+
renderedAttention = attention ? V : null;
|
|
448
|
+
}
|
|
350
449
|
lastHtml = html;
|
|
351
450
|
lastCls = cls;
|
|
352
451
|
fit(previous);
|
|
@@ -437,6 +536,7 @@ async function act(action, target) {
|
|
|
437
536
|
case "minimize": open = false; panel = ""; render(true); return api().minimize(); // back as a capsule when restored
|
|
438
537
|
case "close": closing = true; ++fitGeneration; clearInterval(pollTimer); clearTimeout(hoverTimer); clearTimeout(leaveTimer); return api().request_close(); // no call left waiting on a closed page
|
|
439
538
|
case "folder": return api().open_folder();
|
|
539
|
+
case "group": return toggleGroup(Number(target.dataset.group));
|
|
440
540
|
case "show_browser": {
|
|
441
541
|
try { await inputActivation; }
|
|
442
542
|
catch (error) { return say("未能激活进度窗口,请重试"); }
|
|
@@ -491,9 +591,14 @@ async function act(action, target) {
|
|
|
491
591
|
}
|
|
492
592
|
}
|
|
493
593
|
|
|
494
|
-
|
|
594
|
+
// A paper list scrolls; pressing in it must not drag the window.
|
|
595
|
+
const interactive = (target) => target.closest('button, input, select, textarea, a, [contenteditable="true"], [role="button"], .paper-list');
|
|
495
596
|
root.addEventListener("pointerdown", (event) => {
|
|
496
597
|
if (event.button === 0 && api().activate_on_input) inputActivation = api().activate_on_input();
|
|
598
|
+
if (event.button === 0 && event.target.closest(".attention-target")) {
|
|
599
|
+
attentionPointer = event.pointerId;
|
|
600
|
+
clearTimeout(hoverTimer); clearTimeout(leaveTimer);
|
|
601
|
+
}
|
|
497
602
|
if (event.button !== 0 || interactive(event.target)) return;
|
|
498
603
|
dragging = true;
|
|
499
604
|
++hoverRequest;
|
|
@@ -555,7 +660,7 @@ function setHover(inside, force = false) {
|
|
|
555
660
|
if (!force && hovering === inside && (!inside || open)) return;
|
|
556
661
|
hovering = inside;
|
|
557
662
|
clearTimeout(hoverTimer); clearTimeout(leaveTimer);
|
|
558
|
-
if (dragging) return;
|
|
663
|
+
if (dragging || attentionPointer !== null) return;
|
|
559
664
|
if (inside) {
|
|
560
665
|
hoverTimer = setTimeout(() => { if (!open) { open = true; render(true); } }, 100);
|
|
561
666
|
} else {
|
|
@@ -586,7 +691,18 @@ async function observeHover(inside, force = false) {
|
|
|
586
691
|
setHover(pointer.inside, force);
|
|
587
692
|
}
|
|
588
693
|
root.addEventListener("mouseenter", () => observeHover(true));
|
|
589
|
-
root.addEventListener("mouseleave", () =>
|
|
694
|
+
root.addEventListener("mouseleave", () => {
|
|
695
|
+
attentionPointer = null;
|
|
696
|
+
observeHover(false);
|
|
697
|
+
});
|
|
698
|
+
function endAttentionPress(event) {
|
|
699
|
+
if (attentionPointer === null || (event.pointerId !== undefined && attentionPointer !== event.pointerId)) return;
|
|
700
|
+
attentionPointer = null;
|
|
701
|
+
observeHover(root.matches(":hover"), true);
|
|
702
|
+
}
|
|
703
|
+
window.addEventListener("pointerup", endAttentionPress);
|
|
704
|
+
window.addEventListener("pointercancel", endAttentionPress);
|
|
705
|
+
window.addEventListener("blur", endAttentionPress);
|
|
590
706
|
document.addEventListener("keydown", (event) => {
|
|
591
707
|
if (event.key === "Escape" && panel) { panel = ""; render(true); }
|
|
592
708
|
if (event.key === "Enter" && panel === "settings") act("save");
|