@gondola-lyrics/kit 0.2.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.
@@ -3,9 +3,10 @@ import { runtime } from '@gondola-lyrics/model';
3
3
  /**
4
4
  * Generates text in the requested format, which need not match `lyric.format`.
5
5
  *
6
- * A format without a writer has no branch here, so adding one to `LyricFormat` makes this fail to compile.
6
+ * The writer map pairs each format's options with its result and requires a writer for every supported format.
7
+ * An unknown target returns `null`.
7
8
  */
8
- export declare const generate: (lyric: runtime.Lyric, target: LyricFormat, options?: LrcGenerateOptions) => LrcGenerateResult;
9
+ export declare const generate: <Target extends LyricFormat>(lyric: runtime.Lyric, target: Target, options?: GenerateOptions[Target]) => GenerateResults[Target] | null;
9
10
 
10
11
  /**
11
12
  * Generates the LRC text plus the annotations a single file cannot hold.
@@ -14,6 +15,24 @@ export declare const generate: (lyric: runtime.Lyric, target: LyricFormat, optio
14
15
  */
15
16
  export declare const generateLrc: (lyric: runtime.Lyric, options?: LrcGenerateOptions) => LrcGenerateResult;
16
17
 
18
+ declare interface GenerateOptions {
19
+ lrc: LrcGenerateOptions;
20
+ ttml: TtmlGenerateOptions;
21
+ }
22
+
23
+ declare interface GenerateResults {
24
+ lrc: LrcGenerateResult;
25
+ ttml: TtmlGenerateResult;
26
+ }
27
+
28
+ /**
29
+ * Generates one TTML document, retaining the source profile unless explicitly overridden.
30
+ *
31
+ * Offsets are baked into timestamps; a negative result or a missing required time throws.
32
+ * Profile mappings retain the lead agent and first AMLL ruby, omitting unsupported fields and instrumental nodes.
33
+ */
34
+ export declare const generateTtml: (lyric: runtime.Lyric, options?: TtmlGenerateOptions) => TtmlGenerateResult;
35
+
17
36
  declare interface LrcContent {
18
37
  original: string;
19
38
  translations?: string;
@@ -46,4 +65,25 @@ export declare type LrcGenerateResult = LrcContent;
46
65
  */
47
66
  export declare type LyricFormat = 'lrc' | 'ttml';
48
67
 
68
+ export declare interface TtmlGenerateOptions {
69
+ /**
70
+ * Defaults to the source TTML profile, or `amll` when the lyric came from another format.
71
+ */
72
+ profile?: TtmlProfile;
73
+ /**
74
+ * Indent document structure; defaults to `false`.
75
+ * Lyric content stays flush to keep formatting whitespace out of the words.
76
+ */
77
+ indent?: boolean;
78
+ /**
79
+ * Emit song metadata; defaults to `true`.
80
+ * Agents and annotation tracks are retained because the body references them.
81
+ */
82
+ includeMeta?: boolean;
83
+ }
84
+
85
+ export declare type TtmlGenerateResult = string;
86
+
87
+ export declare type TtmlProfile = 'amll' | 'itunes';
88
+
49
89
  export { }
package/dist/generator.js CHANGED
@@ -1 +1 @@
1
- export { generate, generateLrc } from "./formats.js";
1
+ export { generate, generateLrc, generateTtml } from "./formats.js";
package/dist/index.d.ts CHANGED
@@ -6,14 +6,15 @@ import { runtime } from '@gondola-lyrics/model';
6
6
  *
7
7
  * Unrecognized text returns `undefined`.
8
8
  */
9
- export declare const detectFormat: (input: unknown) => "lrc" | "ttml" | undefined;
9
+ export declare const detectFormat: (input: unknown) => LyricFormat | undefined;
10
10
 
11
11
  /**
12
12
  * Generates text in the requested format, which need not match `lyric.format`.
13
13
  *
14
- * A format without a writer has no branch here, so adding one to `LyricFormat` makes this fail to compile.
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`.
15
16
  */
16
- 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;
17
18
 
18
19
  /**
19
20
  * Generates the LRC text plus the annotations a single file cannot hold.
@@ -22,6 +23,24 @@ export declare const generate: (lyric: runtime.Lyric, target: LyricFormat, optio
22
23
  */
23
24
  export declare const generateLrc: (lyric: runtime.Lyric, options?: LrcGenerateOptions) => LrcGenerateResult;
24
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
+
25
44
  declare interface LrcContent {
26
45
  original: string;
27
46
  translations?: string;
@@ -93,12 +112,29 @@ export declare interface ParseResult {
93
112
  * The profile only changes where metadata comes from, so one reader serves both.
94
113
  * A document that parses but holds no timed paragraph is `INVALID` rather than an error.
95
114
  */
96
- export declare const parseTtml: (input: string | TtmlContent, options?: TtmlParseOptions) => ParseResult;
115
+ export declare const parseTtml: (input: TtmlParseInput, options?: TtmlParseOptions) => ParseResult;
97
116
 
98
- export declare interface TtmlContent {
99
- original: string;
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;
100
132
  }
101
133
 
134
+ export declare type TtmlGenerateResult = string;
135
+
136
+ export declare type TtmlParseInput = string;
137
+
102
138
  export declare interface TtmlParseOptions {
103
139
  /** Language tag the lyric declares; the document's own `xml:lang` wins when it states one. */
104
140
  language?: string;
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { detectFormat, generate, generateLrc, parse, parseLrc, parseTtml } 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
@@ -6,7 +6,7 @@ import { runtime } from '@gondola-lyrics/model';
6
6
  *
7
7
  * Unrecognized text returns `undefined`.
8
8
  */
9
- export declare const detectFormat: (input: unknown) => "lrc" | "ttml" | undefined;
9
+ export declare const detectFormat: (input: unknown) => LyricFormat | undefined;
10
10
 
11
11
  declare interface LrcContent {
12
12
  original: string;
@@ -58,11 +58,9 @@ export declare interface ParseResult {
58
58
  * The profile only changes where metadata comes from, so one reader serves both.
59
59
  * A document that parses but holds no timed paragraph is `INVALID` rather than an error.
60
60
  */
61
- export declare const parseTtml: (input: string | TtmlContent, options?: TtmlParseOptions) => ParseResult;
61
+ export declare const parseTtml: (input: TtmlParseInput, options?: TtmlParseOptions) => ParseResult;
62
62
 
63
- export declare interface TtmlContent {
64
- original: string;
65
- }
63
+ export declare type TtmlParseInput = string;
66
64
 
67
65
  export declare interface TtmlParseOptions {
68
66
  /** Language tag the lyric declares; the document's own `xml:lang` wins when it states one. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gondola-lyrics/kit",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Gondola lyrics toolkit",
5
5
  "keywords": [
6
6
  "gondola",