@file-viewer/renderer-archive 2.1.11 → 2.1.13
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/archiveFallback.d.ts +11 -0
- package/dist/archiveFallback.js +8 -4
- package/package.json +2 -2
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { type ArchiveEntryView } from './archiveShared.js';
|
|
2
|
+
type JSZipLike = {
|
|
3
|
+
loadAsync(data: ArrayBuffer): Promise<{
|
|
4
|
+
forEach(callback: (relativePath: string, file: {
|
|
5
|
+
dir?: boolean;
|
|
6
|
+
date?: Date;
|
|
7
|
+
async(type: 'arraybuffer'): Promise<ArrayBuffer>;
|
|
8
|
+
}) => void): void;
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
export declare const resolveJSZip: (module: unknown) => JSZipLike;
|
|
2
12
|
export declare const isLikelyEncryptedArchive: (data: ArrayBuffer, filename: string) => boolean;
|
|
3
13
|
/**
|
|
4
14
|
* Worker fallback for constrained browsers, temporary local servers, and
|
|
@@ -6,3 +16,4 @@ export declare const isLikelyEncryptedArchive: (data: ArrayBuffer, filename: str
|
|
|
6
16
|
* this covers common ZIP/TAR/GZIP archives without an extra static Worker.
|
|
7
17
|
*/
|
|
8
18
|
export declare const loadArchiveEntriesWithoutWorker: (data: ArrayBuffer, filename: string) => Promise<ArchiveEntryView[] | null>;
|
|
19
|
+
export {};
|
package/dist/archiveFallback.js
CHANGED
|
@@ -5,7 +5,13 @@ const TAR_BLOCK_SIZE = 512;
|
|
|
5
5
|
const ZIP_CENTRAL_FILE_HEADER = 0x02014b50;
|
|
6
6
|
const ZIP_LOCAL_FILE_HEADER = 0x04034b50;
|
|
7
7
|
const ZIP_GENERAL_PURPOSE_ENCRYPTED_FLAG = 0x0001;
|
|
8
|
-
const
|
|
8
|
+
const isJSZipLike = (value) => {
|
|
9
|
+
return !!value &&
|
|
10
|
+
(typeof value === 'object' || typeof value === 'function') &&
|
|
11
|
+
typeof value.loadAsync === 'function';
|
|
12
|
+
};
|
|
13
|
+
// Vite can expose the CJS constructor as a function-shaped default export.
|
|
14
|
+
export const resolveJSZip = (module) => {
|
|
9
15
|
const record = module;
|
|
10
16
|
const defaultRecord = record === null || record === void 0 ? void 0 : record.default;
|
|
11
17
|
const candidates = [
|
|
@@ -14,9 +20,7 @@ const resolveJSZip = (module) => {
|
|
|
14
20
|
record === null || record === void 0 ? void 0 : record.JSZip,
|
|
15
21
|
module,
|
|
16
22
|
];
|
|
17
|
-
const JSZip = candidates.find(
|
|
18
|
-
typeof candidate === 'object' &&
|
|
19
|
-
typeof candidate.loadAsync === 'function');
|
|
23
|
+
const JSZip = candidates.find(isJSZipLike);
|
|
20
24
|
if (!JSZip) {
|
|
21
25
|
throw new Error('JSZip module does not expose loadAsync.');
|
|
22
26
|
}
|
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.13",
|
|
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.13",
|
|
60
60
|
"jszip": "^3.10.1",
|
|
61
61
|
"libarchive.js": "^2.0.2"
|
|
62
62
|
},
|