@epubook/core 0.0.9 → 0.0.11
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/chunks/index.cjs +4 -3
- package/dist/index.cjs +5 -10
- package/dist/index.d.ts +244 -244
- package/dist/index.mjs +1 -7
- package/package.json +7 -7
package/dist/chunks/index.cjs
CHANGED
|
@@ -9,7 +9,8 @@ require('node:crypto');
|
|
|
9
9
|
require('defu');
|
|
10
10
|
require('node:fs');
|
|
11
11
|
|
|
12
|
-
function
|
|
12
|
+
function _interopNamespaceCompat(e) {
|
|
13
|
+
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
13
14
|
const n = Object.create(null);
|
|
14
15
|
if (e) {
|
|
15
16
|
for (const k in e) {
|
|
@@ -20,8 +21,8 @@ function _interopNamespaceDefault(e) {
|
|
|
20
21
|
return n;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
const path__namespace = /*#__PURE__*/
|
|
24
|
-
const fflate__namespace = /*#__PURE__*/
|
|
24
|
+
const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
|
|
25
|
+
const fflate__namespace = /*#__PURE__*/_interopNamespaceCompat(fflate);
|
|
25
26
|
|
|
26
27
|
function toISO8601String(date) {
|
|
27
28
|
function pad(n) {
|
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,8 @@ const fflate = require('fflate');
|
|
|
8
8
|
const fastXmlParser = require('fast-xml-parser');
|
|
9
9
|
const node_fs = require('node:fs');
|
|
10
10
|
|
|
11
|
-
function
|
|
11
|
+
function _interopNamespaceCompat(e) {
|
|
12
|
+
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
12
13
|
const n = Object.create(null);
|
|
13
14
|
if (e) {
|
|
14
15
|
for (const k in e) {
|
|
@@ -19,8 +20,8 @@ function _interopNamespaceDefault(e) {
|
|
|
19
20
|
return n;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
const path__namespace = /*#__PURE__*/
|
|
23
|
-
const path__namespace$1 = /*#__PURE__*/
|
|
23
|
+
const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
|
|
24
|
+
const path__namespace$1 = /*#__PURE__*/_interopNamespaceCompat(path$1);
|
|
24
25
|
|
|
25
26
|
const Fragment = "Fragment";
|
|
26
27
|
function h(tag, attrs = {}, ...children) {
|
|
@@ -555,13 +556,7 @@ const UnbuildPreset = ({
|
|
|
555
556
|
rollup: {
|
|
556
557
|
esbuild: {
|
|
557
558
|
jsxFactory: inject ? "__epubook_core.h" : "h",
|
|
558
|
-
jsxFragment: inject ? "__epubook_core.Fragment" : "Fragment"
|
|
559
|
-
loaders: {
|
|
560
|
-
".js": "js",
|
|
561
|
-
".ts": "ts",
|
|
562
|
-
".jsx": "jsx",
|
|
563
|
-
".tsx": "tsx"
|
|
564
|
-
}
|
|
559
|
+
jsxFragment: inject ? "__epubook_core.Fragment" : "Fragment"
|
|
565
560
|
}
|
|
566
561
|
},
|
|
567
562
|
hooks: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,274 +1,274 @@
|
|
|
1
1
|
import { Plugin } from 'rollup';
|
|
2
2
|
import { BuildConfig } from 'unbuild';
|
|
3
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;
|
|
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
15
|
declare function getImageMediaType(file: string): ImageMediaType | undefined;
|
|
16
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;
|
|
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
40
|
}
|
|
41
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>;
|
|
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
74
|
}
|
|
75
75
|
|
|
76
|
-
type Prettify<T> = {
|
|
77
|
-
[K in keyof T]: T[K];
|
|
76
|
+
type Prettify<T> = {
|
|
77
|
+
[K in keyof T]: T[K];
|
|
78
78
|
} & {};
|
|
79
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
|
-
};
|
|
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
115
|
}
|
|
116
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)[];
|
|
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
122
|
};
|
|
123
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;
|
|
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
152
|
}
|
|
153
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;
|
|
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
175
|
}
|
|
176
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;
|
|
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
227
|
}
|
|
228
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>;
|
|
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
246
|
}
|
|
247
247
|
|
|
248
|
-
declare class BundleError extends Error {
|
|
249
|
-
constructor(msg: string);
|
|
248
|
+
declare class BundleError extends Error {
|
|
249
|
+
constructor(msg: string);
|
|
250
250
|
}
|
|
251
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>;
|
|
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
267
|
}
|
|
268
268
|
|
|
269
|
-
declare const UnbuildPreset: (options?: {
|
|
270
|
-
inject?: boolean;
|
|
271
|
-
}) => BuildConfig;
|
|
269
|
+
declare const UnbuildPreset: (options?: {
|
|
270
|
+
inject?: boolean;
|
|
271
|
+
}) => BuildConfig;
|
|
272
272
|
declare function Rollup(): Plugin;
|
|
273
273
|
|
|
274
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -539,13 +539,7 @@ const UnbuildPreset = ({
|
|
|
539
539
|
rollup: {
|
|
540
540
|
esbuild: {
|
|
541
541
|
jsxFactory: inject ? "__epubook_core.h" : "h",
|
|
542
|
-
jsxFragment: inject ? "__epubook_core.Fragment" : "Fragment"
|
|
543
|
-
loaders: {
|
|
544
|
-
".js": "js",
|
|
545
|
-
".ts": "ts",
|
|
546
|
-
".jsx": "jsx",
|
|
547
|
-
".tsx": "tsx"
|
|
548
|
-
}
|
|
542
|
+
jsxFragment: inject ? "__epubook_core.Fragment" : "Fragment"
|
|
549
543
|
}
|
|
550
544
|
},
|
|
551
545
|
hooks: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epubook/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ebook",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"defu": "^6.1.2",
|
|
37
|
-
"fast-xml-parser": "^4.
|
|
38
|
-
"fflate": "^0.
|
|
39
|
-
"pathe": "^1.1.
|
|
37
|
+
"fast-xml-parser": "^4.2.7",
|
|
38
|
+
"fflate": "^0.8.0",
|
|
39
|
+
"pathe": "^1.1.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"rollup": "^3.
|
|
43
|
-
"vitest": "^0.
|
|
42
|
+
"rollup": "^3.27.2",
|
|
43
|
+
"vitest": "^0.33.0"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
|
-
"node": ">=v18.
|
|
46
|
+
"node": ">=v18.16.0"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "unbuild",
|