trackparse 0.1.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.
@@ -0,0 +1,104 @@
1
+ declare const SPEC_VERSION = "0.1.0";
2
+
3
+ /** Public types. They mirror spec/schema/parsed-track.schema.json and options.schema.json. */
4
+ type Mode = "clean" | "youtube" | "filename";
5
+ type ModeOption = Mode | "auto";
6
+ type ArtistRole = "primary" | "featured" | "remixer" | "producer";
7
+ type ArtistSource = "artist" | "title" | "version";
8
+ interface Artist {
9
+ name: string;
10
+ role: ArtistRole;
11
+ /** Raw joiner / marker text that preceded the name in its credit list; `null` for the first name. */
12
+ joiner: string | null;
13
+ source: ArtistSource;
14
+ }
15
+ type VersionType = "remix" | "bootleg" | "vip" | "edit" | "flip" | "refix" | "rework" | "mashup" | "blend" | "dub" | "mix" | "extended" | "radio" | "club" | "original" | "instrumental" | "acapella" | "live" | "acoustic" | "remaster" | "demo" | "reprise" | "cover" | "version" | "spedUp" | "slowed" | "nightcore";
16
+ type VersionDelimiter = "(" | "[" | "{" | "-";
17
+ interface Version {
18
+ type: VersionType;
19
+ raw: string;
20
+ artists: Artist[];
21
+ modifiers: string[];
22
+ descriptor: string | null;
23
+ year: number | null;
24
+ unknownArtist: boolean;
25
+ delimiter: VersionDelimiter;
26
+ }
27
+ type JunkKind = "video" | "audio" | "lyrics" | "quality" | "promo" | "platform" | "label" | "genre" | "other";
28
+ interface Junk {
29
+ raw: string;
30
+ kind: JunkKind;
31
+ }
32
+ type Warning = "noSeparator" | "ambiguousSeparator" | "unspacedDashSplit" | "asymmetricDashSplit" | "bySplit" | "quotedTitleSplit" | "ambiguousMixCredit" | "unbalancedBrackets";
33
+ interface Flags {
34
+ explicit: boolean;
35
+ clean: boolean;
36
+ unknownArtist: boolean;
37
+ unknownTitle: boolean;
38
+ }
39
+ interface Position {
40
+ raw: string;
41
+ number: number;
42
+ }
43
+ interface Timestamp {
44
+ raw: string;
45
+ seconds: number;
46
+ }
47
+ interface ParsedTrack {
48
+ input: string;
49
+ mode: Mode;
50
+ position: Position | null;
51
+ timestamp: Timestamp | null;
52
+ artists: Artist[];
53
+ title: string;
54
+ fullTitle: string;
55
+ versions: Version[];
56
+ year: number | null;
57
+ flags: Flags;
58
+ junk: Junk[];
59
+ warnings: Warning[];
60
+ }
61
+ interface KeywordOptions {
62
+ /** Extra version heads: key → version type. */
63
+ versionHeads?: Record<string, VersionType>;
64
+ descriptors?: string[];
65
+ genres?: string[];
66
+ /** Extra junk phrases: phrase → kind. */
67
+ junk?: Record<string, JunkKind>;
68
+ featMarkers?: string[];
69
+ }
70
+ interface ParseOptions {
71
+ mode?: ModeOption;
72
+ /** youtube mode: channel name used as the artist when no separator is found (R6.8). */
73
+ uploader?: string;
74
+ /** Names that must never be split (R7.3a). */
75
+ knownArtists?: string[];
76
+ splitAnd?: "auto" | "always" | "never";
77
+ keywords?: KeywordOptions;
78
+ }
79
+ interface FormatOptions {
80
+ feat?: "source" | "artist" | "title" | "omit";
81
+ featMarker?: string;
82
+ joiners?: "original" | "canonical";
83
+ versions?: "all" | "none";
84
+ producers?: boolean;
85
+ position?: boolean;
86
+ }
87
+
88
+ declare function format(track: ParsedTrack, options?: FormatOptions): string;
89
+ /** All credited names: track artists plus every version's remixers, deduped by R0.4 key. */
90
+ declare function allArtists(track: ParsedTrack): Artist[];
91
+
92
+ /** R1: normalize a track string. Idempotent; never throws on string input. */
93
+ declare function normalize(input: string): string;
94
+
95
+ interface Parser {
96
+ parse(input: string, options?: ParseOptions): ParsedTrack;
97
+ parseArtists(input: string, options?: ParseOptions): Artist[];
98
+ }
99
+ /** A parser with `options.keywords` compiled once. Per-call options are merged over `base`. */
100
+ declare function createParser(base?: ParseOptions): Parser;
101
+ declare function parse(input: string, options?: ParseOptions): ParsedTrack;
102
+ declare function parseArtists(input: string, options?: ParseOptions): Artist[];
103
+
104
+ export { type Artist, type ArtistRole, type ArtistSource, type Flags, type FormatOptions, type Junk, type JunkKind, type KeywordOptions, type Mode, type ModeOption, type ParseOptions, type ParsedTrack, type Parser, type Position, SPEC_VERSION, type Timestamp, type Version, type VersionDelimiter, type VersionType, type Warning, allArtists, createParser, format, normalize, parse, parseArtists };
@@ -0,0 +1,104 @@
1
+ declare const SPEC_VERSION = "0.1.0";
2
+
3
+ /** Public types. They mirror spec/schema/parsed-track.schema.json and options.schema.json. */
4
+ type Mode = "clean" | "youtube" | "filename";
5
+ type ModeOption = Mode | "auto";
6
+ type ArtistRole = "primary" | "featured" | "remixer" | "producer";
7
+ type ArtistSource = "artist" | "title" | "version";
8
+ interface Artist {
9
+ name: string;
10
+ role: ArtistRole;
11
+ /** Raw joiner / marker text that preceded the name in its credit list; `null` for the first name. */
12
+ joiner: string | null;
13
+ source: ArtistSource;
14
+ }
15
+ type VersionType = "remix" | "bootleg" | "vip" | "edit" | "flip" | "refix" | "rework" | "mashup" | "blend" | "dub" | "mix" | "extended" | "radio" | "club" | "original" | "instrumental" | "acapella" | "live" | "acoustic" | "remaster" | "demo" | "reprise" | "cover" | "version" | "spedUp" | "slowed" | "nightcore";
16
+ type VersionDelimiter = "(" | "[" | "{" | "-";
17
+ interface Version {
18
+ type: VersionType;
19
+ raw: string;
20
+ artists: Artist[];
21
+ modifiers: string[];
22
+ descriptor: string | null;
23
+ year: number | null;
24
+ unknownArtist: boolean;
25
+ delimiter: VersionDelimiter;
26
+ }
27
+ type JunkKind = "video" | "audio" | "lyrics" | "quality" | "promo" | "platform" | "label" | "genre" | "other";
28
+ interface Junk {
29
+ raw: string;
30
+ kind: JunkKind;
31
+ }
32
+ type Warning = "noSeparator" | "ambiguousSeparator" | "unspacedDashSplit" | "asymmetricDashSplit" | "bySplit" | "quotedTitleSplit" | "ambiguousMixCredit" | "unbalancedBrackets";
33
+ interface Flags {
34
+ explicit: boolean;
35
+ clean: boolean;
36
+ unknownArtist: boolean;
37
+ unknownTitle: boolean;
38
+ }
39
+ interface Position {
40
+ raw: string;
41
+ number: number;
42
+ }
43
+ interface Timestamp {
44
+ raw: string;
45
+ seconds: number;
46
+ }
47
+ interface ParsedTrack {
48
+ input: string;
49
+ mode: Mode;
50
+ position: Position | null;
51
+ timestamp: Timestamp | null;
52
+ artists: Artist[];
53
+ title: string;
54
+ fullTitle: string;
55
+ versions: Version[];
56
+ year: number | null;
57
+ flags: Flags;
58
+ junk: Junk[];
59
+ warnings: Warning[];
60
+ }
61
+ interface KeywordOptions {
62
+ /** Extra version heads: key → version type. */
63
+ versionHeads?: Record<string, VersionType>;
64
+ descriptors?: string[];
65
+ genres?: string[];
66
+ /** Extra junk phrases: phrase → kind. */
67
+ junk?: Record<string, JunkKind>;
68
+ featMarkers?: string[];
69
+ }
70
+ interface ParseOptions {
71
+ mode?: ModeOption;
72
+ /** youtube mode: channel name used as the artist when no separator is found (R6.8). */
73
+ uploader?: string;
74
+ /** Names that must never be split (R7.3a). */
75
+ knownArtists?: string[];
76
+ splitAnd?: "auto" | "always" | "never";
77
+ keywords?: KeywordOptions;
78
+ }
79
+ interface FormatOptions {
80
+ feat?: "source" | "artist" | "title" | "omit";
81
+ featMarker?: string;
82
+ joiners?: "original" | "canonical";
83
+ versions?: "all" | "none";
84
+ producers?: boolean;
85
+ position?: boolean;
86
+ }
87
+
88
+ declare function format(track: ParsedTrack, options?: FormatOptions): string;
89
+ /** All credited names: track artists plus every version's remixers, deduped by R0.4 key. */
90
+ declare function allArtists(track: ParsedTrack): Artist[];
91
+
92
+ /** R1: normalize a track string. Idempotent; never throws on string input. */
93
+ declare function normalize(input: string): string;
94
+
95
+ interface Parser {
96
+ parse(input: string, options?: ParseOptions): ParsedTrack;
97
+ parseArtists(input: string, options?: ParseOptions): Artist[];
98
+ }
99
+ /** A parser with `options.keywords` compiled once. Per-call options are merged over `base`. */
100
+ declare function createParser(base?: ParseOptions): Parser;
101
+ declare function parse(input: string, options?: ParseOptions): ParsedTrack;
102
+ declare function parseArtists(input: string, options?: ParseOptions): Artist[];
103
+
104
+ export { type Artist, type ArtistRole, type ArtistSource, type Flags, type FormatOptions, type Junk, type JunkKind, type KeywordOptions, type Mode, type ModeOption, type ParseOptions, type ParsedTrack, type Parser, type Position, SPEC_VERSION, type Timestamp, type Version, type VersionDelimiter, type VersionType, type Warning, allArtists, createParser, format, normalize, parse, parseArtists };