blitz-pdf 0.1.4 → 0.1.6
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 +67 -3
- package/THIRD_PARTY_NOTICES.md +2 -0
- package/dist/api.d.ts +9 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +25 -27
- package/dist/api.js.map +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +13 -1
- package/dist/browser.js.map +1 -1
- package/dist/node-worker.d.ts +2 -0
- package/dist/node-worker.d.ts.map +1 -0
- package/dist/node-worker.js +10 -0
- package/dist/node-worker.js.map +1 -0
- package/dist/node.d.ts +1 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +18 -6
- package/dist/node.js.map +1 -1
- package/dist/render.d.ts +8 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +28 -0
- package/dist/render.js.map +1 -0
- package/dist/wasm.d.ts +3 -0
- package/dist/wasm.d.ts.map +1 -0
- package/dist/wasm.js +18 -0
- package/dist/wasm.js.map +1 -0
- package/dist/worker-host.d.ts +16 -0
- package/dist/worker-host.d.ts.map +1 -0
- package/dist/worker-host.js +31 -0
- package/dist/worker-host.js.map +1 -0
- package/dist/worker-protocol.d.ts +22 -0
- package/dist/worker-protocol.d.ts.map +1 -0
- package/dist/worker-protocol.js +2 -0
- package/dist/worker-protocol.js.map +1 -0
- package/dist/worker-runtime.d.ts +8 -0
- package/dist/worker-runtime.d.ts.map +1 -0
- package/dist/worker-runtime.js +34 -0
- package/dist/worker-runtime.js.map +1 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +7 -0
- package/dist/worker.js.map +1 -0
- package/package.json +5 -2
- package/src/api.ts +33 -22
- package/src/browser.ts +13 -3
- package/src/node-worker.ts +9 -0
- package/src/node.ts +13 -4
- package/src/render.ts +28 -0
- package/src/wasm.ts +17 -0
- package/src/worker-host.ts +45 -0
- package/src/worker-protocol.ts +10 -0
- package/src/worker-runtime.ts +35 -0
- package/src/worker.ts +12 -0
- package/vendor/README.md +24 -0
- package/vendor/blitz-paint/Cargo.toml +50 -0
- package/vendor/blitz-paint/LICENSE-APACHE +176 -0
- package/vendor/blitz-paint/LICENSE-MIT +23 -0
- package/vendor/blitz-paint/src/color.rs +66 -0
- package/vendor/blitz-paint/src/debug_overlay.rs +168 -0
- package/vendor/blitz-paint/src/filters.rs +40 -0
- package/vendor/blitz-paint/src/gradient.rs +536 -0
- package/vendor/blitz-paint/src/kurbo_css/css_box.rs +847 -0
- package/vendor/blitz-paint/src/kurbo_css/mod.rs +77 -0
- package/vendor/blitz-paint/src/kurbo_css/non_uniform_radii.rs +60 -0
- package/vendor/blitz-paint/src/layers.rs +95 -0
- package/vendor/blitz-paint/src/lib.rs +190 -0
- package/vendor/blitz-paint/src/render/background.rs +968 -0
- package/vendor/blitz-paint/src/render/border.rs +631 -0
- package/vendor/blitz-paint/src/render/box_shadow.rs +157 -0
- package/vendor/blitz-paint/src/render/clip_path.rs +492 -0
- package/vendor/blitz-paint/src/render/form_controls.rs +103 -0
- package/vendor/blitz-paint/src/render/mask.rs +144 -0
- package/vendor/blitz-paint/src/render.rs +1351 -0
- package/vendor/blitz-paint/src/sizing.rs +63 -0
- package/vendor/blitz-paint/src/text.rs +747 -0
- package/wasm/blitz_pdf_bg.wasm +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
use style::properties::generated::longhands::object_fit::computed_value::T as ObjectFit;
|
|
2
|
+
|
|
3
|
+
pub(crate) fn compute_object_fit(
|
|
4
|
+
container_size: taffy::Size<f32>,
|
|
5
|
+
object_size: Option<taffy::Size<f32>>,
|
|
6
|
+
object_fit: ObjectFit,
|
|
7
|
+
) -> taffy::Size<f32> {
|
|
8
|
+
match object_fit {
|
|
9
|
+
ObjectFit::None => object_size.unwrap_or(container_size),
|
|
10
|
+
ObjectFit::Fill => container_size,
|
|
11
|
+
ObjectFit::Cover => compute_object_fit_cover(container_size, object_size),
|
|
12
|
+
ObjectFit::Contain => compute_object_fit_contain(container_size, object_size),
|
|
13
|
+
ObjectFit::ScaleDown => {
|
|
14
|
+
let contain_size = compute_object_fit_contain(container_size, object_size);
|
|
15
|
+
match object_size {
|
|
16
|
+
Some(object_size) if object_size.width < contain_size.width => object_size,
|
|
17
|
+
_ => contain_size,
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
fn compute_object_fit_contain(
|
|
24
|
+
container_size: taffy::Size<f32>,
|
|
25
|
+
object_size: Option<taffy::Size<f32>>,
|
|
26
|
+
) -> taffy::Size<f32> {
|
|
27
|
+
let Some(object_size) = object_size else {
|
|
28
|
+
return container_size;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
let x_ratio = container_size.width / object_size.width;
|
|
32
|
+
let y_ratio = container_size.height / object_size.height;
|
|
33
|
+
|
|
34
|
+
let ratio = match (x_ratio < 1.0, y_ratio < 1.0) {
|
|
35
|
+
(true, true) => x_ratio.min(y_ratio),
|
|
36
|
+
(true, false) => x_ratio,
|
|
37
|
+
(false, true) => y_ratio,
|
|
38
|
+
(false, false) => x_ratio.min(y_ratio),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
object_size.map(|dim| dim * ratio)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
fn compute_object_fit_cover(
|
|
45
|
+
container_size: taffy::Size<f32>,
|
|
46
|
+
object_size: Option<taffy::Size<f32>>,
|
|
47
|
+
) -> taffy::Size<f32> {
|
|
48
|
+
let Some(object_size) = object_size else {
|
|
49
|
+
return container_size;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
let x_ratio = container_size.width / object_size.width;
|
|
53
|
+
let y_ratio = container_size.height / object_size.height;
|
|
54
|
+
|
|
55
|
+
let ratio = match (x_ratio < 1.0, y_ratio < 1.0) {
|
|
56
|
+
(true, true) => x_ratio.max(y_ratio),
|
|
57
|
+
(true, false) => y_ratio,
|
|
58
|
+
(false, true) => x_ratio,
|
|
59
|
+
(false, false) => x_ratio.max(y_ratio),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
object_size.map(|dim| dim * ratio)
|
|
63
|
+
}
|