filens-preview 0.1.3 → 0.2.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 +104 -19
- package/dist/all-in-one/THIRD-PARTY-NOTICES.txt +0 -1010
- package/dist/all-in-one/filens.js +41412 -39945
- package/dist/index.d.ts +4 -0
- package/dist/split/THIRD-PARTY-NOTICES.txt +0 -1010
- package/dist/split/assets/iwork-worker-DiTOJG8f.js +27 -0
- package/dist/split/chunks/{archive-Drem4a-o.js → archive-_cUUL2-3.js} +2 -2
- package/dist/split/chunks/{cad-CsU3TiHK.js → cad-Cyh8aipO.js} +1 -1
- package/dist/split/chunks/{core-BvtuMqS1.js → core-gp02JQ3r.js} +1493 -1459
- package/dist/split/chunks/{diagram-BxRNHzmO.js → diagram-rxvArV-1.js} +2 -2
- package/dist/split/chunks/{docx-Ch1AvEUX.js → docx-ecvZsSWm.js} +2 -2
- package/dist/split/chunks/{ebook-P42eILp5.js → ebook-5FyKWZ8s.js} +2 -2
- package/dist/split/chunks/{iwork-HnghW_EB.js → iwork-DlaehzuR.js} +63 -63
- package/dist/split/chunks/{media-runtime-kbzoW8bd.js → media-runtime-DwW7eq4g.js} +2 -2
- package/dist/split/chunks/{mindmap-vFlOJSIq.js → mindmap-D9lNNDoa.js} +2 -2
- package/dist/split/chunks/model3d-BtFT01ZH.js +5093 -0
- package/dist/split/chunks/{panorama-Bw_8HQsv.js → panorama-Ci6DK6sa.js} +989 -985
- package/dist/split/chunks/{vendor-Cv2Fxtsf.js → vendor-DvWhw-zP.js} +6883 -7216
- package/dist/split/chunks/{xlsx-ypLtJxeq.js → xlsx-VJTu9XNS.js} +2 -2
- package/dist/split/converter-core.wasm +0 -0
- package/dist/split/converter-office.wasm +0 -0
- package/dist/split/filens-step.wasm +0 -0
- package/dist/split/filens.js +3814 -1213
- package/package.json +1 -1
- package/dist/split/assets/iwork-worker-D64s_rsm.js +0 -34
- package/dist/split/chunks/model3d-BBFXmxkf.js +0 -5926
- package/dist/split/occt-import-js.wasm +0 -0
package/README.md
CHANGED
|
@@ -4,8 +4,9 @@ Build the same preview engines as a single JavaScript file or split modules. Bot
|
|
|
4
4
|
include Vue, styles, PDF/iWork workers and the document, image/RAW and STEP WASM
|
|
5
5
|
engines. No conversion server or host Vue installation is needed.
|
|
6
6
|
|
|
7
|
-
Version 0.
|
|
8
|
-
|
|
7
|
+
Version 0.2.0 adds 28 toolbar languages, application-icon previews and the
|
|
8
|
+
runtime fixes used by CLI 0.5.0's offline HTML preview. It uses native HEIC/HEIF decoding first, with a small dedicated WASM
|
|
9
|
+
decoder as fallback. MOV plays through browser codecs.
|
|
9
10
|
Applications can supply an optional `mediaConverter` for unsupported MOV codecs.
|
|
10
11
|
Both builds preserve the same image and video support boundaries.
|
|
11
12
|
|
|
@@ -31,8 +32,14 @@ npm run build:preview
|
|
|
31
32
|
|
|
32
33
|
| Build | Deploy | Approximate runtime size |
|
|
33
34
|
| --- | --- | --- |
|
|
34
|
-
| Split | Entire `packages/preview/dist/split/` directory |
|
|
35
|
-
| All in one | `packages/preview/dist/all-in-one/filens.js` |
|
|
35
|
+
| Split | Entire `packages/preview/dist/split/` directory | 11.05 MB raw / 3.20 MB gzip / 2.52 MB Brotli, across all runtime files |
|
|
36
|
+
| All in one | `packages/preview/dist/all-in-one/filens.js` | 12.68 MB raw / 3.77 MB gzip / 2.83 MB Brotli |
|
|
37
|
+
|
|
38
|
+
These are current source build measurements (MB = 1,000,000 bytes), including
|
|
39
|
+
application icons, optional Office decryption and 28 locale dictionaries. The
|
|
40
|
+
npm package contains both directories, including notices, types and
|
|
41
|
+
documentation. Packed and installed bytes are recorded for each release.
|
|
42
|
+
[Package measurements](https://github.com/IceWhaleTech/filens/blob/main/docs/preview-package-sizes.json).
|
|
36
43
|
|
|
37
44
|
Both directories contain an `index.html` with a local file picker. Serve either
|
|
38
45
|
directory over HTTP(S). To integrate into another page:
|
|
@@ -63,16 +70,44 @@ direct Vue component integration.
|
|
|
63
70
|
Split chunks can range from a few KB to hundreds of KB after compression. Those
|
|
64
71
|
figures exclude shared dependencies and engines; a chunk is not a complete
|
|
65
72
|
per-format download. The all-in-one file embeds CSS, base64 WASM and workers; it
|
|
66
|
-
needs no additional runtime files.
|
|
67
|
-
|
|
73
|
+
needs no additional runtime files.
|
|
74
|
+
A separate notices file accompanies
|
|
68
75
|
both builds and should be distributed with them. [Exact measurements](https://github.com/IceWhaleTech/filens/blob/main/docs/preview-build-sizes.json).
|
|
69
76
|
|
|
70
77
|
Single-file embedding still requires browser support for WebAssembly and workers.
|
|
71
78
|
Pages with a Content Security Policy must permit the generated inline styles,
|
|
72
79
|
`blob:` workers and `data:` WASM. Use an HTTP(S) server for module imports, rather
|
|
73
|
-
than opening `index.html` as a `file:` URL. The
|
|
80
|
+
than opening the module-importing `index.html` as a `file:` URL. The CLI's
|
|
81
|
+
self-contained HTML embeds the module instead and supports `file:` URLs.
|
|
82
|
+
The supported formats and fidelity
|
|
74
83
|
limits are shared with the [demo](https://github.com/IceWhaleTech/filens/blob/main/docs/support-matrix.md).
|
|
75
84
|
|
|
85
|
+
## Languages and application icons (0.2.0)
|
|
86
|
+
|
|
87
|
+
Preview toolbars, common prompts and model controls include the same 28 locale
|
|
88
|
+
codes as ZimaOS. Pass `locale: 'zh_CN'` (or `zh-CN`); omit it for browser language
|
|
89
|
+
detection. Switch language with `viewer.update({ locale: 'de_DE' })`. Optional
|
|
90
|
+
`messages: { Next: 'Forward' }` overrides English source phrases per instance.
|
|
91
|
+
Both split and all-in-one builds contain these dictionaries for offline use.
|
|
92
|
+
See the [locale list and API notes](../vue/README.md#languages-source-build).
|
|
93
|
+
|
|
94
|
+
APK/IPA packages and Windows EXE/DLL/MUI/MUN resource files can be previewed as
|
|
95
|
+
application icons using the included WASM converter. Icon extraction supports
|
|
96
|
+
compiled Android icon resources, XML/binary iOS plist metadata, iOS CgBI PNGs,
|
|
97
|
+
and Windows PNG/DIB icon frames. These additions are included in 0.2.0.
|
|
98
|
+
See the [supported icon representations
|
|
99
|
+
and limits](../vue/README.md#application-icons-source-build).
|
|
100
|
+
|
|
101
|
+
The split build loads `converter-office.wasm` only when an encrypted Office
|
|
102
|
+
document has a supplied password; a password prompt alone does not download it.
|
|
103
|
+
The core is about 413 KB gzip, and the optional decryptor about 164 KB gzip.
|
|
104
|
+
Splitting saves about 64 KB gzip on ordinary converted previews, while downloading
|
|
105
|
+
both costs about 100 KB gzip more than the combined core due to shared code.
|
|
106
|
+
The all-in-one file uses the combined core (477 KB gzip / 387 KB Brotli) to avoid
|
|
107
|
+
that duplication; its download includes decryption. See the
|
|
108
|
+
[same-source measurements](../../docs/converter-size-impact.md) and the
|
|
109
|
+
[format package audit](../../docs/format-package-sizes.md).
|
|
110
|
+
|
|
76
111
|
## CLI preview
|
|
77
112
|
|
|
78
113
|
CLI 0.4.0 includes `preview`. The first preview downloads the optional frontend
|
|
@@ -99,20 +134,60 @@ npm run filens -- preview report.pdf
|
|
|
99
134
|
./dist/filens preview report.pdf --no-open --json
|
|
100
135
|
```
|
|
101
136
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
137
|
+
CLI 0.4.x used a loopback HTTP server. **CLI 0.5.0 defaults to a self-contained
|
|
138
|
+
HTML instead**: the shared all-in-one frontend runtime and a
|
|
139
|
+
copy of the selected file are embedded, the browser opens a `file:` URL, and the
|
|
140
|
+
CLI exits. No HTTP server is started. Parsing, conversion and rendering happen
|
|
141
|
+
in the browser, with no external runtime dependencies. The page checks WASM and
|
|
142
|
+
local Worker support and displays compatibility instructions on failure. It also
|
|
143
|
+
includes a GitHub link and third-party notices. Browser launch success does not
|
|
144
|
+
certify rendering; the CLI cannot automatically detect every browser failure.
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
# Generate and open an offline HTML, or save it without opening a browser
|
|
148
|
+
filens preview report.pdf
|
|
149
|
+
filens preview report.pdf --output report-preview.html --no-open
|
|
150
|
+
filens preview report.pdf --no-open --json
|
|
151
|
+
|
|
152
|
+
# Compatibility mode: serve only on this machine; Ctrl-C stops it
|
|
153
|
+
filens preview report.pdf --mode serve
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
HTML mode returns a `file:` URL and a filesystem `path`; the command exits even
|
|
157
|
+
with `--no-open --json`. Default HTML files remain in the system temporary
|
|
158
|
+
directory so the browser can finish loading after CLI exit. **The HTML contains
|
|
159
|
+
the original file bytes**; delete it when no longer needed. `--output` never
|
|
160
|
+
overwrites existing files. Base64 embedding adds about one third to the source
|
|
161
|
+
file size, plus the runtime and notices. Prefer HTTP mode or the browser file
|
|
162
|
+
picker for very large files. The HTML's Content Security Policy blocks external
|
|
163
|
+
connections and resource loads; linked images/fonts are unavailable unless
|
|
164
|
+
embedded or supplied locally. The GitHub link opens only when clicked.
|
|
165
|
+
|
|
166
|
+
On `file:` pages PDF.js uses its supported main-thread worker implementation to
|
|
167
|
+
avoid opaque-origin module-worker restrictions in WebKit. Large PDFs can occupy
|
|
168
|
+
the UI thread; HTTP mode keeps the usual worker loading path.
|
|
169
|
+
WebKit currently cannot load the embedded iWork parser worker from a `file:`
|
|
170
|
+
page. Its error panel offers `--mode serve`; the same Keynote sample was verified
|
|
171
|
+
with the split runtime in that compatibility mode. Chromium and Firefox support
|
|
172
|
+
the tested iWork HTML previews directly.
|
|
173
|
+
|
|
174
|
+
`--mode serve --no-open --json` retains the previous URL/server lifecycle. Its
|
|
175
|
+
command keeps running until Ctrl-C. `--port` implies serve mode unless an explicit
|
|
176
|
+
`--mode` is given. To choose a port or built runtime:
|
|
106
177
|
|
|
107
178
|
```sh
|
|
108
179
|
# Choose a port or another built runtime (including the all-in-one build)
|
|
109
|
-
filens preview report.pdf --port 8080 --assets /path/to/preview/dist/all-in-one
|
|
180
|
+
filens preview report.pdf --mode serve --port 8080 --assets /path/to/preview/dist/all-in-one
|
|
110
181
|
```
|
|
111
182
|
|
|
112
183
|
`FILENS_PREVIEW_DIR` overrides the default `<binary-directory>/preview` asset
|
|
113
|
-
directory.
|
|
114
|
-
`
|
|
115
|
-
|
|
184
|
+
directory. An asset directory can be the package's `dist/` root or a specific
|
|
185
|
+
`split/` / `all-in-one/` directory; HTML mode needs the all-in-one runtime (a
|
|
186
|
+
`split/` directory also works when its `all-in-one/` sibling is present).
|
|
187
|
+
Source npm packaging can include the assets with
|
|
188
|
+
`node scripts/package-agent-npm.mjs --with-preview`. These optional resources
|
|
189
|
+
include both split assets and the all-in-one runtime, measured separately from
|
|
190
|
+
the document-reading CLI.
|
|
116
191
|
|
|
117
192
|
The server exposes one selected file, not its parent directory. Models or media
|
|
118
193
|
with external sidecars need a supported ZIP bundle or a host-provided resource
|
|
@@ -128,9 +203,19 @@ macOS; Windows/Linux browser launching still needs native validation.
|
|
|
128
203
|
另附第三方许可文件。单文件部署更简单,初次下载也更大。
|
|
129
204
|
|
|
130
205
|
`filens preview 文件路径` 会启动本地浏览器预览,由前端完成格式解析与渲染。
|
|
131
|
-
CLI 0.
|
|
206
|
+
CLI 0.5.0 首次预览时自动安装 filens-preview 0.2.0,也可先运行 `filens setup-preview`;
|
|
132
207
|
源码版先运行 `npm run build:agent:preview`。
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
208
|
+
当前源码构建中,分包运行时合计 2.52 MB Brotli,单文件为 2.83 MB Brotli / 3.77 MB gzip / 12.68 MB 原始体积,已包含安装包图标、可选 Office 解密模块和 28 个语言包。分包版仅在加密 Office 文档提交密码后加载解密模块;单文件版使用含解密功能的合并核心,避免重复代码。合并核心为 477 KB gzip / 387 KB Brotli,尚未达到约 300 KB 的目标。
|
|
209
|
+
独立 npm 包同时包含两种产物,[各版本包体积记录](../../docs/preview-package-sizes.json)。
|
|
210
|
+
CLI 的安装体积另计:Lite 7.7–8.1 MiB,Full 31.1–36.8 MiB(含 OCR 运行时与模型);
|
|
211
|
+
其中原生可执行文件为 1.8–2.2 MiB,不含 Node.js、缓存及预览包。
|
|
212
|
+
源码仅附带分包目录时约 11.6 MB(含许可文件与 HTML)。图片先尝试原生显示,分包版仅在失败时加载 HEIF 解码器;视频使用浏览器编解码器,不支持的编码可通过可选 mediaConverter 接入转换器。`--no-open --json` 返回本地地址,`--assets` 可切换单文件或分包版,
|
|
213
|
+
HTTP 模式下 Ctrl-C 退出。**CLI 0.5.0 默认生成携带原文件、预览引擎和许可说明的独立 HTML**,
|
|
214
|
+
通过 `file://` 打开,生成后 CLI 退出,无需本地服务器,可完全离线使用。
|
|
215
|
+
`--output preview.html` 保存到指定路径且不覆盖已有文件;默认临时 HTML 不会随 CLI
|
|
216
|
+
退出而删除,其中包含原文件副本,使用后可自行删除。`--no-open --json` 返回本地文件
|
|
217
|
+
URL 和路径;`--mode serve` 保留原来的本地 HTTP 模式和 Ctrl-C 生命周期。
|
|
218
|
+
页面检测 WASM / Worker 能力,失败时显示兼容模式命令,并通过 CSP 禁止外部连接及
|
|
219
|
+
资源加载;右上角提供 GitHub 链接。浏览器启动成功不等于渲染成功,无法保证自动检测
|
|
220
|
+
所有浏览器失败。仅嵌入选中的文件,不开放整个父目录;伴随文件需要打成受支持的 ZIP
|
|
136
221
|
或由宿主配置解析器。
|