( themeName: string )
| 594 | } |
| 595 | |
| 596 | async function localTheme( |
| 597 | themeName: string |
| 598 | ): Promise<Theme<ThemeOptions>> | never { |
| 599 | const extensions = ['.ts', '.js', '.mjs', '.cjs'] |
| 600 | const paths = HAS_EXTENSION_RE.test(themeName) |
| 601 | ? [resolve(process.cwd(), themeName)] |
| 602 | : extensions.map((ext) => resolve(process.cwd(), themeName + ext)) |
| 603 | const path = getPath(paths) |
| 604 | if (!path) error(`Could not find ${themeName}.`) |
| 605 | |
| 606 | const jiti = createJiti(import.meta.url, { interopDefault: true }) |
| 607 | const theme = (await jiti.import(path, {})) as |
| 608 | | Theme<ThemeOptions> |
| 609 | | { default?: Theme<ThemeOptions> } |
| 610 | const themeFunction = typeof theme === 'function' ? theme : theme.default |
| 611 | if (!themeFunction) error('Invalid theme file.') |
| 612 | return themeFunction |
| 613 | } |
| 614 | |
| 615 | export function extractThemeData( |
| 616 | theme: string |
no test coverage detected