// ── HTML Injection ─────────────────────────────────────────────────────────── // Injects the Originmain fiber hook `; } return cachedScriptTag; } /** * Inject the fiber hook script into an HTML string. * * Injection strategy (in order of preference): * 1. After `` — standard position for early scripts * 2. After `` — fallback if is missing * 3. Prepend to document — final fallback */ export function injectFiberHook(html: string): string { const tag = getScriptTag(); // Try after const headMatch = /]*>/i.exec(html); if (headMatch) { const insertAt = headMatch.index + headMatch[0].length; return html.slice(0, insertAt) + tag + html.slice(insertAt); } // Try after const htmlMatch = /]*>/i.exec(html); if (htmlMatch) { const insertAt = htmlMatch.index + htmlMatch[0].length; return html.slice(0, insertAt) + tag + html.slice(insertAt); } // Final fallback: prepend return tag + html; }