@gondola-lyrics/kit 0.1.0 → 0.3.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/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Diagnostic } from '@gondola-lyrics/model/runtime';
1
2
  import { runtime } from '@gondola-lyrics/model';
2
3
 
3
4
  /**
@@ -5,12 +6,15 @@ import { runtime } from '@gondola-lyrics/model';
5
6
  *
6
7
  * Unrecognized text returns `undefined`.
7
8
  */
8
- export declare const detectFormat: (input: unknown) => "lrc" | undefined;
9
+ export declare const detectFormat: (input: unknown) => LyricFormat | undefined;
9
10
 
10
11
  /**
11
12
  * Generates text in the requested format, which need not match `lyric.format`.
13
+ *
14
+ * The writer map pairs each format's options with its result and requires a writer for every supported format.
15
+ * An unknown target returns `null`.
12
16
  */
13
- export declare const generate: (lyric: runtime.Lyric, target: LyricFormat, options?: LrcGenerateOptions) => LrcGenerateResult;
17
+ export declare const generate: <Target extends LyricFormat>(lyric: runtime.Lyric, target: Target, options?: GenerateOptions[Target]) => GenerateResults[Target] | null;
14
18
 
15
19
  /**
16
20
  * Generates the LRC text plus the annotations a single file cannot hold.
@@ -19,6 +23,24 @@ export declare const generate: (lyric: runtime.Lyric, target: LyricFormat, optio
19
23
  */
20
24
  export declare const generateLrc: (lyric: runtime.Lyric, options?: LrcGenerateOptions) => LrcGenerateResult;
21
25
 
