@file-viewer/renderer-archive 2.1.0 → 2.1.2
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/dist/archive.js +2 -10
- package/dist/archiveShared.d.ts +2 -0
- package/dist/archiveShared.js +14 -0
- package/package.json +2 -2
package/dist/archive.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveFileViewerArchiveWasmUrl, resolveFileViewerArchiveWorkerUrl, } from '@file-viewer/core/assets';
|
|
2
2
|
import { disposeFileViewerRendered, } from '@file-viewer/core';
|
|
3
|
-
import { createArchiveCacheKey, flattenArchiveObject, formatArchiveBytes, getArchiveEntryExtension, } from './archiveShared.js';
|
|
3
|
+
import { buildArchiveNestedRenderContext, createArchiveCacheKey, flattenArchiveObject, formatArchiveBytes, getArchiveEntryExtension, } from './archiveShared.js';
|
|
4
4
|
import { readArchiveCache, writeArchiveCache } from './archiveCache.js';
|
|
5
5
|
import { loadArchiveEntriesWithoutWorker } from './archiveFallback.js';
|
|
6
6
|
const DEFAULT_MAX_ARCHIVE_SIZE = 320 * 1024 * 1024;
|
|
@@ -190,10 +190,6 @@ const resolveWorkerCandidates = async (documentRef, options) => {
|
|
|
190
190
|
}
|
|
191
191
|
return candidates;
|
|
192
192
|
};
|
|
193
|
-
const buildNestedOptions = (context, archiveOptions) => ({
|
|
194
|
-
...((context === null || context === void 0 ? void 0 : context.options) || {}),
|
|
195
|
-
archive: archiveOptions,
|
|
196
|
-
});
|
|
197
193
|
const renderNestedWithCoreFallback = async (buffer, type, target, context) => {
|
|
198
194
|
const { fileViewerCoreRendererDispatcher } = await import('@file-viewer/core');
|
|
199
195
|
const handler = fileViewerCoreRendererDispatcher.resolve(type);
|
|
@@ -452,11 +448,7 @@ export default async function renderArchive(buffer, target, _type, context) {
|
|
|
452
448
|
await clearNestedPreview();
|
|
453
449
|
const child = createElement(documentRef, 'div', 'archive-nested-content');
|
|
454
450
|
nestedTarget.append(child);
|
|
455
|
-
const nestedContext =
|
|
456
|
-
...context,
|
|
457
|
-
filename: entry.name,
|
|
458
|
-
options: buildNestedOptions(context, archiveOptions),
|
|
459
|
-
};
|
|
451
|
+
const nestedContext = buildArchiveNestedRenderContext(context, entry, archiveOptions);
|
|
460
452
|
nestedRendered = (context === null || context === void 0 ? void 0 : context.renderNestedBuffer)
|
|
461
453
|
? await context.renderNestedBuffer(entryBuffer, entry.extension, child, nestedContext)
|
|
462
454
|
: await renderNestedWithCoreFallback(entryBuffer, entry.extension, child, nestedContext);
|
package/dist/archiveShared.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FileRenderContext, FileViewerArchiveOptions } from '@file-viewer/core';
|
|
1
2
|
export declare const ARCHIVE_PREVIEWABLE_EXTENSIONS: readonly string[];
|
|
2
3
|
export interface ArchiveEntryView {
|
|
3
4
|
id: string;
|
|
@@ -22,3 +23,4 @@ export declare const isPreviewableArchiveEntry: (name: string) => boolean;
|
|
|
22
23
|
export declare const formatArchiveBytes: (value: number) => string;
|
|
23
24
|
export declare const flattenArchiveObject: (input: Record<string, unknown>, prefix?: string) => ArchiveEntryView[];
|
|
24
25
|
export declare const createArchiveCacheKey: (archiveName: string, archiveSize: number, entry: ArchiveEntryView) => string;
|
|
26
|
+
export declare const buildArchiveNestedRenderContext: (context: FileRenderContext | undefined, entry: Pick<ArchiveEntryView, "name">, archiveOptions: FileViewerArchiveOptions | undefined) => FileRenderContext;
|
package/dist/archiveShared.js
CHANGED
|
@@ -85,3 +85,17 @@ export const createArchiveCacheKey = (archiveName, archiveSize, entry) => {
|
|
|
85
85
|
entry.lastModified || 0,
|
|
86
86
|
].join(':');
|
|
87
87
|
};
|
|
88
|
+
const buildNestedOptions = (context, archiveOptions) => ({
|
|
89
|
+
...((context === null || context === void 0 ? void 0 : context.options) || {}),
|
|
90
|
+
archive: archiveOptions,
|
|
91
|
+
});
|
|
92
|
+
export const buildArchiveNestedRenderContext = (context, entry, archiveOptions) => ({
|
|
93
|
+
...context,
|
|
94
|
+
filename: entry.name,
|
|
95
|
+
// Archive children are rendered from the extracted bytes. Never inherit
|
|
96
|
+
// the parent archive URL, otherwise streaming renderers such as PDF.js
|
|
97
|
+
// would try to parse the .zip/.rar source as the nested file.
|
|
98
|
+
url: undefined,
|
|
99
|
+
streamUrl: undefined,
|
|
100
|
+
options: buildNestedOptions(context, archiveOptions),
|
|
101
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/renderer-archive",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Standalone archive renderer plugin for Flyfish File Viewer with libarchive worker, ZIP/TAR fallback, IndexedDB cache, and nested previews.",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"LICENSE"
|
|
57
57
|
],
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@file-viewer/core": "^2.1.
|
|
59
|
+
"@file-viewer/core": "^2.1.2",
|
|
60
60
|
"jszip": "^3.10.1",
|
|
61
61
|
"libarchive.js": "^2.0.2"
|
|
62
62
|
},
|