(mimeType: string, loadingMessage = 'Loading...')
| 105 | |
| 106 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 107 | export function getTransform(mimeType: string, loadingMessage = 'Loading...'): LoadableComponent<{ data: any }> { |
| 108 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 109 | return Loadable<{ data: any }>( |
| 110 | async () => { |
| 111 | const match = mimeTypeToImport.find((m) => m.mimeType === mimeType); |
| 112 | if (match) { |
| 113 | const transform = await match.getComponent(); |
| 114 | return transform; |
| 115 | } |
| 116 | |
| 117 | return () => <div>Transform not found for mimetype {mimeType}</div>; |
| 118 | }, |
| 119 | { fallback: <div>{loadingMessage}</div> } |
| 120 | ); |
| 121 | } |
| 122 | |
| 123 | export async function forceLoad() { |
| 124 | // Used for tests to make sure we don't end up with 'Loading ...' anywhere in a test |
no test coverage detected