@file-viewer/renderer-pdf 3.1.2 → 3.2.0

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.en.md CHANGED
@@ -1,57 +1,7 @@
1
1
  # @file-viewer/renderer-pdf
2
2
 
3
- Standalone PDF renderer package for Flyfish File Viewer. It is powered by PDF.js and provides page rendering, navigation, outline, search, zoom, print, and HTML export support.
3
+ Runtime package version 3.2.0.
4
4
 
5
- ## Usage
5
+ Usage and API documentation: https://doc.file-viewer.app/guide/on-demand-renderers
6
6
 
7
- ```ts
8
- import FileViewer from '@file-viewer/vue3'
9
- import { pdfRenderer } from '@file-viewer/renderer-pdf'
10
-
11
- const options = {
12
- rendererMode: 'replace',
13
- renderers: pdfRenderer,
14
- }
15
- ```
16
-
17
- You can combine it with other renderer packages:
18
-
19
- ```ts
20
- const options = {
21
- rendererMode: 'replace',
22
- renderers: [pdfRenderer],
23
- }
24
- ```
25
-
26
- ## Offline Assets
27
-
28
- PDF preview depends on the PDF.js worker, cMaps, WASM helpers, standard fonts, and an offline fallback for unembedded CJK fonts. Asset paths use the same unified options as `@file-viewer/core`:
29
-
30
- ```ts
31
- const options = {
32
- renderers: pdfRenderer,
33
- pdf: {
34
- assetBaseUrl: '/workspace/',
35
- workerUrl: '/vendor/pdf/pdf.worker.mjs',
36
- cMapUrl: '/vendor/pdf/cmaps/',
37
- wasmUrl: '/vendor/pdf/wasm/',
38
- standardFontDataUrl: '/vendor/pdf/standard_fonts/',
39
- cjkFontFallbackPath: '/vendor/pdf/fonts/',
40
- identityFontRepair: true,
41
- },
42
- }
43
- ```
44
-
45
- When no explicit PDF asset URL is configured, the renderer first uses the public base exposed by build tools such as Vite and can fall back to the page entry script. An app deployed under `/workspace/` therefore still requests `/workspace/vendor/pdf/pdf.worker.mjs` while its current SPA route is `/workspace/c/`. UMI, custom proxies, and builds whose public path cannot be detected can set `pdf.assetBaseUrl: '/workspace/'` to pin the base for every PDF offline asset. Before creating a static Worker, the renderer reads the official PDF.js version marker; a stale Worker from an older deployment is rejected and the packaged same-version handler is used instead. If the host app did not run `file-viewer-copy-assets`, does not use `@file-viewer/vite-plugin`, or a local dev server falls back to HTML for that path, the same fallback prevents `Setting up fake worker failed`. For best performance, complete cMap/standard-font/WASM decoding, or strict offline deployments, still copy viewer assets and point these URLs at real static files. The pinned PDF.js 5.4 stable line loads local JBIG2, JPEG 2000, color-management, and related helpers through `wasmUrl`; viewer assets and the Vite plugin copy them without relying on the public internet.
46
-
47
- `cjkFontFallback` is enabled by default. When a PDF references `MicrosoftYaHei-Bold`, SimSun, SimHei, or another CJK font without embedding the font program, the renderer prefers an installed system font and otherwise aliases the original PDF font name to the local Noto Sans SC variable font supplied by `@file-viewer/assets-standard`. The Vite plugin reuses that standard asset set instead of packing a second font copy into the renderer. Only WOFF2 shards needed by the current page text are loaded. The first page waits for the font before rendering, and later pages are redrawn when they introduce new glyphs. Set the option to `false` to disable this behavior, or point `cjkFontFallbackPath` at a self-hosted directory with the same structure.
48
-
49
- `identityFontRepair` is also enabled by default for malformed PDFs that write TrueType glyph IDs through `Identity-H`/`Identity-V` but omit `ToUnicode`. The repair module is loaded only after CJK font substitution and multiple control-character glyphs are detected. If the same PDF embeds a usable same-family TrueType font, its cmap is used to rebuild the Unicode mapping for the in-memory preview. The repair is applied only to a preview copy and never overwrites the original file or download source; an unsafe or unsupported repair falls back to the original preview. Set the option to `false` to disable this compatibility path.
50
-
51
- ## Migration Note
52
-
53
- PDF rendering has moved out of `@file-viewer/core` into this package, and `pdfjs-dist` is now declared only by `@file-viewer/renderer-pdf`. Installing core or a standard component package no longer pulls PDF.js; explicitly assemble this renderer when PDF preview is needed, or use `@file-viewer/preset-all`.
54
-
55
- The published renderer stages its Apache-2.0 PDF.js runtime under `dist/vendor/pdfjs` and isolates PDF.js' internal webpack bootstrap before packing. `provenance.json` records source hashes after the declared patches, transform counts, and staged output hashes, so webpack 4 consumers do not need a loader for renderer-internal paths.
56
-
57
- The staged runtime also includes a PDF.js 5.4.624 document-startup cancellation patch. It prevents unhandled promise rejections when switching files during main-thread fallback initialization; active parsing and password errors remain visible. The patch is included under `dist/vendor/pdfjs/patches/` with its hash in `provenance.json`. `pnpm verify:worker-lifecycle` tests cancellation, subsequent rendering, and invalid-file errors in both real and main-thread Workers on Chromium and WebKit.
7
+ The package's own license is Apache-2.0. Included third-party notices apply to their respective components.
package/README.md CHANGED
@@ -1,57 +1,7 @@
1
1
  # @file-viewer/renderer-pdf
2
2
 
3
- Flyfish File Viewer 的独立 PDF renderer 包,基于 PDF.js,提供 PDF 页面渲染、导航、目录、搜索、缩放、打印和 HTML 导出能力。
3
+ Runtime package version 3.2.0.
4
4
 
5
- ## 用法
5
+ Usage and API documentation: https://doc.file-viewer.app/guide/on-demand-renderers
6
6
 
7
- ```ts
8
- import FileViewer from '@file-viewer/vue3'
9
- import { pdfRenderer } from '@file-viewer/renderer-pdf'
10
-
11
- const options = {
12
- rendererMode: 'replace',
13
- renderers: pdfRenderer,
14
- }
15
- ```
16
-
17
- 也可以和其他 renderer 一起组合:
18
-
19
- ```ts
20
- const options = {
21
- rendererMode: 'replace',
22
- renderers: [pdfRenderer],
23
- }
24
- ```
25
-
26
- ## 离线资源
27
-
28
- PDF 预览依赖 PDF.js worker、cMaps、WASM、standard fonts,以及未嵌入中文字体的离线回退资源。资源路径沿用 `@file-viewer/core` 的统一 options:
29
-
30
- ```ts
31
- const options = {
32
- renderers: pdfRenderer,
33
- pdf: {
34
- assetBaseUrl: '/workspace/',
35
- workerUrl: '/vendor/pdf/pdf.worker.mjs',
36
- cMapUrl: '/vendor/pdf/cmaps/',
37
- wasmUrl: '/vendor/pdf/wasm/',
38
- standardFontDataUrl: '/vendor/pdf/standard_fonts/',
39
- cjkFontFallbackPath: '/vendor/pdf/fonts/',
40
- identityFontRepair: true,
41
- },
42
- }
43
- ```
44
-
45
- 默认未显式配置时,渲染器优先使用 Vite 等构建器提供的公开基址,并可从页面入口脚本回退识别部署子路径。因此应用部署在 `/workspace/`、当前 SPA 路由为 `/workspace/c/` 时,仍会请求 `/workspace/vendor/pdf/pdf.worker.mjs`。UMI、自定义代理或无法自动识别的构建环境可以设置 `pdf.assetBaseUrl: '/workspace/'` 固定全部 PDF 离线资源的基址。创建静态 Worker 前会先读取 PDF.js 官方版本标记;若部署目录残留的旧 Worker 与当前 API 不一致,会拒绝旧文件并自动使用包内同版本 handler。项目未执行 `file-viewer-copy-assets`、未使用 `@file-viewer/vite-plugin`,或本地临时服务器把该路径回退成 HTML 时,也会使用同一兜底,避免 `Setting up fake worker failed` 直接中断预览。需要最佳性能、完整 cMap/standard fonts/WASM 解码或严格离线部署时,仍建议复制 viewer assets 并配置真实静态地址。当前锁定的 PDF.js 5.4 稳定线会通过 `wasmUrl` 本地加载 JBIG2、JPEG 2000、颜色管理等辅助资源;这些资源由 viewer assets 和 Vite 插件统一复制,不依赖公网。
46
-
47
- `cjkFontFallback` 默认开启。PDF 引用了 `MicrosoftYaHei-Bold`、宋体、黑体或其他中文字体但没有嵌入字体数据时,渲染器优先使用本机字体;本机缺失时,会把原 PDF 字体名映射到 `@file-viewer/assets-standard` 提供的本地 Noto Sans SC 可变字体,并根据当前页实际文字只加载需要的 WOFF2 分片。Vite 插件会优先复用这份标准资源,避免在 renderer 中重复打包字体。首屏会在字体就绪后再渲染,后续页发现新字形时会自动重绘。可设为 `false` 完全关闭,或用 `cjkFontFallbackPath` 指向同结构的自托管字体目录。
48
-
49
- `identityFontRepair` 也默认开启,用于少数把 TrueType 字形 ID 写入 `Identity-H`/`Identity-V`、却遗漏 `ToUnicode` 的异常 PDF。只有检测到中文字体替换和多个控制字符乱码时,渲染器才会懒加载修复模块;若文件内同时嵌入了可用的同族 TrueType 字体,就从其 cmap 重建内存预览所需的 Unicode 映射。修复只作用于预览副本,不覆盖原始文件和下载源;无法安全修复时继续使用原预览。可设为 `false` 关闭。
50
-
51
- ## 迁移说明
52
-
53
- PDF 渲染已经从 `@file-viewer/core` 移入本包,`pdfjs-dist` 只由 `@file-viewer/renderer-pdf` 声明。只安装 core 或标准组件包时不会再拉取 PDF.js;需要 PDF 预览时请显式装配本 renderer,或使用 `@file-viewer/preset-all`。
54
-
55
- 发布产物会把 Apache-2.0 的 PDF.js runtime 内封到 `dist/vendor/pdfjs`,并在打包前隔离 PDF.js 内部 webpack bootstrap。`provenance.json` 会记录应用声明补丁后的源文件哈希、变换次数和产物哈希,因此 webpack 4 消费项目不需要再为 renderer 内部路径配置 loader。
56
-
57
- 内封运行时还包含 PDF.js 5.4.624 的文档初始化取消补丁,避免快速切换文件时主线程降级路径产生未处理的 Promise 异常;正常解析和密码错误仍会报告。补丁原文保留在 `dist/vendor/pdfjs/patches/`,其哈希记入 `provenance.json`。`pnpm verify:worker-lifecycle` 使用 Chromium/WebKit 分别验证真实 Worker 和主线程降级路径的取消、后续渲染及损坏文件报错。
7
+ The package's own license is Apache-2.0. Included third-party notices apply to their respective components.
package/dist/pdf.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { installPdfHandTool } from './pdfHandTool.js';
2
+ import { scrollPdfPageWithinContainer } from './pdfPageScroll.js';
1
3
  import { getDocument, GlobalWorkerOptions, PDFWorker as PdfJsWorker, PixelsPerInch, version as pdfJsVersion, } from './vendor/pdfjs/legacy/build/pdf.mjs';
