filens-preview 0.1.4 → 0.3.0
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 +152 -30
- package/dist/all-in-one/THIRD-PARTY-NOTICES.txt +969 -0
- 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 +71714 -63448
- package/dist/all-in-one/index.html +12 -3
- package/dist/index.d.ts +9 -0
- package/dist/split/THIRD-PARTY-NOTICES.txt +969 -0
- package/dist/split/archive/7zz.wasm +0 -0
- package/dist/split/assets/archive-worker-Cy3bEdVg.js +2 -0
- package/dist/split/assets/iwork-worker-B9KPoDW3.js +27 -0
- package/dist/split/chunks/archive-B4jVwD9o.js +921 -0
- package/dist/split/chunks/{cad-CsU3TiHK.js → cad-DMg-lGJX.js} +1 -1
- package/dist/split/chunks/{core-BvtuMqS1.js → core--zVW212C.js} +4692 -4213
- package/dist/split/chunks/{diagram-BxRNHzmO.js → diagram-CDwCA6LZ.js} +2 -2
- package/dist/split/chunks/{docx-Ch1AvEUX.js → docx-CuQfFJqr.js} +2 -2
- package/dist/split/chunks/{ebook-P42eILp5.js → ebook-CLlJ8KX3.js} +2 -2
- package/dist/split/chunks/{iwork-HnghW_EB.js → iwork-dNVC0X8j.js} +57 -57
- package/dist/split/chunks/media-runtime-gcsBQMuo.js +48 -0
- package/dist/split/chunks/{mindmap-vFlOJSIq.js → mindmap-g0-VoK-K.js} +2 -2
- package/dist/split/chunks/{model3d-DoNu7iyY.js → model3d-1G1CC52V.js} +3 -3
- package/dist/split/chunks/{panorama-Bw_8HQsv.js → panorama-D7GVivtM.js} +1005 -989
- package/dist/split/chunks/{vendor-Cv2Fxtsf.js → vendor-DPFNKNkh.js} +27630 -22859
- package/dist/split/chunks/{xlsx-ypLtJxeq.js → xlsx-Co26yo-R.js} +2 -2
- package/dist/split/converter-core.wasm +0 -0
- package/dist/split/converter-office.wasm +0 -0
- package/dist/split/filens.js +4133 -1301
- package/dist/split/index.html +12 -3
- package/package.json +2 -2
- package/dist/split/assets/iwork-worker-D64s_rsm.js +0 -34
- package/dist/split/chunks/archive-Drem4a-o.js +0 -731
- package/dist/split/chunks/media-runtime-kbzoW8bd.js +0 -48
package/README.md
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
# Standalone browser previews / 独立前端预览
|
|
2
2
|
|
|
3
|
-
Build the same preview engines as
|
|
3
|
+
Build the same preview engines as one main JavaScript file or split modules,
|
|
4
|
+
with an optional external archive engine in either build. Both
|
|
4
5
|
include Vue, styles, PDF/iWork workers and the document, image/RAW and STEP WASM
|
|
5
6
|
engines. No conversion server or host Vue installation is needed.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
For iOS and Android application embedding, the [source SDKs](../../sdk/README.zh-CN.md)
|
|
9
|
+
wrap this same runtime in native views, with local file loading and lifecycle callbacks.
|
|
10
|
+
|
|
11
|
+
Version **0.3.0** adds the mobile source SDK integration, encrypted / solid / multipart
|
|
12
|
+
RAR and 7z previews, Office attachment previews, smaller embedded WASM, shared ZIP
|
|
13
|
+
loading and the default `FiLens © IceWhale` watermark. The optional archive engine
|
|
14
|
+
and its worker stay external in both runtime builds.
|
|
15
|
+
|
|
16
|
+
Version 0.2.0 adds 28 toolbar languages, application-icon previews and the
|
|
17
|
+
runtime fixes used by CLI 0.5.0's offline HTML preview. It uses native HEIC/HEIF decoding first, with a small dedicated WASM
|
|
18
|
+
decoder as fallback. MOV plays through browser codecs.
|
|
9
19
|
Applications can supply an optional `mediaConverter` for unsupported MOV codecs.
|
|
10
20
|
Both builds preserve the same image and video support boundaries.
|
|
11
21
|
|
|
@@ -29,15 +39,31 @@ npm run build:wasm
|
|
|
29
39
|
npm run build:preview
|
|
30
40
|
```
|
|
31
41
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
Deploy the entire `packages/preview/dist/split/` directory, or
|
|
43
|
+
`dist/all-in-one/filens.js` with the archive sidecars when needed. The following
|
|
44
|
+
table is generated by `npm run report:preview-sizes` from exact byte measurements.
|
|
45
|
+
|
|
46
|
+
<!-- preview-runtime-sizes:start -->
|
|
47
|
+
| Runtime | Raw MB | gzip MB | Brotli MB |
|
|
48
|
+
| --- | ---: | ---: | ---: |
|
|
49
|
+
| Split main runtime | 11.23 | 3.26 | 2.57 |
|
|
50
|
+
| All-in-one main JS | 8.85 | 3.26 | 2.90 |
|
|
51
|
+
| Optional archive WASM + worker (either build) | 0.88 | 0.35 | 0.28 |
|
|
52
|
+
| Split with archive assets | 12.11 | 3.61 | 2.85 |
|
|
53
|
+
| All-in-one with archive assets | 9.73 | 3.60 | 3.18 |
|
|
54
|
+
<!-- preview-runtime-sizes:end -->
|
|
36
55
|
|
|
37
|
-
These are
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
56
|
+
These are current source build measurements (MB = 1,000,000 bytes), including
|
|
57
|
+
application icons, optional Office decryption and 28 locale dictionaries. The
|
|
58
|
+
archive engine always stays external, including all-in-one builds, and is loaded
|
|
59
|
+
only for RAR, 7z or multi-volume ZIP. Ordinary ZIP and ZIP-based document formats
|
|
60
|
+
share the existing JSZip/fflate dependencies. The extraction-only engine uses
|
|
61
|
+
-O3 and LTO, retains encryption and all supported decoders, and shares its compiled
|
|
62
|
+
WASM module between fresh per-operation workers. iWork uses the ordinary ZIP
|
|
63
|
+
reader without duplicating the ZIP encryption library. The totals in the table
|
|
64
|
+
include the optional archive assets and exclude notices.
|
|
65
|
+
The npm package contains both directories, including notices, types and
|
|
66
|
+
documentation. Packed and installed bytes are recorded for each release.
|
|
41
67
|
[Package measurements](https://github.com/IceWhaleTech/filens/blob/main/docs/preview-package-sizes.json).
|
|
42
68
|
|
|
43
69
|
Both directories contain an `index.html` with a local file picker. Serve either
|
|
@@ -66,19 +92,68 @@ directory over HTTP(S). To integrate into another page:
|
|
|
66
92
|
uses the bundled frontend WASM engines. Use [`@filens/vue`](https://github.com/IceWhaleTech/filens/tree/main/packages/vue) for
|
|
67
93
|
direct Vue component integration.
|
|
68
94
|
|
|
95
|
+
Previews display a translucent `FiLens © IceWhale` watermark at the bottom right,
|
|
96
|
+
including when the toolbar is hidden and in preview fullscreen mode.
|
|
97
|
+
|
|
69
98
|
Split chunks can range from a few KB to hundreds of KB after compression. Those
|
|
70
99
|
figures exclude shared dependencies and engines; a chunk is not a complete
|
|
71
|
-
per-format download. The all-in-one file embeds CSS
|
|
72
|
-
|
|
100
|
+
per-format download. The all-in-one file embeds CSS and document/image engines.
|
|
101
|
+
The RAR/7z engine and its worker are always separate files, never base64-embedded;
|
|
102
|
+
deploy both sidecars alongside the main JS to enable RAR, 7z and multi-volume ZIP.
|
|
103
|
+
They can be omitted when those formats are not required.
|
|
73
104
|
A separate notices file accompanies
|
|
74
105
|
both builds and should be distributed with them. [Exact measurements](https://github.com/IceWhaleTech/filens/blob/main/docs/preview-build-sizes.json).
|
|
75
106
|
|
|
76
107
|
Single-file embedding still requires browser support for WebAssembly and workers.
|
|
77
108
|
Pages with a Content Security Policy must permit the generated inline styles,
|
|
78
109
|
`blob:` workers and `data:` WASM. Use an HTTP(S) server for module imports, rather
|
|
79
|
-
than opening `index.html` as a `file:` URL. The
|
|
110
|
+
than opening the module-importing `index.html` as a `file:` URL. The CLI's
|
|
111
|
+
self-contained HTML embeds the module instead and supports `file:` URLs.
|
|
112
|
+
RAR, 7z and multi-volume ZIP require the separate archive assets over HTTP(S);
|
|
113
|
+
CLI HTML shows a `--mode serve` fallback for them instead of embedding the engine.
|
|
114
|
+
The supported formats and fidelity
|
|
80
115
|
limits are shared with the [demo](https://github.com/IceWhaleTech/filens/blob/main/docs/support-matrix.md).
|
|
81
116
|
|
|
117
|
+
## Languages and application icons (0.2.0)
|
|
118
|
+
|
|
119
|
+
Preview toolbars, common prompts and model controls include the same 28 locale
|
|
120
|
+
codes as ZimaOS. Pass `locale: 'zh_CN'` (or `zh-CN`); omit it for browser language
|
|
121
|
+
detection. Switch language with `viewer.update({ locale: 'de_DE' })`. Optional
|
|
122
|
+
`messages: { Next: 'Forward' }` overrides English source phrases per instance.
|
|
123
|
+
Both split and all-in-one builds contain these dictionaries for offline use.
|
|
124
|
+
See the [locale list and API notes](../vue/README.md#languages-source-build).
|
|
125
|
+
|
|
126
|
+
APK/IPA packages and Windows EXE/DLL/MUI/MUN resource files can be previewed as
|
|
127
|
+
application icons using the included WASM converter. Icon extraction supports
|
|
128
|
+
compiled Android icon resources, XML/binary iOS plist metadata, iOS CgBI PNGs,
|
|
129
|
+
and Windows PNG/DIB icon frames. These additions are included in 0.2.0.
|
|
130
|
+
See the [supported icon representations
|
|
131
|
+
and limits](../vue/README.md#application-icons-source-build).
|
|
132
|
+
|
|
133
|
+
The browser file picker accepts multi-volume RAR (`.part01.rar` or `.rar`/`.r00`),
|
|
134
|
+
7z (`.7z.001`) and ZIP (`.zip.001` or `.z01`/`.zip`) archives. Select every part
|
|
135
|
+
together; picker order does not matter. Password prompts and nested previews
|
|
136
|
+
work across the parts. Missing first/intermediate volumes identify the filename;
|
|
137
|
+
the engine validates completeness. Limits are 256 parts and 512 MiB compressed
|
|
138
|
+
input per set, with 128 MiB per expanded entry. Both HTTP(S)-served builds support
|
|
139
|
+
this workflow with local archive sidecars; no remote service or CDN is used.
|
|
140
|
+
Programmatic callers supply the other
|
|
141
|
+
parts as `src.archiveVolumes: [{ name, source }]`; see the
|
|
142
|
+
[core API example](../core/README.md).
|
|
143
|
+
|
|
144
|
+
The split build loads `converter-office.wasm` only when an encrypted Office
|
|
145
|
+
document has a supplied password; a password prompt alone does not download it.
|
|
146
|
+
The core is about 413 KB gzip, and the optional decryptor about 164 KB gzip.
|
|
147
|
+
Splitting saves about 64 KB gzip on ordinary converted previews, while downloading
|
|
148
|
+
both costs about 100 KB gzip more than the combined core due to shared code.
|
|
149
|
+
The all-in-one file uses the combined core (477 KB gzip / 387 KB Brotli) to avoid
|
|
150
|
+
that duplication; its download includes decryption. Embedded WASM is gzipped
|
|
151
|
+
before base64 encoding and decompressed on first use, with a JavaScript fallback
|
|
152
|
+
for browsers without DecompressionStream. HTTP split assets remain ordinary WASM
|
|
153
|
+
and use streaming compilation when the server supplies the correct MIME. See the
|
|
154
|
+
[same-source measurements](../../docs/converter-size-impact.md) and the
|
|
155
|
+
[format package audit](../../docs/format-package-sizes.md).
|
|
156
|
+
|
|
82
157
|
## CLI preview
|
|
83
158
|
|
|
84
159
|
CLI 0.4.0 includes `preview`. The first preview downloads the optional frontend
|
|
@@ -105,20 +180,60 @@ npm run filens -- preview report.pdf
|
|
|
105
180
|
./dist/filens preview report.pdf --no-open --json
|
|
106
181
|
```
|
|
107
182
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
183
|
+
CLI 0.4.x used a loopback HTTP server. **CLI 0.5.0 defaults to a self-contained
|
|
184
|
+
HTML instead**: the shared all-in-one frontend runtime and a
|
|
185
|
+
copy of the selected file are embedded, the browser opens a `file:` URL, and the
|
|
186
|
+
CLI exits. No HTTP server is started. Parsing, conversion and rendering happen
|
|
187
|
+
in the browser, with no external runtime dependencies. The page checks WASM and
|
|
188
|
+
local Worker support and displays compatibility instructions on failure. It also
|
|
189
|
+
includes a GitHub link and third-party notices. Browser launch success does not
|
|
190
|
+
certify rendering; the CLI cannot automatically detect every browser failure.
|
|
191
|
+
|
|
192
|
+
```sh
|
|
193
|
+
# Generate and open an offline HTML, or save it without opening a browser
|
|
194
|
+
filens preview report.pdf
|
|
195
|
+
filens preview report.pdf --output report-preview.html --no-open
|
|
196
|
+
filens preview report.pdf --no-open --json
|
|
197
|
+
|
|
198
|
+
# Compatibility mode: serve only on this machine; Ctrl-C stops it
|
|
199
|
+
filens preview report.pdf --mode serve
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
HTML mode returns a `file:` URL and a filesystem `path`; the command exits even
|
|
203
|
+
with `--no-open --json`. Default HTML files remain in the system temporary
|
|
204
|
+
directory so the browser can finish loading after CLI exit. **The HTML contains
|
|
205
|
+
the original file bytes**; delete it when no longer needed. `--output` never
|
|
206
|
+
overwrites existing files. Base64 embedding adds about one third to the source
|
|
207
|
+
file size, plus the runtime and notices. Prefer HTTP mode or the browser file
|
|
208
|
+
picker for very large files. The HTML's Content Security Policy blocks external
|
|
209
|
+
connections and resource loads; linked images/fonts are unavailable unless
|
|
210
|
+
embedded or supplied locally. The GitHub link opens only when clicked.
|
|
211
|
+
|
|
212
|
+
On `file:` pages PDF.js uses its supported main-thread worker implementation to
|
|
213
|
+
avoid opaque-origin module-worker restrictions in WebKit. Large PDFs can occupy
|
|
214
|
+
the UI thread; HTTP mode keeps the usual worker loading path.
|
|
215
|
+
WebKit currently cannot load the embedded iWork parser worker from a `file:`
|
|
216
|
+
page. Its error panel offers `--mode serve`; the same Keynote sample was verified
|
|
217
|
+
with the split runtime in that compatibility mode. Chromium and Firefox support
|
|
218
|
+
the tested iWork HTML previews directly.
|
|
219
|
+
|
|
220
|
+
`--mode serve --no-open --json` retains the previous URL/server lifecycle. Its
|
|
221
|
+
command keeps running until Ctrl-C. `--port` implies serve mode unless an explicit
|
|
222
|
+
`--mode` is given. To choose a port or built runtime:
|
|
112
223
|
|
|
113
224
|
```sh
|
|
114
225
|
# Choose a port or another built runtime (including the all-in-one build)
|
|
115
|
-
filens preview report.pdf --port 8080 --assets /path/to/preview/dist/all-in-one
|
|
226
|
+
filens preview report.pdf --mode serve --port 8080 --assets /path/to/preview/dist/all-in-one
|
|
116
227
|
```
|
|
117
228
|
|
|
118
229
|
`FILENS_PREVIEW_DIR` overrides the default `<binary-directory>/preview` asset
|
|
119
|
-
directory.
|
|
120
|
-
`
|
|
121
|
-
|
|
230
|
+
directory. An asset directory can be the package's `dist/` root or a specific
|
|
231
|
+
`split/` / `all-in-one/` directory; HTML mode needs the all-in-one runtime (a
|
|
232
|
+
`split/` directory also works when its `all-in-one/` sibling is present).
|
|
233
|
+
Source npm packaging can include the assets with
|
|
234
|
+
`node scripts/package-agent-npm.mjs --with-preview`. These optional resources
|
|
235
|
+
include both split assets and the all-in-one runtime, measured separately from
|
|
236
|
+
the document-reading CLI.
|
|
122
237
|
|
|
123
238
|
The server exposes one selected file, not its parent directory. Models or media
|
|
124
239
|
with external sidecars need a supported ZIP bundle or a host-provided resource
|
|
@@ -130,17 +245,24 @@ macOS; Windows/Linux browser launching still needs native validation.
|
|
|
130
245
|
## 中文说明
|
|
131
246
|
|
|
132
247
|
两种产物使用相同 API:分包版部署整个 `split/` 目录,WASM 与重型引擎按需加载;
|
|
133
|
-
|
|
134
|
-
|
|
248
|
+
单文件版的 `all-in-one/filens.js` 包含 Vue、样式和文档/图片引擎,另附第三方许可文件。
|
|
249
|
+
RAR/7z 和分卷 ZIP 始终使用独立的 `archive/7zz.wasm` 与 `assets/archive-worker-*.js`,
|
|
250
|
+
按需加载,任何构建都不合并进主 JS。无需这些格式时可以省略这两个资源。
|
|
135
251
|
|
|
136
252
|
`filens preview 文件路径` 会启动本地浏览器预览,由前端完成格式解析与渲染。
|
|
137
|
-
CLI 0.
|
|
253
|
+
CLI 0.5.0 首次预览时自动安装 filens-preview 0.2.0,也可先运行 `filens setup-preview`;
|
|
138
254
|
源码版先运行 `npm run build:agent:preview`。
|
|
139
|
-
0.
|
|
140
|
-
|
|
141
|
-
独立 npm 包同时包含两种产物,约 7.0 MB 压缩包 / 24.34 MB 安装体积。
|
|
255
|
+
当前 0.3.0 构建的精确体积见上方自动生成表格,主运行时、可选压缩引擎和包含压缩引擎的总量分别计量。主运行时已包含安装包图标、可选 Office 解密模块和 28 个语言包。压缩引擎采用 O3 加 LTO,保留密码、固实压缩、分卷和所有原有解码器,移除写入功能及未使用的格式;复用编译模块,各操作仍使用独立 Worker 和内存。iWork 不再重复内嵌 ZIP 解密库。JSZip 使用源模块,让 ZIP 文档和 TIFF 共享同一份 pako,Three.js 与文档解析器共享 fflate。分包版仅在加密 Office 文档提交密码后加载解密模块;单文件版使用含解密功能的合并核心。自包含 HTML 不嵌入压缩引擎,RAR/7z 和分卷 ZIP 使用 `--mode serve`。
|
|
256
|
+
独立 npm 包同时包含两种产物,[各版本包体积记录](../../docs/preview-package-sizes.json)。
|
|
142
257
|
CLI 的安装体积另计:Lite 7.7–8.1 MiB,Full 31.1–36.8 MiB(含 OCR 运行时与模型);
|
|
143
258
|
其中原生可执行文件为 1.8–2.2 MiB,不含 Node.js、缓存及预览包。
|
|
144
|
-
|
|
145
|
-
Ctrl-C
|
|
259
|
+
图片先尝试原生显示,分包版仅在失败时加载 HEIF 解码器;视频使用浏览器编解码器,不支持的编码可通过可选 mediaConverter 接入转换器。`--no-open --json` 返回本地地址,`--assets` 可切换单文件或分包版,
|
|
260
|
+
HTTP 模式下 Ctrl-C 退出。**CLI 0.5.0 默认生成携带原文件、预览引擎和许可说明的独立 HTML**,
|
|
261
|
+
通过 `file://` 打开,生成后 CLI 退出,无需本地服务器,可完全离线使用。
|
|
262
|
+
`--output preview.html` 保存到指定路径且不覆盖已有文件;默认临时 HTML 不会随 CLI
|
|
263
|
+
退出而删除,其中包含原文件副本,使用后可自行删除。`--no-open --json` 返回本地文件
|
|
264
|
+
URL 和路径;`--mode serve` 保留原来的本地 HTTP 模式和 Ctrl-C 生命周期。
|
|
265
|
+
页面检测 WASM / Worker 能力,失败时显示兼容模式命令,并通过 CSP 禁止外部连接及
|
|
266
|
+
资源加载;右上角提供 GitHub 链接。浏览器启动成功不等于渲染成功,无法保证自动检测
|
|
267
|
+
所有浏览器失败。仅嵌入选中的文件,不开放整个父目录;伴随文件需要打成受支持的 ZIP
|
|
146
268
|
或由宿主配置解析器。
|