/
githubmirror
/
ui
Обзор
Документация
Войти
/
githubmirror
/
ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/shadcn/src/styles/transform.ts
35 строк
839 B
shadcn
chore: update deps (#9022)
12 дек 2025, 20:01
Не верифицирован
12 дек 2025, 20:01
86d9b00
Код
Авторство
О чём код?
import { Project, ScriptKind, type SourceFile } from "ts-morph" import { type StyleMap } from "./create-style-map" import { transformStyleMap } from "./transform-style-map" export type TransformerStyle<Output = SourceFile> = (opts: { sourceFile: SourceFile styleMap: StyleMap }) => Promise<Output> export async function transformStyle( source: string, { styleMap, transformers = [transformStyleMap], }: { styleMap: StyleMap transformers?: TransformerStyle<SourceFile>[] } ) { const project = new Project({ useInMemoryFileSystem: true, }) const sourceFile = project.createSourceFile("component.tsx", source, { scriptKind: ScriptKind.TSX, overwrite: true, }) for (const transformer of transformers) { await transformer({ sourceFile, styleMap }) } return sourceFile.getText() }