/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
packages-internal/docs-utils/src/index.ts
55 строк
2 KB
Eng Zer Jun
[core] Replace more `indexOf` with `includes` (#43694)
12 сен 2024, 15:15
Не верифицирован
12 сен 2024, 15:15
092e100
Код
Авторство
О чём код?
import { EOL } from 'os'; export * from './createTypeScriptProject'; export { type ComponentClassDefinition } from './ComponentClassDefinition'; export * from './getPropsFromComponentNode'; export function getLineFeed(source: string): string { const match = source.match(/\r?\n/); return match === null ? EOL : match[0]; } const fixBabelIssuesRegExp = /(?<=(\/>)|,)(\r?\n){2}/g; export function fixBabelGeneratorIssues(source: string): string { return source.replace(fixBabelIssuesRegExp, '\n'); } export function fixLineEndings(source: string, target: string): string { return target.replace(/\r?\n/g, getLineFeed(source)); } /** * Converts styled or regular component d.ts file to unstyled d.ts * @param filename - the file of the styled or regular mui component */ export function getUnstyledFilename(filename: string, definitionFile: boolean = false): string { if (filename.includes('mui-base')) { return filename; } let unstyledFile = ''; const separator = filename.includes('/') ? '/' : '\\'; if (!filename.includes('mui-base')) { unstyledFile = filename .replace(/.d.ts$/, '') .replace(/.tsx?$/, '') .replace(/.js$/, ''); unstyledFile = unstyledFile.replace(/Styled/g, ''); if (separator === '/') { unstyledFile = unstyledFile.replace( /packages\/mui-lab|packages\/mui-material/g, 'packages/mui-base', ); } else { unstyledFile = unstyledFile.replace( /packages\\mui-lab|packages\\mui-material/g, 'packages\\mui-base', ); } } return definitionFile ? `${unstyledFile}.d.ts` : `${unstyledFile}.js`; }