@epubook/core 0.0.11 → 0.0.12-beta.2
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 +6 -26
- package/dist/index.d.mts +235 -0
- package/dist/index.mjs +478 -556
- package/package.json +12 -17
- package/dist/chunks/index.cjs +0 -190
- package/dist/chunks/index.mjs +0 -171
- package/dist/index.cjs +0 -607
- package/dist/index.d.ts +0 -274
package/dist/index.d.ts
DELETED
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import { Plugin } from 'rollup';
|
|
2
|
-
import { BuildConfig } from 'unbuild';
|
|
3
|
-
|
|
4
|
-
declare const MIMETYPE = "application/epub+zip";
|
|
5
|
-
declare const ImageGif = "image/gif";
|
|
6
|
-
declare const ImageJpeg = "image/jpeg";
|
|
7
|
-
declare const ImagePng = "image/png";
|
|
8
|
-
declare const ImageSvg = "image/svg+xml";
|
|
9
|
-
declare const ImageWebp = "image/webp";
|
|
10
|
-
type ImageMediaType = typeof ImageGif | typeof ImageJpeg | typeof ImagePng | typeof ImageSvg | typeof ImageWebp;
|
|
11
|
-
type ImageExtension = 'gif' | 'jpg' | 'jpeg' | 'png' | 'svg' | 'webp';
|
|
12
|
-
declare const TextCSS = "text/css";
|
|
13
|
-
declare const TextXHTML = "application/xhtml+xml";
|
|
14
|
-
type MediaType = ImageMediaType | typeof TextCSS | typeof TextXHTML;
|
|
15
|
-
declare function getImageMediaType(file: string): ImageMediaType | undefined;
|
|
16
|
-
|
|
17
|
-
declare class ManifestItem {
|
|
18
|
-
private _href;
|
|
19
|
-
private _id;
|
|
20
|
-
private optional;
|
|
21
|
-
constructor(href: string, id: string);
|
|
22
|
-
update(info: typeof this$1.optional): this;
|
|
23
|
-
href(): string;
|
|
24
|
-
id(): string;
|
|
25
|
-
fallback(): string | undefined;
|
|
26
|
-
mediaOverlay(): string | undefined;
|
|
27
|
-
mediaType(): MediaType | undefined;
|
|
28
|
-
properties(): string | undefined;
|
|
29
|
-
ref(): ManifestItemRef;
|
|
30
|
-
}
|
|
31
|
-
declare class ManifestItemRef {
|
|
32
|
-
private _idref;
|
|
33
|
-
private optional;
|
|
34
|
-
constructor(idref: string);
|
|
35
|
-
update(info: typeof this$1.optional): this;
|
|
36
|
-
idref(): string;
|
|
37
|
-
id(): string | undefined;
|
|
38
|
-
linear(): string | undefined;
|
|
39
|
-
properties(): string | undefined;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
declare abstract class Item {
|
|
43
|
-
private readonly file;
|
|
44
|
-
private readonly mediaType;
|
|
45
|
-
private _properties?;
|
|
46
|
-
constructor(file: string, mediaType: MediaType);
|
|
47
|
-
filename(): string;
|
|
48
|
-
relative(from: string): string;
|
|
49
|
-
update(info: Partial<{
|
|
50
|
-
properties: string;
|
|
51
|
-
}>): this;
|
|
52
|
-
id(): string;
|
|
53
|
-
manifest(): ManifestItem;
|
|
54
|
-
itemref(): ManifestItemRef;
|
|
55
|
-
abstract bundle(): Promise<Uint8Array>;
|
|
56
|
-
}
|
|
57
|
-
declare class Style extends Item {
|
|
58
|
-
private content;
|
|
59
|
-
constructor(file: string, content: string);
|
|
60
|
-
static read(src: string, dst: string): Promise<Style | undefined>;
|
|
61
|
-
bundle(): Promise<Uint8Array>;
|
|
62
|
-
}
|
|
63
|
-
declare class Image extends Item {
|
|
64
|
-
private data;
|
|
65
|
-
constructor(file: string, type: ImageMediaType, data: Uint8Array);
|
|
66
|
-
static read(file: string, src: string): Promise<Image | undefined>;
|
|
67
|
-
bundle(): Promise<Uint8Array>;
|
|
68
|
-
}
|
|
69
|
-
declare class HTML extends Item {
|
|
70
|
-
private content;
|
|
71
|
-
constructor(file: string, content: string);
|
|
72
|
-
static read(src: string, dst: string): Promise<HTML | undefined>;
|
|
73
|
-
bundle(): Promise<Uint8Array>;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
type Prettify<T> = {
|
|
77
|
-
[K in keyof T]: T[K];
|
|
78
|
-
} & {};
|
|
79
|
-
|
|
80
|
-
declare global {
|
|
81
|
-
namespace JSX {
|
|
82
|
-
interface IntrinsicElements extends EpubIntrinsicElements {
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
interface XHTMLNode {
|
|
87
|
-
tag: string;
|
|
88
|
-
attrs?: Record<string, string>;
|
|
89
|
-
children?: Array<string | XHTMLNode>;
|
|
90
|
-
}
|
|
91
|
-
interface BaseElementAttrs {
|
|
92
|
-
class?: string;
|
|
93
|
-
id?: string;
|
|
94
|
-
html?: string;
|
|
95
|
-
}
|
|
96
|
-
interface EpubIntrinsicElements {
|
|
97
|
-
div: BaseElementAttrs & {};
|
|
98
|
-
nav: BaseElementAttrs & {};
|
|
99
|
-
ul: BaseElementAttrs & {};
|
|
100
|
-
ol: BaseElementAttrs & {};
|
|
101
|
-
li: BaseElementAttrs & {};
|
|
102
|
-
h1: BaseElementAttrs & {};
|
|
103
|
-
h2: BaseElementAttrs & {};
|
|
104
|
-
h3: BaseElementAttrs & {};
|
|
105
|
-
h4: BaseElementAttrs & {};
|
|
106
|
-
h5: BaseElementAttrs & {};
|
|
107
|
-
h6: BaseElementAttrs & {};
|
|
108
|
-
p: BaseElementAttrs & {};
|
|
109
|
-
pre: BaseElementAttrs & {};
|
|
110
|
-
span: BaseElementAttrs & {};
|
|
111
|
-
code: BaseElementAttrs & {};
|
|
112
|
-
a: BaseElementAttrs & {
|
|
113
|
-
href: string;
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
declare const Fragment = "Fragment";
|
|
118
|
-
declare function h(tag: string, attrs?: Record<string, string>, ...children: Array<string | XHTMLNode | Array<string | XHTMLNode>>): {
|
|
119
|
-
tag: string;
|
|
120
|
-
attrs: Record<string, string>;
|
|
121
|
-
children: (string | XHTMLNode)[];
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
interface HTMLMeta {
|
|
125
|
-
language: string;
|
|
126
|
-
title: string;
|
|
127
|
-
}
|
|
128
|
-
declare class XHTML extends Item {
|
|
129
|
-
private _meta;
|
|
130
|
-
private _content;
|
|
131
|
-
constructor(file: string, meta: HTMLMeta, content: string);
|
|
132
|
-
meta(): HTMLMeta;
|
|
133
|
-
title(): string;
|
|
134
|
-
language(): string;
|
|
135
|
-
content(): string;
|
|
136
|
-
bundle(): Promise<Uint8Array>;
|
|
137
|
-
}
|
|
138
|
-
declare class XHTMLBuilder {
|
|
139
|
-
private _meta;
|
|
140
|
-
private _filename;
|
|
141
|
-
private _head;
|
|
142
|
-
private _body;
|
|
143
|
-
private _bodyAttrs;
|
|
144
|
-
constructor(filename: string);
|
|
145
|
-
language(value: string): this;
|
|
146
|
-
title(value: string): this;
|
|
147
|
-
style(...list: Array<string | Style>): this;
|
|
148
|
-
head(...node: XHTMLNode[]): this;
|
|
149
|
-
body(...node: XHTMLNode[]): this;
|
|
150
|
-
bodyAttrs(attrs?: Record<string, string>): this;
|
|
151
|
-
build(): XHTML;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
type NavItem = {
|
|
155
|
-
title: string;
|
|
156
|
-
attrs?: Record<string, string>;
|
|
157
|
-
};
|
|
158
|
-
type NavLink = Prettify<NavItem & {
|
|
159
|
-
page: HTML | XHTML;
|
|
160
|
-
}>;
|
|
161
|
-
type NavSubList = Prettify<NavItem & {
|
|
162
|
-
list: NavLink[];
|
|
163
|
-
}>;
|
|
164
|
-
type NavList = Array<NavLink | NavSubList>;
|
|
165
|
-
interface NavOption {
|
|
166
|
-
title: string;
|
|
167
|
-
heading: 1 | 2 | 3 | 4 | 5 | 6;
|
|
168
|
-
titleAttrs: Record<string, string>;
|
|
169
|
-
builder?: XHTMLBuilder;
|
|
170
|
-
}
|
|
171
|
-
declare class Toc extends XHTML {
|
|
172
|
-
constructor(file: string, meta: HTMLMeta, content: string);
|
|
173
|
-
static from(xhtml: XHTML): Toc;
|
|
174
|
-
static generate(file: string, nav: NavList, { title, heading, titleAttrs, builder }?: Partial<NavOption>): XHTMLBuilder;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
interface Author {
|
|
178
|
-
name: string;
|
|
179
|
-
fileAs?: string;
|
|
180
|
-
role?: string;
|
|
181
|
-
uid?: string;
|
|
182
|
-
}
|
|
183
|
-
interface PackageDocumentMeta {
|
|
184
|
-
title: string;
|
|
185
|
-
language: string;
|
|
186
|
-
contributor: Author[];
|
|
187
|
-
coverage: string;
|
|
188
|
-
creator: Author;
|
|
189
|
-
date: Date;
|
|
190
|
-
description: string;
|
|
191
|
-
format: string;
|
|
192
|
-
publisher: string;
|
|
193
|
-
relation: string;
|
|
194
|
-
rights: string;
|
|
195
|
-
source: string;
|
|
196
|
-
subject: string;
|
|
197
|
-
type: string;
|
|
198
|
-
lastModified: Date;
|
|
199
|
-
}
|
|
200
|
-
declare class PackageDocument {
|
|
201
|
-
private readonly file;
|
|
202
|
-
private readonly SpecVersion;
|
|
203
|
-
private _uniqueIdentifier;
|
|
204
|
-
private _identifier;
|
|
205
|
-
private _metadata;
|
|
206
|
-
private _toc;
|
|
207
|
-
private _items;
|
|
208
|
-
private _spine;
|
|
209
|
-
constructor(file: string);
|
|
210
|
-
filename(): string;
|
|
211
|
-
version(): "3.0";
|
|
212
|
-
update(info: Partial<PackageDocumentMeta>): this;
|
|
213
|
-
title(): string;
|
|
214
|
-
language(): string;
|
|
215
|
-
creator(): Author;
|
|
216
|
-
metadata(): PackageDocumentMeta;
|
|
217
|
-
addItem(item: Item): this;
|
|
218
|
-
items(): Item[];
|
|
219
|
-
manifest(): ManifestItem[];
|
|
220
|
-
spine(): ManifestItemRef[];
|
|
221
|
-
setSpine(items: Item[]): this;
|
|
222
|
-
toc(): Toc | undefined;
|
|
223
|
-
setToc(nav: NavList, option?: Partial<NavOption>): this;
|
|
224
|
-
uniqueIdentifier(): string;
|
|
225
|
-
identifier(): string;
|
|
226
|
-
setIdentifier(identifier: string, uniqueIdentifier?: string): void;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
declare class Epub {
|
|
230
|
-
/**
|
|
231
|
-
* See: https://www.w3.org/TR/epub-33/#sec-package-doc
|
|
232
|
-
*
|
|
233
|
-
* Now, it only supports single opf (OEBPS/content.opf)
|
|
234
|
-
*
|
|
235
|
-
* @returns list of package documents
|
|
236
|
-
*/
|
|
237
|
-
private opfs;
|
|
238
|
-
constructor(meta?: Partial<PackageDocumentMeta>);
|
|
239
|
-
packages(): PackageDocument[];
|
|
240
|
-
main(): PackageDocument;
|
|
241
|
-
item(...items: Item[]): this;
|
|
242
|
-
toc(nav: NavList, option?: Partial<NavOption>): this;
|
|
243
|
-
spine(...items: Item[]): this;
|
|
244
|
-
bundle(): Promise<Uint8Array>;
|
|
245
|
-
writeFile(file: string): Promise<void>;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
declare class BundleError extends Error {
|
|
249
|
-
constructor(msg: string);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
type PageTemplate<T = any> = (file: string, props: T) => XHTMLBuilder;
|
|
253
|
-
interface Theme<P extends Record<string, PageTemplate<any>>> {
|
|
254
|
-
name: string;
|
|
255
|
-
styles: string[];
|
|
256
|
-
images: string[];
|
|
257
|
-
pages: Prettify<{
|
|
258
|
-
cover(file: string, props: {
|
|
259
|
-
image: Image;
|
|
260
|
-
title?: string;
|
|
261
|
-
}): XHTMLBuilder;
|
|
262
|
-
nav(file: string, props: {
|
|
263
|
-
nav: NavList;
|
|
264
|
-
option: Partial<NavOption>;
|
|
265
|
-
}): XHTMLBuilder;
|
|
266
|
-
} & P>;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
declare const UnbuildPreset: (options?: {
|
|
270
|
-
inject?: boolean;
|
|
271
|
-
}) => BuildConfig;
|
|
272
|
-
declare function Rollup(): Plugin;
|
|
273
|
-
|
|
274
|
-
export { Author, BundleError, Epub, EpubIntrinsicElements, Fragment, HTML, HTMLMeta, Image, ImageExtension, ImageGif, ImageJpeg, ImageMediaType, ImagePng, ImageSvg, ImageWebp, Item, MIMETYPE, ManifestItem, ManifestItemRef, MediaType, NavList, NavOption, PackageDocument, PackageDocumentMeta, PageTemplate, Rollup, Style, TextCSS, TextXHTML, Theme, Toc, UnbuildPreset, XHTML, XHTMLBuilder, XHTMLNode, getImageMediaType, h };
|