@likecoin/epubcheck-ts 0.3.8 → 0.4.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/dist/index.d.cts CHANGED
@@ -1,353 +1,3 @@
1
- /**
2
- * Represents a manifest item in the OPF
3
- */
4
- interface ManifestItem {
5
- /** Unique identifier for this item */
6
- id: string;
7
- /** Path relative to the OPF file */
8
- href: string;
9
- /** MIME media type */
10
- mediaType: string;
11
- /** Fallback item ID for non-standard media types */
12
- fallback?: string;
13
- /** Media overlay ID */
14
- mediaOverlay?: string;
15
- /** Item properties (EPUB 3) - e.g., 'nav', 'scripted', 'svg', 'remote-resources' */
16
- properties?: string[];
17
- }
18
- /**
19
- * Represents a spine itemref in the OPF
20
- */
21
- interface SpineItemRef {
22
- /** Optional ID attribute on the itemref element */
23
- id?: string;
24
- /** Reference to manifest item ID */
25
- idref: string;
26
- /** Whether this item is part of the linear reading order */
27
- linear: boolean;
28
- /** Itemref properties (EPUB 3) - e.g., 'page-spread-left', 'page-spread-right' */
29
- properties?: string[];
30
- }
31
- /**
32
- * Represents a guide reference (EPUB 2)
33
- */
34
- interface GuideReference {
35
- /** Type of reference (cover, toc, etc.) */
36
- type: string;
37
- /** Title for display */
38
- title?: string;
39
- /** Path to the referenced item */
40
- href: string;
41
- }
42
- /**
43
- * Dublin Core metadata element
44
- */
45
- interface DCElement {
46
- /** The element name (title, creator, identifier, etc.) */
47
- name: string;
48
- /** The text content */
49
- value: string;
50
- /** The id attribute, if any */
51
- id?: string;
52
- /** Additional attributes */
53
- attributes?: Record<string, string>;
54
- }
55
- /**
56
- * EPUB 3 meta element
57
- */
58
- interface MetaElement {
59
- /** Property name (with optional prefix) */
60
- property: string;
61
- /** The text content */
62
- value: string;
63
- /** ID of the element this meta refines */
64
- refines?: string;
65
- /** Scheme for the value */
66
- scheme?: string;
67
- /** The id attribute, if any */
68
- id?: string;
69
- }
70
- /**
71
- * EPUB 3 link element
72
- */
73
- interface LinkElement {
74
- /** Relationship type */
75
- rel: string;
76
- /** URL to the linked resource */
77
- href: string;
78
- /** Media type of the linked resource */
79
- mediaType?: string;
80
- /** ID of the element this link refines */
81
- refines?: string;
82
- /** Link properties */
83
- properties?: string[];
84
- /** The id attribute, if any */
85
- id?: string;
86
- /** Language tag for the linked resource */
87
- hreflang?: string;
88
- }
89
- /**
90
- * Parsed OPF package document
91
- */
92
- interface PackageDocument {
93
- /** EPUB version from package@version */
94
- version: EPUBVersion;
95
- /** Unique identifier reference (package@unique-identifier) */
96
- uniqueIdentifier: string;
97
- /** Package prefix declarations (EPUB 3) */
98
- prefixes?: Record<string, string>;
99
- /** Package direction (rtl, ltr, auto) */
100
- dir?: string;
101
- /** Dublin Core metadata elements */
102
- dcElements: DCElement[];
103
- /** EPUB 3 meta elements */
104
- metaElements: MetaElement[];
105
- /** EPUB 3 link elements */
106
- linkElements: LinkElement[];
107
- /** Manifest items */
108
- manifest: ManifestItem[];
109
- /** Spine item references */
110
- spine: SpineItemRef[];
111
- /** Spine toc attribute (NCX reference for EPUB 2) */
112
- spineToc?: string;
113
- /** Spine page-progression-direction */
114
- pageProgressionDirection?: 'ltr' | 'rtl' | 'default';
115
- /** Guide references (EPUB 2) */
116
- guide: GuideReference[];
117
- /** Collections (EPUB 3) */
118
- collections: Collection[];
119
- /** Whether the bindings element is present (deprecated in EPUB 3.3) */
120
- hasBindings?: boolean;
121
- /** xml:lang attribute on elements (for validation) */
122
- xmlLangs?: string[];
123
- }
124
- /**
125
- * Represents a collection in the OPF (EPUB 3)
126
- */
127
- interface Collection {
128
- /** Collection role (dictionary, index, preview, etc.) */
129
- role: string;
130
- /** Collection identifier */
131
- id?: string;
132
- /** Collection name/label */
133
- name?: string;
134
- /** Resource hrefs in this collection (from link elements) */
135
- links: string[];
136
- }
137
-
138
- /**
139
- * Severity levels for validation messages
140
- */
141
- type Severity = 'fatal' | 'error' | 'warning' | 'info' | 'usage';
142
- /**
143
- * Supported EPUB versions
144
- */
145
- type EPUBVersion = '2.0' | '3.0' | '3.1' | '3.2' | '3.3';
146
- /**
147
- * EPUB validation profiles
148
- */
149
- type EPUBProfile = 'default' | 'edupub' | 'idx' | 'dict' | 'preview';
150
- /**
151
- * Location within an EPUB file
152
- */
153
- interface EPUBLocation {
154
- /** Path to the file within the EPUB container */
155
- path: string;
156
- /** Line number (1-based), if applicable */
157
- line?: number;
158
- /** Column number (1-based), if applicable */
159
- column?: number;
160
- /** Additional context about the location */
161
- context?: string;
162
- }
163
- /**
164
- * A validation message (error, warning, etc.)
165
- */
166
- interface ValidationMessage {
167
- /** Unique message identifier */
168
- id: string;
169
- /** Severity level */
170
- severity: Severity;
171
- /** Human-readable message */
172
- message: string;
173
- /** Location where the issue was found */
174
- location?: EPUBLocation;
175
- /** Suggestion for fixing the issue */
176
- suggestion?: string;
177
- }
178
- /**
179
- * Result of EPUB validation
180
- */
181
- interface EpubCheckResult {
182
- /** Whether the EPUB is valid (no errors or fatal errors) */
183
- valid: boolean;
184
- /** All validation messages */
185
- messages: ValidationMessage[];
186
- /** Count of fatal errors */
187
- fatalCount: number;
188
- /** Count of errors */
189
- errorCount: number;
190
- /** Count of warnings */
191
- warningCount: number;
192
- /** Count of info messages */
193
- infoCount: number;
194
- /** Count of usage messages */
195
- usageCount: number;
196
- /** Detected EPUB version */
197
- version?: EPUBVersion | undefined;
198
- /** Time taken for validation in milliseconds */
199
- elapsedMs: number;
200
- }
201
- /**
202
- * Options for EpubCheck
203
- */
204
- interface EpubCheckOptions {
205
- /** EPUB version to validate against (auto-detected if not specified) */
206
- version?: EPUBVersion;
207
- /** Validation profile */
208
- profile?: EPUBProfile;
209
- /** Whether to include usage messages */
210
- includeUsage?: boolean;
211
- /** Whether to include info messages */
212
- includeInfo?: boolean;
213
- /** Maximum number of errors before stopping (0 = unlimited) */
214
- maxErrors?: number;
215
- /** Locale for messages (e.g., 'en', 'de', 'fr') */
216
- locale?: string;
217
- }
218
- /**
219
- * Internal validation context passed through the validation pipeline
220
- */
221
- interface ValidationContext {
222
- /** EPUB file data */
223
- data: Uint8Array;
224
- /** Validation options */
225
- options: Required<EpubCheckOptions>;
226
- /** Detected EPUB version */
227
- version: EPUBVersion;
228
- /** Validation messages collected so far */
229
- messages: ValidationMessage[];
230
- /** Files extracted from EPUB container */
231
- files: Map<string, Uint8Array>;
232
- /** Rootfiles found in container.xml */
233
- rootfiles: Rootfile[];
234
- /** Path to the package document (OPF) */
235
- opfPath?: string;
236
- /** Parsed package document */
237
- packageDocument?: PackageDocument;
238
- /** NCX UID for validation against OPF identifier */
239
- ncxUid?: string;
240
- /** Resources referenced in content but not declared in manifest */
241
- referencedUndeclaredResources?: Set<string>;
242
- /** TOC navigation link targets in order, for reading order validation (NAV-011) */
243
- tocLinks?: {
244
- targetResource: string;
245
- fragment?: string;
246
- location: EPUBLocation;
247
- }[];
248
- /** Resources marked with IDPF font obfuscation in encryption.xml */
249
- obfuscatedResources?: Set<string>;
250
- }
251
- /**
252
- * Rootfile reference from container.xml
253
- */
254
- interface Rootfile {
255
- path: string;
256
- mediaType: string;
257
- }
258
-
259
- /**
260
- * Main EPUB validation class
261
- *
262
- * @example
263
- * ```typescript
264
- * import { EpubCheck } from 'epubcheck-ts';
265
- *
266
- * // Validate from a Uint8Array (works in Node.js and browsers)
267
- * const result = await EpubCheck.validate(epubData);
268
- *
269
- * if (result.valid) {
270
- * console.log('EPUB is valid!');
271
- * } else {
272
- * console.log(`Found ${result.errorCount} errors`);
273
- * for (const msg of result.messages) {
274
- * console.log(`${msg.severity}: ${msg.message}`);
275
- * }
276
- * }
277
- * ```
278
- */
279
- declare class EpubCheck {
280
- private readonly options;
281
- /**
282
- * Create a new EpubCheck instance with custom options
283
- */
284
- constructor(options?: EpubCheckOptions);
285
- /**
286
- * Validate an EPUB file
287
- *
288
- * @param data - The EPUB file as a Uint8Array
289
- * @returns Validation result
290
- */
291
- check(data: Uint8Array): Promise<EpubCheckResult>;
292
- /**
293
- * Static method to validate an EPUB file with default options
294
- *
295
- * @param data - The EPUB file as a Uint8Array
296
- * @param options - Optional validation options
297
- * @returns Validation result
298
- */
299
- static validate(data: Uint8Array, options?: EpubCheckOptions): Promise<EpubCheckResult>;
300
- /**
301
- * Get the current EPUB version being validated against
302
- */
303
- get version(): EPUBVersion;
304
- /**
305
- * Validate NCX navigation document (EPUB 2 always, EPUB 3 when NCX present)
306
- */
307
- private validateNCX;
308
- /**
309
- * Add a validation message to the context
310
- */
311
- protected addMessage(messages: ValidationMessage[], message: ValidationMessage): void;
312
- /**
313
- * Validate that obfuscated resources are blessed font types (PKG-026)
314
- */
315
- private validateObfuscatedResources;
316
- /**
317
- * Populate resource registry from package document manifest
318
- */
319
- private populateRegistry;
320
- /**
321
- * Check if a manifest item has a fallback chain reaching a Core Media Type
322
- */
323
- private hasCMTFallback;
324
- }
325
-
326
- /**
327
- * Build a validation result from messages
328
- */
329
- declare function buildReport(messages: ValidationMessage[], version: EPUBVersion | undefined, elapsedMs: number): EpubCheckResult;
330
- /**
331
- * Count messages by severity
332
- */
333
- declare function countBySeverity(messages: ValidationMessage[]): Record<Severity, number>;
334
- /**
335
- * Filter messages by severity
336
- */
337
- declare function filterBySeverity(messages: ValidationMessage[], severity: Severity): ValidationMessage[];
338
- /**
339
- * Filter messages by path
340
- */
341
- declare function filterByPath(messages: ValidationMessage[], path: string): ValidationMessage[];
342
- /**
343
- * Format messages as a string for display
344
- */
345
- declare function formatMessages(messages: ValidationMessage[]): string;
346
- /**
347
- * Convert result to JSON report format (compatible with EPUBCheck JSON output)
348
- */
349
- declare function toJSONReport(result: EpubCheckResult): string;
350
-
351
1
  /**
352
2
  * Message Definitions for EPUB validation errors and warnings
353
3
  *
@@ -1906,72 +1556,469 @@ type MessageKey = keyof MessageDefsType;
1906
1556
  declare const MessageId: { readonly [K in MessageKey]: MessageDefsType[K]["id"]; };
1907
1557
  type MessageId = MessageDefsType[MessageKey]['id'];
1908
1558
  /**
1909
- * Message info structure
1559
+ * Message info structure
1560
+ */
1561
+ interface MessageInfo {
1562
+ id: string;
1563
+ severity: MessageSeverity;
1564
+ description: string;
1565
+ }
1566
+ /**
1567
+ * Get message info by ID
1568
+ */
1569
+ declare function getMessageInfo(id: string): MessageInfo | undefined;
1570
+ /**
1571
+ * Get default severity for a message ID
1572
+ */
1573
+ declare function getDefaultSeverity(id: string): MessageSeverity;
1574
+ /**
1575
+ * Get all message definitions as an array (for iteration/display)
1576
+ */
1577
+ declare function getAllMessages(): readonly MessageInfo[];
1578
+ /**
1579
+ * Format message list for console output
1580
+ */
1581
+ declare function formatMessageList(): string;
1582
+ /**
1583
+ * Options for creating a validation message
1584
+ */
1585
+ interface CreateMessageOptions {
1586
+ /** Message ID from MessageId enum */
1587
+ id: MessageId;
1588
+ /** Human-readable message */
1589
+ message: string;
1590
+ /** Location where the issue was found */
1591
+ location?: EPUBLocation;
1592
+ /** Suggestion for fixing the issue */
1593
+ suggestion?: string;
1594
+ /** Override the default severity (use sparingly) */
1595
+ severityOverride?: Severity;
1596
+ }
1597
+ /**
1598
+ * Create a validation message with automatic severity lookup
1599
+ *
1600
+ * @example
1601
+ * ```typescript
1602
+ * const msg = createMessage({
1603
+ * id: MessageId.PKG_006,
1604
+ * message: 'Missing mimetype file',
1605
+ * location: { path: 'mimetype' },
1606
+ * });
1607
+ * if (msg) context.messages.push(msg);
1608
+ * ```
1609
+ */
1610
+ declare function createMessage(options: CreateMessageOptions): ValidationMessage | null;
1611
+ /**
1612
+ * Create and push a validation message to the messages array.
1613
+ * Automatically handles suppressed messages by not pushing them.
1614
+ *
1615
+ * @example
1616
+ * ```typescript
1617
+ * pushMessage(context.messages, {
1618
+ * id: MessageId.PKG_006,
1619
+ * message: 'Missing mimetype file',
1620
+ * location: { path: 'mimetype' },
1621
+ * });
1622
+ * ```
1623
+ */
1624
+ declare function pushMessage(messages: ValidationMessage[], options: CreateMessageOptions): void;
1625
+ /**
1626
+ * Parse a custom messages file (TSV format compatible with Java EPUBCheck).
1627
+ *
1628
+ * Format: one override per line, tab-separated: `ID\tSEVERITY`
1629
+ * Lines starting with # are comments. A header line starting with "id" is skipped.
1630
+ *
1631
+ * @example
1632
+ * ```
1633
+ * ACC-004\tWARNING
1634
+ * ACC-005\tWARNING
1635
+ * RSC-008\tSUPPRESSED
1636
+ * ```
1637
+ */
1638
+ declare function parseCustomMessages(content: string): Map<string, MessageSeverity>;
1639
+
1640
+ /**
1641
+ * Represents a manifest item in the OPF
1642
+ */
1643
+ interface ManifestItem {
1644
+ /** Unique identifier for this item */
1645
+ id: string;
1646
+ /** Path relative to the OPF file */
1647
+ href: string;
1648
+ /** MIME media type */
1649
+ mediaType: string;
1650
+ /** Fallback item ID for non-standard media types */
1651
+ fallback?: string;
1652
+ /** Media overlay ID */
1653
+ mediaOverlay?: string;
1654
+ /** Item properties (EPUB 3) - e.g., 'nav', 'scripted', 'svg', 'remote-resources' */
1655
+ properties?: string[];
1656
+ }
1657
+ /**
1658
+ * Represents a spine itemref in the OPF
1659
+ */
1660
+ interface SpineItemRef {
1661
+ /** Optional ID attribute on the itemref element */
1662
+ id?: string;
1663
+ /** Reference to manifest item ID */
1664
+ idref: string;
1665
+ /** Whether this item is part of the linear reading order */
1666
+ linear: boolean;
1667
+ /** Itemref properties (EPUB 3) - e.g., 'page-spread-left', 'page-spread-right' */
1668
+ properties?: string[];
1669
+ }
1670
+ /**
1671
+ * Represents a guide reference (EPUB 2)
1672
+ */
1673
+ interface GuideReference {
1674
+ /** Type of reference (cover, toc, etc.) */
1675
+ type: string;
1676
+ /** Title for display */
1677
+ title?: string;
1678
+ /** Path to the referenced item */
1679
+ href: string;
1680
+ }
1681
+ /**
1682
+ * Dublin Core metadata element
1683
+ */
1684
+ interface DCElement {
1685
+ /** The element name (title, creator, identifier, etc.) */
1686
+ name: string;
1687
+ /** The text content */
1688
+ value: string;
1689
+ /** The id attribute, if any */
1690
+ id?: string;
1691
+ /** Additional attributes */
1692
+ attributes?: Record<string, string>;
1693
+ }
1694
+ /**
1695
+ * EPUB 3 meta element
1696
+ */
1697
+ interface MetaElement {
1698
+ /** Property name (with optional prefix) */
1699
+ property: string;
1700
+ /** The text content */
1701
+ value: string;
1702
+ /** ID of the element this meta refines */
1703
+ refines?: string;
1704
+ /** Scheme for the value */
1705
+ scheme?: string;
1706
+ /** The id attribute, if any */
1707
+ id?: string;
1708
+ }
1709
+ /**
1710
+ * EPUB 3 link element
1711
+ */
1712
+ interface LinkElement {
1713
+ /** Relationship type */
1714
+ rel: string;
1715
+ /** URL to the linked resource */
1716
+ href: string;
1717
+ /** Media type of the linked resource */
1718
+ mediaType?: string;
1719
+ /** ID of the element this link refines */
1720
+ refines?: string;
1721
+ /** Link properties */
1722
+ properties?: string[];
1723
+ /** The id attribute, if any */
1724
+ id?: string;
1725
+ /** Language tag for the linked resource */
1726
+ hreflang?: string;
1727
+ }
1728
+ /**
1729
+ * Parsed OPF package document
1730
+ */
1731
+ interface PackageDocument {
1732
+ /** EPUB version from package@version */
1733
+ version: EPUBVersion;
1734
+ /** Unique identifier reference (package@unique-identifier) */
1735
+ uniqueIdentifier: string;
1736
+ /** Package prefix declarations (EPUB 3) */
1737
+ prefixes?: Record<string, string>;
1738
+ /** Package direction (rtl, ltr, auto) */
1739
+ dir?: string;
1740
+ /** Dublin Core metadata elements */
1741
+ dcElements: DCElement[];
1742
+ /** EPUB 3 meta elements */
1743
+ metaElements: MetaElement[];
1744
+ /** EPUB 3 link elements */
1745
+ linkElements: LinkElement[];
1746
+ /** Manifest items */
1747
+ manifest: ManifestItem[];
1748
+ /** Spine item references */
1749
+ spine: SpineItemRef[];
1750
+ /** Spine toc attribute (NCX reference for EPUB 2) */
1751
+ spineToc?: string;
1752
+ /** Spine page-progression-direction */
1753
+ pageProgressionDirection?: 'ltr' | 'rtl' | 'default';
1754
+ /** Guide references (EPUB 2) */
1755
+ guide: GuideReference[];
1756
+ /** Collections (EPUB 3) */
1757
+ collections: Collection[];
1758
+ /** Whether the bindings element is present (deprecated in EPUB 3.3) */
1759
+ hasBindings?: boolean;
1760
+ /** xml:lang attribute on elements (for validation) */
1761
+ xmlLangs?: string[];
1762
+ }
1763
+ /**
1764
+ * Represents a collection in the OPF (EPUB 3)
1910
1765
  */
