@file-viewer/renderer-archive 2.1.9 → 2.1.11

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 CHANGED
@@ -14,9 +14,9 @@ class ArchivePasswordCancelledError extends Error {
14
14
  }
15
15
  }
16
16
  const archiveStyle = `
17
- .archive-shell,.archive-viewer{position:relative;box-sizing:border-box;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden;display:grid;grid-template-columns:minmax(280px,34%) minmax(0,1fr);background:#edf2f7;color:#172033;font-family:Aptos,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif}
17
+ .archive-shell,.archive-viewer{position:relative;box-sizing:border-box;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden;display:grid;grid-template-columns:minmax(280px,34%) minmax(0,1fr);grid-template-rows:minmax(0,1fr);background:#edf2f7;color:#172033;font-family:Aptos,'Segoe UI','PingFang SC','Microsoft YaHei',sans-serif}
18
18
  .archive-shell *,.archive-viewer *{box-sizing:border-box}
19
- .archive-sidebar{min-width:0;min-height:0;overflow:hidden;display:flex;flex-direction:column;gap:12px;padding:16px;border-right:1px solid rgba(23,32,51,.08);background:rgba(255,255,255,.72);transition:opacity .18s ease,padding .18s ease,border-color .18s ease}
19
+ .archive-sidebar{grid-column:1;grid-row:1;min-width:0;min-height:0;overflow:hidden;display:flex;flex-direction:column;gap:12px;padding:16px;border-right:1px solid rgba(23,32,51,.08);background:rgba(255,255,255,.72);transition:opacity .18s ease,padding .18s ease,border-color .18s ease}
20
20
  .archive-shell.archive-sidebar-collapsed,.archive-viewer.archive-sidebar-collapsed{grid-template-columns:0 minmax(0,1fr)}
21
21
  .archive-sidebar-collapsed .archive-sidebar{display:none;width:0;max-width:0;padding:0;border-color:transparent;opacity:0;pointer-events:none}
22
22
  .archive-sidebar-collapsed .archive-sidebar>*{visibility:hidden}
@@ -38,11 +38,12 @@ const archiveStyle = `
38
38
  .entry-copy strong,.entry-copy em{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
39
39
  .entry-copy em,.archive-entry small{color:#718096;font-size:12px;font-style:normal}
40
40
  .archive-entry small{min-width:0;max-width:74px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:right}
41
- .archive-preview{min-width:0;min-height:0;display:flex;flex-direction:column}
41
+ .archive-preview{grid-column:2;grid-row:1;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden;display:flex;flex-direction:column}
42
42
  .archive-preview-toolbar{min-width:0;min-height:64px;display:flex;align-items:center;gap:12px;padding:12px 16px;border-bottom:1px solid rgba(23,32,51,.08);background:rgba(255,255,255,.76)}
43
43
  .archive-preview-toolbar button{height:34px;border:0;border-radius:10px;padding:0 12px;background:#1f7a58;color:#fff;font:inherit;font-size:13px;font-weight:800;cursor:pointer}
44
44
  .archive-preview-toolbar .archive-sidebar-toggle{background:#fff;color:#1f7a58;border:1px solid rgba(23,32,51,.1);padding:0}
45
45
  .archive-preview-title{min-width:0;flex:1}
46
+ .archive-preview-toolbar span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
46
47
  .archive-preview-toolbar .archive-download-button{flex:0 0 auto}
47
48
  .archive-nested-target{position:relative;flex:1;min-height:0;overflow:auto}
48
49
  .archive-nested-content{width:100%;height:100%;min-height:420px}
@@ -74,7 +75,7 @@ const archiveStyle = `
74
75
  .file-viewer[data-viewer-theme='dark'] .archive-empty strong{color:#f8fafc}
75
76
  @media (prefers-color-scheme:dark){.file-viewer[data-viewer-theme='system'] .archive-shell,.file-viewer[data-viewer-theme='system'] .archive-viewer{background:#101820;color:#e6edf3}.file-viewer[data-viewer-theme='system'] .archive-sidebar,.file-viewer[data-viewer-theme='system'] .archive-preview-toolbar{border-color:rgba(139,148,158,.2);background:rgba(21,27,35,.82)}.file-viewer[data-viewer-theme='system'] .archive-entry,.file-viewer[data-viewer-theme='system'] .archive-search,.file-viewer[data-viewer-theme='system'] .archive-state>div{background:#151b23;color:#e6edf3;border-color:rgba(139,148,158,.2)}.file-viewer[data-viewer-theme='system'] .archive-password-card{background:#151b23;color:#e6edf3}.file-viewer[data-viewer-theme='system'] .archive-password-card input{background:#0d1117;color:#e6edf3;border-color:rgba(139,148,158,.24)}.file-viewer[data-viewer-theme='system'] .archive-password-cancel{background:#212a35;color:#d7dee8}.file-viewer[data-viewer-theme='system'] .archive-empty strong{color:#f8fafc}}
76
77
  @keyframes archive-spin{to{transform:rotate(360deg)}}
77
- @media (max-width:860px){.archive-shell,.archive-viewer{grid-template-columns:1fr;grid-template-rows:minmax(220px,38%) minmax(0,1fr)}.archive-shell.archive-sidebar-collapsed,.archive-viewer.archive-sidebar-collapsed{grid-template-columns:1fr;grid-template-rows:0 minmax(0,1fr)}.archive-sidebar{border-right:0;border-bottom:1px solid rgba(23,32,51,.08)}.archive-preview-toolbar{min-height:56px;padding:10px 12px}.archive-head strong,.archive-preview-toolbar strong{font-size:16px}.archive-entry{grid-template-columns:38px minmax(0,1fr) minmax(40px,auto)}}
78
+ @media (max-width:860px){.archive-shell,.archive-viewer{grid-template-columns:1fr;grid-template-rows:minmax(220px,38%) minmax(0,1fr)}.archive-shell.archive-sidebar-collapsed,.archive-viewer.archive-sidebar-collapsed{grid-template-columns:1fr;grid-template-rows:0 minmax(0,1fr)}.archive-sidebar{grid-column:1;grid-row:1;border-right:0;border-bottom:1px solid rgba(23,32,51,.08)}.archive-preview{grid-column:1;grid-row:2}.archive-preview-toolbar{min-height:56px;padding:10px 12px}.archive-head strong,.archive-preview-toolbar strong{font-size:16px}.archive-entry{grid-template-columns:38px minmax(0,1fr) minmax(40px,auto)}}
78
79
  `;
79
80
  const createStyle = (documentRef) => {
80
81
  const style = documentRef.createElement('style');
@@ -416,6 +417,12 @@ export default async function renderArchive(buffer, target, _type, context) {
416
417
  resolve === null || resolve === void 0 ? void 0 : resolve(password);
417
418
  };
418
419
  const requestPasswordWithDialog = async (reason, previousError) => {
420
+ const wasLoading = loading;
421
+ if (wasLoading) {
422
+ loading = false;
423
+ syncState();
424
+ renderEmptyState();
425
+ }
419
426
  passwordDescription.textContent = t('archive.password.description');
420
427
  passwordError.textContent = previousError || reason === 'invalid-password'
421
428
  ? t('archive.password.invalid')
@@ -424,7 +431,14 @@ export default async function renderArchive(buffer, target, _type, context) {
424
431
  passwordDialog.classList.remove('archive-hidden');
425
432
  targetWindow === null || targetWindow === void 0 ? void 0 : targetWindow.setTimeout(() => passwordInput.focus(), 0);
426
433
  return new Promise((resolve) => {
427
- passwordResolver = resolve;
434
+ passwordResolver = password => {
435
+ if (wasLoading && password !== null) {
436
+ loading = true;
437
+ syncState();
438
+ renderEmptyState();
439
+ }
440
+ resolve(password);
441
+ };
428
442
  });
429
443
  };
430
444
  const requestArchivePassword = async (reason, entry, previousError) => {
@@ -5,6 +5,23 @@ 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 resolveJSZip = (module) => {
9
+ const record = module;
10
+ const defaultRecord = record === null || record === void 0 ? void 0 : record.default;
11
+ const candidates = [
12
+ record === null || record === void 0 ? void 0 : record.default,
13
+ defaultRecord === null || defaultRecord === void 0 ? void 0 : defaultRecord.default,
14
+ record === null || record === void 0 ? void 0 : record.JSZip,
15
+ module,
16
+ ];
17
+ const JSZip = candidates.find(candidate => !!candidate &&
18
+ typeof candidate === 'object' &&
19
+ typeof candidate.loadAsync === 'function');
20
+ if (!JSZip) {
21
+ throw new Error('JSZip module does not expose loadAsync.');
22
+ }
23
+ return JSZip;
24
+ };
8
25
  const toArrayBuffer = (bytes) => {
9
26
  const output = new Uint8Array(bytes.byteLength);
10
27
  output.set(bytes);
@@ -140,7 +157,7 @@ const getGzipEntryName = (filename) => {
140
157
  return `${filename || 'archive'}.bin`;
141
158
  };
142
159
  const loadZipEntries = async (data) => {
143
- const { default: JSZip } = await import('jszip');
160
+ const JSZip = resolveJSZip(await import('jszip'));
144
161
  const zip = await JSZip.loadAsync(data);
145
162
  const entries = [];
146
163
  zip.forEach((relativePath, file) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@file-viewer/renderer-archive",
3
- "version": "2.1.9",
3
+ "version": "2.1.11",
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.9",
59
+ "@file-viewer/core": "^2.1.11",
60
60
  "jszip": "^3.10.1",
61
61
  "libarchive.js": "^2.0.2"
62
62
  },