(cssUpdates: any[], httpOrigin: string)
| 43 | |
| 44 | // Handle CSS updates from Vite |
| 45 | export async function handleCssUpdates(cssUpdates: any[], httpOrigin: string): Promise<void> { |
| 46 | for (const update of cssUpdates) { |
| 47 | try { |
| 48 | const path = update.path || update.acceptedPath || ''; |
| 49 | if (!path || !httpOrigin) continue; |
| 50 | |
| 51 | // Compose URL like the Vite client (ensure raw content and cache-bust) |
| 52 | const hasQuery = path.includes('?'); |
| 53 | const tParam = `t=${encodeURIComponent(String(update.timestamp || Date.now()))}`; |
| 54 | const directParam = hasQuery ? '&direct=1' : '?direct=1'; |
| 55 | const tSuffix = (hasQuery ? '&' : '?') + tParam; |
| 56 | const url = httpOrigin + path + directParam + tSuffix; |
| 57 | |
| 58 | if (VERBOSE) console.info('[ns-hmr] Fetching CSS:', url); |
| 59 | const cssText = await fetchText(url); |
| 60 | if (cssText) { |
| 61 | applyCssText(cssText); |
| 62 | } |
| 63 | } catch (e) { |
| 64 | console.warn('[ns-hmr] CSS update fetch/apply failed:', e?.message || String(e)); |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | // Handle custom CSS events |
| 70 | export function handleCustomCss(cssText: string): void { |
no test coverage detected