filens-preview 0.0.0-stage → 0.1.2
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/LICENSE +21 -0
- package/README.md +135 -2
- package/dist/all-in-one/THIRD-PARTY-NOTICES.txt +9296 -0
- package/dist/all-in-one/filens.js +107579 -0
- package/dist/all-in-one/index.html +18 -0
- package/dist/index.d.ts +36 -0
- package/dist/split/THIRD-PARTY-NOTICES.txt +9296 -0
- package/dist/split/assets/iwork-worker-D64s_rsm.js +34 -0
- package/dist/split/chunks/archive-Drem4a-o.js +731 -0
- package/dist/split/chunks/cad-CsU3TiHK.js +2405 -0
- package/dist/split/chunks/core-BvtuMqS1.js +14148 -0
- package/dist/split/chunks/diagram-BxRNHzmO.js +654 -0
- package/dist/split/chunks/docx-Ch1AvEUX.js +299 -0
- package/dist/split/chunks/ebook-P42eILp5.js +623 -0
- package/dist/split/chunks/iwork-HnghW_EB.js +772 -0
- package/dist/split/chunks/media-runtime-kbzoW8bd.js +48 -0
- package/dist/split/chunks/mindmap-vFlOJSIq.js +560 -0
- package/dist/split/chunks/model3d-BBFXmxkf.js +5926 -0
- package/dist/split/chunks/panorama-Bw_8HQsv.js +5956 -0
- package/dist/split/chunks/pdf-CecYOWld.js +17898 -0
- package/dist/split/chunks/vendor-Cv2Fxtsf.js +54804 -0
- package/dist/split/chunks/xlsx-ypLtJxeq.js +818 -0
- package/dist/split/converter-core.wasm +0 -0
- package/dist/split/converter-image.wasm +0 -0
- package/dist/split/filens-step.wasm +0 -0
- package/dist/split/filens.js +2180 -0
- package/dist/split/index.html +18 -0
- package/dist/split/libheif.wasm +0 -0
- package/dist/split/occt-import-js.wasm +0 -0
- package/dist/split/pdf.worker.min.mjs +28 -0
- package/package.json +22 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FiLens contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,136 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Standalone browser previews / 独立前端预览
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Build the same preview engines as a single JavaScript file or split modules. Both
|
|
4
|
+
include Vue, styles, PDF/iWork workers and the document, image/RAW and STEP WASM
|
|
5
|
+
engines. No conversion server or host Vue installation is needed.
|
|
6
|
+
|
|
7
|
+
Version 0.1.2 uses native HEIC/HEIF decoding first, with a small dedicated WASM
|
|
8
|
+
decoder as fallback. MOV plays through browser codecs; full FFmpeg is excluded.
|
|
9
|
+
Applications can supply an optional `mediaConverter` for unsupported MOV codecs.
|
|
10
|
+
Both builds preserve the same image and video support boundaries.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install filens-preview
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import { createPreview } from 'filens-preview';
|
|
18
|
+
// Or: import { createPreview } from 'filens-preview/all-in-one';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The npm package includes both runtime directories, TypeScript declarations and third-party notices.
|
|
22
|
+
Deploy `node_modules/filens-preview/dist/split/` or `dist/all-in-one/` for direct browser use.
|
|
23
|
+
|
|
24
|
+
## Build and use
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm ci
|
|
28
|
+
npm run build:wasm
|
|
29
|
+
npm run build:preview
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
| Build | Deploy | Approximate runtime size |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| Split | Entire `packages/preview/dist/split/` directory | 13.5 MB raw / 4.2 MB gzip / 3.3 MB Brotli, across all runtime files |
|
|
35
|
+
| All in one | `packages/preview/dist/all-in-one/filens.js` | 16.3 MB raw / 5.2 MB gzip / 3.9 MB Brotli |
|
|
36
|
+
|
|
37
|
+
Both directories contain an `index.html` with a local file picker. Serve either
|
|
38
|
+
directory over HTTP(S). To integrate into another page:
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<div id="preview" style="height: 80vh"></div>
|
|
42
|
+
<script type="module">
|
|
43
|
+
import { createPreview } from './split/filens.js';
|
|
44
|
+
// Or: import { createPreview } from './all-in-one/filens.js';
|
|
45
|
+
|
|
46
|
+
const viewer = createPreview('#preview', {
|
|
47
|
+
src: './report.pdf',
|
|
48
|
+
name: 'report.pdf',
|
|
49
|
+
onError: error => console.error(error)
|
|
50
|
+
});
|
|
51
|
+
// File / Blob / Uint8Array sources also work; supply a name or extension.
|
|
52
|
+
// viewer.update({ src: anotherFile, name: anotherFile.name });
|
|
53
|
+
// viewer.destroy();
|
|
54
|
+
</script>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`createPreview()` mounts the shared `Preview` component and returns `update()` and
|
|
58
|
+
`destroy()`. Options include `src`, `name`, `extension`, `toolbar`, `converter`, `panoramaProcessor`,
|
|
59
|
+
`resourceResolver`, `fontResolver`, `onRendered` and `onError`. The default converter
|
|
60
|
+
uses the bundled frontend WASM engines. Use [`@filens/vue`](https://github.com/IceWhaleTech/filens/tree/main/packages/vue) for
|
|
61
|
+
direct Vue component integration.
|
|
62
|
+
|
|
63
|
+
Split chunks can range from a few KB to hundreds of KB after compression. Those
|
|
64
|
+
figures exclude shared dependencies and engines; a chunk is not a complete
|
|
65
|
+
per-format download. The all-in-one file embeds CSS, base64 WASM and workers; it
|
|
66
|
+
needs no additional runtime files. Its larger initial download includes optional
|
|
67
|
+
OCCT as well as the default Rust STEP engine. A separate notices file accompanies
|
|
68
|
+
both builds and should be distributed with them. [Exact measurements](https://github.com/IceWhaleTech/filens/blob/main/docs/preview-build-sizes.json).
|
|
69
|
+
|
|
70
|
+
Single-file embedding still requires browser support for WebAssembly and workers.
|
|
71
|
+
Pages with a Content Security Policy must permit the generated inline styles,
|
|
72
|
+
`blob:` workers and `data:` WASM. Use an HTTP(S) server for module imports, rather
|
|
73
|
+
than opening `index.html` as a `file:` URL. The supported formats and fidelity
|
|
74
|
+
limits are shared with the [demo](https://github.com/IceWhaleTech/filens/blob/main/docs/support-matrix.md).
|
|
75
|
+
|
|
76
|
+
## CLI preview
|
|
77
|
+
|
|
78
|
+
CLI 0.4.0 includes `preview`. The first preview downloads the optional frontend
|
|
79
|
+
package into the writable versioned cache; subsequent previews work offline.
|
|
80
|
+
You can install it ahead of time:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
npm install -g filens-cli
|
|
84
|
+
filens setup-preview
|
|
85
|
+
filens preview report.pdf
|
|
86
|
+
filens preview report.pdf --no-open --json
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`filens-cli-lite` supports the same preview command without OCR models. Frontend
|
|
90
|
+
resources are separate from the base CLI installation. For a source build:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
npm run build:wasm
|
|
94
|
+
npm run build:agent:preview
|
|
95
|
+
npm run filens -- preview report.pdf
|
|
96
|
+
|
|
97
|
+
# Or run the freshly built binary directly
|
|
98
|
+
./dist/filens preview drawing.step
|
|
99
|
+
./dist/filens preview report.pdf --no-open --json
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Preview serves the selected file and built assets on `127.0.0.1`, chooses a free
|
|
103
|
+
port, and opens the browser. Parsing, conversion and rendering happen in the
|
|
104
|
+
browser. Ctrl-C stops the server. `--no-open --json` prints a URL for an Agent or a
|
|
105
|
+
terminal without a browser; the command keeps running until stopped.
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
# 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
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`FILENS_PREVIEW_DIR` overrides the default `<binary-directory>/preview` asset
|
|
113
|
+
directory. Source npm packaging can include the assets with
|
|
114
|
+
`node scripts/package-agent-npm.mjs --with-preview`; they are optional and add
|
|
115
|
+
about 13.5 MB on disk, measured separately from the document-reading CLI.
|
|
116
|
+
|
|
117
|
+
The server exposes one selected file, not its parent directory. Models or media
|
|
118
|
+
with external sidecars need a supported ZIP bundle or a host-provided resource
|
|
119
|
+
resolver; arbitrary adjacent files are not served. Binary media responses support
|
|
120
|
+
byte ranges. The listener checks the Host and Origin, scopes routes to a random
|
|
121
|
+
session path, and rejects directory traversal. CLI preview has been exercised on
|
|
122
|
+
macOS; Windows/Linux browser launching still needs native validation.
|
|
123
|
+
|
|
124
|
+
## 中文说明
|
|
125
|
+
|
|
126
|
+
两种产物使用相同 API:分包版部署整个 `split/` 目录,WASM 与重型引擎按需加载;
|
|
127
|
+
单文件版仅需部署 `all-in-one/filens.js`,其中包含 Vue、样式、Worker 和 WASM,
|
|
128
|
+
另附第三方许可文件。单文件部署更简单,初次下载也更大。
|
|
129
|
+
|
|
130
|
+
`filens preview 文件路径` 会启动本地浏览器预览,由前端完成格式解析与渲染。
|
|
131
|
+
CLI 0.4.1 首次预览时自动安装 filens-preview 0.1.2,也可先运行 `filens setup-preview`;
|
|
132
|
+
源码版先运行 `npm run build:agent:preview`。
|
|
133
|
+
独立前端包同时包含单文件和分包产物,完整安装约 31 MB,包含专用 HEIC/HEIF 解码器,不含完整 FFmpeg,不混入 CLI 的
|
|
134
|
+
约 2 MB / Lite 8 MB / Full 30 多 MB 安装体积。源码仅附带分包时约 13.5 MB。图片先尝试原生显示,分包版仅在失败时加载 HEIF 解码器;视频使用浏览器编解码器,不支持的编码可通过可选 mediaConverter 接入转换器。`--no-open --json` 返回本地地址,`--assets` 可切换单文件或分包版,
|
|
135
|
+
Ctrl-C 退出。仅提供选中的文件,不开放整个父目录;伴随文件需要打成受支持的 ZIP
|
|
136
|
+
或由宿主配置解析器。
|