block-display.tsx — ui Source File
Architecture documentation for block-display.tsx, a tsx file in the ui codebase. 9 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 336888d9_0bee_4622_33dc_3b5f87613c80["block-display.tsx"] 1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"] 336888d9_0bee_4622_33dc_3b5f87613c80 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2 ceec689a_1334_a657_3c35_094070222b09["schema"] 336888d9_0bee_4622_33dc_3b5f87613c80 --> ceec689a_1334_a657_3c35_094070222b09 6802ce19_522d_e5fb_e458_8826d9f6952e["zod"] 336888d9_0bee_4622_33dc_3b5f87613c80 --> 6802ce19_522d_e5fb_e458_8826d9f6952e 7edb604f_23f1_911f_0682_b46c871a68d6["highlight-code"] 336888d9_0bee_4622_33dc_3b5f87613c80 --> 7edb604f_23f1_911f_0682_b46c871a68d6 7a25f51b_551e_131b_bc51_bd5ccc7c308c["registry"] 336888d9_0bee_4622_33dc_3b5f87613c80 --> 7a25f51b_551e_131b_bc51_bd5ccc7c308c 79081a1f_55a3_945a_fb8c_d53d6d3eab81["utils"] 336888d9_0bee_4622_33dc_3b5f87613c80 --> 79081a1f_55a3_945a_fb8c_d53d6d3eab81 03061ea5_31a1_22d5_3c3e_f114f58f5e50["block-viewer"] 336888d9_0bee_4622_33dc_3b5f87613c80 --> 03061ea5_31a1_22d5_3c3e_f114f58f5e50 7478bc40_c1f7_407b_1a68_526885831907["component-preview"] 336888d9_0bee_4622_33dc_3b5f87613c80 --> 7478bc40_c1f7_407b_1a68_526885831907 b5745d66_2f51_7fb8_758d_e409c7f36c09["_legacy-styles"] 336888d9_0bee_4622_33dc_3b5f87613c80 --> b5745d66_2f51_7fb8_758d_e409c7f36c09 style 336888d9_0bee_4622_33dc_3b5f87613c80 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import * as React from "react"
import { type registryItemFileSchema } from "shadcn/schema"
import { type z } from "zod"
import { highlightCode } from "@/lib/highlight-code"
import {
createFileTreeForRegistryItemFiles,
getRegistryItem,
} from "@/lib/registry"
import { cn } from "@/lib/utils"
import { BlockViewer } from "@/components/block-viewer"
import { ComponentPreview } from "@/components/component-preview"
import { type Style } from "@/registry/_legacy-styles"
export async function BlockDisplay({
name,
styleName,
}: {
name: string
styleName: Style["name"]
}) {
const item = await getCachedRegistryItem(name, styleName)
if (!item?.files) {
return null
}
const [tree, highlightedFiles] = await Promise.all([
getCachedFileTree(item.files),
getCachedHighlightedFiles(item.files),
])
return (
<BlockViewer
item={item}
tree={tree}
highlightedFiles={highlightedFiles}
styleName={styleName}
>
<ComponentPreview
name={item.name}
styleName={styleName}
hideCode
className={cn(
"my-0 **:[.preview]:h-auto **:[.preview]:p-4 **:[.preview>.p-6]:p-0",
item.meta?.containerClassName
)}
/>
</BlockViewer>
)
}
const getCachedRegistryItem = React.cache(
async (name: string, styleName: Style["name"]) => {
return await getRegistryItem(name, styleName)
}
)
const getCachedFileTree = React.cache(
async (files: Array<{ path: string; target?: string }>) => {
if (!files) {
return null
}
return await createFileTreeForRegistryItemFiles(files)
}
)
const getCachedHighlightedFiles = React.cache(
async (files: z.infer<typeof registryItemFileSchema>[]) => {
return await Promise.all(
files.map(async (file) => ({
...file,
highlightedContent: await highlightCode(file.content ?? ""),
}))
)
}
)
Domain
Subdomains
Dependencies
- _legacy-styles
- block-viewer
- component-preview
- highlight-code
- react
- registry
- schema
- utils
- zod
Source
Frequently Asked Questions
What does block-display.tsx do?
block-display.tsx is a source file in the ui codebase, written in tsx. It belongs to the Internationalization domain, RTLLayout subdomain.
What functions are defined in block-display.tsx?
block-display.tsx defines 4 function(s): BlockDisplay, getCachedFileTree, getCachedHighlightedFiles, getCachedRegistryItem.
What does block-display.tsx depend on?
block-display.tsx imports 9 module(s): _legacy-styles, block-viewer, component-preview, highlight-code, react, registry, schema, utils, and 1 more.
Where is block-display.tsx in the architecture?
block-display.tsx is located at apps/v4/components/block-display.tsx (domain: Internationalization, subdomain: RTLLayout, directory: apps/v4/components).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free