Home / Function/ scanIconUsage() — ui Function Reference

scanIconUsage() — ui Function Reference

Architecture documentation for the scanIconUsage() function in build-icons.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  f267d8c0_0773_483d_c74e_d6642e1de388["scanIconUsage()"]
  2f008c94_8a17_fd88_024f_322b76e3544a["build-icons.ts"]
  f267d8c0_0773_483d_c74e_d6642e1de388 -->|defined in| 2f008c94_8a17_fd88_024f_322b76e3544a
  8b6df75e_d1fe_5f84_8bf7_b16b4a70e076["main()"]
  8b6df75e_d1fe_5f84_8bf7_b16b4a70e076 -->|calls| f267d8c0_0773_483d_c74e_d6642e1de388
  8eab1f24_75ed_341b_22e0_3883570e446e["findTsxFiles()"]
  f267d8c0_0773_483d_c74e_d6642e1de388 -->|calls| 8eab1f24_75ed_341b_22e0_3883570e446e
  style f267d8c0_0773_483d_c74e_d6642e1de388 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/v4/scripts/build-icons.ts lines 24–59

function scanIconUsage() {
  const iconUsage: IconUsage = Object.keys(iconLibraries).reduce((acc, key) => {
    acc[key as IconLibraryName] = new Set()
    return acc
  }, {} as IconUsage)

  const registryBasesDir = path.join(process.cwd(), "registry/bases")
  const files = findTsxFiles(registryBasesDir)
  const libraryNames = Object.values(iconLibraries)
    .map((lib) => lib.name)
    .join("|")
  const iconPlaceholderRegex = new RegExp(
    `<IconPlaceholder\\s+([^>]*?)(?:${libraryNames})=["']([^"']+)["']([^>]*?)\\/?>`,
    "g"
  )

  for (const file of files) {
    const content = fs.readFileSync(file, "utf-8")

    let match
    while ((match = iconPlaceholderRegex.exec(content)) !== null) {
      const fullMatch = match[0]

      for (const [libraryName, config] of Object.entries(iconLibraries)) {
        const attrMatch = fullMatch.match(
          new RegExp(`${config.name}=["']([^"']+)["']`)
        )
        if (attrMatch) {
          iconUsage[libraryName as IconLibraryName].add(attrMatch[1])
        }
      }
    }
  }

  return iconUsage
}

Subdomains

Called By

Frequently Asked Questions

What does scanIconUsage() do?
scanIconUsage() is a function in the ui codebase, defined in apps/v4/scripts/build-icons.ts.
Where is scanIconUsage() defined?
scanIconUsage() is defined in apps/v4/scripts/build-icons.ts at line 24.
What does scanIconUsage() call?
scanIconUsage() calls 1 function(s): findTsxFiles.
What calls scanIconUsage()?
scanIconUsage() is called by 1 function(s): main.

Analyze Your Own Codebase

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

Try Supermodel Free