@ggboy123/dsh-paper-reader 1.12.1 → 1.13.1
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/README.md +1 -1
- package/dist/babeldoc-install.js +169 -12
- package/dist/harness-translate.js +20 -2
- package/dist/translate.js +80 -2
- package/lib/client.js +20 -13
- package/package.json +1 -1
- package/reader/index.html +101 -4
- package/reader/vendor/78-EUC-H.bcmap +0 -0
- package/reader/vendor/78-EUC-V.bcmap +0 -0
- package/reader/vendor/78-H.bcmap +0 -0
- package/reader/vendor/78-RKSJ-H.bcmap +0 -0
- package/reader/vendor/78-RKSJ-V.bcmap +0 -0
- package/reader/vendor/78-V.bcmap +0 -0
- package/reader/vendor/78ms-RKSJ-H.bcmap +0 -0
- package/reader/vendor/78ms-RKSJ-V.bcmap +0 -0
- package/reader/vendor/83pv-RKSJ-H.bcmap +0 -0
- package/reader/vendor/90ms-RKSJ-H.bcmap +0 -0
- package/reader/vendor/90ms-RKSJ-V.bcmap +0 -0
- package/reader/vendor/90msp-RKSJ-H.bcmap +0 -0
- package/reader/vendor/90msp-RKSJ-V.bcmap +0 -0
- package/reader/vendor/90pv-RKSJ-H.bcmap +0 -0
- package/reader/vendor/90pv-RKSJ-V.bcmap +0 -0
- package/reader/vendor/Add-H.bcmap +0 -0
- package/reader/vendor/Add-RKSJ-H.bcmap +0 -0
- package/reader/vendor/Add-RKSJ-V.bcmap +0 -0
- package/reader/vendor/Add-V.bcmap +0 -0
- package/reader/vendor/Adobe-CNS1-0.bcmap +0 -0
- package/reader/vendor/Adobe-CNS1-1.bcmap +0 -0
- package/reader/vendor/Adobe-CNS1-2.bcmap +0 -0
- package/reader/vendor/Adobe-CNS1-3.bcmap +0 -0
- package/reader/vendor/Adobe-CNS1-4.bcmap +0 -0
- package/reader/vendor/Adobe-CNS1-5.bcmap +0 -0
- package/reader/vendor/Adobe-CNS1-6.bcmap +0 -0
- package/reader/vendor/Adobe-CNS1-UCS2.bcmap +0 -0
- package/reader/vendor/Adobe-GB1-0.bcmap +0 -0
- package/reader/vendor/Adobe-GB1-1.bcmap +0 -0
- package/reader/vendor/Adobe-GB1-2.bcmap +0 -0
- package/reader/vendor/Adobe-GB1-3.bcmap +0 -0
- package/reader/vendor/Adobe-GB1-4.bcmap +0 -0
- package/reader/vendor/Adobe-GB1-5.bcmap +0 -0
- package/reader/vendor/Adobe-GB1-UCS2.bcmap +0 -0
- package/reader/vendor/Adobe-Japan1-0.bcmap +0 -0
- package/reader/vendor/Adobe-Japan1-1.bcmap +0 -0
- package/reader/vendor/Adobe-Japan1-2.bcmap +0 -0
- package/reader/vendor/Adobe-Japan1-3.bcmap +0 -0
- package/reader/vendor/Adobe-Japan1-4.bcmap +0 -0
- package/reader/vendor/Adobe-Japan1-5.bcmap +0 -0
- package/reader/vendor/Adobe-Japan1-6.bcmap +0 -0
- package/reader/vendor/Adobe-Japan1-UCS2.bcmap +0 -0
- package/reader/vendor/Adobe-Korea1-0.bcmap +0 -0
- package/reader/vendor/Adobe-Korea1-1.bcmap +0 -0
- package/reader/vendor/Adobe-Korea1-2.bcmap +0 -0
- package/reader/vendor/Adobe-Korea1-UCS2.bcmap +0 -0
- package/reader/vendor/B5-H.bcmap +0 -0
- package/reader/vendor/B5-V.bcmap +0 -0
- package/reader/vendor/B5pc-H.bcmap +0 -0
- package/reader/vendor/B5pc-V.bcmap +0 -0
- package/reader/vendor/CNS-EUC-H.bcmap +0 -0
- package/reader/vendor/CNS-EUC-V.bcmap +0 -0
- package/reader/vendor/CNS1-H.bcmap +0 -0
- package/reader/vendor/CNS1-V.bcmap +0 -0
- package/reader/vendor/CNS2-H.bcmap +0 -0
- package/reader/vendor/CNS2-V.bcmap +3 -0
- package/reader/vendor/ETHK-B5-H.bcmap +0 -0
- package/reader/vendor/ETHK-B5-V.bcmap +0 -0
- package/reader/vendor/ETen-B5-H.bcmap +0 -0
- package/reader/vendor/ETen-B5-V.bcmap +0 -0
- package/reader/vendor/ETenms-B5-H.bcmap +3 -0
- package/reader/vendor/ETenms-B5-V.bcmap +0 -0
- package/reader/vendor/EUC-H.bcmap +0 -0
- package/reader/vendor/EUC-V.bcmap +0 -0
- package/reader/vendor/Ext-H.bcmap +0 -0
- package/reader/vendor/Ext-RKSJ-H.bcmap +0 -0
- package/reader/vendor/Ext-RKSJ-V.bcmap +0 -0
- package/reader/vendor/Ext-V.bcmap +0 -0
- package/reader/vendor/GB-EUC-H.bcmap +0 -0
- package/reader/vendor/GB-EUC-V.bcmap +0 -0
- package/reader/vendor/GB-H.bcmap +4 -0
- package/reader/vendor/GB-V.bcmap +0 -0
- package/reader/vendor/GBK-EUC-H.bcmap +0 -0
- package/reader/vendor/GBK-EUC-V.bcmap +0 -0
- package/reader/vendor/GBK2K-H.bcmap +0 -0
- package/reader/vendor/GBK2K-V.bcmap +0 -0
- package/reader/vendor/GBKp-EUC-H.bcmap +0 -0
- package/reader/vendor/GBKp-EUC-V.bcmap +0 -0
- package/reader/vendor/GBT-EUC-H.bcmap +0 -0
- package/reader/vendor/GBT-EUC-V.bcmap +0 -0
- package/reader/vendor/GBT-H.bcmap +0 -0
- package/reader/vendor/GBT-V.bcmap +0 -0
- package/reader/vendor/GBTpc-EUC-H.bcmap +0 -0
- package/reader/vendor/GBTpc-EUC-V.bcmap +0 -0
- package/reader/vendor/GBpc-EUC-H.bcmap +0 -0
- package/reader/vendor/GBpc-EUC-V.bcmap +0 -0
- package/reader/vendor/H.bcmap +0 -0
- package/reader/vendor/HKdla-B5-H.bcmap +0 -0
- package/reader/vendor/HKdla-B5-V.bcmap +0 -0
- package/reader/vendor/HKdlb-B5-H.bcmap +0 -0
- package/reader/vendor/HKdlb-B5-V.bcmap +0 -0
- package/reader/vendor/HKgccs-B5-H.bcmap +0 -0
- package/reader/vendor/HKgccs-B5-V.bcmap +0 -0
- package/reader/vendor/HKm314-B5-H.bcmap +0 -0
- package/reader/vendor/HKm314-B5-V.bcmap +0 -0
- package/reader/vendor/HKm471-B5-H.bcmap +0 -0
- package/reader/vendor/HKm471-B5-V.bcmap +0 -0
- package/reader/vendor/HKscs-B5-H.bcmap +0 -0
- package/reader/vendor/HKscs-B5-V.bcmap +0 -0
- package/reader/vendor/Hankaku.bcmap +0 -0
- package/reader/vendor/Hiragana.bcmap +0 -0
- package/reader/vendor/KSC-EUC-H.bcmap +0 -0
- package/reader/vendor/KSC-EUC-V.bcmap +0 -0
- package/reader/vendor/KSC-H.bcmap +0 -0
- package/reader/vendor/KSC-Johab-H.bcmap +0 -0
- package/reader/vendor/KSC-Johab-V.bcmap +0 -0
- package/reader/vendor/KSC-V.bcmap +0 -0
- package/reader/vendor/KSCms-UHC-H.bcmap +0 -0
- package/reader/vendor/KSCms-UHC-HW-H.bcmap +0 -0
- package/reader/vendor/KSCms-UHC-HW-V.bcmap +0 -0
- package/reader/vendor/KSCms-UHC-V.bcmap +0 -0
- package/reader/vendor/KSCpc-EUC-H.bcmap +0 -0
- package/reader/vendor/KSCpc-EUC-V.bcmap +0 -0
- package/reader/vendor/Katakana.bcmap +0 -0
- package/reader/vendor/LICENSE_PDFJS_JBIG2 +13 -0
- package/reader/vendor/LICENSE_PDFJS_OPENJPEG +22 -0
- package/reader/vendor/NWP-H.bcmap +0 -0
- package/reader/vendor/NWP-V.bcmap +0 -0
- package/reader/vendor/RKSJ-H.bcmap +0 -0
- package/reader/vendor/RKSJ-V.bcmap +0 -0
- package/reader/vendor/Roman.bcmap +0 -0
- package/reader/vendor/UniCNS-UCS2-H.bcmap +0 -0
- package/reader/vendor/UniCNS-UCS2-V.bcmap +0 -0
- package/reader/vendor/UniCNS-UTF16-H.bcmap +0 -0
- package/reader/vendor/UniCNS-UTF16-V.bcmap +0 -0
- package/reader/vendor/UniCNS-UTF32-H.bcmap +0 -0
- package/reader/vendor/UniCNS-UTF32-V.bcmap +0 -0
- package/reader/vendor/UniCNS-UTF8-H.bcmap +0 -0
- package/reader/vendor/UniCNS-UTF8-V.bcmap +0 -0
- package/reader/vendor/UniGB-UCS2-H.bcmap +0 -0
- package/reader/vendor/UniGB-UCS2-V.bcmap +0 -0
- package/reader/vendor/UniGB-UTF16-H.bcmap +0 -0
- package/reader/vendor/UniGB-UTF16-V.bcmap +0 -0
- package/reader/vendor/UniGB-UTF32-H.bcmap +0 -0
- package/reader/vendor/UniGB-UTF32-V.bcmap +0 -0
- package/reader/vendor/UniGB-UTF8-H.bcmap +0 -0
- package/reader/vendor/UniGB-UTF8-V.bcmap +0 -0
- package/reader/vendor/UniJIS-UCS2-H.bcmap +0 -0
- package/reader/vendor/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/reader/vendor/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/reader/vendor/UniJIS-UCS2-V.bcmap +0 -0
- package/reader/vendor/UniJIS-UTF16-H.bcmap +0 -0
- package/reader/vendor/UniJIS-UTF16-V.bcmap +0 -0
- package/reader/vendor/UniJIS-UTF32-H.bcmap +0 -0
- package/reader/vendor/UniJIS-UTF32-V.bcmap +0 -0
- package/reader/vendor/UniJIS-UTF8-H.bcmap +0 -0
- package/reader/vendor/UniJIS-UTF8-V.bcmap +0 -0
- package/reader/vendor/UniJIS2004-UTF16-H.bcmap +0 -0
- package/reader/vendor/UniJIS2004-UTF16-V.bcmap +0 -0
- package/reader/vendor/UniJIS2004-UTF32-H.bcmap +0 -0
- package/reader/vendor/UniJIS2004-UTF32-V.bcmap +0 -0
- package/reader/vendor/UniJIS2004-UTF8-H.bcmap +0 -0
- package/reader/vendor/UniJIS2004-UTF8-V.bcmap +0 -0
- package/reader/vendor/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/reader/vendor/UniJISPro-UCS2-V.bcmap +0 -0
- package/reader/vendor/UniJISPro-UTF8-V.bcmap +0 -0
- package/reader/vendor/UniJISX0213-UTF32-H.bcmap +0 -0
- package/reader/vendor/UniJISX0213-UTF32-V.bcmap +0 -0
- package/reader/vendor/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/reader/vendor/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/reader/vendor/UniKS-UCS2-H.bcmap +0 -0
- package/reader/vendor/UniKS-UCS2-V.bcmap +0 -0
- package/reader/vendor/UniKS-UTF16-H.bcmap +0 -0
- package/reader/vendor/UniKS-UTF16-V.bcmap +0 -0
- package/reader/vendor/UniKS-UTF32-H.bcmap +0 -0
- package/reader/vendor/UniKS-UTF32-V.bcmap +0 -0
- package/reader/vendor/UniKS-UTF8-H.bcmap +0 -0
- package/reader/vendor/UniKS-UTF8-V.bcmap +0 -0
- package/reader/vendor/V.bcmap +0 -0
- package/reader/vendor/WP-Symbol.bcmap +0 -0
- package/reader/vendor/jbig2_nowasm_fallback.js +15 -0
- package/reader/vendor/openjpeg_nowasm_fallback.js +17 -0
package/reader/index.html
CHANGED
|
@@ -149,6 +149,19 @@
|
|
|
149
149
|
.textLayer span.dpr-hl { background: rgba(255,196,0,.45); border-radius: 2px; }
|
|
150
150
|
#empty { margin: 60px auto; color: var(--text-2); text-align: center; max-width: 420px; }
|
|
151
151
|
|
|
152
|
+
/* ---------- 扫描件查看态 ----------
|
|
153
|
+
Web 与 Electron 统一走 pdf.js + 纯 JS 图像解码(vendor 下的 *nowasm_fallback.js),
|
|
154
|
+
不依赖浏览器内置 PDF 插件/ wasm;只给提示,不伪装成可检索文本。 */
|
|
155
|
+
#scan-banner { display: none; position: sticky; top: -16px; z-index: 6; margin: -16px -16px 12px;
|
|
156
|
+
padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--border);
|
|
157
|
+
color: var(--text-2); font-size: 12.5px; line-height: 1.55; }
|
|
158
|
+
#scan-banner.on { display: block; }
|
|
159
|
+
#scan-banner strong { color: var(--text); margin-right: 6px; }
|
|
160
|
+
#scan-banner a { color: var(--accent); text-decoration: none; white-space: nowrap; }
|
|
161
|
+
#scan-banner a:hover { text-decoration: underline; }
|
|
162
|
+
body.dpr-scan #find-open, body.dpr-scan #note-open, body.dpr-scan #eq-toggle,
|
|
163
|
+
body.dpr-scan #zh-toggle, body.dpr-scan #view-menu-btn, body.dpr-scan #view-menu { display: none !important; }
|
|
164
|
+
|
|
152
165
|
/* ---------- 公式引用(MinerU bbox 热区 + 列表面板)----------
|
|
153
166
|
契约 §1.3/§1.4:热区**不用** pointer-events:auto 的覆盖层——那会夺走 textLayer 的
|
|
154
167
|
mousedown/拖拽,破坏既有划词提问。这里 .eqLayer 只负责画描边(pointer-events:none),
|
|
@@ -471,6 +484,11 @@
|
|
|
471
484
|
<div id="split-wrap">
|
|
472
485
|
<div id="pdf-pane">
|
|
473
486
|
<div id="pane-label" class="pane-label">原文</div>
|
|
487
|
+
<div id="scan-banner">
|
|
488
|
+
<strong id="scan-title">扫描件:只能查看</strong>
|
|
489
|
+
<span id="scan-msg"></span>
|
|
490
|
+
<a id="scan-open" href="#" target="_blank" rel="noreferrer">在新窗口打开 PDF</a>
|
|
491
|
+
</div>
|
|
474
492
|
<div id="pdf-pages"></div>
|
|
475
493
|
<div id="empty" style="display:none"></div>
|
|
476
494
|
</div>
|
|
@@ -1014,6 +1032,7 @@ function syncTranscribeButton() {
|
|
|
1014
1032
|
|
|
1015
1033
|
async function openPaper(topic, name, opts = {}) {
|
|
1016
1034
|
if (!name) return;
|
|
1035
|
+
exitScannedView();
|
|
1017
1036
|
openingPaper = true;
|
|
1018
1037
|
// P2:打开/切换文献后先留出静默窗,别让译文预取在这段里挤进来
|
|
1019
1038
|
preloadNotBefore = Date.now() + PRELOAD_GRACE_MS;
|
|
@@ -1583,6 +1602,7 @@ async function findRun(q) {
|
|
|
1583
1602
|
/** 打开查找窗口(focus=true 时选中输入框内容,方便直接改写关键词) */
|
|
1584
1603
|
function findPanelOpen(focus) {
|
|
1585
1604
|
if (!findWinEl) return;
|
|
1605
|
+
if (scannedPdfMode) { toast('扫描件没有文本层,只能查看;全文查找不可用', 4000); return; }
|
|
1586
1606
|
findWinShow(true);
|
|
1587
1607
|
if (find.idx >= 0) findReapply(); // 重新打开时把上次的当前命中重新标出来,不用再跳一次
|
|
1588
1608
|
if (focus) { findInputEl.focus(); findInputEl.select(); }
|
|
@@ -2027,6 +2047,7 @@ $('main').addEventListener('mousemove', (e) => {
|
|
|
2027
2047
|
/* ---------- 笔记窗口:列表态 / 编辑态 ---------- */
|
|
2028
2048
|
function noteWinShow(on) {
|
|
2029
2049
|
if (!noteWinEl) return;
|
|
2050
|
+
if (on && scannedPdfMode) { toast('扫描件没有文本层,只能查看;笔记不可用', 4000); return; }
|
|
2030
2051
|
if (!on) {
|
|
2031
2052
|
noteWinEl.classList.remove('on');
|
|
2032
2053
|
notes.shown = false;
|
|
@@ -3018,6 +3039,15 @@ function ensurePdfjs() {
|
|
|
3018
3039
|
ensurePdfjs().catch(() => {}); // 预热:与 bootstrap 的 API 请求并行拉取,不把首屏串行化
|
|
3019
3040
|
|
|
3020
3041
|
let pdfDoc = null;
|
|
3042
|
+
// pdf.js 6 把 CCITT/JBIG2/JPX 解码放到了 wasm/JS 模块里;插件不打包 wasm,
|
|
3043
|
+
// 统一走 vendor 下的**纯 JS 兜底模块**(useWasm:false)。这样 Web 与 Electron
|
|
3044
|
+
// 桌面端都不依赖浏览器的内嵌 PDF 插件,扫描件也能正常出图。
|
|
3045
|
+
const PDFJS_IMAGE_OPTS = {
|
|
3046
|
+
useWasm: false, wasmUrl: PR_ASSET_BASE + 'vendor/',
|
|
3047
|
+
// 预定义 CMap(Adobe-GB1-UCS2 等):ESP32 那类 TeX 中文 PDF 的内嵌字体没有 /ToUnicode,
|
|
3048
|
+
// pdf.js 必须靠这张字符映射表才能把中文画出来。平铺在 vendor/ 下,路由无需放子目录。
|
|
3049
|
+
cMapUrl: PR_ASSET_BASE + 'vendor/', cMapPacked: true, useSystemFonts: true,
|
|
3050
|
+
};
|
|
3021
3051
|
let pdfLoadSeq = 0; // loadPdf 的序号:旧请求晚到时直接丢弃,避免覆盖新文档
|
|
3022
3052
|
let zoomScale = 1.5;
|
|
3023
3053
|
let dpr = window.devicePixelRatio || 1;
|
|
@@ -3038,6 +3068,7 @@ let openingPaper = false;
|
|
|
3038
3068
|
// P2:译文预取不再和「点开论文」抢主线程 —— 打开后先让首帧/切换喘口气,再等真空闲。
|
|
3039
3069
|
const PRELOAD_GRACE_MS = 1800;
|
|
3040
3070
|
let lazyView = null; // {doc, pane, container, scale, token, observer, pages: Map<pageNo,{div,page,vp,rendered,painting}>}
|
|
3071
|
+
let scannedPdfMode = false; // true = 当前文档无文本层:只作查看,不参与译文/分屏
|
|
3041
3072
|
const LAZY_MIN_PAGES = 12; // 页数少的文档全量渲染更快;长文档滚动模式才启用懒渲染
|
|
3042
3073
|
|
|
3043
3074
|
/** 释放 pdf.js 文档(worker + 页面缓存)。销毁前调用方必须先 ++renderToken,
|
|
@@ -3057,10 +3088,62 @@ async function destroyPdfDoc(doc) {
|
|
|
3057
3088
|
});
|
|
3058
3089
|
})();
|
|
3059
3090
|
|
|
3091
|
+
/** 只在真实浏览器/Electron 里做扫描件判定;Node 测试桩不进入这条 UI 分支。 */
|
|
3092
|
+
function browserRuntime() {
|
|
3093
|
+
try { const ua = (typeof navigator !== 'undefined' && navigator && navigator.userAgent) || ''; return ua.length > 0 && !/Node\.js/i.test(ua) } catch { return false }
|
|
3094
|
+
}
|
|
3095
|
+
|
|
3096
|
+
/** 扫描件判定:前 3 页 + 中间 + 末页都没有可读文本。只影响「怎么显示」,不影响转录/翻译缓存。 */
|
|
3097
|
+
async function docLooksScanned(doc) {
|
|
3098
|
+
if (!doc || !doc.numPages || !browserRuntime()) return false;
|
|
3099
|
+
// 前 3 页 + 中间 + 末页:避免「封面/版权页是图,正文有字」的文本 PDF 被误判为扫描件。
|
|
3100
|
+
const probe = new Set([1, 2, 3].filter((n) => n <= doc.numPages));
|
|
3101
|
+
probe.add(Math.max(1, Math.ceil(doc.numPages / 2)));
|
|
3102
|
+
probe.add(doc.numPages);
|
|
3103
|
+
let chars = 0;
|
|
3104
|
+
for (const i of probe) {
|
|
3105
|
+
try {
|
|
3106
|
+
const page = await doc.getPage(i);
|
|
3107
|
+
const tc = await page.getTextContent();
|
|
3108
|
+
for (const item of tc.items) {
|
|
3109
|
+
if (typeof item.str === 'string') chars += item.str.replace(/\s+/g, '').length;
|
|
3110
|
+
}
|
|
3111
|
+
} catch { /* 单页读不出文本:当作没文本继续探测 */ }
|
|
3112
|
+
if (chars >= 12) return false;
|
|
3113
|
+
}
|
|
3114
|
+
return true;
|
|
3115
|
+
}
|
|
3116
|
+
|
|
3117
|
+
const SCAN_TITLE = '扫描件:只能查看';
|
|
3118
|
+
const SCAN_MSG = '这篇 PDF 没有文本层,只能按原样查看;选词提问、笔记、全文查找与翻译在此视图不可用。如需 OCR,可在「设置 → 论文伴读」启用 MinerU 后点顶栏「转录」。';
|
|
3119
|
+
|
|
3120
|
+
/** 进入扫描件查看态:Web 与客户端统一走 pdf.js 画页(纯 JS 图像解码),只显示提示、禁用文本功能。 */
|
|
3121
|
+
function enterScannedView(url) {
|
|
3122
|
+
const banner = $('scan-banner');
|
|
3123
|
+
if (!banner) return;
|
|
3124
|
+
scannedPdfMode = true;
|
|
3125
|
+
document.body.classList.add('dpr-scan');
|
|
3126
|
+
banner.classList.add('on');
|
|
3127
|
+
$('scan-title').textContent = SCAN_TITLE;
|
|
3128
|
+
$('scan-msg').textContent = SCAN_MSG;
|
|
3129
|
+
const open = $('scan-open');
|
|
3130
|
+
if (open) { open.href = url; open.target = '_blank'; open.rel = 'noreferrer'; }
|
|
3131
|
+
if (current) $('status').textContent = `${current.name} · 扫描件(只能查看)`;
|
|
3132
|
+
}
|
|
3133
|
+
|
|
3134
|
+
/** 退出扫描件查看态。调用点:换论文 / 换视图 / 重新加载普通 PDF。 */
|
|
3135
|
+
function exitScannedView() {
|
|
3136
|
+
if (!scannedPdfMode) return;
|
|
3137
|
+
scannedPdfMode = false;
|
|
3138
|
+
document.body.classList.remove('dpr-scan');
|
|
3139
|
+
$('scan-banner').classList.remove('on');
|
|
3140
|
+
}
|
|
3141
|
+
|
|
3060
3142
|
async function loadPdf(url, opts = {}) {
|
|
3143
|
+
exitScannedView(); // 换文档/换视图:上一次的兜底态必须先撤掉
|
|
3061
3144
|
await ensurePdfjs(); // 就绪前禁止触 pdfjsLib(defer 竞态,见文件头注释)
|
|
3062
3145
|
const seq = ++pdfLoadSeq;
|
|
3063
|
-
const task = pdfjsLib.getDocument({ url }); // v6 起不接受字符串参数,必须传对象
|
|
3146
|
+
const task = pdfjsLib.getDocument({ url, ...PDFJS_IMAGE_OPTS }); // v6 起不接受字符串参数,必须传对象
|
|
3064
3147
|
let doc;
|
|
3065
3148
|
try {
|
|
3066
3149
|
doc = await task.promise;
|
|
@@ -3081,6 +3164,11 @@ async function loadPdf(url, opts = {}) {
|
|
|
3081
3164
|
// 换了文档(换论文 / 原文↔译文):查找索引按文档对象缓存,这里必须作废,
|
|
3082
3165
|
// 否则会拿旧文档的页码去定位新文档(页数不同时直接跳错页)。
|
|
3083
3166
|
if (find.doc !== pdfDoc) findReset();
|
|
3167
|
+
// 扫描件:CCITT/JBIG2 图像解码在 pdf.js 6 里依赖 wasm;插件改用纯 JS 兜底,
|
|
3168
|
+
// 页面照样由 pdf.js 渲染,只额外提示「只能查看」并禁用文本功能。
|
|
3169
|
+
const scanned = await docLooksScanned(doc);
|
|
3170
|
+
if (seq !== pdfLoadSeq) return false;
|
|
3171
|
+
if (scanned) enterScannedView(url); // Web/Electron 同一条路:pdf.js + 纯 JS 图像解码
|
|
3084
3172
|
$('empty').style.display = 'none';
|
|
3085
3173
|
// 翻页控件与模式切换按钮:文档就绪后才出现
|
|
3086
3174
|
$('pager').style.display = '';
|
|
@@ -3162,7 +3250,7 @@ function loadViewDoc(key) {
|
|
|
3162
3250
|
if (viewLoads.has(key)) return viewLoads.get(key)
|
|
3163
3251
|
const seq = ++viewLoadSeq
|
|
3164
3252
|
const variant = key === 'orig' ? null : key
|
|
3165
|
-
const task = pdfjsLib.getDocument({ url: pdfUrl(variant) })
|
|
3253
|
+
const task = pdfjsLib.getDocument({ url: pdfUrl(variant), ...PDFJS_IMAGE_OPTS })
|
|
3166
3254
|
const p = (async () => {
|
|
3167
3255
|
const doc = await task.promise
|
|
3168
3256
|
if (seq !== viewLoadSeq) { try { await task.destroy(); } catch { /* stale */ } return null }
|
|
@@ -3320,7 +3408,7 @@ async function preloadView(key) {
|
|
|
3320
3408
|
* ③ 排期本身走 requestIdleCallback(拿不到 idle 的老浏览器退回 setTimeout),
|
|
3321
3409
|
* timeout 放宽到 4s:真的长期不空闲就延后,而不是 2.5s 强行插队。 */
|
|
3322
3410
|
function schedulePreload() {
|
|
3323
|
-
if (openingPaper) return
|
|
3411
|
+
if (openingPaper || scannedPdfMode) return
|
|
3324
3412
|
const key = zhState.zh ? 'zh' : zhState.dual ? 'dual' : null
|
|
3325
3413
|
if (!key || key === activeKey || viewCache.has(key) || (viewDocs.has(key) && viewCache.has(key))) return
|
|
3326
3414
|
cancelPreload()
|
|
@@ -5363,6 +5451,7 @@ async function renderSplit() {
|
|
|
5363
5451
|
|
|
5364
5452
|
/** 进入分屏(或 openPaper 恢复分屏):拉原文 + -zh.pdf 两个文档,两列同渲。 */
|
|
5365
5453
|
async function openSplit() {
|
|
5454
|
+
if (scannedPdfMode) return; // 扫描件只作查看,不参与分屏/译文渲染
|
|
5366
5455
|
if (!current || !zhState.zh) return;
|
|
5367
5456
|
if (window.innerWidth < SPLIT_MIN_WIDTH) {
|
|
5368
5457
|
toast('面板太窄,请把阅读器拉宽后再用分屏对照', 4000);
|
|
@@ -5385,7 +5474,7 @@ async function openSplit() {
|
|
|
5385
5474
|
if (pdfDocZh) { await destroyPdfDoc(pdfDocZh); pdfDocZh = null; }
|
|
5386
5475
|
let task = null;
|
|
5387
5476
|
try {
|
|
5388
|
-
task = pdfjsLib.getDocument({ url: pdfUrl('zh') });
|
|
5477
|
+
task = pdfjsLib.getDocument({ url: pdfUrl('zh'), ...PDFJS_IMAGE_OPTS });
|
|
5389
5478
|
const doc = await task.promise;
|
|
5390
5479
|
if (seq !== splitLoadSeq) { try { await task.destroy(); } catch { /* 已被新请求/teardown 取代 */ } return; }
|
|
5391
5480
|
pdfDocZh = doc;
|
|
@@ -5397,6 +5486,14 @@ async function openSplit() {
|
|
|
5397
5486
|
return;
|
|
5398
5487
|
}
|
|
5399
5488
|
await loadPdf(pdfUrl(null), { deferRender: true }); // 原文列(pdfDoc 恒指原文),本函数自己安排渲染
|
|
5489
|
+
if (scannedPdfMode) {
|
|
5490
|
+
// loadPdf 判定扫描件(统一 pdf.js + 纯 JS 兜底):撤掉刚刚打开的分屏壳,别留一列空白。
|
|
5491
|
+
teardownSplit();
|
|
5492
|
+
viewMode = 'orig';
|
|
5493
|
+
zhVariant = null;
|
|
5494
|
+
updateViewButtons();
|
|
5495
|
+
return;
|
|
5496
|
+
}
|
|
5400
5497
|
// 分屏适宽:按较窄的那一列算一次(等价于 fitToWidth,但不让它触发一次多余的单列渲染)
|
|
5401
5498
|
const w = fitPaneWidth();
|
|
5402
5499
|
if (w > 0 && pdfDoc) {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
�RCopyright 1990-2009 Adobe Systems Incorporated.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
See ./LICENSE!!��]aX!!]`�21�> �p�z�$]��"R�d�-U�7�*�
|
|
4
|
+
�"]�h�"]�F�"]�$�"]��"]�`�"]�>�"]��"]�z�"]�X�"]�6�"]��"]�r�"]�P�"]�.�"]��"]�j�"]�H�"]�&�"]��"]�b�"]�@�"]��"]�|�"]�Z�"]�8�"]��"]�t�"]�R�"]�0�"]��"]�l�"]�J�"]�(�"]��"]�d�"]�B�"]� �"X�~�']�W�"]�5�"]��"]�q�"]�O�"]�-�"]��"]�i�"]�G�"]�%�"]��"]�a�"]�?�"]��"]�{�"]�Y�"]�7�"]��"]�s�"]�Q�"]�/�"]�
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2026 Mozilla Foundation
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2024, Mozilla Foundation
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
|
4
|
+
modification, are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
7
|
+
list of conditions and the following disclaimer.
|
|
8
|
+
|
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
and/or other materials provided with the distribution.
|
|
12
|
+
|
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
14
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
15
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
16
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
17
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
18
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
19
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
20
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
21
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
22
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|