vite-plugin-smart-prefetch 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/frameworks/react/index.ts","../../src/frameworks/react/usePrefetch.ts","../../src/runtime/prefetch-manager.ts","../../src/frameworks/react/PrefetchLink.tsx","../../src/frameworks/react/PrefetchDebugPanel.tsx"],"sourcesContent":["/**\n * React Framework Integration\n * Exports all React-specific components and hooks\n */\n\nexport { usePrefetch, getPrefetchManager } from './usePrefetch';\nexport { PrefetchLink } from './PrefetchLink';\nexport type { PrefetchLinkProps } from './PrefetchLink';\nexport { PrefetchDebugPanel } from './PrefetchDebugPanel';\nexport type { PrefetchDebugPanelProps } from './PrefetchDebugPanel';\n","/**\n * React Hook for Smart Prefetch\n * Automatically prefetches routes based on navigation\n */\n\nimport { useEffect, useRef } from 'react';\nimport { useLocation } from 'react-router-dom';\nimport { PrefetchManager } from '../../runtime/prefetch-manager';\nimport type { PrefetchStrategy } from '../../types';\n\n// Singleton instance\nlet managerInstance: PrefetchManager | null = null;\n\n/**\n * React hook to enable smart prefetching\n * Call this once in your root App component\n *\n * @example\n * ```tsx\n * function App() {\n * usePrefetch();\n * return <Routes>...</Routes>;\n * }\n * ```\n */\nexport function usePrefetch(): PrefetchManager | null {\n const location = useLocation();\n const initialized = useRef(false);\n\n // Initialize manager once\n useEffect(() => {\n if (!initialized.current) {\n // Read config from window (injected by plugin)\n const config = (window as any).__SMART_PREFETCH__ || {};\n const strategy: PrefetchStrategy = config.strategy || 'hybrid';\n const debug: boolean = config.debug || false;\n\n managerInstance = new PrefetchManager(strategy, debug);\n managerInstance.init();\n\n // Expose manager globally for debugging and external use\n (window as any).__FARMART_PREFETCH_MANAGER__ = managerInstance;\n\n initialized.current = true;\n\n if (debug) {\n console.log('āœ… usePrefetch initialized');\n console.log('āœ… Prefetch manager exposed as window.__FARMART_PREFETCH_MANAGER__');\n }\n }\n }, []);\n\n // Prefetch on route change\n useEffect(() => {\n if (managerInstance) {\n managerInstance.prefetch(location.pathname);\n }\n }, [location.pathname]);\n\n return managerInstance;\n}\n\n/**\n * Get the prefetch manager instance\n * Useful for manual prefetch control\n */\nexport function getPrefetchManager(): PrefetchManager | null {\n return managerInstance;\n}\n","/**\n * Prefetch Manager (Runtime)\n * Manages route prefetching in the browser\n */\n\nimport type { PrefetchConfig, PrefetchStrategy, PrefetchTarget } from '../types';\n\nexport class PrefetchManager {\n private config: PrefetchConfig | null = null;\n private prefetched = new Set<string>();\n private strategy: PrefetchStrategy;\n private observer: IntersectionObserver | null = null;\n private debug: boolean;\n private currentSegment: string | null = null;\n private fallbackToDefault: boolean = true;\n\n constructor(strategy: PrefetchStrategy = 'hybrid', debug = false) {\n this.strategy = strategy;\n this.debug = debug;\n }\n\n /**\n * Initialize the prefetch manager\n * Loads configuration and sets up observers\n */\n async init(): Promise<void> {\n if (this.debug) {\n console.log('šŸš€ Smart Prefetch Manager - Initializing...');\n console.log(' Strategy:', this.strategy);\n console.log(' Debug mode: enabled');\n }\n\n try {\n // Load prefetch configuration\n if (this.debug) {\n console.log('šŸ“„ Fetching prefetch-config.json...');\n }\n\n const response = await fetch('/prefetch-config.json');\n\n // Gracefully handle missing config file (common in development)\n if (!response.ok) {\n if (response.status === 404) {\n if (this.debug) {\n console.warn('āš ļø Prefetch config not found (404)');\n console.log(' This is expected if:');\n console.log(' 1. You haven\\'t built the app yet (run `pnpm build`)');\n console.log(' 2. The plugin failed to generate the config during build');\n console.log(' Prefetch manager will be inactive until config is available');\n }\n return;\n }\n throw new Error(`Failed to load prefetch config: ${response.statusText}`);\n }\n\n this.config = await response.json();\n\n if (this.debug && this.config) {\n console.log('āœ… Config loaded successfully');\n console.log(` Routes with prefetch rules: ${Object.keys(this.config.routes).length} ${typeof this.config.routes}`);\n console.log(` Environment: ${this.config.environment}`);\n console.log(` Config version: ${this.config.version || 'N/A'}`);\n\n // List all routes with prefetch rules\n console.groupCollapsed('šŸ“‹ Available prefetch rules:');\n Object.entries(this.config.routes).forEach(([source, data]: [string, any]) => {\n console.log(`${source} → ${data.prefetch.length} target(s)`,\n data.prefetch.map((t: any) => t.route));\n });\n console.groupEnd();\n }\n\n // Set up intersection observer for 'visible' strategy\n if (this.strategy === 'visible' || this.strategy === 'hybrid') {\n this.initIntersectionObserver();\n if (this.debug) {\n console.log('šŸ‘ļø IntersectionObserver initialized for visibility-based prefetching');\n }\n }\n\n if (this.debug) {\n console.log('āœ… Prefetch Manager fully initialized');\n console.log('šŸ’” Run window.__PREFETCH_DEBUG__() to see current state');\n\n // Expose debug helper globally\n (window as any).__PREFETCH_DEBUG__ = () => this.logDebugInfo();\n }\n } catch (error) {\n // Only log error if debug mode is enabled\n if (this.debug) {\n console.error('āŒ Failed to initialize Prefetch Manager:', error);\n }\n }\n }\n\n /**\n * Set the user segment for segment-based prefetch rules\n * @param segment - The user's segment (e.g., 'premium', 'free', 'admin')\n * @param fallbackToDefault - Use default rules if segment rules unavailable\n */\n setSegment(segment: string | null, fallbackToDefault: boolean = true): void {\n this.currentSegment = segment;\n this.fallbackToDefault = fallbackToDefault;\n\n if (this.debug) {\n console.log(`šŸ”„ Segment updated: ${segment || '(none)'}`);\n console.log(` Fallback to default: ${fallbackToDefault}`);\n }\n }\n\n /**\n * Get the current segment\n */\n getSegment(): string | null {\n return this.currentSegment;\n }\n\n /**\n * Prefetch routes based on current route\n */\n prefetch(currentRoute: string): void {\n // Strip query parameters and hash from the route\n const cleanRoute = currentRoute.split('?')[0].split('#')[0];\n\n if (this.debug) {\n console.log(`šŸ“ Checking prefetch for route: ${currentRoute}`);\n if (currentRoute !== cleanRoute) {\n console.log(` Clean route: ${cleanRoute}`);\n }\n }\n\n if (!this.config) {\n if (this.debug) {\n console.warn('āš ļø Config not loaded yet - cannot prefetch');\n console.log(' Make sure the app was built with the plugin enabled');\n }\n return;\n }\n\n // Check network conditions\n if (!this.shouldPrefetch()) {\n if (this.debug) {\n console.log('ā­ļø Skipping prefetch due to network conditions');\n }\n return;\n }\n\n // Try to find route config (try both clean and original route)\n let routeConfig = this.config.routes[cleanRoute] || this.config.routes[currentRoute];\n const matchedRoute = routeConfig ? (this.config.routes[cleanRoute] ? cleanRoute : currentRoute) : null;\n\n if (!routeConfig) {\n if (this.debug) {\n console.warn(`āš ļø No prefetch rules configured for route: ${cleanRoute}`);\n console.groupCollapsed('Available routes in config:');\n Object.keys(this.config.routes).forEach(route => {\n const targets = this.config!.routes[route].prefetch;\n console.log(` ${route} → ${targets.length} target(s)`, targets.map(t => t.route));\n });\n console.groupEnd();\n console.log(`šŸ’” Tip: Make sure your manualRules key matches exactly: \"${cleanRoute}\"`);\n }\n return;\n }\n\n // Determine which rules to use: segment-specific or default\n let prefetchTargets = routeConfig.prefetch;\n let ruleSource = 'default';\n\n // Check if segment-specific rules are available and configured\n if (this.currentSegment && routeConfig.segments?.[this.currentSegment]) {\n prefetchTargets = routeConfig.segments[this.currentSegment];\n ruleSource = `segment (${this.currentSegment})`;\n } else if (this.currentSegment && !routeConfig.segments?.[this.currentSegment] && !this.fallbackToDefault) {\n // Segment specified but no rules for it and fallback disabled\n if (this.debug) {\n console.warn(`āš ļø No prefetch rules for segment \"${this.currentSegment}\" and fallback disabled`);\n }\n return;\n }\n\n // Always log when a route is found and prefetch is about to happen\n console.log(`āœ… Found prefetch rule for: ${matchedRoute}`);\n console.log(` Total targets to prefetch: ${prefetchTargets.length}`);\n console.log(` Using: ${ruleSource} rules`);\n console.log(` Strategy: ${this.strategy}`);\n\n if (this.debug) {\n console.groupCollapsed(`šŸ“Š Prefetch Rules for: ${matchedRoute} (${ruleSource})`);\n prefetchTargets.forEach((target, index) => {\n console.log(` ${index + 1}. ${target.route} (${target.priority} priority, ${(target.probability * 100).toFixed(1)}%)`);\n });\n console.groupEnd();\n }\n\n // Prefetch based on strategy\n prefetchTargets.forEach((target) => {\n this.prefetchTarget(target);\n });\n }\n\n /**\n * Prefetch a specific target\n */\n private prefetchTarget(target: any): void {\n // Check if already prefetched\n if (this.prefetched.has(target.route)) {\n console.log(` ā­ļø Already prefetched: ${target.route}`);\n return;\n }\n\n console.log(` šŸ”— Prefetch target: ${target.route}, chunk: ${target.chunk}`);\n\n try {\n // Apply strategy-based prefetching\n switch (this.strategy) {\n case 'auto':\n this.injectPrefetchLink(target);\n break;\n\n case 'hover':\n // Hover is handled by link components\n break;\n\n case 'visible':\n // Visible is handled by IntersectionObserver\n break;\n\n case 'idle':\n this.prefetchOnIdle(target);\n break;\n\n case 'hybrid':\n this.prefetchHybrid(target);\n break;\n\n default:\n console.warn(`āš ļø Unknown strategy: ${this.strategy}`);\n }\n } catch (error) {\n console.error(`āŒ Error prefetching ${target.route}:`, error);\n }\n }\n\n /**\n * Hybrid strategy: prioritize based on probability\n * FOR TESTING: Fetch all priorities to verify chunks are correct\n */\n private prefetchHybrid(target: PrefetchTarget & { chunk: string }): void {\n if (target.priority === 'high' || target.probability >= 0.7) {\n // High priority: prefetch immediately\n console.log(` ⚔ High priority (${(target.probability * 100).toFixed(1)}%) - Prefetching immediately`);\n this.injectPrefetchLink(target);\n } else if (target.priority === 'medium' || target.probability >= 0.4) {\n // Medium priority: prefetch on idle (FOR TESTING: fetch immediately)\n console.log(` ā±ļø Medium priority (${(target.probability * 100).toFixed(1)}%) - Fetching immediately (TESTING MODE)`);\n this.injectPrefetchLink(target); // Changed from prefetchOnIdle to immediate for testing\n } else {\n // Low priority: wait for visibility or hover (FOR TESTING: fetch immediately)\n console.log(` šŸ”” Low priority (${(target.probability * 100).toFixed(1)}%) - Fetching immediately (TESTING MODE)`);\n this.injectPrefetchLink(target); // Changed from deferred to immediate for testing\n }\n }\n\n /**\n * Prefetch during idle time\n */\n private prefetchOnIdle(target: PrefetchTarget & { chunk: string }): void {\n if ('requestIdleCallback' in window) {\n requestIdleCallback(() => {\n this.injectPrefetchLink(target);\n });\n } else {\n // Fallback for browsers without requestIdleCallback\n setTimeout(() => {\n this.injectPrefetchLink(target);\n }, 1000);\n }\n }\n\n /**\n * Resolve chunk path for the current environment\n * In production: chunks are built with hashes (e.g., chunks/Privacy-D5qJZu-O.js or js/index-CJMMxcQV.js)\n * In dev mode: need to resolve to the actual module or use a proxy\n */\n private resolveChunkPath(chunkPath: string, route: string): string {\n const isDev = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';\n\n if (!isDev) {\n // Production: use the chunk path as-is (it has real hashes from the build)\n return `/${chunkPath}`;\n }\n\n // Dev mode: Try to map chunk to component and use source files\n // Extract component name from chunk path\n // Examples:\n // - chunks/Privacy-D5qJZu-O.js → Privacy\n // - js/index-CJMMxcQV.js → index\n // - chunks/chunk-user-profile-JNr_q4Gn.js → (can't map, use original)\n\n // Try to extract component name from various chunk name patterns\n let componentName: string | null = null;\n\n // Pattern 1: Individual component chunks (e.g., Privacy-D5qJZu-O.js)\n const match1 = chunkPath.match(/\\/([A-Z][a-zA-Z]*)-[a-zA-Z0-9_-]+\\.js$/);\n if (match1) {\n componentName = match1[1];\n }\n\n // Pattern 2: Main/index chunks (e.g., js/index-CJMMxcQV.js)\n const match2 = chunkPath.match(/\\/(index)-[a-zA-Z0-9_-]+\\.js$/);\n if (match2) {\n componentName = match2[1];\n }\n\n if (componentName) {\n // Map component name to source file\n // This works because Vite's dev server resolves source files dynamically\n const sourceFile = componentName === 'index' ? '/src/main.tsx' : `/src/pages/${componentName}.tsx`;\n if (this.debug) {\n console.log(` šŸ“ Dev mode: Resolved ${chunkPath} → ${sourceFile}`);\n }\n return sourceFile;\n }\n\n // Fallback: use original chunk path with leading slash\n if (this.debug) {\n console.log(` āš ļø Dev mode: Could not extract component name from ${chunkPath}, using as-is`);\n }\n return `/${chunkPath}`;\n }\n\n /**\n * Inject prefetch link into DOM\n */\n private injectPrefetchLink(target: PrefetchTarget & { chunk: string }): void {\n if (this.prefetched.has(target.route)) {\n if (this.debug) {\n console.log(` ā­ļø Already prefetched: ${target.route}`);\n }\n return;\n }\n\n // Resolve the actual chunk path for the current environment\n // In production: use the chunk hash from config (e.g., chunks/Privacy-D5qJZu-O.js)\n // In dev mode: chunks don't exist as files, Vite handles them at request time\n const chunkPath = this.resolveChunkPath(target.chunk, target.route);\n\n // Create main chunk link\n const link = document.createElement('link');\n // Use modulepreload for better ES module support (triggers actual fetch)\n link.rel = 'modulepreload';\n link.href = chunkPath;\n link.setAttribute('data-prefetch-route', target.route);\n link.setAttribute('data-prefetch-priority', target.priority);\n link.setAttribute('data-prefetch-probability', target.probability.toString());\n\n // Always log prefetch with details\n console.groupCollapsed(`šŸ”— PREFETCH: ${target.route}`);\n console.log(` šŸ“„ Page/Route: ${target.route}`);\n console.log(` šŸ“¦ Main Chunk: ${target.chunk}`);\n console.log(` 🌐 Resolved URL: ${window.location.origin}${chunkPath}`);\n console.log(` ⭐ Priority: ${target.priority}`);\n console.log(` šŸ“Š Probability: ${(target.probability * 100).toFixed(1)}%`);\n\n // Track total chunks being fetched\n let totalChunksForThisRoute = 1; // Main chunk\n const injectedLinks: string[] = [];\n\n // Try to append the main link - CRITICAL: this must happen first\n try {\n document.head.appendChild(link);\n injectedLinks.push(target.chunk);\n console.log(` āœ… Main chunk link injected: ${target.chunk}`);\n } catch (e) {\n console.error(` āŒ Failed to inject main chunk link:`, e);\n console.groupEnd();\n return;\n }\n\n // Also prefetch all dependency chunks (imports)\n if (target.imports && target.imports.length > 0) {\n console.log(` šŸ“š Dependencies (${target.imports.length}):`);\n target.imports.forEach((importChunk, index) => {\n // Skip if already prefetched by another route\n const importId = `import:${importChunk}`;\n if (this.prefetched.has(importId)) {\n console.log(` ${index + 1}. ${importChunk} (already prefetched)`);\n return;\n }\n\n try {\n const importLink = document.createElement('link');\n importLink.rel = 'modulepreload';\n importLink.href = `/${importChunk}`;\n importLink.setAttribute('data-prefetch-import', 'true');\n importLink.setAttribute('data-prefetch-parent', target.route);\n document.head.appendChild(importLink);\n this.prefetched.add(importId);\n totalChunksForThisRoute++;\n injectedLinks.push(importChunk);\n\n console.log(` ${index + 1}. ${importChunk} āœ…`);\n } catch (e) {\n console.error(` ${index + 1}. ${importChunk} āŒ Error:`, e);\n }\n });\n }\n\n // Mark as prefetched\n this.prefetched.add(target.route);\n\n console.log(` āœ… Total chunks injected: ${totalChunksForThisRoute}`);\n console.log(` šŸ“ˆ Overall prefetched count: ${this.prefetched.size}`);\n\n if (this.debug) {\n console.log(` DOM Status: ${injectedLinks.length} link tag(s) added to document.head`);\n console.log(` Injected URLs:`, injectedLinks.map(c => `/${c}`));\n\n // Verify the link was actually added and check if it loaded\n setTimeout(() => {\n const addedLink = document.querySelector(`link[data-prefetch-route=\"${target.route}\"]`);\n if (addedLink) {\n console.log(` āœ”ļø DOM Verification: Link exists`);\n console.log(` href:`, (addedLink as HTMLLinkElement).href);\n console.log(` as:`, (addedLink as HTMLLinkElement).getAttribute('as'));\n console.log(` rel:`, (addedLink as HTMLLinkElement).rel);\n\n // Check if link actually triggered a fetch\n if ((addedLink as any).relList?.contains('modulepreload')) {\n console.log(` šŸ”„ Link has modulepreload rel (will fetch)`);\n }\n } else {\n console.error(` āŒ ERROR: Link tag not found in DOM after 100ms`);\n }\n\n // Verify ALL injected links exist\n console.log(` šŸ“‹ Verifying all injected links in head:`);\n document.querySelectorAll('link[data-prefetch-route], link[data-prefetch-import]').forEach((el, idx) => {\n const isMain = el.hasAttribute('data-prefetch-route');\n const parent = isMain ? el.getAttribute('data-prefetch-route') : el.getAttribute('data-prefetch-parent');\n console.log(` ${idx + 1}. ${(el as HTMLLinkElement).href} (parent: ${parent})`);\n });\n }, 50);\n }\n\n console.groupEnd();\n }\n\n /**\n * Check if prefetching should be performed based on network conditions\n */\n private shouldPrefetch(): boolean {\n // Check if Network Information API is available\n const nav = navigator as any;\n const connection = nav.connection || nav.mozConnection || nav.webkitConnection;\n\n if (!connection) {\n // API not available, assume prefetch is OK\n return true;\n }\n\n // Respect Data Saver mode\n if (connection.saveData) {\n if (this.debug) console.log(' āš ļø Data Saver enabled');\n return false;\n }\n\n // Check connection speed\n const slowConnections = ['slow-2g', '2g'];\n if (slowConnections.includes(connection.effectiveType)) {\n if (this.debug) console.log(` āš ļø Slow connection: ${connection.effectiveType}`);\n return false;\n }\n\n // Check if metered connection (conservative approach)\n if (connection.type === 'cellular' && connection.effectiveType !== '4g') {\n if (this.debug) console.log(' āš ļø Metered connection');\n return false;\n }\n\n return true;\n }\n\n /**\n * Initialize IntersectionObserver for 'visible' strategy\n */\n private initIntersectionObserver(): void {\n this.observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n const route = entry.target.getAttribute('data-prefetch-route');\n if (route && this.config) {\n // Find the target in config\n Object.values(this.config.routes).forEach((routeConfig) => {\n const target = routeConfig.prefetch.find((t) => t.route === route);\n if (target) {\n this.injectPrefetchLink(target);\n }\n });\n }\n }\n });\n },\n {\n rootMargin: '50px', // Start prefetch 50px before element is visible\n }\n );\n }\n\n /**\n * Observe an element for visibility-based prefetching\n */\n observeLink(element: HTMLElement, route: string): void {\n if (this.observer) {\n element.setAttribute('data-prefetch-route', route);\n this.observer.observe(element);\n }\n }\n\n /**\n * Manually trigger prefetch for a specific route\n * Useful for hover events\n */\n prefetchRoute(route: string): void {\n if (!this.config) return;\n\n // Find this route in all route configs\n Object.values(this.config.routes).forEach((routeConfig) => {\n const target = routeConfig.prefetch.find((t) => t.route === route);\n if (target) {\n this.injectPrefetchLink(target);\n }\n });\n }\n\n /**\n * Get prefetch statistics\n */\n getStats(): {\n totalPrefetched: number;\n prefetchedRoutes: string[];\n configLoaded: boolean;\n strategy: PrefetchStrategy;\n } {\n return {\n totalPrefetched: this.prefetched.size,\n prefetchedRoutes: Array.from(this.prefetched),\n configLoaded: this.config !== null,\n strategy: this.strategy,\n };\n }\n\n /**\n * Check if a route has been prefetched\n */\n isPrefetched(route: string): boolean {\n return this.prefetched.has(route);\n }\n\n /**\n * Clear all prefetch state\n */\n clear(): void {\n this.prefetched.clear();\n if (this.observer) {\n this.observer.disconnect();\n }\n }\n\n /**\n * Get all prefetch link elements currently in the DOM\n */\n getActivePrefetchLinks(): HTMLLinkElement[] {\n return Array.from(document.querySelectorAll('link[rel=\"modulepreload\"][data-prefetch-route]'));\n }\n\n /**\n * Log current state for debugging\n */\n logDebugInfo(): void {\n console.group('šŸ› Smart Prefetch Debug Info');\n console.log('Strategy:', this.strategy);\n console.log('Config loaded:', this.config !== null);\n console.log('Total prefetch entries:', this.prefetched.size);\n console.log('Prefetched items:', Array.from(this.prefetched));\n\n const links = this.getActivePrefetchLinks();\n console.log('\\nšŸ”— Active Link Tags in DOM:', links.length);\n\n if (links.length > 0) {\n console.table(links.map(link => ({\n route: link.getAttribute('data-prefetch-route'),\n chunk: link.href.replace(window.location.origin + '/', ''),\n priority: link.getAttribute('data-prefetch-priority'),\n probability: link.getAttribute('data-prefetch-probability'),\n })));\n }\n\n if (this.config) {\n console.log('\\nšŸ“Š Configuration Summary:');\n console.log('Available routes in config:', Object.keys(this.config.routes).length);\n console.log('Config environment:', this.config.environment);\n\n console.group('šŸ“‹ All configured routes with prefetch targets:');\n Object.entries(this.config.routes).forEach(([route, data]: [string, any]) => {\n console.group(`${route}`);\n data.prefetch.forEach((t: any, idx: number) => {\n console.log(` ${idx + 1}. ${t.route} (${t.priority}, ${(t.probability * 100).toFixed(1)}%) → ${t.chunk}`);\n });\n console.groupEnd();\n });\n console.groupEnd();\n\n console.log('\\nšŸ’” Current location:', window.location.pathname);\n console.log('šŸ’” Clean route:', window.location.pathname.split('?')[0].split('#')[0]);\n }\n\n console.groupEnd();\n }\n\n /**\n * Log all prefetched pages and chunks (summary view)\n */\n logPrefetchSummary(): void {\n const links = this.getActivePrefetchLinks();\n const routeLinks = links.filter(l => !l.getAttribute('data-prefetch-import'));\n const dependencyLinks = links.filter(l => l.getAttribute('data-prefetch-import'));\n\n console.group('šŸ“Š PREFETCH SUMMARY');\n console.log(`Total pages prefetched: ${routeLinks.length}`);\n console.log(`Total dependency chunks: ${dependencyLinks.length}`);\n console.log(`Total overall entries: ${this.prefetched.size}`);\n\n if (routeLinks.length > 0) {\n console.group('šŸ“„ Pages/Routes Prefetched:');\n const pageTable = routeLinks.map(link => ({\n route: link.getAttribute('data-prefetch-route'),\n chunk: link.href.replace(window.location.origin + '/', ''),\n priority: link.getAttribute('data-prefetch-priority'),\n probability: `${link.getAttribute('data-prefetch-probability')}`,\n }));\n console.table(pageTable);\n console.groupEnd();\n }\n\n if (dependencyLinks.length > 0) {\n console.group('šŸ“¦ Dependency Chunks Prefetched:');\n const depsTable = dependencyLinks.map(link => ({\n parentRoute: link.getAttribute('data-prefetch-parent'),\n chunk: link.href.replace(window.location.origin + '/', ''),\n }));\n console.table(depsTable);\n console.groupEnd();\n }\n\n console.groupEnd();\n }\n}\n","/**\n * Enhanced Link Component with Prefetch Support\n * Extends React Router Link with smart prefetching\n */\n\nimport React, { useRef, useEffect } from 'react';\nimport { Link, type LinkProps } from 'react-router-dom';\nimport { getPrefetchManager } from './usePrefetch';\n\nexport interface PrefetchLinkProps extends Omit<LinkProps, 'prefetch'> {\n /**\n * Prefetch behavior\n * - 'hover': Prefetch on mouse enter\n * - 'visible': Prefetch when link becomes visible\n * - 'manual': No automatic prefetch (use onClick)\n * - undefined: Use default strategy from config\n */\n prefetch?: 'hover' | 'visible' | 'manual';\n}\n\n/**\n * Enhanced Link component with prefetching\n *\n * @example\n * ```tsx\n * // Prefetch on hover\n * <PrefetchLink to=\"/orders\" prefetch=\"hover\">\n * View Orders\n * </PrefetchLink>\n *\n * // Prefetch when visible\n * <PrefetchLink to=\"/dispatch-order\" prefetch=\"visible\">\n * Create Dispatch\n * </PrefetchLink>\n * ```\n */\nexport const PrefetchLink = React.forwardRef<HTMLAnchorElement, PrefetchLinkProps>(\n ({ prefetch, to, children, onMouseEnter, ...props }, forwardedRef) => {\n const linkRef = useRef<HTMLAnchorElement>(null);\n const manager = getPrefetchManager();\n\n const route = typeof to === 'string' ? to : to.pathname || '';\n\n // Handle visibility-based prefetch\n useEffect(() => {\n if (prefetch === 'visible' && linkRef.current && manager) {\n manager.observeLink(linkRef.current, route);\n }\n }, [prefetch, route, manager]);\n\n // Handle hover-based prefetch\n const handleMouseEnter = (e: React.MouseEvent<HTMLAnchorElement>) => {\n if (prefetch === 'hover' && manager) {\n manager.prefetchRoute(route);\n }\n\n // Call original onMouseEnter if provided\n if (onMouseEnter) {\n onMouseEnter(e);\n }\n };\n\n return (\n <Link\n ref={(node) => {\n // Handle both forwarded ref and internal ref\n if (node) {\n (linkRef as React.MutableRefObject<HTMLAnchorElement>).current = node;\n if (typeof forwardedRef === 'function') {\n forwardedRef(node);\n } else if (forwardedRef) {\n forwardedRef.current = node;\n }\n }\n }}\n to={to}\n onMouseEnter={handleMouseEnter}\n {...props}\n >\n {children}\n </Link>\n );\n }\n);\n\nPrefetchLink.displayName = 'PrefetchLink';\n","/**\n * Debug Panel Component for Smart Prefetch Plugin\n * Shows real-time prefetch status and link tags\n */\n\nimport { useEffect, useState } from 'react';\nimport type { PrefetchManager } from '../../runtime/prefetch-manager';\n\nexport interface PrefetchDebugPanelProps {\n manager: PrefetchManager | null;\n position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\n defaultOpen?: boolean;\n}\n\ninterface LinkInfo {\n route: string;\n href: string;\n priority: string;\n probability: string;\n}\n\nexport function PrefetchDebugPanel({\n manager,\n position = 'bottom-right',\n defaultOpen = false,\n}: PrefetchDebugPanelProps) {\n const [isOpen, setIsOpen] = useState(defaultOpen);\n const [stats, setStats] = useState<ReturnType<PrefetchManager['getStats']> | null>(null);\n const [links, setLinks] = useState<LinkInfo[]>([]);\n\n useEffect(() => {\n if (!manager) return;\n\n const updateStats = () => {\n setStats(manager.getStats());\n const linkElements = manager.getActivePrefetchLinks();\n setLinks(\n linkElements.map((link) => ({\n route: link.getAttribute('data-prefetch-route') || '',\n href: link.href,\n priority: link.getAttribute('data-prefetch-priority') || '',\n probability: link.getAttribute('data-prefetch-probability') || '',\n }))\n );\n };\n\n // Update stats immediately\n updateStats();\n\n // Update stats every second\n const interval = setInterval(updateStats, 1000);\n\n return () => clearInterval(interval);\n }, [manager]);\n\n if (!manager) {\n return null;\n }\n\n const positionStyles: Record<string, React.CSSProperties> = {\n 'top-left': { top: 10, left: 10 },\n 'top-right': { top: 10, right: 10 },\n 'bottom-left': { bottom: 10, left: 10 },\n 'bottom-right': { bottom: 10, right: 10 },\n };\n\n const containerStyle: React.CSSProperties = {\n position: 'fixed',\n ...positionStyles[position],\n zIndex: 99999,\n fontFamily: 'system-ui, -apple-system, sans-serif',\n fontSize: '12px',\n };\n\n const buttonStyle: React.CSSProperties = {\n background: '#4CAF50',\n color: 'white',\n border: 'none',\n borderRadius: '50%',\n width: '48px',\n height: '48px',\n cursor: 'pointer',\n boxShadow: '0 4px 8px rgba(0,0,0,0.2)',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n fontSize: '20px',\n };\n\n const panelStyle: React.CSSProperties = {\n background: 'white',\n border: '1px solid #ddd',\n borderRadius: '8px',\n boxShadow: '0 4px 12px rgba(0,0,0,0.15)',\n padding: '12px',\n minWidth: '320px',\n maxWidth: '400px',\n maxHeight: '500px',\n overflow: 'auto',\n marginBottom: '8px',\n };\n\n const headerStyle: React.CSSProperties = {\n fontWeight: 'bold',\n marginBottom: '8px',\n color: '#333',\n borderBottom: '2px solid #4CAF50',\n paddingBottom: '4px',\n };\n\n const statStyle: React.CSSProperties = {\n display: 'flex',\n justifyContent: 'space-between',\n padding: '4px 0',\n borderBottom: '1px solid #eee',\n };\n\n const linkStyle: React.CSSProperties = {\n background: '#f5f5f5',\n padding: '8px',\n borderRadius: '4px',\n marginBottom: '8px',\n fontSize: '11px',\n };\n\n return (\n <div style={containerStyle}>\n {isOpen && stats && (\n <div style={panelStyle}>\n <div style={headerStyle}>šŸš€ Smart Prefetch Debug</div>\n\n <div style={{ marginBottom: '12px' }}>\n <div style={statStyle}>\n <span>Strategy:</span>\n <strong>{stats.strategy}</strong>\n </div>\n <div style={statStyle}>\n <span>Config Loaded:</span>\n <strong>{stats.configLoaded ? 'āœ…' : 'āŒ'}</strong>\n </div>\n <div style={statStyle}>\n <span>Total Prefetched:</span>\n <strong>{stats.totalPrefetched}</strong>\n </div>\n <div style={statStyle}>\n <span>Link Tags in DOM:</span>\n <strong>{links.length}</strong>\n </div>\n </div>\n\n {stats.prefetchedRoutes.length > 0 && (\n <div>\n <div style={{ ...headerStyle, fontSize: '11px' }}>Prefetched Routes:</div>\n <div style={{ fontSize: '11px', color: '#666', marginBottom: '8px' }}>\n {stats.prefetchedRoutes.join(', ')}\n </div>\n </div>\n )}\n\n {links.length > 0 && (\n <div>\n <div style={{ ...headerStyle, fontSize: '11px' }}>Active Link Tags:</div>\n {links.map((link, i) => (\n <div key={i} style={linkStyle}>\n <div>\n <strong>{link.route}</strong>\n </div>\n <div style={{ color: '#666', marginTop: '4px' }}>\n Priority: {link.priority} | Prob: {(parseFloat(link.probability) * 100).toFixed(1)}%\n </div>\n <div style={{ color: '#999', marginTop: '2px', wordBreak: 'break-all' }}>\n {link.href.split('/').pop()}\n </div>\n </div>\n ))}\n </div>\n )}\n\n <button\n onClick={() => {\n manager.logDebugInfo();\n }}\n style={{\n width: '100%',\n padding: '8px',\n background: '#2196F3',\n color: 'white',\n border: 'none',\n borderRadius: '4px',\n cursor: 'pointer',\n marginTop: '8px',\n }}\n >\n Log Debug Info to Console\n </button>\n </div>\n )}\n\n <button\n style={buttonStyle}\n onClick={() => setIsOpen(!isOpen)}\n title=\"Smart Prefetch Debug Panel\"\n >\n šŸ”—\n </button>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,mBAAkC;AAClC,8BAA4B;;;ACCrB,IAAM,kBAAN,MAAsB;AAAA,EAS3B,YAAY,WAA6B,UAAU,QAAQ,OAAO;AARlE,SAAQ,SAAgC;AACxC,SAAQ,aAAa,oBAAI,IAAY;AAErC,SAAQ,WAAwC;AAEhD,SA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O,QAAQ,WAAW,OAAO,WAAW,YAAY,GACnE,eAAK,KAAK,MAAM,GAAG,EAAE,IAAI,GAC5B;AAAA,aATQ,CAUV,CACD;AAAA,SACH;AAAA,MAGF;AAAA,QAAC;AAAA;AAAA,UACC,SAAS,MAAM;AACb,oBAAQ,aAAa;AAAA,UACvB;AAAA,UACA,OAAO;AAAA,YACL,OAAO;AAAA,YACP,SAAS;AAAA,YACT,YAAY;AAAA,YACZ,OAAO;AAAA,YACP,QAAQ;AAAA,YACR,cAAc;AAAA,YACd,QAAQ;AAAA,YACR,WAAW;AAAA,UACb;AAAA,UACD;AAAA;AAAA,MAED;AAAA,OACF;AAAA,IAGF;AAAA,MAAC;AAAA;AAAA,QACC,OAAO;AAAA,QACP,SAAS,MAAM,UAAU,CAAC,MAAM;AAAA,QAChC,OAAM;AAAA,QACP;AAAA;AAAA,IAED;AAAA,KACF;AAEJ;","names":["import_react","import_react_router_dom","React","import_react","import_jsx_runtime"]}
@@ -0,0 +1,175 @@
1
+ import React from 'react';
2
+ import { LinkProps } from 'react-router-dom';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ type PrefetchStrategy = 'auto' | 'hover' | 'visible' | 'idle' | 'hybrid';
6
+
7
+ /**
8
+ * Prefetch Manager (Runtime)
9
+ * Manages route prefetching in the browser
10
+ */
11
+
12
+ declare class PrefetchManager {
13
+ private config;
14
+ private prefetched;
15
+ private strategy;
16
+ private observer;
17
+ private debug;
18
+ private currentSegment;
19
+ private fallbackToDefault;
20
+ constructor(strategy?: PrefetchStrategy, debug?: boolean);
21
+ /**
22
+ * Initialize the prefetch manager
23
+ * Loads configuration and sets up observers
24
+ */
25
+ init(): Promise<void>;
26
+ /**
27
+ * Set the user segment for segment-based prefetch rules
28
+ * @param segment - The user's segment (e.g., 'premium', 'free', 'admin')
29
+ * @param fallbackToDefault - Use default rules if segment rules unavailable
30
+ */
31
+ setSegment(segment: string | null, fallbackToDefault?: boolean): void;
32
+ /**
33
+ * Get the current segment
34
+ */
35
+ getSegment(): string | null;
36
+ /**
37
+ * Prefetch routes based on current route
38
+ */
39
+ prefetch(currentRoute: string): void;
40
+ /**
41
+ * Prefetch a specific target
42
+ */
43
+ private prefetchTarget;
44
+ /**
45
+ * Hybrid strategy: prioritize based on probability
46
+ * FOR TESTING: Fetch all priorities to verify chunks are correct
47
+ */
48
+ private prefetchHybrid;
49
+ /**
50
+ * Prefetch during idle time
51
+ */
52
+ private prefetchOnIdle;
53
+ /**
54
+ * Resolve chunk path for the current environment
55
+ * In production: chunks are built with hashes (e.g., chunks/Privacy-D5qJZu-O.js or js/index-CJMMxcQV.js)
56
+ * In dev mode: need to resolve to the actual module or use a proxy
57
+ */
58
+ private resolveChunkPath;
59
+ /**
60
+ * Inject prefetch link into DOM
61
+ */
62
+ private injectPrefetchLink;
63
+ /**
64
+ * Check if prefetching should be performed based on network conditions
65
+ */
66
+ private shouldPrefetch;
67
+ /**
68
+ * Initialize IntersectionObserver for 'visible' strategy
69
+ */
70
+ private initIntersectionObserver;
71
+ /**
72
+ * Observe an element for visibility-based prefetching
73
+ */
74
+ observeLink(element: HTMLElement, route: string): void;
75
+ /**
76
+ * Manually trigger prefetch for a specific route
77
+ * Useful for hover events
78
+ */
79
+ prefetchRoute(route: string): void;
80
+ /**
81
+ * Get prefetch statistics
82
+ */
83
+ getStats(): {
84
+ totalPrefetched: number;
85
+ prefetchedRoutes: string[];
86
+ configLoaded: boolean;
87
+ strategy: PrefetchStrategy;
88
+ };
89
+ /**
90
+ * Check if a route has been prefetched
91
+ */
92
+ isPrefetched(route: string): boolean;
93
+ /**
94
+ * Clear all prefetch state
95
+ */
96
+ clear(): void;
97
+ /**
98
+ * Get all prefetch link elements currently in the DOM
99
+ */
100
+ getActivePrefetchLinks(): HTMLLinkElement[];
101
+ /**
102
+ * Log current state for debugging
103
+ */
104
+ logDebugInfo(): void;
105
+ /**
106
+ * Log all prefetched pages and chunks (summary view)
107
+ */
108
+ logPrefetchSummary(): void;
109
+ }
110
+
111
+ /**
112
+ * React Hook for Smart Prefetch
113
+ * Automatically prefetches routes based on navigation
114
+ */
115
+
116
+ /**
117
+ * React hook to enable smart prefetching
118
+ * Call this once in your root App component
119
+ *
120
+ * @example
121
+ * ```tsx
122
+ * function App() {
123
+ * usePrefetch();
124
+ * return <Routes>...</Routes>;
125
+ * }
126
+ * ```
127
+ */
128
+ declare function usePrefetch(): PrefetchManager | null;
129
+ /**
130
+ * Get the prefetch manager instance
131
+ * Useful for manual prefetch control
132
+ */
133
+ declare function getPrefetchManager(): PrefetchManager | null;
134
+
135
+ /**
136
+ * Enhanced Link Component with Prefetch Support
137
+ * Extends React Router Link with smart prefetching
138
+ */
139
+
140
+ interface PrefetchLinkProps extends Omit<LinkProps, 'prefetch'> {
141
+ /**
142
+ * Prefetch behavior
143
+ * - 'hover': Prefetch on mouse enter
144
+ * - 'visible': Prefetch when link becomes visible
145
+ * - 'manual': No automatic prefetch (use onClick)
146
+ * - undefined: Use default strategy from config
147
+ */
148
+ prefetch?: 'hover' | 'visible' | 'manual';
149
+ }
150
+ /**
151
+ * Enhanced Link component with prefetching
152
+ *
153
+ * @example
154
+ * ```tsx
155
+ * // Prefetch on hover
156
+ * <PrefetchLink to="/orders" prefetch="hover">
157
+ * View Orders
158
+ * </PrefetchLink>
159
+ *
160
+ * // Prefetch when visible
161
+ * <PrefetchLink to="/dispatch-order" prefetch="visible">
162
+ * Create Dispatch
163
+ * </PrefetchLink>
164
+ * ```
165
+ */
166
+ declare const PrefetchLink: React.ForwardRefExoticComponent<PrefetchLinkProps & React.RefAttributes<HTMLAnchorElement>>;
167
+
168
+ interface PrefetchDebugPanelProps {
169
+ manager: PrefetchManager | null;
170
+ position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
171
+ defaultOpen?: boolean;
172
+ }
173
+ declare function PrefetchDebugPanel({ manager, position, defaultOpen, }: PrefetchDebugPanelProps): react_jsx_runtime.JSX.Element | null;
174
+
175
+ export { PrefetchDebugPanel, type PrefetchDebugPanelProps, PrefetchLink, type PrefetchLinkProps, getPrefetchManager, usePrefetch };
@@ -0,0 +1,175 @@
1
+ import React from 'react';
2
+ import { LinkProps } from 'react-router-dom';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ type PrefetchStrategy = 'auto' | 'hover' | 'visible' | 'idle' | 'hybrid';
6
+
7
+ /**
8
+ * Prefetch Manager (Runtime)
9
+ * Manages route prefetching in the browser
10
+ */
11
+
12
+ declare class PrefetchManager {
13
+ private config;
14
+ private prefetched;
15
+ private strategy;
16
+ private observer;
17
+ private debug;
18
+ private currentSegment;
19
+ private fallbackToDefault;
20
+ constructor(strategy?: PrefetchStrategy, debug?: boolean);
21
+ /**
22
+ * Initialize the prefetch manager
23
+ * Loads configuration and sets up observers
24
+ */
25
+ init(): Promise<void>;
26
+ /**
27
+ * Set the user segment for segment-based prefetch rules
28
+ * @param segment - The user's segment (e.g., 'premium', 'free', 'admin')
29
+ * @param fallbackToDefault - Use default rules if segment rules unavailable
30
+ */
31
+ setSegment(segment: string | null, fallbackToDefault?: boolean): void;
32
+ /**
33
+ * Get the current segment
34
+ */
35
+ getSegment(): string | null;
36
+ /**
37
+ * Prefetch routes based on current route
38
+ */
39
+ prefetch(currentRoute: string): void;
40
+ /**
41
+ * Prefetch a specific target
42
+ */
43
+ private prefetchTarget;
44
+ /**
45
+ * Hybrid strategy: prioritize based on probability
46
+ * FOR TESTING: Fetch all priorities to verify chunks are correct
47
+ */
48
+ private prefetchHybrid;
49
+ /**
50
+ * Prefetch during idle time
51
+ */
52
+ private prefetchOnIdle;
53
+ /**
54
+ * Resolve chunk path for the current environment
55
+ * In production: chunks are built with hashes (e.g., chunks/Privacy-D5qJZu-O.js or js/index-CJMMxcQV.js)
56
+ * In dev mode: need to resolve to the actual module or use a proxy
57
+ */
58
+ private resolveChunkPath;
59
+ /**
60
+ * Inject prefetch link into DOM
61
+ */
62
+ private injectPrefetchLink;
63
+ /**
64
+ * Check if prefetching should be performed based on network conditions
65
+ */
66
+ private shouldPrefetch;
67
+ /**
68
+ * Initialize IntersectionObserver for 'visible' strategy
69
+ */
70
+ private initIntersectionObserver;
71
+ /**
72
+ * Observe an element for visibility-based prefetching
73
+ */
74
+ observeLink(element: HTMLElement, route: string): void;
75
+ /**
76
+ * Manually trigger prefetch for a specific route
77
+ * Useful for hover events
78
+ */
79
+ prefetchRoute(route: string): void;
80
+ /**
81
+ * Get prefetch statistics
82
+ */
83
+ getStats(): {
84
+ totalPrefetched: number;
85
+ prefetchedRoutes: string[];
86
+ configLoaded: boolean;
87
+ strategy: PrefetchStrategy;
88
+ };
89
+ /**
90
+ * Check if a route has been prefetched
91
+ */
92
+ isPrefetched(route: string): boolean;
93
+ /**
94
+ * Clear all prefetch state
95
+ */
96
+ clear(): void;
97
+ /**
98
+ * Get all prefetch link elements currently in the DOM
99
+ */
100
+ getActivePrefetchLinks(): HTMLLinkElement[];
101
+ /**
102
+ * Log current state for debugging
103
+ */
104
+ logDebugInfo(): void;
105
+ /**
106
+ * Log all prefetched pages and chunks (summary view)
107
+ */
108
+ logPrefetchSummary(): void;
109
+ }
110
+
111
+ /**
112
+ * React Hook for Smart Prefetch
113
+ * Automatically prefetches routes based on navigation
114
+ */
115
+
116
+ /**
117
+ * React hook to enable smart prefetching
118
+ * Call this once in your root App component
119
+ *
120
+ * @example
121
+ * ```tsx
122
+ * function App() {
123
+ * usePrefetch();
124
+ * return <Routes>...</Routes>;
125
+ * }
126
+ * ```
127
+ */
128
+ declare function usePrefetch(): PrefetchManager | null;
129
+ /**
130
+ * Get the prefetch manager instance
131
+ * Useful for manual prefetch control
132
+ */
133
+ declare function getPrefetchManager(): PrefetchManager | null;
134
+
135
+ /**
136
+ * Enhanced Link Component with Prefetch Support
137
+ * Extends React Router Link with smart prefetching
138
+ */
139
+
140
+ interface PrefetchLinkProps extends Omit<LinkProps, 'prefetch'> {
141
+ /**
142
+ * Prefetch behavior
143
+ * - 'hover': Prefetch on mouse enter
144
+ * - 'visible': Prefetch when link becomes visible
145
+ * - 'manual': No automatic prefetch (use onClick)
146
+ * - undefined: Use default strategy from config
147
+ */
148
+ prefetch?: 'hover' | 'visible' | 'manual';
149
+ }
150
+ /**
151
+ * Enhanced Link component with prefetching
152
+ *
153
+ * @example
154
+ * ```tsx
155
+ * // Prefetch on hover
156
+ * <PrefetchLink to="/orders" prefetch="hover">
157
+ * View Orders
158
+ * </PrefetchLink>
159
+ *
160
+ * // Prefetch when visible
161
+ * <PrefetchLink to="/dispatch-order" prefetch="visible">
162
+ * Create Dispatch
163
+ * </PrefetchLink>
164
+ * ```
165
+ */
166
+ declare const PrefetchLink: React.ForwardRefExoticComponent<PrefetchLinkProps & React.RefAttributes<HTMLAnchorElement>>;
167
+
168
+ interface PrefetchDebugPanelProps {
169
+ manager: PrefetchManager | null;
170
+ position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
171
+ defaultOpen?: boolean;
172
+ }
173
+ declare function PrefetchDebugPanel({ manager, position, defaultOpen, }: PrefetchDebugPanelProps): react_jsx_runtime.JSX.Element | null;
174
+
175
+ export { PrefetchDebugPanel, type PrefetchDebugPanelProps, PrefetchLink, type PrefetchLinkProps, getPrefetchManager, usePrefetch };