@storyteller-platform/align 0.1.57 → 0.1.58
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/align/align.cjs +38 -19
- package/dist/align/align.d.cts +12 -1
- package/dist/align/align.d.ts +12 -1
- package/dist/align/align.js +38 -19
- package/dist/align/ctc/Aligner.cjs +800 -0
- package/dist/align/ctc/Aligner.d.cts +56 -0
- package/dist/align/ctc/Aligner.d.ts +56 -0
- package/dist/align/ctc/Aligner.js +789 -0
- package/dist/align/ctc/align.cjs +189 -0
- package/dist/align/ctc/align.d.cts +14 -0
- package/dist/align/ctc/align.d.ts +14 -0
- package/dist/align/ctc/align.js +132 -0
- package/dist/{process/mime.cjs → align/ctc/emissions.cjs} +7 -20
- package/dist/align/ctc/emissions.d.cts +6 -0
- package/dist/align/ctc/emissions.d.ts +6 -0
- package/dist/align/ctc/emissions.js +7 -0
- package/dist/align/ctc/forcedAlign.cjs +273 -0
- package/dist/align/ctc/forcedAlign.d.cts +21 -0
- package/dist/align/ctc/forcedAlign.d.ts +21 -0
- package/dist/align/ctc/forcedAlign.js +248 -0
- package/dist/align/ctc/greedyDecode.cjs +61 -0
- package/dist/align/ctc/greedyDecode.d.cts +15 -0
- package/dist/align/ctc/greedyDecode.d.ts +15 -0
- package/dist/align/ctc/greedyDecode.js +37 -0
- package/dist/align/ctc/mediaOverlay.cjs +248 -0
- package/dist/align/ctc/mediaOverlay.d.cts +16 -0
- package/dist/align/ctc/mediaOverlay.d.ts +16 -0
- package/dist/align/ctc/mediaOverlay.js +224 -0
- package/dist/align/ctc/report.cjs +66 -0
- package/dist/align/ctc/report.d.cts +79 -0
- package/dist/align/ctc/report.d.ts +79 -0
- package/dist/align/ctc/report.js +42 -0
- package/dist/align/ctc/search.cjs +437 -0
- package/dist/align/ctc/search.d.cts +46 -0
- package/dist/align/ctc/search.d.ts +46 -0
- package/dist/align/ctc/search.js +412 -0
- package/dist/align/getSentenceRanges.cjs +9 -3
- package/dist/align/getSentenceRanges.d.cts +1 -0
- package/dist/align/getSentenceRanges.d.ts +1 -0
- package/dist/align/getSentenceRanges.js +9 -3
- package/dist/align/parse.cjs +17 -4
- package/dist/align/parse.d.cts +8 -4
- package/dist/align/parse.d.ts +8 -4
- package/dist/align/parse.js +19 -4
- package/dist/align/search.cjs +76 -23
- package/dist/align/search.d.cts +8 -4
- package/dist/align/search.d.ts +8 -4
- package/dist/align/search.js +76 -24
- package/dist/align/slugify.cjs +3 -2
- package/dist/align/slugify.d.cts +1 -1
- package/dist/align/slugify.d.ts +1 -1
- package/dist/align/slugify.js +3 -2
- package/dist/cli/bin.cjs +204 -114
- package/dist/cli/bin.js +194 -103
- package/dist/common/ffmpeg.cjs +10 -5
- package/dist/common/ffmpeg.js +10 -5
- package/dist/common/logging.cjs +33 -1
- package/dist/common/logging.js +33 -1
- package/dist/emit/emit.cjs +105 -0
- package/dist/emit/emit.d.cts +15 -0
- package/dist/emit/emit.d.ts +15 -0
- package/dist/emit/emit.js +86 -0
- package/dist/emit/fs.cjs +227 -0
- package/dist/emit/fs.d.cts +22 -0
- package/dist/emit/fs.d.ts +22 -0
- package/dist/emit/fs.js +162 -0
- package/dist/emit/parse.cjs +68 -0
- package/dist/emit/parse.d.cts +26 -0
- package/dist/emit/parse.d.ts +26 -0
- package/dist/emit/parse.js +58 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/markup/model.cjs +0 -16
- package/dist/markup/model.d.cts +1 -1
- package/dist/markup/model.d.ts +1 -1
- package/dist/markup/model.js +0 -12
- package/dist/markup/parseDom.cjs +13 -14
- package/dist/markup/parseDom.d.cts +2 -2
- package/dist/markup/parseDom.d.ts +2 -2
- package/dist/markup/parseDom.js +13 -18
- package/dist/markup/resolvedPos.d.cts +1 -1
- package/dist/markup/resolvedPos.d.ts +1 -1
- package/dist/markup/segmentation.cjs +3 -1
- package/dist/markup/segmentation.js +3 -1
- package/dist/markup/serializeDom.cjs +1 -1
- package/dist/markup/serializeDom.d.cts +1 -1
- package/dist/markup/serializeDom.d.ts +1 -1
- package/dist/markup/serializeDom.js +1 -1
- package/dist/markup/transform.cjs +5 -2
- package/dist/markup/transform.d.cts +1 -1
- package/dist/markup/transform.d.ts +1 -1
- package/dist/markup/transform.js +5 -4
- package/dist/{model-CZ2mMHJO.d.cts → model-CeOMDDgt.d.cts} +3 -11
- package/dist/{model-CZ2mMHJO.d.ts → model-CeOMDDgt.d.ts} +3 -11
- package/dist/process/processAudiobook.cjs +12 -23
- package/dist/process/processAudiobook.js +14 -30
- package/dist/process/ranges.cjs +2 -2
- package/dist/process/ranges.js +2 -2
- package/dist/readium/guidedNavigation.cjs +8 -8
- package/dist/readium/guidedNavigation.js +8 -8
- package/dist/readium/manifest.cjs +5 -4
- package/dist/readium/manifest.js +5 -4
- package/dist/snapshot/ctc/snapshot.cjs +261 -0
- package/dist/snapshot/ctc/snapshot.d.cts +6 -0
- package/dist/snapshot/ctc/snapshot.d.ts +6 -0
- package/dist/snapshot/ctc/snapshot.js +200 -0
- package/dist/snapshot/parse.cjs +29 -16
- package/dist/snapshot/parse.d.cts +14 -10
- package/dist/snapshot/parse.d.ts +14 -10
- package/dist/snapshot/parse.js +32 -17
- package/dist/transcribe/parse.d.cts +6 -6
- package/dist/transcribe/parse.d.ts +6 -6
- package/dist/transcribe/transcribe.cjs +4 -2
- package/dist/transcribe/transcribe.js +4 -2
- package/package.json +6 -4
- package/dist/process/mime.d.cts +0 -3
- package/dist/process/mime.d.ts +0 -3
- package/dist/process/mime.js +0 -24
|
@@ -72,6 +72,7 @@ var import_node_path = require("node:path");
|
|
|
72
72
|
var import_async_semaphore = require("@esfx/async-semaphore");
|
|
73
73
|
var import_audiobook = require("@storyteller-platform/audiobook");
|
|
74
74
|
var import_ghost_story = require("@storyteller-platform/ghost-story");
|
|
75
|
+
var import_media_types = require("@storyteller-platform/media-types");
|
|
75
76
|
var import_ffmpeg = require("../common/ffmpeg.cjs");
|
|
76
77
|
var import_ranges = require("./ranges.cjs");
|
|
77
78
|
async function processAudiobook(input, output, options) {
|
|
@@ -81,7 +82,10 @@ async function processAudiobook(input, output, options) {
|
|
|
81
82
|
timing.setMetadata("max-length", `${(options.maxLength ?? 2) * 60} minutes`);
|
|
82
83
|
await (0, import_promises.mkdir)(output, { recursive: true });
|
|
83
84
|
const allFiles = await (0, import_promises.readdir)(input, { recursive: true });
|
|
84
|
-
const filenames = allFiles.filter((f) =>
|
|
85
|
+
const filenames = allFiles.filter((f) => {
|
|
86
|
+
const kind = import_media_types.MediaType.fromPath(f)?.kind;
|
|
87
|
+
return kind === "audio" || kind === "archive";
|
|
88
|
+
});
|
|
85
89
|
options.logger?.debug(`Found ${filenames.length} files to process`);
|
|
86
90
|
const outputFiles = [];
|
|
87
91
|
const controller = new AbortController();
|
|
@@ -127,10 +131,10 @@ async function processAudiobook(input, output, options) {
|
|
|
127
131
|
return timing;
|
|
128
132
|
}
|
|
129
133
|
async function resolveVbrEncoding(filepath, userEncoding, logger) {
|
|
130
|
-
if (userEncoding?.codec && userEncoding.codec !==
|
|
134
|
+
if (userEncoding?.codec && userEncoding.codec !== import_audiobook.AUDIO_ENCODERS.mp3) {
|
|
131
135
|
return userEncoding;
|
|
132
136
|
}
|
|
133
|
-
const sourceIsMp3 =
|
|
137
|
+
const sourceIsMp3 = import_media_types.MediaType.fromPath(filepath) === import_media_types.MediaType.MPEG_AUDIO;
|
|
134
138
|
if (!userEncoding?.codec && !sourceIsMp3) {
|
|
135
139
|
return userEncoding;
|
|
136
140
|
}
|
|
@@ -143,7 +147,7 @@ async function resolveVbrEncoding(filepath, userEncoding, logger) {
|
|
|
143
147
|
`Forcing CBR MP3 for ${filepath} (avg ${trackInfo.bitRate}bps) at ${targetBitrate / 1e3}k`
|
|
144
148
|
);
|
|
145
149
|
return {
|
|
146
|
-
codec:
|
|
150
|
+
codec: import_audiobook.AUDIO_ENCODERS.mp3,
|
|
147
151
|
bitrate: `${targetBitrate / 1e3}k`
|
|
148
152
|
};
|
|
149
153
|
}
|
|
@@ -182,10 +186,10 @@ async function processFile(input, output, prefix, options) {
|
|
|
182
186
|
var _stack2 = [];
|
|
183
187
|
try {
|
|
184
188
|
const effectiveEncoding = vbrEncodings.has(range.filepath) ? vbrEncodings.get(range.filepath) : options.encoding;
|
|
185
|
-
const outputExtension =
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
);
|
|
189
|
+
const outputExtension = (0, import_audiobook.outputContainer)(
|
|
190
|
+
effectiveEncoding?.codec,
|
|
191
|
+
import_media_types.MediaType.fromPath(range.filepath)
|
|
192
|
+
)?.extension ?? (0, import_node_path.extname)(range.filepath);
|
|
189
193
|
const outputFilename = `${prefix}${(index + 1).toString().padStart(5, "0")}${outputExtension}`;
|
|
190
194
|
const outputFilepath = (0, import_node_path.join)(output, outputFilename);
|
|
191
195
|
const stack = __using(_stack2, new DisposableStack());
|
|
@@ -226,21 +230,6 @@ async function processFile(input, output, prefix, options) {
|
|
|
226
230
|
__callDispose(_stack, _error, _hasError);
|
|
227
231
|
}
|
|
228
232
|
}
|
|
229
|
-
function determineExtension(input, codec) {
|
|
230
|
-
if (codec === "libmp3lame") {
|
|
231
|
-
return ".mp3";
|
|
232
|
-
}
|
|
233
|
-
if (codec === "aac" || codec === "libopus") {
|
|
234
|
-
return ".mp4";
|
|
235
|
-
}
|
|
236
|
-
if (import_audiobook.MP3_FILE_EXTENSIONS.some((ext) => input.endsWith(ext))) {
|
|
237
|
-
return ".mp3";
|
|
238
|
-
}
|
|
239
|
-
if (import_audiobook.MPEG4_FILE_EXTENSIONS.some((ext) => input.endsWith(ext)) || import_audiobook.OGG_FILE_EXTENSIONS.some((ext) => input.endsWith(ext)) || import_audiobook.OPUS_FILE_EXTENSIONS.some((ext) => input.endsWith(ext)) || import_audiobook.AAC_FILE_EXTENSIONS.some((ext) => input.endsWith(ext))) {
|
|
240
|
-
return ".mp4";
|
|
241
|
-
}
|
|
242
|
-
return (0, import_node_path.extname)(input);
|
|
243
|
-
}
|
|
244
233
|
// Annotate the CommonJS export names for ESM import in node:
|
|
245
234
|
0 && (module.exports = {
|
|
246
235
|
processAudiobook,
|
|
@@ -6,19 +6,15 @@ import { mkdir, readdir } from "node:fs/promises";
|
|
|
6
6
|
import { extname, join } from "node:path";
|
|
7
7
|
import { AsyncSemaphore } from "@esfx/async-semaphore";
|
|
8
8
|
import {
|
|
9
|
-
|
|
9
|
+
AUDIO_ENCODERS,
|
|
10
10
|
Audiobook,
|
|
11
|
-
|
|
12
|
-
MPEG4_FILE_EXTENSIONS,
|
|
13
|
-
OGG_FILE_EXTENSIONS,
|
|
14
|
-
OPUS_FILE_EXTENSIONS,
|
|
15
|
-
isAudioFile,
|
|
16
|
-
isZipArchive
|
|
11
|
+
outputContainer
|
|
17
12
|
} from "@storyteller-platform/audiobook";
|
|
18
13
|
import {
|
|
19
14
|
createAggregator,
|
|
20
15
|
createTiming
|
|
21
16
|
} from "@storyteller-platform/ghost-story";
|
|
17
|
+
import { MediaType } from "@storyteller-platform/media-types";
|
|
22
18
|
import {
|
|
23
19
|
getTrackInfo,
|
|
24
20
|
isVbrMp3,
|
|
@@ -33,7 +29,10 @@ async function processAudiobook(input, output, options) {
|
|
|
33
29
|
timing.setMetadata("max-length", `${(options.maxLength ?? 2) * 60} minutes`);
|
|
34
30
|
await mkdir(output, { recursive: true });
|
|
35
31
|
const allFiles = await readdir(input, { recursive: true });
|
|
36
|
-
const filenames = allFiles.filter((f) =>
|
|
32
|
+
const filenames = allFiles.filter((f) => {
|
|
33
|
+
const kind = MediaType.fromPath(f)?.kind;
|
|
34
|
+
return kind === "audio" || kind === "archive";
|
|
35
|
+
});
|
|
37
36
|
options.logger?.debug(`Found ${filenames.length} files to process`);
|
|
38
37
|
const outputFiles = [];
|
|
39
38
|
const controller = new AbortController();
|
|
@@ -79,10 +78,10 @@ async function processAudiobook(input, output, options) {
|
|
|
79
78
|
return timing;
|
|
80
79
|
}
|
|
81
80
|
async function resolveVbrEncoding(filepath, userEncoding, logger) {
|
|
82
|
-
if (userEncoding?.codec && userEncoding.codec !==
|
|
81
|
+
if (userEncoding?.codec && userEncoding.codec !== AUDIO_ENCODERS.mp3) {
|
|
83
82
|
return userEncoding;
|
|
84
83
|
}
|
|
85
|
-
const sourceIsMp3 =
|
|
84
|
+
const sourceIsMp3 = MediaType.fromPath(filepath) === MediaType.MPEG_AUDIO;
|
|
86
85
|
if (!userEncoding?.codec && !sourceIsMp3) {
|
|
87
86
|
return userEncoding;
|
|
88
87
|
}
|
|
@@ -95,7 +94,7 @@ async function resolveVbrEncoding(filepath, userEncoding, logger) {
|
|
|
95
94
|
`Forcing CBR MP3 for ${filepath} (avg ${trackInfo.bitRate}bps) at ${targetBitrate / 1e3}k`
|
|
96
95
|
);
|
|
97
96
|
return {
|
|
98
|
-
codec:
|
|
97
|
+
codec: AUDIO_ENCODERS.mp3,
|
|
99
98
|
bitrate: `${targetBitrate / 1e3}k`
|
|
100
99
|
};
|
|
101
100
|
}
|
|
@@ -134,10 +133,10 @@ async function processFile(input, output, prefix, options) {
|
|
|
134
133
|
var _stack2 = [];
|
|
135
134
|
try {
|
|
136
135
|
const effectiveEncoding = vbrEncodings.has(range.filepath) ? vbrEncodings.get(range.filepath) : options.encoding;
|
|
137
|
-
const outputExtension =
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
);
|
|
136
|
+
const outputExtension = outputContainer(
|
|
137
|
+
effectiveEncoding?.codec,
|
|
138
|
+
MediaType.fromPath(range.filepath)
|
|
139
|
+
)?.extension ?? extname(range.filepath);
|
|
141
140
|
const outputFilename = `${prefix}${(index + 1).toString().padStart(5, "0")}${outputExtension}`;
|
|
142
141
|
const outputFilepath = join(output, outputFilename);
|
|
143
142
|
const stack = __using(_stack2, new DisposableStack());
|
|
@@ -178,21 +177,6 @@ async function processFile(input, output, prefix, options) {
|
|
|
178
177
|
__callDispose(_stack, _error, _hasError);
|
|
179
178
|
}
|
|
180
179
|
}
|
|
181
|
-
function determineExtension(input, codec) {
|
|
182
|
-
if (codec === "libmp3lame") {
|
|
183
|
-
return ".mp3";
|
|
184
|
-
}
|
|
185
|
-
if (codec === "aac" || codec === "libopus") {
|
|
186
|
-
return ".mp4";
|
|
187
|
-
}
|
|
188
|
-
if (MP3_FILE_EXTENSIONS.some((ext) => input.endsWith(ext))) {
|
|
189
|
-
return ".mp3";
|
|
190
|
-
}
|
|
191
|
-
if (MPEG4_FILE_EXTENSIONS.some((ext) => input.endsWith(ext)) || OGG_FILE_EXTENSIONS.some((ext) => input.endsWith(ext)) || OPUS_FILE_EXTENSIONS.some((ext) => input.endsWith(ext)) || AAC_FILE_EXTENSIONS.some((ext) => input.endsWith(ext))) {
|
|
192
|
-
return ".mp4";
|
|
193
|
-
}
|
|
194
|
-
return extname(input);
|
|
195
|
-
}
|
|
196
180
|
export {
|
|
197
181
|
processAudiobook,
|
|
198
182
|
processFile
|
package/dist/process/ranges.cjs
CHANGED
|
@@ -69,8 +69,8 @@ __export(ranges_exports, {
|
|
|
69
69
|
module.exports = __toCommonJS(ranges_exports);
|
|
70
70
|
var import_node_crypto = require("node:crypto");
|
|
71
71
|
var import_promises = require("node:fs/promises");
|
|
72
|
-
var import_node_os = require("node:os");
|
|
73
72
|
var import_node_path = require("node:path");
|
|
73
|
+
var import_fs = require("@storyteller-platform/fs");
|
|
74
74
|
var import_vad = require("@storyteller-platform/ghost-story/vad");
|
|
75
75
|
var import_ffmpeg = require("../common/ffmpeg.cjs");
|
|
76
76
|
async function getSafeChapterRanges(input, duration, chapters, maxSeconds, signal, logger) {
|
|
@@ -125,7 +125,7 @@ async function getSafeRanges(input, duration, maxSeconds, start = 0, signal, log
|
|
|
125
125
|
try {
|
|
126
126
|
const ext = (0, import_node_path.extname)(input);
|
|
127
127
|
const rawFilename = (0, import_node_path.basename)(input, ext);
|
|
128
|
-
const tmpDir = (0,
|
|
128
|
+
const tmpDir = (0, import_fs.scratchPath)(`storyteller-align-silence-${(0, import_node_crypto.randomUUID)()}`);
|
|
129
129
|
const stack = __using(_stack, new AsyncDisposableStack(), true);
|
|
130
130
|
stack.defer(async () => {
|
|
131
131
|
await (0, import_promises.rm)(tmpDir, { recursive: true, force: true });
|
package/dist/process/ranges.js
CHANGED
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
} from "../chunk-BIEQXUOY.js";
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
6
|
import { mkdir, rm } from "node:fs/promises";
|
|
7
|
-
import { tmpdir } from "node:os";
|
|
8
7
|
import { basename, dirname, extname, join } from "node:path";
|
|
8
|
+
import { scratchPath } from "@storyteller-platform/fs";
|
|
9
9
|
import { detectVoiceActivity } from "@storyteller-platform/ghost-story/vad";
|
|
10
10
|
import { splitFile } from "../common/ffmpeg.js";
|
|
11
11
|
async function getSafeChapterRanges(input, duration, chapters, maxSeconds, signal, logger) {
|
|
@@ -60,7 +60,7 @@ async function getSafeRanges(input, duration, maxSeconds, start = 0, signal, log
|
|
|
60
60
|
try {
|
|
61
61
|
const ext = extname(input);
|
|
62
62
|
const rawFilename = basename(input, ext);
|
|
63
|
-
const tmpDir =
|
|
63
|
+
const tmpDir = scratchPath(`storyteller-align-silence-${randomUUID()}`);
|
|
64
64
|
const stack = __using(_stack, new AsyncDisposableStack(), true);
|
|
65
65
|
stack.defer(async () => {
|
|
66
66
|
await rm(tmpDir, { recursive: true, force: true });
|
|
@@ -36,8 +36,8 @@ var import_shared = require("@readium/shared");
|
|
|
36
36
|
var import_change_case = require("change-case");
|
|
37
37
|
var import_itertools = require("itertools");
|
|
38
38
|
var import_smil_clockvalue = __toESM(require("smil-clockvalue"), 1);
|
|
39
|
-
var import_audiobook = require("@storyteller-platform/audiobook");
|
|
40
39
|
var import_epub = require("@storyteller-platform/epub");
|
|
40
|
+
var import_media_types = require("@storyteller-platform/media-types");
|
|
41
41
|
function generateGuidedNavigationManifest(title, guidedNavDocs) {
|
|
42
42
|
const readingOrder = [];
|
|
43
43
|
for (const doc of guidedNavDocs) {
|
|
@@ -67,18 +67,18 @@ function generateGuidedNavigationManifest(title, guidedNavDocs) {
|
|
|
67
67
|
const audioReferences = Object.entries(referencedAudioFiles).map(
|
|
68
68
|
([audioFile, { start, end }]) => ({
|
|
69
69
|
href: `${audioFile}#t=${start},${end}`,
|
|
70
|
-
type:
|
|
70
|
+
type: import_media_types.MediaType.fromPath(audioFile)?.mime ?? null
|
|
71
71
|
})
|
|
72
72
|
);
|
|
73
73
|
readingOrder.push(
|
|
74
74
|
new import_shared.Link({
|
|
75
75
|
href,
|
|
76
|
-
type:
|
|
76
|
+
type: import_media_types.MediaType.GUIDED_NAVIGATION.mime,
|
|
77
77
|
properties: new import_shared.Properties({
|
|
78
78
|
references: [
|
|
79
79
|
{
|
|
80
80
|
href: textref,
|
|
81
|
-
type:
|
|
81
|
+
type: import_media_types.MediaType.XHTML.mime
|
|
82
82
|
},
|
|
83
83
|
...audioReferences
|
|
84
84
|
]
|
|
@@ -96,7 +96,7 @@ function generateGuidedNavigationManifest(title, guidedNavDocs) {
|
|
|
96
96
|
links: new import_shared.Links([
|
|
97
97
|
new import_shared.Link({
|
|
98
98
|
href: "manifest.json",
|
|
99
|
-
type:
|
|
99
|
+
type: import_media_types.MediaType.WEBPUB_MANIFEST.mime,
|
|
100
100
|
rels: /* @__PURE__ */ new Set(["self"])
|
|
101
101
|
})
|
|
102
102
|
]),
|
|
@@ -126,7 +126,7 @@ async function generateGuidedNavigationDocuments(epub) {
|
|
|
126
126
|
new import_shared.Link({
|
|
127
127
|
rels: /* @__PURE__ */ new Set(["prev"]),
|
|
128
128
|
href: `GND/${prevOverlay.id}.json`,
|
|
129
|
-
type:
|
|
129
|
+
type: import_media_types.MediaType.GUIDED_NAVIGATION.mime
|
|
130
130
|
})
|
|
131
131
|
);
|
|
132
132
|
}
|
|
@@ -134,7 +134,7 @@ async function generateGuidedNavigationDocuments(epub) {
|
|
|
134
134
|
new import_shared.Link({
|
|
135
135
|
rels: /* @__PURE__ */ new Set(["self"]),
|
|
136
136
|
href: `GND/${overlay.id}.json`,
|
|
137
|
-
type:
|
|
137
|
+
type: import_media_types.MediaType.GUIDED_NAVIGATION.mime
|
|
138
138
|
})
|
|
139
139
|
);
|
|
140
140
|
const nextOverlay = mediaOverlays[i + 1];
|
|
@@ -143,7 +143,7 @@ async function generateGuidedNavigationDocuments(epub) {
|
|
|
143
143
|
new import_shared.Link({
|
|
144
144
|
rels: /* @__PURE__ */ new Set(["next"]),
|
|
145
145
|
href: `GND/${nextOverlay.id}.json`,
|
|
146
|
-
type:
|
|
146
|
+
type: import_media_types.MediaType.GUIDED_NAVIGATION.mime
|
|
147
147
|
})
|
|
148
148
|
);
|
|
149
149
|
}
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
import { camelCase } from "change-case";
|
|
12
12
|
import { enumerate } from "itertools";
|
|
13
13
|
import clockvalue from "smil-clockvalue";
|
|
14
|
-
import { lookupAudioMime } from "@storyteller-platform/audiobook";
|
|
15
14
|
import {
|
|
16
15
|
Epub
|
|
17
16
|
} from "@storyteller-platform/epub";
|
|
17
|
+
import { MediaType } from "@storyteller-platform/media-types";
|
|
18
18
|
function generateGuidedNavigationManifest(title, guidedNavDocs) {
|
|
19
19
|
const readingOrder = [];
|
|
20
20
|
for (const doc of guidedNavDocs) {
|
|
@@ -44,18 +44,18 @@ function generateGuidedNavigationManifest(title, guidedNavDocs) {
|
|
|
44
44
|
const audioReferences = Object.entries(referencedAudioFiles).map(
|
|
45
45
|
([audioFile, { start, end }]) => ({
|
|
46
46
|
href: `${audioFile}#t=${start},${end}`,
|
|
47
|
-
type:
|
|
47
|
+
type: MediaType.fromPath(audioFile)?.mime ?? null
|
|
48
48
|
})
|
|
49
49
|
);
|
|
50
50
|
readingOrder.push(
|
|
51
51
|
new Link({
|
|
52
52
|
href,
|
|
53
|
-
type:
|
|
53
|
+
type: MediaType.GUIDED_NAVIGATION.mime,
|
|
54
54
|
properties: new Properties({
|
|
55
55
|
references: [
|
|
56
56
|
{
|
|
57
57
|
href: textref,
|
|
58
|
-
type:
|
|
58
|
+
type: MediaType.XHTML.mime
|
|
59
59
|
},
|
|
60
60
|
...audioReferences
|
|
61
61
|
]
|
|
@@ -73,7 +73,7 @@ function generateGuidedNavigationManifest(title, guidedNavDocs) {
|
|
|
73
73
|
links: new Links([
|
|
74
74
|
new Link({
|
|
75
75
|
href: "manifest.json",
|
|
76
|
-
type:
|
|
76
|
+
type: MediaType.WEBPUB_MANIFEST.mime,
|
|
77
77
|
rels: /* @__PURE__ */ new Set(["self"])
|
|
78
78
|
})
|
|
79
79
|
]),
|
|
@@ -103,7 +103,7 @@ async function generateGuidedNavigationDocuments(epub) {
|
|
|
103
103
|
new Link({
|
|
104
104
|
rels: /* @__PURE__ */ new Set(["prev"]),
|
|
105
105
|
href: `GND/${prevOverlay.id}.json`,
|
|
106
|
-
type:
|
|
106
|
+
type: MediaType.GUIDED_NAVIGATION.mime
|
|
107
107
|
})
|
|
108
108
|
);
|
|
109
109
|
}
|
|
@@ -111,7 +111,7 @@ async function generateGuidedNavigationDocuments(epub) {
|
|
|
111
111
|
new Link({
|
|
112
112
|
rels: /* @__PURE__ */ new Set(["self"]),
|
|
113
113
|
href: `GND/${overlay.id}.json`,
|
|
114
|
-
type:
|
|
114
|
+
type: MediaType.GUIDED_NAVIGATION.mime
|
|
115
115
|
})
|
|
116
116
|
);
|
|
117
117
|
const nextOverlay = mediaOverlays[i + 1];
|
|
@@ -120,7 +120,7 @@ async function generateGuidedNavigationDocuments(epub) {
|
|
|
120
120
|
new Link({
|
|
121
121
|
rels: /* @__PURE__ */ new Set(["next"]),
|
|
122
122
|
href: `GND/${nextOverlay.id}.json`,
|
|
123
|
-
type:
|
|
123
|
+
type: MediaType.GUIDED_NAVIGATION.mime
|
|
124
124
|
})
|
|
125
125
|
);
|
|
126
126
|
}
|
|
@@ -33,6 +33,7 @@ __export(manifest_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(manifest_exports);
|
|
34
34
|
var import_shared = require("@readium/shared");
|
|
35
35
|
var import_smil_clockvalue = __toESM(require("smil-clockvalue"), 1);
|
|
36
|
+
var import_media_types = require("@storyteller-platform/media-types");
|
|
36
37
|
const BYTES_PER_PAGE = 1024;
|
|
37
38
|
async function generateReadiumManifest(epub, options = {}) {
|
|
38
39
|
const primaryLocale = await epub.getLanguage() ?? new Intl.Locale("en-US");
|
|
@@ -161,7 +162,7 @@ async function generateReadiumManifest(epub, options = {}) {
|
|
|
161
162
|
alternates: new import_shared.Links([
|
|
162
163
|
new import_shared.Link({
|
|
163
164
|
href: `GND/${mediaOverlayItem.id}.json`,
|
|
164
|
-
type:
|
|
165
|
+
type: import_media_types.MediaType.GUIDED_NAVIGATION.mime
|
|
165
166
|
})
|
|
166
167
|
])
|
|
167
168
|
});
|
|
@@ -174,7 +175,7 @@ async function generateReadiumManifest(epub, options = {}) {
|
|
|
174
175
|
if (item.id === coverItem?.id) {
|
|
175
176
|
rels.add("cover");
|
|
176
177
|
}
|
|
177
|
-
if (item.mediaType ===
|
|
178
|
+
if (item.mediaType === import_media_types.MediaType.XHTML.mime) {
|
|
178
179
|
rels.add("contents");
|
|
179
180
|
}
|
|
180
181
|
const otherResourceMetadata = epubMetadata.filter((meta) => meta.properties["refines"] === `#${item.id}`).filter(
|
|
@@ -232,7 +233,7 @@ async function generateReadiumManifest(epub, options = {}) {
|
|
|
232
233
|
links: new import_shared.Links([
|
|
233
234
|
new import_shared.Link({
|
|
234
235
|
href: "manifest.json",
|
|
235
|
-
type:
|
|
236
|
+
type: import_media_types.MediaType.WEBPUB_MANIFEST.mime,
|
|
236
237
|
rels: /* @__PURE__ */ new Set(["self"])
|
|
237
238
|
})
|
|
238
239
|
]),
|
|
@@ -249,7 +250,7 @@ async function inferPageCount(epub, spine, signal) {
|
|
|
249
250
|
signal.reason instanceof Error ? signal.reason.message : "Aborted while inferring page count"
|
|
250
251
|
);
|
|
251
252
|
}
|
|
252
|
-
if (item.mediaType !==
|
|
253
|
+
if (item.mediaType !== import_media_types.MediaType.XHTML.mime) continue;
|
|
253
254
|
try {
|
|
254
255
|
const length = await epub.getItemArchiveLength(item.id);
|
|
255
256
|
total += Math.max(1, Math.ceil(length / BYTES_PER_PAGE));
|
package/dist/readium/manifest.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
Subjects
|
|
17
17
|
} from "@readium/shared";
|
|
18
18
|
import clockvalue from "smil-clockvalue";
|
|
19
|
+
import { MediaType } from "@storyteller-platform/media-types";
|
|
19
20
|
const BYTES_PER_PAGE = 1024;
|
|
20
21
|
async function generateReadiumManifest(epub, options = {}) {
|
|
21
22
|
const primaryLocale = await epub.getLanguage() ?? new Intl.Locale("en-US");
|
|
@@ -144,7 +145,7 @@ async function generateReadiumManifest(epub, options = {}) {
|
|
|
144
145
|
alternates: new Links([
|
|
145
146
|
new Link({
|
|
146
147
|
href: `GND/${mediaOverlayItem.id}.json`,
|
|
147
|
-
type:
|
|
148
|
+
type: MediaType.GUIDED_NAVIGATION.mime
|
|
148
149
|
})
|
|
149
150
|
])
|
|
150
151
|
});
|
|
@@ -157,7 +158,7 @@ async function generateReadiumManifest(epub, options = {}) {
|
|
|
157
158
|
if (item.id === coverItem?.id) {
|
|
158
159
|
rels.add("cover");
|
|
159
160
|
}
|
|
160
|
-
if (item.mediaType ===
|
|
161
|
+
if (item.mediaType === MediaType.XHTML.mime) {
|
|
161
162
|
rels.add("contents");
|
|
162
163
|
}
|
|
163
164
|
const otherResourceMetadata = epubMetadata.filter((meta) => meta.properties["refines"] === `#${item.id}`).filter(
|
|
@@ -215,7 +216,7 @@ async function generateReadiumManifest(epub, options = {}) {
|
|
|
215
216
|
links: new Links([
|
|
216
217
|
new Link({
|
|
217
218
|
href: "manifest.json",
|
|
218
|
-
type:
|
|
219
|
+
type: MediaType.WEBPUB_MANIFEST.mime,
|
|
219
220
|
rels: /* @__PURE__ */ new Set(["self"])
|
|
220
221
|
})
|
|
221
222
|
]),
|
|
@@ -232,7 +233,7 @@ async function inferPageCount(epub, spine, signal) {
|
|
|
232
233
|
signal.reason instanceof Error ? signal.reason.message : "Aborted while inferring page count"
|
|
233
234
|
);
|
|
234
235
|
}
|
|
235
|
-
if (item.mediaType !==
|
|
236
|
+
if (item.mediaType !== MediaType.XHTML.mime) continue;
|
|
236
237
|
try {
|
|
237
238
|
const length = await epub.getItemArchiveLength(item.id);
|
|
238
239
|
total += Math.max(1, Math.ceil(length / BYTES_PER_PAGE));
|