@file-viewer/core 2.2.0 → 2.2.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.
@@ -93,15 +93,31 @@ export const executeFileViewerDownloadOperation = async ({ source, filename, bef
93
93
  source,
94
94
  fallback: DEFAULT_FILE_VIEWER_DOWNLOAD_FILENAME,
95
95
  });
96
- if (source.buffer) {
96
+ // PDF.js transfers ArrayBuffer-backed data to its worker. After a successful
97
+ // render the original buffer can therefore be detached (byteLength === 0),
98
+ // while the File or URL retained by the viewer is still the complete source.
99
+ // Preserve the existing buffer-first contract for non-empty buffers, but do
100
+ // not turn a detached buffer into a zero-byte download.
101
+ if (source.buffer &&
102
+ (source.buffer.byteLength > 0 || (!source.file && !source.url))) {
97
103
  triggerFileViewerBlobDownload(new Blob([source.buffer], { type: source.mimeType || ((_a = source.file) === null || _a === void 0 ? void 0 : _a.type) || 'application/octet-stream' }), resolvedFilename);
98
104
  return true;
99
105
  }
106
+ if (source.file && (source.file.size > 0 || !source.url)) {
107
+ triggerFileViewerBlobDownload(source.file, resolvedFilename);
108
+ return true;
109
+ }
110
+ if (source.url) {
111
+ triggerFileViewerUrlDownload(source.url, resolvedFilename);
112
+ return true;
113
+ }
114
+ // Empty local files are valid sources. These final fallbacks preserve their
115
+ // intentional zero-byte downloads when no complete File or URL is available.
100
116
  if (source.file) {
101
117
  triggerFileViewerBlobDownload(source.file, resolvedFilename);
102
118
  return true;
103
119
  }
104
- triggerFileViewerUrlDownload(source.url, resolvedFilename);
120
+ triggerFileViewerBlobDownload(new Blob([source.buffer], { type: source.mimeType || 'application/octet-stream' }), resolvedFilename);
105
121
  return true;
106
122
  };
107
123
  export const executeFileViewerExportHtmlOperation = async ({ download = true, filename, beforeOperation, i18n, ...input }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@file-viewer/core",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Framework-neutral modular TypeScript core for Flyfish File Viewer renderer orchestration, lifecycle APIs, search, zoom, print, and export",