@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
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
emitCommand: () => emitCommand,
|
|
22
|
+
emitParser: () => emitParser
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(parse_exports);
|
|
25
|
+
var import_core = require("@optique/core");
|
|
26
|
+
var import_valueparser = require("@optique/run/valueparser");
|
|
27
|
+
var import_constants = require("@storyteller-platform/ghost-story/constants");
|
|
28
|
+
var import_parse = require("../common/parse.cjs");
|
|
29
|
+
const emitParser = (0, import_core.object)({
|
|
30
|
+
model: (0, import_core.withDefault)(
|
|
31
|
+
(0, import_core.option)("--model", "-m", (0, import_core.choice)(import_constants.WAV2VEC2_MODELS, { metavar: "MODEL" }), {
|
|
32
|
+
description: import_core.message`The wav2vec2 model to use`
|
|
33
|
+
}),
|
|
34
|
+
"onnx-community/mms-300m-1130-forced-aligner-ONNX"
|
|
35
|
+
),
|
|
36
|
+
device: (0, import_core.withDefault)(
|
|
37
|
+
(0, import_core.option)("--device", "-d", (0, import_core.choice)(import_constants.WAV2VEC2_DEVICES, { metavar: "DEVICE" }), {
|
|
38
|
+
description: import_core.message`The device to run inference on`
|
|
39
|
+
}),
|
|
40
|
+
"auto"
|
|
41
|
+
),
|
|
42
|
+
dtype: (0, import_core.withDefault)(
|
|
43
|
+
(0, import_core.option)("--dtype", (0, import_core.choice)(import_constants.WAV2VEC2_DTYPES, { metavar: "DTYPE" }), {
|
|
44
|
+
description: import_core.message`The data type to load the model with`
|
|
45
|
+
}),
|
|
46
|
+
"fp16"
|
|
47
|
+
)
|
|
48
|
+
});
|
|
49
|
+
const emitCommand = (0, import_core.command)(
|
|
50
|
+
"emit",
|
|
51
|
+
(0, import_core.merge)(
|
|
52
|
+
(0, import_core.object)({
|
|
53
|
+
action: (0, import_core.constant)("emit"),
|
|
54
|
+
input: (0, import_core.argument)(
|
|
55
|
+
(0, import_valueparser.path)({ type: "directory", mustExist: true, metavar: "INPUT" })
|
|
56
|
+
),
|
|
57
|
+
output: (0, import_core.argument)((0, import_valueparser.path)({ metavar: "OUTPUT", type: "directory" }))
|
|
58
|
+
}),
|
|
59
|
+
emitParser,
|
|
60
|
+
import_parse.loggingParser
|
|
61
|
+
),
|
|
62
|
+
{ description: import_core.message`Transcribe a directory of audiobook files.` }
|
|
63
|
+
);
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
emitCommand,
|
|
67
|
+
emitParser
|
|
68
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as _optique_core from '@optique/core';
|
|
2
|
+
|
|
3
|
+
declare const emitParser: _optique_core.Parser<"sync", {
|
|
4
|
+
readonly model: "Xenova/wav2vec2-base-960h" | "onnx-community/mms-300m-1130-forced-aligner-ONNX";
|
|
5
|
+
readonly device: "auto" | "cpu" | "webgpu" | "cuda";
|
|
6
|
+
readonly dtype: "fp32" | "fp16" | "q8";
|
|
7
|
+
}, {
|
|
8
|
+
readonly model: [_optique_core.ValueParserResult<"Xenova/wav2vec2-base-960h" | "onnx-community/mms-300m-1130-forced-aligner-ONNX"> | undefined] | undefined;
|
|
9
|
+
readonly device: [_optique_core.ValueParserResult<"auto" | "cpu" | "webgpu" | "cuda"> | undefined] | undefined;
|
|
10
|
+
readonly dtype: [_optique_core.ValueParserResult<"fp32" | "fp16" | "q8"> | undefined] | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
declare const emitCommand: _optique_core.Parser<"sync", {
|
|
13
|
+
readonly action: "emit";
|
|
14
|
+
readonly input: string;
|
|
15
|
+
readonly output: string;
|
|
16
|
+
} & {
|
|
17
|
+
readonly model: "Xenova/wav2vec2-base-960h" | "onnx-community/mms-300m-1130-forced-aligner-ONNX";
|
|
18
|
+
readonly device: "auto" | "cpu" | "webgpu" | "cuda";
|
|
19
|
+
readonly dtype: "fp32" | "fp16" | "q8";
|
|
20
|
+
} & {
|
|
21
|
+
readonly noProgress: boolean;
|
|
22
|
+
readonly logLevel: "silent" | "debug" | "info" | "warn" | "error";
|
|
23
|
+
readonly time: boolean;
|
|
24
|
+
}, ["matched", string] | ["parsing", Record<string | symbol, unknown>] | undefined>;
|
|
25
|
+
|
|
26
|
+
export { emitCommand, emitParser };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as _optique_core from '@optique/core';
|
|
2
|
+
|
|
3
|
+
declare const emitParser: _optique_core.Parser<"sync", {
|
|
4
|
+
readonly model: "Xenova/wav2vec2-base-960h" | "onnx-community/mms-300m-1130-forced-aligner-ONNX";
|
|
5
|
+
readonly device: "auto" | "cpu" | "webgpu" | "cuda";
|
|
6
|
+
readonly dtype: "fp32" | "fp16" | "q8";
|
|
7
|
+
}, {
|
|
8
|
+
readonly model: [_optique_core.ValueParserResult<"Xenova/wav2vec2-base-960h" | "onnx-community/mms-300m-1130-forced-aligner-ONNX"> | undefined] | undefined;
|
|
9
|
+
readonly device: [_optique_core.ValueParserResult<"auto" | "cpu" | "webgpu" | "cuda"> | undefined] | undefined;
|
|
10
|
+
readonly dtype: [_optique_core.ValueParserResult<"fp32" | "fp16" | "q8"> | undefined] | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
declare const emitCommand: _optique_core.Parser<"sync", {
|
|
13
|
+
readonly action: "emit";
|
|
14
|
+
readonly input: string;
|
|
15
|
+
readonly output: string;
|
|
16
|
+
} & {
|
|
17
|
+
readonly model: "Xenova/wav2vec2-base-960h" | "onnx-community/mms-300m-1130-forced-aligner-ONNX";
|
|
18
|
+
readonly device: "auto" | "cpu" | "webgpu" | "cuda";
|
|
19
|
+
readonly dtype: "fp32" | "fp16" | "q8";
|
|
20
|
+
} & {
|
|
21
|
+
readonly noProgress: boolean;
|
|
22
|
+
readonly logLevel: "silent" | "debug" | "info" | "warn" | "error";
|
|
23
|
+
readonly time: boolean;
|
|
24
|
+
}, ["matched", string] | ["parsing", Record<string | symbol, unknown>] | undefined>;
|
|
25
|
+
|
|
26
|
+
export { emitCommand, emitParser };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import "../chunk-BIEQXUOY.js";
|
|
2
|
+
import {
|
|
3
|
+
argument,
|
|
4
|
+
choice,
|
|
5
|
+
command,
|
|
6
|
+
constant,
|
|
7
|
+
merge,
|
|
8
|
+
message,
|
|
9
|
+
object,
|
|
10
|
+
option,
|
|
11
|
+
withDefault
|
|
12
|
+
} from "@optique/core";
|
|
13
|
+
import { path } from "@optique/run/valueparser";
|
|
14
|
+
import {
|
|
15
|
+
WAV2VEC2_DEVICES,
|
|
16
|
+
WAV2VEC2_DTYPES,
|
|
17
|
+
WAV2VEC2_MODELS
|
|
18
|
+
} from "@storyteller-platform/ghost-story/constants";
|
|
19
|
+
import { loggingParser } from "../common/parse.js";
|
|
20
|
+
const emitParser = object({
|
|
21
|
+
model: withDefault(
|
|
22
|
+
option("--model", "-m", choice(WAV2VEC2_MODELS, { metavar: "MODEL" }), {
|
|
23
|
+
description: message`The wav2vec2 model to use`
|
|
24
|
+
}),
|
|
25
|
+
"onnx-community/mms-300m-1130-forced-aligner-ONNX"
|
|
26
|
+
),
|
|
27
|
+
device: withDefault(
|
|
28
|
+
option("--device", "-d", choice(WAV2VEC2_DEVICES, { metavar: "DEVICE" }), {
|
|
29
|
+
description: message`The device to run inference on`
|
|
30
|
+
}),
|
|
31
|
+
"auto"
|
|
32
|
+
),
|
|
33
|
+
dtype: withDefault(
|
|
34
|
+
option("--dtype", choice(WAV2VEC2_DTYPES, { metavar: "DTYPE" }), {
|
|
35
|
+
description: message`The data type to load the model with`
|
|
36
|
+
}),
|
|
37
|
+
"fp16"
|
|
38
|
+
)
|
|
39
|
+
});
|
|
40
|
+
const emitCommand = command(
|
|
41
|
+
"emit",
|
|
42
|
+
merge(
|
|
43
|
+
object({
|
|
44
|
+
action: constant("emit"),
|
|
45
|
+
input: argument(
|
|
46
|
+
path({ type: "directory", mustExist: true, metavar: "INPUT" })
|
|
47
|
+
),
|
|
48
|
+
output: argument(path({ metavar: "OUTPUT", type: "directory" }))
|
|
49
|
+
}),
|
|
50
|
+
emitParser,
|
|
51
|
+
loggingParser
|
|
52
|
+
),
|
|
53
|
+
{ description: message`Transcribe a directory of audiobook files.` }
|
|
54
|
+
);
|
|
55
|
+
export {
|
|
56
|
+
emitCommand,
|
|
57
|
+
emitParser
|
|
58
|
+
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { processAudiobook } from './process/processAudiobook.cjs';
|
|
2
2
|
export { transcribe } from './transcribe/transcribe.cjs';
|
|
3
3
|
export { markup } from './markup/markup.cjs';
|
|
4
|
-
export { align } from './align/align.cjs';
|
|
4
|
+
export { AlignOptions, AudioFileReport, ChapterReport, Report, UnalignedAudioFileReport, UnalignedChapterReport, UnalignedNotFoundChapterReport, align } from './align/align.cjs';
|
|
5
5
|
export { upgradeEpub } from './upgradeEpub/upgradeEpub.cjs';
|
|
6
6
|
import '@storyteller-platform/ghost-story';
|
|
7
7
|
import '@esfx/async-semaphore';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { processAudiobook } from './process/processAudiobook.js';
|
|
2
2
|
export { transcribe } from './transcribe/transcribe.js';
|
|
3
3
|
export { markup } from './markup/markup.js';
|
|
4
|
-
export { align } from './align/align.js';
|
|
4
|
+
export { AlignOptions, AudioFileReport, ChapterReport, Report, UnalignedAudioFileReport, UnalignedChapterReport, UnalignedNotFoundChapterReport, align } from './align/align.js';
|
|
5
5
|
export { upgradeEpub } from './upgradeEpub/upgradeEpub.js';
|
|
6
6
|
import '@storyteller-platform/ghost-story';
|
|
7
7
|
import '@esfx/async-semaphore';
|
package/dist/markup/model.cjs
CHANGED
|
@@ -21,11 +21,7 @@ __export(model_exports, {
|
|
|
21
21
|
FootnoteNode: () => FootnoteNode,
|
|
22
22
|
Mark: () => Mark,
|
|
23
23
|
Node: () => Node,
|
|
24
|
-
NoterefNode: () => NoterefNode,
|
|
25
24
|
Root: () => Root,
|
|
26
|
-
RubyNode: () => RubyNode,
|
|
27
|
-
RubyParenthesisNode: () => RubyParenthesisNode,
|
|
28
|
-
RubyTextNode: () => RubyTextNode,
|
|
29
25
|
TextNode: () => TextNode,
|
|
30
26
|
descendants: () => descendants
|
|
31
27
|
});
|
|
@@ -234,16 +230,8 @@ class Node {
|
|
|
234
230
|
}
|
|
235
231
|
}
|
|
236
232
|
}
|
|
237
|
-
class NoterefNode extends Node {
|
|
238
|
-
}
|
|
239
233
|
class FootnoteNode extends Node {
|
|
240
234
|
}
|
|
241
|
-
class RubyParenthesisNode extends Node {
|
|
242
|
-
}
|
|
243
|
-
class RubyTextNode extends Node {
|
|
244
|
-
}
|
|
245
|
-
class RubyNode extends Node {
|
|
246
|
-
}
|
|
247
235
|
class Mark {
|
|
248
236
|
constructor(tagName, attrs = {}) {
|
|
249
237
|
this.tagName = tagName;
|
|
@@ -307,11 +295,7 @@ function descendants(node, cb, pos = 0) {
|
|
|
307
295
|
FootnoteNode,
|
|
308
296
|
Mark,
|
|
309
297
|
Node,
|
|
310
|
-
NoterefNode,
|
|
311
298
|
Root,
|
|
312
|
-
RubyNode,
|
|
313
|
-
RubyParenthesisNode,
|
|
314
|
-
RubyTextNode,
|
|
315
299
|
TextNode,
|
|
316
300
|
descendants
|
|
317
301
|
});
|
package/dist/markup/model.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '@storyteller-platform/epub';
|
|
2
|
-
export { F as FootnoteNode, M as Mark, N as Node,
|
|
2
|
+
export { F as FootnoteNode, M as Mark, N as Node, R as Root, T as TextNode, d as descendants } from '../model-CeOMDDgt.cjs';
|
package/dist/markup/model.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '@storyteller-platform/epub';
|
|
2
|
-
export { F as FootnoteNode, M as Mark, N as Node,
|
|
2
|
+
export { F as FootnoteNode, M as Mark, N as Node, R as Root, T as TextNode, d as descendants } from '../model-CeOMDDgt.js';
|
package/dist/markup/model.js
CHANGED
|
@@ -203,16 +203,8 @@ class Node {
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
class NoterefNode extends Node {
|
|
207
|
-
}
|
|
208
206
|
class FootnoteNode extends Node {
|
|
209
207
|
}
|
|
210
|
-
class RubyParenthesisNode extends Node {
|
|
211
|
-
}
|
|
212
|
-
class RubyTextNode extends Node {
|
|
213
|
-
}
|
|
214
|
-
class RubyNode extends Node {
|
|
215
|
-
}
|
|
216
208
|
class Mark {
|
|
217
209
|
constructor(tagName, attrs = {}) {
|
|
218
210
|
this.tagName = tagName;
|
|
@@ -275,11 +267,7 @@ export {
|
|
|
275
267
|
FootnoteNode,
|
|
276
268
|
Mark,
|
|
277
269
|
Node,
|
|
278
|
-
NoterefNode,
|
|
279
270
|
Root,
|
|
280
|
-
RubyNode,
|
|
281
|
-
RubyParenthesisNode,
|
|
282
|
-
RubyTextNode,
|
|
283
271
|
TextNode,
|
|
284
272
|
descendants
|
|
285
273
|
};
|
package/dist/markup/parseDom.cjs
CHANGED
|
@@ -57,13 +57,11 @@ class Parser {
|
|
|
57
57
|
pos + 1
|
|
58
58
|
);
|
|
59
59
|
if (tagName === "a" && attrs["epub:type"] === "noteref") {
|
|
60
|
-
const
|
|
61
|
-
const href = node.attrs["href"];
|
|
60
|
+
const href = attrs["href"];
|
|
62
61
|
const fragment = href?.split("#")[1];
|
|
63
62
|
if (fragment) {
|
|
64
63
|
this.footnoteIds.add(fragment);
|
|
65
64
|
}
|
|
66
|
-
return node;
|
|
67
65
|
}
|
|
68
66
|
if (attrs["id"] && (FOOTNOTE_ROLES.includes(attrs["epub:type"] ?? "") || // Some footnotes aren't properly marked up with the
|
|
69
67
|
// correct role
|
|
@@ -81,15 +79,6 @@ class Parser {
|
|
|
81
79
|
);
|
|
82
80
|
return footnoteNode;
|
|
83
81
|
}
|
|
84
|
-
if (tagName === "ruby") {
|
|
85
|
-
return new import_model.RubyNode(tagName, attrs, blockChildren, marks);
|
|
86
|
-
}
|
|
87
|
-
if (tagName === "rt") {
|
|
88
|
-
return new import_model.RubyTextNode(tagName, attrs, blockChildren, marks);
|
|
89
|
-
}
|
|
90
|
-
if (tagName === "rp") {
|
|
91
|
-
return new import_model.RubyParenthesisNode(tagName, attrs, blockChildren, marks);
|
|
92
|
-
}
|
|
93
82
|
if (import_semantics.BLOCKS.includes(tagName)) {
|
|
94
83
|
return new import_model.Node(tagName, attrs, blockChildren, marks);
|
|
95
84
|
}
|
|
@@ -108,9 +97,19 @@ function findFootnotePairs(root) {
|
|
|
108
97
|
const noterefs = /* @__PURE__ */ new Map();
|
|
109
98
|
const pairs = /* @__PURE__ */ new Map();
|
|
110
99
|
(0, import_model.descendants)(root, (node, pos) => {
|
|
111
|
-
|
|
112
|
-
|
|
100
|
+
const mark = node.marks.find((mark2) => mark2.tagName === "a");
|
|
101
|
+
if (mark) {
|
|
102
|
+
const id = mark.attrs["href"]?.split("#")[1];
|
|
113
103
|
if (id) {
|
|
104
|
+
const $pos = root.resolve(pos);
|
|
105
|
+
let d = $pos.depth;
|
|
106
|
+
while (d > 0) {
|
|
107
|
+
const node2 = $pos.node(d);
|
|
108
|
+
if (node2 instanceof import_model.FootnoteNode) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
d--;
|
|
112
|
+
}
|
|
114
113
|
noterefs.set(id, pos);
|
|
115
114
|
}
|
|
116
115
|
return false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ParsedXml } from '@storyteller-platform/epub';
|
|
2
|
-
import { R as Root
|
|
2
|
+
import { R as Root } from '../model-CeOMDDgt.cjs';
|
|
3
3
|
|
|
4
4
|
declare function parseDom(xml: ParsedXml): Root;
|
|
5
|
-
declare function findFootnotePairs(root: Root
|
|
5
|
+
declare function findFootnotePairs(root: Root): Map<number, number>;
|
|
6
6
|
|
|
7
7
|
export { findFootnotePairs, parseDom };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ParsedXml } from '@storyteller-platform/epub';
|
|
2
|
-
import { R as Root
|
|
2
|
+
import { R as Root } from '../model-CeOMDDgt.js';
|
|
3
3
|
|
|
4
4
|
declare function parseDom(xml: ParsedXml): Root;
|
|
5
|
-
declare function findFootnotePairs(root: Root
|
|
5
|
+
declare function findFootnotePairs(root: Root): Map<number, number>;
|
|
6
6
|
|
|
7
7
|
export { findFootnotePairs, parseDom };
|
package/dist/markup/parseDom.js
CHANGED
|
@@ -4,11 +4,7 @@ import {
|
|
|
4
4
|
FootnoteNode,
|
|
5
5
|
Mark,
|
|
6
6
|
Node,
|
|
7
|
-
NoterefNode,
|
|
8
7
|
Root,
|
|
9
|
-
RubyNode,
|
|
10
|
-
RubyParenthesisNode,
|
|
11
|
-
RubyTextNode,
|
|
12
8
|
TextNode,
|
|
13
9
|
descendants
|
|
14
10
|
} from "./model.js";
|
|
@@ -45,13 +41,11 @@ class Parser {
|
|
|
45
41
|
pos + 1
|
|
46
42
|
);
|
|
47
43
|
if (tagName === "a" && attrs["epub:type"] === "noteref") {
|
|
48
|
-
const
|
|
49
|
-
const href = node.attrs["href"];
|
|
44
|
+
const href = attrs["href"];
|
|
50
45
|
const fragment = href?.split("#")[1];
|
|
51
46
|
if (fragment) {
|
|
52
47
|
this.footnoteIds.add(fragment);
|
|
53
48
|
}
|
|
54
|
-
return node;
|
|
55
49
|
}
|
|
56
50
|
if (attrs["id"] && (FOOTNOTE_ROLES.includes(attrs["epub:type"] ?? "") || // Some footnotes aren't properly marked up with the
|
|
57
51
|
// correct role
|
|
@@ -69,15 +63,6 @@ class Parser {
|
|
|
69
63
|
);
|
|
70
64
|
return footnoteNode;
|
|
71
65
|
}
|
|
72
|
-
if (tagName === "ruby") {
|
|
73
|
-
return new RubyNode(tagName, attrs, blockChildren, marks);
|
|
74
|
-
}
|
|
75
|
-
if (tagName === "rt") {
|
|
76
|
-
return new RubyTextNode(tagName, attrs, blockChildren, marks);
|
|
77
|
-
}
|
|
78
|
-
if (tagName === "rp") {
|
|
79
|
-
return new RubyParenthesisNode(tagName, attrs, blockChildren, marks);
|
|
80
|
-
}
|
|
81
66
|
if (BLOCKS.includes(tagName)) {
|
|
82
67
|
return new Node(tagName, attrs, blockChildren, marks);
|
|
83
68
|
}
|
|
@@ -96,9 +81,19 @@ function findFootnotePairs(root) {
|
|
|
96
81
|
const noterefs = /* @__PURE__ */ new Map();
|
|
97
82
|
const pairs = /* @__PURE__ */ new Map();
|
|
98
83
|
descendants(root, (node, pos) => {
|
|
99
|
-
|
|
100
|
-
|
|
84
|
+
const mark = node.marks.find((mark2) => mark2.tagName === "a");
|
|
85
|
+
if (mark) {
|
|
86
|
+
const id = mark.attrs["href"]?.split("#")[1];
|
|
101
87
|
if (id) {
|
|
88
|
+
const $pos = root.resolve(pos);
|
|
89
|
+
let d = $pos.depth;
|
|
90
|
+
while (d > 0) {
|
|
91
|
+
const node2 = $pos.node(d);
|
|
92
|
+
if (node2 instanceof FootnoteNode) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
d--;
|
|
96
|
+
}
|
|
102
97
|
noterefs.set(id, pos);
|
|
103
98
|
}
|
|
104
99
|
return false;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { a as ResolvedPos } from '../model-
|
|
1
|
+
export { a as ResolvedPos } from '../model-CeOMDDgt.cjs';
|
|
2
2
|
import '@storyteller-platform/epub';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { a as ResolvedPos } from '../model-
|
|
1
|
+
export { a as ResolvedPos } from '../model-CeOMDDgt.js';
|
|
2
2
|
import '@storyteller-platform/epub';
|
|
@@ -27,7 +27,9 @@ async function segmentChapter(text, options) {
|
|
|
27
27
|
...options.primaryLocale && {
|
|
28
28
|
language: options.primaryLocale.language
|
|
29
29
|
},
|
|
30
|
-
|
|
30
|
+
// TODO: re-enable this, only disabled until we figure out
|
|
31
|
+
// why it's not working in the SEA!
|
|
32
|
+
enableEastAsianPostprocessing: false
|
|
31
33
|
});
|
|
32
34
|
return result.sentences;
|
|
33
35
|
}
|
|
@@ -7,7 +7,9 @@ async function segmentChapter(text, options) {
|
|
|
7
7
|
...options.primaryLocale && {
|
|
8
8
|
language: options.primaryLocale.language
|
|
9
9
|
},
|
|
10
|
-
|
|
10
|
+
// TODO: re-enable this, only disabled until we figure out
|
|
11
|
+
// why it's not working in the SEA!
|
|
12
|
+
enableEastAsianPostprocessing: false
|
|
11
13
|
});
|
|
12
14
|
return result.sentences;
|
|
13
15
|
}
|
|
@@ -29,7 +29,7 @@ class Serializer {
|
|
|
29
29
|
}
|
|
30
30
|
serializedIds = /* @__PURE__ */ new Set();
|
|
31
31
|
serialize() {
|
|
32
|
-
return this.doc.children
|
|
32
|
+
return this.serializeDomNodes(this.doc.children);
|
|
33
33
|
}
|
|
34
34
|
serializeDomNode(node) {
|
|
35
35
|
if (node instanceof import_model.TextNode) {
|
|
@@ -7,7 +7,7 @@ class Serializer {
|
|
|
7
7
|
}
|
|
8
8
|
serializedIds = /* @__PURE__ */ new Set();
|
|
9
9
|
serialize() {
|
|
10
|
-
return this.doc.children
|
|
10
|
+
return this.serializeDomNodes(this.doc.children);
|
|
11
11
|
}
|
|
12
12
|
serializeDomNode(node) {
|
|
13
13
|
if (node instanceof TextNode) {
|
|
@@ -69,7 +69,10 @@ function liftText(root) {
|
|
|
69
69
|
if (node.isLeaf && parent.isBlock && index === parent.children.length - 1 && !text.endsWith("\n")) {
|
|
70
70
|
text += "\n";
|
|
71
71
|
}
|
|
72
|
-
return
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
if (node.marks.some((m) => m.tagName === "rp" || m.tagName === "rt")) {
|
|
75
|
+
return false;
|
|
73
76
|
}
|
|
74
77
|
if (pos - lastTextEnd) {
|
|
75
78
|
mapping.insertMap(lastTextEnd, pos - lastTextEnd, 0);
|
|
@@ -124,7 +127,7 @@ function replaceFootnotes(original, root, footnotePairs, mapping) {
|
|
|
124
127
|
for (const [noterefPos, footnotePos] of footnotePairs.entries()) {
|
|
125
128
|
const noteref = original.resolve(noterefPos).nodeAfter;
|
|
126
129
|
const footnote = transformed.resolve(cursor.map(noterefPos)).nodeAfter;
|
|
127
|
-
if (!(noteref instanceof import_model.
|
|
130
|
+
if (!(noteref instanceof import_model.TextNode) || !(footnote instanceof import_model.Node)) continue;
|
|
128
131
|
transformed = transformed.replace(cursor.map(noterefPos), noteref);
|
|
129
132
|
mapping.insertMap(noterefPos, footnote.nodeSize, noteref.nodeSize);
|
|
130
133
|
cursor = mapping.cursor();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mapping } from '@storyteller-platform/mapping';
|
|
2
|
-
import { R as Root, M as Mark } from '../model-
|
|
2
|
+
import { R as Root, M as Mark } from '../model-CeOMDDgt.cjs';
|
|
3
3
|
import '@storyteller-platform/epub';
|
|
4
4
|
|
|
5
5
|
declare function addMark(root: Root, from: number, to: number, mark: Mark): Root;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mapping } from '@storyteller-platform/mapping';
|
|
2
|
-
import { R as Root, M as Mark } from '../model-
|
|
2
|
+
import { R as Root, M as Mark } from '../model-CeOMDDgt.js';
|
|
3
3
|
import '@storyteller-platform/epub';
|
|
4
4
|
|
|
5
5
|
declare function addMark(root: Root, from: number, to: number, mark: Mark): Root;
|
package/dist/markup/transform.js
CHANGED
|
@@ -3,8 +3,6 @@ import { Mapping } from "@storyteller-platform/mapping";
|
|
|
3
3
|
import {
|
|
4
4
|
FootnoteNode,
|
|
5
5
|
Node,
|
|
6
|
-
RubyParenthesisNode,
|
|
7
|
-
RubyTextNode,
|
|
8
6
|
TextNode,
|
|
9
7
|
descendants
|
|
10
8
|
} from "./model.js";
|
|
@@ -51,7 +49,10 @@ function liftText(root) {
|
|
|
51
49
|
if (node.isLeaf && parent.isBlock && index === parent.children.length - 1 && !text.endsWith("\n")) {
|
|
52
50
|
text += "\n";
|
|
53
51
|
}
|
|
54
|
-
return
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
if (node.marks.some((m) => m.tagName === "rp" || m.tagName === "rt")) {
|
|
55
|
+
return false;
|
|
55
56
|
}
|
|
56
57
|
if (pos - lastTextEnd) {
|
|
57
58
|
mapping.insertMap(lastTextEnd, pos - lastTextEnd, 0);
|
|
@@ -106,7 +107,7 @@ function replaceFootnotes(original, root, footnotePairs, mapping) {
|
|
|
106
107
|
for (const [noterefPos, footnotePos] of footnotePairs.entries()) {
|
|
107
108
|
const noteref = original.resolve(noterefPos).nodeAfter;
|
|
108
109
|
const footnote = transformed.resolve(cursor.map(noterefPos)).nodeAfter;
|
|
109
|
-
if (!(noteref instanceof
|
|
110
|
+
if (!(noteref instanceof TextNode) || !(footnote instanceof Node)) continue;
|
|
110
111
|
transformed = transformed.replace(cursor.map(noterefPos), noteref);
|
|
111
112
|
mapping.insertMap(noterefPos, footnote.nodeSize, noteref.nodeSize);
|
|
112
113
|
cursor = mapping.cursor();
|
|
@@ -32,7 +32,7 @@ declare class Root {
|
|
|
32
32
|
index: number;
|
|
33
33
|
offset: number;
|
|
34
34
|
};
|
|
35
|
-
replace(at: number, withNode: Node): Root;
|
|
35
|
+
replace(at: number, withNode: Node | TextNode): Root;
|
|
36
36
|
cut(pos: number): Node | TextNode | null;
|
|
37
37
|
resolve(pos: number): ResolvedPos;
|
|
38
38
|
}
|
|
@@ -57,23 +57,15 @@ declare class Node {
|
|
|
57
57
|
children?: (Node | TextNode)[];
|
|
58
58
|
marks?: Mark[];
|
|
59
59
|
}): Node;
|
|
60
|
-
replace(at: number, withNode: Node): Node;
|
|
60
|
+
replace(at: number, withNode: Node | TextNode): Node;
|
|
61
61
|
cut(pos: number): Node | TextNode | null;
|
|
62
62
|
findIndex(pos: number): {
|
|
63
63
|
index: number;
|
|
64
64
|
offset: number;
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
declare class NoterefNode extends Node {
|
|
68
|
-
}
|
|
69
67
|
declare class FootnoteNode extends Node {
|
|
70
68
|
}
|
|
71
|
-
declare class RubyParenthesisNode extends Node {
|
|
72
|
-
}
|
|
73
|
-
declare class RubyTextNode extends Node {
|
|
74
|
-
}
|
|
75
|
-
declare class RubyNode extends Node {
|
|
76
|
-
}
|
|
77
69
|
declare class Mark {
|
|
78
70
|
tagName: ElementName;
|
|
79
71
|
attrs: Record<string, string>;
|
|
@@ -99,4 +91,4 @@ declare class TextNode {
|
|
|
99
91
|
}
|
|
100
92
|
declare function descendants(node: Root | Node, cb: (node: Node | TextNode, pos: number, parent: Node | Root, index: number) => boolean, pos?: number): void;
|
|
101
93
|
|
|
102
|
-
export { FootnoteNode as F, Mark as M, Node as N, Root as R, TextNode as T, ResolvedPos as a,
|
|
94
|
+
export { FootnoteNode as F, Mark as M, Node as N, Root as R, TextNode as T, ResolvedPos as a, descendants as d };
|
|
@@ -32,7 +32,7 @@ declare class Root {
|
|
|
32
32
|
index: number;
|
|
33
33
|
offset: number;
|
|
34
34
|
};
|
|
35
|
-
replace(at: number, withNode: Node): Root;
|
|
35
|
+
replace(at: number, withNode: Node | TextNode): Root;
|
|
36
36
|
cut(pos: number): Node | TextNode | null;
|
|
37
37
|
resolve(pos: number): ResolvedPos;
|
|
38
38
|
}
|
|
@@ -57,23 +57,15 @@ declare class Node {
|
|
|
57
57
|
children?: (Node | TextNode)[];
|
|
58
58
|
marks?: Mark[];
|
|
59
59
|
}): Node;
|
|
60
|
-
replace(at: number, withNode: Node): Node;
|
|
60
|
+
replace(at: number, withNode: Node | TextNode): Node;
|
|
61
61
|
cut(pos: number): Node | TextNode | null;
|
|
62
62
|
findIndex(pos: number): {
|
|
63
63
|
index: number;
|
|
64
64
|
offset: number;
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
declare class NoterefNode extends Node {
|
|
68
|
-
}
|
|
69
67
|
declare class FootnoteNode extends Node {
|
|
70
68
|
}
|
|
71
|
-
declare class RubyParenthesisNode extends Node {
|
|
72
|
-
}
|
|
73
|
-
declare class RubyTextNode extends Node {
|
|
74
|
-
}
|
|
75
|
-
declare class RubyNode extends Node {
|
|
76
|
-
}
|
|
77
69
|
declare class Mark {
|
|
78
70
|
tagName: ElementName;
|
|
79
71
|
attrs: Record<string, string>;
|
|
@@ -99,4 +91,4 @@ declare class TextNode {
|
|
|
99
91
|
}
|
|
100
92
|
declare function descendants(node: Root | Node, cb: (node: Node | TextNode, pos: number, parent: Node | Root, index: number) => boolean, pos?: number): void;
|
|
101
93
|
|
|
102
|
-
export { FootnoteNode as F, Mark as M, Node as N, Root as R, TextNode as T, ResolvedPos as a,
|
|
94
|
+
export { FootnoteNode as F, Mark as M, Node as N, Root as R, TextNode as T, ResolvedPos as a, descendants as d };
|