@likecoin/epubcheck-ts 0.3.3 → 0.3.5
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 +18 -11
- package/bin/epubcheck.js +2 -4
- package/bin/epubcheck.ts +9 -13
- package/dist/index.cjs +1075 -109
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +1075 -109
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -6,13 +6,13 @@ A TypeScript port of [EPUBCheck](https://github.com/w3c/epubcheck) - the officia
|
|
|
6
6
|
[](https://www.npmjs.com/package/@likecoin/epubcheck-ts)
|
|
7
7
|
[](./LICENSE)
|
|
8
8
|
|
|
9
|
-
> **Note**: This library is primarily developed for internal use at [3ook.com](https://3ook.com/about) and is built with AI-assisted development. While it has comprehensive test coverage (
|
|
9
|
+
> **Note**: This library is primarily developed for internal use at [3ook.com](https://3ook.com/about) and is built with AI-assisted development. While it has comprehensive test coverage (618 tests) and ~75% feature parity with Java EPUBCheck, it may not be suitable for mission-critical production workloads. For production environments requiring full EPUB validation, consider using the official [Java EPUBCheck](https://github.com/w3c/epubcheck). Contributions and feedback are welcome!
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
13
|
- **CLI and programmatic API**: Use as a command-line tool or integrate into your application
|
|
14
14
|
- **Cross-platform**: Works in Node.js (18+) and modern browsers
|
|
15
|
-
- **Partial EPUB validation**: Currently ~
|
|
15
|
+
- **Partial EPUB validation**: Currently ~75% of EPUBCheck feature parity
|
|
16
16
|
- **Zero native dependencies**: Pure JavaScript/WebAssembly, no compilation required
|
|
17
17
|
- **TypeScript first**: Full type definitions included
|
|
18
18
|
- **Tree-shakable**: ESM with proper exports for optimal bundling
|
|
@@ -70,7 +70,7 @@ epubcheck-ts book.epub --quiet --fail-on-warnings
|
|
|
70
70
|
epubcheck-ts dictionary.epub --profile dict
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
**Note:** This CLI provides ~
|
|
73
|
+
**Note:** This CLI provides ~75% coverage of Java EPUBCheck features. For complete EPUB 3 conformance testing, use the [official Java EPUBCheck](https://github.com/w3c/epubcheck).
|
|
74
74
|
|
|
75
75
|
### ES Modules (recommended)
|
|
76
76
|
|
|
@@ -133,6 +133,8 @@ fileInput.addEventListener('change', async (event) => {
|
|
|
133
133
|
|
|
134
134
|
## API
|
|
135
135
|
|
|
136
|
+
> Full API reference: [online](https://likecoin.github.io/epubcheck-ts/docs/) | [markdown](./docs/md/globals.md)
|
|
137
|
+
|
|
136
138
|
### `EpubCheck.validate(data, options?)`
|
|
137
139
|
|
|
138
140
|
Static method to validate an EPUB file.
|
|
@@ -264,20 +266,20 @@ This library is a TypeScript port of the Java-based [EPUBCheck](https://github.c
|
|
|
264
266
|
|
|
265
267
|
| Component | Status | Completeness | Notes |
|
|
266
268
|
|-----------|--------|--------------|-------|
|
|
267
|
-
| OCF Container | 🟡 Partial | ~
|
|
268
|
-
| Package Document (OPF) |
|
|
269
|
-
| Content Documents | 🟡 Partial | ~
|
|
270
|
-
| Navigation Document |
|
|
269
|
+
| OCF Container | 🟡 Partial | ~90% | ZIP structure, mimetype, container.xml, encryption.xml obfuscation |
|
|
270
|
+
| Package Document (OPF) | 🟢 Complete | ~90% | Metadata, manifest, spine, collections, Schematron-equivalent checks |
|
|
271
|
+
| Content Documents | 🟡 Partial | ~80% | XHTML structure, CSS url(), @import, SVG, script detection |
|
|
272
|
+
| Navigation Document | 🟢 Complete | ~85% | Nav content model, landmarks, labels, reading order, hidden |
|
|
271
273
|
| Schema Validation | 🟡 Partial | ~50% | RelaxNG for OPF/container; XHTML/SVG disabled (libxml2 limitation) |
|
|
272
|
-
| CSS | 🟡 Partial | ~
|
|
273
|
-
| Cross-reference Validation | 🟡 Partial | ~
|
|
274
|
+
| CSS | 🟡 Partial | ~70% | @font-face, @import, url() extraction, position, forbidden properties |
|
|
275
|
+
| Cross-reference Validation | 🟡 Partial | ~80% | Reference tracking, fragments, fallbacks, remote resources |
|
|
274
276
|
| Accessibility Checks | 🟡 Partial | ~30% | Basic checks only (empty links, image alt, SVG titles) |
|
|
275
277
|
| Media Overlays | ❌ Not Started | 0% | Planned |
|
|
276
278
|
| Media Validation | ❌ Not Started | 0% | Planned |
|
|
277
279
|
|
|
278
280
|
Legend: 🟢 Complete | 🟡 Partial | 🔴 Basic | ❌ Not Started
|
|
279
281
|
|
|
280
|
-
**Overall Progress: ~
|
|
282
|
+
**Overall Progress: ~75% of Java EPUBCheck features**
|
|
281
283
|
|
|
282
284
|
See [PROJECT_STATUS.md](./PROJECT_STATUS.md) for detailed comparison.
|
|
283
285
|
|
|
@@ -319,6 +321,9 @@ npm run build
|
|
|
319
321
|
| `npm run format` | Format with Biome |
|
|
320
322
|
| `npm run typecheck` | TypeScript type checking |
|
|
321
323
|
| `npm run check` | Run all checks (format + typecheck) |
|
|
324
|
+
| `npm run docs` | Generate API docs (HTML + Markdown) |
|
|
325
|
+
| `npm run docs:html` | Generate HTML API docs to `docs/html/` |
|
|
326
|
+
| `npm run docs:md` | Generate Markdown API docs to `docs/md/` |
|
|
322
327
|
|
|
323
328
|
### Project Structure
|
|
324
329
|
|
|
@@ -345,6 +350,8 @@ epubcheck-ts/
|
|
|
345
350
|
├── test/
|
|
346
351
|
│ ├── fixtures/ # Test EPUB files
|
|
347
352
|
│ └── integration/ # Integration tests
|
|
353
|
+
├── docs/
|
|
354
|
+
│ └── md/ # Generated API docs (Markdown, checked in)
|
|
348
355
|
├── examples/
|
|
349
356
|
│ └── web/ # Web demo ✅
|
|
350
357
|
└── dist/ # Build output
|
|
@@ -357,7 +364,7 @@ Legend: ✅ Implemented
|
|
|
357
364
|
| Aspect | epubcheck-ts | EPUBCheck (Java) |
|
|
358
365
|
|--------|--------------|------------------|
|
|
359
366
|
| Runtime | Node.js / Browser | JVM |
|
|
360
|
-
| Feature Parity | ~
|
|
367
|
+
| Feature Parity | ~75% | 100% |
|
|
361
368
|
| Bundle Size | ~450KB JS + ~1.6MB WASM | ~15MB |
|
|
362
369
|
| Installation | `npm install` | Download JAR |
|
|
363
370
|
| Integration | Native JS/TS | CLI or Java API |
|
package/bin/epubcheck.js
CHANGED
|
@@ -3,7 +3,7 @@ import { readFile, writeFile } from "node:fs/promises";
|
|
|
3
3
|
import { parseArgs } from "node:util";
|
|
4
4
|
import { basename } from "node:path";
|
|
5
5
|
const { EpubCheck, toJSONReport } = await import("../dist/index.js");
|
|
6
|
-
const VERSION = "0.3.
|
|
6
|
+
const VERSION = "0.3.5";
|
|
7
7
|
const { values, positionals } = parseArgs({
|
|
8
8
|
options: {
|
|
9
9
|
json: { type: "string", short: "j" },
|
|
@@ -111,9 +111,7 @@ async function main() {
|
|
|
111
111
|
if (!values.quiet) {
|
|
112
112
|
const fatal = result.messages.filter((m) => m.severity === "fatal");
|
|
113
113
|
const errors = result.messages.filter((m) => m.severity === "error");
|
|
114
|
-
const warnings = result.messages.filter(
|
|
115
|
-
(m) => m.severity === "warning"
|
|
116
|
-
);
|
|
114
|
+
const warnings = result.messages.filter((m) => m.severity === "warning");
|
|
117
115
|
const info = result.messages.filter((m) => m.severity === "info");
|
|
118
116
|
const usage = result.messages.filter((m) => m.severity === "usage");
|
|
119
117
|
const printMessages = (messages, color, label) => {
|
package/bin/epubcheck.ts
CHANGED
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
11
11
|
import { parseArgs } from 'node:util';
|
|
12
12
|
import { basename } from 'node:path';
|
|
13
|
+
import type { EpubCheckOptions, EPUBProfile, ValidationMessage } from '../src/types.js';
|
|
13
14
|
|
|
14
15
|
// Dynamic import to support both ESM and CJS builds
|
|
15
16
|
const { EpubCheck, toJSONReport } = await import('../dist/index.js');
|
|
16
17
|
|
|
17
|
-
const VERSION = '0.3.
|
|
18
|
+
const VERSION = '0.3.5';
|
|
18
19
|
|
|
19
20
|
// Parse command line arguments
|
|
20
21
|
const { values, positionals } = parseArgs({
|
|
@@ -110,12 +111,9 @@ async function main(): Promise<void> {
|
|
|
110
111
|
|
|
111
112
|
// Validate
|
|
112
113
|
const startTime = Date.now();
|
|
113
|
-
const options: {
|
|
114
|
-
profile?: 'default' | 'dict' | 'edupub' | 'idx' | 'preview';
|
|
115
|
-
includeUsage?: boolean;
|
|
116
|
-
} = {};
|
|
114
|
+
const options: EpubCheckOptions = {};
|
|
117
115
|
if (values.profile) {
|
|
118
|
-
options.profile = values.profile as
|
|
116
|
+
options.profile = values.profile as EPUBProfile;
|
|
119
117
|
}
|
|
120
118
|
if (values.usage) {
|
|
121
119
|
options.includeUsage = true;
|
|
@@ -147,13 +145,11 @@ async function main(): Promise<void> {
|
|
|
147
145
|
// Console output (unless quiet mode)
|
|
148
146
|
if (!values.quiet) {
|
|
149
147
|
// Group messages by severity
|
|
150
|
-
const fatal = result.messages.filter((m:
|
|
151
|
-
const errors = result.messages.filter((m:
|
|
152
|
-
const warnings = result.messages.filter(
|
|
153
|
-
|
|
154
|
-
);
|
|
155
|
-
const info = result.messages.filter((m: { severity: string }) => m.severity === 'info');
|
|
156
|
-
const usage = result.messages.filter((m: { severity: string }) => m.severity === 'usage');
|
|
148
|
+
const fatal = result.messages.filter((m: ValidationMessage) => m.severity === 'fatal');
|
|
149
|
+
const errors = result.messages.filter((m: ValidationMessage) => m.severity === 'error');
|
|
150
|
+
const warnings = result.messages.filter((m: ValidationMessage) => m.severity === 'warning');
|
|
151
|
+
const info = result.messages.filter((m: ValidationMessage) => m.severity === 'info');
|
|
152
|
+
const usage = result.messages.filter((m: ValidationMessage) => m.severity === 'usage');
|
|
157
153
|
|
|
158
154
|
// Print messages with colors
|
|
159
155
|
const printMessages = (
|