@@ -15,6 +15,93 @@ initGlobalSandbox();
1515// Инициализируем роутер асинхронно
1616router . init ( ) . then ( ( ) => {
1717 console . log ( '✅ AdvancedRouter fully initialized' ) ;
18+
19+ // Добавляем глобальные функции для управления из консоли
20+ if ( typeof window !== 'undefined' ) {
21+ // Очистить весь кэш роутера
22+ ( window as any ) . clearRouterCache = ( ) => {
23+ router . clearCache ( ) ;
24+ console . log ( '🧹 Router cache cleared' ) ;
25+ return 'Router cache cleared successfully' ;
26+ } ;
27+
28+ // Очистить очередь предзагрузки
29+ ( window as any ) . clearPrefetchQueue = ( ) => {
30+ router . clearPrefetchQueue ( ) ;
31+ console . log ( '🧹 Prefetch queue cleared' ) ;
32+ return 'Prefetch queue cleared successfully' ;
33+ } ;
34+
35+ // Очистить историю навигации
36+ ( window as any ) . clearNavigationHistory = ( ) => {
37+ router . clearNavigationHistory ( ) ;
38+ console . log ( '🧹 Navigation history cleared' ) ;
39+ return 'Navigation history cleared successfully' ;
40+ } ;
41+
42+ // Очистить кэш Service Worker
43+ ( window as any ) . clearServiceWorkerCache = async ( ) => {
44+ const result = await router . clearServiceWorkerCache ( ) ;
45+ console . log ( '🧹 Service Worker cache cleared:' , result ) ;
46+ return `Service Worker cache cleared: ${ result } ` ;
47+ } ;
48+
49+ // Получить статистику кэша
50+ ( window as any ) . getCacheStats = ( ) => {
51+ const stats = router . getCacheManager ( ) . getStats ( ) ;
52+ console . log ( '📊 Cache stats:' , stats ) ;
53+ return stats ;
54+ } ;
55+
56+ // Получить статистику предзагрузки
57+ ( window as any ) . getPrefetchStats = ( ) => {
58+ const stats = router . getPrefetchManager ( ) . getStats ( ) ;
59+ console . log ( '📊 Prefetch stats:' , stats ) ;
60+ return stats ;
61+ } ;
62+
63+ // Получить все URL в кэше
64+ ( window as any ) . getCachedUrls = ( ) => {
65+ const urls = router . getCacheManager ( ) . getUrls ( ) ;
66+ console . log ( '📋 Cached URLs:' , urls ) ;
67+ return urls ;
68+ } ;
69+
70+ // Очистить ВСЁ (комплексная очистка)
71+ ( window as any ) . clearAllRouterData = async ( ) => {
72+ console . log ( '🧹 Starting comprehensive router data cleanup...' ) ;
73+
74+ router . clearCache ( ) ;
75+ console . log ( '✅ Router cache cleared' ) ;
76+
77+ router . clearPrefetchQueue ( ) ;
78+ console . log ( '✅ Prefetch queue cleared' ) ;
79+
80+ router . clearNavigationHistory ( ) ;
81+ console . log ( '✅ Navigation history cleared' ) ;
82+
83+ try {
84+ const swResult = await router . clearServiceWorkerCache ( ) ;
85+ console . log ( '✅ Service Worker cache cleared:' , swResult ) ;
86+ } catch ( error ) {
87+ console . warn ( '⚠️ Could not clear Service Worker cache:' , error ) ;
88+ }
89+
90+ console . log ( '🎉 All router data cleared successfully' ) ;
91+ return 'All router data cleared successfully' ;
92+ } ;
93+
94+ console . log ( '🔧 Global router management functions added to window object' ) ;
95+ console . log ( '📋 Available functions:' ) ;
96+ console . log ( ' - clearRouterCache() - Clear router cache' ) ;
97+ console . log ( ' - clearPrefetchQueue() - Clear prefetch queue' ) ;
98+ console . log ( ' - clearNavigationHistory() - Clear navigation history' ) ;
99+ console . log ( ' - clearServiceWorkerCache() - Clear Service Worker cache' ) ;
100+ console . log ( ' - clearAllRouterData() - Clear ALL router data' ) ;
101+ console . log ( ' - getCacheStats() - Get cache statistics' ) ;
102+ console . log ( ' - getPrefetchStats() - Get prefetch statistics' ) ;
103+ console . log ( ' - getCachedUrls() - Get all cached URLs' ) ;
104+ }
18105} ) . catch ( error => {
19106 console . error ( '❌ Failed to initialize AdvancedRouter:' , error ) ;
20107} ) ;
0 commit comments