@file-viewer/core
Advanced tools
@@ -96,6 +96,22 @@ import { buildFileViewerRenderedHtmlDocument, triggerFileViewerBlobDownload, triggerFileViewerUrlDownload, waitForFileViewerPrintWindowReady, } from '../output/export.js'; | ||
| }); | ||
| if (source.buffer) { | ||
| // PDF.js transfers ArrayBuffer-backed data to its worker. After a successful | ||
| // render the original buffer can therefore be detached (byteLength === 0), | ||
| // while the File or URL retained by the viewer is still the complete source. | ||
| // Preserve the existing buffer-first contract for non-empty buffers, but do | ||
| // not turn a detached buffer into a zero-byte download. | ||
| if (source.buffer && | ||
| (source.buffer.byteLength > 0 || (!source.file && !source.url))) { | ||
| triggerFileViewerBlobDownload(new Blob([source.buffer], { type: source.mimeType || ((_a = source.file) === null || _a === void 0 ? void 0 : _a.type) || 'application/octet-stream' }), resolvedFilename); | ||
| return true; | ||
| } | ||
| if (source.file && (source.file.size > 0 || !source.url)) { | ||
| triggerFileViewerBlobDownload(source.file, resolvedFilename); | ||
| return true; | ||
| } | ||
| if (source.url) { | ||
| triggerFileViewerUrlDownload(source.url, resolvedFilename); | ||
| return true; | ||
| } | ||
| // Empty local files are valid sources. These final fallbacks preserve their | ||
| // intentional zero-byte downloads when no complete File or URL is available. | ||
| if (source.file) { | ||
@@ -105,3 +121,3 @@ triggerFileViewerBlobDownload(source.file, resolvedFilename); | ||
| } | ||
| triggerFileViewerUrlDownload(source.url, resolvedFilename); | ||
| triggerFileViewerBlobDownload(new Blob([source.buffer], { type: source.mimeType || 'application/octet-stream' }), resolvedFilename); | ||
| return true; | ||
@@ -108,0 +124,0 @@ }; |
+1
-1
| { | ||
| "name": "@file-viewer/core", | ||
| "version": "2.2.0", | ||
| "version": "2.2.1", | ||
| "private": false, | ||
@@ -5,0 +5,0 @@ "type": "module", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
764228
0.13%14598
0.11%