@mcut/timeline
Project lifecycle
Project creation, parsing, and migration.
Constants
PROJECT_VERSION
const PROJECT_VERSION = 1The format version written into new and serialized projects.
Functions
migrateProject
function migrateProject(data: unknown): unknownUpgrades a persisted project document to PROJECT_VERSION, treating documents without a version as version 1, and throws ProjectFormatError for invalid or newer documents.
createProject
function createProject(options: CreateProjectOptions = {}): ProjectReturns a new project with the given or default id, name, 1920 by 1080 size, and 30 fps, holding one empty track with the id t-default.
parseProject
function parseProject(data: unknown): ProjectMigrates an untrusted project document to the current format and validates it, throwing ProjectFormatError for documents from a newer version.
Classes
ProjectFormatError
class ProjectFormatError extends Error {
readonly code: 'newer-version' | 'missing-migration' | 'invalid-document'
constructor(code: ProjectFormatError['code'], message: string)
}Error thrown for project documents that are not objects, come from a newer version, or lack a migration, with a matching code.