(ctx: ImageResolveContext)
| 116 | export const imageMappingCsvStrategy: ImageSourceStrategy = { |
| 117 | id: 'image-mapping-csv', |
| 118 | async resolve(ctx: ImageResolveContext) { |
| 119 | if (!ctx.fetchText) { |
| 120 | return null; |
| 121 | } |
| 122 | // Prefer a mapping CSV in the model directory; fall back to any in the tree. |
| 123 | const candidates = ctx.filePaths.filter( |
| 124 | (path) => getBasename(path).toLowerCase() === IMAGE_MAPPING_CSV_FILENAME |
| 125 | ); |
| 126 | const csvPath = |
| 127 | candidates.find((path) => getParentDir(path) === ctx.modelDir) ?? candidates[0]; |
| 128 | if (!csvPath) { |
| 129 | return null; |
| 130 | } |
| 131 | |
| 132 | const text = await ctx.fetchText(csvPath); |
| 133 | if (!text) { |
| 134 | return null; |
| 135 | } |
| 136 | const imageNameToPath = parseImageMappingCsv(text); |
| 137 | return Object.keys(imageNameToPath).length > 0 |
| 138 | ? { kind: 'per-image', imageNameToPath } |
| 139 | : null; |
| 140 | }, |
| 141 | }; |
nothing calls this directly
no test coverage detected