(file: File, isOnDisk = false)
| 61 | } |
| 62 | |
| 63 | export async function transformFile(file: File, isOnDisk = false): Promise<TransformedFile> { |
| 64 | const isOrigami = file.type === '' && file.name.endsWith('.origami') |
| 65 | const isPrinciple = file.type === '' && file.name.endsWith('.prd') |
| 66 | const isStitch = file.type === '' && file.name.endsWith('.stitch') |
| 67 | const isLottie = await fileIsLottie(file) |
| 68 | let type = file.type |
| 69 | |
| 70 | if (isOrigami) type = 'origami' |
| 71 | if (isPrinciple) type = 'principle' |
| 72 | if (isStitch) type = 'stitch' |
| 73 | if (isLottie) type = 'lottie' |
| 74 | |
| 75 | const raw = new File([file], file.name, { type }) |
| 76 | |
| 77 | const metadata = await generateFileMetadata(file, isOnDisk) |
| 78 | |
| 79 | return { |
| 80 | ...metadata, |
| 81 | optimistic_src: metadata.url, |
| 82 | id: uuid(), |
| 83 | raw, |
| 84 | type, |
| 85 | relative_url: null, |
| 86 | key: null, |
| 87 | preview_file_path: null, |
| 88 | error: null, |
| 89 | name: file.name, |
| 90 | size: file.size |
| 91 | } |
| 92 | } |
no test coverage detected