filens-preview 0.2.0 → 0.3.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/README.md +69 -16
- package/dist/all-in-one/THIRD-PARTY-NOTICES.txt +1902 -63
- package/dist/all-in-one/archive/7zz.wasm +0 -0
- package/dist/all-in-one/assets/archive-worker-Cy3bEdVg.js +2 -0
- package/dist/all-in-one/filens.js +5063 -108925
- package/dist/all-in-one/index.html +12 -3
- package/dist/index.d.ts +7 -0
- package/dist/split/THIRD-PARTY-NOTICES.txt +1902 -63
- package/dist/split/archive/7zz.wasm +0 -0
- package/dist/split/assets/archive-worker-Cy3bEdVg.js +2 -0
- package/dist/split/assets/{iwork-worker-DiTOJG8f.js → iwork-worker-B9KPoDW3.js} +17 -17
- package/dist/split/chunks/archive-DMapcEqq.js +1 -0
- package/dist/split/chunks/browser-video-session-CGI8FpX_.js +1 -0
- package/dist/split/chunks/cad-BvXJNqHR.js +7 -0
- package/dist/split/chunks/core-BLayEJn5.js +17 -0
- package/dist/split/chunks/diagram-DlpgioZ9.js +1 -0
- package/dist/split/chunks/docx-Sii3GNtE.js +1 -0
- package/dist/split/chunks/ebook-CLCQfska.js +5 -0
- package/dist/split/chunks/index-BPK_cNTp.js +1 -0
- package/dist/split/chunks/index-DI_GyFX1.js +1 -0
- package/dist/split/chunks/iwork-Datv3D5d.js +4 -0
- package/dist/split/chunks/media-runtime-tb-Q4Sah.js +1 -0
- package/dist/split/chunks/mindmap-B_GYpiFO.js +1 -0
- package/dist/split/chunks/model3d-BsIQNF2D.js +55 -0
- package/dist/split/chunks/mp4box.all-Bw_Tlr0T-D0URDfA1.js +1 -0
- package/dist/split/chunks/panorama-CIdiLIwD.js +973 -0
- package/dist/split/chunks/pdf-Dzzffz3p.js +12 -0
- package/dist/split/chunks/vendor-CBCxJuSg.js +4115 -0
- package/dist/split/chunks/xlsx-D2NFYc3n.js +3 -0
- package/dist/split/converter-image.wasm +0 -0
- package/dist/split/filens.js +2 -4781
- package/dist/split/index.html +12 -3
- package/package.json +2 -2
- package/dist/split/chunks/archive-_cUUL2-3.js +0 -731
- package/dist/split/chunks/cad-Cyh8aipO.js +0 -2405
- package/dist/split/chunks/core-gp02JQ3r.js +0 -14182
- package/dist/split/chunks/diagram-rxvArV-1.js +0 -654
- package/dist/split/chunks/docx-ecvZsSWm.js +0 -299
- package/dist/split/chunks/ebook-5FyKWZ8s.js +0 -623
- package/dist/split/chunks/iwork-DlaehzuR.js +0 -772
- package/dist/split/chunks/media-runtime-DwW7eq4g.js +0 -48
- package/dist/split/chunks/mindmap-D9lNNDoa.js +0 -560
- package/dist/split/chunks/model3d-BtFT01ZH.js +0 -5093
- package/dist/split/chunks/panorama-Ci6DK6sa.js +0 -5960
- package/dist/split/chunks/pdf-CecYOWld.js +0 -17898
- package/dist/split/chunks/vendor-DvWhw-zP.js +0 -54471
- package/dist/split/chunks/xlsx-VJTu9XNS.js +0 -818
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>filens preview</title>
|
|
2
2
|
<style>html,body,#preview{height:100%;margin:0}body{font-family:system-ui}#picker{position:fixed;z-index:100;top:12px;right:16px;background:white;padding:8px;border:1px solid #ddd;border-radius:6px}#picker input{max-width:220px}</style>
|
|
3
|
-
<label id="picker">Open file <input type="file" id="file"></label><div id="preview"></div>
|
|
3
|
+
<label id="picker">Open file(s) <input type="file" id="file" multiple><span id="source-error" role="alert" hidden></span></label><div id="preview"></div>
|
|
4
4
|
<script type="module">
|
|
5
|
-
import { createPreview } from './filens.js';
|
|
5
|
+
import { createPreview, isArchiveVolumeName, selectArchiveVolumes } from './filens.js';
|
|
6
6
|
let preview;
|
|
7
7
|
const open = options => { document.body.dataset.state='loading'; delete document.body.dataset.error; preview?.destroy(); preview = createPreview('#preview', {
|
|
8
8
|
...options, onRendered: () => { document.body.dataset.state='ready'; },
|
|
9
9
|
onError: error => { document.body.dataset.state='error'; document.body.dataset.error=error.message; }
|
|
10
10
|
}); };
|
|
11
|
-
document.querySelector('#file').onchange = event => {
|
|
11
|
+
document.querySelector('#file').onchange = event => {
|
|
12
|
+
const files=Array.from(event.target.files), file=files.find(part=>isArchiveVolumeName(part.name))??files[0];
|
|
13
|
+
const error=document.querySelector('#source-error'); error.hidden=true;
|
|
14
|
+
if(!file) return;
|
|
15
|
+
try {
|
|
16
|
+
const set=selectArchiveVolumes(file.name,files);
|
|
17
|
+
open(set ? {src:{source:set.primary,archiveVolumes:set.files.slice(1).map(part=>({name:part.name,source:part}))},name:set.primary.name}
|
|
18
|
+
: {src:file,name:file.name});
|
|
19
|
+
} catch (cause) { error.textContent=cause.message; error.hidden=false; }
|
|
20
|
+
};
|
|
12
21
|
// The CLI serves metadata and file bytes from its local, token-scoped HTTP server.
|
|
13
22
|
if (new URL(location.href).searchParams.has('cli')) {
|
|
14
23
|
const response = await fetch('./source.json');
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type PreviewSource = string | ArrayBuffer | Uint8Array | Blob | File;
|
|
2
2
|
export interface SourceDescriptor {
|
|
3
3
|
source: PreviewSource;
|
|
4
|
+
archiveVolumes?: readonly { name: string; source: PreviewSource }[];
|
|
4
5
|
name?: string;
|
|
5
6
|
extension?: string;
|
|
6
7
|
contentType?: string;
|
|
@@ -15,6 +16,8 @@ export interface BrowserPreviewOptions {
|
|
|
15
16
|
password?: string;
|
|
16
17
|
fit?: 'contain' | 'width' | 'height' | 'none';
|
|
17
18
|
toolbar?: boolean;
|
|
19
|
+
/** Native first; local MP4/MOV recovery without a conversion service. Off by default. */
|
|
20
|
+
browserMedia?: boolean | { allowTranscoding?: boolean; fetch?: typeof globalThis.fetch };
|
|
18
21
|
/** ZimaOS codes (zh_CN) and BCP 47 tags (zh-CN); defaults to browser language. */
|
|
19
22
|
locale?: string;
|
|
20
23
|
/** English source phrases mapped to host translations. */
|
|
@@ -38,3 +41,7 @@ export interface BrowserPreview {
|
|
|
38
41
|
destroy(): void;
|
|
39
42
|
}
|
|
40
43
|
export declare function createPreview(element: Element | string, options: BrowserPreviewOptions): BrowserPreview;
|
|
44
|
+
export declare function isArchiveVolumeName(name: string): boolean;
|
|
45
|
+
export declare function selectArchiveVolumes<T extends { name: string }>(name: string, candidates: readonly T[]): {
|
|
46
|
+
format: 'rar' | '7z' | 'zip'; primary: T; files: T[];
|
|
47
|
+
} | undefined;
|