lrc-kit
Version:
lrc parser, maker, runner
61 lines (60 loc) • 1.86 kB
TypeScript
import type { ParseOptions } from './lrc';
export declare const SQUARE_TAGS_REGEXP: RegExp;
export declare const INFO_REGEXP: RegExp;
export declare const TIME_REGEXP: RegExp;
export declare const ENHANCED_TAG_WORD_REGEXP: RegExp;
export declare enum LineType {
INVALID = "INVALID",
INFO = "INFO",
TIME = "TIME"
}
export interface InvalidLine {
type: LineType.INVALID;
}
interface TimeWordTimestamp {
timestamp: number;
content: string;
}
export interface TimeLine {
type: LineType.TIME;
timestamps: number[];
wordTimestamps?: TimeWordTimestamp[];
rawContent: string;
content: string;
}
export interface InfoLine {
type: LineType.INFO;
key: string;
value: string;
}
export declare function parseSquareTags(line: string): null | {
tags: string[];
rawContent: string;
};
export declare function parseEnhancedWords(timestamps: number[], rawContent: string): TimeLine | null;
export declare function parseTime(tags: string[], rawContent: string, { enhanced }?: ParseOptions): TimeLine;
export declare function parseInfo(tag: string): InfoLine | null;
/**
* line parse lrc of timestamp
* @example
* const lp = parseLine('[ti: Song title]')
* lp.type === LineParser.TYPE.INFO
* lp.key === 'ti'
* lp.value === 'Song title'
*
* const lp = parseLine('[10:10.10]hello')
* lp.type === LineParser.TYPE.TIME
* lp.timestamps === [10*60+10.10]
* lp.content === 'hello'
*
* const lp = parseLine('[10:10.10] <10:10.12> hello <10:11.02> world')
* lp.type === LineParser.TYPE.TIME
* lp.timestamps === [10*60+10.10]
* lp.content === 'hello world'
* lp.wordTimestamps === [
* { timestamp: 10*60+10.12, content: 'hello' },
* { timestamp: 10*60+11.02, content: 'world' }
* ]
*/
export declare function parseLine(line: string, options?: ParseOptions): InfoLine | TimeLine | InvalidLine;
export {};