@veripublica/epubveri-wasm 0.9.29 → 0.11.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 +36 -12
- package/epubveri.d.ts +57 -9
- package/epubveri_bg.js +19 -4
- package/epubveri_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ 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.status, report.summary); // "ok" | "problems", {
|
|
29
|
+
console.log(report.status, report.summary); // "ok" | "problems", { error, warning, … }
|
|
30
30
|
for (const it of report.items) {
|
|
31
31
|
console.log(`${it.severity} ${it.code}: ${it.message}`, it.location ?? "");
|
|
32
32
|
}
|
|
@@ -45,7 +45,7 @@ instead (`wasm-pack build . --target web`), which exposes an async `init()` you
|
|
|
45
45
|
```ts
|
|
46
46
|
interface Report {
|
|
47
47
|
status: string; // "ok" (valid) | "problems" (error/fatal findings remain)
|
|
48
|
-
summary: {
|
|
48
|
+
summary: { fatal?: number; error: number; warning: number; info?: number; usage?: number };
|
|
49
49
|
items: Item[];
|
|
50
50
|
}
|
|
51
51
|
interface Item {
|
|
@@ -56,7 +56,13 @@ interface Item {
|
|
|
56
56
|
location?: string; // container-relative path, when available
|
|
57
57
|
position?: { line: number; column: number };
|
|
58
58
|
message: string; // epubveri's own message wording
|
|
59
|
-
data?: {
|
|
59
|
+
data?: {
|
|
60
|
+
params: string[]; // the values interpolated into `message`
|
|
61
|
+
element_path?: string; // XPath-style path to the offending node
|
|
62
|
+
namespaces: Map<string, string>; // bindings that resolve element_path — a Map, see below
|
|
63
|
+
advisory_basis?: string; // "spec-ahead" | "spec-silent", on ADV-*/NEXT-* only
|
|
64
|
+
violation_kind?: string; // which of six kinds a schema violation is
|
|
65
|
+
};
|
|
60
66
|
}
|
|
61
67
|
|
|
62
68
|
function validate(
|
|
@@ -75,17 +81,35 @@ function version(): string;
|
|
|
75
81
|
|
|
76
82
|
### Advisory checks
|
|
77
83
|
|
|
78
|
-
`advisory` mirrors the CLI `--advisory` flag: pass `true` to also emit the opt-in
|
|
79
|
-
|
|
80
|
-
(`ADV-001`/`ADV-002`, at `usage` severity). It is **off by default**: leaving the argument
|
|
81
|
-
out, or passing `false`/`undefined`, produces a byte-identical report, so existing
|
|
82
|
-
two-argument callers are unaffected.
|
|
84
|
+
`advisory` mirrors the CLI `--advisory` flag: pass `true` to also emit the opt-in findings
|
|
85
|
+
epubcheck has no verdict on, in two families, both at `usage` severity:
|
|
83
86
|
|
|
84
|
-
|
|
87
|
+
- **`NEXT-*`** — a published specification requires it and epubcheck has not implemented it
|
|
88
|
+
yet, so it becomes an ordinary error the day it catches up (today: the EPUB 3.4 rules).
|
|
89
|
+
- **`ADV-*`** — no specification says anything, but the book is still probably wrong
|
|
90
|
+
(unknown CSS property and descriptor names, a type selector naming no known element, an
|
|
91
|
+
EPUB 2 package written in EPUB 3, two navigation entries landing on one document).
|
|
85
92
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
It is **off by default**: leaving the argument out, or passing `false`/`undefined`,
|
|
94
|
+
produces a byte-identical report, so existing two-argument callers are unaffected. Neither
|
|
95
|
+
family ever affects `status` — a book that passes epubcheck passes epubveri, with or
|
|
96
|
+
without the flag.
|
|
97
|
+
|
|
98
|
+
### Two differences from the CLI
|
|
99
|
+
|
|
100
|
+
**`PKG-016` is not reported here.** That check is about the `.epub` **file extension**
|
|
101
|
+
being lowercase, and this entry point only ever sees bytes, never a filename.
|
|
102
|
+
|
|
103
|
+
**`data.namespaces` is a `Map`, not a plain object.** That is how a Rust map crosses
|
|
104
|
+
into JavaScript here, and it is the one place this binding's shape differs from the
|
|
105
|
+
CLI's JSON, where the same field is an object. Use `data.namespaces.get("opf")`;
|
|
106
|
+
`data.namespaces["opf"]` is silently `undefined`. Everything else in `data` — added in
|
|
107
|
+
0.10.0, having previously been CLI-only — is exactly the CLI's shape.
|
|
108
|
+
|
|
109
|
+
**Nothing is filtered here.** The CLI hides `usage`-severity findings from its human
|
|
110
|
+
report unless you pass `-u`; this binding is a machine interface and always returns
|
|
111
|
+
every finding, exactly like `--format json`. Filter on `severity` yourself if your UI
|
|
112
|
+
wants the CLI's default view.
|
|
89
113
|
|
|
90
114
|
## Try the demo
|
|
91
115
|
|
package/epubveri.d.ts
CHANGED
|
@@ -63,19 +63,64 @@ export interface Item {
|
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Small aggregate counts, mirroring the envelope\'s per-input `summary`
|
|
66
|
-
*
|
|
66
|
+
* exactly — same singular key names, and `fatal`/`info`/`usage` omitted when
|
|
67
|
+
* zero, as the CLI envelope emits them.
|
|
68
|
+
*
|
|
69
|
+
* **These counts are never filtered**, unlike the CLI\'s, where `-u` decides
|
|
70
|
+
* what the output contains and the counts describe the output. This binding
|
|
71
|
+
* has no such flag: it is a machine interface and always returns everything,
|
|
72
|
+
* so its counts always describe the whole report.
|
|
67
73
|
*/
|
|
68
74
|
export interface Summary {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
fatal: number;
|
|
76
|
+
error: number;
|
|
77
|
+
warning: number;
|
|
78
|
+
info: number;
|
|
79
|
+
usage: number;
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
/**
|
|
75
|
-
* Tool-specific item extras
|
|
83
|
+
* Tool-specific item extras — the same slot the CLI\'s `--format json` fills,
|
|
84
|
+
* with the same contents.
|
|
85
|
+
*
|
|
86
|
+
* Kept in step with [`epubveri::envelope::Data`] deliberately: a browser
|
|
87
|
+
* consumer that has to fall back to the CLI for a field is a consumer this
|
|
88
|
+
* package failed. Through 0.9.x this struct carried `params` alone, so
|
|
89
|
+
* `element_path`, `namespaces`, `advisory_basis` and `violation_kind` were
|
|
90
|
+
* reachable from the command line and not from the web. That was an omission
|
|
91
|
+
* rather than a decision — nothing about the browser makes them harder to
|
|
92
|
+
* produce — and 0.10.0 closes it.
|
|
93
|
+
*
|
|
94
|
+
* **Absent means absent**, as in the CLI envelope: every optional field is
|
|
95
|
+
* omitted rather than emitted as `null`, so a consumer tests for presence.
|
|
76
96
|
*/
|
|
77
97
|
export interface Data {
|
|
78
98
|
params: string[];
|
|
99
|
+
/**
|
|
100
|
+
* XPath-style path to the offending node, resolvable with `namespaces`.
|
|
101
|
+
*/
|
|
102
|
+
element_path?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Prefix -> namespace-URI bindings needed to resolve `element_path`.
|
|
105
|
+
*
|
|
106
|
+
* **This arrives in JavaScript as a `Map`, not a plain object** — that is
|
|
107
|
+
* how serde-wasm-bindgen renders a map, and it is the one place this
|
|
108
|
+
* binding\'s shape differs from the CLI\'s JSON, where the same field is an
|
|
109
|
+
* object. So `data.namespaces.get(\"opf\")`, never
|
|
110
|
+
* `data.namespaces[\"opf\"]`, which would silently be `undefined`.
|
|
111
|
+
*/
|
|
112
|
+
namespaces: Map<string, string>;
|
|
113
|
+
/**
|
|
114
|
+
* `spec-ahead` | `spec-silent` — what an advisory finding is grounded in.
|
|
115
|
+
* Present only on `ADV-*`/`NEXT-*` findings.
|
|
116
|
+
*/
|
|
117
|
+
advisory_basis?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Which of the six kinds of schema violation this is, when the rule
|
|
120
|
+
* carries kinds. `None` says the rule has no kinds, never that the kind
|
|
121
|
+
* could not be determined.
|
|
122
|
+
*/
|
|
123
|
+
violation_kind?: string;
|
|
79
124
|
}
|
|
80
125
|
|
|
81
126
|
|
|
@@ -88,10 +133,13 @@ export interface Data {
|
|
|
88
133
|
* names behave like `undefined` (permissive).
|
|
89
134
|
*
|
|
90
135
|
* `advisory` mirrors the CLI `--advisory` flag: pass `true` to also emit the
|
|
91
|
-
* opt-in
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
136
|
+
* opt-in findings epubcheck has no verdict on, in two families, both at
|
|
137
|
+
* `usage` severity — `NEXT-*` (a published specification requires it and
|
|
138
|
+
* epubcheck has not implemented it yet, so it becomes an ordinary error once
|
|
139
|
+
* it does) and `ADV-*` (no specification says anything, but the book is still
|
|
140
|
+
* probably wrong). `undefined`/`false` leaves them off, and with them off the
|
|
141
|
+
* report is byte-identical — so existing two-argument callers are unaffected.
|
|
142
|
+
* Neither family can move `status`.
|
|
95
143
|
*
|
|
96
144
|
* `epub_version` mirrors the CLI `-v` flag — pass `"2"`, `"2.0"`, `"3"`,
|
|
97
145
|
* `"3.0"` to validate against that version whatever the book declares, or
|
package/epubveri_bg.js
CHANGED
|
@@ -7,10 +7,13 @@
|
|
|
7
7
|
* names behave like `undefined` (permissive).
|
|
8
8
|
*
|
|
9
9
|
* `advisory` mirrors the CLI `--advisory` flag: pass `true` to also emit the
|
|
10
|
-
* opt-in
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* opt-in findings epubcheck has no verdict on, in two families, both at
|
|
11
|
+
* `usage` severity — `NEXT-*` (a published specification requires it and
|
|
12
|
+
* epubcheck has not implemented it yet, so it becomes an ordinary error once
|
|
13
|
+
* it does) and `ADV-*` (no specification says anything, but the book is still
|
|
14
|
+
* probably wrong). `undefined`/`false` leaves them off, and with them off the
|
|
15
|
+
* report is byte-identical — so existing two-argument callers are unaffected.
|
|
16
|
+
* Neither family can move `status`.
|
|
14
17
|
*
|
|
15
18
|
* `epub_version` mirrors the CLI `-v` flag — pass `"2"`, `"2.0"`, `"3"`,
|
|
16
19
|
* `"3.0"` to validate against that version whatever the book declares, or
|
|
@@ -68,6 +71,10 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
|
68
71
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
69
72
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
70
73
|
}
|
|
74
|
+
export function __wbg___wbindgen_is_string_ea5e6cc2e4141dfe(arg0) {
|
|
75
|
+
const ret = typeof(arg0) === 'string';
|
|
76
|
+
return ret;
|
|
77
|
+
}
|
|
71
78
|
export function __wbg___wbindgen_throw_344f42d3211c4765(arg0, arg1) {
|
|
72
79
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
73
80
|
}
|
|
@@ -75,10 +82,18 @@ export function __wbg_new_32b398fb48b6d94a() {
|
|
|
75
82
|
const ret = new Array();
|
|
76
83
|
return ret;
|
|
77
84
|
}
|
|
85
|
+
export function __wbg_new_7796ffc7ed656783() {
|
|
86
|
+
const ret = new Map();
|
|
87
|
+
return ret;
|
|
88
|
+
}
|
|
78
89
|
export function __wbg_new_da52cf8fe3429cb2() {
|
|
79
90
|
const ret = new Object();
|
|
80
91
|
return ret;
|
|
81
92
|
}
|
|
93
|
+
export function __wbg_set_575dd786d51585f8(arg0, arg1, arg2) {
|
|
94
|
+
const ret = arg0.set(arg1, arg2);
|
|
95
|
+
return ret;
|
|
96
|
+
}
|
|
82
97
|
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
83
98
|
arg0[arg1] = arg2;
|
|
84
99
|
}
|
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.11.0",
|
|
6
6
|
"license": "AGPL-3.0-only OR LicenseRef-veripublica-Commercial",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|