1911
- interface MessageInfo {
1912
- id: string;
1913
- severity: MessageSeverity;
1914
- description: string;
1766
+ interface Collection {
1767
+ /** Collection role (dictionary, index, preview, etc.) */
1768
+ role: string;
1769
+ /** Collection identifier */
1770
+ id?: string;
1771
+ /** Collection name/label */
1772
+ name?: string;
1773
+ /** Resource hrefs in this collection (from link elements) */
1774
+ links: string[];
1915
1775
  }
1776
+
1916
1777
  /**
1917
- * Get message info by ID
1778
+ * Severity levels for validation messages
1918
1779
  */
1919
- declare function getMessageInfo(id: string): MessageInfo | undefined;
1780
+ type Severity = 'fatal' | 'error' | 'warning' | 'info' | 'usage';
1920
1781
  /**
1921
- * Get default severity for a message ID
1782
+ * Supported EPUB versions
1922
1783
  */
1923
- declare function getDefaultSeverity(id: string): MessageSeverity;
1784
+ type EPUBVersion = '2.0' | '3.0' | '3.1' | '3.2' | '3.3';
1924
1785
  /**
1925
- * Get all message definitions as an array (for iteration/display)
1786
+ * EPUB validation profiles
1926
1787
  */
1927
- declare function getAllMessages(): readonly MessageInfo[];
1788
+ type EPUBProfile = 'default' | 'edupub' | 'idx' | 'dict' | 'preview';
1928
1789
  /**
1929
- * Format message list for console output
1790
+ * Location within an EPUB file
1930
1791
  */
1931
- declare function formatMessageList(): string;
1792
+ interface EPUBLocation {
1793
+ /** Path to the file within the EPUB container */
1794
+ path: string;
1795
+ /** Line number (1-based), if applicable */
1796
+ line?: number;
1797
+ /** Column number (1-based), if applicable */
1798
+ column?: number;
1799
+ /** Additional context about the location */
1800
+ context?: string;
1801
+ }
1932
1802
  /**
1933
- * Options for creating a validation message
1803
+ * A validation message (error, warning, etc.)
1934
1804
  */
1935
- interface CreateMessageOptions {
1936
- /** Message ID from MessageId enum */
1937
- id: MessageId;
1805
+ interface ValidationMessage {
1806
+ /** Unique message identifier */
1807
+ id: string;
1808
+ /** Severity level */
1809
+ severity: Severity;
1938
1810
  /** Human-readable message */
1939
1811
  message: string;
1940
1812
  /** Location where the issue was found */
1941
1813
  location?: EPUBLocation;
1942
1814
  /** Suggestion for fixing the issue */
1943
1815
  suggestion?: string;
1944
- /** Override the default severity (use sparingly) */
1945
- severityOverride?: Severity;
1946
1816
  }
1947
1817
  /**
1948
- * Create a validation message with automatic severity lookup
1949
- *
1950
- * @example
1951
- * ```typescript
1952
- * const msg = createMessage({
1953
- * id: MessageId.PKG_006,
1954
- * message: 'Missing mimetype file',
1955
- * location: { path: 'mimetype' },
1956
- * });
1957
- * if (msg) context.messages.push(msg);
1958
- * ```
1818
+ * Result of EPUB validation
1959
1819
  */
1960
- declare function createMessage(options: CreateMessageOptions): ValidationMessage | null;
1820
+ interface EpubCheckResult {
1821
+ /** Whether the EPUB is valid (no errors or fatal errors) */
1822
+ valid: boolean;
1823
+ /** All validation messages */
1824
+ messages: ValidationMessage[];
1825
+ /** Count of fatal errors */
1826
+ fatalCount: number;
1827
+ /** Count of errors */
1828
+ errorCount: number;
1829
+ /** Count of warnings */
1830
+ warningCount: number;
1831
+ /** Count of info messages */
1832
+ infoCount: number;
1833
+ /** Count of usage messages */
1834
+ usageCount: number;
1835
+ /** Detected EPUB version */
1836
+ version?: EPUBVersion | undefined;
1837
+ /** Time taken for validation in milliseconds */
1838
+ elapsedMs: number;
1839
+ }
1961
1840
  /**
1962
- * Create and push a validation message to the messages array.
1963
- * Automatically handles suppressed messages by not pushing them.
1841
+ * Options for EpubCheck
1842
+ */
1843
+ interface EpubCheckOptions {
1844
+ /** EPUB version to validate against (auto-detected if not specified) */
1845
+ version?: EPUBVersion;
1846
+ /** Validation profile */
1847
+ profile?: EPUBProfile;
1848
+ /** Whether to include usage messages */
1849
+ includeUsage?: boolean;
1850
+ /** Whether to include info messages */
1851
+ includeInfo?: boolean;
1852
+ /** Maximum number of errors before stopping (0 = unlimited) */
1853
+ maxErrors?: number;
1854
+ /** Locale for messages (e.g., 'en', 'de', 'fr') */
1855
+ locale?: string;
1856
+ /** Custom message severity overrides (message ID → severity) */
1857
+ customMessages?: Map<string, MessageSeverity>;
1858
+ }
1859
+ /**
1860
+ * Internal validation context passed through the validation pipeline
1861
+ */
1862
+ interface ValidationContext {
1863
+ /** EPUB file data */
1864
+ data: Uint8Array;
1865
+ /** Validation options */
1866
+ options: Required<EpubCheckOptions>;
1867
+ /** Detected EPUB version */
1868
+ version: EPUBVersion;
1869
+ /** Validation messages collected so far */
1870
+ messages: ValidationMessage[];
1871
+ /** Files extracted from EPUB container */
1872
+ files: Map<string, Uint8Array>;
1873
+ /** Rootfiles found in container.xml */
1874
+ rootfiles: Rootfile[];
1875
+ /** Path to the package document (OPF) */
1876
+ opfPath?: string;
1877
+ /** Parsed package document */
1878
+ packageDocument?: PackageDocument;
1879
+ /** NCX UID for validation against OPF identifier */
1880
+ ncxUid?: string;
1881
+ /** Resources referenced in content but not declared in manifest */
1882
+ referencedUndeclaredResources?: Set<string>;
1883
+ /** TOC navigation link targets in order, for reading order validation (NAV-011) */
1884
+ tocLinks?: {
1885
+ targetResource: string;
1886
+ fragment?: string;
1887
+ location: EPUBLocation;
1888
+ }[];
1889
+ /** Media overlay text link targets in order, for reading order validation (MED-015) */
1890
+ overlayTextLinks?: {
1891
+ targetResource: string;
1892
+ fragment?: string;
1893
+ location: EPUBLocation;
1894
+ }[];
1895
+ /** OPF media:active-class value (if declared) */
1896
+ mediaActiveClass?: string;
1897
+ /** OPF media:playback-active-class value (if declared) */
1898
+ mediaPlaybackActiveClass?: string;
1899
+ /** Resources marked with IDPF font obfuscation in encryption.xml */
1900
+ obfuscatedResources?: Set<string>;
1901
+ /** Feature flags collected during content validation for cross-document checks */
1902
+ contentFeatures?: {
1903
+ hasPageBreak?: boolean;
1904
+ hasPageList?: boolean;
1905
+ hasTable?: boolean;
1906
+ hasFigure?: boolean;
1907
+ hasAudio?: boolean;
1908
+ hasVideo?: boolean;
1909
+ hasDictionary?: boolean;
1910
+ hasIndex?: boolean;
1911
+ hasLOI?: boolean;
1912
+ hasLOT?: boolean;
1913
+ hasLOA?: boolean;
1914
+ hasLOV?: boolean;
1915
+ hasMicrodata?: boolean;
1916
+ hasRDFa?: boolean;
1917
+ };
1918
+ }
1919
+ /**
1920
+ * Rootfile reference from container.xml
1921
+ */
1922
+ interface Rootfile {
1923
+ path: string;
1924
+ mediaType: string;
1925
+ }
1926
+
1927
+ /**
1928
+ * Main EPUB validation class
1964
1929
  *
1965
1930
  * @example
1966
1931
  * ```typescript
1967
- * pushMessage(context.messages, {
1968
- * id: MessageId.PKG_006,
1969
- * message: 'Missing mimetype file',
1970
- * location: { path: 'mimetype' },
1971
- * });
1932
+ * import { EpubCheck } from 'epubcheck-ts';
1933
+ *
1934
+ * // Validate from a Uint8Array (works in Node.js and browsers)
1935
+ * const result = await EpubCheck.validate(epubData);
1936
+ *
1937
+ * if (result.valid) {
1938
+ * console.log('EPUB is valid!');
1939
+ * } else {
1940
+ * console.log(`Found ${result.errorCount} errors`);
1941
+ * for (const msg of result.messages) {
1942
+ * console.log(`${msg.severity}: ${msg.message}`);
1943
+ * }
1944
+ * }
1972
1945
  * ```
1973
1946
  */
1974
- declare function pushMessage(messages: ValidationMessage[], options: CreateMessageOptions): void;
1947
+ declare class EpubCheck {
1948
+ private readonly options;
1949
+ /**
1950
+ * Create a new EpubCheck instance with custom options
1951
+ */
1952
+ constructor(options?: EpubCheckOptions);
1953
+ /**
1954
+ * Validate an EPUB file
1955
+ *
1956
+ * @param data - The EPUB file as a Uint8Array
1957
+ * @returns Validation result
1958
+ */
1959
+ check(data: Uint8Array): Promise<EpubCheckResult>;
1960
+ /**
1961
+ * Static method to validate an EPUB file with default options
1962
+ *
1963
+ * @param data - The EPUB file as a Uint8Array
1964
+ * @param options - Optional validation options
1965
+ * @returns Validation result
1966
+ */
1967
+ static validate(data: Uint8Array, options?: EpubCheckOptions): Promise<EpubCheckResult>;
1968
+ /**
1969
+ * Get the current EPUB version being validated against
1970
+ */
1971
+ get version(): EPUBVersion;
1972
+ /**
1973
+ * Cross-document feature validation (Pattern B from Java EPUBCheck)
1974
+ */
1975
+ private validateCrossDocumentFeatures;
1976
+ /**
1977
+ * Validate NCX navigation document (EPUB 2 always, EPUB 3 when NCX present)
1978
+ */
1979
+ private validateNCX;
1980
+ /**
1981
+ * Add a validation message to the context
1982
+ */
1983
+ protected addMessage(messages: ValidationMessage[], message: ValidationMessage): void;
1984
+ /**
1985
+ * Validate that obfuscated resources are blessed font types (PKG-026)
1986
+ */
1987
+ private validateObfuscatedResources;
1988
+ /**
1989
+ * Populate resource registry from package document manifest
1990
+ */
1991
+ private populateRegistry;
1992
+ /**
1993
+ * Check if a manifest item has a fallback chain reaching a Core Media Type
1994
+ */
1995
+ private hasCMTFallback;
1996
+ }
1997
+
1998
+ /**
1999
+ * Build a validation result from messages
2000
+ */
2001
+ declare function buildReport(messages: ValidationMessage[], version: EPUBVersion | undefined, elapsedMs: number): EpubCheckResult;
2002
+ /**
2003
+ * Count messages by severity
2004
+ */
2005
+ declare function countBySeverity(messages: ValidationMessage[]): Record<Severity, number>;
2006
+ /**
2007
+ * Filter messages by severity
2008
+ */
2009
+ declare function filterBySeverity(messages: ValidationMessage[], severity: Severity): ValidationMessage[];
2010
+ /**
2011
+ * Filter messages by path
2012
+ */
2013
+ declare function filterByPath(messages: ValidationMessage[], path: string): ValidationMessage[];
2014
+ /**
2015
+ * Format messages as a string for display
2016
+ */
2017
+ declare function formatMessages(messages: ValidationMessage[]): string;
2018
+ /**
2019
+ * Convert result to JSON report format (compatible with EPUBCheck JSON output)
2020
+ */
2021
+ declare function toJSONReport(result: EpubCheckResult): string;
1975
2022
 
1976
2023
  /**
1977
2024
  * Interface for schema validators
@@ -1991,4 +2038,4 @@ interface SchemaValidator {
1991
2038
  dispose(): void;
1992
2039
  }
1993
2040
 
1994
- export { type CreateMessageOptions, type EPUBProfile, type EPUBVersion, EpubCheck, type EpubCheckOptions, type EpubCheckResult, MessageId, type MessageInfo, type MessageSeverity, type SchemaValidator, type Severity, type ValidationContext, type ValidationMessage, buildReport, countBySeverity, createMessage, filterByPath, filterBySeverity, formatMessageList, formatMessages, getAllMessages, getDefaultSeverity, getMessageInfo, pushMessage, toJSONReport };
2041
+ export { type CreateMessageOptions, type EPUBProfile, type EPUBVersion, EpubCheck, type EpubCheckOptions, type EpubCheckResult, MessageId, type MessageInfo, type MessageSeverity, type SchemaValidator, type Severity, type ValidationContext, type ValidationMessage, buildReport, countBySeverity, createMessage, filterByPath, filterBySeverity, formatMessageList, formatMessages, getAllMessages, getDefaultSeverity, getMessageInfo, parseCustomMessages, pushMessage, toJSONReport };