2
4
  import { EventBus, GenericL10n, PDFFindController, PDFLinkService, PDFViewer, } from './vendor/pdfjs/legacy/web/pdf_viewer.mjs';
3
5
  import { registerFileViewerSearchProvider, registerFileViewerZoomProvider, unregisterFileViewerSearchProvider, unregisterFileViewerZoomProvider, registerFileViewerViewStateProvider, unregisterFileViewerViewStateProvider, createFileViewerZoomChangeEmitter, createFileViewerViewStateChange, createFileViewerViewStateChangeEmitter, createFileViewerTranslator, buildPrintPageStyle, formatCssPixels, DEFAULT_PDF_RANGE_CHUNK_SIZE, resolveFileViewerLocale, resolveFileViewerFitScale, } from '@file-viewer/core';
@@ -6,7 +8,7 @@ import { pdfViewerStyle } from './pdfStyles.js';
6
8
  import { collectMalformedIdentityFontNames, createPdfCjkFontFallbackManager, detectMalformedIdentityCjkFontFamilies, } from './pdfFontFallback.js';
7
9
  import { PDF_FIT_HORIZONTAL_PADDING, PDF_PAGE_BORDER_WIDTH, resolvePdfFitViewportSize, } from './pdfFit.js';
8
10
  import { createPdfBoundingBoxController, } from './pdfBboxController.js';
9
- import { clampPdfScale, normalizePdfRotation, resolvePdfViewStateUpdate, } from './pdfViewState.js';
11
+ import { clampPdfScale, normalizePdfRotation, resolvePdfPageRotation, resolvePdfViewStateUpdate, } from './pdfViewState.js';
10
12
  import { capturePdfJsWorkerGlobal, scopePdfJsWorkerMessageHandler, } from './pdfWorkerGlobal.js';
11
13
  import { readPdfJsWorkerVersion } from './pdfWorkerVersion.js';
12
14
  import { getFileViewerPdfIdentityFontRepair } from './optionalCapabilities.js';
@@ -21,10 +23,6 @@ const PDF_WORKER_VERSION_PROBE_BYTES = 4096;
21
23
  const PDF_JS_DESTROY_CONSOLE_SUPPRESSION_MS = 1500;
22
24
  let bundledPdfWorkerModulePromise = null;
23
25
  const scopePdfJsRootVariables = (style) => style.replace(/:root(\s*\{)/g, ':root,\n.pdf-shell$1');
24
- // PDF.js viewer CSS references image assets that are not shipped with the
25
- // on-demand renderer chunk, so keep the preview self-contained and 404-free.
26
- // Its root custom properties also need a local scope: a :root selector inside
27
- // Shadow DOM does not match the document root or the custom-element host.
28
26
  const normalizedPdfViewerStyle = `${scopePdfJsRootVariables(pdfViewerStyle)}
29
27
  .pdf-shell{background:var(--file-viewer-render-surface-background,#edf2f7)}
30
28
  .pdf-wrapper{background:var(--file-viewer-render-surface-background,#e8edf4)}
@@ -233,9 +231,6 @@ const isJavaScriptLikeResponse = (response) => {
233
231
  contentType.includes('text/plain');
234
232
  };
235
233
  const readResponsePrefix = async (response, maximumBytes = PDF_WORKER_VERSION_PROBE_BYTES) => {
236
- // Consume the response even when a server ignores Range. Cancelling after the
237
- // prefix creates a browser-level ERR_ABORTED event that strict hosts treat as
238
- // a failed asset request, despite the compatibility probe succeeding.
239
234
  return (await response.text()).slice(0, maximumBytes);
240
235
  };
241
236
  const loadBundledPdfWorkerModule = async () => {
@@ -244,8 +239,6 @@ const loadBundledPdfWorkerModule = async () => {
244
239
  };
245
240
  const createBundledPdfFakeWorker = async () => {
246
241
  const workerGlobal = globalThis;
247
- // pdf.worker.mjs assigns globalThis.pdfjsWorker as a module side effect, so
248
- // capture the host namespace before importing it and restore that snapshot.
249
242
  const hostWorkerGlobal = capturePdfJsWorkerGlobal(workerGlobal);
250
243
  const workerModule = await loadBundledPdfWorkerModule();
251
244
  const workerHandlerScope = scopePdfJsWorkerMessageHandler(workerGlobal, workerModule.WorkerMessageHandler, hostWorkerGlobal);
@@ -277,7 +270,7 @@ const buildOutlineItems = (items, prefix = 'outline', getFallbackTitle = index =
277
270
  };
278
271
  });
279
272
  export default async function renderPdf(buffer, target, context) {
280
- var _a, _b, _c, _d;
273
+ var _a, _b, _c, _d, _e, _f;
281
274
  const documentRef = target.ownerDocument || document;
282
275
  const targetWindow = documentRef.defaultView || (typeof window !== 'undefined' ? window : null);
283
276
  const t = createFileViewerTranslator(context === null || context === void 0 ? void 0 : context.options);
@@ -425,6 +418,9 @@ export default async function renderPdf(buffer, target, context) {
425
418
  root.insertBefore(toolbar, content);
426
419
  }
427
420
  target.replaceChildren(createStyle(documentRef), root);
421
+ const disposeHandTool = ((_e = (_d = context === null || context === void 0 ? void 0 : context.options) === null || _d === void 0 ? void 0 : _d.pdf) === null || _e === void 0 ? void 0 : _e.handTool) === true
422
+ ? installPdfHandTool(container)
423
+ : () => { };
428
424
  const scaleText = () => `${Math.round(currentScale * 100)}%`;
429
425
  const rotationText = () => `${currentRotation}°`;
430
426
  const canGoPrevious = () => currentPage > 1;
@@ -537,14 +533,14 @@ export default async function renderPdf(buffer, target, context) {
537
533
  await ensurePdfPageCjkFontFallback(pageNumber, page);
538
534
  const baseViewport = page.getViewport({
539
535
  scale: PixelsPerInch.PDF_TO_CSS_UNITS,
540
- rotation: currentRotation,
536
+ rotation: resolvePdfPageRotation(page.rotate, currentRotation),
541
537
  });
542
538
  const deviceScale = Math.min(2, Math.max(1, targetWindow.devicePixelRatio || 1));
543
539
  const thumbnailWidth = 46;
544
540
  const ratio = Math.min(1, thumbnailWidth / Math.max(baseViewport.width, 1));
545
541
  const renderViewport = page.getViewport({
546
542
  scale: PixelsPerInch.PDF_TO_CSS_UNITS * ratio * deviceScale,
547
- rotation: currentRotation,
543
+ rotation: resolvePdfPageRotation(page.rotate, currentRotation),
548
544
  });
549
545
  const canvas = documentRef.createElement('canvas');
550
546
  const canvasContext = canvas.getContext('2d');
@@ -583,9 +579,9 @@ export default async function renderPdf(buffer, target, context) {
583
579
  }
584
580
  const page = await pdfDocument.getPage(1);
585
581
  await ensurePdfPageCjkFontFallback(1, page);
586
- const baseViewport = page.getViewport({ scale: 1, rotation: currentRotation });
582
+ const baseViewport = page.getViewport({ scale: 1, rotation: resolvePdfPageRotation(page.rotate, currentRotation) });
587
583
  const scale = Math.max(0.1, Math.min(captureOptions.width / Math.max(baseViewport.width, 1), captureOptions.height / Math.max(baseViewport.height, 1)));
588
- const viewport = page.getViewport({ scale, rotation: currentRotation });
584
+ const viewport = page.getViewport({ scale, rotation: resolvePdfPageRotation(page.rotate, currentRotation) });
589
585
  const canvas = documentRef.createElement('canvas');
590
586
  const canvasContext = canvas.getContext('2d');
591
587
  if (!canvasContext) {
@@ -616,7 +612,7 @@ export default async function renderPdf(buffer, target, context) {
616
612
  (_f = page.cleanup) === null || _f === void 0 ? void 0 : _f.call(page);
617
613
  }
618
614
  };
619
- (_d = context === null || context === void 0 ? void 0 : context.registerThumbnailAdapter) === null || _d === void 0 ? void 0 : _d.call(context, {
615
+ (_f = context === null || context === void 0 ? void 0 : context.registerThumbnailAdapter) === null || _f === void 0 ? void 0 : _f.call(context, {
620
616
  beforeCapture: async ({ signal }) => {
621
617
  while (loadStatus === 'loading' && !destroyed) {
622
618
  if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
@@ -738,10 +734,6 @@ export default async function renderPdf(buffer, target, context) {
738
734
  try {
739
735
  const response = await fetcher(workerUrl, {
740
736
  method: 'GET',
741
- // A successful range probe must never seed the HTTP cache for the
742
- // subsequent module Worker request. Some static servers correctly
743
- // return 206 here, and Chromium can otherwise reuse that partial body
744
- // as the Worker module, which fails with "Invalid or unexpected token".
745
737
  cache: 'no-store',
746
738
  headers: {
747
739
  Range: `bytes=0-${PDF_WORKER_VERSION_PROBE_BYTES - 1}`,
@@ -773,10 +765,6 @@ export default async function renderPdf(buffer, target, context) {
773
765
  const workerGlobal = globalThis;
774
766
  if ((_a = workerGlobal.pdfjsWorker) === null || _a === void 0 ? void 0 : _a.WorkerMessageHandler) {
775
767
  try {
776
- // PDF.js prefers a preinstalled main-thread handler over workerSrc.
777
- // Scope our bundled handler only until this PDFWorker captures it, so
778
- // a vue-office/PDF.js 3.x global cannot hijack this renderer and the
779
- // host can still use its original handler afterwards.
780
768
  return await createBundledPdfFakeWorker();
781
769
  }
782
770
  catch (error) {
@@ -1029,6 +1017,7 @@ export default async function renderPdf(buffer, target, context) {
1029
1017
  }
1030
1018
  autoFitWidth = false;
1031
1019
  activeFitRequest = null;
1020
+ pendingFitRequest = null;
1032
1021
  };
1033
1022
  const getPdfPageElement = (pageNumber) => {
1034
1023
  var _a;
@@ -1188,9 +1177,6 @@ export default async function renderPdf(buffer, target, context) {
1188
1177
  if (update.page !== undefined) {
1189
1178
  goToPage(update.page, 'page-change', source, false);
1190
1179
  }
1191
- // A remote presenter can send scroll snapshots faster than one animation
1192
- // frame. Apply the latest offset before yielding so superseded promises
1193
- // cannot starve the projected screen until the presenter stops scrolling.
1194
1180
  restoreScrollState(state.scroll, false);
1195
1181
  await waitForPaint(targetWindow);
1196
1182
  if (applyVersion !== viewStateApplyVersion) {
@@ -1256,7 +1242,7 @@ export default async function renderPdf(buffer, target, context) {
1256
1242
  if (pdfPage) {
1257
1243
  const viewportAtScaleOne = pdfPage.getViewport({
1258
1244
  scale: PixelsPerInch.PDF_TO_CSS_UNITS,
1259
- rotation: currentRotation,
1245
+ rotation: resolvePdfPageRotation(pdfPage.rotate, currentRotation),
1260
1246
  });
1261
1247
  return {
1262
1248
  width: viewportAtScaleOne.width,
@@ -1276,6 +1262,7 @@ export default async function renderPdf(buffer, target, context) {
1276
1262
  const getPageWidthAtScaleOne = (pdfViewer) => {
1277
1263
  return getPageSizeAtScaleOne(pdfViewer).width;
1278
1264
  };
1265
+ const hasMeasurableViewport = () => container.clientWidth > 0 && container.clientHeight > 0;
1279
1266
  const getFitWidthScale = (pdfViewer) => {
1280
1267
  const pageWidth = getPageWidthAtScaleOne(pdfViewer);
1281
1268
  const containerWidth = container.clientWidth || targetWindow.innerWidth;
@@ -1290,6 +1277,9 @@ export default async function renderPdf(buffer, target, context) {
1290
1277
  userScrollIntentUntil = 0;
1291
1278
  suppressProgrammaticScrollEvents();
1292
1279
  autoFitWidth = true;
1280
+ if (!hasMeasurableViewport()) {
1281
+ return;
1282
+ }
1293
1283
  setScale(getFitWidthScale(pdfContext.viewer), 'zoom-reset', source, notifyViewState);
1294
1284
  void waitForPaint(targetWindow).then(() => {
1295
1285
  var _a;
@@ -1301,8 +1291,8 @@ export default async function renderPdf(buffer, target, context) {
1301
1291
  cancelPendingUserZoomRestore();
1302
1292
  userScrollIntentUntil = 0;
1303
1293
  activeFitRequest = { ...request };
1304
- if (!pdfContext.viewer || loadStatus !== 'ready') {
1305
- pendingFitRequest = request;
1294
+ if (!pdfContext.viewer || loadStatus !== 'ready' || !hasMeasurableViewport()) {
1295
+ pendingFitRequest = { ...request };
1306
1296
  return {
1307
1297
  applied: false,
1308
1298
  mode: request.mode,
@@ -1312,6 +1302,7 @@ export default async function renderPdf(buffer, target, context) {
1312
1302
  provider: 'view-state',
1313
1303
  };
1314
1304
  }
1305
+ pendingFitRequest = null;
1315
1306
  const pageSize = getPageSizeAtScaleOne(pdfContext.viewer);
1316
1307
  const mode = request.mode === 'auto' ? 'width' : request.mode;
1317
1308
  const fitViewport = resolvePdfFitViewportSize({
@@ -1323,9 +1314,6 @@ export default async function renderPdf(buffer, target, context) {
1323
1314
  });
1324
1315
  const scale = resolveFileViewerFitScale({
1325
1316
  mode,
1326
- // The core request measures the whole viewer root. PDF's scroll
1327
- // container is the actual visible document area after the navigation
1328
- // pane, so prefer it whenever it has been laid out.
1329
1317
  viewportWidth: fitViewport.width,
1330
1318
  viewportHeight: fitViewport.height,
1331
1319
  contentWidth: pageSize.width,
@@ -1368,10 +1356,10 @@ export default async function renderPdf(buffer, target, context) {
1368
1356
  };
1369
1357
  };
1370
1358
  const scheduleFitAfterResize = () => {
1371
- if (!pdfContext.viewer) {
1359
+ if (destroyed || !pdfContext.viewer || !hasMeasurableViewport()) {
1372
1360
  return;
1373
1361
  }
1374
- if ((activeFitRequest === null || activeFitRequest === void 0 ? void 0 : activeFitRequest.resize) === 'initial') {
1362
+ if ((activeFitRequest === null || activeFitRequest === void 0 ? void 0 : activeFitRequest.resize) === 'initial' && !pendingFitRequest) {
1375
1363
  return;
1376
1364
  }
1377
1365
  if (!activeFitRequest && !autoFitWidth) {
@@ -1379,6 +1367,10 @@ export default async function renderPdf(buffer, target, context) {
1379
1367
  }
1380
1368
  targetWindow.cancelAnimationFrame(fitFrame);
1381
1369
  fitFrame = targetWindow.requestAnimationFrame(() => {
1370
+ fitFrame = 0;
1371
+ if (destroyed || !hasMeasurableViewport()) {
1372
+ return;
1373
+ }
1382
1374
  if (activeFitRequest) {
1383
1375
  void applyPdfFit({ ...activeFitRequest, source: 'viewer' });
1384
1376
  return;
@@ -1502,7 +1494,12 @@ export default async function renderPdf(buffer, target, context) {
1502
1494
  markFitInteraction(source);
1503
1495
  const nextPage = Math.min(pageCount, Math.max(1, pageNumber));
1504
1496
  runWithStableHorizontalScroll(() => {
1497
+ var _a;
1505
1498
  pdfContext.viewer.currentPageNumber = nextPage;
1499
+ const page = ((_a = pdfContext.viewer.getPageView(nextPage - 1)) === null || _a === void 0 ? void 0 : _a.div)
1500
+ || pdfViewerRoot.querySelector(`.page[data-page-number="${nextPage}"]`);
1501
+ if (scrollPdfPageWithinContainer(container, page))
1502
+ pdfContext.viewer.update();
1506
1503
  currentPage = nextPage;
1507
1504
  syncUi();
1508
1505
  if (notifyViewState) {
@@ -1602,18 +1599,27 @@ export default async function renderPdf(buffer, target, context) {
1602
1599
  const page = await pdfDocument.getPage(Math.min(Math.max(pageNumber, 1), pdfDocument.numPages));
1603
1600
  const viewport = page.getViewport({
1604
1601
  scale: PixelsPerInch.PDF_TO_CSS_UNITS,
1605
- rotation: currentRotation,
1602
+ rotation: resolvePdfPageRotation(page.rotate, currentRotation),
1606
1603
  });
1607
1604
  (_b = (_a = page).cleanup) === null || _b === void 0 ? void 0 : _b.call(_a);
1608
1605
  return {
1609
- width: Math.ceil(viewport.width),
1610
- height: Math.ceil(viewport.height),
1606
+ width: viewport.width,
1607
+ height: viewport.height,
1611
1608
  };
1612
1609
  };
1613
1610
  const buildPdfPrintStyle = async () => {
1614
- const size = await getPdfPrintPageSize();
1611
+ var _a;
1612
+ const sizes = [];
1613
+ const count = ((_a = pdfContext.document) === null || _a === void 0 ? void 0 : _a.numPages) || 1;
1614
+ for (let number = 1; number <= count; number += 1) {
1615
+ if (destroyed)
1616
+ throw new Error(t('pdf.error.unloaded'));
1617
+ sizes.push(await getPdfPrintPageSize(number));
1618
+ }
1619
+ const size = sizes[0];
1615
1620
  return buildPrintPageStyle({
1616
1621
  selector: '.viewer-export-content .pdf-export-page',
1622
+ pages: sizes,
1617
1623
  width: size.width,
1618
1624
  height: size.height,
1619
1625
  });
@@ -1633,14 +1639,14 @@ export default async function renderPdf(buffer, target, context) {
1633
1639
  await ensurePdfPageCjkFontFallback(pageNumber, page);
1634
1640
  const baseViewport = page.getViewport({
1635
1641
  scale: PixelsPerInch.PDF_TO_CSS_UNITS,
1636
- rotation: currentRotation,
1642
+ rotation: resolvePdfPageRotation(page.rotate, currentRotation),
1637
1643
  });
1638
- const pageWidth = Math.ceil(baseViewport.width);
1639
- const pageHeight = Math.ceil(baseViewport.height);
1644
+ const pageWidth = baseViewport.width;
1645
+ const pageHeight = baseViewport.height;
1640
1646
  const exportRatio = getPdfExportRatio(baseViewport.width, baseViewport.height, exportOptions.mode);
1641
1647
  const renderViewport = page.getViewport({
1642
1648
  scale: PixelsPerInch.PDF_TO_CSS_UNITS * exportRatio,
1643
- rotation: currentRotation,
1649
+ rotation: resolvePdfPageRotation(page.rotate, currentRotation),
1644
1650
  });
1645
1651
  const canvas = documentRef.createElement('canvas');
1646
1652
  const canvasContext = canvas.getContext('2d');
@@ -1866,7 +1872,6 @@ export default async function renderPdf(buffer, target, context) {
1866
1872
  }
1867
1873
  }
1868
1874
  catch {
1869
- // A font object that is still unresolved cannot be repaired safely.
1870
1875
  }
1871
1876
  }
1872
1877
  const candidateFamilies = detectMalformedIdentityCjkFontFamilies(firstPageTextContent, fontName => malformedFontFamilies.get(fontName) || '');
@@ -1998,6 +2003,7 @@ export default async function renderPdf(buffer, target, context) {
1998
2003
  zoomInButton.addEventListener('click', () => zoomIn('user'));
1999
2004
  scaleButton.addEventListener('click', () => {
2000
2005
  activeFitRequest = null;
2006
+ pendingFitRequest = null;
2001
2007
  fitToWidth('user');
2002
2008
  });
2003
2009
  rotateLeftButton.addEventListener('click', () => applyRotation(currentRotation - 90, 'rotate-left', 'user'));
@@ -2016,9 +2022,6 @@ export default async function renderPdf(buffer, target, context) {
2016
2022
  });
2017
2023
  resizeObserver.observe(container);
2018
2024
  }
2019
- // PDFViewer writes this value to documentElement, which cannot safely model
2020
- // multiple differently-sized viewers. Keep a live shell-local value as well
2021
- // so Shadow DOM and multi-instance layouts both resolve the dummy-page height.
2022
2025
  root.style.setProperty('--viewer-container-height', `${container.clientHeight}px`);
2023
2026
  syncUi();
2024
2027
  void loadFile();
@@ -2027,6 +2030,7 @@ export default async function renderPdf(buffer, target, context) {
2027
2030
  unmount() {
2028
2031
  var _a, _b, _c, _d;
2029
2032
  destroyed = true;
2033
+ disposeHandTool();
2030
2034
  loadVersion += 1;
2031
2035
  restorePdfJsMissingSystemFontWarnings();
2032
2036
  restorePdfJsMissingSystemFontWarnings = () => { };
@@ -117,7 +117,6 @@ export const createPdfBoundingBoxController = ({ documentRef, targetWindow, view
117
117
  if (focus && page === focusPage) {
118
118
  await waitForPaint(targetWindow);
119
119
  focusNodes(pageNode, nodes);
120
- // PDF.js can settle dimensions one frame after fit or rotation.
121
120
  await waitForPaint(targetWindow);
122
121
  focusNodes(pageNode, nodes);
123
122
  }
@@ -1,9 +1 @@
1
- /**
2
- * PDF.js can finish an already queued page task after File Viewer has started
3
- * tearing the document down. A queued `forceRendering` callback can also run
4
- * after PDFViewer has reset its old page views and report that the old
5
- * `pdfPage` is no longer loaded. Only silence those exact message/reason pairs
6
- * inside File Viewer's scoped teardown window. All parsing, rendering, worker
7
- * and network errors remain visible.
8
- */
9
1
  export declare const isExpectedPdfJsDestroyConsoleError: (args: unknown[]) => boolean;
@@ -10,14 +10,6 @@ const readErrorLikeMessage = (value) => {
10
10
  const isPdfJsDestroyLifecycleMessage = (message) => /^Unable to get page \d+ to initialize viewer$/.test(message) ||
11
11
  message === 'Unable to get page for page view' ||
12
12
  message === 'renderView:';
13
- /**
14
- * PDF.js can finish an already queued page task after File Viewer has started
15
- * tearing the document down. A queued `forceRendering` callback can also run
16
- * after PDFViewer has reset its old page views and report that the old
17
- * `pdfPage` is no longer loaded. Only silence those exact message/reason pairs
18
- * inside File Viewer's scoped teardown window. All parsing, rendering, worker
19
- * and network errors remain visible.
20
- */
21
13
  export const isExpectedPdfJsDestroyConsoleError = (args) => {
22
14
  const [message, reason] = args;
23
15
  if (typeof message !== 'string' || !isPdfJsDestroyLifecycleMessage(message)) {
package/dist/pdfFit.d.ts CHANGED
@@ -9,11 +9,6 @@ export interface ResolvePdfFitViewportSizeInput {
9
9
  fallbackHeight: number;
10
10
  request: Pick<FileViewerFitRequest, 'viewportWidth' | 'viewportHeight' | 'padding'>;
11
11
  }
12
- /**
13
- * Resolves the PDF page viewport after the navigation pane has been laid out.
14
- * Core request dimensions already exclude fit.padding; live container and
15
- * window fallback dimensions do not, so only those branches subtract it.
16
- */
17
12
  export declare const resolvePdfFitViewportSize: ({ containerWidth, containerHeight, fallbackWidth, fallbackHeight, request, }: ResolvePdfFitViewportSizeInput) => {
18
13
  width: number;
19
14
  height: number;
package/dist/pdfFit.js CHANGED
@@ -2,11 +2,6 @@ export const PDF_FIT_MIN_VIEWPORT_SIZE = 96;
2
2
  export const PDF_FIT_HORIZONTAL_PADDING = 28;
3
3
  export const PDF_PAGE_BORDER_WIDTH = 18;
4
4
  const normalizePadding = (padding) => (Number.isFinite(padding) && Number(padding) > 0 ? Number(padding) : 0);
5
- /**
6
- * Resolves the PDF page viewport after the navigation pane has been laid out.
7
- * Core request dimensions already exclude fit.padding; live container and
8
- * window fallback dimensions do not, so only those branches subtract it.
9
- */
10
5
  export const resolvePdfFitViewportSize = ({ containerWidth, containerHeight, fallbackWidth, fallbackHeight, request, }) => {
11
6
  const padding = normalizePadding(request.padding);
12
7
  const requestWidth = Number(request.viewportWidth) || 0;
@@ -22,11 +22,6 @@ export interface CreatePdfCjkFontFallbackManagerOptions {
22
22
  fontAssetPath: string;
23
23
  onWarning?: (message: string, error?: unknown) => void;
24
24
  }
25
- /**
26
- * Some PDF generators write TrueType glyph IDs through Identity-H but omit
27
- * ToUnicode. PDF.js then exposes those glyph IDs as control characters, so a
28
- * replacement font alone cannot recover the intended text.
29
- */
30
25
  export declare const detectMalformedIdentityCjkFontFamilies: (textContent: PdfTextContent, resolveFontFamily?: (fontName: string) => string) => string[];
31
26
  export declare const collectMalformedIdentityFontNames: (textContent: PdfTextContent) => string[];
32
27
  export declare const createPdfCjkFontFallbackManager: ({ documentRef, fontAssetPath, onWarning, }: CreatePdfCjkFontFallbackManagerOptions) => PdfCjkFontFallbackManager;
@@ -100,11 +100,6 @@ const isKnownCjkFontFamily = (family) => {
100
100
  /(?:cjk|han|song|hei|kai|fang|yahei|ming|gothic|mincho)/i.test(key) ||
101
101
  /[\u3400-\u9fff]/.test(family);
102
102
  };
103
- /**
104
- * Some PDF generators write TrueType glyph IDs through Identity-H but omit
105
- * ToUnicode. PDF.js then exposes those glyph IDs as control characters, so a
106
- * replacement font alone cannot recover the intended text.
107
- */
108
103
  export const detectMalformedIdentityCjkFontFamilies = (textContent, resolveFontFamily = () => '') => {
109
104
  var _a, _b;
110
105
  const styles = textContent.styles || {};
@@ -0,0 +1 @@
1
+ export declare function installPdfHandTool(container: HTMLElement): () => void;
@@ -0,0 +1,126 @@
1
+ export function installPdfHandTool(container) {
2
+ const view = container.ownerDocument.defaultView;
3
+ if (!view)
4
+ return () => { };
5
+ const previousCursor = container.style.getPropertyValue('cursor');
6
+ const cursorPriority = container.style.getPropertyPriority('cursor');
7
+ const interactive = 'a,button,input,textarea,select,option,[contenteditable]:not([contenteditable="false"]),[role="button"],[role="link"],[role="textbox"]';
8
+ let drag = null;
9
+ let suppressClick = false;
10
+ let clickTimer = 0;
11
+ container.style.cursor = 'grab';
12
+ const finish = () => {
13
+ var _a;
14
+ if (!drag)
15
+ return;
16
+ const state = drag;
17
+ drag = null;
18
+ container.style.setProperty('user-select', state.selection, state.priority);
19
+ container.style.cursor = 'grab';
20
+ view.removeEventListener('pointermove', move, true);
21
+ view.removeEventListener('pointerup', up, true);
22
+ view.removeEventListener('pointercancel', up, true);
23
+ view.removeEventListener('blur', finish);
24
+ if ((_a = container.hasPointerCapture) === null || _a === void 0 ? void 0 : _a.call(container, state.id))
25
+ container.releasePointerCapture(state.id);
26
+ suppressClick = state.moved;
27
+ view.clearTimeout(clickTimer);
28
+ clickTimer = view.setTimeout(() => {
29
+ suppressClick = false;
30
+ }, 0);
31
+ };
32
+ const move = (event) => {
33
+ if (!drag || event.pointerId !== drag.id)
34
+ return;
35
+ if (!(event.buttons & 1)) {
36
+ finish();
37
+ return;
38
+ }
39
+ const dx = (event.clientX - drag.x) / drag.ratio;
40
+ const dy = (event.clientY - drag.y) / drag.ratio;
41
+ drag.moved || (drag.moved = Math.hypot(dx, dy) >= 3);
42
+ container.scrollLeft = drag.left - dx;
43
+ container.scrollTop = drag.top - dy;
44
+ event.preventDefault();
45
+ };
46
+ const up = (event) => {
47
+ if (event.pointerId === (drag === null || drag === void 0 ? void 0 : drag.id))
48
+ finish();
49
+ };
50
+ const down = (event) => {
51
+ var _a;
52
+ if (event.defaultPrevented ||
53
+ event.pointerType !== 'mouse' ||
54
+ event.button !== 0 ||
55
+ event.isPrimary === false ||
56
+ event.ctrlKey ||
57
+ event.metaKey ||
58
+ event.altKey ||
59
+ event.shiftKey)
60
+ return;
61
+ if (event
62
+ .composedPath()
63
+ .some((node) => { var _a, _b; return node !== container && ((_b = (_a = node).matches) === null || _b === void 0 ? void 0 : _b.call(_a, interactive)); }))
64
+ return;
65
+ if (container.scrollWidth <= container.clientWidth &&
66
+ container.scrollHeight <= container.clientHeight)
67
+ return;
68
+ const rect = container.getBoundingClientRect();
69
+ const ratio = container.offsetWidth > 0 ? rect.width / container.offsetWidth : 1;
70
+ if (!Number.isFinite(ratio) || ratio <= 0)
71
+ return;
72
+ const x = (event.clientX - rect.left) / ratio - container.clientLeft;
73
+ const y = (event.clientY - rect.top) / ratio - container.clientTop;
74
+ if (x < 0 || y < 0 || x >= container.clientWidth || y >= container.clientHeight)
75
+ return;
76
+ finish();
77
+ suppressClick = false;
78
+ drag = {
79
+ id: event.pointerId,
80
+ x: event.clientX,
81
+ y: event.clientY,
82
+ left: container.scrollLeft,
83
+ top: container.scrollTop,
84
+ ratio,
85
+ moved: false,
86
+ selection: container.style.getPropertyValue('user-select'),
87
+ priority: container.style.getPropertyPriority('user-select')
88
+ };
89
+ container.style.cursor = 'grabbing';
90
+ container.style.setProperty('user-select', 'none');
91
+ try {
92
+ (_a = container.setPointerCapture) === null || _a === void 0 ? void 0 : _a.call(container, event.pointerId);
93
+ }
94
+ catch {
95
+ }
96
+ view.addEventListener('pointermove', move, { capture: true, passive: false });
97
+ view.addEventListener('pointerup', up, true);
98
+ view.addEventListener('pointercancel', up, true);
99
+ view.addEventListener('blur', finish);
100
+ event.preventDefault();
101
+ };
102
+ const click = (event) => {
103
+ if (suppressClick && event.detail > 0) {
104
+ event.preventDefault();
105
+ event.stopImmediatePropagation();
106
+ }
107
+ };
108
+ const nativeDrag = (event) => {
109
+ if (drag)
110
+ event.preventDefault();
111
+ };
112
+ container.addEventListener('pointerdown', down);
113
+ container.addEventListener('lostpointercapture', up);
114
+ container.addEventListener('click', click, true);
115
+ container.addEventListener('dragstart', nativeDrag);
116
+ return () => {
117
+ finish();
118
+ view.clearTimeout(clickTimer);
119
+ suppressClick = false;
120
+ container.style.setProperty('cursor', previousCursor, cursorPriority);
121
+ container.removeEventListener('pointerdown', down);
122
+ container.removeEventListener('lostpointercapture', up);
123
+ container.removeEventListener('click', click, true);
124
+ container.removeEventListener('dragstart', nativeDrag);
125
+ };
126
+ }
@@ -1,2 +1 @@
1
- /** @internal Shared only with the source-level regression tests. */
2
1
  export declare const normalizePdfIdentityFontFamily: (value: string) => string;
@@ -42,7 +42,6 @@ const stripFontStyleSuffix = (value) => {
42
42
  }
43
43
  return value;
44
44
  };
45
- /** @internal Shared only with the source-level regression tests. */
46
45
  export const normalizePdfIdentityFontFamily = (value) => {
47
46
  if (!value || value.length > MAX_PDF_IDENTITY_FONT_NAME_CHARACTERS)
48
47
  return '';
@@ -425,7 +425,6 @@ export const repairMalformedIdentityCjkFonts = async (sourceBytes, candidateFami
425
425
  }
426
426
  }
427
427
  catch {
428
- // A different same-family embedded font may still provide a valid cmap.
429
428
  }
430
429
  }
431
430
  if (!bestMap || bestMap.size < 2) {
@@ -0,0 +1 @@
1
+ export declare function scrollPdfPageWithinContainer(container: HTMLElement, page: HTMLElement | null): boolean;
@@ -0,0 +1,12 @@
1
+ export function scrollPdfPageWithinContainer(container, page) {
2
+ if (!page || !container.contains(page) || container.clientHeight <= 0)
3
+ return false;
4
+ const containerRect = container.getBoundingClientRect();
5
+ const pageRect = page.getBoundingClientRect();
6
+ const scale = container.offsetHeight > 0 ? containerRect.height / container.offsetHeight : 1;
7
+ if (!Number.isFinite(scale) || scale <= 0 || pageRect.height <= 0)
8
+ return false;
9
+ const top = container.scrollTop + (pageRect.top - containerRect.top) / scale - container.clientTop;
10
+ container.scrollTop = Math.min(Math.max(0, top), Math.max(0, container.scrollHeight - container.clientHeight));
11
+ return true;
12
+ }
@@ -1,6 +1,7 @@
1
1
  import type { FileViewerViewState } from '@file-viewer/core';
2
2
  export type PdfRotation = 0 | 90 | 180 | 270;
3
3
  export declare const normalizePdfRotation: (rotation: number) => PdfRotation;
4
+ export declare const resolvePdfPageRotation: (pageRotation: number, viewerRotation: number) => PdfRotation;
4
5
  export declare const clampPdfScale: (scale: number, minScale: number, maxScale: number) => number;
5
6
  export declare const resolvePdfViewStateUpdate: (state: FileViewerViewState, current: {
6
7
  rotation: number;
@@ -2,6 +2,7 @@ export const normalizePdfRotation = (rotation) => {
2
2
  const normalized = (((Math.round(rotation / 90) * 90) % 360) + 360) % 360;
3
3
  return (normalized === 90 || normalized === 180 || normalized === 270 ? normalized : 0);
4
4
  };
5
+ export const resolvePdfPageRotation = (pageRotation, viewerRotation) => normalizePdfRotation(normalizePdfRotation(pageRotation) + normalizePdfRotation(viewerRotation));
5
6
  export const clampPdfScale = (scale, minScale, maxScale) => {
6
7
  return Number(Math.min(maxScale, Math.max(minScale, scale)).toFixed(2));
7
8
  };
@@ -15,13 +15,4 @@ export type PdfJsWorkerGlobalSnapshot = {
15
15
  namespace: PdfJsWorkerNamespace | undefined;
16
16
  };
17
17
  export declare const capturePdfJsWorkerGlobal: (workerGlobal: PdfJsWorkerGlobal) => PdfJsWorkerGlobalSnapshot;
18
- /**
19
- * Temporarily own the fake-worker handler used by this renderer.
20
- *
21
- * Host applications can load another PDF.js build before File Viewer. Reusing
22
- * that global handler is unsafe because PDF.js requires its API and worker
23
- * versions to match exactly. The original namespace is restored after our
24
- * PDFWorker has captured and initialized the bundled handler, so a host PDF.js
25
- * build can continue using its own global afterwards.
26
- */
27
18
  export declare const scopePdfJsWorkerMessageHandler: (workerGlobal: PdfJsWorkerGlobal, WorkerMessageHandler: unknown, restoreSnapshot?: PdfJsWorkerGlobalSnapshot) => PdfJsWorkerHandlerScope;
@@ -2,15 +2,6 @@ export const capturePdfJsWorkerGlobal = (workerGlobal) => ({
2
2
  hadOwnNamespace: Object.prototype.hasOwnProperty.call(workerGlobal, 'pdfjsWorker'),
3
3
  namespace: workerGlobal.pdfjsWorker,
4
4
  });
5
- /**
6
- * Temporarily own the fake-worker handler used by this renderer.
7
- *
8
- * Host applications can load another PDF.js build before File Viewer. Reusing
9
- * that global handler is unsafe because PDF.js requires its API and worker
10
- * versions to match exactly. The original namespace is restored after our
11
- * PDFWorker has captured and initialized the bundled handler, so a host PDF.js
12
- * build can continue using its own global afterwards.
13
- */
14
5
  export const scopePdfJsWorkerMessageHandler = (workerGlobal, WorkerMessageHandler, restoreSnapshot = capturePdfJsWorkerGlobal(workerGlobal)) => {
15
6
  const currentNamespace = workerGlobal.pdfjsWorker;
16
7
  const installResult = (currentNamespace === null || currentNamespace === void 0 ? void 0 : currentNamespace.WorkerMessageHandler) === WorkerMessageHandler
@@ -1,9 +1 @@
1
- /**
2
- * Read the version marker emitted by official PDF.js worker bundles.
3
- *
4
- * The marker is intentionally read from a small source prefix before a Worker
5
- * is constructed. PDF.js does not reject an API/worker mismatch until the
6
- * first document request, which is too late for `PDFWorker.promise` to be a
7
- * useful compatibility probe.
8
- */
9
1
  export declare const readPdfJsWorkerVersion: (sourcePrefix: string) => string | null;
@@ -4,14 +4,6 @@ const PDF_JS_WORKER_VERSION_PATTERNS = [
4
4
  new RegExp(`\\bworkerVersion\\s*=\\s*["']${PDF_JS_SEMVER_PATTERN}["']`, 'i'),
5
5
  new RegExp(`\\bPDF\\.js\\s+v${PDF_JS_SEMVER_PATTERN}`, 'i'),
6
6
  ];
7
- /**
8
- * Read the version marker emitted by official PDF.js worker bundles.
9
- *
10
- * The marker is intentionally read from a small source prefix before a Worker
11
- * is constructed. PDF.js does not reject an API/worker mismatch until the
12
- * first document request, which is too late for `PDFWorker.promise` to be a
13
- * useful compatibility probe.
14
- */
15
7
  export const readPdfJsWorkerVersion = (sourcePrefix) => {
16
8
  for (const pattern of PDF_JS_WORKER_VERSION_PATTERNS) {
17
9
  const match = pattern.exec(sourcePrefix);
@@ -1,4 +1,4 @@
1
- /* File Viewer modification: isolated PDF.js internal webpack runtime identifiers for webpack 4 compatibility. */
1
+ /* File Viewer modification: isolated PDF.js internal webpack runtime identifiers for webpack 4 compatibility and removed unavailable source-map metadata. */
2
2
  /**
3
3
  * @licstart The following is the entire license notice for the
4
4
  * JavaScript code in this page
@@ -32797,4 +32797,3 @@ globalThis.pdfjsLib = {
32797
32797
 
32798
32798
  export { AbortException, AnnotationEditorLayer, AnnotationEditorParamsType, AnnotationEditorType, AnnotationEditorUIManager, AnnotationLayer, AnnotationMode, AnnotationType, CSSConstants, ColorPicker, DOMSVGFactory, DrawLayer, util_FeatureTest as FeatureTest, GlobalWorkerOptions, util_ImageKind as ImageKind, InvalidPDFException, MathClamp, OPS, OutputScale, PDFDataRangeTransport, PDFDateString, PDFWorker, PagesMapper, PasswordResponses, PermissionFlag, PixelsPerInch, RenderingCancelledException, ResponseException, SignatureExtractor, SupportedImageMimeTypes, TextLayer, TouchManager, Util, VerbosityLevel, XfaLayer, applyOpacity, build, createValidAbsoluteUrl, fetchData, findContrastColor, getDocument, getFilenameFromUrl, getPdfFilenameFromUrl, getRGB, getUuid, getXfaPageViewport, isDataScheme, isPdfFile, isValidExplicitDest, noContextMenu, normalizeUnicode, renderRichText, setLayerDimensions, shadow, stopEvent, updateUrlHash, version };
32799
32799
 
32800
- //# sourceMappingURL=pdf.mjs.map
@@ -1,4 +1,4 @@
1
- /* File Viewer modification: isolated PDF.js internal webpack runtime identifiers for webpack 4 compatibility. */
1
+ /* File Viewer modification: isolated PDF.js internal webpack runtime identifiers for webpack 4 compatibility and removed unavailable source-map metadata. */
2
2
  /**
3
3
  * @licstart The following is the entire license notice for the
4
4
  * JavaScript code in this page
@@ -67399,4 +67399,3 @@ globalThis.pdfjsWorker = {
67399
67399
 
67400
67400
  export { WorkerMessageHandler };
67401
67401
 
67402
- //# sourceMappingURL=pdf.worker.mjs.map
@@ -1,4 +1,4 @@
1
- /* File Viewer modification: isolated PDF.js internal webpack runtime identifiers for webpack 4 compatibility. */
1
+ /* File Viewer modification: isolated PDF.js internal webpack runtime identifiers for webpack 4 compatibility and removed unavailable source-map metadata. */
2
2
  /**
3
3
  * @licstart The following is the entire license notice for the
4
4
  * JavaScript code in this page
@@ -14445,4 +14445,3 @@ globalThis.pdfjsViewer = {
14445
14445
 
14446
14446
  export { AnnotationLayerBuilder, DownloadManager, EventBus, FindState, genericl10n_GenericL10n as GenericL10n, LinkTarget, PDFFindController, PDFHistory, PDFLinkService, PDFPageView, PDFScriptingManagerComponents as PDFScriptingManager, PDFSinglePageViewer, PDFViewer, ProgressBar, RenderingStates, ScrollMode, SimpleLinkService, SpreadMode, StructTreeLayerBuilder, TextLayerBuilder, XfaLayerBuilder, parseQueryString };
14447
14447
 
14448
- //# sourceMappingURL=pdf_viewer.mjs.map
@@ -4,7 +4,7 @@
4
4
  "version": "5.4.624",
5
5
  "sourceRepository": "https://github.com/mozilla/pdf.js",
6
6
  "licenseSpdx": "Apache-2.0",
7
- "runtimeTransform": "isolate-pdfjs-webpack4-runtime-v1",
7
+ "runtimeTransform": "isolate-pdfjs-webpack4-runtime-v2",
8
8
  "sourcePatches": [
9
9
  {
10
10
  "path": "patches/pdfjs-dist@5.4.624.patch",
@@ -18,24 +18,24 @@
18
18
  "sourceSize": 976824,
19
19
  "sourceSha256": "5464c1bf96dddd169eed8f4afacffde4c9369d397b7eb383fb6bbe2e28fa400c",
20
20
  "runtimeBindingReplacements": 843,
21
- "size": 981996,
22
- "sha256": "af40b0e9b6f237cb40659afcd100f84ec21bc7d5d9044fa0cfc2d6a506b8e489"
21
+ "size": 982008,
22
+ "sha256": "e194c0650817dffdbdf0bf76bfde918b64021c4b699d6914f7d3ae20cec6d4dd"
23
23
  },
24
24
  {
25
25
  "path": "legacy/build/pdf.worker.mjs",
26
26
  "sourceSize": 2139821,
27
27
  "sourceSha256": "6c97b16c12986a5043311d7c4a15043e6f160db2503795e9a6804b85e8054c1d",
28
28
  "runtimeBindingReplacements": 793,
29
- "size": 2144693,
30
- "sha256": "6dbca20dcff89ef88c00b543bf66873be2ad778d17a65f9e426f75b57774d432"
29
+ "size": 2144698,
30
+ "sha256": "195cbedfa6bb5d7f4e6296c06fdf38b193a53de623127865677355ea164e1b03"
31
31
  },
32
32
  {
33
33
  "path": "legacy/web/pdf_viewer.mjs",
34
34
  "sourceSize": 453414,
35
35
  "sourceSha256": "c993ef3af7e11a28e7ce15bef6717adf14617a0451f02861a5cd90c5fe5bf00e",
36
36
  "runtimeBindingReplacements": 687,
37
- "size": 457650,
38
- "sha256": "b5856515ea724805f70febb0694e729a88604bc1071d01091bb35595d4808b99"
37
+ "size": 457655,
38
+ "sha256": "03ccd6120d3149278a90c9b58e6b7ab90eb80d3d5bb6f6f70f5635a3f145cfe9"
39
39
  }
40
40
  ],
41
41
  "assetDirectories": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@file-viewer/renderer-pdf",
3
- "version": "3.1.2",
3
+ "version": "3.2.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Standalone PDF renderer plugin for File Viewer powered by PDF.js.",
@@ -25,8 +25,7 @@
25
25
  },
26
26
  "repository": {
27
27
  "type": "git",
28
- "url": "git+https://github.com/flyfish-dev/file-viewer.git",
29
- "directory": "packages/renderers/pdf"
28
+ "url": "git+https://github.com/flyfish-dev/file-viewer.git"
30
29
  },
31
30
  "homepage": "https://doc.file-viewer.app/guide/on-demand-renderers",
32
31
  "bugs": {
@@ -53,14 +52,246 @@
53
52
  "./package.json": "./package.json"
54
53
  },
55
54
  "files": [
56
- "dist",
55
+ "dist/index.d.ts",
56
+ "dist/index.js",
57
+ "dist/optionalCapabilities.d.ts",
58
+ "dist/optionalCapabilities.js",
59
+ "dist/pdf.d.ts",
60
+ "dist/pdf.js",
61
+ "dist/pdfBbox.d.ts",
62
+ "dist/pdfBbox.js",
63
+ "dist/pdfBboxController.d.ts",
64
+ "dist/pdfBboxController.js",
65
+ "dist/pdfConsoleLifecycle.d.ts",
66
+ "dist/pdfConsoleLifecycle.js",
67
+ "dist/pdfFit.d.ts",
68
+ "dist/pdfFit.js",
69
+ "dist/pdfFontFallback.d.ts",
70
+ "dist/pdfFontFallback.js",
71
+ "dist/pdfHandTool.d.ts",
72
+ "dist/pdfHandTool.js",
73
+ "dist/pdfIdentityFontName.d.ts",
74
+ "dist/pdfIdentityFontName.js",
75
+ "dist/pdfIdentityFontRepair.d.ts",
76
+ "dist/pdfIdentityFontRepair.js",
77
+ "dist/pdfPageScroll.d.ts",
78
+ "dist/pdfPageScroll.js",
79
+ "dist/pdfStyles.d.ts",
80
+ "dist/pdfStyles.js",
81
+ "dist/pdfViewState.d.ts",
82
+ "dist/pdfViewState.js",
83
+ "dist/pdfWorkerGlobal.d.ts",
84
+ "dist/pdfWorkerGlobal.js",
85
+ "dist/pdfWorkerVersion.d.ts",
86
+ "dist/pdfWorkerVersion.js",
87
+ "dist/vendor/pdfjs/cmaps/78-EUC-H.bcmap",
88
+ "dist/vendor/pdfjs/cmaps/78-EUC-V.bcmap",
89
+ "dist/vendor/pdfjs/cmaps/78-H.bcmap",
90
+ "dist/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap",
91
+ "dist/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap",
92
+ "dist/vendor/pdfjs/cmaps/78-V.bcmap",
93
+ "dist/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap",
94
+ "dist/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap",
95
+ "dist/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap",
96
+ "dist/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap",
97
+ "dist/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap",
98
+ "dist/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap",
99
+ "dist/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap",
100
+ "dist/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap",
101
+ "dist/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap",
102
+ "dist/vendor/pdfjs/cmaps/Add-H.bcmap",
103
+ "dist/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap",
104
+ "dist/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap",
105
+ "dist/vendor/pdfjs/cmaps/Add-V.bcmap",
106
+ "dist/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap",
107
+ "dist/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap",
108
+ "dist/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap",
109
+ "dist/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap",
110
+ "dist/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap",
111
+ "dist/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap",
112
+ "dist/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap",
113
+ "dist/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap",
114
+ "dist/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap",
115
+ "dist/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap",
116
+ "dist/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap",
117
+ "dist/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap",
118
+ "dist/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap",
119
+ "dist/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap",
120
+ "dist/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap",
121
+ "dist/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap",
122
+ "dist/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap",
123
+ "dist/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap",
124
+ "dist/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap",
125
+ "dist/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap",
126
+ "dist/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap",
127
+ "dist/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap",
128
+ "dist/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap",
129
+ "dist/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap",
130
+ "dist/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap",
131
+ "dist/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap",
132
+ "dist/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap",
133
+ "dist/vendor/pdfjs/cmaps/B5-H.bcmap",
134
+ "dist/vendor/pdfjs/cmaps/B5-V.bcmap",
135
+ "dist/vendor/pdfjs/cmaps/B5pc-H.bcmap",
136
+ "dist/vendor/pdfjs/cmaps/B5pc-V.bcmap",
137
+ "dist/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap",
138
+ "dist/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap",
139
+ "dist/vendor/pdfjs/cmaps/CNS1-H.bcmap",
140
+ "dist/vendor/pdfjs/cmaps/CNS1-V.bcmap",
141
+ "dist/vendor/pdfjs/cmaps/CNS2-H.bcmap",
142
+ "dist/vendor/pdfjs/cmaps/CNS2-V.bcmap",
143
+ "dist/vendor/pdfjs/cmaps/ETen-B5-H.bcmap",
144
+ "dist/vendor/pdfjs/cmaps/ETen-B5-V.bcmap",
145
+ "dist/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap",
146
+ "dist/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap",
147
+ "dist/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap",
148
+ "dist/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap",
149
+ "dist/vendor/pdfjs/cmaps/EUC-H.bcmap",
150
+ "dist/vendor/pdfjs/cmaps/EUC-V.bcmap",
151
+ "dist/vendor/pdfjs/cmaps/Ext-H.bcmap",
152
+ "dist/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap",
153
+ "dist/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap",
154
+ "dist/vendor/pdfjs/cmaps/Ext-V.bcmap",
155
+ "dist/vendor/pdfjs/cmaps/GB-EUC-H.bcmap",
156
+ "dist/vendor/pdfjs/cmaps/GB-EUC-V.bcmap",
157
+ "dist/vendor/pdfjs/cmaps/GB-H.bcmap",
158
+ "dist/vendor/pdfjs/cmaps/GB-V.bcmap",
159
+ "dist/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap",
160
+ "dist/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap",
161
+ "dist/vendor/pdfjs/cmaps/GBK2K-H.bcmap",
162
+ "dist/vendor/pdfjs/cmaps/GBK2K-V.bcmap",
163
+ "dist/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap",
164
+ "dist/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap",
165
+ "dist/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap",
166
+ "dist/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap",
167
+ "dist/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap",
168
+ "dist/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap",
169
+ "dist/vendor/pdfjs/cmaps/GBT-H.bcmap",
170
+ "dist/vendor/pdfjs/cmaps/GBT-V.bcmap",
171
+ "dist/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap",
172
+ "dist/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap",
173
+ "dist/vendor/pdfjs/cmaps/H.bcmap",
174
+ "dist/vendor/pdfjs/cmaps/Hankaku.bcmap",
175
+ "dist/vendor/pdfjs/cmaps/Hiragana.bcmap",
176
+ "dist/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap",
177
+ "dist/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap",
178
+ "dist/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap",
179
+ "dist/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap",
180
+ "dist/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap",
181
+ "dist/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap",
182
+ "dist/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap",
183
+ "dist/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap",
184
+ "dist/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap",
185
+ "dist/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap",
186
+ "dist/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap",
187
+ "dist/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap",
188
+ "dist/vendor/pdfjs/cmaps/Katakana.bcmap",
189
+ "dist/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap",
190
+ "dist/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap",
191
+ "dist/vendor/pdfjs/cmaps/KSC-H.bcmap",
192
+ "dist/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap",
193
+ "dist/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap",
194
+ "dist/vendor/pdfjs/cmaps/KSC-V.bcmap",
195
+ "dist/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap",
196
+ "dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap",
197
+ "dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap",
198
+ "dist/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap",
199
+ "dist/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap",
200
+ "dist/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap",
201
+ "dist/vendor/pdfjs/cmaps/LICENSE",
202
+ "dist/vendor/pdfjs/cmaps/NWP-H.bcmap",
203
+ "dist/vendor/pdfjs/cmaps/NWP-V.bcmap",
204
+ "dist/vendor/pdfjs/cmaps/RKSJ-H.bcmap",
205
+ "dist/vendor/pdfjs/cmaps/RKSJ-V.bcmap",
206
+ "dist/vendor/pdfjs/cmaps/Roman.bcmap",
207
+ "dist/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap",
208
+ "dist/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap",
209
+ "dist/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap",
210
+ "dist/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap",
211
+ "dist/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap",
212
+ "dist/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap",
213
+ "dist/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap",
214
+ "dist/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap",
215
+ "dist/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap",
216
+ "dist/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap",
217
+ "dist/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap",
218
+ "dist/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap",
219
+ "dist/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap",
220
+ "dist/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap",
221
+ "dist/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap",
222
+ "dist/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap",
223
+ "dist/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap",
224
+ "dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap",
225
+ "dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap",
226
+ "dist/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap",
227
+ "dist/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap",
228
+ "dist/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap",
229
+ "dist/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap",
230
+ "dist/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap",
231
+ "dist/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap",
232
+ "dist/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap",
233
+ "dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap",
234
+ "dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap",
235
+ "dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap",
236
+ "dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap",
237
+ "dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap",
238
+ "dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap",
239
+ "dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap",
240
+ "dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap",
241
+ "dist/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap",
242
+ "dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap",
243
+ "dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap",
244
+ "dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap",
245
+ "dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap",
246
+ "dist/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap",
247
+ "dist/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap",
248
+ "dist/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap",
249
+ "dist/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap",
250
+ "dist/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap",
251
+ "dist/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap",
252
+ "dist/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap",
253
+ "dist/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap",
254
+ "dist/vendor/pdfjs/cmaps/V.bcmap",
255
+ "dist/vendor/pdfjs/cmaps/WP-Symbol.bcmap",
256
+ "dist/vendor/pdfjs/legacy/build/pdf.mjs",
257
+ "dist/vendor/pdfjs/legacy/build/pdf.worker.mjs",
258
+ "dist/vendor/pdfjs/legacy/web/pdf_viewer.mjs",
259
+ "dist/vendor/pdfjs/LICENSE",
260
+ "dist/vendor/pdfjs/NOTICE",
261
+ "dist/vendor/pdfjs/provenance.json",
262
+ "dist/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb",
263
+ "dist/vendor/pdfjs/standard_fonts/FoxitFixed.pfb",
264
+ "dist/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb",
265
+ "dist/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb",
266
+ "dist/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb",
267
+ "dist/vendor/pdfjs/standard_fonts/FoxitSerif.pfb",
268
+ "dist/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb",
269
+ "dist/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb",
270
+ "dist/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb",
271
+ "dist/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb",
272
+ "dist/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf",
273
+ "dist/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf",
274
+ "dist/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf",
275
+ "dist/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf",
276
+ "dist/vendor/pdfjs/standard_fonts/LICENSE_FOXIT",
277
+ "dist/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION",
278
+ "dist/vendor/pdfjs/wasm/jbig2.wasm",
279
+ "dist/vendor/pdfjs/wasm/LICENSE_JBIG2",
280
+ "dist/vendor/pdfjs/wasm/LICENSE_OPENJPEG",
281
+ "dist/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2",
282
+ "dist/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG",
283
+ "dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS",
284
+ "dist/vendor/pdfjs/wasm/LICENSE_QCMS",
285
+ "dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js",
286
+ "dist/vendor/pdfjs/wasm/openjpeg.wasm",
287
+ "dist/vendor/pdfjs/wasm/qcms_bg.wasm",
57
288
  "file-viewer.capability.json",
58
- "README.md",
289
+ "LICENSE",
59
290
  "README.en.md",
60
- "LICENSE"
291
+ "README.md"
61
292
  ],
62
293
  "dependencies": {
63
- "@file-viewer/core": "3.1.2",
294
+ "@file-viewer/core": "3.2.0",
64
295
  "@fontsource-variable/noto-sans-sc": "5.3.0"
65
296
  },
66
297
  "peerDependencies": {
@@ -71,19 +302,12 @@
71
302
  "optional": true
72
303
  }
73
304
  },
74
- "devDependencies": {
75
- "pdf-lib": "1.17.1",
76
- "pdfjs-dist": "5.4.624",
77
- "typescript": "^6.0.3"
78
- },
79
305
  "fileViewer": {
80
- "capabilityManifest": "./file-viewer.capability.json"
306
+ "capabilityManifest": "./file-viewer.capability.json",
307
+ "distribution": {
308
+ "schemaVersion": 1,
309
+ "mode": "runtime-only"
310
+ }
81
311
  },
82
- "license": "Apache-2.0",
83
- "scripts": {
84
- "build": "tsc -b tsconfig.json && node scripts/stage-pdfjs-runtime.mjs",
85
- "type-check": "tsc -b tsconfig.json",
86
- "verify:pdfjs-runtime": "node scripts/stage-pdfjs-runtime.mjs --check",
87
- "verify:worker-lifecycle": "npm exec --yes --package playwright@1.61.1 -- node scripts/verify-worker-lifecycle.mjs"
88
- }
89
- }
312
+ "license": "Apache-2.0"
313
+ }
@@ -1,112 +0,0 @@
1
- diff --git a/legacy/build/pdf.worker.mjs b/legacy/build/pdf.worker.mjs
2
- index b7416c415e6490b16f642562003f54e78ab345f8..d2070ba6f1ecaaa5659977ef5ac577ee89195e75 100644
3
- --- a/legacy/build/pdf.worker.mjs
4
- +++ b/legacy/build/pdf.worker.mjs
5
- @@ -66846,15 +66846,21 @@ class WorkerMessageHandler {
6
- };
7
- return pdfManagerCapability.promise;
8
- }
9
- + // File Viewer modification: canceled initialization must not reject detached
10
- + // startup promises or send messages through an already destroyed handler.
11
- function setupDoc(data) {
12
- function onSuccess(doc) {
13
- - ensureNotTerminated();
14
- + if (terminated) {
15
- + return;
16
- + }
17
- handler.send("GetDoc", {
18
- pdfInfo: doc
19
- });
20
- }
21
- function onFailure(ex) {
22
- - ensureNotTerminated();
23
- + if (terminated) {
24
- + return;
25
- + }
26
- if (ex instanceof PasswordException) {
27
- const task = new WorkerTask(`PasswordException: response ${ex.code}`);
28
- startWorkerTask(task);
29
- @@ -66862,43 +66868,67 @@ class WorkerMessageHandler {
30
- password
31
- }) {
32
- finishWorkerTask(task);
33
- + if (terminated) {
34
- + return;
35
- + }
36
- pdfManager.updatePassword(password);
37
- pdfManagerReady();
38
- }).catch(function () {
39
- finishWorkerTask(task);
40
- + if (terminated) {
41
- + return;
42
- + }
43
- handler.send("DocException", ex);
44
- });
45
- } else {
46
- handler.send("DocException", wrapReason(ex));
47
- }
48
- }
49
- - function pdfManagerReady() {
50
- - ensureNotTerminated();
51
- - loadDocument(false).then(onSuccess, function (reason) {
52
- - ensureNotTerminated();
53
- - if (!(reason instanceof XRefParseException)) {
54
- - onFailure(reason);
55
- - return;
56
- + async function pdfManagerReady() {
57
- + if (terminated) {
58
- + return;
59
- + }
60
- + try {
61
- + let doc;
62
- + try {
63
- + doc = await loadDocument(false);
64
- + } catch (reason) {
65
- + if (terminated) {
66
- + return;
67
- + }
68
- + if (!(reason instanceof XRefParseException)) {
69
- + throw reason;
70
- + }
71
- + await pdfManager.requestLoadedStream();
72
- + if (terminated) {
73
- + return;
74
- + }
75
- + doc = await loadDocument(true);
76
- }
77
- - pdfManager.requestLoadedStream().then(function () {
78
- - ensureNotTerminated();
79
- - loadDocument(true).then(onSuccess, onFailure);
80
- - });
81
- - });
82
- + onSuccess(doc);
83
- + } catch (reason) {
84
- + onFailure(reason);
85
- + }
86
- + }
87
- + if (terminated) {
88
- + return;
89
- }
90
- - ensureNotTerminated();
91
- getPdfManager(data).then(function (newPdfManager) {
92
- if (terminated) {
93
- newPdfManager.terminate(new AbortException("Worker was terminated."));
94
- - throw new Error("Worker was terminated");
95
- + return;
96
- }
97
- pdfManager = newPdfManager;
98
- pdfManager.requestLoadedStream(true).then(stream => {
99
- + if (terminated) {
100
- + return;
101
- + }
102
- handler.send("DataLoaded", {
103
- length: stream.bytes.byteLength
104
- });
105
- - });
106
- - }).then(pdfManagerReady, onFailure);
107
- + }, onFailure);
108
- + return pdfManagerReady();
109
- + }).catch(onFailure);
110
- }
111
- handler.on("GetPage", function (data) {
112
- return pdfManager.getPage(data.pageIndex).then(function (page) {