@otisk/preview 1.1.0 → 1.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/README.md CHANGED
@@ -1,96 +1,109 @@
1
- # `engine-wasm` — WASM bindings for otisk
2
-
3
- Thin `wasm-bindgen` wrapper around `otisk::Engine`. Exposes a single
4
- JS-callable entry point so browser (and other `wasm32-unknown-unknown`)
5
- hosts can drive the otisk pipeline:
6
-
7
- ```rust
8
- // Issue 30 baseline + Issue 115 widening: an **optional** 4th argument
9
- // crosses a JS-side `AssetResolver` into the engine. The 3-arg call
10
- // `render_pdf(html, css, margin)` remains byte-identical to the
11
- // Issue 31 parity baseline; passing `null` / `undefined` for the 4th
12
- // arg is equivalent. When present, `assets` must be either a bare
13
- // `function(url): Uint8Array` callable or an object with a synchronous
14
- // `fetch(url): Uint8Array` method — every engine-side `@font-face`,
15
- // `<img>`, `background-image`, `@color-profile` lookup is funneled
16
- // through it.
17
- #[wasm_bindgen]
18
- pub fn render_pdf(
19
- html: &str,
20
- css: &str,
21
- margin_mm: f32,
22
- assets: Option<JsValue>, // bindgen-side: omittable in JS
23
- ) -> Result<Vec<u8>, JsValue>;
1
+ # @otisk/preview
2
+
3
+ Raster **print-preview** for the [otisk](https://www.npmjs.com/org/otisk)
4
+ typesetting engine, compiled to WebAssembly. Render HTML/CSS pages to RGBA
5
+ bitmaps in the browser (or Bun/Node) and paint them onto an HTML5 canvas —
6
+ the preview shares the **same layout engine** as otisk's PDF output, so what
7
+ you see on screen matches the print geometry pixel-for-pixel; only the
8
+ rasteriser differs (tiny-skia here, the press RIP for the PDF).
9
+
10
+ This package is **preview-only**: it renders pages to bitmaps for on-screen
11
+ display. It does not generate PDFs produce the final PDF/X-4 on your
12
+ backend with the otisk engine, from the same `(html, css)` you previewed.
13
+
14
+ ```
15
+ npm i @otisk/preview
24
16
  ```
25
17
 
26
- JS call sites:
18
+ ## Quick start — paint a page to a canvas
27
19
 
28
20
  ```js
