(filename: string)
| 9 | } |
| 10 | |
| 11 | export function getEmbeddedData<T>(filename: string): T | null { |
| 12 | if (typeof document === "undefined") return null; |
| 13 | |
| 14 | if (embeddedDataCache.has(filename)) { |
| 15 | return embeddedDataCache.get(filename) as T; |
| 16 | } |
| 17 | |
| 18 | const element = document.getElementById(getEmbeddedDataElementId(filename)); |
| 19 | if (!(element instanceof HTMLScriptElement)) return null; |
| 20 | |
| 21 | try { |
| 22 | const data = JSON.parse(element.textContent || "null") as T; |
| 23 | embeddedDataCache.set(filename, data); |
| 24 | return data; |
| 25 | } catch (error) { |
| 26 | console.error(`Error parsing embedded data for ${filename}:`, error); |
| 27 | return null; |
| 28 | } |
| 29 | } |
nothing calls this directly
no test coverage detected