@file-viewer/renderer-archive 2.0.11 → 2.1.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.
- package/dist/archiveFallback.js +5 -2
- package/dist/archiveShared.d.ts +1 -0
- package/dist/archiveShared.js +16 -0
- package/package.json +2 -2
package/dist/archiveFallback.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getArchiveEntryExtension, isPreviewableArchiveEntry, } from './archiveShared.js';
|
|
1
|
+
import { getArchiveEntryExtension, isArchiveSystemMetadataPath, isPreviewableArchiveEntry, } from './archiveShared.js';
|
|
2
2
|
const ZIP_LIKE_EXTENSIONS = new Set(['zip', 'zipx', 'jar', 'war', 'ear', 'apk', 'cbz']);
|
|
3
3
|
const TAR_LIKE_EXTENSIONS = new Set(['tar', 'tgz', 'gz', 'gzip']);
|
|
4
4
|
const TAR_BLOCK_SIZE = 512;
|
|
@@ -78,7 +78,7 @@ const parseTarEntries = (bytes) => {
|
|
|
78
78
|
const typeFlag = String.fromCharCode(bytes[offset + 156] || 0);
|
|
79
79
|
const dataOffset = offset + TAR_BLOCK_SIZE;
|
|
80
80
|
const nextOffset = dataOffset + Math.ceil(size / TAR_BLOCK_SIZE) * TAR_BLOCK_SIZE;
|
|
81
|
-
if (path && typeFlag !== '5') {
|
|
81
|
+
if (path && typeFlag !== '5' && !isArchiveSystemMetadataPath(path)) {
|
|
82
82
|
const fileBytes = bytes.slice(dataOffset, dataOffset + size);
|
|
83
83
|
entries.push(createEntryView({
|
|
84
84
|
path,
|
|
@@ -118,6 +118,9 @@ const loadZipEntries = async (data) => {
|
|
|
118
118
|
}
|
|
119
119
|
const metadata = file;
|
|
120
120
|
const normalizedPath = normalizeArchivePath(relativePath);
|
|
121
|
+
if (isArchiveSystemMetadataPath(normalizedPath)) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
121
124
|
entries.push(createEntryView({
|
|
122
125
|
path: normalizedPath,
|
|
123
126
|
size: ((_a = metadata._data) === null || _a === void 0 ? void 0 : _a.uncompressedSize) || 0,
|
package/dist/archiveShared.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface ArchiveEntryView {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
export declare const getArchiveEntryExtension: (name: string) => string;
|
|
19
|
+
export declare const isArchiveSystemMetadataPath: (path: string) => boolean;
|
|
19
20
|
export declare const isArchiveExtension: (extension: string) => boolean;
|
|
20
21
|
export declare const isPreviewableArchiveEntry: (name: string) => boolean;
|
|
21
22
|
export declare const formatArchiveBytes: (value: number) => string;
|
package/dist/archiveShared.js
CHANGED
|
@@ -5,6 +5,19 @@ export const getArchiveEntryExtension = (name) => {
|
|
|
5
5
|
const dot = clean.lastIndexOf('.');
|
|
6
6
|
return dot === -1 ? '' : clean.slice(dot + 1).toLowerCase();
|
|
7
7
|
};
|
|
8
|
+
const ARCHIVE_SYSTEM_METADATA_FILENAMES = new Set([
|
|
9
|
+
'.ds_store',
|
|
10
|
+
'desktop.ini',
|
|
11
|
+
'thumbs.db',
|
|
12
|
+
]);
|
|
13
|
+
export const isArchiveSystemMetadataPath = (path) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const normalized = path.replace(/^\/+/, '').replace(/\\/g, '/');
|
|
16
|
+
const parts = normalized.split('/').filter(Boolean);
|
|
17
|
+
const filename = ((_a = parts[parts.length - 1]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '';
|
|
18
|
+
return parts.some(part => part === '__MACOSX' || part.startsWith('._')) ||
|
|
19
|
+
ARCHIVE_SYSTEM_METADATA_FILENAMES.has(filename);
|
|
20
|
+
};
|
|
8
21
|
export const isArchiveExtension = (extension) => (ARCHIVE_EXTENSIONS.includes(extension.toLowerCase()));
|
|
9
22
|
export const isPreviewableArchiveEntry = (name) => {
|
|
10
23
|
const extension = getArchiveEntryExtension(name);
|
|
@@ -37,6 +50,9 @@ export const flattenArchiveObject = (input, prefix = '') => {
|
|
|
37
50
|
const entries = [];
|
|
38
51
|
Object.entries(input).forEach(([key, value]) => {
|
|
39
52
|
const path = prefix ? `${prefix}/${key}` : key;
|
|
53
|
+
if (isArchiveSystemMetadataPath(path)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
40
56
|
if (isCompressedFile(value)) {
|
|
41
57
|
const name = value.name || key;
|
|
42
58
|
const extension = getArchiveEntryExtension(name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/renderer-archive",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
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.
|
|
59
|
+
"@file-viewer/core": "^2.1.1",
|
|
60
60
|
"jszip": "^3.10.1",
|
|
61
61
|
"libarchive.js": "^2.0.2"
|
|
62
62
|
},
|