turbo-html2pdf 0.2.2 → 0.2.3
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/Cargo.toml +2 -2
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/convert.rs +1 -1
- package/src/errors.rs +1 -1
- package/src/lib.rs +6 -6
- package/turbo-pdf-napi.darwin-arm64.node +0 -0
- package/turbo-pdf-napi.linux-arm64-gnu.node +0 -0
- package/turbo-pdf-napi.linux-x64-gnu.node +0 -0
- package/turbo-pdf-napi.linux-x64-musl.node +0 -0
- package/turbo-pdf-napi.win32-x64-msvc.node +0 -0
package/Cargo.toml
CHANGED
|
@@ -14,7 +14,7 @@ rust-version.workspace = true
|
|
|
14
14
|
crate-type = ["cdylib", "rlib"]
|
|
15
15
|
|
|
16
16
|
[dependencies]
|
|
17
|
-
turbo-
|
|
17
|
+
turbo-html2pdf-core = { path = "../turbo-html2pdf-core", features = [
|
|
18
18
|
"endnotes",
|
|
19
19
|
"xref",
|
|
20
20
|
"pdf-a",
|
|
@@ -34,7 +34,7 @@ napi-derive = "2"
|
|
|
34
34
|
# default: the standard `turbo-html2pdf` package ships without it. The separate
|
|
35
35
|
# `turbo-html2pdf-svg` package is built with `napi build --features svg` (see the
|
|
36
36
|
# `build-napi-svg`/`publish-svg` jobs in .github/workflows/release.yml).
|
|
37
|
-
svg = ["turbo-
|
|
37
|
+
svg = ["turbo-html2pdf-core/svg"]
|
|
38
38
|
|
|
39
39
|
[build-dependencies]
|
|
40
40
|
napi-build = "2"
|
package/README.md
CHANGED
|
@@ -111,7 +111,7 @@ Numbers are "on this machine", never absolutes — rerun with `cd benches/compet
|
|
|
111
111
|
## Architecture
|
|
112
112
|
|
|
113
113
|
A template is **compiled once** into a reusable `Program`, then rendered against
|
|
114
|
-
data many times. The pipeline (`crates/turbo-
|
|
114
|
+
data many times. The pipeline (`crates/turbo-html2pdf-core`):
|
|
115
115
|
|
|
116
116
|
```
|
|
117
117
|
template (HTML + Jinja + t: directives)
|
|
@@ -201,7 +201,7 @@ fs.writeFileSync('out.pdf', pdf) // %PDF-1.7
|
|
|
201
201
|
|
|
202
202
|
## Status
|
|
203
203
|
|
|
204
|
-
`v0.2.
|
|
204
|
+
`v0.2.3`. The core engine is complete and heavily tested (the `turbo-html2pdf-core`
|
|
205
205
|
crate holds 100% line coverage with a cyclomatic-complexity ≤ 5 gate). Bindings:
|
|
206
206
|
Node (napi) and WebAssembly. See [`docs/`](https://github.com/miaskiewicz/turbo-html2pdf/blob/main/docs/) for the full guide and
|
|
207
207
|
[`benches/competitive/`](https://github.com/miaskiewicz/turbo-html2pdf/blob/main/benches/competitive/) for the benchmark harness.
|
package/package.json
CHANGED
package/src/convert.rs
CHANGED
|
@@ -7,7 +7,7 @@ use std::collections::HashMap;
|
|
|
7
7
|
use napi::bindgen_prelude::Buffer;
|
|
8
8
|
use napi_derive::napi;
|
|
9
9
|
|
|
10
|
-
use
|
|
10
|
+
use turbo_html2pdf_core::{Diagnostics, FontFace, FontRegistry, ImageResolver, Lint, LintCode};
|
|
11
11
|
|
|
12
12
|
/// A non-fatal diagnostic (lint) returned in the render result, never thrown.
|
|
13
13
|
#[napi(object)]
|
package/src/errors.rs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
//! JS wrapper (`index.js`) detects the prefix and rethrows a typed
|
|
8
8
|
//! `TurboPdfError` whose `.code` and `.span` mirror this payload.
|
|
9
9
|
|
|
10
|
-
use
|
|
10
|
+
use turbo_html2pdf_core::{AppendError, CompileError, ErrorCode, RenderError, Span};
|
|
11
11
|
|
|
12
12
|
/// Sentinel that marks a `reason` string as a structured turbo-pdf error. The JS
|
|
13
13
|
/// wrapper splits on this to recover the JSON payload.
|
package/src/lib.rs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//! turbo-pdf N-API binding (Phase 10).
|
|
2
2
|
//!
|
|
3
|
-
//! Exposes the compile -> render -> emit pipeline of `turbo-
|
|
3
|
+
//! Exposes the compile -> render -> emit pipeline of `turbo-html2pdf-core` to Node/JS.
|
|
4
4
|
//! A template is compiled once into a [`Program`] (a `Send + Sync` native handle)
|
|
5
5
|
//! and rendered against data as many times as needed; a one-shot [`render`]
|
|
6
6
|
//! convenience does both in a single call.
|
|
@@ -31,8 +31,8 @@ use std::sync::Arc;
|
|
|
31
31
|
|
|
32
32
|
use std::collections::HashMap;
|
|
33
33
|
|
|
34
|
-
use
|
|
35
|
-
use
|
|
34
|
+
use turbo_html2pdf_core::style::TokenSet;
|
|
35
|
+
use turbo_html2pdf_core::{
|
|
36
36
|
append_pdfs, build_cascade, compile as core_compile, emit_pdf_with_images, render_pages,
|
|
37
37
|
style::parse_stylesheet, CompileOptions, Diagnostics, EmitOptions, Encryption, FontRegistry,
|
|
38
38
|
ImageWatermark, MissingPolicy, NoImages, Permissions, RenderInputs, Rgba, TextWatermark,
|
|
@@ -210,7 +210,7 @@ impl Fonts {
|
|
|
210
210
|
/// render it against many data sets. The handle is thread-safe.
|
|
211
211
|
#[napi]
|
|
212
212
|
pub struct Program {
|
|
213
|
-
inner:
|
|
213
|
+
inner: turbo_html2pdf_core::Program,
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
#[napi]
|
|
@@ -313,7 +313,7 @@ pub fn append_pdf(base: Buffer, extras: Vec<Buffer>) -> napi::Result<Buffer> {
|
|
|
313
313
|
/// The shared render pipeline: cascade + geometry + fonts -> `render_pages` ->
|
|
314
314
|
/// `emit_pdf`. Diagnostics flow into the result; only fatal faults throw.
|
|
315
315
|
fn run_pipeline(
|
|
316
|
-
program: &
|
|
316
|
+
program: &turbo_html2pdf_core::Program,
|
|
317
317
|
opts: RenderOptions,
|
|
318
318
|
fonts: Option<&Fonts>,
|
|
319
319
|
) -> napi::Result<RenderResult> {
|
|
@@ -393,7 +393,7 @@ fn apply_append(pdf: Vec<u8>, extras: &[Buffer]) -> napi::Result<Vec<u8>> {
|
|
|
393
393
|
|
|
394
394
|
/// The image source for layout/emit: the caller's resolver when it carries
|
|
395
395
|
/// images, else the zero-image [`NoImages`] so the no-image path is identical.
|
|
396
|
-
fn image_source(resolver: &MapResolver) -> &dyn
|
|
396
|
+
fn image_source(resolver: &MapResolver) -> &dyn turbo_html2pdf_core::ImageResolver {
|
|
397
397
|
if resolver.is_empty() {
|
|
398
398
|
&NoImages
|
|
399
399
|
} else {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|