26
+ declare interface GenerateOptions {
27
+ lrc: LrcGenerateOptions;
28
+ ttml: TtmlGenerateOptions;
29
+ }
30
+
31
+ declare interface GenerateResults {
32
+ lrc: LrcGenerateResult;
33
+ ttml: TtmlGenerateResult;
34
+ }
35
+
36
+ /**
37
+ * Generates one TTML document, retaining the source profile unless explicitly overridden.
38
+ *
39
+ * Offsets are baked into timestamps; a negative result or a missing required time throws.
40
+ * Profile mappings retain the lead agent and first AMLL ruby, omitting unsupported fields and instrumental nodes.
41
+ */
42
+ export declare const generateTtml: (lyric: runtime.Lyric, options?: TtmlGenerateOptions) => TtmlGenerateResult;
43
+
22
44
  declare interface LrcContent {
23
45
  original: string;
24
46
  translations?: string;
@@ -59,21 +81,65 @@ export declare interface LrcParseOptions {
59
81
  /**
60
82
  * Values match the lowercase format names stored in `Lyric.format`.
61
83
  */
62
- export declare type LyricFormat = 'lrc';
84
+ export declare type LyricFormat = 'lrc' | 'ttml';
63
85
 
64
86
  /**
65
- * Unrecognized text returns `null`; a recognized format returns a lyric with its parser-assigned status.
87
+ * Unrecognized text returns `null`; a recognized format returns its canonical lyric and diagnostics.
66
88
  * Annotation tracks travel with the source and are attached by the format's parser.
67
89
  */
68
- export declare const parse: (input: unknown, options?: LrcParseOptions) => runtime.Lyric | null;
90
+ export declare const parse: (input: unknown, options?: LrcParseOptions & TtmlParseOptions) => ParseResult | null;
69
91
 
70
92
  /**
71
93
  * Source order, empty timed lines, and missing word times are preserved for model validation.
72
94
  *
73
95
  * Annotation tracks are read as lines too and attached by timestamp, and rows that match no line are dropped.
74
96
  *
75
- * `INVALID` means no readable timed lines; `VALID` does not imply model validation has passed.
97
+ * `INVALID` means no readable timed lines; the returned diagnostics carry whatever the canonical tree breaks.
98
+ */
99
+ export declare const parseLrc: (input: string | LrcParseInput, options?: LrcParseOptions) => ParseResult;
100
+
101
+ /**
102
+ * A parsed lyric in canonical form, with every rule it breaks.
76
103
  */
77
- export declare const parseLrc: (input: string | LrcParseInput, options?: LrcParseOptions) => runtime.Lyric;
104
+ export declare interface ParseResult {
105
+ lyric: runtime.Lyric;
106
+ diagnostics: Diagnostic[];
107
+ }
108
+
109
+ /**
110
+ * Reads a TTML document into the model.
111
+ *
112
+ * The profile only changes where metadata comes from, so one reader serves both.
113
+ * A document that parses but holds no timed paragraph is `INVALID` rather than an error.
114
+ */
115
+ export declare const parseTtml: (input: TtmlParseInput, options?: TtmlParseOptions) => ParseResult;
116
+
117
+ export declare interface TtmlGenerateOptions {
118
+ /**
119
+ * Defaults to the source TTML profile, or `amll` when the lyric came from another format.
120
+ */
121
+ profile?: TtmlProfile;
122
+ /**
123
+ * Indent document structure; defaults to `false`.
124
+ * Lyric content stays flush to keep formatting whitespace out of the words.
125
+ */
126
+ indent?: boolean;
127
+ /**
128
+ * Emit song metadata; defaults to `true`.
129
+ * Agents and annotation tracks are retained because the body references them.
130
+ */
131
+ includeMeta?: boolean;
132
+ }
133
+
134
+ export declare type TtmlGenerateResult = string;
135
+
136
+ export declare type TtmlParseInput = string;
137
+
138
+ export declare interface TtmlParseOptions {
139
+ /** Language tag the lyric declares; the document's own `xml:lang` wins when it states one. */
140
+ language?: string;
141
+ }
142
+
143
+ export declare type TtmlProfile = 'amll' | 'itunes';
78
144
 
79
145
  export { }
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { detectFormat, generate, generateLrc, parse, parseLrc } from "./formats.js";
1
+ export { detectFormat, generate, generateLrc, generateTtml, parse, parseLrc, parseTtml } from "./formats.js";
2
2
  import "./parser.js";
3
3
  import "./generator.js";
package/dist/parser.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Diagnostic } from '@gondola-lyrics/model/runtime';
1
2
  import { runtime } from '@gondola-lyrics/model';
2
3
 
3
4
  /**
@@ -5,7 +6,7 @@ import { runtime } from '@gondola-lyrics/model';
5
6
  *
6
7
  * Unrecognized text returns `undefined`.
7
8
  */
8
- export declare const detectFormat: (input: unknown) => "lrc" | undefined;
9
+ export declare const detectFormat: (input: unknown) => LyricFormat | undefined;
9
10
 
10
11
  declare interface LrcContent {
11
12
  original: string;
@@ -26,21 +27,46 @@ export declare interface LrcParseOptions {
26
27
  /**
27
28
  * Values match the lowercase format names stored in `Lyric.format`.
28
29
  */
29
- export declare type LyricFormat = 'lrc';
30
+ export declare type LyricFormat = 'lrc' | 'ttml';
30
31
 
31
32
  /**
32
- * Unrecognized text returns `null`; a recognized format returns a lyric with its parser-assigned status.
33
+ * Unrecognized text returns `null`; a recognized format returns its canonical lyric and diagnostics.
33
34
  * Annotation tracks travel with the source and are attached by the format's parser.
34
35
  */
35
- export declare const parse: (input: unknown, options?: LrcParseOptions) => runtime.Lyric | null;
36
+ export declare const parse: (input: unknown, options?: LrcParseOptions & TtmlParseOptions) => ParseResult | null;
36
37
 
37
38
  /**
38
39
  * Source order, empty timed lines, and missing word times are preserved for model validation.
39
40
  *
40
41
  * Annotation tracks are read as lines too and attached by timestamp, and rows that match no line are dropped.
41
42
  *
42
- * `INVALID` means no readable timed lines; `VALID` does not imply model validation has passed.
43
+ * `INVALID` means no readable timed lines; the returned diagnostics carry whatever the canonical tree breaks.
43
44
  */
44
- export declare const parseLrc: (input: string | LrcParseInput, options?: LrcParseOptions) => runtime.Lyric;
45
+ export declare const parseLrc: (input: string | LrcParseInput, options?: LrcParseOptions) => ParseResult;
46
+
47
+ /**
48
+ * A parsed lyric in canonical form, with every rule it breaks.
49
+ */
50
+ export declare interface ParseResult {
51
+ lyric: runtime.Lyric;
52
+ diagnostics: Diagnostic[];
53
+ }
54
+
55
+ /**
56
+ * Reads a TTML document into the model.
57
+ *
58
+ * The profile only changes where metadata comes from, so one reader serves both.
59
+ * A document that parses but holds no timed paragraph is `INVALID` rather than an error.
60
+ */
61
+ export declare const parseTtml: (input: TtmlParseInput, options?: TtmlParseOptions) => ParseResult;
62
+
63
+ export declare type TtmlParseInput = string;
64
+
65
+ export declare interface TtmlParseOptions {
66
+ /** Language tag the lyric declares; the document's own `xml:lang` wins when it states one. */
67
+ language?: string;
68
+ }
69
+
70
+ export declare type TtmlProfile = 'amll' | 'itunes';
45
71
 
46
72
  export { }
package/dist/parser.js CHANGED
@@ -1 +1 @@
1
- export { detectFormat, parse, parseLrc } from "./formats.js";
1
+ export { detectFormat, parse, parseLrc, parseTtml } from "./formats.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gondola-lyrics/kit",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Gondola lyrics toolkit",
5
5
  "keywords": [
6
6
  "gondola",