@qrcommunication/gigapdf-lib 0.40.0 → 0.42.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/CHANGELOG.md +53 -0
- package/dist/index.cjs +31 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -6
- package/dist/index.d.ts +17 -6
- package/dist/index.js +31 -5
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @qrcommunication/gigapdf-lib — TypeScript SDK for the
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* @qrcommunication/gigapdf-lib — TypeScript SDK for the gigapdf-lib Rust→WASM PDF
|
|
3
|
+
* engine: no third-party PDF/Office/image library (cryptography uses RustCrypto,
|
|
4
|
+
* JavaScript uses Boa). Wraps the flat `extern "C"` `gp_*` ABI behind a typed,
|
|
5
|
+
* ergonomic class. No third-party npm deps; the `.wasm` imports a single host
|
|
6
|
+
* function — `env.gp_host_random` (entropy), which `load()` supplies.
|
|
5
7
|
*
|
|
6
8
|
* Usage:
|
|
7
9
|
* const giga = await GigaPdfEngine.load(wasmBytesOrUrl);
|
|
@@ -135,13 +137,22 @@ declare class GigaPdfEngine {
|
|
|
135
137
|
*/
|
|
136
138
|
encodeWebp(rgba: Uint8Array, width: number, height: number): Uint8Array;
|
|
137
139
|
/**
|
|
138
|
-
* Decode a
|
|
139
|
-
*
|
|
140
|
+
* Decode a WebP to `{ width, height, rgba }`, or `null`. Handles both
|
|
141
|
+
* **lossless** (VP8L) and **lossy** (VP8 keyframe) WebP with the engine's
|
|
142
|
+
* native decoder — no third-party image library. Extended/animated WebP
|
|
143
|
+
* (`VP8X`) is not handled (returns `null`).
|
|
140
144
|
*/
|
|
141
145
|
decodeWebp(webp: Uint8Array): DecodedImage | null;
|
|
142
146
|
/**
|
|
143
147
|
* Decode a still **AVIF** (AV1 intra) to `{ width, height, rgba }`, or `null`.
|
|
144
|
-
*
|
|
148
|
+
* Pure-Rust AV1 decoder — no third-party library. Supports lossy + lossless
|
|
149
|
+
* transforms, in-loop deblocking (AV1 §7.14) and CDEF (§7.15, including the
|
|
150
|
+
* multi-strength `cdef_bits > 0` path), screen-content **palette** mode
|
|
151
|
+
* (§5.11.46-50), and both `reduced_still_picture_header` and the full
|
|
152
|
+
* streaming sequence/frame headers — all validated bit-exact against dav1d.
|
|
153
|
+
* Not yet covered: animated AVIF, film grain, loop restoration (§7.17), the
|
|
154
|
+
* fully bit-exact directional top-right/bottom-left intra edge, and the
|
|
155
|
+
* lossless WHT path at very-high quality (`q ≤ 20`).
|
|
145
156
|
*/
|
|
146
157
|
decodeAvif(avif: Uint8Array): DecodedImage | null;
|
|
147
158
|
/** Unpack a `[w:u32 LE][h:u32 LE][rgba]` decode buffer; `null` if empty. */
|
package/dist/index.js
CHANGED
|
@@ -19,11 +19,28 @@ var GigaPdfEngine = class _GigaPdfEngine {
|
|
|
19
19
|
} else {
|
|
20
20
|
bytes = source;
|
|
21
21
|
}
|
|
22
|
+
let ex;
|
|
22
23
|
const { instance } = await WebAssembly.instantiate(
|
|
23
24
|
bytes instanceof Uint8Array ? bytes.slice().buffer : bytes,
|
|
24
|
-
{
|
|
25
|
+
{
|
|
26
|
+
env: {
|
|
27
|
+
gp_host_random: (ptr, len) => {
|
|
28
|
+
const c = globalThis.crypto;
|
|
29
|
+
if (!c?.getRandomValues) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
"gigapdf: wasm entropy needs Web Crypto (globalThis.crypto.getRandomValues)"
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
const mem = new Uint8Array(ex.memory.buffer, ptr, len);
|
|
35
|
+
for (let off = 0; off < len; off += 65536) {
|
|
36
|
+
c.getRandomValues(mem.subarray(off, Math.min(off + 65536, len)));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
25
41
|
);
|
|
26
|
-
|
|
42
|
+
ex = instance.exports;
|
|
43
|
+
return new _GigaPdfEngine(ex);
|
|
27
44
|
}
|
|
28
45
|
/**
|
|
29
46
|
* Convenience loader for Node: instantiate from the `gigapdf.wasm` shipped
|
|
@@ -305,15 +322,24 @@ var GigaPdfEngine = class _GigaPdfEngine {
|
|
|
305
322
|
);
|
|
306
323
|
}
|
|
307
324
|
/**
|
|
308
|
-
* Decode a
|
|
309
|
-
*
|
|
325
|
+
* Decode a WebP to `{ width, height, rgba }`, or `null`. Handles both
|
|
326
|
+
* **lossless** (VP8L) and **lossy** (VP8 keyframe) WebP with the engine's
|
|
327
|
+
* native decoder — no third-party image library. Extended/animated WebP
|
|
328
|
+
* (`VP8X`) is not handled (returns `null`).
|
|
310
329
|
*/
|
|
311
330
|
decodeWebp(webp) {
|
|
312
331
|
return this._decodeFramed(webp, (p, l, o) => this.ex.gp_decode_webp(p, l, o));
|
|
313
332
|
}
|
|
314
333
|
/**
|
|
315
334
|
* Decode a still **AVIF** (AV1 intra) to `{ width, height, rgba }`, or `null`.
|
|
316
|
-
*
|
|
335
|
+
* Pure-Rust AV1 decoder — no third-party library. Supports lossy + lossless
|
|
336
|
+
* transforms, in-loop deblocking (AV1 §7.14) and CDEF (§7.15, including the
|
|
337
|
+
* multi-strength `cdef_bits > 0` path), screen-content **palette** mode
|
|
338
|
+
* (§5.11.46-50), and both `reduced_still_picture_header` and the full
|
|
339
|
+
* streaming sequence/frame headers — all validated bit-exact against dav1d.
|
|
340
|
+
* Not yet covered: animated AVIF, film grain, loop restoration (§7.17), the
|
|
341
|
+
* fully bit-exact directional top-right/bottom-left intra edge, and the
|
|
342
|
+
* lossless WHT path at very-high quality (`q ≤ 20`).
|
|
317
343
|
*/
|
|
318
344
|
decodeAvif(avif) {
|
|
319
345
|
return this._decodeFramed(avif, (p, l, o) => this.ex.gp_decode_avif(p, l, o));
|