fetcher.ts — ui Source File
Architecture documentation for fetcher.ts, a typescript file in the ui codebase. 10 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 16316120_c278_1dd6_844b_6f1683d22437["fetcher.ts"] eac8f98f_e40a_7fe8_f505_372c83d20c7a["fs"] 16316120_c278_1dd6_844b_6f1683d22437 --> eac8f98f_e40a_7fe8_f505_372c83d20c7a b80715bf_43eb_b495_f2cf_a439c5eb0e34["os"] 16316120_c278_1dd6_844b_6f1683d22437 --> b80715bf_43eb_b495_f2cf_a439c5eb0e34 d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5["path"] 16316120_c278_1dd6_844b_6f1683d22437 --> d05ec4ea_7a68_3a36_bfa4_9ba7f8409ee5 6cb39c88_2e7f_0418_0b3e_763f882f13ff["builder"] 16316120_c278_1dd6_844b_6f1683d22437 --> 6cb39c88_2e7f_0418_0b3e_763f882f13ff ff842930_3a95_1c03_7d51_b342f47a7971["context"] 16316120_c278_1dd6_844b_6f1683d22437 --> ff842930_3a95_1c03_7d51_b342f47a7971 0ec72e6a_72c2_0fcf_92e9_0b0612e46d40["errors"] 16316120_c278_1dd6_844b_6f1683d22437 --> 0ec72e6a_72c2_0fcf_92e9_0b0612e46d40 a3b2545e_3d8c_699d_ef11_6ab18db14666["schema"] 16316120_c278_1dd6_844b_6f1683d22437 --> a3b2545e_3d8c_699d_ef11_6ab18db14666 7f9b0cd8_8fc4_e135_ad46_ef3ee475e7e2["https-proxy-agent"] 16316120_c278_1dd6_844b_6f1683d22437 --> 7f9b0cd8_8fc4_e135_ad46_ef3ee475e7e2 1b8b3af0_8c29_615e_c85f_55467e0d6c9b["node-fetch"] 16316120_c278_1dd6_844b_6f1683d22437 --> 1b8b3af0_8c29_615e_c85f_55467e0d6c9b 6802ce19_522d_e5fb_e458_8826d9f6952e["zod"] 16316120_c278_1dd6_844b_6f1683d22437 --> 6802ce19_522d_e5fb_e458_8826d9f6952e c2fb9011_4efa_7368_983e_e7685977db7c["fetcher.test.ts"] c2fb9011_4efa_7368_983e_e7685977db7c --> 16316120_c278_1dd6_844b_6f1683d22437 style 16316120_c278_1dd6_844b_6f1683d22437 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { promises as fs } from "fs"
import { homedir } from "os"
import path from "path"
import { resolveRegistryUrl } from "@/src/registry/builder"
import { getRegistryHeadersFromContext } from "@/src/registry/context"
import {
RegistryFetchError,
RegistryForbiddenError,
RegistryLocalFileError,
RegistryNotFoundError,
RegistryParseError,
RegistryUnauthorizedError,
} from "@/src/registry/errors"
import { registryItemSchema } from "@/src/schema"
import { HttpsProxyAgent } from "https-proxy-agent"
import fetch from "node-fetch"
import { z } from "zod"
const agent = process.env.https_proxy
? new HttpsProxyAgent(process.env.https_proxy)
: undefined
const registryCache = new Map<string, Promise<any>>()
export function clearRegistryCache() {
registryCache.clear()
}
export async function fetchRegistry(
paths: string[],
options: { useCache?: boolean } = {}
) {
options = {
useCache: true,
...options,
}
try {
const results = await Promise.all(
paths.map(async (path) => {
const url = resolveRegistryUrl(path)
// Check cache first if caching is enabled
if (options.useCache && registryCache.has(url)) {
return registryCache.get(url)
}
// Store the promise in the cache before awaiting if caching is enabled.
const fetchPromise = (async () => {
// Get headers from context for this URL.
const headers = getRegistryHeadersFromContext(url)
const response = await fetch(url, {
agent,
headers: {
...headers,
},
})
if (!response.ok) {
// ... (97 more lines)
Domain
Subdomains
Dependencies
- builder
- context
- errors
- fs
- https-proxy-agent
- node-fetch
- os
- path
- schema
- zod
Imported By
Source
Frequently Asked Questions
What does fetcher.ts do?
fetcher.ts is a source file in the ui codebase, written in typescript. It belongs to the FrameworkTooling domain, SchemaValidation subdomain.
What functions are defined in fetcher.ts?
fetcher.ts defines 3 function(s): clearRegistryCache, fetchRegistry, fetchRegistryLocal.
What does fetcher.ts depend on?
fetcher.ts imports 10 module(s): builder, context, errors, fs, https-proxy-agent, node-fetch, os, path, and 2 more.
What files import fetcher.ts?
fetcher.ts is imported by 1 file(s): fetcher.test.ts.
Where is fetcher.ts in the architecture?
fetcher.ts is located at packages/shadcn/src/registry/fetcher.ts (domain: FrameworkTooling, subdomain: SchemaValidation, directory: packages/shadcn/src/registry).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free