/** * Early Console Capture Script * * This script captures console logs BEFORE the application initializes, which is critical * for catching early-stage errors. It must be injected into the HTML as an inline script. * * The script creates `window.__sweetlinkEarlyLogs` which ConsoleCapture will pick up * via `importEarlyLogs()`, merging these early logs with subsequent console output. * * @example * ```typescript * import { EARLY_CONSOLE_CAPTURE_SCRIPT } from '@ytspar/sweetlink'; * // Inject as inline script in HTML head * ``` */ export declare const EARLY_CONSOLE_CAPTURE_SCRIPT = "\n(function() {\n if (window.__sweetlinkEarlyLogs) return;\n window.__sweetlinkEarlyLogs = [];\n var orig = {\n log: console.log,\n error: console.error,\n warn: console.warn,\n info: console.info\n };\n function formatArg(a) {\n if (a instanceof Error) {\n return a.name + ': ' + a.message + (a.stack ? '\\n' + a.stack : '');\n }\n if (typeof a === 'object' && a !== null) {\n try {\n return JSON.stringify(a, function(key, val) {\n if (val instanceof Error) {\n return val.name + ': ' + val.message;\n }\n return val;\n });\n } catch(e) {\n return String(a);\n }\n }\n return String(a);\n }\n function capture(level, args) {\n window.__sweetlinkEarlyLogs.push({\n level: level,\n message: Array.from(args).map(formatArg).join(' '),\n timestamp: new Date().toISOString()\n });\n }\n console.log = function() { capture('log', arguments); orig.log.apply(console, arguments); };\n console.error = function() { capture('error', arguments); orig.error.apply(console, arguments); };\n console.warn = function() { capture('warn', arguments); orig.warn.apply(console, arguments); };\n console.info = function() { capture('info', arguments); orig.info.apply(console, arguments); };\n window.addEventListener('error', function(e) {\n window.__sweetlinkEarlyLogs.push({\n level: 'error',\n message: 'Uncaught ' + (e.error ? formatArg(e.error) : e.message) + ' at ' + e.filename + ':' + e.lineno + ':' + e.colno,\n timestamp: new Date().toISOString()\n });\n });\n window.addEventListener('unhandledrejection', function(e) {\n window.__sweetlinkEarlyLogs.push({\n level: 'error',\n message: 'Unhandled Promise Rejection: ' + formatArg(e.reason),\n timestamp: new Date().toISOString()\n });\n });\n})();\n"; /** * Type declaration for the window object with early logs * Use this to type-check access to early logs in your app */ declare global { interface Window { __sweetlinkEarlyLogs?: Array<{ level: 'log' | 'error' | 'warn' | 'info' | 'debug' | 'trace'; message: string; timestamp: string; }>; } } //# sourceMappingURL=earlyConsoleCapture.d.ts.map