trackparse 0.2.0 → 0.3.1
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 +87 -5
- package/dist/chunk-3TS4DITR.js +2314 -0
- package/dist/index.cjs +73 -6
- package/dist/index.d.cts +4 -86
- package/dist/index.d.ts +4 -86
- package/dist/index.js +3 -2189
- package/dist/tracklist.cjs +3135 -0
- package/dist/tracklist.d.cts +114 -0
- package/dist/tracklist.d.ts +114 -0
- package/dist/tracklist.js +827 -0
- package/dist/types-DqJSn18b.d.cts +87 -0
- package/dist/types-DqJSn18b.d.ts +87 -0
- package/package.json +15 -4
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { P as ParsedTrack, f as ModeOption, K as KeywordOptions } from './types-DqJSn18b.cjs';
|
|
2
|
+
|
|
3
|
+
/** Public tracklist types. They mirror spec/schema/tracklist.schema.json and options.schema.json. */
|
|
4
|
+
|
|
5
|
+
type EntryKind = "track" | "marker" | "header" | "link" | "note" | "blank";
|
|
6
|
+
type Eol = "\n" | "\r\n" | "\r" | "";
|
|
7
|
+
/** R13.1.3: `lead + time + gap + rest === raw`. */
|
|
8
|
+
interface EntryParts {
|
|
9
|
+
lead: string;
|
|
10
|
+
time: string;
|
|
11
|
+
gap: string;
|
|
12
|
+
rest: string;
|
|
13
|
+
}
|
|
14
|
+
/** R13.2.5: `raw` without brackets; `seconds` may carry a fraction. */
|
|
15
|
+
interface TracklistTime {
|
|
16
|
+
raw: string;
|
|
17
|
+
seconds: number;
|
|
18
|
+
}
|
|
19
|
+
interface TracklistEntry {
|
|
20
|
+
/** 1-based line number. */
|
|
21
|
+
line: number;
|
|
22
|
+
kind: EntryKind;
|
|
23
|
+
eol: Eol;
|
|
24
|
+
raw: string;
|
|
25
|
+
parts: EntryParts;
|
|
26
|
+
time: TracklistTime | null;
|
|
27
|
+
track: ParsedTrack | null;
|
|
28
|
+
}
|
|
29
|
+
type TracklistWarningCode = "time-missing" | "time-out-of-order" | "time-duplicate" | "no-start-at-zero" | "time-after-audio-end" | "invalid-time" | "position-gap" | "position-duplicate" | "line-unparsed";
|
|
30
|
+
interface TracklistWarning {
|
|
31
|
+
code: TracklistWarningCode;
|
|
32
|
+
line: number;
|
|
33
|
+
severity: "info" | "warning";
|
|
34
|
+
suggestion: TimeSuggestion | null;
|
|
35
|
+
}
|
|
36
|
+
/** R13.7: a one- or two-digit fix for `time-out-of-order`; `line` is the line to change. */
|
|
37
|
+
interface TimeSuggestion {
|
|
38
|
+
line: number;
|
|
39
|
+
raw: string;
|
|
40
|
+
seconds: number;
|
|
41
|
+
}
|
|
42
|
+
interface TracklistStats {
|
|
43
|
+
lines: number;
|
|
44
|
+
tracks: number;
|
|
45
|
+
markers: number;
|
|
46
|
+
timed: number;
|
|
47
|
+
firstTime: number | null;
|
|
48
|
+
lastTime: number | null;
|
|
49
|
+
}
|
|
50
|
+
interface Tracklist {
|
|
51
|
+
specVersion: string;
|
|
52
|
+
entries: TracklistEntry[];
|
|
53
|
+
warnings: TracklistWarning[];
|
|
54
|
+
stats: TracklistStats;
|
|
55
|
+
}
|
|
56
|
+
/** R13.10 */
|
|
57
|
+
interface TracklistOptions {
|
|
58
|
+
/** Per-line parse mode; default `"tracklist"`. */
|
|
59
|
+
mode?: ModeOption;
|
|
60
|
+
knownArtists?: string[];
|
|
61
|
+
splitAnd?: "auto" | "always" | "never";
|
|
62
|
+
keywords?: KeywordOptions;
|
|
63
|
+
/** Length of the audio in seconds; enables `time-after-audio-end`. */
|
|
64
|
+
audioSeconds?: number;
|
|
65
|
+
/** Extra R13.3 marker words. */
|
|
66
|
+
markerWords?: string[];
|
|
67
|
+
}
|
|
68
|
+
/** R13.9 */
|
|
69
|
+
type Edit = {
|
|
70
|
+
op: "set-time";
|
|
71
|
+
line: number;
|
|
72
|
+
seconds: number;
|
|
73
|
+
} | {
|
|
74
|
+
op: "shift";
|
|
75
|
+
seconds: number;
|
|
76
|
+
lines?: number[];
|
|
77
|
+
from?: number;
|
|
78
|
+
} | {
|
|
79
|
+
op: "sort-by-time";
|
|
80
|
+
} | {
|
|
81
|
+
op: "set-rest";
|
|
82
|
+
line: number;
|
|
83
|
+
rest: string;
|
|
84
|
+
} | {
|
|
85
|
+
op: "insert";
|
|
86
|
+
after: number;
|
|
87
|
+
text: string;
|
|
88
|
+
} | {
|
|
89
|
+
op: "delete";
|
|
90
|
+
line: number;
|
|
91
|
+
};
|
|
92
|
+
type EditWarningCode = "edit-invalid" | "time-clamped" | "style-upgraded";
|
|
93
|
+
interface EditWarning {
|
|
94
|
+
code: EditWarningCode;
|
|
95
|
+
/** Index of the edit in the `edits` array. */
|
|
96
|
+
edit: number;
|
|
97
|
+
line: number | null;
|
|
98
|
+
}
|
|
99
|
+
interface EditResult {
|
|
100
|
+
text: string;
|
|
101
|
+
/** Line numbers (in the final text) of lines an edit wrote; sorted, unique. */
|
|
102
|
+
changed: number[];
|
|
103
|
+
warnings: EditWarning[];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* R13.9: apply `edits` to `text`. Never throws (R13.9.6): an invalid edit changes nothing and
|
|
108
|
+
* warns `edit-invalid`.
|
|
109
|
+
*/
|
|
110
|
+
declare function applyEdits(text: string, edits: readonly Edit[], options?: TracklistOptions): EditResult;
|
|
111
|
+
|
|
112
|
+
declare function parseTracklist(text: string, options?: TracklistOptions): Tracklist;
|
|
113
|
+
|
|
114
|
+
export { type Edit, type EditResult, type EditWarning, type EditWarningCode, type EntryKind, type EntryParts, type Eol, type TimeSuggestion, type Tracklist, type TracklistEntry, type TracklistOptions, type TracklistStats, type TracklistTime, type TracklistWarning, type TracklistWarningCode, applyEdits, parseTracklist };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { P as ParsedTrack, f as ModeOption, K as KeywordOptions } from './types-DqJSn18b.js';
|
|
2
|
+
|
|
3
|
+
/** Public tracklist types. They mirror spec/schema/tracklist.schema.json and options.schema.json. */
|
|
4
|
+
|
|
5
|
+
type EntryKind = "track" | "marker" | "header" | "link" | "note" | "blank";
|
|
6
|
+
type Eol = "\n" | "\r\n" | "\r" | "";
|
|
7
|
+
/** R13.1.3: `lead + time + gap + rest === raw`. */
|
|
8
|
+
interface EntryParts {
|
|
9
|
+
lead: string;
|
|
10
|
+
time: string;
|
|
11
|
+
gap: string;
|
|
12
|
+
rest: string;
|
|
13
|
+
}
|
|
14
|
+
/** R13.2.5: `raw` without brackets; `seconds` may carry a fraction. */
|
|
15
|
+
interface TracklistTime {
|
|
16
|
+
raw: string;
|
|
17
|
+
seconds: number;
|
|
18
|
+
}
|
|
19
|
+
interface TracklistEntry {
|
|
20
|
+
/** 1-based line number. */
|
|
21
|
+
line: number;
|
|
22
|
+
kind: EntryKind;
|
|
23
|
+
eol: Eol;
|
|
24
|
+
raw: string;
|
|
25
|
+
parts: EntryParts;
|
|
26
|
+
time: TracklistTime | null;
|
|
27
|
+
track: ParsedTrack | null;
|
|
28
|
+
}
|
|
29
|
+
type TracklistWarningCode = "time-missing" | "time-out-of-order" | "time-duplicate" | "no-start-at-zero" | "time-after-audio-end" | "invalid-time" | "position-gap" | "position-duplicate" | "line-unparsed";
|
|
30
|
+
interface TracklistWarning {
|
|
31
|
+
code: TracklistWarningCode;
|
|
32
|
+
line: number;
|
|
33
|
+
severity: "info" | "warning";
|
|
34
|
+
suggestion: TimeSuggestion | null;
|
|
35
|
+
}
|
|
36
|
+
/** R13.7: a one- or two-digit fix for `time-out-of-order`; `line` is the line to change. */
|
|
37
|
+
interface TimeSuggestion {
|
|
38
|
+
line: number;
|
|
39
|
+
raw: string;
|
|
40
|
+
seconds: number;
|
|
41
|
+
}
|
|
42
|
+
interface TracklistStats {
|
|
43
|
+
lines: number;
|
|
44
|
+
tracks: number;
|
|
45
|
+
markers: number;
|
|
46
|
+
timed: number;
|
|
47
|
+
firstTime: number | null;
|
|
48
|
+
lastTime: number | null;
|
|
49
|
+
}
|
|
50
|
+
interface Tracklist {
|
|
51
|
+
specVersion: string;
|
|
52
|
+
entries: TracklistEntry[];
|
|
53
|
+
warnings: TracklistWarning[];
|
|
54
|
+
stats: TracklistStats;
|
|
55
|
+
}
|
|
56
|
+
/** R13.10 */
|
|
57
|
+
interface TracklistOptions {
|
|
58
|
+
/** Per-line parse mode; default `"tracklist"`. */
|
|
59
|
+
mode?: ModeOption;
|
|
60
|
+
knownArtists?: string[];
|
|
61
|
+
splitAnd?: "auto" | "always" | "never";
|
|
62
|
+
keywords?: KeywordOptions;
|
|
63
|
+
/** Length of the audio in seconds; enables `time-after-audio-end`. */
|
|
64
|
+
audioSeconds?: number;
|
|
65
|
+
/** Extra R13.3 marker words. */
|
|
66
|
+
markerWords?: string[];
|
|
67
|
+
}
|
|
68
|
+
/** R13.9 */
|
|
69
|
+
type Edit = {
|
|
70
|
+
op: "set-time";
|
|
71
|
+
line: number;
|
|
72
|
+
seconds: number;
|
|
73
|
+
} | {
|
|
74
|
+
op: "shift";
|
|
75
|
+
seconds: number;
|
|
76
|
+
lines?: number[];
|
|
77
|
+
from?: number;
|
|
78
|
+
} | {
|
|
79
|
+
op: "sort-by-time";
|
|
80
|
+
} | {
|
|
81
|
+
op: "set-rest";
|
|
82
|
+
line: number;
|
|
83
|
+
rest: string;
|
|
84
|
+
} | {
|
|
85
|
+
op: "insert";
|
|
86
|
+
after: number;
|
|
87
|
+
text: string;
|
|
88
|
+
} | {
|
|
89
|
+
op: "delete";
|
|
90
|
+
line: number;
|
|
91
|
+
};
|
|
92
|
+
type EditWarningCode = "edit-invalid" | "time-clamped" | "style-upgraded";
|
|
93
|
+
interface EditWarning {
|
|
94
|
+
code: EditWarningCode;
|
|
95
|
+
/** Index of the edit in the `edits` array. */
|
|
96
|
+
edit: number;
|
|
97
|
+
line: number | null;
|
|
98
|
+
}
|
|
99
|
+
interface EditResult {
|
|
100
|
+
text: string;
|
|
101
|
+
/** Line numbers (in the final text) of lines an edit wrote; sorted, unique. */
|
|
102
|
+
changed: number[];
|
|
103
|
+
warnings: EditWarning[];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* R13.9: apply `edits` to `text`. Never throws (R13.9.6): an invalid edit changes nothing and
|
|
108
|
+
* warns `edit-invalid`.
|
|
109
|
+
*/
|
|
110
|
+
declare function applyEdits(text: string, edits: readonly Edit[], options?: TracklistOptions): EditResult;
|
|
111
|
+
|
|
112
|
+
declare function parseTracklist(text: string, options?: TracklistOptions): Tracklist;
|
|
113
|
+
|
|
114
|
+
export { type Edit, type EditResult, type EditWarning, type EditWarningCode, type EntryKind, type EntryParts, type Eol, type TimeSuggestion, type Tracklist, type TracklistEntry, type TracklistOptions, type TracklistStats, type TracklistTime, type TracklistWarning, type TracklistWarningCode, applyEdits, parseTracklist };
|