Home / File/ block-display.tsx — ui Source File

block-display.tsx — ui Source File

Architecture documentation for block-display.tsx, a tsx file in the ui codebase. 6 imports, 0 dependents.

File tsx ComponentRegistry UIPrimitives 6 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  794ed575_b54d_e225_c4f8_8572f3888b67["block-display.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  794ed575_b54d_e225_c4f8_8572f3888b67 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  ceec689a_1334_a657_3c35_094070222b09["schema"]
  794ed575_b54d_e225_c4f8_8572f3888b67 --> ceec689a_1334_a657_3c35_094070222b09
  6802ce19_522d_e5fb_e458_8826d9f6952e["zod"]
  794ed575_b54d_e225_c4f8_8572f3888b67 --> 6802ce19_522d_e5fb_e458_8826d9f6952e
  7edb604f_23f1_911f_0682_b46c871a68d6["highlight-code"]
  794ed575_b54d_e225_c4f8_8572f3888b67 --> 7edb604f_23f1_911f_0682_b46c871a68d6
  7a25f51b_551e_131b_bc51_bd5ccc7c308c["registry"]
  794ed575_b54d_e225_c4f8_8572f3888b67 --> 7a25f51b_551e_131b_bc51_bd5ccc7c308c
  03061ea5_31a1_22d5_3c3e_f114f58f5e50["block-viewer"]
  794ed575_b54d_e225_c4f8_8572f3888b67 --> 03061ea5_31a1_22d5_3c3e_f114f58f5e50
  style 794ed575_b54d_e225_c4f8_8572f3888b67 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as React from "react"
import { registryItemFileSchema } from "shadcn/schema"
import { z } from "zod"

import { highlightCode } from "@/lib/highlight-code"
import {
  createFileTreeForRegistryItemFiles,
  getRegistryItem,
} from "@/lib/registry"
import { BlockViewer } from "@/components/block-viewer"

export async function BlockDisplay({ name }: { name: string }) {
  const item = await getCachedRegistryItem(name)

  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} />
  )
}

const getCachedRegistryItem = React.cache(async (name: string) => {
  return await getRegistryItem(name)
})

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 ?? ""),
      }))
    )
  }
)

Subdomains

Dependencies

  • block-viewer
  • highlight-code
  • react
  • registry
  • schema
  • zod

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 ComponentRegistry domain, UIPrimitives 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 6 module(s): block-viewer, highlight-code, react, registry, schema, zod.
Where is block-display.tsx in the architecture?
block-display.tsx is located at deprecated/www/components/block-display.tsx (domain: ComponentRegistry, subdomain: UIPrimitives, directory: deprecated/www/components).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free