bm-render 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/NOTICE +38 -0
- package/README.md +51 -3
- package/README.vi.md +51 -0
- package/THIRD-PARTY-NOTICES.md +1228 -0
- package/js/addons.d.mts +13 -0
- package/js/addons.mjs +74 -0
- package/js/bm_render.core.wasm +0 -0
- package/js/bm_render.pdf.wasm +0 -0
- package/js/bm_render.standard.wasm +0 -0
- package/js/bm_render.wasm +0 -0
- package/js/bm_woff.wasm +0 -0
- package/js/build-manifest.json +46 -0
- package/js/core.d.mts +16 -0
- package/js/core.mjs +20 -0
- package/js/engine.mjs +797 -0
- package/js/full.d.mts +16 -0
- package/js/full.mjs +20 -0
- package/js/index.d.mts +381 -0
- package/js/index.mjs +64 -0
- package/js/native.d.mts +4 -0
- package/js/native.mjs +250 -0
- package/js/node-core.mjs +9 -0
- package/js/node-full.mjs +9 -0
- package/js/node-native.mjs +15 -0
- package/js/node-pdf.mjs +34 -0
- package/js/node-standard.mjs +9 -0
- package/js/node.mjs +63 -0
- package/js/pdf-api.mjs +232 -0
- package/js/pdf-resources.mjs +152 -0
- package/js/pdf-types.d.mts +211 -0
- package/js/pdf.d.mts +85 -0
- package/js/pdf.mjs +26 -0
- package/js/standard.d.mts +16 -0
- package/js/standard.mjs +20 -0
- package/js/wasm-file.mjs +93 -0
- package/js/wasm.d.mts +9 -0
- package/package.json +248 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 hunghg255
|
|
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/NOTICE
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
bm-render
|
|
2
|
+
Copyright (c) 2026 hunghg255
|
|
3
|
+
https://github.com/BM-Hospital/bm-render
|
|
4
|
+
|
|
5
|
+
Licensed under the MIT License (LICENSE).
|
|
6
|
+
|
|
7
|
+
bm-render is a port to Zig / WebAssembly of takumi (https://github.com/kane50613/takumi):
|
|
8
|
+
|
|
9
|
+
takumi
|
|
10
|
+
Copyright (c) 2025 Kane Wang
|
|
11
|
+
Licensed under the MIT License or the Apache License, Version 2.0, at your option.
|
|
12
|
+
|
|
13
|
+
Large parts of bm-render are transliterations of takumi's Rust code (layout, painting, text, CSS,
|
|
14
|
+
Tailwind, HTML, SVG, animation, codecs); bm-render is therefore a derivative work of takumi, uses
|
|
15
|
+
takumi under the MIT option of its dual license, and keeps its copyright notice in LICENSE.
|
|
16
|
+
|
|
17
|
+
takumi in turn follows Chromium's Blink renderer and Skia in many places, and bm-render ports or follows
|
|
18
|
+
further third-party code, algorithms and data. The notices they require are reproduced in
|
|
19
|
+
THIRD-PARTY-NOTICES.md:
|
|
20
|
+
|
|
21
|
+
- Chromium (Blink) and Skia ............ BSD-style (via takumi's LICENSE-CHROMIUM)
|
|
22
|
+
- tiny-skia ............................ BSD 3-Clause
|
|
23
|
+
- HarfBuzz ............................. "Old MIT"
|
|
24
|
+
- libwebp .............................. BSD 3-Clause (+ patent grant)
|
|
25
|
+
- Independent JPEG Group (libjpeg) ..... "This software is based in part on the work of the
|
|
26
|
+
Independent JPEG Group."
|
|
27
|
+
- Unicode data, ICU / ICU4X ............ Unicode License V3
|
|
28
|
+
- emoji-segmenter ...................... Apache License 2.0 (Copyright 2019 Google LLC)
|
|
29
|
+
- Brotli static dictionary ............. MIT (Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors)
|
|
30
|
+
- Taffy ................................ MIT (Copyright (c) 2018 Visly Inc.)
|
|
31
|
+
- krilla (PDF output) .................. MIT OR Apache-2.0 (Copyright (c) 2024 Laurenz Stampfl), with notices for code
|
|
32
|
+
it takes from resvg (MPL 2.0), typst, svg2pdf and vello
|
|
33
|
+
- subsetter (PDF font subsetting) ...... MIT, with ttf-parser (Copyright (c) 2018 Yevhenii Reizner) and fonttools
|
|
34
|
+
(Copyright (c) 2017 Just van Rossum), both MIT
|
|
35
|
+
- pdf-writer, xmp-writer (PDF output) .. MIT OR Apache-2.0
|
|
36
|
+
- Compact ICC Profiles, sRGB v4 ........ CC0 1.0 (Clinton Ingram / saucecontrol); src/pdf/srgb-v4.icc
|
|
37
|
+
|
|
38
|
+
No font files are distributed with the package. Fonts you register at run time keep their own licenses.
|
package/README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# bm-render
|
|
2
|
+
|
|
3
|
+
[English](README.md) · [Tiếng Việt](README.vi.md)
|
|
4
|
+
|
|
5
|
+
A Zig library that turns node trees or HTML + CSS into PNG, JPEG, WebP, SVG, animations and PDF. Runs as a native addon on Node.js when available, with WebAssembly fallback and support for browsers and edge runtimes.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install bm-render
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Create an image
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { Renderer } from "bm-render";
|
|
18
|
+
|
|
19
|
+
const renderer = new Renderer();
|
|
20
|
+
renderer.registerFont(readFileSync("./fonts/Inter-Regular.ttf"));
|
|
21
|
+
|
|
22
|
+
const png = await renderer.render({
|
|
23
|
+
type: "container",
|
|
24
|
+
style: {
|
|
25
|
+
display: "flex", width: "100%", height: "100%",
|
|
26
|
+
alignItems: "center", justifyContent: "center",
|
|
27
|
+
backgroundColor: "#18181b", color: "white", fontSize: 64,
|
|
28
|
+
},
|
|
29
|
+
children: [{ type: "text", text: "Hello from bm-render" }],
|
|
30
|
+
}, { width: 1200, height: 630 });
|
|
31
|
+
|
|
32
|
+
writeFileSync("card.png", png);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Provide the font file at the example path before running it. Reuse the renderer so each image does not reload fonts.
|
|
36
|
+
|
|
37
|
+
## Documentation
|
|
38
|
+
|
|
39
|
+
- [Getting started](docs/en/getting-started.md)
|
|
40
|
+
- [Images](docs/en/image/index.md)
|
|
41
|
+
- [PDF](docs/en/pdf/index.md)
|
|
42
|
+
- [Choose an output](docs/en/outputs-compared.md)
|
|
43
|
+
- [Profiles and size](docs/en/profiles-and-size.md)
|
|
44
|
+
- [Benchmark](docs/en/benchmark.md)
|
|
45
|
+
- [Troubleshooting](docs/en/troubleshooting.md)
|
|
46
|
+
|
|
47
|
+
## License and attribution
|
|
48
|
+
|
|
49
|
+
bm-render is licensed under the [MIT License](LICENSE). Copyright (c) 2026 hunghg255.
|
|
50
|
+
Third-party code and data it builds on are credited in [NOTICE](NOTICE) and
|
|
51
|
+
[THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).
|
package/README.vi.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# bm-render
|
|
2
|
+
|
|
3
|
+
[English](README.md) · [Tiếng Việt](README.vi.md)
|
|
4
|
+
|
|
5
|
+
Thư viện viết bằng Zig để chuyển cây node hoặc HTML + CSS thành PNG, JPEG, WebP, SVG, ảnh động và PDF. Chạy bằng addon native trên Node.js khi có sẵn, với WebAssembly dự phòng và hỗ trợ trình duyệt cùng môi trường edge.
|
|
6
|
+
|
|
7
|
+
## Cài đặt
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install bm-render
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Ví dụ tạo ảnh
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { Renderer } from "bm-render";
|
|
18
|
+
|
|
19
|
+
const renderer = new Renderer();
|
|
20
|
+
renderer.registerFont(readFileSync("./fonts/Inter-Regular.ttf"));
|
|
21
|
+
|
|
22
|
+
const png = await renderer.render({
|
|
23
|
+
type: "container",
|
|
24
|
+
style: {
|
|
25
|
+
display: "flex", width: "100%", height: "100%",
|
|
26
|
+
alignItems: "center", justifyContent: "center",
|
|
27
|
+
backgroundColor: "#18181b", color: "white", fontSize: 64,
|
|
28
|
+
},
|
|
29
|
+
children: [{ type: "text", text: "Hello from bm-render" }],
|
|
30
|
+
}, { width: 1200, height: 630 });
|
|
31
|
+
|
|
32
|
+
writeFileSync("card.png", png);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Chuẩn bị file font ở đường dẫn trong ví dụ trước khi chạy. Tái sử dụng renderer để không phải nạp font lại cho từng ảnh.
|
|
36
|
+
|
|
37
|
+
## Tài liệu
|
|
38
|
+
|
|
39
|
+
- [Bắt đầu](docs/vi/getting-started.md)
|
|
40
|
+
- [Tạo ảnh](docs/vi/image/index.md)
|
|
41
|
+
- [Tạo PDF](docs/vi/pdf/index.md)
|
|
42
|
+
- [Chọn đầu ra](docs/vi/outputs-compared.md)
|
|
43
|
+
- [Profile và kích thước](docs/vi/profiles-and-size.md)
|
|
44
|
+
- [Benchmark](docs/vi/benchmark.md)
|
|
45
|
+
- [Xử lý sự cố](docs/vi/troubleshooting.md)
|
|
46
|
+
|
|
47
|
+
## Giấy phép và ghi công
|
|
48
|
+
|
|
49
|
+
bm-render được cấp phép theo [MIT License](LICENSE). Copyright (c) 2026 hunghg255.
|
|
50
|
+
Mã và dữ liệu bên thứ ba mà bm-render dựa vào được ghi công trong [NOTICE](NOTICE) và
|
|
51
|
+
[THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).
|