@storyteller-platform/align 0.1.39-rc.4 → 0.1.39
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/parse.cjs +2 -0
- package/dist/align/parse.d.cts +4 -0
- package/dist/align/parse.d.ts +4 -0
- package/dist/align/parse.js +5 -1
- package/dist/cli/bin.cjs +50 -5
- package/dist/cli/bin.js +54 -7
- package/dist/common/parse.cjs +16 -2
- package/dist/common/parse.d.cts +11 -1
- package/dist/common/parse.d.ts +11 -1
- package/dist/common/parse.js +13 -1
- package/dist/index.cjs +5 -2
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/markup/markup.cjs +1 -1
- package/dist/markup/markup.js +1 -1
- package/dist/markup/parse.cjs +2 -0
- package/dist/markup/parse.d.cts +4 -0
- package/dist/markup/parse.d.ts +4 -0
- package/dist/markup/parse.js +5 -1
- package/dist/upgradeEpub/parse.cjs +44 -0
- package/dist/upgradeEpub/parse.d.cts +11 -0
- package/dist/upgradeEpub/parse.d.ts +11 -0
- package/dist/upgradeEpub/parse.js +28 -0
- package/dist/upgradeEpub/upgradeEpub.cjs +84 -0
- package/dist/upgradeEpub/upgradeEpub.d.cts +6 -0
- package/dist/upgradeEpub/upgradeEpub.d.ts +6 -0
- package/dist/upgradeEpub/upgradeEpub.js +19 -0
- package/package.json +2 -2
- package/prebuilds/win32-x64/@storyteller-platform+align.node +0 -0
package/dist/align/parse.cjs
CHANGED
package/dist/align/parse.d.cts
CHANGED
|
@@ -23,6 +23,10 @@ declare const alignCommand: _optique_core.Parser<"sync", {
|
|
|
23
23
|
readonly textRef: "id-fragment" | "text-fragment";
|
|
24
24
|
readonly reports: string | undefined;
|
|
25
25
|
readonly outFormat: "epub" | "gnp";
|
|
26
|
+
} & {
|
|
27
|
+
readonly autoupgrade: boolean;
|
|
28
|
+
} & {
|
|
29
|
+
readonly removeNcx: boolean;
|
|
26
30
|
} & {
|
|
27
31
|
readonly noProgress: boolean;
|
|
28
32
|
readonly logLevel: "silent" | "debug" | "info" | "warn" | "error";
|
package/dist/align/parse.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ declare const alignCommand: _optique_core.Parser<"sync", {
|
|
|
23
23
|
readonly textRef: "id-fragment" | "text-fragment";
|
|
24
24
|
readonly reports: string | undefined;
|
|
25
25
|
readonly outFormat: "epub" | "gnp";
|
|
26
|
+
} & {
|
|
27
|
+
readonly autoupgrade: boolean;
|
|
28
|
+
} & {
|
|
29
|
+
readonly removeNcx: boolean;
|
|
26
30
|
} & {
|
|
27
31
|
readonly noProgress: boolean;
|
|
28
32
|
readonly logLevel: "silent" | "debug" | "info" | "warn" | "error";
|
package/dist/align/parse.js
CHANGED
|
@@ -12,9 +12,11 @@ import {
|
|
|
12
12
|
} from "@optique/core";
|
|
13
13
|
import { path } from "@optique/run/valueparser";
|
|
14
14
|
import {
|
|
15
|
+
autoUpgradeParser,
|
|
15
16
|
granularityParser,
|
|
16
17
|
languageParser,
|
|
17
|
-
loggingParser
|
|
18
|
+
loggingParser,
|
|
19
|
+
removeNcxParser
|
|
18
20
|
} from "../common/parse.js";
|
|
19
21
|
const alignParser = object("Alignment", {
|
|
20
22
|
audiobook: option(
|
|
@@ -58,6 +60,8 @@ const alignCommand = command(
|
|
|
58
60
|
)
|
|
59
61
|
}),
|
|
60
62
|
alignParser,
|
|
63
|
+
autoUpgradeParser,
|
|
64
|
+
removeNcxParser,
|
|
61
65
|
loggingParser,
|
|
62
66
|
languageParser,
|
|
63
67
|
granularityParser
|
package/dist/cli/bin.cjs
CHANGED
|
@@ -89,6 +89,8 @@ var import_parse5 = require("../snapshot/parse.cjs");
|
|
|
89
89
|
var import_snapshot = require("../snapshot/snapshot.cjs");
|
|
90
90
|
var import_parse6 = require("../transcribe/parse.cjs");
|
|
91
91
|
var import_transcribe = require("../transcribe/transcribe.cjs");
|
|
92
|
+
var import_parse7 = require("../upgradeEpub/parse.cjs");
|
|
93
|
+
var import_upgradeEpub = require("../upgradeEpub/upgradeEpub.cjs");
|
|
92
94
|
const pipelineCommand = (0, import_core.merge)(
|
|
93
95
|
(0, import_core.object)({
|
|
94
96
|
action: (0, import_core.constant)("pipeline"),
|
|
@@ -113,6 +115,8 @@ const pipelineCommand = (0, import_core.merge)(
|
|
|
113
115
|
}),
|
|
114
116
|
import_parse4.processParser,
|
|
115
117
|
(0, import_core.group)("Transcription", import_parse6.transcribeParser),
|
|
118
|
+
import_parse2.autoUpgradeParser,
|
|
119
|
+
import_parse2.removeNcxParser,
|
|
116
120
|
import_parse2.granularityParser,
|
|
117
121
|
import_parse2.languageParser,
|
|
118
122
|
import_parse.alignParser,
|
|
@@ -121,6 +125,7 @@ const pipelineCommand = (0, import_core.merge)(
|
|
|
121
125
|
const parser = (0, import_core.or)(
|
|
122
126
|
import_parse4.processCommand,
|
|
123
127
|
import_parse6.transcribeCommand,
|
|
128
|
+
import_parse7.upgradeEpubCommand,
|
|
124
129
|
import_parse3.markupCommand,
|
|
125
130
|
import_parse.alignCommand,
|
|
126
131
|
pipelineCommand,
|
|
@@ -147,6 +152,7 @@ async function main() {
|
|
|
147
152
|
);
|
|
148
153
|
}
|
|
149
154
|
function startProgressBar() {
|
|
155
|
+
if (parsed.action === "upgrade-epub") return;
|
|
150
156
|
if (!parsed.noProgress && parsed.logLevel === "silent") {
|
|
151
157
|
progressBar.start(100, 0);
|
|
152
158
|
}
|
|
@@ -161,7 +167,9 @@ async function main() {
|
|
|
161
167
|
progressBar.stop();
|
|
162
168
|
});
|
|
163
169
|
startProgressBar();
|
|
164
|
-
const logger = (0, import_logging.createLogger)(
|
|
170
|
+
const logger = (0, import_logging.createLogger)(
|
|
171
|
+
parsed.action === "upgrade-epub" ? "warn" : parsed.logLevel
|
|
172
|
+
);
|
|
165
173
|
switch (parsed.action) {
|
|
166
174
|
case "process": {
|
|
167
175
|
const timing = await (0, import_processAudiobook.processAudiobook)(parsed.input, parsed.output, {
|
|
@@ -202,8 +210,24 @@ async function main() {
|
|
|
202
210
|
}
|
|
203
211
|
break;
|
|
204
212
|
}
|
|
213
|
+
case "upgrade-epub": {
|
|
214
|
+
await (0, import_upgradeEpub.upgradeEpub)(parsed.input, parsed.output, {
|
|
215
|
+
removeNcx: parsed.removeNcx
|
|
216
|
+
});
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
205
219
|
case "markup": {
|
|
206
|
-
|
|
220
|
+
let input = parsed.input;
|
|
221
|
+
if (parsed.autoupgrade) {
|
|
222
|
+
logger.info("Upgrading EPUB 2 to EPUB 3");
|
|
223
|
+
input = (0, import_node_path.join)(
|
|
224
|
+
os.tmpdir(),
|
|
225
|
+
`stalign-autoupgrade-${(0, import_node_crypto.randomUUID)()}`,
|
|
226
|
+
(0, import_node_path.basename)(parsed.input)
|
|
227
|
+
);
|
|
228
|
+
await (0, import_upgradeEpub.upgradeEpub)(parsed.input, input, { removeNcx: parsed.removeNcx });
|
|
229
|
+
}
|
|
230
|
+
const timing = await (0, import_markup.markup)(input, parsed.output, {
|
|
207
231
|
primaryLocale: parsed.language ?? new Intl.Locale("en-US"),
|
|
208
232
|
granularity: parsed.granularity,
|
|
209
233
|
logger,
|
|
@@ -219,8 +243,18 @@ async function main() {
|
|
|
219
243
|
break;
|
|
220
244
|
}
|
|
221
245
|
case "align": {
|
|
246
|
+
let input = parsed.epub;
|
|
247
|
+
if (parsed.autoupgrade) {
|
|
248
|
+
logger.info("Upgrading EPUB 2 to EPUB 3");
|
|
249
|
+
input = (0, import_node_path.join)(
|
|
250
|
+
os.tmpdir(),
|
|
251
|
+
`stalign-autoupgrade-${(0, import_node_crypto.randomUUID)()}`,
|
|
252
|
+
(0, import_node_path.basename)(parsed.epub)
|
|
253
|
+
);
|
|
254
|
+
await (0, import_upgradeEpub.upgradeEpub)(parsed.epub, input, { removeNcx: parsed.removeNcx });
|
|
255
|
+
}
|
|
222
256
|
const timing = await (0, import_align.align)(
|
|
223
|
-
|
|
257
|
+
input,
|
|
224
258
|
parsed.output,
|
|
225
259
|
parsed.transcriptions,
|
|
226
260
|
parsed.audiobook,
|
|
@@ -246,8 +280,19 @@ async function main() {
|
|
|
246
280
|
case "pipeline": {
|
|
247
281
|
var _stack = [];
|
|
248
282
|
try {
|
|
249
|
-
|
|
283
|
+
let input = parsed.epub;
|
|
284
|
+
if (parsed.autoupgrade) {
|
|
285
|
+
logger.info("Upgrading EPUB 2 to EPUB 3");
|
|
286
|
+
input = (0, import_node_path.join)(
|
|
287
|
+
os.tmpdir(),
|
|
288
|
+
`stalign-autoupgrade-${(0, import_node_crypto.randomUUID)()}`,
|
|
289
|
+
(0, import_node_path.basename)(parsed.epub)
|
|
290
|
+
);
|
|
291
|
+
await (0, import_upgradeEpub.upgradeEpub)(parsed.epub, input, { removeNcx: parsed.removeNcx });
|
|
292
|
+
}
|
|
293
|
+
const epub = __using(_stack, await import_epub.Epub.from(input));
|
|
250
294
|
const primaryLocale = parsed.language ?? await epub.getLanguage() ?? new Intl.Locale("en-US");
|
|
295
|
+
epub.discardAndClose();
|
|
251
296
|
const processedAudio = parsed.processedAudio ?? (0, import_node_path.join)(os.tmpdir(), `stalign-processed-${(0, import_node_crypto.randomUUID)()}`);
|
|
252
297
|
if (!parsed.processedAudio) {
|
|
253
298
|
stack.defer(() => {
|
|
@@ -320,7 +365,7 @@ async function main() {
|
|
|
320
365
|
(0, import_node_fs.rmSync)(markedup2, { recursive: true, force: true });
|
|
321
366
|
});
|
|
322
367
|
}
|
|
323
|
-
const markupTiming = await (0, import_markup.markup)(
|
|
368
|
+
const markupTiming = await (0, import_markup.markup)(input, markedup2, {
|
|
324
369
|
granularity: parsed.granularity,
|
|
325
370
|
primaryLocale,
|
|
326
371
|
logger,
|
package/dist/cli/bin.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
import { rmSync } from "node:fs";
|
|
8
8
|
import * as os from "node:os";
|
|
9
|
-
import { join } from "node:path";
|
|
9
|
+
import { basename, join } from "node:path";
|
|
10
10
|
import {
|
|
11
11
|
constant,
|
|
12
12
|
group,
|
|
@@ -28,9 +28,11 @@ import { align } from "../align/align.js";
|
|
|
28
28
|
import { alignCommand, alignParser } from "../align/parse.js";
|
|
29
29
|
import { createLogger } from "../common/logging.js";
|
|
30
30
|
import {
|
|
31
|
+
autoUpgradeParser,
|
|
31
32
|
granularityParser,
|
|
32
33
|
languageParser,
|
|
33
|
-
loggingParser
|
|
34
|
+
loggingParser,
|
|
35
|
+
removeNcxParser
|
|
34
36
|
} from "../common/parse.js";
|
|
35
37
|
import { markup } from "../markup/markup.js";
|
|
36
38
|
import { markupCommand } from "../markup/parse.js";
|
|
@@ -40,6 +42,8 @@ import { snapshotCommand } from "../snapshot/parse.js";
|
|
|
40
42
|
import { snapshotAlignment } from "../snapshot/snapshot.js";
|
|
41
43
|
import { transcribeCommand, transcribeParser } from "../transcribe/parse.js";
|
|
42
44
|
import { transcribe } from "../transcribe/transcribe.js";
|
|
45
|
+
import { upgradeEpubCommand } from "../upgradeEpub/parse.js";
|
|
46
|
+
import { upgradeEpub } from "../upgradeEpub/upgradeEpub.js";
|
|
43
47
|
const pipelineCommand = merge(
|
|
44
48
|
object({
|
|
45
49
|
action: constant("pipeline"),
|
|
@@ -64,6 +68,8 @@ const pipelineCommand = merge(
|
|
|
64
68
|
}),
|
|
65
69
|
processParser,
|
|
66
70
|
group("Transcription", transcribeParser),
|
|
71
|
+
autoUpgradeParser,
|
|
72
|
+
removeNcxParser,
|
|
67
73
|
granularityParser,
|
|
68
74
|
languageParser,
|
|
69
75
|
alignParser,
|
|
@@ -72,6 +78,7 @@ const pipelineCommand = merge(
|
|
|
72
78
|
const parser = or(
|
|
73
79
|
processCommand,
|
|
74
80
|
transcribeCommand,
|
|
81
|
+
upgradeEpubCommand,
|
|
75
82
|
markupCommand,
|
|
76
83
|
alignCommand,
|
|
77
84
|
pipelineCommand,
|
|
@@ -98,6 +105,7 @@ async function main() {
|
|
|
98
105
|
);
|
|
99
106
|
}
|
|
100
107
|
function startProgressBar() {
|
|
108
|
+
if (parsed.action === "upgrade-epub") return;
|
|
101
109
|
if (!parsed.noProgress && parsed.logLevel === "silent") {
|
|
102
110
|
progressBar.start(100, 0);
|
|
103
111
|
}
|
|
@@ -112,7 +120,9 @@ async function main() {
|
|
|
112
120
|
progressBar.stop();
|
|
113
121
|
});
|
|
114
122
|
startProgressBar();
|
|
115
|
-
const logger = createLogger(
|
|
123
|
+
const logger = createLogger(
|
|
124
|
+
parsed.action === "upgrade-epub" ? "warn" : parsed.logLevel
|
|
125
|
+
);
|
|
116
126
|
switch (parsed.action) {
|
|
117
127
|
case "process": {
|
|
118
128
|
const timing = await processAudiobook(parsed.input, parsed.output, {
|
|
@@ -153,8 +163,24 @@ async function main() {
|
|
|
153
163
|
}
|
|
154
164
|
break;
|
|
155
165
|
}
|
|
166
|
+
case "upgrade-epub": {
|
|
167
|
+
await upgradeEpub(parsed.input, parsed.output, {
|
|
168
|
+
removeNcx: parsed.removeNcx
|
|
169
|
+
});
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
156
172
|
case "markup": {
|
|
157
|
-
|
|
173
|
+
let input = parsed.input;
|
|
174
|
+
if (parsed.autoupgrade) {
|
|
175
|
+
logger.info("Upgrading EPUB 2 to EPUB 3");
|
|
176
|
+
input = join(
|
|
177
|
+
os.tmpdir(),
|
|
178
|
+
`stalign-autoupgrade-${randomUUID()}`,
|
|
179
|
+
basename(parsed.input)
|
|
180
|
+
);
|
|
181
|
+
await upgradeEpub(parsed.input, input, { removeNcx: parsed.removeNcx });
|
|
182
|
+
}
|
|
183
|
+
const timing = await markup(input, parsed.output, {
|
|
158
184
|
primaryLocale: parsed.language ?? new Intl.Locale("en-US"),
|
|
159
185
|
granularity: parsed.granularity,
|
|
160
186
|
logger,
|
|
@@ -170,8 +196,18 @@ async function main() {
|
|
|
170
196
|
break;
|
|
171
197
|
}
|
|
172
198
|
case "align": {
|
|
199
|
+
let input = parsed.epub;
|
|
200
|
+
if (parsed.autoupgrade) {
|
|
201
|
+
logger.info("Upgrading EPUB 2 to EPUB 3");
|
|
202
|
+
input = join(
|
|
203
|
+
os.tmpdir(),
|
|
204
|
+
`stalign-autoupgrade-${randomUUID()}`,
|
|
205
|
+
basename(parsed.epub)
|
|
206
|
+
);
|
|
207
|
+
await upgradeEpub(parsed.epub, input, { removeNcx: parsed.removeNcx });
|
|
208
|
+
}
|
|
173
209
|
const timing = await align(
|
|
174
|
-
|
|
210
|
+
input,
|
|
175
211
|
parsed.output,
|
|
176
212
|
parsed.transcriptions,
|
|
177
213
|
parsed.audiobook,
|
|
@@ -197,8 +233,19 @@ async function main() {
|
|
|
197
233
|
case "pipeline": {
|
|
198
234
|
var _stack = [];
|
|
199
235
|
try {
|
|
200
|
-
|
|
236
|
+
let input = parsed.epub;
|
|
237
|
+
if (parsed.autoupgrade) {
|
|
238
|
+
logger.info("Upgrading EPUB 2 to EPUB 3");
|
|
239
|
+
input = join(
|
|
240
|
+
os.tmpdir(),
|
|
241
|
+
`stalign-autoupgrade-${randomUUID()}`,
|
|
242
|
+
basename(parsed.epub)
|
|
243
|
+
);
|
|
244
|
+
await upgradeEpub(parsed.epub, input, { removeNcx: parsed.removeNcx });
|
|
245
|
+
}
|
|
246
|
+
const epub = __using(_stack, await Epub.from(input));
|
|
201
247
|
const primaryLocale = parsed.language ?? await epub.getLanguage() ?? new Intl.Locale("en-US");
|
|
248
|
+
epub.discardAndClose();
|
|
202
249
|
const processedAudio = parsed.processedAudio ?? join(os.tmpdir(), `stalign-processed-${randomUUID()}`);
|
|
203
250
|
if (!parsed.processedAudio) {
|
|
204
251
|
stack.defer(() => {
|
|
@@ -271,7 +318,7 @@ async function main() {
|
|
|
271
318
|
rmSync(markedup2, { recursive: true, force: true });
|
|
272
319
|
});
|
|
273
320
|
}
|
|
274
|
-
const markupTiming = await markup(
|
|
321
|
+
const markupTiming = await markup(input, markedup2, {
|
|
275
322
|
granularity: parsed.granularity,
|
|
276
323
|
primaryLocale,
|
|
277
324
|
logger,
|
package/dist/common/parse.cjs
CHANGED
|
@@ -18,10 +18,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var parse_exports = {};
|
|
20
20
|
__export(parse_exports, {
|
|
21
|
+
autoUpgradeParser: () => autoUpgradeParser,
|
|
21
22
|
granularityParser: () => granularityParser,
|
|
22
23
|
languageParser: () => languageParser,
|
|
23
24
|
loggingParser: () => loggingParser,
|
|
24
|
-
parallelismParser: () => parallelismParser
|
|
25
|
+
parallelismParser: () => parallelismParser,
|
|
26
|
+
removeNcxParser: () => removeNcxParser
|
|
25
27
|
});
|
|
26
28
|
module.exports = __toCommonJS(parse_exports);
|
|
27
29
|
var import_core = require("@optique/core");
|
|
@@ -64,10 +66,22 @@ const parallelismParser = (0, import_core.object)({
|
|
|
64
66
|
1
|
|
65
67
|
)
|
|
66
68
|
});
|
|
69
|
+
const autoUpgradeParser = (0, import_core.object)({
|
|
70
|
+
autoupgrade: (0, import_core.option)("--autoupgrade", "-u", {
|
|
71
|
+
description: import_core.message`Automatically upgrade any EPUB 2 files to EPUB 3`
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
const removeNcxParser = (0, import_core.object)({
|
|
75
|
+
removeNcx: (0, import_core.option)("--remove-ncx", {
|
|
76
|
+
description: import_core.message`Whether to remove the NCX and guide element after upgrading an EPUB from 2 to 3`
|
|
77
|
+
})
|
|
78
|
+
});
|
|
67
79
|
// Annotate the CommonJS export names for ESM import in node:
|
|
68
80
|
0 && (module.exports = {
|
|
81
|
+
autoUpgradeParser,
|
|
69
82
|
granularityParser,
|
|
70
83
|
languageParser,
|
|
71
84
|
loggingParser,
|
|
72
|
-
parallelismParser
|
|
85
|
+
parallelismParser,
|
|
86
|
+
removeNcxParser
|
|
73
87
|
});
|
package/dist/common/parse.d.cts
CHANGED
|
@@ -24,5 +24,15 @@ declare const parallelismParser: _optique_core.Parser<"sync", {
|
|
|
24
24
|
}, {
|
|
25
25
|
readonly parallelism: [_optique_core.ValueParserResult<number> | undefined] | undefined;
|
|
26
26
|
}>;
|
|
27
|
+
declare const autoUpgradeParser: _optique_core.Parser<"sync", {
|
|
28
|
+
readonly autoupgrade: boolean;
|
|
29
|
+
}, {
|
|
30
|
+
readonly autoupgrade: _optique_core.ValueParserResult<boolean> | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
declare const removeNcxParser: _optique_core.Parser<"sync", {
|
|
33
|
+
readonly removeNcx: boolean;
|
|
34
|
+
}, {
|
|
35
|
+
readonly removeNcx: _optique_core.ValueParserResult<boolean> | undefined;
|
|
36
|
+
}>;
|
|
27
37
|
|
|
28
|
-
export { granularityParser, languageParser, loggingParser, parallelismParser };
|
|
38
|
+
export { autoUpgradeParser, granularityParser, languageParser, loggingParser, parallelismParser, removeNcxParser };
|
package/dist/common/parse.d.ts
CHANGED
|
@@ -24,5 +24,15 @@ declare const parallelismParser: _optique_core.Parser<"sync", {
|
|
|
24
24
|
}, {
|
|
25
25
|
readonly parallelism: [_optique_core.ValueParserResult<number> | undefined] | undefined;
|
|
26
26
|
}>;
|
|
27
|
+
declare const autoUpgradeParser: _optique_core.Parser<"sync", {
|
|
28
|
+
readonly autoupgrade: boolean;
|
|
29
|
+
}, {
|
|
30
|
+
readonly autoupgrade: _optique_core.ValueParserResult<boolean> | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
declare const removeNcxParser: _optique_core.Parser<"sync", {
|
|
33
|
+
readonly removeNcx: boolean;
|
|
34
|
+
}, {
|
|
35
|
+
readonly removeNcx: _optique_core.ValueParserResult<boolean> | undefined;
|
|
36
|
+
}>;
|
|
27
37
|
|
|
28
|
-
export { granularityParser, languageParser, loggingParser, parallelismParser };
|
|
38
|
+
export { autoUpgradeParser, granularityParser, languageParser, loggingParser, parallelismParser, removeNcxParser };
|
package/dist/common/parse.js
CHANGED
|
@@ -48,9 +48,21 @@ const parallelismParser = object({
|
|
|
48
48
|
1
|
|
49
49
|
)
|
|
50
50
|
});
|
|
51
|
+
const autoUpgradeParser = object({
|
|
52
|
+
autoupgrade: option("--autoupgrade", "-u", {
|
|
53
|
+
description: message`Automatically upgrade any EPUB 2 files to EPUB 3`
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
const removeNcxParser = object({
|
|
57
|
+
removeNcx: option("--remove-ncx", {
|
|
58
|
+
description: message`Whether to remove the NCX and guide element after upgrading an EPUB from 2 to 3`
|
|
59
|
+
})
|
|
60
|
+
});
|
|
51
61
|
export {
|
|
62
|
+
autoUpgradeParser,
|
|
52
63
|
granularityParser,
|
|
53
64
|
languageParser,
|
|
54
65
|
loggingParser,
|
|
55
|
-
parallelismParser
|
|
66
|
+
parallelismParser,
|
|
67
|
+
removeNcxParser
|
|
56
68
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -21,17 +21,20 @@ __export(index_exports, {
|
|
|
21
21
|
align: () => import_align.align,
|
|
22
22
|
markup: () => import_markup.markup,
|
|
23
23
|
processAudiobook: () => import_processAudiobook.processAudiobook,
|
|
24
|
-
transcribe: () => import_transcribe.transcribe
|
|
24
|
+
transcribe: () => import_transcribe.transcribe,
|
|
25
|
+
upgradeEpub: () => import_upgradeEpub.upgradeEpub
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(index_exports);
|
|
27
28
|
var import_processAudiobook = require("./process/processAudiobook.cjs");
|
|
28
29
|
var import_transcribe = require("./transcribe/transcribe.cjs");
|
|
29
30
|
var import_markup = require("./markup/markup.cjs");
|
|
30
31
|
var import_align = require("./align/align.cjs");
|
|
32
|
+
var import_upgradeEpub = require("./upgradeEpub/upgradeEpub.cjs");
|
|
31
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
34
|
0 && (module.exports = {
|
|
33
35
|
align,
|
|
34
36
|
markup,
|
|
35
37
|
processAudiobook,
|
|
36
|
-
transcribe
|
|
38
|
+
transcribe,
|
|
39
|
+
upgradeEpub
|
|
37
40
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +2,7 @@ export { processAudiobook } from './process/processAudiobook.cjs';
|
|
|
2
2
|
export { transcribe } from './transcribe/transcribe.cjs';
|
|
3
3
|
export { markup } from './markup/markup.cjs';
|
|
4
4
|
export { align } from './align/align.cjs';
|
|
5
|
+
export { upgradeEpub } from './upgradeEpub/upgradeEpub.cjs';
|
|
5
6
|
import '@storyteller-platform/ghost-story';
|
|
6
7
|
import '@esfx/async-semaphore';
|
|
7
8
|
import 'pino';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { processAudiobook } from './process/processAudiobook.js';
|
|
|
2
2
|
export { transcribe } from './transcribe/transcribe.js';
|
|
3
3
|
export { markup } from './markup/markup.js';
|
|
4
4
|
export { align } from './align/align.js';
|
|
5
|
+
export { upgradeEpub } from './upgradeEpub/upgradeEpub.js';
|
|
5
6
|
import '@storyteller-platform/ghost-story';
|
|
6
7
|
import '@esfx/async-semaphore';
|
|
7
8
|
import 'pino';
|
package/dist/index.js
CHANGED
|
@@ -3,9 +3,11 @@ import { processAudiobook } from "./process/processAudiobook.js";
|
|
|
3
3
|
import { transcribe } from "./transcribe/transcribe.js";
|
|
4
4
|
import { markup } from "./markup/markup.js";
|
|
5
5
|
import { align } from "./align/align.js";
|
|
6
|
+
import { upgradeEpub } from "./upgradeEpub/upgradeEpub.js";
|
|
6
7
|
export {
|
|
7
8
|
align,
|
|
8
9
|
markup,
|
|
9
10
|
processAudiobook,
|
|
10
|
-
transcribe
|
|
11
|
+
transcribe,
|
|
12
|
+
upgradeEpub
|
|
11
13
|
};
|
package/dist/markup/markup.cjs
CHANGED
|
@@ -140,7 +140,7 @@ async function markupChapter(chapterId, chapterXml, granularity, locale) {
|
|
|
140
140
|
let j = 0;
|
|
141
141
|
let wordPos = pos;
|
|
142
142
|
for (const word of sentence.words.entries) {
|
|
143
|
-
if (word.
|
|
143
|
+
if (!word.isPunctuation) {
|
|
144
144
|
root = (0, import_transform.addMark)(
|
|
145
145
|
root,
|
|
146
146
|
lifted.mapping.invert().map(wordPos),
|
package/dist/markup/markup.js
CHANGED
|
@@ -83,7 +83,7 @@ async function markupChapter(chapterId, chapterXml, granularity, locale) {
|
|
|
83
83
|
let j = 0;
|
|
84
84
|
let wordPos = pos;
|
|
85
85
|
for (const word of sentence.words.entries) {
|
|
86
|
-
if (word.
|
|
86
|
+
if (!word.isPunctuation) {
|
|
87
87
|
root = addMark(
|
|
88
88
|
root,
|
|
89
89
|
lifted.mapping.invert().map(wordPos),
|
package/dist/markup/parse.cjs
CHANGED
package/dist/markup/parse.d.cts
CHANGED
|
@@ -6,6 +6,10 @@ declare const markupCommand: _optique_core.Parser<"sync", {
|
|
|
6
6
|
readonly output: string;
|
|
7
7
|
} & {
|
|
8
8
|
readonly granularity: "word" | "sentence";
|
|
9
|
+
} & {
|
|
10
|
+
readonly autoupgrade: boolean;
|
|
11
|
+
} & {
|
|
12
|
+
readonly removeNcx: boolean;
|
|
9
13
|
} & {
|
|
10
14
|
readonly language: Intl.Locale | undefined;
|
|
11
15
|
} & {
|
package/dist/markup/parse.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ declare const markupCommand: _optique_core.Parser<"sync", {
|
|
|
6
6
|
readonly output: string;
|
|
7
7
|
} & {
|
|
8
8
|
readonly granularity: "word" | "sentence";
|
|
9
|
+
} & {
|
|
10
|
+
readonly autoupgrade: boolean;
|
|
11
|
+
} & {
|
|
12
|
+
readonly removeNcx: boolean;
|
|
9
13
|
} & {
|
|
10
14
|
readonly language: Intl.Locale | undefined;
|
|
11
15
|
} & {
|
package/dist/markup/parse.js
CHANGED
|
@@ -9,9 +9,11 @@ import {
|
|
|
9
9
|
} from "@optique/core";
|
|
10
10
|
import { path } from "@optique/run/valueparser";
|
|
11
11
|
import {
|
|
12
|
+
autoUpgradeParser,
|
|
12
13
|
granularityParser,
|
|
13
14
|
languageParser,
|
|
14
|
-
loggingParser
|
|
15
|
+
loggingParser,
|
|
16
|
+
removeNcxParser
|
|
15
17
|
} from "../common/parse.js";
|
|
16
18
|
const markupCommand = command(
|
|
17
19
|
"markup",
|
|
@@ -31,6 +33,8 @@ const markupCommand = command(
|
|
|
31
33
|
)
|
|
32
34
|
}),
|
|
33
35
|
granularityParser,
|
|
36
|
+
autoUpgradeParser,
|
|
37
|
+
removeNcxParser,
|
|
34
38
|
languageParser,
|
|
35
39
|
loggingParser
|
|
36
40
|
),
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var parse_exports = {};
|
|
20
|
+
__export(parse_exports, {
|
|
21
|
+
upgradeEpubCommand: () => upgradeEpubCommand
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(parse_exports);
|
|
24
|
+
var import_core = require("@optique/core");
|
|
25
|
+
var import_run = require("@optique/run");
|
|
26
|
+
var import_parse = require("../common/parse.cjs");
|
|
27
|
+
const upgradeEpubCommand = (0, import_core.command)(
|
|
28
|
+
"upgrade-epub",
|
|
29
|
+
(0, import_core.merge)(
|
|
30
|
+
(0, import_core.object)({
|
|
31
|
+
action: (0, import_core.constant)("upgrade-epub"),
|
|
32
|
+
input: (0, import_core.argument)(
|
|
33
|
+
(0, import_run.path)({ type: "file", mustExist: true, metavar: "EPUB2" })
|
|
34
|
+
),
|
|
35
|
+
output: (0, import_core.argument)((0, import_run.path)({ metavar: "OUTPUT", type: "file" }))
|
|
36
|
+
}),
|
|
37
|
+
import_parse.removeNcxParser
|
|
38
|
+
),
|
|
39
|
+
{ description: import_core.message`Upgrade an EPUB 2 file to EPUB 3` }
|
|
40
|
+
);
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
upgradeEpubCommand
|
|
44
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as _optique_core from '@optique/core';
|
|
2
|
+
|
|
3
|
+
declare const upgradeEpubCommand: _optique_core.Parser<"sync", {
|
|
4
|
+
readonly action: "upgrade-epub";
|
|
5
|
+
readonly input: string;
|
|
6
|
+
readonly output: string;
|
|
7
|
+
} & {
|
|
8
|
+
readonly removeNcx: boolean;
|
|
9
|
+
}, ["matched", string] | ["parsing", Record<string | symbol, unknown>] | undefined>;
|
|
10
|
+
|
|
11
|
+
export { upgradeEpubCommand };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as _optique_core from '@optique/core';
|
|
2
|
+
|
|
3
|
+
declare const upgradeEpubCommand: _optique_core.Parser<"sync", {
|
|
4
|
+
readonly action: "upgrade-epub";
|
|
5
|
+
readonly input: string;
|
|
6
|
+
readonly output: string;
|
|
7
|
+
} & {
|
|
8
|
+
readonly removeNcx: boolean;
|
|
9
|
+
}, ["matched", string] | ["parsing", Record<string | symbol, unknown>] | undefined>;
|
|
10
|
+
|
|
11
|
+
export { upgradeEpubCommand };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import "../chunk-BIEQXUOY.js";
|
|
2
|
+
import {
|
|
3
|
+
argument,
|
|
4
|
+
command,
|
|
5
|
+
constant,
|
|
6
|
+
merge,
|
|
7
|
+
message,
|
|
8
|
+
object
|
|
9
|
+
} from "@optique/core";
|
|
10
|
+
import { path } from "@optique/run";
|
|
11
|
+
import { removeNcxParser } from "../common/parse.js";
|
|
12
|
+
const upgradeEpubCommand = command(
|
|
13
|
+
"upgrade-epub",
|
|
14
|
+
merge(
|
|
15
|
+
object({
|
|
16
|
+
action: constant("upgrade-epub"),
|
|
17
|
+
input: argument(
|
|
18
|
+
path({ type: "file", mustExist: true, metavar: "EPUB2" })
|
|
19
|
+
),
|
|
20
|
+
output: argument(path({ metavar: "OUTPUT", type: "file" }))
|
|
21
|
+
}),
|
|
22
|
+
removeNcxParser
|
|
23
|
+
),
|
|
24
|
+
{ description: message`Upgrade an EPUB 2 file to EPUB 3` }
|
|
25
|
+
);
|
|
26
|
+
export {
|
|
27
|
+
upgradeEpubCommand
|
|
28
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
|
|
7
|
+
var __typeError = (msg) => {
|
|
8
|
+
throw TypeError(msg);
|
|
9
|
+
};
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var __using = (stack, value, async) => {
|
|
24
|
+
if (value != null) {
|
|
25
|
+
if (typeof value !== "object" && typeof value !== "function") __typeError("Object expected");
|
|
26
|
+
var dispose, inner;
|
|
27
|
+
if (async) dispose = value[__knownSymbol("asyncDispose")];
|
|
28
|
+
if (dispose === void 0) {
|
|
29
|
+
dispose = value[__knownSymbol("dispose")];
|
|
30
|
+
if (async) inner = dispose;
|
|
31
|
+
}
|
|
32
|
+
if (typeof dispose !== "function") __typeError("Object not disposable");
|
|
33
|
+
if (inner) dispose = function() {
|
|
34
|
+
try {
|
|
35
|
+
inner.call(this);
|
|
36
|
+
} catch (e) {
|
|
37
|
+
return Promise.reject(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
stack.push([async, dispose, value]);
|
|
41
|
+
} else if (async) {
|
|
42
|
+
stack.push([async]);
|
|
43
|
+
}
|
|
44
|
+
return value;
|
|
45
|
+
};
|
|
46
|
+
var __callDispose = (stack, error, hasError) => {
|
|
47
|
+
var E = typeof SuppressedError === "function" ? SuppressedError : function(e, s, m, _) {
|
|
48
|
+
return _ = Error(m), _.name = "SuppressedError", _.error = e, _.suppressed = s, _;
|
|
49
|
+
};
|
|
50
|
+
var fail = (e) => error = hasError ? new E(e, error, "An error was suppressed during disposal") : (hasError = true, e);
|
|
51
|
+
var next = (it) => {
|
|
52
|
+
while (it = stack.pop()) {
|
|
53
|
+
try {
|
|
54
|
+
var result = it[1] && it[1].call(it[2]);
|
|
55
|
+
if (it[0]) return Promise.resolve(result).then(next, (e) => (fail(e), next()));
|
|
56
|
+
} catch (e) {
|
|
57
|
+
fail(e);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (hasError) throw error;
|
|
61
|
+
};
|
|
62
|
+
return next();
|
|
63
|
+
};
|
|
64
|
+
var upgradeEpub_exports = {};
|
|
65
|
+
__export(upgradeEpub_exports, {
|
|
66
|
+
upgradeEpub: () => upgradeEpub
|
|
67
|
+
});
|
|
68
|
+
module.exports = __toCommonJS(upgradeEpub_exports);
|
|
69
|
+
var import_epub = require("@storyteller-platform/epub");
|
|
70
|
+
async function upgradeEpub(input, output, { removeNcx = false }) {
|
|
71
|
+
var _stack = [];
|
|
72
|
+
try {
|
|
73
|
+
const epub = __using(_stack, await import_epub.Epub.upgrade(input, { outputPath: output, removeNcx }));
|
|
74
|
+
await epub.saveAndClose();
|
|
75
|
+
} catch (_) {
|
|
76
|
+
var _error = _, _hasError = true;
|
|
77
|
+
} finally {
|
|
78
|
+
__callDispose(_stack, _error, _hasError);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
upgradeEpub
|
|
84
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__callDispose,
|
|
3
|
+
__using
|
|
4
|
+
} from "../chunk-BIEQXUOY.js";
|
|
5
|
+
import { Epub } from "@storyteller-platform/epub";
|
|
6
|
+
async function upgradeEpub(input, output, { removeNcx = false }) {
|
|
7
|
+
var _stack = [];
|
|
8
|
+
try {
|
|
9
|
+
const epub = __using(_stack, await Epub.upgrade(input, { outputPath: output, removeNcx }));
|
|
10
|
+
await epub.saveAndClose();
|
|
11
|
+
} catch (_) {
|
|
12
|
+
var _error = _, _hasError = true;
|
|
13
|
+
} finally {
|
|
14
|
+
__callDispose(_stack, _error, _hasError);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
upgradeEpub
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyteller-platform/align",
|
|
3
|
-
"version": "0.1.39
|
|
3
|
+
"version": "0.1.39",
|
|
4
4
|
"description": "A library and CLI for automatically aligning audiobooks and EPUBs to produce Media Overlays",
|
|
5
5
|
"author": "Shane Friedman",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@optique/run": "^0.10.7",
|
|
62
62
|
"@readium/shared": "patch:@readium/shared@npm%3A2.1.5#~/.yarn/patches/@readium-shared-npm-2.1.5-8d6f9d2432.patch",
|
|
63
63
|
"@storyteller-platform/audiobook": "^0.3.10",
|
|
64
|
-
"@storyteller-platform/epub": "^0.5.
|
|
64
|
+
"@storyteller-platform/epub": "^0.5.1",
|
|
65
65
|
"@storyteller-platform/ghost-story": "^0.1.11",
|
|
66
66
|
"@storyteller-platform/transliteration": "^3.1.2",
|
|
67
67
|
"chalk": "^5.4.1",
|
|
Binary file
|