transform-render.ts — ui Source File
Architecture documentation for transform-render.ts, a typescript file in the ui codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 53d6baa6_7fd1_a1aa_6718_e4a746737a82["transform-render.ts"] e69863ed_3e2f_ef94_648a_ef0155c386ef["transformers"] 53d6baa6_7fd1_a1aa_6718_e4a746737a82 --> e69863ed_3e2f_ef94_648a_ef0155c386ef 4f6f7e78_23ff_4f5f_c723_474454f64c85["ts-morph"] 53d6baa6_7fd1_a1aa_6718_e4a746737a82 --> 4f6f7e78_23ff_4f5f_c723_474454f64c85 style 53d6baa6_7fd1_a1aa_6718_e4a746737a82 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { Transformer } from "@/src/utils/transformers"
import { SyntaxKind } from "ts-morph"
interface TransformInfo {
elementStart: number
elementEnd: number
newText: string
}
export const transformRender: Transformer = async ({ sourceFile, config }) => {
// Only run for base- styles.
if (!config.style?.startsWith("base-")) {
return sourceFile
}
// Collect all transformations first, then apply them in reverse order.
// This prevents issues with invalidated nodes when modifying the tree.
const transformations: TransformInfo[] = []
// Find all JSX elements with render attribute.
const jsxElements = sourceFile.getDescendantsOfKind(SyntaxKind.JsxElement)
for (const jsxElement of jsxElements) {
const openingElement = jsxElement.getOpeningElement()
const renderAttr = openingElement.getAttribute("render")
if (!renderAttr) {
continue
}
// Get the children of the parent element.
const children = jsxElement.getJsxChildren()
const childrenText = children
.map((c) => c.getText())
.join("")
.trim()
// If there are no children, nothing to transform.
if (!childrenText) {
continue
}
// Get the render attribute value.
if (renderAttr.getKind() !== SyntaxKind.JsxAttribute) {
continue
}
const jsxAttr = renderAttr.asKindOrThrow(SyntaxKind.JsxAttribute)
const initializer = jsxAttr.getInitializer()
if (!initializer) {
continue
}
// The render value should be a JSX expression like {<Button />}.
if (initializer.getKind() !== SyntaxKind.JsxExpression) {
continue
}
const jsxExpression = initializer.asKindOrThrow(SyntaxKind.JsxExpression)
// ... (70 more lines)
Domain
Subdomains
Functions
Types
Dependencies
- transformers
- ts-morph
Source
Frequently Asked Questions
What does transform-render.ts do?
transform-render.ts is a source file in the ui codebase, written in typescript. It belongs to the FrameworkTooling domain, CLICore subdomain.
What functions are defined in transform-render.ts?
transform-render.ts defines 1 function(s): transformRender.
What does transform-render.ts depend on?
transform-render.ts imports 2 module(s): transformers, ts-morph.
Where is transform-render.ts in the architecture?
transform-render.ts is located at packages/shadcn/src/utils/transformers/transform-render.ts (domain: FrameworkTooling, subdomain: CLICore, directory: packages/shadcn/src/utils/transformers).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free