Home / File/ registry.ts — ui Source File

registry.ts — ui Source File

Architecture documentation for registry.ts, a typescript file in the ui codebase. 9 imports, 0 dependents.

File typescript DocumentationAtlas SearchAPI 9 imports 12 functions

Entity Profile

Dependency Diagram

graph LR
  a2cd9f1d_8dbe_d488_4209_1dbd8f522cc1["registry.ts"]
  eac8f98f_e40a_7fe8_f505_372c83d20c7a["fs"]
  a2cd9f1d_8dbe_d488_4209_1dbd8f522cc1 --> eac8f98f_e40a_7fe8_f505_372c83d20c7a
  d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5["path"]
  a2cd9f1d_8dbe_d488_4209_1dbd8f522cc1 --> d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5
  7c0ef5ae_77fa_2db5_3105_1433ebd1e241["__index__"]
  a2cd9f1d_8dbe_d488_4209_1dbd8f522cc1 --> 7c0ef5ae_77fa_2db5_3105_1433ebd1e241
  e75b0e1f_129c_d7e6_5b85_ee0ca841109b["lru-cache"]
  a2cd9f1d_8dbe_d488_4209_1dbd8f522cc1 --> e75b0e1f_129c_d7e6_5b85_ee0ca841109b
  ceec689a_1334_a657_3c35_094070222b09["schema"]
  a2cd9f1d_8dbe_d488_4209_1dbd8f522cc1 --> ceec689a_1334_a657_3c35_094070222b09
  6802ce19_522d_e5fb_e458_8826d9f6952e["zod"]
  a2cd9f1d_8dbe_d488_4209_1dbd8f522cc1 --> 6802ce19_522d_e5fb_e458_8826d9f6952e
  3760d05c_9abb_8921_1a30_9996e59e5714["__index__"]
  a2cd9f1d_8dbe_d488_4209_1dbd8f522cc1 --> 3760d05c_9abb_8921_1a30_9996e59e5714
  c544a3e1_3972_d827_a6cc_0c6a194dbe9e["bases"]
  a2cd9f1d_8dbe_d488_4209_1dbd8f522cc1 --> c544a3e1_3972_d827_a6cc_0c6a194dbe9e
  bfb9bc1d_9320_eaa1_c2b8_c6e4e825bbf7["__index__"]
  a2cd9f1d_8dbe_d488_4209_1dbd8f522cc1 --> bfb9bc1d_9320_eaa1_c2b8_c6e4e825bbf7
  style a2cd9f1d_8dbe_d488_4209_1dbd8f522cc1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { promises as fs } from "fs"
import path from "path"
import { ExamplesIndex } from "@/examples/__index__"
import { LRUCache } from "lru-cache"
import { registryItemSchema, type registryItemFileSchema } from "shadcn/schema"
import { type z } from "zod"

import { Index as StylesIndex } from "@/registry/__index__"
import { BASES } from "@/registry/bases"
import { Index as BasesIndex } from "@/registry/bases/__index__"

const INDEXED_STYLES = ["new-york-v4"]

// LRU cache for cross-request caching of registry items.
// File reads are I/O-bound, so caching improves dev server performance.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const registryCache = new LRUCache<string, any>({
  max: 500,
  ttl: 1000 * 60 * 5, // 5 minutes (shorter for dev to pick up changes).
})

function getBaseForStyle(styleName: string) {
  for (const base of BASES) {
    if (styleName.startsWith(`${base.name}-`)) {
      return base.name
    }
  }
  return null
}

export function getDemoComponent(name: string, styleName: string) {
  const base = getBaseForStyle(styleName)
  if (!base) return undefined
  return ExamplesIndex[base]?.[name]?.component
}

export async function getDemoItem(name: string, styleName: string) {
  const base = getBaseForStyle(styleName)
  if (!base) return null

  const demo = ExamplesIndex[base]?.[name]
  if (!demo) {
    return null
  }

  const filePath = path.join(process.cwd(), demo.filePath)
  const content = await fs.readFile(filePath, "utf-8")

  return {
    name: demo.name,
    type: "registry:internal" as const,
    files: [
      {
        path: demo.filePath,
        content,
        type: "registry:internal" as const,
      },
    ],
  }
}
// ... (243 more lines)

Subdomains

Types

Dependencies

  • __index__
  • __index__
  • __index__
  • bases
  • fs
  • lru-cache
  • path
  • schema
  • zod

Frequently Asked Questions

What does registry.ts do?
registry.ts is a source file in the ui codebase, written in typescript. It belongs to the DocumentationAtlas domain, SearchAPI subdomain.
What functions are defined in registry.ts?
registry.ts defines 12 function(s): createFileTreeForRegistryItemFiles, fixFilePaths, fixImport, getBaseForStyle, getDemoComponent, getDemoItem, getFileContent, getFileTarget, getIndexForStyle, getRegistryComponent, and 2 more.
What does registry.ts depend on?
registry.ts imports 9 module(s): __index__, __index__, __index__, bases, fs, lru-cache, path, schema, and 1 more.
Where is registry.ts in the architecture?
registry.ts is located at apps/v4/lib/registry.ts (domain: DocumentationAtlas, subdomain: SearchAPI, directory: apps/v4/lib).

Analyze Your Own Codebase

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

Try Supermodel Free