29
- // 3-arg legacy form unchanged, empty resolver.
30
- const pdf = render_pdf(html, css, 10);
31
-
32
- // 4-arg widened form — supply a resolver. `null` / `undefined` are
33
- // equivalent to omitting the arg.
34
- const pdf = render_pdf(html, css, 10, {
35
- fetch(url) { /* return Uint8Array */ }
36
- });
37
- ```
21
+ import init, { render_page_rgba } from "@otisk/preview";
22
+
23
+ await init(); // load the wasm module (once)
38
24
 
39
- See `src/lib.rs` and the issue specs at
40
- `.plans/pdfx4-engine/issues/30-wasm-bindings-crate.md` (baseline) and
41
- `.plans/pdfx4-engine/issues/115-wasm-asset-resolver-crossing.md`
42
- (resolver crossing) for the full rationale.
25
+ const html = "<h1>Náhled sazby</h1><p>Příliš žluťoučký kůň…</p>";
26
+ const css = "@page { size: A6 } body { font-family: serif }";
43
27
 
44
- ## Build (browser bundle)
28
+ const dpi = 96;
29
+ const page = render_page_rgba(html, css, /*marginMm*/ 0, null, null, /*pageIndex*/ 0, dpi / 72);
45
30
 
46
- ```sh
47
- wasm-pack build crates/engine-wasm --target web --out-dir ../../examples/web-ui/pkg --release
31
+ const canvas = document.querySelector("canvas");
32
+ canvas.width = page.width;
33
+ canvas.height = page.height;
34
+ canvas
35
+ .getContext("2d")
36
+ .putImageData(new ImageData(new Uint8ClampedArray(page.rgba), page.width, page.height), 0, 0);
48
37
  ```
49
38
 
50
- This produces `examples/web-ui/pkg/engine_wasm_bg.wasm` plus the
51
- `engine_wasm.js` glue module. Serve the demo UI with any static server:
39
+ `rgba` is straight (non-premultiplied) RGBA8, row-major, top-down — exactly
40
+ the layout `ImageData` / `createImageBitmap` expect, so there's no per-pixel
41
+ rework.
52
42
 
53
- ```sh
54
- python3 -m http.server 4173 --directory examples/web-ui
55
- ```
43
+ ## Recommended — render off the main thread
56
44
 
57
- The `pkg/` output directory is git-ignored.
45
+ Rasterising a page will jank the UI thread. For a live preview (re-rendering
46
+ on every edit), run the wasm in a **Web Worker** that owns an
47
+ `OffscreenCanvas`, so pixels never cross back to the main thread. A complete,
48
+ copy-paste consumer — worker + a `PreviewClient` with latest-wins coalescing —
49
+ lives in the repo at
50
+ [`examples/preview-canvas/`](https://github.com/otisk-engine/otisk/tree/main/examples/preview-canvas).
58
51
 
59
- ## Build (raw `.wasm`, no JS glue)
52
+ ## API
60
53
 
61
- For CI gate parity with the issue specno `wasm-pack` required:
54
+ The default export is the wasm initialiser`await init()` (or
55
+ `init(customWasmUrl)`) once before calling anything else.
62
56
 
63
- ```sh
64
- cargo build -p engine-wasm --target wasm32-unknown-unknown --locked --release
65
- ```
57
+ ### `render_page_rgba(html, css, marginMm, assets?, outputIntent?, pageIndex, scale) → RasterResult`
66
58
 
67
- Artefact at `target/wasm32-unknown-unknown/release/engine_wasm.wasm`.
59
+ Render one page to an RGBA bitmap. `scale` is pixels-per-point (`dpi / 72`);
60
+ `pageIndex` is 0-based. Throws a string error on a layout failure, an
61
+ out-of-range page, or degenerate dimensions.
68
62
 
69
- ## Size budget
63
+ ### `page_count(html, css, marginMm, assets?, outputIntent?) → number`
70
64
 
71
- `SPECIFICATION.md` §4.2: **5 MB compressed** for the full engine. Phase 2
72
- ships the raw bundle without `wasm-opt`; binary-size optimization lands in
73
- Issue 31 / Phase 6. The commit that introduces this crate records the
74
- current unoptimized `.wasm` size as a baseline.
65
+ How many pages the `(html, css)` pair lays out for preview navigation.
75
66
 
76
- ## Host-target build
67
+ ### `RasterResult`
77
68
 
78
- The crate is also exposed as an `rlib` so `cargo build -p engine-wasm`
79
- on the host triple works (useful for `cargo doc`, future host-side
80
- integration tests, and IDE indexing). The `cdylib` artefact only matters
81
- for the `wasm32-unknown-unknown` target.
69
+ | Member | Type | Notes |
70
+ | ---------- | ------------ | -------------------------------------- |
71
+ | `width` | `number` | Device width in pixels. |
72
+ | `height` | `number` | Device height in pixels. |
73
+ | `rgba` | `Uint8Array` | `4 · width · height` bytes, RGBA8. |
82
74
 
83
- ## `parity_export` feature (Issue 31)
75
+ ### Asset resolver (`assets`)
84
76
 
85
- The crate ships a second WASM entry point — a raw C-ABI
86
- `render_pdf_raw` gated behind the `parity_export` feature. The Phase 2
87
- parity harness (`crates/otisk/tests/wasm_parity.rs`) builds the artefact
88
- with `--no-default-features --features parity_export` and drives it
89
- through `wasmtime` without the `wasm-bindgen` JS glue. This surface is
90
- **internal** — the wire format is not a stability contract, and browser
91
- hosts should always use the default `render_pdf`.
77
+ Fonts, images, and color profiles referenced by the CSS/HTML
78
+ (`@font-face`, `<img>`, `background-image`, `@color-profile`) are pulled
79
+ through an optional **synchronous** resolver. Pass `null`/`undefined` to
80
+ disable it, or an object with a `fetch` method (or a bare function):
92
81
 
93
- ```sh
94
- cargo build -p engine-wasm --target wasm32-unknown-unknown \
95
- --no-default-features --features parity_export --release
82
+ ```js
83
+ const assets = {
84
+ fetch(url) {
85
+ return fontBytes.get(url); // must return a Uint8Array, synchronously
86
+ },
87
+ };
88
+ render_page_rgba(html, css, 0, assets, null, 0, dpi / 72);
96
89
  ```
