()
| 35 | |
| 36 | // initial version by @aquaductape |
| 37 | export async function check_for_solid(): Promise<boolean> { |
| 38 | |
| 39 | if (detectSolidDev()) return true |
| 40 | |
| 41 | const $hy = (window as any)._$HY as unknown |
| 42 | if ($hy && typeof $hy === 'object' && 'completed' in $hy && $hy.completed instanceof WeakSet) |
| 43 | return true |
| 44 | |
| 45 | if (document.querySelector('[data-hk]')) |
| 46 | return true |
| 47 | |
| 48 | const resources = performance.getEntriesByType('resource') as PerformanceResourceTiming[] |
| 49 | |
| 50 | for (const resource of resources) { |
| 51 | if (resource.initiatorType === 'script' && resource.name.startsWith(location.origin)) { |
| 52 | try { |
| 53 | const response = await fetch(resource.name) |
| 54 | const text = await response.text() |
| 55 | if (script_text_detect_solid(text)) { |
| 56 | return true |
| 57 | } |
| 58 | } catch (_) {/**/} |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | return false |
| 63 | } |
| 64 | |
| 65 | export function detectSolidDev(): boolean { |
| 66 | return !!window[SOLID_DEV_GLOBAL] |
no test coverage detected
searching dependent graphs…