@file-viewer/renderer-pdf 2.1.27 → 2.1.28

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.
Files changed (2) hide show
  1. package/dist/pdf.js +2 -46
  2. package/package.json +2 -2
package/dist/pdf.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getDocument, GlobalWorkerOptions, PDFWorker as PdfJsWorker, PixelsPerInch, } from 'pdfjs-dist/legacy/build/pdf.mjs';
2
2
  import { EventBus, GenericL10n, PDFFindController, PDFLinkService, PDFViewer, } from 'pdfjs-dist/legacy/web/pdf_viewer.mjs';
3
3
  import { registerFileViewerSearchProvider, registerFileViewerZoomProvider, unregisterFileViewerSearchProvider, unregisterFileViewerZoomProvider, registerFileViewerViewStateProvider, unregisterFileViewerViewStateProvider, createFileViewerZoomChangeEmitter, createFileViewerViewStateChange, createFileViewerViewStateChangeEmitter, createFileViewerTranslator, buildPrintPageStyle, formatCssPixels, DEFAULT_PDF_RANGE_CHUNK_SIZE, resolveFileViewerLocale, resolveFileViewerFitScale, } from '@file-viewer/core';
4
- import { DEFAULT_FILE_VIEWER_PDF_WORKER_PATH, resolveFileViewerPdfAssetUrls, } from '@file-viewer/core/assets';
4
+ import { DEFAULT_FILE_VIEWER_PDF_WORKER_PATH, resolveFileViewerPdfAssetUrls, resolveFileViewerRuntimeAssetBaseUrl, } from '@file-viewer/core/assets';
5
5
  import { pdfViewerStyle } from './pdfStyles.js';
6
6
  import { collectMalformedIdentityFontNames, createPdfCjkFontFallbackManager, detectMalformedIdentityCjkFontFamilies, } from './pdfFontFallback.js';
7
7
  export const DEFAULT_FILE_VIEWER_PDF_WORKER_URL = DEFAULT_FILE_VIEWER_PDF_WORKER_PATH;
@@ -254,50 +254,6 @@ const installBundledPdfFakeWorker = async () => {
254
254
  const resolvePdfWorkerUrl = (options, documentBaseUrl) => {
255
255
  return resolveFileViewerPdfAssetUrls(options, documentBaseUrl).workerUrl;
256
256
  };
257
- const readBundlerPublicBaseUrl = () => {
258
- var _a;
259
- try {
260
- const value = (_a = import.meta.env) === null || _a === void 0 ? void 0 : _a.BASE_URL;
261
- return typeof value === 'string' ? value.trim() : '';
262
- }
263
- catch {
264
- return '';
265
- }
266
- };
267
- const resolvePdfRuntimeAssetBaseUrl = (documentRef) => {
268
- const documentBaseUrl = documentRef.baseURI || documentRef.URL || 'file:///';
269
- const bundlerBaseUrl = readBundlerPublicBaseUrl();
270
- if (bundlerBaseUrl && bundlerBaseUrl !== '.' && bundlerBaseUrl !== './') {
271
- try {
272
- return new URL(bundlerBaseUrl.endsWith('/') ? bundlerBaseUrl : `${bundlerBaseUrl}/`, documentBaseUrl).href;
273
- }
274
- catch {
275
- // Continue with DOM-based public-path detection.
276
- }
277
- }
278
- // An explicit <base> is authoritative and already reflected by baseURI.
279
- if (documentRef.querySelector('base[href]')) {
280
- return documentBaseUrl;
281
- }
282
- // Entry scripts remain under the public deployment base when an SPA route
283
- // changes document.baseURI. This covers Vite and common UMI/Webpack layouts.
284
- for (const script of Array.from(documentRef.querySelectorAll('script[src]'))) {
285
- try {
286
- const scriptUrl = new URL(script.src || script.getAttribute('src') || '', documentBaseUrl);
287
- const assetDirectory = scriptUrl.pathname.match(/^(.*\/)(?:assets|static)\/[^/]+$/i);
288
- if (assetDirectory) {
289
- return new URL(assetDirectory[1], scriptUrl.origin).href;
290
- }
291
- if (/\/(?:umi|main|index)(?:[.-][^/]*)?\.(?:m?js)$/i.test(scriptUrl.pathname)) {
292
- return new URL('./', scriptUrl).href;
293
- }
294
- }
295
- catch {
296
- // Ignore unrelated or malformed script URLs.
297
- }
298
- }
299
- return documentBaseUrl;
300
- };
301
257
  const buildOutlineItems = (items, prefix = 'outline', getFallbackTitle = index => `Outline ${index + 1}`) => items.map((item, index) => {
302
258
  const id = `${prefix}-${index}`;
303
259
  const children = Array.isArray(item.items)
@@ -321,7 +277,7 @@ export default async function renderPdf(buffer, target, context) {
321
277
  throw new Error(t('pdf.error.browserWindow'));
322
278
  }
323
279
  const options = (_a = context === null || context === void 0 ? void 0 : context.options) === null || _a === void 0 ? void 0 : _a.pdf;
324
- const pdfRuntimeAssetBaseUrl = resolvePdfRuntimeAssetBaseUrl(documentRef);
280
+ const pdfRuntimeAssetBaseUrl = resolveFileViewerRuntimeAssetBaseUrl(documentRef);
325
281
  const cjkFontFallbackEnabled = (options === null || options === void 0 ? void 0 : options.cjkFontFallback) !== false;
326
282
  const identityFontRepairEnabled = (options === null || options === void 0 ? void 0 : options.identityFontRepair) !== false;
327
283
  const fontInspectionEnabled = cjkFontFallbackEnabled || identityFontRepairEnabled;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@file-viewer/renderer-pdf",
3
- "version": "2.1.27",
3
+ "version": "2.1.28",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Standalone PDF renderer plugin for Flyfish File Viewer powered by PDF.js.",
@@ -54,7 +54,7 @@
54
54
  "LICENSE"
55
55
  ],
56
56
  "dependencies": {
57
- "@file-viewer/core": "2.1.27",
57
+ "@file-viewer/core": "2.1.28",
58
58
  "@fontsource-variable/noto-sans-sc": "5.2.10",
59
59
  "pdf-lib": "1.17.1",
60
60
  "pdfjs-dist": "5.4.624"