@file-viewer/renderer-typst 3.1.2 → 3.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.en.md +3 -49
- package/README.md +3 -49
- package/assets/LICENSE-seahash-4.1.0 +23 -0
- package/assets/NATIVE_THIRD_PARTY_LICENSES.json +10974 -0
- package/assets/fonts/LICENSE.LPPL-1.3c.txt +416 -0
- package/assets/fonts/LICENSE.typst-assets.txt +176 -0
- package/assets/fonts/NOTICE.typst-assets.txt +447 -0
- package/assets/fonts/README.md +9 -0
- package/dist/sanitize.js +0 -3
- package/dist/typst.js +0 -2
- package/package.json +42 -16
package/README.en.md
CHANGED
|
@@ -1,53 +1,7 @@
|
|
|
1
1
|
# @file-viewer/renderer-typst
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Runtime package version 3.2.0.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Usage and API documentation: https://doc.file-viewer.app/guide/on-demand-renderers
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
import FileViewer from '@file-viewer/vue3'
|
|
9
|
-
import { typstRenderer } from '@file-viewer/renderer-typst'
|
|
10
|
-
|
|
11
|
-
const options = {
|
|
12
|
-
rendererMode: 'replace',
|
|
13
|
-
renderers: typstRenderer,
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
You can also compose it with other renderer packages:
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
import { pdfRenderer } from '@file-viewer/renderer-pdf'
|
|
21
|
-
import { typstRenderer } from '@file-viewer/renderer-typst'
|
|
22
|
-
|
|
23
|
-
const options = {
|
|
24
|
-
rendererMode: 'replace',
|
|
25
|
-
renderers: [pdfRenderer, typstRenderer],
|
|
26
|
-
}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Capabilities
|
|
30
|
-
|
|
31
|
-
- Supports `.typ` and `.typst`.
|
|
32
|
-
- Compiles Typst source in the browser and renders SVG pages.
|
|
33
|
-
- Preserves page size metadata for preview, zoom, print, and HTML export.
|
|
34
|
-
- Supports `options.typst.renderTimeoutMs` for slow asset loading and long-running documents.
|
|
35
|
-
- Reports clear diagnostics for missing WASM assets, wrong MIME types, network failures, and Typst compile errors.
|
|
36
|
-
|
|
37
|
-
## Offline Assets
|
|
38
|
-
|
|
39
|
-
The default asset paths are:
|
|
40
|
-
|
|
41
|
-
- `wasm/typst/typst_ts_web_compiler_bg.wasm`
|
|
42
|
-
- `wasm/typst/typst_ts_renderer_bg.wasm`
|
|
43
|
-
- `wasm/typst/fonts/`
|
|
44
|
-
|
|
45
|
-
For private deployments, override them with `options.typst.compilerWasmUrl`, `options.typst.rendererWasmUrl`, and `options.typst.fontAssetsUrl`. The default text fonts ship with this package and are copied by `file-viewer-copy-assets` / `@file-viewer/vite-plugin`, so the runtime does not depend on public CDNs.
|
|
46
|
-
|
|
47
|
-
## CSP and Trusted Types
|
|
48
|
-
|
|
49
|
-
Typst SVG is rendered through controlled XML parsing, structural sanitization, and DOM node import without `innerHTML`. If the site enables `require-trusted-types-for 'script'`, allow `file-viewer-typst-svg` in the `trusted-types` directive (the DOMPurify export/print path also needs `dompurify`).
|
|
50
|
-
|
|
51
|
-
## Migration Note
|
|
52
|
-
|
|
53
|
-
Typst rendering has moved out of `@file-viewer/core` into this package. Core only keeps the `renderFileViewerTypst()` compatibility export with a clear installation error, and no longer installs `@myriaddreamin/*` by default. Install this renderer explicitly, or use `@file-viewer/preset-all`, when real Typst preview is required.
|
|
7
|
+
The package's own license is Apache-2.0. Included third-party notices apply to their respective components.
|
package/README.md
CHANGED
|
@@ -1,53 +1,7 @@
|
|
|
1
1
|
# @file-viewer/renderer-typst
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Runtime package version 3.2.0.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Usage and API documentation: https://doc.file-viewer.app/guide/on-demand-renderers
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
import FileViewer from '@file-viewer/vue3'
|
|
9
|
-
import { typstRenderer } from '@file-viewer/renderer-typst'
|
|
10
|
-
|
|
11
|
-
const options = {
|
|
12
|
-
rendererMode: 'replace',
|
|
13
|
-
renderers: typstRenderer,
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
也可以和其他 renderer 一起组合:
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
import { pdfRenderer } from '@file-viewer/renderer-pdf'
|
|
21
|
-
import { typstRenderer } from '@file-viewer/renderer-typst'
|
|
22
|
-
|
|
23
|
-
const options = {
|
|
24
|
-
rendererMode: 'replace',
|
|
25
|
-
renderers: [pdfRenderer, typstRenderer],
|
|
26
|
-
}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## 能力边界
|
|
30
|
-
|
|
31
|
-
- 支持 `.typ`、`.typst`。
|
|
32
|
-
- 浏览器端真实编译 Typst 源文件并输出 SVG 页面。
|
|
33
|
-
- 支持页面尺寸识别、缩放、打印和 HTML 导出。
|
|
34
|
-
- 支持 `options.typst.renderTimeoutMs` 加载 / 编译超时控制。
|
|
35
|
-
- WASM 缺失、MIME 错误、网络错误或编译错误会给出明确诊断。
|
|
36
|
-
|
|
37
|
-
## 离线资产
|
|
38
|
-
|
|
39
|
-
默认会从 viewer assets 下读取:
|
|
40
|
-
|
|
41
|
-
- `wasm/typst/typst_ts_web_compiler_bg.wasm`
|
|
42
|
-
- `wasm/typst/typst_ts_renderer_bg.wasm`
|
|
43
|
-
- `wasm/typst/fonts/`
|
|
44
|
-
|
|
45
|
-
私有化部署时可以通过 `options.typst.compilerWasmUrl`、`options.typst.rendererWasmUrl` 和 `options.typst.fontAssetsUrl` 覆盖。默认字体资产随本包发布并由 `file-viewer-copy-assets` / `@file-viewer/vite-plugin` 复制到本地静态目录,预览运行时不会访问公共 CDN。
|
|
46
|
-
|
|
47
|
-
## CSP 与 Trusted Types
|
|
48
|
-
|
|
49
|
-
Typst SVG 通过受控的 XML 解析、结构化净化和 DOM 节点导入渲染,不使用 `innerHTML`。如果站点启用了 `require-trusted-types-for 'script'`,请在 `trusted-types` 指令中允许 `file-viewer-typst-svg`(DOMPurify 的导出/打印路径还需要 `dompurify`)。
|
|
50
|
-
|
|
51
|
-
## 迁移说明
|
|
52
|
-
|
|
53
|
-
Typst 渲染已经从 `@file-viewer/core` 迁移到本包。core 只保留 `renderFileViewerTypst()` 兼容导出并给出明确安装提示,不再默认安装 `@myriaddreamin/*`。需要 Typst 真实预览时,请显式安装本包,或直接使用 `@file-viewer/preset-all`。
|
|
7
|
+
The package's own license is Apache-2.0. Included third-party notices apply to their respective components.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Permission is hereby granted, free of charge, to any
|
|
2
|
+
person obtaining a copy of this software and associated
|
|
3
|
+
documentation files (the "Software"), to deal in the
|
|
4
|
+
Software without restriction, including without
|
|
5
|
+
limitation the rights to use, copy, modify, merge,
|
|
6
|
+
publish, distribute, sublicense, and/or sell copies of
|
|
7
|
+
the Software, and to permit persons to whom the Software
|
|
8
|
+
is furnished to do so, subject to the following
|
|
9
|
+
conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice
|
|
12
|
+
shall be included in all copies or substantial portions
|
|
13
|
+
of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
|
16
|
+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
17
|
+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
18
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
19
|
+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
22
|
+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
23
|
+
DEALINGS IN THE SOFTWARE.
|