@veripublica/kepubverto-wasm 0.1.1 → 0.2.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/README.md +8 -2
- package/kepubverto_wasm.d.ts +15 -2
- package/kepubverto_wasm_bg.js +13 -3
- package/kepubverto_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,12 +23,18 @@ await init();
|
|
|
23
23
|
const r = convert(new Uint8Array(await file.arrayBuffer()));
|
|
24
24
|
// r.epub: Uint8Array, the converted book → save as <name>.kepub.epub
|
|
25
25
|
// r.complete: every content document was converted
|
|
26
|
-
// r.documents: [{ path, outcome, spans, reason? }]
|
|
26
|
+
// r.documents: [{ path, outcome, spans, reason?, code?, severity? }]
|
|
27
27
|
// outcome: "converted" | "already_converted" | "nothing_to_do" | "left_alone"
|
|
28
28
|
// reason: why a document was left as it was, for a person to read
|
|
29
|
+
// code, severity: for a document left as it was, the code and severity
|
|
30
|
+
// the CLI's --format json gives it ("RSC-016" / "fatal", …)
|
|
31
|
+
|
|
32
|
+
// The CLI's --hyphens: "auto" turns hyphenation on, "none" off.
|
|
33
|
+
convert(bytes, "auto");
|
|
29
34
|
```
|
|
30
35
|
|
|
31
|
-
`convert` throws when the file cannot be read as an EPUB at all
|
|
36
|
+
`convert` throws when the file cannot be read as an EPUB at all, and on a
|
|
37
|
+
`hyphens` value other than `"auto"` or `"none"`.
|
|
32
38
|
|
|
33
39
|
## License
|
|
34
40
|
|
package/kepubverto_wasm.d.ts
CHANGED
|
@@ -17,6 +17,16 @@ export interface Document {
|
|
|
17
17
|
* Why a document was left alone, for a person to read.
|
|
18
18
|
*/
|
|
19
19
|
reason?: string;
|
|
20
|
+
/**
|
|
21
|
+
* For a document left alone: the code the CLI\'s `--format json` gives
|
|
22
|
+
* it (`\"RSC-016\"`, `\"KEPUB-003\"`, …), epubcheck\'s where it has one.
|
|
23
|
+
*/
|
|
24
|
+
code?: string;
|
|
25
|
+
/**
|
|
26
|
+
* For a document left alone: that code\'s severity, `\"fatal\"` or
|
|
27
|
+
* `\"error\"`.
|
|
28
|
+
*/
|
|
29
|
+
severity?: string;
|
|
20
30
|
}
|
|
21
31
|
|
|
22
32
|
export interface Conversion {
|
|
@@ -30,9 +40,12 @@ export interface Conversion {
|
|
|
30
40
|
|
|
31
41
|
|
|
32
42
|
/**
|
|
33
|
-
* Convert an EPUB.
|
|
43
|
+
* Convert an EPUB. `hyphens` mirrors the CLI's `--hyphens`: `"auto"` or
|
|
44
|
+
* `"none"` adds CSS that turns hyphenation on or off; leave it out to let the
|
|
45
|
+
* book decide. Throws on any other value, and when the book cannot be read
|
|
46
|
+
* at all.
|
|
34
47
|
*/
|
|
35
|
-
export function convert(epub: Uint8Array): Conversion;
|
|
48
|
+
export function convert(epub: Uint8Array, hyphens?: string | null): Conversion;
|
|
36
49
|
|
|
37
50
|
/**
|
|
38
51
|
* The crate version, with the git hash it was built from.
|
package/kepubverto_wasm_bg.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Convert an EPUB.
|
|
2
|
+
* Convert an EPUB. `hyphens` mirrors the CLI's `--hyphens`: `"auto"` or
|
|
3
|
+
* `"none"` adds CSS that turns hyphenation on or off; leave it out to let the
|
|
4
|
+
* book decide. Throws on any other value, and when the book cannot be read
|
|
5
|
+
* at all.
|
|
3
6
|
* @param {Uint8Array} epub
|
|
7
|
+
* @param {string | null} [hyphens]
|
|
4
8
|
* @returns {Conversion}
|
|
5
9
|
*/
|
|
6
|
-
export function convert(epub) {
|
|
10
|
+
export function convert(epub, hyphens) {
|
|
7
11
|
const ptr0 = passArray8ToWasm0(epub, wasm.__wbindgen_malloc);
|
|
8
12
|
const len0 = WASM_VECTOR_LEN;
|
|
9
|
-
|
|
13
|
+
var ptr1 = isLikeNone(hyphens) ? 0 : passStringToWasm0(hyphens, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
14
|
+
var len1 = WASM_VECTOR_LEN;
|
|
15
|
+
const ret = wasm.convert(ptr0, len0, ptr1, len1);
|
|
10
16
|
if (ret[2]) {
|
|
11
17
|
throw takeFromExternrefTable0(ret[1]);
|
|
12
18
|
}
|
|
@@ -119,6 +125,10 @@ function getUint8ArrayMemory0() {
|
|
|
119
125
|
return cachedUint8ArrayMemory0;
|
|
120
126
|
}
|
|
121
127
|
|
|
128
|
+
function isLikeNone(x) {
|
|
129
|
+
return x === undefined || x === null;
|
|
130
|
+
}
|
|
131
|
+
|
|
122
132
|
function passArray8ToWasm0(arg, malloc) {
|
|
123
133
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
124
134
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
package/kepubverto_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@veripublica/kepubverto-wasm",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "WebAssembly bindings for kepubverto — convert EPUB to KEPUB in the browser, no upload.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.2.0",
|
|
6
6
|
"license": "AGPL-3.0-only OR LicenseRef-veripublica-Commercial",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|