@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 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.valid, report.errors, report.warnings);
30
- for (const m of report.messages) {
31
- console.log(`${m.severity} ${m.id}: ${m.text}`, m.location ?? "");
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
- valid: boolean; // true when there are zero ERROR-severity messages
44
- errors: number;
45
- warnings: number;
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 Message {
49
- id: string; // epubcheck-compatible, e.g. "RSC-005"
50
- severity: string; // "ERROR" | "WARNING" | "INFO"
51
- text: string; // epubveri's own message wording
52
- location?: string; // path/element hint, when available
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 diagnostic, mirroring [`epubveri::report::Message`] with the message ID
13
- * and severity flattened to strings for the JS boundary.
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 Message {
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
- id: string;
37
+ code: string;
20
38
  /**
21
- * `\"ERROR\"`, `\"WARNING\"`, or `\"INFO\"`.
39
+ * epubveri\'s finer semantic sub-code, when the site carries one.
22
40
  */
23
- severity: string;
41
+ rule: string | undefined;
24
42
  /**
25
- * Human-readable message text (epubveri\'s own wording).
43
+ * Lowercase severity: `\"fatal\" | \"error\" | \"warning\" | \"info\" | \"usage\"`.
26
44
  */
27
- text: string;
45
+ severity: string;
28
46
  /**
29
- * Optional location hint (path / element), when the check provides one.
47
+ * Container-relative path the finding concerns, when known.
30
48
  */
31
49
  location: string | undefined;
32
50
  /**
33
- * Optional exact source position, when the check provides one.
51
+ * Exact source position, when known.
34
52
  */
35
53
  position: Position | undefined;
36
54
  /**
37
- * epubveri\'s own stable, semantic sub-code distinguishing sub-cases
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
- rule: string | undefined;
57
+ message: string;
43
58
  /**
44
- * The positional values interpolated into `text`, when `rule` is
45
- * present. Empty otherwise.
59
+ * Tool-specific extras carries the message\'s interpolation `params`.
46
60
  */
47
- params: string[];
61
+ data: Data | undefined;
48
62
  }
49
63
 
50
64
  /**
51
- * The full validation result for one EPUB.
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 Report {
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
- * Every diagnostic, in the order the validator produced them.
68
- */
69
- messages: Message[];
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 a typed [`Report`].
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-wasm` crate version (matches this crate's `Cargo.toml`).
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 a typed [`Report`].
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-wasm` crate version (matches this crate's `Cargo.toml`).
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.4.4",
5
+ "version": "0.5.0",
6
6
  "license": "AGPL-3.0-only OR LicenseRef-veripublica-Commercial",
7
7
  "repository": {
8
8
  "type": "git",