@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.
Files changed (49) hide show
  1. package/dist/bufferEntry.cjs +59 -0
  2. package/dist/bufferEntry.d.cts +16 -0
  3. package/dist/bufferEntry.d.ts +16 -0
  4. package/dist/bufferEntry.js +35 -0
  5. package/dist/entry.cjs +259 -28
  6. package/dist/entry.d.cts +31 -11
  7. package/dist/entry.d.ts +31 -11
  8. package/dist/entry.js +273 -28
  9. package/dist/ffmpeg.cjs +84 -0
  10. package/dist/ffmpeg.d.cts +11 -0
  11. package/dist/ffmpeg.d.ts +11 -0
  12. package/dist/ffmpeg.js +58 -0
  13. package/dist/fileEntry.cjs +58 -0
  14. package/dist/fileEntry.d.cts +16 -0
  15. package/dist/fileEntry.d.ts +16 -0
  16. package/dist/fileEntry.js +34 -0
  17. package/dist/index.cjs +281 -35
  18. package/dist/index.d.cts +67 -11
  19. package/dist/index.d.ts +67 -11
  20. package/dist/index.js +269 -35
  21. package/dist/resources.cjs +16 -0
  22. package/dist/resources.d.cts +14 -0
  23. package/dist/resources.d.ts +14 -0
  24. package/dist/resources.js +0 -0
  25. package/dist/tagMaps.cjs +120 -0
  26. package/dist/tagMaps.d.cts +24 -0
  27. package/dist/tagMaps.d.ts +24 -0
  28. package/dist/tagMaps.js +95 -0
  29. package/dist/zipFsEntry.cjs +65 -0
  30. package/dist/zipFsEntry.d.cts +19 -0
  31. package/dist/zipFsEntry.d.ts +19 -0
  32. package/dist/zipFsEntry.js +41 -0
  33. package/package.json +24 -29
  34. package/dist/base.cjs +0 -248
  35. package/dist/base.d.cts +0 -67
  36. package/dist/base.d.ts +0 -67
  37. package/dist/base.js +0 -223
  38. package/dist/node/entry.cjs +0 -76
  39. package/dist/node/entry.d.cts +0 -18
  40. package/dist/node/entry.d.ts +0 -18
  41. package/dist/node/entry.js +0 -52
  42. package/dist/node/index.cjs +0 -107
  43. package/dist/node/index.d.cts +0 -17
  44. package/dist/node/index.d.ts +0 -17
  45. package/dist/node/index.js +0 -89
  46. package/dist/taglib/Uint8ArrayFileAbstraction.cjs +0 -128
  47. package/dist/taglib/Uint8ArrayFileAbstraction.d.cts +0 -26
  48. package/dist/taglib/Uint8ArrayFileAbstraction.d.ts +0 -26
  49. 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
- Audiobook: () => Audiobook
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 import_zip = require("@zip.js/zip.js");
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 import_base = require("./base.cjs");
27
- var import_entry = require("./entry.cjs");
28
- class Audiobook extends import_base.BaseAudiobook {
29
- constructor(entries) {
30
- super();
31
- this.entries = entries;
32
- }
33
- static async from(pathOrPathsOrData) {
34
- if (!Array.isArray(pathOrPathsOrData)) {
35
- const ext = (0, import_path.extname)(pathOrPathsOrData.filename);
36
- if (ext === ".zip") {
37
- const dataReader = new import_zip.Uint8ArrayReader(pathOrPathsOrData.data);
38
- const zipReader = new import_zip.ZipReader(dataReader);
39
- const zipEntries = await zipReader.getEntries();
40
- const entries = zipEntries.map((entry) => new import_entry.AudiobookEntry(entry));
41
- return new Audiobook(entries);
42
- }
43
- return new Audiobook([new import_entry.AudiobookEntry(pathOrPathsOrData)]);
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
- return new Audiobook(
46
- pathOrPathsOrData.map((path) => new import_entry.AudiobookEntry(path))
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
- static create(metadata) {
50
- const audiobook = new Audiobook([]);
51
- audiobook.metadata = metadata;
52
- return audiobook;
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 save() {
119
+ async setValue(setter) {
55
120
  for (const entry of this.entries) {
56
- entry.save();
121
+ await setter(entry);
57
122
  }
58
- return await Promise.all(
59
- this.entries.map(async (entry) => ({
60
- filename: entry.filename,
61
- data: await entry.getData()
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
- Audiobook
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 { BaseAudiobook, AudiobookMetadata } from './base.cjs';
2
- import { AudiobookEntry, Uint8ArrayEntry } from './entry.cjs';
3
- import 'node-taglib-sharp';
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
- declare class Audiobook extends BaseAudiobook {
7
- protected entries: AudiobookEntry[];
8
- protected constructor(entries: AudiobookEntry[]);
9
- static from(pathOrPathsOrData: Uint8ArrayEntry | Uint8ArrayEntry[]): Promise<Audiobook>;
10
- static create(metadata: AudiobookMetadata): Audiobook;
11
- save(): Promise<Uint8ArrayEntry[]>;
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 { BaseAudiobook, AudiobookMetadata } from './base.js';
2
- import { AudiobookEntry, Uint8ArrayEntry } from './entry.js';
3
- import 'node-taglib-sharp';
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
- declare class Audiobook extends BaseAudiobook {
7
- protected entries: AudiobookEntry[];
8
- protected constructor(entries: AudiobookEntry[]);
9
- static from(pathOrPathsOrData: Uint8ArrayEntry | Uint8ArrayEntry[]): Promise<Audiobook>;
10
- static create(metadata: AudiobookMetadata): Audiobook;
11
- save(): Promise<Uint8ArrayEntry[]>;
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 };