import { isFontFile } from './font'; import { celFilesOf } from './pixelart'; import type { Project } from './Project'; import { isTextureFile } from './texture'; /** The stored files a project draws with, per library – what is loaded before anything asks. */ export interface ProjectFiles { textures: string[]; fonts: string[]; cels: string[]; } /** * Every file an asset names, used or not: which frame an animation or a tile reaches next is only * known while it plays, and a file fetched then shows as a gap. A name that is no stored file – * an upload that failed – is left out, as the libraries would never get it anyway. */ export function projectFiles(project: Project): ProjectFiles { const files: ProjectFiles = { textures: [], fonts: [], cels: [] }; for (const asset of project.assets) { if (asset.type === 'texture' && isTextureFile(asset.file)) files.textures.push(asset.file); else if (asset.type === 'font' && isFontFile(asset.file)) files.fonts.push(asset.file); else if (asset.type === 'pixelart') files.cels.push(...celFilesOf(asset)); } return files; }