@storyteller-platform/epub 0.7.1 → 0.8.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 +1363 -775
- package/dist/adapters/interface.d.ts +6 -8
- package/dist/adapters/interface.js +1 -0
- package/dist/adapters/memory.d.ts +3 -6
- package/dist/adapters/memory.js +69 -64
- package/dist/adapters/tmpfs.d.ts +2 -5
- package/dist/adapters/tmpfs.js +230 -161
- package/dist/epubcheck.d.ts +4 -6
- package/dist/epubcheck.js +24 -26
- package/dist/index.d.ts +1161 -5
- package/dist/index.js +2581 -2739
- package/dist/upgrade.d.ts +23 -1183
- package/dist/upgrade.js +412 -432
- package/dist/zip.d.ts +2 -5
- package/dist/zip.js +113 -100
- package/package.json +18 -31
- package/dist/adapters/interface.cjs +0 -16
- package/dist/adapters/interface.d.cts +0 -75
- package/dist/adapters/memory.cjs +0 -93
- package/dist/adapters/memory.d.cts +0 -36
- package/dist/adapters/tmpfs.cjs +0 -240
- package/dist/adapters/tmpfs.d.cts +0 -31
- package/dist/chunk-BIEQXUOY.js +0 -50
- package/dist/epubcheck.cjs +0 -60
- package/dist/epubcheck.d.cts +0 -23
- package/dist/index.cjs +0 -2846
- package/dist/index.d.cts +0 -5
- package/dist/upgrade.cjs +0 -523
- package/dist/upgrade.d.cts +0 -1196
- package/dist/zip.cjs +0 -142
- package/dist/zip.d.cts +0 -5
package/dist/upgrade.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import './adapters/memory.js';
|
|
4
|
-
import './adapters/tmpfs.js';
|
|
5
|
-
|
|
6
|
-
interface Landmark {
|
|
1
|
+
import { Epub, type NavigationItem, type PackageElement, type XmlElement } from "./index.ts";
|
|
2
|
+
export interface Landmark {
|
|
7
3
|
href: string;
|
|
8
4
|
title: string;
|
|
9
5
|
type: string;
|
|
10
6
|
}
|
|
11
|
-
interface Epub2UpgradeOptions {
|
|
7
|
+
export interface Epub2UpgradeOptions {
|
|
12
8
|
/**
|
|
13
9
|
* The path to the output file. If provided, the input file will be copied to the output path.
|
|
14
10
|
*/
|
|
@@ -18,1179 +14,23 @@ interface Epub2UpgradeOptions {
|
|
|
18
14
|
*/
|
|
19
15
|
removeNcx?: boolean;
|
|
20
16
|
}
|
|
21
|
-
declare function upgradeIdentifiers(pkg: PackageElement): void;
|
|
22
|
-
declare function upgradeTitle(pkg: PackageElement): void;
|
|
23
|
-
declare function upgradeLanguages(pkg: PackageElement): void;
|
|
24
|
-
declare function upgradeAuthors(pkg: PackageElement): void;
|
|
25
|
-
declare function upgradeDate(pkg: PackageElement): void;
|
|
26
|
-
declare function upgradeMeta(pkg: PackageElement): void;
|
|
27
|
-
declare function upgradeCover(pkg: PackageElement): void;
|
|
28
|
-
declare function removeInvalidDcAttrs(pkg: PackageElement): void;
|
|
29
|
-
declare function setLastModified(pkg: PackageElement): void;
|
|
30
|
-
declare function upgradePackageMetadata(pkg: PackageElement): void;
|
|
31
|
-
declare function extractGuideLandmarks(pkg: PackageElement): Landmark[];
|
|
32
|
-
declare function removeGuide(pkg: PackageElement): void;
|
|
33
|
-
declare function removeSpineTocRef(pkg: PackageElement): void;
|
|
34
|
-
declare function collectManifestProperties(epub: Epub): Promise<void>;
|
|
35
|
-
declare function fixFontMimeTypes(pkg: PackageElement): void;
|
|
36
|
-
declare function buildTocOl(entries: NavigationItem[]): XmlElement<"ol">;
|
|
37
|
-
declare function buildNavDocument(epub: Epub, tocEntries: NavigationItem[], landmarks: Landmark[]): Promise<string>;
|
|
38
|
-
declare function setPackageVersion(pkg: PackageElement, version: string): void;
|
|
39
|
-
declare function chooseNavHref(epub: Epub): Promise<string>;
|
|
40
|
-
declare function removeNcx(epub: Epub): Promise<void>;
|
|
41
|
-
|
|
42
|
-
declare global {
|
|
43
|
-
namespace Intl {
|
|
44
|
-
interface Locale {
|
|
45
|
-
textInfo: {
|
|
46
|
-
direction: "rtl" | "ltr";
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
type Letter = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
|
|
52
|
-
type QuestionMark = "?";
|
|
53
|
-
/** A valid name for an XML element (must start with a letter) */
|
|
54
|
-
type ElementName = `${Letter | Uppercase<Letter> | QuestionMark}${string}`;
|
|
55
|
-
type PropertyPrefix = "@_";
|
|
56
|
-
/** An XML element */
|
|
57
|
-
type XmlElement<Name extends ElementName = ElementName> = {
|
|
58
|
-
":@"?: Record<`${PropertyPrefix}${string}`, string>;
|
|
59
|
-
} & {
|
|
60
|
-
[key in Name]: ParsedXml;
|
|
61
|
-
};
|
|
62
|
-
/** A text node in an XML document */
|
|
63
|
-
type XmlTextNode = {
|
|
64
|
-
"#text": string;
|
|
65
|
-
};
|
|
66
|
-
/** A valid XML node. May be either an element or a text node. */
|
|
67
|
-
type XmlNode = XmlElement | XmlTextNode;
|
|
68
|
-
/** An XML structure */
|
|
69
|
-
type ParsedXml = Array<XmlNode>;
|
|
70
|
-
type ManifestItem = {
|
|
71
|
-
id: string;
|
|
72
|
-
href: string;
|
|
73
|
-
mediaType?: string | undefined;
|
|
74
|
-
fallback?: string | undefined;
|
|
75
|
-
mediaOverlay?: string | undefined;
|
|
76
|
-
properties?: string[] | undefined;
|
|
77
|
-
};
|
|
78
|
-
type MetadataEntry = {
|
|
79
|
-
id?: string | undefined;
|
|
80
|
-
type: ElementName;
|
|
81
|
-
properties: Record<string, string>;
|
|
82
|
-
value: string | undefined;
|
|
83
|
-
};
|
|
84
|
-
type EpubMetadata = MetadataEntry[];
|
|
85
|
-
interface DcSubject {
|
|
86
|
-
value: string;
|
|
87
|
-
authority: string;
|
|
88
|
-
term: string;
|
|
89
|
-
}
|
|
90
|
-
interface EpubIdentifier {
|
|
91
|
-
value: string;
|
|
92
|
-
id?: string | undefined;
|
|
93
|
-
/** the value of a refining `identifier-type` meta, if present */
|
|
94
|
-
identifierType?: string | undefined;
|
|
95
|
-
/** the `scheme` of a refining `identifier-type` meta, or a legacy `opf:scheme` attribute */
|
|
96
|
-
scheme?: string | undefined;
|
|
97
|
-
}
|
|
98
|
-
interface EpubSource {
|
|
99
|
-
value: string;
|
|
100
|
-
id?: string | undefined;
|
|
101
|
-
/** the value of a refining `identifier-type` meta, if present */
|
|
102
|
-
identifierType?: string | undefined;
|
|
103
|
-
/** the `scheme` of a refining `identifier-type` meta, or a legacy `opf:scheme` attribute */
|
|
104
|
-
scheme?: string | undefined;
|
|
105
|
-
/**
|
|
106
|
-
* whether this source has a `source-of="pagination"` refinement
|
|
107
|
-
* or of a `<meta property="pageBreakSource">` element
|
|
108
|
-
*
|
|
109
|
-
* as of EPUB 3.4 `source-of` is advised-deprecated in favour of the
|
|
110
|
-
* publication-level `pageBreakSource` property. if you want to
|
|
111
|
-
* be sure to get the source of pagination, use {@link Epub.getPageBreakSource}
|
|
112
|
-
*/
|
|
113
|
-
isPageBreakSource?: boolean | undefined;
|
|
114
|
-
}
|
|
115
|
-
interface AlternateScript {
|
|
116
|
-
name: string;
|
|
117
|
-
locale: Intl.Locale;
|
|
118
|
-
}
|
|
119
|
-
interface DcCreator {
|
|
120
|
-
name: string;
|
|
121
|
-
role?: string;
|
|
122
|
-
roleScheme?: string;
|
|
123
|
-
fileAs?: string;
|
|
124
|
-
alternateScripts?: AlternateScript[];
|
|
125
|
-
}
|
|
126
|
-
interface DublinCore {
|
|
127
|
-
title: string;
|
|
128
|
-
language: Intl.Locale;
|
|
129
|
-
identifier: string;
|
|
130
|
-
date?: Date;
|
|
131
|
-
subjects?: Array<string | DcSubject>;
|
|
132
|
-
creators?: DcCreator[];
|
|
133
|
-
contributors?: DcCreator[];
|
|
134
|
-
type?: string;
|
|
135
|
-
}
|
|
136
|
-
interface Collection {
|
|
137
|
-
name: string;
|
|
138
|
-
type?: string;
|
|
139
|
-
position?: string;
|
|
140
|
-
}
|
|
141
|
-
interface NavigationItem {
|
|
142
|
-
title: string;
|
|
143
|
-
href?: string;
|
|
144
|
-
children?: NavigationList;
|
|
145
|
-
}
|
|
146
|
-
type NavigationList = NavigationItem[];
|
|
147
|
-
interface Navigation {
|
|
148
|
-
title?: string;
|
|
149
|
-
children: NavigationList;
|
|
150
|
-
}
|
|
151
|
-
interface GuideItem {
|
|
152
|
-
href: string;
|
|
153
|
-
title: string;
|
|
154
|
-
type: string;
|
|
155
|
-
}
|
|
156
|
-
type PackageElement = XmlElement<"package">;
|
|
157
|
-
interface FromOptions {
|
|
158
|
-
/**
|
|
159
|
-
* when true, mutation methods throw {@link EpubReadOnlyError} at runtime
|
|
160
|
-
* @default false
|
|
161
|
-
*/
|
|
162
|
-
readonly?: boolean;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Read-only view of an EPUB
|
|
166
|
-
* Returned by Epub.using(MemoryAdapter).from(...) and by Epub.from(path, { readonly: true })
|
|
167
|
-
*/
|
|
168
|
-
type EpubReader = Pick<Epub, "storage" | "findMetadataItem" | "findAllMetadataItems" | "resolveHref" | "readFileContents" | "readItemContents" | "readXhtmlItemContents" | "discardAndClose" | Extract<keyof Epub, `get${string}`>> & Disposable;
|
|
169
|
-
/**
|
|
170
|
-
* Readonly Epub-instance backed by an in-memory zip handle
|
|
171
|
-
* Returned by `Epub.using(MemoryAdapter).from(...)`
|
|
172
|
-
*/
|
|
173
|
-
type InMemoryEpubReader = EpubReader & {
|
|
174
|
-
readonly storage: "in-memory";
|
|
175
|
-
};
|
|
176
|
-
declare class EpubVersionError extends Error {
|
|
177
|
-
}
|
|
178
|
-
declare class EpubReadOnlyError extends Error {
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* A single EPUB instance.
|
|
182
|
-
*
|
|
183
|
-
* The entire EPUB contents will be read into memory.
|
|
184
|
-
*
|
|
185
|
-
* Example usage:
|
|
186
|
-
*
|
|
187
|
-
* ```ts
|
|
188
|
-
* import { Epub, getBody, findByName, textContent } from '@storyteller-platform/epub';
|
|
189
|
-
*
|
|
190
|
-
* const epub = await Epub.from('./path/to/book.epub');
|
|
191
|
-
* const title = await epub.getTitle();
|
|
192
|
-
* const spineItems = await epub.getSpineItems();
|
|
193
|
-
* const chptOne = spineItems[0];
|
|
194
|
-
* const chptOneXml = await epub.readXhtmlItemContents(chptOne.id);
|
|
195
|
-
*
|
|
196
|
-
* const body = getBody(chptOneXml);
|
|
197
|
-
* const h1 = Epub.findXmlChildByName('h1', body);
|
|
198
|
-
* const headingText = textContent(h1);
|
|
199
|
-
*
|
|
200
|
-
* await epub.setTitle(headingText);
|
|
201
|
-
* await epub.writeToFile('./path/to/updated.epub');
|
|
202
|
-
* await epub.close();
|
|
203
|
-
* ```
|
|
204
|
-
*
|
|
205
|
-
* @link https://www.w3.org/TR/epub-33/
|
|
206
|
-
*/
|
|
207
|
-
declare class Epub {
|
|
208
|
-
protected adapterClass: EpubStorageAdapterClass;
|
|
209
|
-
protected adapter: EpubStorageAdapter;
|
|
210
|
-
protected inputPath: string | undefined;
|
|
211
|
-
protected readonlyOverride: boolean;
|
|
212
|
-
static xmlParser: XMLParser;
|
|
213
|
-
static xhtmlParser: XMLParser;
|
|
214
|
-
static xmlBuilder: XMLBuilder;
|
|
215
|
-
static xhtmlBuilder: XMLBuilder;
|
|
216
|
-
/**
|
|
217
|
-
* Format a duration, provided as a number of seconds, as
|
|
218
|
-
* a SMIL clock value, to be used for Media Overlays.
|
|
219
|
-
*
|
|
220
|
-
* @link https://www.w3.org/TR/epub-33/#sec-duration
|
|
221
|
-
*/
|
|
222
|
-
static formatSmilDuration(duration: number): string;
|
|
223
|
-
/**
|
|
224
|
-
* Given an XML structure representing a complete XHTML document,
|
|
225
|
-
* add a `link` element to the `head` of the document.
|
|
226
|
-
*
|
|
227
|
-
* This method modifies the provided XML structure.
|
|
228
|
-
*/
|
|
229
|
-
static addLinkToXhtmlHead(xml: ParsedXml, link: {
|
|
230
|
-
rel: string;
|
|
231
|
-
href: string;
|
|
232
|
-
type: string;
|
|
233
|
-
}): void;
|
|
234
|
-
/**
|
|
235
|
-
* Given an XML structure representing a complete XHTML document,
|
|
236
|
-
* return the sub-structure representing the children of the
|
|
237
|
-
* document's body element.
|
|
238
|
-
*/
|
|
239
|
-
static getXhtmlBody(xml: ParsedXml): ParsedXml;
|
|
240
|
-
static createXmlElement<Name extends ElementName>(name: Name, properties: Record<string, string>, children?: XmlNode[]): XmlElement<Name>;
|
|
241
|
-
static createXmlTextNode(text: string): XmlTextNode;
|
|
242
|
-
/**
|
|
243
|
-
* Given an XML structure representing a complete XHTML document,
|
|
244
|
-
* return a string representing the concatenation of all text nodes
|
|
245
|
-
* in the document.
|
|
246
|
-
*/
|
|
247
|
-
static getXhtmlTextContent(xml: ParsedXml): string;
|
|
248
|
-
/**
|
|
249
|
-
* Given an XMLElement, return its attributes.
|
|
250
|
-
*/
|
|
251
|
-
static getXmlAttributes(element: XmlElement): Record<string, string>;
|
|
252
|
-
/**
|
|
253
|
-
* Given an XMLElement, return its tag name.
|
|
254
|
-
*/
|
|
255
|
-
static getXmlElementName<Name extends ElementName>(element: XmlElement<Name>): Name;
|
|
256
|
-
/**
|
|
257
|
-
* Given an XMLElement, return a list of its children
|
|
258
|
-
*/
|
|
259
|
-
static getXmlChildren<Name extends ElementName>(element: XmlElement<Name>): ParsedXml;
|
|
260
|
-
static replaceXmlChildren<Name extends ElementName>(element: XmlElement<Name>, children: XmlNode[]): void;
|
|
261
|
-
/**
|
|
262
|
-
* Given an XML structure, find the first child matching
|
|
263
|
-
* the provided name and optional filter.
|
|
264
|
-
*/
|
|
265
|
-
static findXmlChildByName<Name extends ElementName>(name: Name, xml: ParsedXml, filter?: (node: XmlElement<Name>) => boolean): XmlElement<Name> | undefined;
|
|
266
|
-
/**
|
|
267
|
-
* Given an XML structure, find the first descendant matching
|
|
268
|
-
* the provided name and optional filter.
|
|
269
|
-
*
|
|
270
|
-
* Will perform a breadth first search for the element, returning
|
|
271
|
-
* the highest element in the tree matching the name and filter.
|
|
272
|
-
*/
|
|
273
|
-
static findXmlDescendantByName<Name extends ElementName>(name: Name, xml: ParsedXml, filter?: (node: XmlElement<Name>) => boolean): XmlElement<Name> | undefined;
|
|
274
|
-
/**
|
|
275
|
-
* Given an XMLNode, determine whether it represents
|
|
276
|
-
* a text node or an XML element.
|
|
277
|
-
*/
|
|
278
|
-
static isXmlTextNode(node: XmlNode): node is XmlTextNode;
|
|
279
|
-
private rootfile;
|
|
280
|
-
private manifest;
|
|
281
|
-
private spine;
|
|
282
|
-
private packageMutex;
|
|
283
|
-
/**
|
|
284
|
-
* Storage backend kind in use for this instance
|
|
285
|
-
*
|
|
286
|
-
* Public so callers can declare type-level requirements via {@link InMemoryEpubReader}
|
|
287
|
-
* Orthogonal to the read-only / writable axis (controlled by `readonlyOverride`
|
|
288
|
-
* and the adapter's capability bag)
|
|
289
|
-
*/
|
|
290
|
-
readonly storage: EpubStorageKind;
|
|
291
|
-
/**
|
|
292
|
-
* Prefer the static factories ({@link Epub.using}, {@link Epub.from},
|
|
293
|
-
* {@link Epub.create}, {@link Epub.upgrade}) over calling this constructor
|
|
294
|
-
* directly. It's public so {@link EpubFactory} can construct instances; nothing
|
|
295
|
-
* else should need to.
|
|
296
|
-
*/
|
|
297
|
-
constructor(adapterClass: EpubStorageAdapterClass, adapter: EpubStorageAdapter, inputPath: string | undefined, readonlyOverride?: boolean);
|
|
298
|
-
/**
|
|
299
|
-
* Runtime guard for mutation methods
|
|
300
|
-
*/
|
|
301
|
-
private assertWritable;
|
|
302
|
-
/**
|
|
303
|
-
* Construct a new EPUB on a writable backend, optionally seeded
|
|
304
|
-
* with the provided metadata. Equivalent to
|
|
305
|
-
* `Epub.using(TmpFsAdapter).create(...)`.
|
|
306
|
-
*
|
|
307
|
-
* @param dublinCore Core metadata terms
|
|
308
|
-
* @param additionalMetadata An array of additional metadata entries
|
|
309
|
-
*/
|
|
310
|
-
static create(path: string, dublinCore: DublinCore, additionalMetadata?: EpubMetadata): Promise<Epub>;
|
|
311
|
-
/**
|
|
312
|
-
* Specify the storage backend to use for the EPUB
|
|
313
|
-
*
|
|
314
|
-
* The returned factory exposes `from`, `create`, and `upgrade`,
|
|
315
|
-
* which route through the supplied adapter.
|
|
316
|
-
*
|
|
317
|
-
* @example
|
|
318
|
-
* ```ts
|
|
319
|
-
* using epub = await Epub.using(TmpFsAdapter).from(path)
|
|
320
|
-
* using reader = await Epub.using(MemoryAdapter).from(buffer, { cache: false })
|
|
321
|
-
* ```
|
|
322
|
-
*/
|
|
323
|
-
static using<A extends EpubStorageAdapterClass>(adapterClass: A): EpubFactory<A>;
|
|
324
|
-
/**
|
|
325
|
-
* Open an existing EPUB publication, extracting it to a temp directory
|
|
326
|
-
* so writes can mutate the unpacked tree and rezip with `saveAndClose`.
|
|
327
|
-
*
|
|
328
|
-
* Pass `{ readonly: true }` to gate mutations at runtime.
|
|
329
|
-
*
|
|
330
|
-
* prefer `Epub.using(TmpFsAdapter).from(path)` (or
|
|
331
|
-
* `Epub.using(MemoryAdapter).from(path)` for read-only, in-memory access)
|
|
332
|
-
* @throws {EpubVersionError} when the archive is not a valid EPUB 3
|
|
333
|
-
*/
|
|
334
|
-
static from(pathOrData: string | Uint8Array): Promise<Epub>;
|
|
335
|
-
static from(pathOrData: string | Uint8Array, options: FromOptions & {
|
|
336
|
-
readonly: true;
|
|
337
|
-
}): Promise<EpubReader>;
|
|
338
|
-
static from(pathOrData: string | Uint8Array, options?: FromOptions): Promise<Epub | EpubReader>;
|
|
339
|
-
static assertEpub3(epub: Epub): Promise<void>;
|
|
340
|
-
copy(path?: string): Promise<Epub>;
|
|
341
|
-
private removeEntry;
|
|
342
|
-
/**
|
|
343
|
-
* Length of the underlying archive entry for a manifest item, in bytes
|
|
344
|
-
* Necessary to compute the readium page count which is for COMPRESSED content
|
|
345
|
-
* @see {@link https://github.com/readium/architecture/issues/123}
|
|
346
|
-
*/
|
|
347
|
-
getItemArchiveLength(id: string): Promise<number>;
|
|
348
|
-
getRootfile(): Promise<string>;
|
|
349
|
-
private getPackageDocument;
|
|
350
|
-
getPackageElement(): Promise<XmlElement<"package">>;
|
|
351
|
-
/**
|
|
352
|
-
* Safely modify the package document, without race conditions.
|
|
353
|
-
*
|
|
354
|
-
* Since the reading the package document is an async process,
|
|
355
|
-
* multiple simultaneously dispatched function calls that all
|
|
356
|
-
* attempt to modify it can clobber each other's changes. This
|
|
357
|
-
* method uses a mutex to ensure that each update runs exclusively.
|
|
358
|
-
*
|
|
359
|
-
* @param producer The function to update the package document. If
|
|
360
|
-
* it returns a new package document, that will be persisted, otherwise
|
|
361
|
-
* it will be assumed that the package document was modified in place.
|
|
362
|
-
*/
|
|
363
|
-
withPackage(producer: ((packageElement: PackageElement) => void) | ((packageElement: PackageElement) => PackageElement) | ((packageElement: PackageElement) => Promise<PackageElement>) | ((packageElement: PackageElement) => Promise<void>)): Promise<void>;
|
|
364
|
-
/**
|
|
365
|
-
* Retrieve the manifest for the Epub.
|
|
366
|
-
*
|
|
367
|
-
* This is represented as a map from each manifest items'
|
|
368
|
-
* id to the rest of its properties.
|
|
369
|
-
*
|
|
370
|
-
* @link https://www.w3.org/TR/epub-33/#sec-pkg-manifest
|
|
371
|
-
*/
|
|
372
|
-
getManifest(): Promise<Record<string, ManifestItem>>;
|
|
373
|
-
/**
|
|
374
|
-
* Returns the first index in the metadata element's children array
|
|
375
|
-
* that matches the provided predicate.
|
|
376
|
-
*
|
|
377
|
-
* Note: This may technically be different than the index in the
|
|
378
|
-
* getMetadata() array, as it includes non-metadata nodes, like
|
|
379
|
-
* text nodes. These are technically not allowed, but may exist,
|
|
380
|
-
* nonetheless. As consumers only ever see the getMetadata()
|
|
381
|
-
* array, this method is only meant to be used internally.
|
|
382
|
-
*/
|
|
383
|
-
private findMetadataIndex;
|
|
384
|
-
/**
|
|
385
|
-
* Returns the item in the metadata element's children array
|
|
386
|
-
* that matches the provided predicate.
|
|
387
|
-
*/
|
|
388
|
-
findMetadataItem(predicate: (entry: MetadataEntry) => boolean): Promise<{
|
|
389
|
-
id: string | undefined;
|
|
390
|
-
type: `a${string}` | `b${string}` | `c${string}` | `d${string}` | `e${string}` | `f${string}` | `g${string}` | `h${string}` | `i${string}` | `j${string}` | `k${string}` | `l${string}` | `m${string}` | `n${string}` | `o${string}` | `p${string}` | `q${string}` | `r${string}` | `s${string}` | `t${string}` | `u${string}` | `v${string}` | `w${string}` | `x${string}` | `y${string}` | `z${string}` | `A${string}` | `B${string}` | `C${string}` | `D${string}` | `E${string}` | `F${string}` | `G${string}` | `H${string}` | `I${string}` | `J${string}` | `K${string}` | `L${string}` | `M${string}` | `N${string}` | `O${string}` | `P${string}` | `Q${string}` | `R${string}` | `S${string}` | `T${string}` | `U${string}` | `V${string}` | `W${string}` | `X${string}` | `Y${string}` | `Z${string}` | `?${string}`;
|
|
391
|
-
properties: {
|
|
392
|
-
[k: string]: string;
|
|
393
|
-
};
|
|
394
|
-
value: string | undefined;
|
|
395
|
-
} | null>;
|
|
396
|
-
/**
|
|
397
|
-
* Returns the item in the metadata element's children array
|
|
398
|
-
* that matches the provided predicate.
|
|
399
|
-
*/
|
|
400
|
-
findAllMetadataItems(predicate: (entry: MetadataEntry) => boolean): Promise<{
|
|
401
|
-
id: string | undefined;
|
|
402
|
-
type: `a${string}` | `b${string}` | `c${string}` | `d${string}` | `e${string}` | `f${string}` | `g${string}` | `h${string}` | `i${string}` | `j${string}` | `k${string}` | `l${string}` | `m${string}` | `n${string}` | `o${string}` | `p${string}` | `q${string}` | `r${string}` | `s${string}` | `t${string}` | `u${string}` | `v${string}` | `w${string}` | `x${string}` | `y${string}` | `z${string}` | `A${string}` | `B${string}` | `C${string}` | `D${string}` | `E${string}` | `F${string}` | `G${string}` | `H${string}` | `I${string}` | `J${string}` | `K${string}` | `L${string}` | `M${string}` | `N${string}` | `O${string}` | `P${string}` | `Q${string}` | `R${string}` | `S${string}` | `T${string}` | `U${string}` | `V${string}` | `W${string}` | `X${string}` | `Y${string}` | `Z${string}` | `?${string}`;
|
|
403
|
-
properties: {
|
|
404
|
-
[k: string]: string;
|
|
405
|
-
};
|
|
406
|
-
value: string | undefined;
|
|
407
|
-
}[]>;
|
|
408
|
-
private static parseMetadataItem;
|
|
409
|
-
/**
|
|
410
|
-
* Retrieve the metadata entries for the Epub.
|
|
411
|
-
*
|
|
412
|
-
* This is represented as an array of metadata entries,
|
|
413
|
-
* in the order that they're presented in the Epub package document.
|
|
414
|
-
*
|
|
415
|
-
* For more useful semantic representations of metadata, use
|
|
416
|
-
* specific methods such as `getTitle()` and `getAuthors()`.
|
|
417
|
-
*
|
|
418
|
-
* @link https://www.w3.org/TR/epub-33/#sec-pkg-metadata
|
|
419
|
-
*/
|
|
420
|
-
getMetadata(): Promise<EpubMetadata>;
|
|
421
|
-
/**
|
|
422
|
-
* Retrieve the first identifier from the dc:identifier element
|
|
423
|
-
* in the EPUB metadata.
|
|
424
|
-
*
|
|
425
|
-
* If there is no dc:identifier element, returns null.
|
|
426
|
-
*
|
|
427
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dcidentifier
|
|
428
|
-
*
|
|
429
|
-
* @deprecated Use {@link getUniqueIdentifier} instead to get the unique identifier,
|
|
430
|
-
* or {@link getIdentifiers} to get all identifiers.
|
|
431
|
-
*/
|
|
432
|
-
getIdentifier(): Promise<string | null>;
|
|
433
|
-
/**
|
|
434
|
-
* Set the dc:identifier metadata element with the provided string.
|
|
435
|
-
*
|
|
436
|
-
* Updates the existing dc:identifier element if one exists.
|
|
437
|
-
* Otherwise creates a new element
|
|
438
|
-
*
|
|
439
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dcidentifier
|
|
440
|
-
*
|
|
441
|
-
* @deprecated Use {@link setUniqueIdentifier} instead.
|
|
442
|
-
*/
|
|
443
|
-
setIdentifier(identifier: string): Promise<void>;
|
|
444
|
-
/**
|
|
445
|
-
* Retrieve the identifier with the unique identifier id
|
|
446
|
-
* in the EPUB metadata.
|
|
447
|
-
*
|
|
448
|
-
* If there is no unique identifier id, returns the first dc:identifier element.
|
|
449
|
-
*
|
|
450
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dcidentifier
|
|
451
|
-
*/
|
|
452
|
-
getUniqueIdentifier(): Promise<string | null>;
|
|
453
|
-
/**
|
|
454
|
-
* Set the unique identifier id for the EPUB.
|
|
455
|
-
*
|
|
456
|
-
* Updates the existing dc:identifier element referenced by the unique identifier id if one exists.
|
|
457
|
-
* Otherwise creates a new element with the provided identifier, and sets the unique identifier id to the new element's id.
|
|
458
|
-
*
|
|
459
|
-
* Note: you likely shouldn't change the unique identifier id unless you are producing a new EPUB.
|
|
460
|
-
*
|
|
461
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dcidentifier
|
|
462
|
-
*/
|
|
463
|
-
setUniqueIdentifier(identifier: string): Promise<void>;
|
|
464
|
-
/**
|
|
465
|
-
* Retrieve the id of the publication's unique identifier, as declared by the
|
|
466
|
-
* package element's `unique-identifier` attribute.
|
|
467
|
-
*
|
|
468
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dcidentifier
|
|
469
|
-
*/
|
|
470
|
-
getUniqueIdentifierId(): Promise<string | null>;
|
|
471
|
-
/**
|
|
472
|
-
* Collect `dc:identifier` or `dc:source` entries, attaching the value and
|
|
473
|
-
* scheme of any refining `identifier-type` meta (spec D.3.8) and a legacy
|
|
474
|
-
* `opf:scheme` attribute. Values are not interpreted.
|
|
475
|
-
*
|
|
476
|
-
* `onRefinement` is invoked for every other meta refining a collected entry,
|
|
477
|
-
* so callers can surface element-specific refinements (e.g. `source-of` on a
|
|
478
|
-
* `dc:source`).
|
|
479
|
-
*/
|
|
480
|
-
private static collectDcEntries;
|
|
481
|
-
/**
|
|
482
|
-
* Retrieve every `dc:identifier` entry, returned as found.
|
|
483
|
-
*
|
|
484
|
-
* Values are not interpreted. Any refining `identifier-type` meta (spec
|
|
485
|
-
* D.3.8) or legacy `opf:scheme` attribute is surfaced on the entry, but no
|
|
486
|
-
* parsing of the value itself is attempted. To read `dc:source` entries, use
|
|
487
|
-
* {@link getSources}.
|
|
488
|
-
*
|
|
489
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dcidentifier
|
|
490
|
-
*/
|
|
491
|
-
getIdentifiers(): Promise<EpubIdentifier[]>;
|
|
492
|
-
/**
|
|
493
|
-
* Retrieve every `dc:source` entry, returned as found.
|
|
494
|
-
*
|
|
495
|
-
* Like {@link getIdentifiers}, values are not interpreted. In addition to a
|
|
496
|
-
* refining `identifier-type`, a refining `source-of` meta (spec D.3.11) is
|
|
497
|
-
* surfaced as `sourceOf`.
|
|
498
|
-
*
|
|
499
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dcsource
|
|
500
|
-
*/
|
|
501
|
-
getSources(): Promise<EpubSource[]>;
|
|
502
|
-
/**
|
|
503
|
-
* Retrieve the `pageBreakSource` property (EPUB 3.4, spec D.2.9), the
|
|
504
|
-
* publication-level source for the source of its page break markers.
|
|
505
|
-
*
|
|
506
|
-
* This property replaces the refining `source-of="pagination"` meta (spec
|
|
507
|
-
* D.3.11), see {@link EpubSource.sourceOf}. If no `pageBreakSource` property is found,
|
|
508
|
-
* we fall back to finding a `dc:source` with a `source-of="pagination"` refinement.
|
|
509
|
-
*
|
|
510
|
-
* @link https://www.w3.org/TR/epub/#pageBreakSource
|
|
511
|
-
*/
|
|
512
|
-
getPageBreakSource(): Promise<EpubSource | null>;
|
|
513
|
-
/**
|
|
514
|
-
* Set the `pageBreakSource` property (EPUB 3.4, spec D.2.9), or remove it when
|
|
515
|
-
* passed null. Replaces an existing `pageBreakSource` meta if present.
|
|
516
|
-
*
|
|
517
|
-
* Pass `none` to indicate the pagination is unique to this publication.
|
|
518
|
-
*
|
|
519
|
-
* @link https://www.w3.org/TR/epub/#pageBreakSource
|
|
520
|
-
*/
|
|
521
|
-
setPageBreakSource(value: string | null): Promise<void>;
|
|
522
|
-
/**
|
|
523
|
-
* Replace the publication's `dc:identifier` entries.
|
|
524
|
-
*
|
|
525
|
-
* This replaces ALL existing `dc:identifier` elements except the publication's
|
|
526
|
-
* unique identifier (the one referenced by the package element's
|
|
527
|
-
* `unique-identifier` attribute), which is always preserved and must not be
|
|
528
|
-
* included in the provided list. If included anyway, it is ignored. See
|
|
529
|
-
* {@link setUniqueIdentifier} to change it.
|
|
530
|
-
*
|
|
531
|
-
* Identifiers are placed in the order they are provided.
|
|
532
|
-
*
|
|
533
|
-
* `dc:source` entries are not touched, use {@link setSources} for those.
|
|
534
|
-
*
|
|
535
|
-
* When an entry has an `identifierType`, it is written in the refining form
|
|
536
|
-
* (a `meta` with `property="identifier-type"`, carrying the `scheme`
|
|
537
|
-
* attribute when provided). An entry with only a `scheme` is written using
|
|
538
|
-
* the legacy `opf:scheme` attribute.
|
|
539
|
-
*
|
|
540
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dcidentifier
|
|
541
|
-
*/
|
|
542
|
-
setIdentifiers(identifiers: EpubIdentifier[]): Promise<void>;
|
|
543
|
-
/**
|
|
544
|
-
* Remove `meta` refinements pointing at any of the given ids,
|
|
545
|
-
* restricted to the given `property` values as a cleanup step
|
|
546
|
-
* Mutates `children` in place.
|
|
547
|
-
*/
|
|
548
|
-
private static removeRefiningMetas;
|
|
549
|
-
/**
|
|
550
|
-
* Replace the publication's `dc:source` entries.
|
|
551
|
-
*
|
|
552
|
-
* This replaces ALL existing `dc:source` elements (and their refining
|
|
553
|
-
* `identifier-type` / `source-of` metas). `dc:identifier` entries are not
|
|
554
|
-
* touched; use {@link setIdentifiers} for those. Pass an empty array to
|
|
555
|
-
* remove all sources.
|
|
556
|
-
*
|
|
557
|
-
* When an entry has an `identifierType`, it is written in the refining form.
|
|
558
|
-
* A `sourceOf` value is written as a refining `source-of` meta (spec D.3.11).
|
|
559
|
-
* An entry with only a `scheme` uses the legacy `opf:scheme` attribute.
|
|
560
|
-
*
|
|
561
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dcsource
|
|
562
|
-
*/
|
|
563
|
-
setSources(sources: EpubSource[]): Promise<void>;
|
|
564
|
-
/**
|
|
565
|
-
* Even "EPUB 3" publications sometimes still only use the
|
|
566
|
-
* EPUB 2 specification for identifying the cover image.
|
|
567
|
-
* This is a private method that is used as a fallback if
|
|
568
|
-
* we fail to find the cover image according to the EPUB 3
|
|
569
|
-
* spec.
|
|
570
|
-
*/
|
|
571
|
-
private getEpub2CoverImage;
|
|
572
|
-
/**
|
|
573
|
-
* Retrieve the cover image manifest item.
|
|
574
|
-
*
|
|
575
|
-
* This does not return the actual image data. To
|
|
576
|
-
* retrieve the image data, pass this item's id to
|
|
577
|
-
* epub.readItemContents, or use epub.getCoverImage()
|
|
578
|
-
* instead.
|
|
579
|
-
*
|
|
580
|
-
* @link https://www.w3.org/TR/epub-33/#sec-cover-image
|
|
581
|
-
*/
|
|
582
|
-
getCoverImageItem(): Promise<ManifestItem | null>;
|
|
583
|
-
/**
|
|
584
|
-
* Retrieve the cover image data as a byte array.
|
|
585
|
-
*
|
|
586
|
-
* This does not include, for example, the cover image's
|
|
587
|
-
* filename or mime type. To retrieve the image manifest
|
|
588
|
-
* item, use epub.getCoverImageItem().
|
|
589
|
-
*
|
|
590
|
-
* @link https://www.w3.org/TR/epub-33/#sec-cover-image
|
|
591
|
-
*/
|
|
592
|
-
getCoverImage(): Promise<Uint8Array<ArrayBufferLike> | null>;
|
|
593
|
-
/**
|
|
594
|
-
* Set the cover image for the EPUB.
|
|
595
|
-
*
|
|
596
|
-
* Adds a manifest item with the `cover-image` property, per
|
|
597
|
-
* the EPUB 3 spec, and then writes the provided image data to
|
|
598
|
-
* the provided href within the publication.
|
|
599
|
-
*/
|
|
600
|
-
setCoverImage(href: string, data: Uint8Array): Promise<void>;
|
|
601
|
-
/**
|
|
602
|
-
* Retrieve the publication date from the dc:date element
|
|
603
|
-
* in the EPUB metadata as a Date object.
|
|
604
|
-
*
|
|
605
|
-
* If there is no dc:date element, returns null.
|
|
606
|
-
*
|
|
607
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dcdate
|
|
608
|
-
*/
|
|
609
|
-
getPublicationDate(): Promise<Date | null>;
|
|
610
|
-
/**
|
|
611
|
-
* Set the dc:date metadata element with the provided date.
|
|
612
|
-
*
|
|
613
|
-
* Updates the existing dc:date element if one exists.
|
|
614
|
-
* Otherwise creates a new element
|
|
615
|
-
*
|
|
616
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dcdate
|
|
617
|
-
*/
|
|
618
|
-
setPublicationDate(date: Date): Promise<void>;
|
|
619
|
-
/**
|
|
620
|
-
* Retrieve the modified date from the dcterms:modified metadata
|
|
621
|
-
* in the EPUB metadata as a Date object.
|
|
622
|
-
*
|
|
623
|
-
* If there is no meta element with dcterms:modified, returns null.
|
|
624
|
-
*
|
|
625
|
-
* @link https://www.w3.org/TR/epub-33/#sec-metadata-last-modified
|
|
626
|
-
*/
|
|
627
|
-
getModifiedDate(): Promise<Date | null>;
|
|
628
|
-
/**
|
|
629
|
-
* Retrieve the layout from the rendition:layout meta element
|
|
630
|
-
* in the EPUB metadata.
|
|
631
|
-
*
|
|
632
|
-
* If there is no meta element, returns 'reflowable'.
|
|
633
|
-
*
|
|
634
|
-
* @link https://www.w3.org/TR/epub-33/#layout
|
|
635
|
-
*/
|
|
636
|
-
getLayout(): Promise<"reflowable" | "pre-paginated">;
|
|
637
|
-
/**
|
|
638
|
-
* Retrieve the base direction from the package element.
|
|
639
|
-
*
|
|
640
|
-
* If there is no `dir` attribute on the package element,
|
|
641
|
-
* returns 'auto'.
|
|
642
|
-
*
|
|
643
|
-
* @link https://www.w3.org/TR/epub-33/#attrdef-dir
|
|
644
|
-
*/
|
|
645
|
-
getBaseDirection(): Promise<"ltr" | "rtl" | "auto">;
|
|
646
|
-
/**
|
|
647
|
-
* Set the dc:type metadata element.
|
|
648
|
-
*
|
|
649
|
-
* Updates the existing dc:type element if one exists.
|
|
650
|
-
* Otherwise creates a new element.
|
|
651
|
-
*
|
|
652
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dctype
|
|
653
|
-
*/
|
|
654
|
-
setType(type: string): Promise<void>;
|
|
655
|
-
/**
|
|
656
|
-
* Retrieve the publication type from the dc:type element
|
|
657
|
-
* in the EPUB metadata.
|
|
658
|
-
*
|
|
659
|
-
* If there is no dc:type element, returns null.
|
|
660
|
-
*
|
|
661
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dctype
|
|
662
|
-
*/
|
|
663
|
-
getType(): Promise<MetadataEntry | null>;
|
|
664
|
-
/**
|
|
665
|
-
* Add a subject to the EPUB metadata.
|
|
666
|
-
*
|
|
667
|
-
* @param subject May be a string representing just a schema-less
|
|
668
|
-
* subject name, or a DcSubject object
|
|
669
|
-
*
|
|
670
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dcsubject
|
|
671
|
-
*/
|
|
672
|
-
addSubject(subject: string | DcSubject): Promise<void>;
|
|
673
|
-
/**
|
|
674
|
-
* Remove a subject from the EPUB metadata.
|
|
675
|
-
*
|
|
676
|
-
* Removes the subject at the provided index. This index
|
|
677
|
-
* refers to the array returned by `epub.getSubjects()`.
|
|
678
|
-
*
|
|
679
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dccreator
|
|
680
|
-
*/
|
|
681
|
-
removeSubject(index: number): Promise<void>;
|
|
682
|
-
/**
|
|
683
|
-
* Retrieve the list of subjects for this EPUB.
|
|
684
|
-
*
|
|
685
|
-
* Subjects without associated authority and term metadata
|
|
686
|
-
* will be returned as strings. Otherwise, they will
|
|
687
|
-
* be represented as DcSubject objects, with a value,
|
|
688
|
-
* authority, and term.
|
|
689
|
-
*
|
|
690
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dcsubject
|
|
691
|
-
*/
|
|
692
|
-
getSubjects(): Promise<(string | DcSubject)[]>;
|
|
693
|
-
/**
|
|
694
|
-
* Retrieve the Epub's language as specified in its
|
|
695
|
-
* package document metadata.
|
|
696
|
-
*
|
|
697
|
-
* If no language metadata is specified, returns null.
|
|
698
|
-
* Returns the language as an Intl.Locale instance.
|
|
699
|
-
*
|
|
700
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dclanguage
|
|
701
|
-
*/
|
|
702
|
-
getLanguage(): Promise<Intl.Locale | null>;
|
|
703
|
-
/**
|
|
704
|
-
* Update the Epub's language metadata entry.
|
|
705
|
-
*
|
|
706
|
-
* Updates the existing dc:language element if one exists.
|
|
707
|
-
* Otherwise creates a new element
|
|
708
|
-
*
|
|
709
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dclanguage
|
|
710
|
-
*/
|
|
711
|
-
setLanguage(locale: Intl.Locale): Promise<void>;
|
|
712
|
-
/**
|
|
713
|
-
* Retrieve the title of the Epub.
|
|
714
|
-
*
|
|
715
|
-
* @param main Optional - whether to return only the first title segment
|
|
716
|
-
* if multiple are found. Otherwise, will follow the spec to combine title
|
|
717
|
-
* segments
|
|
718
|
-
*
|
|
719
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dctitle
|
|
720
|
-
*/
|
|
721
|
-
getTitle(expanded?: boolean): Promise<string | null>;
|
|
722
|
-
/**
|
|
723
|
-
* Retrieve the subtitle of the Epub, if it exists.
|
|
724
|
-
*
|
|
725
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dctitle
|
|
726
|
-
*/
|
|
727
|
-
getSubtitle(): Promise<string | null>;
|
|
728
|
-
/**
|
|
729
|
-
* Retrieve all title entries of the Epub.
|
|
730
|
-
*
|
|
731
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dctitle
|
|
732
|
-
*/
|
|
733
|
-
getTitles(): Promise<{
|
|
734
|
-
title: string;
|
|
735
|
-
type: string | null;
|
|
736
|
-
}[]>;
|
|
737
|
-
/**
|
|
738
|
-
* Update the Epub's description metadata entry.
|
|
739
|
-
*
|
|
740
|
-
* Updates the existing dc:description element if one exists.
|
|
741
|
-
* Otherwise creates a new element. Any non-ASCII symbols,
|
|
742
|
-
* `&`, `<`, `>`, `"`, `'`, and `\``` will be encoded as HTML entities.
|
|
743
|
-
*/
|
|
744
|
-
setDescription(description: string): Promise<void>;
|
|
745
|
-
/**
|
|
746
|
-
* Retrieve the Epub's description as specified in its
|
|
747
|
-
* package document metadata.
|
|
748
|
-
*
|
|
749
|
-
* If no description metadata is specified, returns null.
|
|
750
|
-
* Returns the description as a string. Descriptions may
|
|
751
|
-
* include HTML markup.
|
|
752
|
-
*/
|
|
753
|
-
getDescription(): Promise<string | null>;
|
|
754
|
-
/**
|
|
755
|
-
* Return the set of custom vocabulary prefixes set on this publication's
|
|
756
|
-
* root package element.
|
|
757
|
-
*
|
|
758
|
-
* Returns a map from prefix to URI
|
|
759
|
-
*
|
|
760
|
-
* @link https://www.w3.org/TR/epub-33/#sec-prefix-attr
|
|
761
|
-
*/
|
|
762
|
-
getPackageVocabularyPrefixes(): Promise<Record<string, string>>;
|
|
763
|
-
/**
|
|
764
|
-
* Set a custom vocabulary prefix on the root package element.
|
|
765
|
-
*
|
|
766
|
-
* @link https://www.w3.org/TR/epub-33/#sec-prefix-attr
|
|
767
|
-
*/
|
|
768
|
-
setPackageVocabularyPrefix(prefix: string, uri: string): Promise<void>;
|
|
769
|
-
/**
|
|
770
|
-
* Set the title of the Epub.
|
|
771
|
-
*
|
|
772
|
-
* This will replace all existing dc:title elements with
|
|
773
|
-
* this title. It will be given title-type "main".
|
|
774
|
-
*
|
|
775
|
-
* To set specific titles and their types, use epub.setTitles().
|
|
776
|
-
*
|
|
777
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dctitle
|
|
778
|
-
*/
|
|
779
|
-
setTitle(title: string): Promise<void>;
|
|
780
|
-
setTitles(entries: {
|
|
781
|
-
title: string;
|
|
782
|
-
type: string | null;
|
|
783
|
-
}[]): Promise<void>;
|
|
784
|
-
/**
|
|
785
|
-
* Retrieve the list of collections.
|
|
786
|
-
*/
|
|
787
|
-
getCollections(): Promise<Collection[]>;
|
|
788
|
-
/**
|
|
789
|
-
* Add a collection to the EPUB metadata.
|
|
790
|
-
*
|
|
791
|
-
* If index is provided, the collection will be placed at
|
|
792
|
-
* that index in the list of collections. Otherwise, it
|
|
793
|
-
* will be added to the end of the list.
|
|
794
|
-
*/
|
|
795
|
-
addCollection(collection: Collection, index?: number): Promise<void>;
|
|
796
|
-
/**
|
|
797
|
-
* Remove a collection from the EPUB metadata.
|
|
798
|
-
*
|
|
799
|
-
* Removes the collection at the provided index. This index
|
|
800
|
-
* refers to the array returned by `epub.getCollections()`.
|
|
801
|
-
*/
|
|
802
|
-
removeCollection(index: number): Promise<void>;
|
|
803
|
-
/**
|
|
804
|
-
* Retrieve the list of creators.
|
|
805
|
-
*
|
|
806
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dccreator
|
|
807
|
-
*/
|
|
808
|
-
getCreators(type?: "creator" | "contributor"): Promise<DcCreator[]>;
|
|
809
|
-
/**
|
|
810
|
-
* Retrieve the list of contributors.
|
|
811
|
-
*
|
|
812
|
-
* This is a convenience method for
|
|
813
|
-
* `epub.getCreators('contributor')`.
|
|
814
|
-
*
|
|
815
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dccontributor
|
|
816
|
-
*/
|
|
817
|
-
getContributors(): Promise<DcCreator[]>;
|
|
818
|
-
/**
|
|
819
|
-
* Add a creator to the EPUB metadata.
|
|
820
|
-
*
|
|
821
|
-
* If index is provided, the creator will be placed at
|
|
822
|
-
* that index in the list of creators. Otherwise, it
|
|
823
|
-
* will be added to the end of the list.
|
|
824
|
-
*
|
|
825
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dccreator
|
|
826
|
-
*/
|
|
827
|
-
addCreator(creator: DcCreator, index?: number, type?: "creator" | "contributor"): Promise<void>;
|
|
828
|
-
/**
|
|
829
|
-
* Remove a creator from the EPUB metadata.
|
|
830
|
-
*
|
|
831
|
-
* Removes the creator at the provided index. This index
|
|
832
|
-
* refers to the array returned by `epub.getCreators()`.
|
|
833
|
-
*
|
|
834
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dccreator
|
|
835
|
-
*/
|
|
836
|
-
removeCreator(index: number, type?: "creator" | "contributor"): Promise<void>;
|
|
837
|
-
/**
|
|
838
|
-
* Remove a contributor from the EPUB metadata.
|
|
839
|
-
*
|
|
840
|
-
* Removes the contributor at the provided index. This index
|
|
841
|
-
* refers to the array returned by `epub.getContributors()`.
|
|
842
|
-
*
|
|
843
|
-
* This is a convenience method for
|
|
844
|
-
* `epub.removeCreator(index, 'contributor')`.
|
|
845
|
-
*
|
|
846
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dccreator
|
|
847
|
-
*/
|
|
848
|
-
removeContributor(index: number): Promise<void>;
|
|
849
|
-
/**
|
|
850
|
-
* Add a contributor to the EPUB metadata.
|
|
851
|
-
*
|
|
852
|
-
* If index is provided, the creator will be placed at
|
|
853
|
-
* that index in the list of creators. Otherwise, it
|
|
854
|
-
* will be added to the end of the list.
|
|
855
|
-
*
|
|
856
|
-
* This is a convenience method for
|
|
857
|
-
* `epub.addCreator(contributor, index, 'contributor')`.
|
|
858
|
-
*
|
|
859
|
-
* @link https://www.w3.org/TR/epub-33/#sec-opf-dccreator
|
|
860
|
-
*/
|
|
861
|
-
addContributor(contributor: DcCreator, index?: number): Promise<void>;
|
|
862
|
-
private getSpine;
|
|
863
|
-
/**
|
|
864
|
-
* Retrieve the manifest items that make up the Epub's spine.
|
|
865
|
-
*
|
|
866
|
-
* The spine specifies the order that the contents of the Epub
|
|
867
|
-
* should be displayed to users by default.
|
|
868
|
-
*
|
|
869
|
-
* @link https://www.w3.org/TR/epub-33/#sec-spine-elem
|
|
870
|
-
*/
|
|
871
|
-
getSpineItems(): Promise<ManifestItem[]>;
|
|
872
|
-
/**
|
|
873
|
-
* Add an item to the spine of the EPUB.
|
|
874
|
-
*
|
|
875
|
-
* If `index` is undefined, the item will be added
|
|
876
|
-
* to the end of the spine. Otherwise it will be
|
|
877
|
-
* inserted at the specified index.
|
|
878
|
-
*
|
|
879
|
-
* If the manifestId does not correspond to an item
|
|
880
|
-
* in the manifest, this will throw an error.
|
|
881
|
-
*
|
|
882
|
-
* @link https://www.w3.org/TR/epub-33/#sec-spine-elem
|
|
883
|
-
*/
|
|
884
|
-
addSpineItem(manifestId: string, index?: number): Promise<void>;
|
|
885
|
-
/**
|
|
886
|
-
* Remove the spine item at the specified index.
|
|
887
|
-
*
|
|
888
|
-
* @link https://www.w3.org/TR/epub-33/#sec-spine-elem
|
|
889
|
-
*/
|
|
890
|
-
removeSpineItem(index: number): Promise<void>;
|
|
891
|
-
private getNavigationChildren;
|
|
892
|
-
private getNavigation;
|
|
893
|
-
/**
|
|
894
|
-
* Returns the structured table of contents navigation document
|
|
895
|
-
* as a Navigation object.
|
|
896
|
-
*
|
|
897
|
-
* @link https://www.w3.org/TR/epub-33/#sec-nav-toc
|
|
898
|
-
*/
|
|
899
|
-
getTableOfContents({ resolveToRoot, }?: {
|
|
900
|
-
resolveToRoot?: boolean;
|
|
901
|
-
}): Promise<Navigation | null>;
|
|
902
|
-
/**
|
|
903
|
-
* Returns the structured landmarks navigation document
|
|
904
|
-
* as a Navigation object
|
|
905
|
-
*
|
|
906
|
-
* @link https://www.w3.org/TR/epub-33/#sec-nav-landmarks
|
|
907
|
-
*/
|
|
908
|
-
getLandmarks({ resolveToRoot, }?: {
|
|
909
|
-
resolveToRoot?: boolean;
|
|
910
|
-
}): Promise<Navigation | null>;
|
|
911
|
-
/**
|
|
912
|
-
* Returns the structured page list navigation document
|
|
913
|
-
* as a Navigation object
|
|
914
|
-
*
|
|
915
|
-
* @link https://www.w3.org/TR/epub-33/#sec-nav-landmarks
|
|
916
|
-
*/
|
|
917
|
-
getPageList({ resolveToRoot, }?: {
|
|
918
|
-
resolveToRoot?: boolean;
|
|
919
|
-
}): Promise<Navigation | null>;
|
|
920
|
-
/**
|
|
921
|
-
* Name the entry a resolved URL addresses.
|
|
922
|
-
*
|
|
923
|
-
* A correctly authored publication percent-encodes its hrefs, so the
|
|
924
|
-
* decoded reading is the one the spec calls for and the one we prefer.
|
|
925
|
-
* Some publications instead write the entry name verbatim, so when the two
|
|
926
|
-
* readings differ we ask the archive which one it holds. A verbatim name
|
|
927
|
-
* carrying a bare `%`, as `100%.xhtml` does, is not a valid encoding at all
|
|
928
|
-
* and can only be its own answer.
|
|
929
|
-
*/
|
|
930
|
-
private entryForUrl;
|
|
931
|
-
/**
|
|
932
|
-
* Resolve an href to the name of the archive entry it addresses.
|
|
933
|
-
*
|
|
934
|
-
* @param from The entry the href appears in; it resolves against that
|
|
935
|
-
* entry's directory
|
|
936
|
-
* @throws when the href addresses something outside the publication
|
|
937
|
-
*/
|
|
938
|
-
private resolveEntry;
|
|
939
|
-
/**
|
|
940
|
-
* Returns a path-relative-scheme-less URL, relative to the
|
|
941
|
-
* container root.
|
|
942
|
-
*
|
|
943
|
-
* An href that points outside the publication, such as an external link in
|
|
944
|
-
* a navigation document, is handed back unchanged.
|
|
945
|
-
*
|
|
946
|
-
* @param href The href to resolve
|
|
947
|
-
* @param [relativeTo] Optional - The href to resolve this href relative to.
|
|
948
|
-
Use if resolving a relative href from a file other than the package document.
|
|
949
|
-
*/
|
|
950
|
-
resolveHref(href: string, relativeTo?: string, { toRoot }?: {
|
|
951
|
-
toRoot?: boolean | undefined;
|
|
952
|
-
}): Promise<string>;
|
|
953
|
-
/**
|
|
954
|
-
* Retrieve the contents of a file, given its href.
|
|
955
|
-
*
|
|
956
|
-
* Optionally takes the href that this href should be resolved relative to,
|
|
957
|
-
* and an encoding parameter.
|
|
958
|
-
*
|
|
959
|
-
* @param href The href of the file to retrieve
|
|
960
|
-
* @param [relitaveTo] Optional - The href to resolve this href relative to.
|
|
961
|
-
* Use if resolving a relative href from a file other than the package document.
|
|
962
|
-
* @param [encoding] Optional - Must be the string "utf-8". If provided,
|
|
963
|
-
* the function will encode the data into a unicode string.
|
|
964
|
-
* Otherwise, the data will be returned as a byte array.
|
|
965
|
-
*/
|
|
966
|
-
readFileContents(href: string, relativeTo?: string): Promise<Uint8Array>;
|
|
967
|
-
readFileContents(href: string, relativeTo: string | undefined, encoding: "utf-8"): Promise<string>;
|
|
968
|
-
/**
|
|
969
|
-
* Retrieve the contents of a manifest item, given its id.
|
|
970
|
-
*
|
|
971
|
-
* @param id The id of the manifest item to retrieve
|
|
972
|
-
* @param [encoding] Optional - must be the string "utf-8". If
|
|
973
|
-
* provided, the function will encode the data into a unicode string.
|
|
974
|
-
* Otherwise, the data will be returned as a byte array.
|
|
975
|
-
*
|
|
976
|
-
* @link https://www.w3.org/TR/epub-33/#sec-contentdocs
|
|
977
|
-
*/
|
|
978
|
-
readItemContents(id: string): Promise<Uint8Array>;
|
|
979
|
-
readItemContents(id: string, encoding: "utf-8"): Promise<string>;
|
|
980
|
-
/**
|
|
981
|
-
* Create a new XHTML document with the given body
|
|
982
|
-
* and head.
|
|
983
|
-
*
|
|
984
|
-
* @param body The XML nodes to place in the body of the document
|
|
985
|
-
* @param head Optional - the XMl nodes to place in the head
|
|
986
|
-
* @param language Optional - defaults to the EPUB's language
|
|
987
|
-
*/
|
|
988
|
-
createXhtmlDocument(body: ParsedXml, head?: ParsedXml, language?: Intl.Locale): Promise<(XmlElement<"?xml"> | XmlElement<"html">)[]>;
|
|
989
|
-
/**
|
|
990
|
-
* Retrieves the contents of an XHTML item, given its manifest id.
|
|
991
|
-
*
|
|
992
|
-
* @param id The id of the manifest item to retrieve
|
|
993
|
-
* @param [as] Optional - whether to return the parsed XML document tree,
|
|
994
|
-
* or the concatenated text of the document. Defaults to the parsed XML tree.
|
|
995
|
-
*
|
|
996
|
-
* @link https://www.w3.org/TR/epub-33/#sec-xhtml
|
|
997
|
-
*/
|
|
998
|
-
readXhtmlItemContents(id: string, as?: "xhtml"): Promise<ParsedXml>;
|
|
999
|
-
readXhtmlItemContents(id: string, as: "text"): Promise<string>;
|
|
1000
|
-
private writeEntryContents;
|
|
1001
|
-
/**
|
|
1002
|
-
* Write new contents for an existing manifest item,
|
|
1003
|
-
* specified by its id.
|
|
1004
|
-
*
|
|
1005
|
-
* The id must reference an existing manifest item. If
|
|
1006
|
-
* creating a new item, use `epub.addManifestItem()` instead.
|
|
1007
|
-
*
|
|
1008
|
-
* @param id The id of the manifest item to write new contents for
|
|
1009
|
-
* @param contents The new contents. May be either a utf-8 encoded string
|
|
1010
|
-
* or a byte array, as determined by the encoding
|
|
1011
|
-
* @param [encoding] Optional - must be the string "utf-8". If provided,
|
|
1012
|
-
* the contents will be interpreted as a unicode string. Otherwise, the
|
|
1013
|
-
* contents must be a byte array.
|
|
1014
|
-
*
|
|
1015
|
-
* @link https://www.w3.org/TR/epub-33/#sec-contentdocs
|
|
1016
|
-
*/
|
|
1017
|
-
writeItemContents(id: string, contents: Uint8Array): Promise<void>;
|
|
1018
|
-
writeItemContents(id: string, contents: string, encoding: "utf-8"): Promise<void>;
|
|
1019
|
-
/**
|
|
1020
|
-
* Write new contents for an existing XHTML item,
|
|
1021
|
-
* specified by its id.
|
|
1022
|
-
*
|
|
1023
|
-
* The id must reference an existing manifest item. If
|
|
1024
|
-
* creating a new item, use `epub.addManifestItem()` instead.
|
|
1025
|
-
*
|
|
1026
|
-
* @param id The id of the manifest item to write new contents for
|
|
1027
|
-
* @param contents The new contents. Must be a parsed XML tree.
|
|
1028
|
-
*
|
|
1029
|
-
* @link https://www.w3.org/TR/epub-33/#sec-xhtml
|
|
1030
|
-
*/
|
|
1031
|
-
writeXhtmlItemContents(id: string, contents: ParsedXml): Promise<void>;
|
|
1032
|
-
removeManifestItem(id: string): Promise<void>;
|
|
1033
|
-
/**
|
|
1034
|
-
* Create a new manifest item and write its contents to a
|
|
1035
|
-
* new entry.
|
|
1036
|
-
*
|
|
1037
|
-
* @param id The id of the manifest item to write new contents for
|
|
1038
|
-
* @param contents The new contents. May be either a parsed XML tree
|
|
1039
|
-
* or a unicode string, as determined by the `as` argument.
|
|
1040
|
-
* @param encoding Optional - whether to interpret contents as a parsed
|
|
1041
|
-
* XML tree, a unicode string, or a byte array. Defaults to a byte array.
|
|
1042
|
-
*
|
|
1043
|
-
* @link https://www.w3.org/TR/epub-33/#sec-pkg-manifest
|
|
1044
|
-
* @link https://www.w3.org/TR/epub-33/#sec-contentdocs
|
|
1045
|
-
*/
|
|
1046
|
-
addManifestItem(item: ManifestItem, contents: ParsedXml, encoding: "xml"): Promise<void>;
|
|
1047
|
-
addManifestItem(item: ManifestItem, contents: string, encoding: "utf-8"): Promise<void>;
|
|
1048
|
-
addManifestItem(item: ManifestItem, contents: Uint8Array): Promise<void>;
|
|
1049
|
-
/**
|
|
1050
|
-
* Update the manifest entry for an existing item.
|
|
1051
|
-
*
|
|
1052
|
-
* To update the contents of an entry, use `epub.writeItemContents()`
|
|
1053
|
-
* or `epub.writeXhtmlItemContents()`
|
|
1054
|
-
*
|
|
1055
|
-
* @link https://www.w3.org/TR/epub-33/#sec-pkg-manifest
|
|
1056
|
-
*/
|
|
1057
|
-
updateManifestItem(id: string, newItem: Omit<ManifestItem, "id">): Promise<void>;
|
|
1058
|
-
/**
|
|
1059
|
-
* Add a new metadata entry to the Epub.
|
|
1060
|
-
*
|
|
1061
|
-
* This method, like `epub.getMetadata()`, operates on
|
|
1062
|
-
* metadata entries. For more useful semantic representations
|
|
1063
|
-
* of metadata, use specific methods such as `setTitle()` and
|
|
1064
|
-
* `setLanguage()`.
|
|
1065
|
-
*
|
|
1066
|
-
* @link https://www.w3.org/TR/epub-33/#sec-pkg-metadata
|
|
1067
|
-
*/
|
|
1068
|
-
addMetadata(entry: MetadataEntry): Promise<void>;
|
|
1069
|
-
/**
|
|
1070
|
-
* Replace a metadata entry with a new one.
|
|
1071
|
-
*
|
|
1072
|
-
* The `predicate` argument will be used to determine which entry
|
|
1073
|
-
* to replace. The first metadata entry that matches the
|
|
1074
|
-
* predicate will be replaced.
|
|
1075
|
-
*
|
|
1076
|
-
* @param predicate Calls predicate once for each metadata entry,
|
|
1077
|
-
* until it finds one where predicate returns true
|
|
1078
|
-
* @param entry The new entry to replace the found entry with
|
|
1079
|
-
*
|
|
1080
|
-
* @link https://www.w3.org/TR/epub-33/#sec-pkg-metadata
|
|
1081
|
-
*/
|
|
1082
|
-
replaceMetadata(predicate: (entry: MetadataEntry) => boolean, entry: MetadataEntry): Promise<void>;
|
|
1083
|
-
/**
|
|
1084
|
-
* Remove one or more metadata entries.
|
|
1085
|
-
*
|
|
1086
|
-
* The `predicate` argument will be used to determine which entries
|
|
1087
|
-
* to remove. The all metadata entries that match the
|
|
1088
|
-
* predicate will be removed.
|
|
1089
|
-
*
|
|
1090
|
-
* @param predicate Calls predicate once for each metadata entry,
|
|
1091
|
-
* removing any for which it returns true
|
|
1092
|
-
*
|
|
1093
|
-
* @link https://www.w3.org/TR/epub-33/#sec-pkg-metadata
|
|
1094
|
-
*/
|
|
1095
|
-
removeMetadata(predicate: (entry: MetadataEntry) => boolean): Promise<void>;
|
|
1096
|
-
/**
|
|
1097
|
-
* Returns the EPUB version declared on the package element.
|
|
1098
|
-
*/
|
|
1099
|
-
getVersion(): Promise<string>;
|
|
1100
|
-
/**
|
|
1101
|
-
* Parse the NCX table of contents, if one exists, and return
|
|
1102
|
-
* a tree of TocEntry nodes.
|
|
1103
|
-
*
|
|
1104
|
-
* Useful for both EPUB 2 publications (where the NCX is the
|
|
1105
|
-
* primary navigation) and EPUB 3 publications that retain an
|
|
1106
|
-
* NCX for backwards compatibility.
|
|
1107
|
-
*/
|
|
1108
|
-
getNcxTableOfContents(): Promise<NavigationList>;
|
|
1109
|
-
private parseNavPoints;
|
|
1110
|
-
/**
|
|
1111
|
-
* Retrieve the guide entries from the package document.
|
|
1112
|
-
*
|
|
1113
|
-
* The guide element is deprecated in EPUB 3 in favor of
|
|
1114
|
-
* the landmarks nav, but many publications still include it.
|
|
1115
|
-
*/
|
|
1116
|
-
getGuideEntries(): Promise<GuideItem[]>;
|
|
1117
|
-
discardAndClose(): void;
|
|
1118
|
-
/**
|
|
1119
|
-
* Write the current contents of the Epub to a new
|
|
1120
|
-
* EPUB archive on disk.
|
|
1121
|
-
*
|
|
1122
|
-
* When this method is called, the "dcterms:modified"
|
|
1123
|
-
* meta tag is automatically updated to the current UTC
|
|
1124
|
-
* timestamp.
|
|
1125
|
-
*/
|
|
1126
|
-
saveAndClose(): Promise<void>;
|
|
1127
|
-
/**
|
|
1128
|
-
* Upgrade an EPUB 2 publication to EPUB 3 in place, returning a new,
|
|
1129
|
-
* valid Epub 3 instance. Equivalent to
|
|
1130
|
-
* `Epub.using(TmpFsAdapter).upgrade(...)`.
|
|
1131
|
-
*/
|
|
1132
|
-
static upgrade(path: string, options?: Epub2UpgradeOptions): Promise<Epub>;
|
|
1133
|
-
[Symbol.dispose](): void;
|
|
1134
|
-
}
|
|
1135
|
-
/**
|
|
1136
|
-
* Resolves to {@link Epub} for writable adapters, {@link EpubReader} for read-only ones.
|
|
1137
|
-
*
|
|
1138
|
-
* The conditional pivots on `capabilities.writable`, which must be a literal
|
|
1139
|
-
* `true`/`false` on the adapter class (use `as const`) for inference to work.
|
|
1140
|
-
*/
|
|
1141
|
-
type EpubInstanceFor<A extends EpubStorageAdapterClass> = A["capabilities"]["writable"] extends true ? Epub : EpubReader;
|
|
1142
|
-
/**
|
|
1143
|
-
* Adapter-bound factory returned by {@link Epub.using}.
|
|
1144
|
-
*
|
|
1145
|
-
* Mirrors the static factory surface (`from`, `create`, `upgrade`) but routes
|
|
1146
|
-
* all I/O through the supplied adapter. Each method's signature degrades
|
|
1147
|
-
* gracefully when the adapter doesn't support the operation: `create` and
|
|
1148
|
-
* `upgrade` throw at runtime if the adapter is read-only or lacks `initEmpty`.
|
|
1149
|
-
*/
|
|
1150
|
-
declare class EpubFactory<A extends EpubStorageAdapterClass> {
|
|
1151
|
-
readonly adapterClass: A;
|
|
1152
|
-
constructor(adapterClass: A);
|
|
1153
|
-
/**
|
|
1154
|
-
* Open an existing EPUB through this factory's adapter
|
|
1155
|
-
*
|
|
1156
|
-
* @throws {EpubVersionError} when the archive is not a valid EPUB 3
|
|
1157
|
-
*/
|
|
1158
|
-
from(source: string | Uint8Array, options: FromOptions & {
|
|
1159
|
-
readonly: true;
|
|
1160
|
-
} & AdapterOptions<A>): Promise<EpubReader & {
|
|
1161
|
-
storage: A["kind"];
|
|
1162
|
-
}>;
|
|
1163
|
-
from(source: string | Uint8Array, options?: FromOptions & AdapterOptions<A>): Promise<EpubInstanceFor<A> & {
|
|
1164
|
-
storage: A["kind"];
|
|
1165
|
-
}>;
|
|
1166
|
-
/**
|
|
1167
|
-
* Construct a new EPUB on this factory's adapter, optionally seeded
|
|
1168
|
-
* with the provided metadata. Requires a writable adapter that
|
|
1169
|
-
* implements `initEmpty` (today: {@link TmpFsAdapter}).
|
|
1170
|
-
*
|
|
1171
|
-
* @throws when the adapter is read-only or does not implement initEmpty
|
|
1172
|
-
*/
|
|
1173
|
-
create(path: string, { title, language, identifier, date, subjects, type, creators, contributors, }: DublinCore, additionalMetadata?: EpubMetadata): Promise<EpubInstanceFor<A>>;
|
|
1174
|
-
/**
|
|
1175
|
-
* Upgrade an EPUB 2 publication to EPUB 3 in place using this
|
|
1176
|
-
* factory's adapter, returning a new, valid Epub 3 instance.
|
|
1177
|
-
*
|
|
1178
|
-
* Performs the following transformations:
|
|
1179
|
-
* - upgrades OPF metadata to EPUB 3 conventions
|
|
1180
|
-
* - scans XHTML documents and adds manifest item properties
|
|
1181
|
-
* - parses the NCX into a TOC tree and generates a nav.xhtml
|
|
1182
|
-
* - removes the NCX file and the guide element (configurable)
|
|
1183
|
-
* - fixes common font MIME types
|
|
1184
|
-
* - bumps the package version to 3.0
|
|
1185
|
-
* - goes over each xhtml item and rewrites it using XMLParser to make sure the output is valid XHTML
|
|
1186
|
-
*
|
|
1187
|
-
* Requires a writable adapter. When {@link Upgrade.Epub2UpgradeOptions.outputPath}
|
|
1188
|
-
* is set, the source file is copied to that path on disk first; this
|
|
1189
|
-
* only makes sense for adapters whose `source` is a real fs path.
|
|
1190
|
-
*
|
|
1191
|
-
* @throws when the adapter is read-only
|
|
1192
|
-
*/
|
|
1193
|
-
upgrade(path: string, options?: Epub2UpgradeOptions): Promise<EpubInstanceFor<A>>;
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
export { type AlternateScript as A, type Collection as C, type DcSubject as D, type ElementName as E, type Epub2UpgradeOptions, type FromOptions as F, type InMemoryEpubReader as I, type Landmark, type ManifestItem as M, type NavigationItem as N, type ParsedXml as P, type XmlElement as X, type XmlTextNode as a, type XmlNode as b, buildNavDocument, buildTocOl, type MetadataEntry as c, chooseNavHref, collectManifestProperties, type EpubMetadata as d, type EpubIdentifier as e, extractGuideLandmarks, type EpubSource as f, fixFontMimeTypes, type DcCreator as g, type DublinCore as h, type NavigationList as i, type Navigation as j, type PackageElement as k, type EpubReader as l, EpubVersionError as m, EpubReadOnlyError as n, Epub as o, type EpubInstanceFor as p, EpubFactory as q, removeGuide, removeInvalidDcAttrs, removeNcx, removeSpineTocRef, setLastModified, setPackageVersion, upgradeAuthors, upgradeCover, upgradeDate, upgradeIdentifiers, upgradeLanguages, upgradeMeta, upgradePackageMetadata, upgradeTitle };
|
|
17
|
+
export declare function upgradeIdentifiers(pkg: PackageElement): void;
|
|
18
|
+
export declare function upgradeTitle(pkg: PackageElement): void;
|
|
19
|
+
export declare function upgradeLanguages(pkg: PackageElement): void;
|
|
20
|
+
export declare function upgradeAuthors(pkg: PackageElement): void;
|
|
21
|
+
export declare function upgradeDate(pkg: PackageElement): void;
|
|
22
|
+
export declare function upgradeMeta(pkg: PackageElement): void;
|
|
23
|
+
export declare function upgradeCover(pkg: PackageElement): void;
|
|
24
|
+
export declare function removeInvalidDcAttrs(pkg: PackageElement): void;
|
|
25
|
+
export declare function setLastModified(pkg: PackageElement): void;
|
|
26
|
+
export declare function upgradePackageMetadata(pkg: PackageElement): void;
|
|
27
|
+
export declare function extractGuideLandmarks(pkg: PackageElement): Landmark[];
|
|
28
|
+
export declare function removeGuide(pkg: PackageElement): void;
|
|
29
|
+
export declare function removeSpineTocRef(pkg: PackageElement): void;
|
|
30
|
+
export declare function collectManifestProperties(epub: Epub): Promise<void>;
|
|
31
|
+
export declare function fixFontMimeTypes(pkg: PackageElement): void;
|
|
32
|
+
export declare function buildTocOl(entries: NavigationItem[]): XmlElement<"ol">;
|
|
33
|
+
export declare function buildNavDocument(epub: Epub, tocEntries: NavigationItem[], landmarks: Landmark[]): Promise<string>;
|
|
34
|
+
export declare function setPackageVersion(pkg: PackageElement, version: string): void;
|
|
35
|
+
export declare function chooseNavHref(epub: Epub): Promise<string>;
|
|
36
|
+
export declare function removeNcx(epub: Epub): Promise<void>;
|