MCPcopy
hub / github.com/intentui/intentui / fetchRegistryData

Function fetchRegistryData

src/components/code/editor-text.tsx:41–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39
40 useEffect(() => {
41 const fetchRegistryData = async () => {
42 const fetchedSourceCode: Record<string, string | null> = {}
43 await Promise.all(
44 Object.entries(source)
45 .filter(([key]) => key !== 'preview')
46
47 .map(async ([key, path]) => {
48 const registryKey = `${path}`
49 const registryItem = registry[registryKey]
50
51 if (registryItem) {
52 try {
53 const response = await fetch(`/registry/${registryKey}.json`)
54 if (response.ok) {
55 const registryEntry = await response.json()
56 fetchedSourceCode[key] =
57 registryEntry.files?.[0]?.content || 'No content available'
58 } else {
59 console.error(`Failed to fetch source code for ${path}:`, response.status)
60 fetchedSourceCode[key] = 'Error loading source code.'
61 }
62 } catch (error) {
63 console.error(`Error fetching source code for ${path}:`, error)
64 fetchedSourceCode[key] = 'Error loading source code.'
65 }
66 } else {
67 console.error(`Registry item for ${registryKey} not found.`)
68 fetchedSourceCode[key] = 'Registry item not found.'
69 }
70 })
71 )
72 setRawSourceCode(fetchedSourceCode)
73 }
74
75 fetchRegistryData()
76 }, [source])

Callers 1

EditorTextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected