@veripublica/epubveri-wasm 0.4.4 → 0.5.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 +19 -12
- package/epubveri.d.ts +48 -36
- package/epubveri_bg.js +5 -2
- package/epubveri_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,12 +26,16 @@ import { validate, version } from "@veripublica/epubveri-wasm";
|
|
|
26
26
|
const bytes = new Uint8Array(await file.arrayBuffer()); // a File / fetched .epub
|
|
27
27
|
const report = validate(bytes, undefined); // second arg: profile or undefined
|
|
28
28
|
|
|
29
|
-
console.log(report.
|
|
30
|
-
for (const
|
|
31
|
-
console.log(`${
|
|
29
|
+
console.log(report.status, report.summary); // "ok" | "problems", { errors, warnings }
|
|
30
|
+
for (const it of report.items) {
|
|
31
|
+
console.log(`${it.severity} ${it.code}: ${it.message}`, it.location ?? "");
|
|
32
32
|
}
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
`report` is the veripublica machine envelope's `inputs[i]` shape — the *same*
|
|
36
|
+
object the CLI's `--format json` emits per input (minus `path`), so one parser
|
|
37
|
+
reads CLI, CI and browser output alike.
|
|
38
|
+
|
|
35
39
|
Using it **directly in a browser without a bundler**? Build the `web` target
|
|
36
40
|
instead (`wasm-pack build . --target web`), which exposes an async `init()` you
|
|
37
41
|
`await` once before calling `validate()` — that's what the demo below uses.
|
|
@@ -40,16 +44,19 @@ instead (`wasm-pack build . --target web`), which exposes an async `init()` you
|
|
|
40
44
|
|
|
41
45
|
```ts
|
|
42
46
|
interface Report {
|
|
43
|
-
|
|
44
|
-
errors: number;
|
|
45
|
-
|
|
46
|
-
messages: Message[];
|
|
47
|
+
status: string; // "ok" (valid) | "problems" (error/fatal findings remain)
|
|
48
|
+
summary: { fatals?: number; errors: number; warnings: number };
|
|
49
|
+
items: Item[];
|
|
47
50
|
}
|
|
48
|
-
interface
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
interface Item {
|
|
52
|
+
type: string; // "finding"
|
|
53
|
+
code: string; // epubcheck-compatible, e.g. "RSC-005"
|
|
54
|
+
rule?: string; // epubveri's finer sub-code, when present
|
|
55
|
+
severity: string; // "fatal" | "error" | "warning" | "info" | "usage"
|
|
56
|
+
location?: string; // container-relative path, when available
|
|
57
|
+
position?: { line: number; column: number };
|
|
58
|
+
message: string; // epubveri's own message wording
|
|
59
|
+
data?: { params: string[] };
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
function validate(bytes: Uint8Array, profile?: string | null): Report;
|
package/epubveri.d.ts
CHANGED
|
@@ -9,69 +9,79 @@ export interface Position {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* One
|
|
13
|
-
*
|
|
12
|
+
* One EPUB\'s validation result — the envelope\'s `inputs[i]` object without
|
|
13
|
+
* `path`/`error` (a wasm caller has no path, and in-memory bytes are always
|
|
14
|
+
* readable, so there is no unprocessable/`\"error\"` case here).
|
|
14
15
|
*/
|
|
15
|
-
export interface
|
|
16
|
+
export interface Report {
|
|
17
|
+
/**
|
|
18
|
+
* `\"ok\"` (valid) or `\"problems\"` (error/fatal findings remain). The
|
|
19
|
+
* warning/info/usage-only case is `\"ok\"` — those never fail a book.
|
|
20
|
+
*/
|
|
21
|
+
status: string;
|
|
22
|
+
summary: Summary;
|
|
23
|
+
items: Item[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* One finding, in the shared item shape (FORMATS.md §1.3).
|
|
28
|
+
*/
|
|
29
|
+
export interface Item {
|
|
30
|
+
/**
|
|
31
|
+
* Always `\"finding\"` for a verifier.
|
|
32
|
+
*/
|
|
33
|
+
type: string;
|
|
16
34
|
/**
|
|
17
35
|
* epubcheck-compatible message ID, e.g. `\"RSC-005\"`.
|
|
18
36
|
*/
|
|
19
|
-
|
|
37
|
+
code: string;
|
|
20
38
|
/**
|
|
21
|
-
*
|
|
39
|
+
* epubveri\'s finer semantic sub-code, when the site carries one.
|
|
22
40
|
*/
|
|
23
|
-
|
|
41
|
+
rule: string | undefined;
|
|
24
42
|
/**
|
|
25
|
-
*
|
|
43
|
+
* Lowercase severity: `\"fatal\" | \"error\" | \"warning\" | \"info\" | \"usage\"`.
|
|
26
44
|
*/
|
|
27
|
-
|
|
45
|
+
severity: string;
|
|
28
46
|
/**
|
|
29
|
-
*
|
|
47
|
+
* Container-relative path the finding concerns, when known.
|
|
30
48
|
*/
|
|
31
49
|
location: string | undefined;
|
|
32
50
|
/**
|
|
33
|
-
*
|
|
51
|
+
* Exact source position, when known.
|
|
34
52
|
*/
|
|
35
53
|
position: Position | undefined;
|
|
36
54
|
/**
|
|
37
|
-
* epubveri\'s own
|
|
38
|
-
* of a shared `id` (e.g. `\"opf.spine.duplicate_itemref\"`), when the
|
|
39
|
-
* check has been retrofitted for it (incremental rollout, see
|
|
40
|
-
* epubveri issue #2). `None` otherwise.
|
|
55
|
+
* Human-readable message text (epubveri\'s own wording).
|
|
41
56
|
*/
|
|
42
|
-
|
|
57
|
+
message: string;
|
|
43
58
|
/**
|
|
44
|
-
*
|
|
45
|
-
* present. Empty otherwise.
|
|
59
|
+
* Tool-specific extras — carries the message\'s interpolation `params`.
|
|
46
60
|
*/
|
|
47
|
-
|
|
61
|
+
data: Data | undefined;
|
|
48
62
|
}
|
|
49
63
|
|
|
50
64
|
/**
|
|
51
|
-
*
|
|
65
|
+
* Small aggregate counts, mirroring the envelope\'s per-input `summary`
|
|
66
|
+
* (`fatals` omitted when zero, exactly as the CLI envelope emits it).
|
|
52
67
|
*/
|
|
53
|
-
export interface
|
|
54
|
-
|
|
55
|
-
* `true` when there are zero `ERROR`-severity messages (warnings are allowed).
|
|
56
|
-
*/
|
|
57
|
-
valid: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Count of `ERROR`-severity messages.
|
|
60
|
-
*/
|
|
68
|
+
export interface Summary {
|
|
69
|
+
fatals: number;
|
|
61
70
|
errors: number;
|
|
62
|
-
/**
|
|
63
|
-
* Count of `WARNING`-severity messages.
|
|
64
|
-
*/
|
|
65
71
|
warnings: number;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Tool-specific item extras.
|
|
76
|
+
*/
|
|
77
|
+
export interface Data {
|
|
78
|
+
params: string[];
|
|
70
79
|
}
|
|
71
80
|
|
|
72
81
|
|
|
73
82
|
/**
|
|
74
|
-
* Validate raw EPUB bytes and return
|
|
83
|
+
* Validate raw EPUB bytes and return the typed [`Report`] (an envelope
|
|
84
|
+
* `inputs[i]` object).
|
|
75
85
|
*
|
|
76
86
|
* `profile` mirrors the CLI `--profile` flag — pass `"dict"`, `"edupub"`,
|
|
77
87
|
* `"idx"`, `"preview"`, or `undefined`/`null` for default behavior. Unknown
|
|
@@ -84,6 +94,8 @@ export interface Report {
|
|
|
84
94
|
export function validate(bytes: Uint8Array, profile?: string | null): Report;
|
|
85
95
|
|
|
86
96
|
/**
|
|
87
|
-
* The `epubveri
|
|
97
|
+
* The validator version — [`epubveri::VERSION`], the one string the CLI's
|
|
98
|
+
* `-V` and the demo footer also print, with git build metadata
|
|
99
|
+
* (`+<short-hash>[.dirty]`) when built from a checkout.
|
|
88
100
|
*/
|
|
89
101
|
export function version(): string;
|
package/epubveri_bg.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Validate raw EPUB bytes and return
|
|
2
|
+
* Validate raw EPUB bytes and return the typed [`Report`] (an envelope
|
|
3
|
+
* `inputs[i]` object).
|
|
3
4
|
*
|
|
4
5
|
* `profile` mirrors the CLI `--profile` flag — pass `"dict"`, `"edupub"`,
|
|
5
6
|
* `"idx"`, `"preview"`, or `undefined`/`null` for default behavior. Unknown
|
|
@@ -22,7 +23,9 @@ export function validate(bytes, profile) {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
|
-
* The `epubveri
|
|
26
|
+
* The validator version — [`epubveri::VERSION`], the one string the CLI's
|
|
27
|
+
* `-V` and the demo footer also print, with git build metadata
|
|
28
|
+
* (`+<short-hash>[.dirty]`) when built from a checkout.
|
|
26
29
|
* @returns {string}
|
|
27
30
|
*/
|
|
28
31
|
export function version() {
|
package/epubveri_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@veripublica/epubveri-wasm",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "WebAssembly bindings for epubveri — a pure-Rust, JVM-free EPUB validator that runs in the browser.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.5.0",
|
|
6
6
|
"license": "AGPL-3.0-only OR LicenseRef-veripublica-Commercial",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|