@storyteller-platform/audiobook 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bufferEntry.cjs +59 -0
- package/dist/bufferEntry.d.cts +16 -0
- package/dist/bufferEntry.d.ts +16 -0
- package/dist/bufferEntry.js +35 -0
- package/dist/entry.cjs +259 -28
- package/dist/entry.d.cts +31 -11
- package/dist/entry.d.ts +31 -11
- package/dist/entry.js +273 -28
- package/dist/ffmpeg.cjs +84 -0
- package/dist/ffmpeg.d.cts +11 -0
- package/dist/ffmpeg.d.ts +11 -0
- package/dist/ffmpeg.js +58 -0
- package/dist/fileEntry.cjs +58 -0
- package/dist/fileEntry.d.cts +16 -0
- package/dist/fileEntry.d.ts +16 -0
- package/dist/fileEntry.js +34 -0
- package/dist/index.cjs +281 -35
- package/dist/index.d.cts +67 -11
- package/dist/index.d.ts +67 -11
- package/dist/index.js +269 -35
- package/dist/resources.cjs +16 -0
- package/dist/resources.d.cts +14 -0
- package/dist/resources.d.ts +14 -0
- package/dist/resources.js +0 -0
- package/dist/tagMaps.cjs +120 -0
- package/dist/tagMaps.d.cts +24 -0
- package/dist/tagMaps.d.ts +24 -0
- package/dist/tagMaps.js +95 -0
- package/dist/zipFsEntry.cjs +65 -0
- package/dist/zipFsEntry.d.cts +19 -0
- package/dist/zipFsEntry.d.ts +19 -0
- package/dist/zipFsEntry.js +41 -0
- package/package.json +24 -29
- package/dist/base.cjs +0 -248
- package/dist/base.d.cts +0 -67
- package/dist/base.d.ts +0 -67
- package/dist/base.js +0 -223
- package/dist/node/entry.cjs +0 -76
- package/dist/node/entry.d.cts +0 -18
- package/dist/node/entry.d.ts +0 -18
- package/dist/node/entry.js +0 -52
- package/dist/node/index.cjs +0 -107
- package/dist/node/index.d.cts +0 -17
- package/dist/node/index.d.ts +0 -17
- package/dist/node/index.js +0 -89
- package/dist/taglib/Uint8ArrayFileAbstraction.cjs +0 -128
- package/dist/taglib/Uint8ArrayFileAbstraction.d.cts +0 -26
- package/dist/taglib/Uint8ArrayFileAbstraction.d.ts +0 -26
- package/dist/taglib/Uint8ArrayFileAbstraction.js +0 -106
package/dist/index.cjs
CHANGED
|
@@ -18,52 +18,298 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var index_exports = {};
|
|
20
20
|
__export(index_exports, {
|
|
21
|
-
|
|
21
|
+
AAC_FILE_EXTENSIONS: () => AAC_FILE_EXTENSIONS,
|
|
22
|
+
AIFF_FILE_EXTENSIONS: () => AIFF_FILE_EXTENSIONS,
|
|
23
|
+
ALAC_FILE_EXTENSIONS: () => ALAC_FILE_EXTENSIONS,
|
|
24
|
+
Audiobook: () => Audiobook,
|
|
25
|
+
COVER_IMAGE_FILE_EXTENSIONS: () => COVER_IMAGE_FILE_EXTENSIONS,
|
|
26
|
+
FLAC_FILE_EXTENSIONS: () => FLAC_FILE_EXTENSIONS,
|
|
27
|
+
MP3_FILE_EXTENSIONS: () => MP3_FILE_EXTENSIONS,
|
|
28
|
+
MPEG4_FILE_EXTENSIONS: () => MPEG4_FILE_EXTENSIONS,
|
|
29
|
+
OGG_FILE_EXTENSIONS: () => OGG_FILE_EXTENSIONS,
|
|
30
|
+
OPUS_FILE_EXTENSIONS: () => OPUS_FILE_EXTENSIONS,
|
|
31
|
+
WAVE_FILE_EXTENSIONS: () => WAVE_FILE_EXTENSIONS,
|
|
32
|
+
WEBM_FILE_EXTENSIONS: () => WEBM_FILE_EXTENSIONS,
|
|
33
|
+
getAttachedImageFromPath: () => getAttachedImageFromPath
|
|
22
34
|
});
|
|
23
35
|
module.exports = __toCommonJS(index_exports);
|
|
24
|
-
var
|
|
36
|
+
var import_promises = require("node:fs/promises");
|
|
37
|
+
var import_libzip = require("@yarnpkg/libzip");
|
|
38
|
+
var import_mime_types = require("mime-types");
|
|
25
39
|
var import_path = require("@storyteller-platform/path");
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
var import_bufferEntry = require("./bufferEntry.cjs");
|
|
41
|
+
var import_fileEntry = require("./fileEntry.cjs");
|
|
42
|
+
var import_zipFsEntry = require("./zipFsEntry.cjs");
|
|
43
|
+
const COVER_IMAGE_FILE_EXTENSIONS = [
|
|
44
|
+
".jpeg",
|
|
45
|
+
".jpg",
|
|
46
|
+
".png",
|
|
47
|
+
".svg"
|
|
48
|
+
];
|
|
49
|
+
const MP3_FILE_EXTENSIONS = [".mp3"];
|
|
50
|
+
const MPEG4_FILE_EXTENSIONS = [".mp4", ".m4a", ".m4b"];
|
|
51
|
+
const AAC_FILE_EXTENSIONS = [".aac"];
|
|
52
|
+
const OGG_FILE_EXTENSIONS = [".ogg", ".oga", ".mogg"];
|
|
53
|
+
const OPUS_FILE_EXTENSIONS = [".opus"];
|
|
54
|
+
const WAVE_FILE_EXTENSIONS = [".wav"];
|
|
55
|
+
const AIFF_FILE_EXTENSIONS = [".aiff"];
|
|
56
|
+
const FLAC_FILE_EXTENSIONS = [".flac"];
|
|
57
|
+
const ALAC_FILE_EXTENSIONS = [".alac"];
|
|
58
|
+
const WEBM_FILE_EXTENSIONS = [".weba"];
|
|
59
|
+
const AUDIO_FILE_EXTENSIONS = [
|
|
60
|
+
...MP3_FILE_EXTENSIONS,
|
|
61
|
+
...AAC_FILE_EXTENSIONS,
|
|
62
|
+
...MPEG4_FILE_EXTENSIONS,
|
|
63
|
+
...OPUS_FILE_EXTENSIONS,
|
|
64
|
+
...OGG_FILE_EXTENSIONS,
|
|
65
|
+
...WAVE_FILE_EXTENSIONS,
|
|
66
|
+
...AIFF_FILE_EXTENSIONS,
|
|
67
|
+
...FLAC_FILE_EXTENSIONS,
|
|
68
|
+
...ALAC_FILE_EXTENSIONS,
|
|
69
|
+
...WEBM_FILE_EXTENSIONS
|
|
70
|
+
];
|
|
71
|
+
class Audiobook {
|
|
72
|
+
metadata = {};
|
|
73
|
+
inputs;
|
|
74
|
+
entries;
|
|
75
|
+
constructor(...inputs) {
|
|
76
|
+
this.inputs = inputs;
|
|
77
|
+
this.entries = this.getEntries();
|
|
78
|
+
}
|
|
79
|
+
isZip() {
|
|
80
|
+
const [first] = this.inputs;
|
|
81
|
+
return typeof first === "string" && ((0, import_path.extname)(first) === ".zip" || (0, import_path.extname)(first) === ".audiobook");
|
|
82
|
+
}
|
|
83
|
+
isFiles() {
|
|
84
|
+
const [first] = this.inputs;
|
|
85
|
+
return typeof first === "string" && !this.isZip();
|
|
86
|
+
}
|
|
87
|
+
isInMemory() {
|
|
88
|
+
const [first] = this.inputs;
|
|
89
|
+
return typeof first !== "string";
|
|
90
|
+
}
|
|
91
|
+
getEntries() {
|
|
92
|
+
if (this.isZip()) {
|
|
93
|
+
const [first] = this.inputs;
|
|
94
|
+
const zipFs = new import_libzip.ZipFS(first);
|
|
95
|
+
const entries = zipFs.getAllFiles();
|
|
96
|
+
return entries.filter(
|
|
97
|
+
(entry) => AUDIO_FILE_EXTENSIONS.includes(
|
|
98
|
+
(0, import_path.extname)(entry)
|
|
99
|
+
)
|
|
100
|
+
).map((entry) => new import_zipFsEntry.ZipFSEntry(zipFs, entry));
|
|
44
101
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
102
|
+
if (this.isFiles()) {
|
|
103
|
+
return this.inputs.map((input) => new import_fileEntry.FileEntry(input));
|
|
104
|
+
}
|
|
105
|
+
if (this.isInMemory()) {
|
|
106
|
+
return this.inputs.map(
|
|
107
|
+
(input) => new import_bufferEntry.BufferEntry(input)
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
return [];
|
|
48
111
|
}
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
112
|
+
async getFirstValue(getter) {
|
|
113
|
+
for (const entry of this.entries) {
|
|
114
|
+
const value = await getter(entry);
|
|
115
|
+
if (value) return value;
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
53
118
|
}
|
|
54
|
-
async
|
|
119
|
+
async setValue(setter) {
|
|
55
120
|
for (const entry of this.entries) {
|
|
56
|
-
entry
|
|
121
|
+
await setter(entry);
|
|
57
122
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
123
|
+
}
|
|
124
|
+
async getTitle() {
|
|
125
|
+
this.metadata.title ??= await this.getFirstValue(
|
|
126
|
+
(entry) => entry.getTitle()
|
|
127
|
+
);
|
|
128
|
+
return this.metadata.title;
|
|
129
|
+
}
|
|
130
|
+
async setTitle(title) {
|
|
131
|
+
this.metadata.title = title;
|
|
132
|
+
await this.setValue((entry) => entry.setTitle(title));
|
|
133
|
+
}
|
|
134
|
+
async getSubtitle() {
|
|
135
|
+
this.metadata.subtitle ??= await this.getFirstValue(
|
|
136
|
+
(entry) => entry.getSubtitle()
|
|
137
|
+
);
|
|
138
|
+
return this.metadata.subtitle;
|
|
139
|
+
}
|
|
140
|
+
async setSubtitle(subtitle) {
|
|
141
|
+
this.metadata.subtitle = subtitle;
|
|
142
|
+
await this.setValue((entry) => entry.setSubtitle(subtitle));
|
|
143
|
+
}
|
|
144
|
+
async getDescription() {
|
|
145
|
+
this.metadata.description ??= await this.getFirstValue(
|
|
146
|
+
(entry) => entry.getDescription()
|
|
147
|
+
);
|
|
148
|
+
return this.metadata.description;
|
|
149
|
+
}
|
|
150
|
+
async setDescription(description) {
|
|
151
|
+
this.metadata.description = description;
|
|
152
|
+
await this.setValue((entry) => entry.setDescription(description));
|
|
153
|
+
}
|
|
154
|
+
async getAuthors() {
|
|
155
|
+
this.metadata.authors ??= await this.getFirstValue(
|
|
156
|
+
(entry) => entry.getAuthors()
|
|
157
|
+
);
|
|
158
|
+
return this.metadata.authors ?? [];
|
|
159
|
+
}
|
|
160
|
+
async setAuthors(authors) {
|
|
161
|
+
this.metadata.authors = authors;
|
|
162
|
+
await this.setValue((entry) => entry.setAuthors(authors));
|
|
163
|
+
}
|
|
164
|
+
async getNarrators() {
|
|
165
|
+
this.metadata.narrators ??= await this.getFirstValue(
|
|
166
|
+
(entry) => entry.getNarrators()
|
|
167
|
+
);
|
|
168
|
+
return this.metadata.narrators ?? [];
|
|
169
|
+
}
|
|
170
|
+
async setNarrators(narrators) {
|
|
171
|
+
this.metadata.narrators = narrators;
|
|
172
|
+
await this.setValue((entry) => entry.setNarrators(narrators));
|
|
173
|
+
}
|
|
174
|
+
async getCoverArt() {
|
|
175
|
+
this.metadata.coverArt ??= await this.getFirstValue(
|
|
176
|
+
(entry) => entry.getCoverArt()
|
|
177
|
+
);
|
|
178
|
+
return this.metadata.coverArt;
|
|
179
|
+
}
|
|
180
|
+
async setCoverArt(picture) {
|
|
181
|
+
this.metadata.coverArt = picture;
|
|
182
|
+
await this.setValue((entry) => entry.setCoverArt(picture));
|
|
183
|
+
}
|
|
184
|
+
async getPublisher() {
|
|
185
|
+
this.metadata.publisher ??= await this.getFirstValue(
|
|
186
|
+
(entry) => entry.getPublisher()
|
|
63
187
|
);
|
|
188
|
+
return this.metadata.publisher;
|
|
64
189
|
}
|
|
190
|
+
async setPublisher(publisher) {
|
|
191
|
+
this.metadata.publisher = publisher;
|
|
192
|
+
await this.setValue((entry) => entry.setPublisher(publisher));
|
|
193
|
+
}
|
|
194
|
+
async getReleaseDate() {
|
|
195
|
+
this.metadata.releaseDate ??= await this.getFirstValue(
|
|
196
|
+
(entry) => entry.getReleaseDate()
|
|
197
|
+
);
|
|
198
|
+
return this.metadata.releaseDate;
|
|
199
|
+
}
|
|
200
|
+
async setReleaseDate(date) {
|
|
201
|
+
this.metadata.releaseDate = date;
|
|
202
|
+
await this.setValue((entry) => entry.setReleaseDate(date));
|
|
203
|
+
}
|
|
204
|
+
async getDuration() {
|
|
205
|
+
let duration = 0;
|
|
206
|
+
for (const entry of this.entries) {
|
|
207
|
+
duration += await entry.getDuration();
|
|
208
|
+
}
|
|
209
|
+
return duration;
|
|
210
|
+
}
|
|
211
|
+
async getChapters() {
|
|
212
|
+
if (this.metadata.chapters) return this.metadata.chapters;
|
|
213
|
+
const chapters = [];
|
|
214
|
+
for (const entry of this.entries) {
|
|
215
|
+
const entryChapters = await entry.getChapters();
|
|
216
|
+
if (entryChapters.length) {
|
|
217
|
+
chapters.push(...entryChapters);
|
|
218
|
+
} else {
|
|
219
|
+
chapters.push({
|
|
220
|
+
filename: entry.filename,
|
|
221
|
+
start: 0,
|
|
222
|
+
title: await entry.getTrackTitle() ?? (0, import_path.basename)(entry.filename, (0, import_path.extname)(entry.filename))
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
this.metadata.chapters = chapters;
|
|
227
|
+
return chapters;
|
|
228
|
+
}
|
|
229
|
+
async getResources() {
|
|
230
|
+
if (this.metadata.resources) return this.metadata.resources;
|
|
231
|
+
const resources = [];
|
|
232
|
+
for (let i = 0; i < this.entries.length; i++) {
|
|
233
|
+
const entry = this.entries[i];
|
|
234
|
+
const resource = await entry.getResource();
|
|
235
|
+
if (!resource.title) {
|
|
236
|
+
resource.title = `Track ${i + 1}`;
|
|
237
|
+
}
|
|
238
|
+
resources.push(resource);
|
|
239
|
+
}
|
|
240
|
+
this.metadata.resources = resources;
|
|
241
|
+
return resources;
|
|
242
|
+
}
|
|
243
|
+
async getArraysAndClose() {
|
|
244
|
+
const output = [];
|
|
245
|
+
for (const entry of this.entries) {
|
|
246
|
+
output.push(await entry.getArrayAndClose());
|
|
247
|
+
}
|
|
248
|
+
if (this.isZip()) {
|
|
249
|
+
const zipFs = this.entries[0].zipFs;
|
|
250
|
+
zipFs.discardAndClose();
|
|
251
|
+
}
|
|
252
|
+
return output;
|
|
253
|
+
}
|
|
254
|
+
async saveAndClose() {
|
|
255
|
+
if (this.isZip()) {
|
|
256
|
+
for (const entry of this.entries) {
|
|
257
|
+
await entry.saveAndClose();
|
|
258
|
+
}
|
|
259
|
+
const zipFs = this.entries[0].zipFs;
|
|
260
|
+
zipFs.saveAndClose();
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (this.isFiles()) {
|
|
264
|
+
for (const entry of this.entries) {
|
|
265
|
+
await entry.saveAndClose();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (this.isInMemory()) {
|
|
269
|
+
throw new Error(
|
|
270
|
+
`Cannot save in-memory Audiobooks. Use audiobook.getArraysAndClose() to access the updated array.`
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
discardAndClose() {
|
|
275
|
+
if (this.isZip()) {
|
|
276
|
+
const zipFs = this.entries[0].zipFs;
|
|
277
|
+
if (zipFs.ready) {
|
|
278
|
+
zipFs.discardAndClose();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
this.inputs = [".mp3"];
|
|
282
|
+
this.entries = [];
|
|
283
|
+
}
|
|
284
|
+
[Symbol.dispose]() {
|
|
285
|
+
this.discardAndClose();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
async function getAttachedImageFromPath(path, kind = "coverFront", description) {
|
|
289
|
+
const data = await (0, import_promises.readFile)(path);
|
|
290
|
+
const name = (0, import_path.basename)(path);
|
|
291
|
+
const mimeType = (0, import_mime_types.lookup)(path) || "";
|
|
292
|
+
return {
|
|
293
|
+
data: new Uint8Array(data),
|
|
294
|
+
name,
|
|
295
|
+
kind,
|
|
296
|
+
...description && { description },
|
|
297
|
+
mimeType
|
|
298
|
+
};
|
|
65
299
|
}
|
|
66
300
|
// Annotate the CommonJS export names for ESM import in node:
|
|
67
301
|
0 && (module.exports = {
|
|
68
|
-
|
|
302
|
+
AAC_FILE_EXTENSIONS,
|
|
303
|
+
AIFF_FILE_EXTENSIONS,
|
|
304
|
+
ALAC_FILE_EXTENSIONS,
|
|
305
|
+
Audiobook,
|
|
306
|
+
COVER_IMAGE_FILE_EXTENSIONS,
|
|
307
|
+
FLAC_FILE_EXTENSIONS,
|
|
308
|
+
MP3_FILE_EXTENSIONS,
|
|
309
|
+
MPEG4_FILE_EXTENSIONS,
|
|
310
|
+
OGG_FILE_EXTENSIONS,
|
|
311
|
+
OPUS_FILE_EXTENSIONS,
|
|
312
|
+
WAVE_FILE_EXTENSIONS,
|
|
313
|
+
WEBM_FILE_EXTENSIONS,
|
|
314
|
+
getAttachedImageFromPath
|
|
69
315
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
4
|
-
import '@zip.js/zip.js';
|
|
1
|
+
import { AttachedImage } from 'mediabunny';
|
|
2
|
+
import { Uint8ArrayEntry, AudiobookEntry } from './entry.cjs';
|
|
3
|
+
import { AudiobookChapter, AudiobookResource } from './resources.cjs';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
interface AudiobookMetadata {
|
|
6
|
+
title?: string | null;
|
|
7
|
+
subtitle?: string | null;
|
|
8
|
+
description?: string | null;
|
|
9
|
+
coverArt?: AttachedImage | null;
|
|
10
|
+
chapters?: AudiobookChapter[] | null;
|
|
11
|
+
resources?: AudiobookResource[] | null;
|
|
12
|
+
authors?: string[] | null;
|
|
13
|
+
narrators?: string[] | null;
|
|
14
|
+
publisher?: string | null;
|
|
15
|
+
releaseDate?: Date | null;
|
|
12
16
|
}
|
|
17
|
+
declare const COVER_IMAGE_FILE_EXTENSIONS: readonly [".jpeg", ".jpg", ".png", ".svg"];
|
|
18
|
+
declare const MP3_FILE_EXTENSIONS: readonly [".mp3"];
|
|
19
|
+
declare const MPEG4_FILE_EXTENSIONS: readonly [".mp4", ".m4a", ".m4b"];
|
|
20
|
+
declare const AAC_FILE_EXTENSIONS: readonly [".aac"];
|
|
21
|
+
declare const OGG_FILE_EXTENSIONS: readonly [".ogg", ".oga", ".mogg"];
|
|
22
|
+
declare const OPUS_FILE_EXTENSIONS: readonly [".opus"];
|
|
23
|
+
declare const WAVE_FILE_EXTENSIONS: readonly [".wav"];
|
|
24
|
+
declare const AIFF_FILE_EXTENSIONS: readonly [".aiff"];
|
|
25
|
+
declare const FLAC_FILE_EXTENSIONS: readonly [".flac"];
|
|
26
|
+
declare const ALAC_FILE_EXTENSIONS: readonly [".alac"];
|
|
27
|
+
declare const WEBM_FILE_EXTENSIONS: readonly [".weba"];
|
|
28
|
+
declare const AUDIO_FILE_EXTENSIONS: readonly [".mp3", ".aac", ".mp4", ".m4a", ".m4b", ".opus", ".ogg", ".oga", ".mogg", ".wav", ".aiff", ".flac", ".alac", ".weba"];
|
|
29
|
+
type AudiobookInputs = [`${string}.zip`] | [`${string}.audiobook`] | [
|
|
30
|
+
`${string}${(typeof AUDIO_FILE_EXTENSIONS)[number]}`,
|
|
31
|
+
...`${string}${(typeof AUDIO_FILE_EXTENSIONS)[number]}`[]
|
|
32
|
+
] | [Uint8ArrayEntry, ...Uint8ArrayEntry[]];
|
|
33
|
+
declare class Audiobook {
|
|
34
|
+
protected metadata: AudiobookMetadata;
|
|
35
|
+
private inputs;
|
|
36
|
+
private entries;
|
|
37
|
+
constructor(...inputs: AudiobookInputs);
|
|
38
|
+
private isZip;
|
|
39
|
+
private isFiles;
|
|
40
|
+
private isInMemory;
|
|
41
|
+
private getEntries;
|
|
42
|
+
protected getFirstValue<T>(getter: (entry: AudiobookEntry) => Promise<T>): Promise<T | null>;
|
|
43
|
+
protected setValue(setter: (entry: AudiobookEntry) => Promise<void>): Promise<void>;
|
|
44
|
+
getTitle(): Promise<string | null>;
|
|
45
|
+
setTitle(title: string): Promise<void>;
|
|
46
|
+
getSubtitle(): Promise<string | null>;
|
|
47
|
+
setSubtitle(subtitle: string): Promise<void>;
|
|
48
|
+
getDescription(): Promise<string | null>;
|
|
49
|
+
setDescription(description: string): Promise<void>;
|
|
50
|
+
getAuthors(): Promise<string[]>;
|
|
51
|
+
setAuthors(authors: string[]): Promise<void>;
|
|
52
|
+
getNarrators(): Promise<string[]>;
|
|
53
|
+
setNarrators(narrators: string[]): Promise<void>;
|
|
54
|
+
getCoverArt(): Promise<AttachedImage | null>;
|
|
55
|
+
setCoverArt(picture: AttachedImage): Promise<void>;
|
|
56
|
+
getPublisher(): Promise<string | null>;
|
|
57
|
+
setPublisher(publisher: string): Promise<void>;
|
|
58
|
+
getReleaseDate(): Promise<Date | null>;
|
|
59
|
+
setReleaseDate(date: Date): Promise<void>;
|
|
60
|
+
getDuration(): Promise<number>;
|
|
61
|
+
getChapters(): Promise<AudiobookChapter[]>;
|
|
62
|
+
getResources(): Promise<AudiobookResource[]>;
|
|
63
|
+
getArraysAndClose(): Promise<Uint8ArrayEntry[]>;
|
|
64
|
+
saveAndClose(): Promise<void>;
|
|
65
|
+
discardAndClose(): void;
|
|
66
|
+
[Symbol.dispose](): void;
|
|
67
|
+
}
|
|
68
|
+
declare function getAttachedImageFromPath(path: string, kind?: AttachedImage["kind"], description?: string): Promise<AttachedImage>;
|
|
13
69
|
|
|
14
|
-
export { Audiobook };
|
|
70
|
+
export { AAC_FILE_EXTENSIONS, AIFF_FILE_EXTENSIONS, ALAC_FILE_EXTENSIONS, Audiobook, type AudiobookInputs, type AudiobookMetadata, COVER_IMAGE_FILE_EXTENSIONS, FLAC_FILE_EXTENSIONS, MP3_FILE_EXTENSIONS, MPEG4_FILE_EXTENSIONS, OGG_FILE_EXTENSIONS, OPUS_FILE_EXTENSIONS, WAVE_FILE_EXTENSIONS, WEBM_FILE_EXTENSIONS, getAttachedImageFromPath };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
4
|
-
import '@zip.js/zip.js';
|
|
1
|
+
import { AttachedImage } from 'mediabunny';
|
|
2
|
+
import { Uint8ArrayEntry, AudiobookEntry } from './entry.js';
|
|
3
|
+
import { AudiobookChapter, AudiobookResource } from './resources.js';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
interface AudiobookMetadata {
|
|
6
|
+
title?: string | null;
|
|
7
|
+
subtitle?: string | null;
|
|
8
|
+
description?: string | null;
|
|
9
|
+
coverArt?: AttachedImage | null;
|
|
10
|
+
chapters?: AudiobookChapter[] | null;
|
|
11
|
+
resources?: AudiobookResource[] | null;
|
|
12
|
+
authors?: string[] | null;
|
|
13
|
+
narrators?: string[] | null;
|
|
14
|
+
publisher?: string | null;
|
|
15
|
+
releaseDate?: Date | null;
|
|
12
16
|
}
|
|
17
|
+
declare const COVER_IMAGE_FILE_EXTENSIONS: readonly [".jpeg", ".jpg", ".png", ".svg"];
|
|
18
|
+
declare const MP3_FILE_EXTENSIONS: readonly [".mp3"];
|
|
19
|
+
declare const MPEG4_FILE_EXTENSIONS: readonly [".mp4", ".m4a", ".m4b"];
|
|
20
|
+
declare const AAC_FILE_EXTENSIONS: readonly [".aac"];
|
|
21
|
+
declare const OGG_FILE_EXTENSIONS: readonly [".ogg", ".oga", ".mogg"];
|
|
22
|
+
declare const OPUS_FILE_EXTENSIONS: readonly [".opus"];
|
|
23
|
+
declare const WAVE_FILE_EXTENSIONS: readonly [".wav"];
|
|
24
|
+
declare const AIFF_FILE_EXTENSIONS: readonly [".aiff"];
|
|
25
|
+
declare const FLAC_FILE_EXTENSIONS: readonly [".flac"];
|
|
26
|
+
declare const ALAC_FILE_EXTENSIONS: readonly [".alac"];
|
|
27
|
+
declare const WEBM_FILE_EXTENSIONS: readonly [".weba"];
|
|
28
|
+
declare const AUDIO_FILE_EXTENSIONS: readonly [".mp3", ".aac", ".mp4", ".m4a", ".m4b", ".opus", ".ogg", ".oga", ".mogg", ".wav", ".aiff", ".flac", ".alac", ".weba"];
|
|
29
|
+
type AudiobookInputs = [`${string}.zip`] | [`${string}.audiobook`] | [
|
|
30
|
+
`${string}${(typeof AUDIO_FILE_EXTENSIONS)[number]}`,
|
|
31
|
+
...`${string}${(typeof AUDIO_FILE_EXTENSIONS)[number]}`[]
|
|
32
|
+
] | [Uint8ArrayEntry, ...Uint8ArrayEntry[]];
|
|
33
|
+
declare class Audiobook {
|
|
34
|
+
protected metadata: AudiobookMetadata;
|
|
35
|
+
private inputs;
|
|
36
|
+
private entries;
|
|
37
|
+
constructor(...inputs: AudiobookInputs);
|
|
38
|
+
private isZip;
|
|
39
|
+
private isFiles;
|
|
40
|
+
private isInMemory;
|
|
41
|
+
private getEntries;
|
|
42
|
+
protected getFirstValue<T>(getter: (entry: AudiobookEntry) => Promise<T>): Promise<T | null>;
|
|
43
|
+
protected setValue(setter: (entry: AudiobookEntry) => Promise<void>): Promise<void>;
|
|
44
|
+
getTitle(): Promise<string | null>;
|
|
45
|
+
setTitle(title: string): Promise<void>;
|
|
46
|
+
getSubtitle(): Promise<string | null>;
|
|
47
|
+
setSubtitle(subtitle: string): Promise<void>;
|
|
48
|
+
getDescription(): Promise<string | null>;
|
|
49
|
+
setDescription(description: string): Promise<void>;
|
|
50
|
+
getAuthors(): Promise<string[]>;
|
|
51
|
+
setAuthors(authors: string[]): Promise<void>;
|
|
52
|
+
getNarrators(): Promise<string[]>;
|
|
53
|
+
setNarrators(narrators: string[]): Promise<void>;
|
|
54
|
+
getCoverArt(): Promise<AttachedImage | null>;
|
|
55
|
+
setCoverArt(picture: AttachedImage): Promise<void>;
|
|
56
|
+
getPublisher(): Promise<string | null>;
|
|
57
|
+
setPublisher(publisher: string): Promise<void>;
|
|
58
|
+
getReleaseDate(): Promise<Date | null>;
|
|
59
|
+
setReleaseDate(date: Date): Promise<void>;
|
|
60
|
+
getDuration(): Promise<number>;
|
|
61
|
+
getChapters(): Promise<AudiobookChapter[]>;
|
|
62
|
+
getResources(): Promise<AudiobookResource[]>;
|
|
63
|
+
getArraysAndClose(): Promise<Uint8ArrayEntry[]>;
|
|
64
|
+
saveAndClose(): Promise<void>;
|
|
65
|
+
discardAndClose(): void;
|
|
66
|
+
[Symbol.dispose](): void;
|
|
67
|
+
}
|
|
68
|
+
declare function getAttachedImageFromPath(path: string, kind?: AttachedImage["kind"], description?: string): Promise<AttachedImage>;
|
|
13
69
|
|
|
14
|
-
export { Audiobook };
|
|
70
|
+
export { AAC_FILE_EXTENSIONS, AIFF_FILE_EXTENSIONS, ALAC_FILE_EXTENSIONS, Audiobook, type AudiobookInputs, type AudiobookMetadata, COVER_IMAGE_FILE_EXTENSIONS, FLAC_FILE_EXTENSIONS, MP3_FILE_EXTENSIONS, MPEG4_FILE_EXTENSIONS, OGG_FILE_EXTENSIONS, OPUS_FILE_EXTENSIONS, WAVE_FILE_EXTENSIONS, WEBM_FILE_EXTENSIONS, getAttachedImageFromPath };
|