@ioris/core
Version:
This package provides the core functionality for the [@ioris](https://www.npmjs.com/search?q=%40ioris) ecosystem for managing music lyrics with time synchronization.
87 lines (86 loc) • 2.23 kB
TypeScript
/**
* Editing API - Split functions
* Split Word/Line into multiple parts
*/
import type { ValidationResult } from "../../schemas/result";
import type { Lyric } from "../../types";
/**
* Split Word by character position
*/
export type SplitWordByPositionOptions = {
type: "position";
/** Split position (character index, 0-based) */
charIndex: number;
};
/**
* Split Word by time
*/
export type SplitWordByTimeOptions = {
type: "time";
/** Split time (seconds) */
splitTime: number;
};
export type SplitWordOptions = SplitWordByPositionOptions | SplitWordByTimeOptions;
/**
* Split a Word into two
*
* @param lyric - Target Lyric
* @param wordID - ID of the Word to split
* @param options - Split options (position or time)
* @returns Lyric after splitting
*
* @example
* // "さくらさく" → "さくら" + "さく" (split by character position)
* const result = splitWord(lyric, "word-1", {
* type: "position",
* charIndex: 3
* });
*
* @example
* // Split by time
* const result = splitWord(lyric, "word-1", {
* type: "time",
* splitTime: 1.5
* });
*/
export declare function splitWord(lyric: Lyric, wordID: string, options: SplitWordOptions): ValidationResult<Lyric>;
/**
* Split Line by Word position
*/
export type SplitLineByWordOptions = {
type: "word";
/** Split position (ID of the first Word of the second Line) */
splitWordID: string;
};
/**
* Split Line by time
*/
export type SplitLineByTimeOptions = {
type: "time";
/** Split time (seconds) */
splitTime: number;
};
export type SplitLineOptions = SplitLineByWordOptions | SplitLineByTimeOptions;
/**
* Split a Line into two
*
* @param lyric - Target Lyric
* @param lineID - ID of the Line to split
* @param options - Split options (position or time)
* @returns Lyric after splitting
*
* @example
* // Split by Word ID
* const result = splitLine(lyric, "line-1", {
* type: "word",
* splitWordID: "word-3"
* });
*
* @example
* // Split by time
* const result = splitLine(lyric, "line-1", {
* type: "time",
* splitTime: 2.0
* });
*/
export declare function splitLine(lyric: Lyric, lineID: string, options: SplitLineOptions): ValidationResult<Lyric>;