@gondola-lyrics/kit 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/formats.d.ts +1 -1
- package/dist/formats.js +11 -5
- package/dist/formats.js.map +1 -1
- package/dist/index.d.ts +166 -1
- package/dist/index.js +3 -1
- package/dist/parser.d.ts +166 -1
- package/dist/parser.js +3 -1
- package/dist/transforms.d.ts +170 -1
- package/dist/transforms.js +1048 -0
- package/dist/transforms.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,9 +10,10 @@ npm install @gondola-lyrics/kit
|
|
|
10
10
|
|
|
11
11
|
## Supports
|
|
12
12
|
|
|
13
|
-
| Format |
|
|
14
|
-
| ------ |
|
|
15
|
-
| LRC | ✅
|
|
13
|
+
| Format | Line level | Word level | Annotation | Meta |
|
|
14
|
+
| ------ | ---------- | ---------- | ---------- | ---- |
|
|
15
|
+
| LRC | ✅ | ✅ | ✅ | ✅ |
|
|
16
|
+
| TTML | ✅ | ✅ | ✅ | ✅ |
|
|
16
17
|
|
|
17
18
|
## Usage
|
|
18
19
|
|
package/dist/formats.d.ts
CHANGED
|
@@ -104,7 +104,7 @@ export declare type LyricFormat = 'lrc' | 'ttml';
|
|
|
104
104
|
export declare const parse: (input: unknown, options?: LrcParseOptions & TtmlParseOptions) => ParseResult | null;
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
|
-
*
|
|
107
|
+
* Empty timed rows become instrumental lines; source order and missing word times remain for model validation.
|
|
108
108
|
*
|
|
109
109
|
* Annotation tracks are read as lines too and attached by timestamp, and rows that match no line are dropped.
|
|
110
110
|
*
|
package/dist/formats.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentType, CreditRole, LineType, LyricStatus, Timing, WordType, canonicalizeLyric, deriveLanguageUsages, getWordsText, makeAgent, makeLineAnnotation, makeLineAnnotationRoman, makeLineAnnotationTranslation, makeLineBackground, makeLineContentText, makeLineContentWords, makeLineNormal, makeLyric, makeMeta, makeMetaCredit, makeText, makeTimeRange, makeUnknownEntry, makeWordAnnotation, makeWordAnnotationRuby, makeWordAnnotationToken, makeWordNormal, makeWordSpace, removeOffset, resolveAnnotationItemTime, resolveAnnotationTokenTime, validateLyric } from "@gondola-lyrics/model/runtime";
|
|
1
|
+
import { AgentType, CreditRole, LineType, LyricStatus, Timing, WordType, canonicalizeLyric, deriveLanguageUsages, getWordsText, makeAgent, makeLineAnnotation, makeLineAnnotationRoman, makeLineAnnotationTranslation, makeLineBackground, makeLineContentText, makeLineContentWords, makeLineInstrumental, makeLineNormal, makeLyric, makeMeta, makeMetaCredit, makeText, makeTimeRange, makeUnknownEntry, makeWordAnnotation, makeWordAnnotationRuby, makeWordAnnotationToken, makeWordNormal, makeWordSpace, removeOffset, resolveAnnotationItemTime, resolveAnnotationTokenTime, validateLyric } from "@gondola-lyrics/model/runtime";
|
|
2
2
|
//#region src/utils/annotation.ts
|
|
3
3
|
/**
|
|
4
4
|
* An annotation line carries its text in either field, depending on whether the track used word tags.
|
|
@@ -1184,14 +1184,20 @@ var readWords$1 = (text, lineStart) => {
|
|
|
1184
1184
|
/**
|
|
1185
1185
|
* A line ends at the next line's start; without one, it ends at its final word's end.
|
|
1186
1186
|
* An open word is closed by the next timed word, or by the line end, so every sung word stays inside the line.
|
|
1187
|
+
* Empty timed rows represent instrumental time rather than sung content.
|
|
1187
1188
|
*/
|
|
1188
1189
|
var readLine$1 = (text, start, nextStart) => {
|
|
1190
|
+
const trimmed = text.trim();
|
|
1191
|
+
let end = nextStart !== void 0 && nextStart >= start ? nextStart : void 0;
|
|
1192
|
+
if (trimmed === "") return makeLineInstrumental({ time: makeTimeRange({
|
|
1193
|
+
start,
|
|
1194
|
+
end
|
|
1195
|
+
}) });
|
|
1189
1196
|
const wordTimed = isWordTimed(text);
|
|
1190
1197
|
const { drafts, closeSegment } = wordTimed ? readWords$1(text, start) : {
|
|
1191
1198
|
drafts: [],
|
|
1192
1199
|
closeSegment: () => {}
|
|
1193
1200
|
};
|
|
1194
|
-
let end = nextStart !== void 0 && nextStart >= start ? nextStart : void 0;
|
|
1195
1201
|
if (end === void 0) end = [...drafts].reverse().find((draft) => !draft.space && draft.start !== void 0)?.end;
|
|
1196
1202
|
closeSegment(end);
|
|
1197
1203
|
const words = drafts.map((draft) => {
|
|
@@ -1209,7 +1215,7 @@ var readLine$1 = (text, start, nextStart) => {
|
|
|
1209
1215
|
start,
|
|
1210
1216
|
end
|
|
1211
1217
|
});
|
|
1212
|
-
const content = wordTimed ? makeLineContentWords(words) : makeLineContentText(
|
|
1218
|
+
const content = wordTimed ? makeLineContentWords(words) : makeLineContentText(trimmed);
|
|
1213
1219
|
return makeLineNormal({
|
|
1214
1220
|
time,
|
|
1215
1221
|
content
|
|
@@ -1217,7 +1223,7 @@ var readLine$1 = (text, start, nextStart) => {
|
|
|
1217
1223
|
};
|
|
1218
1224
|
/**
|
|
1219
1225
|
* Builds one line per timed row, so an annotation track reuses the original text's reading unchanged.
|
|
1220
|
-
*
|
|
1226
|
+
* Empty timed rows become instrumental lines bounded by the next timestamp when one is usable.
|
|
1221
1227
|
*/
|
|
1222
1228
|
var readLines = (timed) => {
|
|
1223
1229
|
const lines = [];
|
|
@@ -1247,7 +1253,7 @@ var parseLrcText = (text) => {
|
|
|
1247
1253
|
});
|
|
1248
1254
|
};
|
|
1249
1255
|
/**
|
|
1250
|
-
*
|
|
1256
|
+
* Empty timed rows become instrumental lines; source order and missing word times remain for model validation.
|
|
1251
1257
|
*
|
|
1252
1258
|
* Annotation tracks are read as lines too and attached by timestamp, and rows that match no line are dropped.
|
|
1253
1259
|
*
|