90
+
91
+ ### Output intent (`outputIntent`)
92
+
93
+ Optional color target for the render: `"srgb"` (default), `"fogra39"`, or
94
+ `"swop_v2"`. Pass `null` for sRGB.
95
+
96
+ ## Notes
97
+
98
+ - **Module format.** This is the `--target web` build — native ESM that
99
+ runs in browsers, Bun, and bundlers (Vite/webpack). It is not a CommonJS
100
+ Node build.
101
+ - **Bundle size.** ~4.8 MB gzipped — fetch it lazily / behind a route split
102
+ rather than in your initial bundle.
103
+ - **No OffscreenCanvas?** On engines without `transferControlToOffscreen`
104
+ (older Safari), run `render_page_rgba` on the main thread and
105
+ `putImageData` as in the quick start.
106
+
107
+ ## License
108
+
109
+ Apache-2.0
package/engine_wasm.d.ts CHANGED
@@ -36,7 +36,7 @@ export class RasterResult {
36
36
  *
37
37
  * # Errors
38
38
  *
39
- * Same channel as [`render_pdf`].
39
+ * A stringified [`otisk::RenderError`] via `JsValue::from_str`.
40
40
  */
41
41
  export function page_count(html: string, css: string, margin_mm: number, assets?: any | null, output_intent?: any | null): number;
42
42
 
@@ -44,11 +44,10 @@ export function page_count(html: string, css: string, margin_mm: number, assets?
44
44
  * Issue 297 — render one page of an `(html, css)` pair to an RGBA8
45
45
  * bitmap for an HTML5-canvas print preview.
46
46
  *
47
- * Mirrors [`render_pdf`]'s argument shape (`html`, `css`, `margin_mm`,
48
- * optional `assets`, optional `output_intent`) and adds `page_index`
49
- * (0-based) + `scale` (pixels-per-point, `scale = dpi / 72`). The
50
- * returned [`RasterResult`] carries the device dimensions + the RGBA
51
- * buffer.
47
+ * Takes the same `(html, css, margin_mm, assets?, output_intent?)`
48
+ * inputs the engine's PDF path uses, plus `page_index` (0-based) +
49
+ * `scale` (pixels-per-point, `scale = dpi / 72`). The returned
50
+ * [`RasterResult`] carries the device dimensions + the RGBA buffer.
52
51
  *
53
52
  * Because the preview reuses the **same** layout the PDF path produces,
54
53
  * it is guaranteed to match print geometry; only the rasteriser differs
@@ -56,100 +55,11 @@ export function page_count(html: string, css: string, margin_mm: number, assets?
56
55
  *
57
56
  * # Errors
58
57
  *
59
- * Same channel as [`render_pdf`] (a stringified [`otisk::RenderError`]
60
- * via `JsValue::from_str`), plus an out-of-range `page_index` or
61
- * degenerate device dimensions.
58
+ * A stringified [`otisk::RenderError`] via `JsValue::from_str`, plus an
59
+ * out-of-range `page_index` or degenerate device dimensions.
62
60
  */
63
61
  export function render_page_rgba(html: string, css: string, margin_mm: number, assets: any | null | undefined, output_intent: any | null | undefined, page_index: number, scale: number): RasterResult;
64
62
 
65
- /**
66
- * Render an `(html, css)` pair to a PDF/X-4 byte buffer.
67
- *
68
- * Thin shim over [`otisk::Engine`]: builds an engine with `margin_mm`
69
- * applied uniformly to all four sides (see
70
- * [`otisk::EngineBuilder::with_margins_mm`]), then forwards to
71
- * [`otisk::Engine::render`] and returns [`otisk::RenderResult::bytes`].
72
- *
73
- * ## Optional asset resolver (Issue 115)
74
- *
75
- * The `assets` parameter is **optional**. wasm-bindgen surfaces it as
76
- * a fourth positional argument that the JS caller may omit (older
77
- * 3-arg call sites — `render_pdf(html, css, margin)` — keep working
78
- * unchanged) or pass as `null` / `undefined` for the same behaviour.
79
- * When `assets` is present it must be either:
80
- *
81
- * - a bare callable: `function(url: string): Uint8Array`, or
82
- * - an object with the spec'd shape: `{ fetch(url: string): Uint8Array }`.
83
- *
84
- * Every engine-side asset lookup (`@font-face`, `<img>`,
85
- * `background-image`, and — Phase 4 — `@color-profile`) is funneled
86
- * through that callable. If `assets.fetch` returns a non-`Uint8Array`
87
- * value, throws, or the method doesn't exist, the render fails with
88
- * [`otisk::FetchError`] surfaced through the usual
89
- * `JsValue`-stringified error channel.
90
- *
91
- * ### Why synchronous
92
- *
93
- * The native [`otisk::AssetResolver::fetch`] signature is synchronous
94
- * (`SPECIFICATION.md` §3.7); the engine never spins up an async
95
- * runtime to fetch an asset. Mirroring that on the JS side keeps the
96
- * byte-identity contract trivial — every fetch returns bytes
97
- * immediately, with the same byte-for-byte semantics on both sides.
98
- * A `Promise<Uint8Array>` arm would either (a) require an async
99
- * engine entry point — out of scope for this issue — or (b) demand
100
- * host-side blocking that the browser doesn't permit on the main
101
- * thread. The simpler synchronous arm is the load-bearing acceptance
102
- * criterion (byte-identical parity for `font_face_load`,
103
- * `image_embed`, `background_image`) and an async overload can ride
104
- * on top of it later.
105
- *
106
- * ## Optional output intent (Issue 116)
107
- *
108
- * The `output_intent` parameter is **optional**. wasm-bindgen surfaces it
109
- * as a fifth positional argument that the JS caller may omit (older
110
- * 3-arg / 4-arg call sites keep working unchanged) or pass as `null` /
111
- * `undefined` for the same default behaviour. When `output_intent` is
112
- * present it must be a UTF-8 string naming a known
113
- * [`otisk::ColorProfile`] variant — see [`parse_color_profile`] for the
114
- * accepted spellings (`"srgb"`, `"fogra39"`, `"swop_v2"`,
115
- * case-insensitive). An unknown string surfaces as the usual
116
- * `JsValue`-stringified error so the JS caller can react.
117
- *
118
- * ## Diagnostics
119
- *
120
- * Diagnostics from the render are intentionally dropped on this entry
121
- * point — the spec deliberately keeps the WASM surface minimal
122
- * (Issue 30 §"Out of scope"). A richer entry point returning
123
- * `{ bytes, diagnostics }` is deferred to a future issue once the
124
- * parity harness has a concrete need for it.
125
- *
126
- * # Errors
127
- *
128
- * On any failure inside the pipeline ([`otisk::RenderError`] — HTML/CSS
129
- * parse errors, layout failures, missing fonts, PDF emit errors, or
130
- * resource-limit breaches), any failure inside the JS-side
131
- * resolver, or an unrecognised `output_intent` string, the error is
132
- * stringified via its `Display` impl and returned as a
133
- * `JsValue::from_str`. JS sees a plain string error message; richer
134
- * error objects can land alongside the diagnostic surface later.
135
- *
136
- * # Parameters
137
- *
138
- * - `html`: the input HTML source as a UTF-8 string.
139
- * - `css`: the matching CSS source (currently the only style input — the
140
- * engine has no `<style>` / `<link rel="stylesheet">` extraction yet).
141
- * - `margin_mm`: uniform page margin applied to all four sides.
142
- * - `assets` *(optional)*: a `{ fetch(url): Uint8Array }` object or a
143
- * bare `(url) -> Uint8Array` callable; pass `null` / `undefined` /
144
- * omit entirely for the empty-resolver baseline (byte-identical to
145
- * the pre-Issue-115 3-arg call).
146
- * - `output_intent` *(optional)*: a UTF-8 string naming a known
147
- * [`otisk::ColorProfile`] variant (`"srgb"`, `"fogra39"`,
148
- * `"swop_v2"`); pass `null` / `undefined` / omit entirely to keep
149
- * the engine's default profile ([`ColorProfile::default`] — sRGB).
150
- */
151
- export function render_pdf(html: string, css: string, margin_mm: number, assets?: any | null, output_intent?: any | null): Uint8Array;
152
-
153
63
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
154
64
 
155
65
  export interface InitOutput {
@@ -160,7 +70,6 @@ export interface InitOutput {
160
70
  readonly rasterresult_rgba: (a: number) => [number, number];
161
71
  readonly rasterresult_width: (a: number) => number;
162
72
  readonly render_page_rgba: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number];
163
- readonly render_pdf: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
164
73
  readonly __wbindgen_malloc: (a: number, b: number) => number;
165
74
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
166
75
  readonly __wbindgen_exn_store: (a: number) => void;
package/engine_wasm.js CHANGED
@@ -63,7 +63,7 @@ if (Symbol.dispose) RasterResult.prototype[Symbol.dispose] = RasterResult.protot
63
63
  *
64
64
  * # Errors
65
65
  *
66
- * Same channel as [`render_pdf`].
66
+ * A stringified [`otisk::RenderError`] via `JsValue::from_str`.
67
67
  * @param {string} html
68
68
  * @param {string} css
69
69
  * @param {number} margin_mm
@@ -87,11 +87,10 @@ export function page_count(html, css, margin_mm, assets, output_intent) {
87
87
  * Issue 297 — render one page of an `(html, css)` pair to an RGBA8
88
88
  * bitmap for an HTML5-canvas print preview.
89
89
  *
90
- * Mirrors [`render_pdf`]'s argument shape (`html`, `css`, `margin_mm`,
91
- * optional `assets`, optional `output_intent`) and adds `page_index`
92
- * (0-based) + `scale` (pixels-per-point, `scale = dpi / 72`). The
93
- * returned [`RasterResult`] carries the device dimensions + the RGBA
94
- * buffer.
90
+ * Takes the same `(html, css, margin_mm, assets?, output_intent?)`
91
+ * inputs the engine's PDF path uses, plus `page_index` (0-based) +
92
+ * `scale` (pixels-per-point, `scale = dpi / 72`). The returned
93
+ * [`RasterResult`] carries the device dimensions + the RGBA buffer.
95
94
  *
96
95
  * Because the preview reuses the **same** layout the PDF path produces,
97
96
  * it is guaranteed to match print geometry; only the rasteriser differs
@@ -99,9 +98,8 @@ export function page_count(html, css, margin_mm, assets, output_intent) {
99
98
  *
100
99
  * # Errors
101
100
  *
102
- * Same channel as [`render_pdf`] (a stringified [`otisk::RenderError`]
103
- * via `JsValue::from_str`), plus an out-of-range `page_index` or
104
- * degenerate device dimensions.
101
+ * A stringified [`otisk::RenderError`] via `JsValue::from_str`, plus an
102
+ * out-of-range `page_index` or degenerate device dimensions.
105
103
  * @param {string} html
106
104
  * @param {string} css
107
105
  * @param {number} margin_mm
@@ -122,112 +120,6 @@ export function render_page_rgba(html, css, margin_mm, assets, output_intent, pa
122
120
  }
123
121
  return RasterResult.__wrap(ret[0]);
124
122
  }
125
-
126
- /**
127
- * Render an `(html, css)` pair to a PDF/X-4 byte buffer.
128
- *
129
- * Thin shim over [`otisk::Engine`]: builds an engine with `margin_mm`
130
- * applied uniformly to all four sides (see
131
- * [`otisk::EngineBuilder::with_margins_mm`]), then forwards to
132
- * [`otisk::Engine::render`] and returns [`otisk::RenderResult::bytes`].
133
- *
134
- * ## Optional asset resolver (Issue 115)
135
- *
136
- * The `assets` parameter is **optional**. wasm-bindgen surfaces it as
137
- * a fourth positional argument that the JS caller may omit (older
138
- * 3-arg call sites — `render_pdf(html, css, margin)` — keep working
139
- * unchanged) or pass as `null` / `undefined` for the same behaviour.
140
- * When `assets` is present it must be either:
141
- *
142
- * - a bare callable: `function(url: string): Uint8Array`, or
143
- * - an object with the spec'd shape: `{ fetch(url: string): Uint8Array }`.
144
- *
145
- * Every engine-side asset lookup (`@font-face`, `<img>`,
146
- * `background-image`, and — Phase 4 — `@color-profile`) is funneled
147
- * through that callable. If `assets.fetch` returns a non-`Uint8Array`
148
- * value, throws, or the method doesn't exist, the render fails with
149
- * [`otisk::FetchError`] surfaced through the usual
150
- * `JsValue`-stringified error channel.
151
- *
152
- * ### Why synchronous
153
- *
154
- * The native [`otisk::AssetResolver::fetch`] signature is synchronous
155
- * (`SPECIFICATION.md` §3.7); the engine never spins up an async
156
- * runtime to fetch an asset. Mirroring that on the JS side keeps the
157
- * byte-identity contract trivial — every fetch returns bytes
158
- * immediately, with the same byte-for-byte semantics on both sides.
159
- * A `Promise<Uint8Array>` arm would either (a) require an async
160
- * engine entry point — out of scope for this issue — or (b) demand
161
- * host-side blocking that the browser doesn't permit on the main
162
- * thread. The simpler synchronous arm is the load-bearing acceptance
163
- * criterion (byte-identical parity for `font_face_load`,
164
- * `image_embed`, `background_image`) and an async overload can ride
165
- * on top of it later.
166
- *
167
- * ## Optional output intent (Issue 116)
168
- *
169
- * The `output_intent` parameter is **optional**. wasm-bindgen surfaces it
170
- * as a fifth positional argument that the JS caller may omit (older
171
- * 3-arg / 4-arg call sites keep working unchanged) or pass as `null` /
172
- * `undefined` for the same default behaviour. When `output_intent` is
173
- * present it must be a UTF-8 string naming a known
174
- * [`otisk::ColorProfile`] variant — see [`parse_color_profile`] for the
175
- * accepted spellings (`"srgb"`, `"fogra39"`, `"swop_v2"`,
176
- * case-insensitive). An unknown string surfaces as the usual
177
- * `JsValue`-stringified error so the JS caller can react.
178
- *
179
- * ## Diagnostics
180
- *
181
- * Diagnostics from the render are intentionally dropped on this entry
182
- * point — the spec deliberately keeps the WASM surface minimal
183
- * (Issue 30 §"Out of scope"). A richer entry point returning
184
- * `{ bytes, diagnostics }` is deferred to a future issue once the
185
- * parity harness has a concrete need for it.
186
- *
187
- * # Errors
188
- *
189
- * On any failure inside the pipeline ([`otisk::RenderError`] — HTML/CSS
190
- * parse errors, layout failures, missing fonts, PDF emit errors, or
191
- * resource-limit breaches), any failure inside the JS-side
192
- * resolver, or an unrecognised `output_intent` string, the error is
193
- * stringified via its `Display` impl and returned as a
194
- * `JsValue::from_str`. JS sees a plain string error message; richer
195
- * error objects can land alongside the diagnostic surface later.
196
- *
197
- * # Parameters
198
- *
199
- * - `html`: the input HTML source as a UTF-8 string.
200
- * - `css`: the matching CSS source (currently the only style input — the
201
- * engine has no `<style>` / `<link rel="stylesheet">` extraction yet).
202
- * - `margin_mm`: uniform page margin applied to all four sides.
203
- * - `assets` *(optional)*: a `{ fetch(url): Uint8Array }` object or a
204
- * bare `(url) -> Uint8Array` callable; pass `null` / `undefined` /
205
- * omit entirely for the empty-resolver baseline (byte-identical to
206
- * the pre-Issue-115 3-arg call).
207
- * - `output_intent` *(optional)*: a UTF-8 string naming a known
208
- * [`otisk::ColorProfile`] variant (`"srgb"`, `"fogra39"`,
209
- * `"swop_v2"`); pass `null` / `undefined` / omit entirely to keep
210
- * the engine's default profile ([`ColorProfile::default`] — sRGB).
211
- * @param {string} html
212
- * @param {string} css
213
- * @param {number} margin_mm
214
- * @param {any | null} [assets]
215
- * @param {any | null} [output_intent]
216
- * @returns {Uint8Array}
217
- */
218
- export function render_pdf(html, css, margin_mm, assets, output_intent) {
219
- const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
220
- const len0 = WASM_VECTOR_LEN;
221
- const ptr1 = passStringToWasm0(css, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
222
- const len1 = WASM_VECTOR_LEN;
223
- const ret = wasm.render_pdf(ptr0, len0, ptr1, len1, margin_mm, isLikeNone(assets) ? 0 : addToExternrefTable0(assets), isLikeNone(output_intent) ? 0 : addToExternrefTable0(output_intent));
224
- if (ret[3]) {
225
- throw takeFromExternrefTable0(ret[2]);
226
- }
227
- var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
228
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
229
- return v3;
230
- }
231
123
  function __wbg_get_imports() {
232
124
  const import0 = {
233
125
  __proto__: null,
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@otisk/preview",
3
3
  "type": "module",
4
4
  "description": "Raster print-preview for the otisk typesetting engine: render HTML/CSS pages to RGBA bitmaps (WASM) for an HTML5-canvas preview that matches the PDF print geometry.",
5
- "version": "1.1.0",
5
+ "version": "1.1.2",
6
6
  "license": "Apache-2.0",
7
7
  "files": [
8
8
  "engine_wasm_bg.wasm",