@rakeyshgidwani/roger-ui-bank-theme-stan-design 0.1.3 → 0.1.5
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.
- package/CHANGELOG.md +1 -1
- package/dist/index.d.ts +131 -131
- package/dist/index.esm.js +148 -148
- package/dist/index.js +148 -148
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/ui/accessibility-demo.tsx +271 -0
- package/src/components/ui/advanced-component-architecture-demo.tsx +916 -0
- package/src/components/ui/advanced-transition-system-demo.tsx +670 -0
- package/src/components/ui/advanced-transition-system.tsx +395 -0
- package/src/components/ui/animation/animated-container.tsx +166 -0
- package/src/components/ui/animation/index.ts +19 -0
- package/src/components/ui/animation/staggered-container.tsx +68 -0
- package/src/components/ui/animation-demo.tsx +250 -0
- package/src/components/ui/badge.tsx +33 -0
- package/src/components/ui/battery-conscious-animation-demo.tsx +568 -0
- package/src/components/ui/border-radius-shadow-demo.tsx +187 -0
- package/src/components/ui/button.tsx +36 -0
- package/src/components/ui/card.tsx +207 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/color-preview.tsx +411 -0
- package/src/components/ui/data-display/chart.tsx +653 -0
- package/src/components/ui/data-display/data-grid-simple.tsx +76 -0
- package/src/components/ui/data-display/data-grid.tsx +680 -0
- package/src/components/ui/data-display/list.tsx +456 -0
- package/src/components/ui/data-display/table.tsx +482 -0
- package/src/components/ui/data-display/timeline.tsx +441 -0
- package/src/components/ui/data-display/tree.tsx +602 -0
- package/src/components/ui/data-display/types.ts +536 -0
- package/src/components/ui/enterprise-mobile-experience-demo.tsx +749 -0
- package/src/components/ui/enterprise-mobile-experience.tsx +464 -0
- package/src/components/ui/feedback/alert.tsx +157 -0
- package/src/components/ui/feedback/progress.tsx +292 -0
- package/src/components/ui/feedback/skeleton.tsx +185 -0
- package/src/components/ui/feedback/toast.tsx +280 -0
- package/src/components/ui/feedback/types.ts +125 -0
- package/src/components/ui/font-preview.tsx +288 -0
- package/src/components/ui/form-demo.tsx +553 -0
- package/src/components/ui/hardware-acceleration-demo.tsx +547 -0
- package/src/components/ui/input.tsx +35 -0
- package/src/components/ui/label.tsx +16 -0
- package/src/components/ui/layout-demo.tsx +367 -0
- package/src/components/ui/layouts/adaptive-layout.tsx +139 -0
- package/src/components/ui/layouts/desktop-layout.tsx +224 -0
- package/src/components/ui/layouts/index.ts +10 -0
- package/src/components/ui/layouts/mobile-layout.tsx +162 -0
- package/src/components/ui/layouts/tablet-layout.tsx +197 -0
- package/src/components/ui/mobile-form-validation.tsx +451 -0
- package/src/components/ui/mobile-input-demo.tsx +201 -0
- package/src/components/ui/mobile-input.tsx +281 -0
- package/src/components/ui/mobile-skeleton-loading-demo.tsx +638 -0
- package/src/components/ui/navigation/breadcrumb.tsx +158 -0
- package/src/components/ui/navigation/index.ts +36 -0
- package/src/components/ui/navigation/menu.tsx +374 -0
- package/src/components/ui/navigation/navigation-demo.tsx +324 -0
- package/src/components/ui/navigation/pagination.tsx +272 -0
- package/src/components/ui/navigation/sidebar.tsx +383 -0
- package/src/components/ui/navigation/stepper.tsx +303 -0
- package/src/components/ui/navigation/tabs.tsx +205 -0
- package/src/components/ui/navigation/types.ts +299 -0
- package/src/components/ui/overlay/backdrop.tsx +81 -0
- package/src/components/ui/overlay/focus-manager.tsx +143 -0
- package/src/components/ui/overlay/index.ts +36 -0
- package/src/components/ui/overlay/modal.tsx +270 -0
- package/src/components/ui/overlay/overlay-manager.tsx +110 -0
- package/src/components/ui/overlay/popover.tsx +462 -0
- package/src/components/ui/overlay/portal.tsx +79 -0
- package/src/components/ui/overlay/tooltip.tsx +303 -0
- package/src/components/ui/overlay/types.ts +196 -0
- package/src/components/ui/performance-demo.tsx +596 -0
- package/src/components/ui/semantic-input-system-demo.tsx +502 -0
- package/src/components/ui/semantic-input-system-demo.tsx.disabled +873 -0
- package/src/components/ui/tablet-layout.tsx +192 -0
- package/src/components/ui/theme-customizer.tsx +386 -0
- package/src/components/ui/theme-preview.tsx +310 -0
- package/src/components/ui/theme-switcher.tsx +264 -0
- package/src/components/ui/theme-toggle.tsx +38 -0
- package/src/components/ui/token-demo.tsx +195 -0
- package/src/components/ui/touch-demo.tsx +462 -0
- package/src/components/ui/touch-friendly-interface-demo.tsx +519 -0
- package/src/components/ui/touch-friendly-interface.tsx +296 -0
- package/src/hooks/index.ts +190 -0
- package/src/hooks/use-accessibility-support.ts +518 -0
- package/src/hooks/use-adaptive-layout.ts +289 -0
- package/src/hooks/use-advanced-patterns.ts +294 -0
- package/src/hooks/use-advanced-transition-system.ts +393 -0
- package/src/hooks/use-animation-profile.ts +288 -0
- package/src/hooks/use-battery-animations.ts +384 -0
- package/src/hooks/use-battery-conscious-loading.ts +475 -0
- package/src/hooks/use-battery-optimization.ts +330 -0
- package/src/hooks/use-battery-status.ts +299 -0
- package/src/hooks/use-component-performance.ts +344 -0
- package/src/hooks/use-device-loading-states.ts +459 -0
- package/src/hooks/use-device.tsx +110 -0
- package/src/hooks/use-enterprise-mobile-experience.ts +488 -0
- package/src/hooks/use-form-feedback.ts +403 -0
- package/src/hooks/use-form-performance.ts +513 -0
- package/src/hooks/use-frame-rate.ts +251 -0
- package/src/hooks/use-gestures.ts +338 -0
- package/src/hooks/use-hardware-acceleration.ts +341 -0
- package/src/hooks/use-input-accessibility.ts +455 -0
- package/src/hooks/use-input-performance.ts +506 -0
- package/src/hooks/use-layout-performance.ts +319 -0
- package/src/hooks/use-loading-accessibility.ts +535 -0
- package/src/hooks/use-loading-performance.ts +473 -0
- package/src/hooks/use-memory-usage.ts +287 -0
- package/src/hooks/use-mobile-form-layout.ts +464 -0
- package/src/hooks/use-mobile-form-validation.ts +518 -0
- package/src/hooks/use-mobile-keyboard-optimization.ts +472 -0
- package/src/hooks/use-mobile-layout.ts +302 -0
- package/src/hooks/use-mobile-optimization.ts +406 -0
- package/src/hooks/use-mobile-skeleton.ts +402 -0
- package/src/hooks/use-mobile-touch.ts +414 -0
- package/src/hooks/use-performance-throttling.ts +348 -0
- package/src/hooks/use-performance.ts +316 -0
- package/src/hooks/use-reusable-architecture.ts +414 -0
- package/src/hooks/use-semantic-input-types.ts +357 -0
- package/src/hooks/use-semantic-input.ts +565 -0
- package/src/hooks/use-tablet-layout.ts +384 -0
- package/src/hooks/use-touch-friendly-input.ts +524 -0
- package/src/hooks/use-touch-friendly-interface.ts +331 -0
- package/src/hooks/use-touch-optimization.ts +375 -0
- package/src/index.ts +279 -279
- package/src/lib/utils.ts +6 -0
- package/src/themes/README.md +272 -0
- package/src/themes/ThemeContext.tsx +31 -0
- package/src/themes/ThemeProvider.tsx +232 -0
- package/src/themes/accessibility/index.ts +27 -0
- package/src/themes/accessibility.ts +259 -0
- package/src/themes/aria-patterns.ts +420 -0
- package/src/themes/base-themes.ts +55 -0
- package/src/themes/colorManager.ts +380 -0
- package/src/themes/examples/dark-theme.ts +154 -0
- package/src/themes/examples/minimal-theme.ts +108 -0
- package/src/themes/focus-management.ts +701 -0
- package/src/themes/fontLoader.ts +201 -0
- package/src/themes/high-contrast.ts +621 -0
- package/src/themes/index.ts +19 -0
- package/src/themes/inheritance.ts +227 -0
- package/src/themes/keyboard-navigation.ts +550 -0
- package/src/themes/motion-reduction.ts +662 -0
- package/src/themes/navigation.ts +238 -0
- package/src/themes/screen-reader.ts +645 -0
- package/src/themes/systemThemeDetector.ts +182 -0
- package/src/themes/themeCSSUpdater.ts +262 -0
- package/src/themes/themePersistence.ts +238 -0
- package/src/themes/themes/default.ts +586 -0
- package/src/themes/themes/harvey.ts +554 -0
- package/src/themes/themes/stan-design.ts +683 -0
- package/src/themes/types.ts +460 -0
- package/src/themes/useSystemTheme.ts +48 -0
- package/src/themes/useTheme.ts +87 -0
- package/src/themes/validation.ts +462 -0
- package/src/tokens/index.ts +34 -0
- package/src/tokens/tokenExporter.ts +397 -0
- package/src/tokens/tokenGenerator.ts +276 -0
- package/src/tokens/tokenManager.ts +248 -0
- package/src/tokens/tokenValidator.ts +543 -0
- package/src/tokens/types.ts +78 -0
- package/src/utils/bundle-analyzer.ts +260 -0
- package/src/utils/bundle-splitting.ts +483 -0
- package/src/utils/lazy-loading.ts +441 -0
- package/src/utils/performance-monitor.ts +513 -0
- package/src/utils/tree-shaking.ts +274 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback, useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
export interface LayoutPerformanceMetrics {
|
|
4
|
+
renderTime: number
|
|
5
|
+
layoutTime: number
|
|
6
|
+
memoryUsage: number
|
|
7
|
+
batteryLevel: number
|
|
8
|
+
fps: number
|
|
9
|
+
performanceScore: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface LayoutPerformanceConfig {
|
|
13
|
+
enableLayoutCalculationOptimization?: boolean
|
|
14
|
+
enableMemoryManagement?: boolean
|
|
15
|
+
enableBatteryOptimization?: boolean
|
|
16
|
+
enablePerformanceMonitoring?: boolean
|
|
17
|
+
layoutThrottleMs?: number
|
|
18
|
+
memoryCleanupThreshold?: number
|
|
19
|
+
batteryLowThreshold?: number
|
|
20
|
+
fpsTarget?: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface LayoutPerformanceCallbacks {
|
|
24
|
+
onPerformanceWarning?: (warning: string, metrics: LayoutPerformanceMetrics) => void
|
|
25
|
+
onMemoryWarning?: (usage: number, threshold: number) => void
|
|
26
|
+
onBatteryWarning?: (level: number, isLow: boolean) => void
|
|
27
|
+
onLayoutOptimization?: (optimization: string) => void
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const useLayoutPerformance = (
|
|
31
|
+
config: LayoutPerformanceConfig = {},
|
|
32
|
+
callbacks: LayoutPerformanceCallbacks = {}
|
|
33
|
+
) => {
|
|
34
|
+
const {
|
|
35
|
+
enableLayoutCalculationOptimization = true,
|
|
36
|
+
enableMemoryManagement = true,
|
|
37
|
+
enableBatteryOptimization = true,
|
|
38
|
+
enablePerformanceMonitoring = true,
|
|
39
|
+
layoutThrottleMs = 16, // ~60fps
|
|
40
|
+
memoryCleanupThreshold = 80,
|
|
41
|
+
batteryLowThreshold = 0.2,
|
|
42
|
+
fpsTarget = 60
|
|
43
|
+
} = config
|
|
44
|
+
|
|
45
|
+
const [metrics, setMetrics] = useState<LayoutPerformanceMetrics>({
|
|
46
|
+
renderTime: 0,
|
|
47
|
+
layoutTime: 0,
|
|
48
|
+
memoryUsage: 0,
|
|
49
|
+
batteryLevel: 1,
|
|
50
|
+
fps: 60,
|
|
51
|
+
performanceScore: 100
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const [isOptimizing, setIsOptimizing] = useState(false)
|
|
55
|
+
const [optimizations, setOptimizations] = useState<string[]>([])
|
|
56
|
+
|
|
57
|
+
const frameCountRef = useRef(0)
|
|
58
|
+
const lastFrameTimeRef = useRef(performance.now())
|
|
59
|
+
const layoutThrottleRef = useRef<number | null>(null)
|
|
60
|
+
const memoryCleanupRef = useRef<number | null>(null)
|
|
61
|
+
const batteryCheckRef = useRef<number | null>(null)
|
|
62
|
+
|
|
63
|
+
// FPS calculation
|
|
64
|
+
const calculateFPS = useCallback(() => {
|
|
65
|
+
const now = performance.now()
|
|
66
|
+
frameCountRef.current++
|
|
67
|
+
|
|
68
|
+
if (now - lastFrameTimeRef.current >= 1000) {
|
|
69
|
+
const fps = Math.round((frameCountRef.current * 1000) / (now - lastFrameTimeRef.current))
|
|
70
|
+
frameCountRef.current = 0
|
|
71
|
+
lastFrameTimeRef.current = now
|
|
72
|
+
|
|
73
|
+
setMetrics(prev => ({ ...prev, fps }))
|
|
74
|
+
return fps
|
|
75
|
+
}
|
|
76
|
+
return null
|
|
77
|
+
}, [])
|
|
78
|
+
|
|
79
|
+
// Layout calculation optimization
|
|
80
|
+
const optimizedLayoutCalculation = useCallback((callback: () => void) => {
|
|
81
|
+
if (!enableLayoutCalculationOptimization) {
|
|
82
|
+
callback()
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (layoutThrottleRef.current) {
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
layoutThrottleRef.current = window.setTimeout(() => {
|
|
91
|
+
const startTime = performance.now()
|
|
92
|
+
callback()
|
|
93
|
+
const endTime = performance.now()
|
|
94
|
+
const layoutTime = endTime - startTime
|
|
95
|
+
|
|
96
|
+
setMetrics(prev => ({ ...prev, layoutTime }))
|
|
97
|
+
layoutThrottleRef.current = null
|
|
98
|
+
}, layoutThrottleMs)
|
|
99
|
+
}, [enableLayoutCalculationOptimization, layoutThrottleMs])
|
|
100
|
+
|
|
101
|
+
// Memory management
|
|
102
|
+
const checkMemoryUsage = useCallback(() => {
|
|
103
|
+
if (!enableMemoryManagement || !('memory' in performance)) return
|
|
104
|
+
|
|
105
|
+
const memory = (performance as any).memory
|
|
106
|
+
const usage = (memory.usedJSHeapSize / memory.jsHeapSizeLimit) * 100
|
|
107
|
+
|
|
108
|
+
setMetrics(prev => ({ ...prev, memoryUsage: usage }))
|
|
109
|
+
|
|
110
|
+
if (usage > memoryCleanupThreshold) {
|
|
111
|
+
callbacks.onMemoryWarning?.(usage, memoryCleanupThreshold)
|
|
112
|
+
triggerMemoryCleanup()
|
|
113
|
+
}
|
|
114
|
+
}, [enableMemoryManagement, memoryCleanupThreshold, callbacks])
|
|
115
|
+
|
|
116
|
+
const triggerMemoryCleanup = useCallback(() => {
|
|
117
|
+
if (!enableMemoryManagement) return
|
|
118
|
+
|
|
119
|
+
setIsOptimizing(true)
|
|
120
|
+
|
|
121
|
+
// Simulate memory cleanup
|
|
122
|
+
setTimeout(() => {
|
|
123
|
+
// Force garbage collection if available
|
|
124
|
+
if ('gc' in window) {
|
|
125
|
+
(window as any).gc()
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Clear any cached data
|
|
129
|
+
if ('caches' in window) {
|
|
130
|
+
caches.keys().then(names => {
|
|
131
|
+
names.forEach(name => caches.delete(name))
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
setIsOptimizing(false)
|
|
136
|
+
setOptimizations(prev => [...prev, 'Memory cleanup completed'])
|
|
137
|
+
}, 100)
|
|
138
|
+
}, [enableMemoryManagement])
|
|
139
|
+
|
|
140
|
+
// Battery optimization
|
|
141
|
+
const checkBatteryStatus = useCallback(async () => {
|
|
142
|
+
if (!enableBatteryOptimization || !('getBattery' in navigator)) return
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
const battery = await (navigator as any).getBattery()
|
|
146
|
+
const level = battery.level
|
|
147
|
+
|
|
148
|
+
setMetrics(prev => ({ ...prev, batteryLevel: level }))
|
|
149
|
+
|
|
150
|
+
if (level < batteryLowThreshold) {
|
|
151
|
+
callbacks.onBatteryWarning?.(level, true)
|
|
152
|
+
enableBatteryOptimizations()
|
|
153
|
+
}
|
|
154
|
+
} catch (error) {
|
|
155
|
+
console.warn('Battery API not available:', error)
|
|
156
|
+
}
|
|
157
|
+
}, [enableBatteryOptimization, batteryLowThreshold, callbacks])
|
|
158
|
+
|
|
159
|
+
const enableBatteryOptimizations = useCallback(() => {
|
|
160
|
+
if (!enableBatteryOptimization) return
|
|
161
|
+
|
|
162
|
+
setIsOptimizing(true)
|
|
163
|
+
|
|
164
|
+
// Simulate battery optimizations
|
|
165
|
+
setTimeout(() => {
|
|
166
|
+
// Reduce animation complexity
|
|
167
|
+
// Reduce layout calculations
|
|
168
|
+
// Optimize touch events
|
|
169
|
+
|
|
170
|
+
setIsOptimizing(false)
|
|
171
|
+
setOptimizations(prev => [...prev, 'Battery optimizations enabled'])
|
|
172
|
+
}, 200)
|
|
173
|
+
}, [enableBatteryOptimization])
|
|
174
|
+
|
|
175
|
+
// Performance monitoring
|
|
176
|
+
const measurePerformance = useCallback(() => {
|
|
177
|
+
if (!enablePerformanceMonitoring) return
|
|
178
|
+
|
|
179
|
+
const startTime = performance.now()
|
|
180
|
+
|
|
181
|
+
// Simulate performance measurement
|
|
182
|
+
setTimeout(() => {
|
|
183
|
+
const endTime = performance.now()
|
|
184
|
+
const renderTime = endTime - startTime
|
|
185
|
+
|
|
186
|
+
// Calculate performance score
|
|
187
|
+
const fpsScore = Math.min((metrics.fps / fpsTarget) * 100, 100)
|
|
188
|
+
const timeScore = Math.max(100 - (renderTime * 10), 0)
|
|
189
|
+
const memoryScore = Math.max(100 - metrics.memoryUsage, 0)
|
|
190
|
+
const batteryScore = metrics.batteryLevel * 100
|
|
191
|
+
|
|
192
|
+
const performanceScore = Math.round((fpsScore + timeScore + memoryScore + batteryScore) / 4)
|
|
193
|
+
|
|
194
|
+
setMetrics(prev => ({ ...prev, renderTime, performanceScore }))
|
|
195
|
+
|
|
196
|
+
if (performanceScore < 70) {
|
|
197
|
+
callbacks.onPerformanceWarning?.('Performance below target', { ...metrics, renderTime, performanceScore })
|
|
198
|
+
}
|
|
199
|
+
}, 10)
|
|
200
|
+
}, [enablePerformanceMonitoring, metrics, fpsTarget, callbacks])
|
|
201
|
+
|
|
202
|
+
// Layout optimization suggestions
|
|
203
|
+
const getLayoutOptimizations = useCallback(() => {
|
|
204
|
+
const suggestions: string[] = []
|
|
205
|
+
|
|
206
|
+
if (metrics.fps < fpsTarget * 0.8) {
|
|
207
|
+
suggestions.push('Reduce layout complexity to improve FPS')
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (metrics.memoryUsage > memoryCleanupThreshold) {
|
|
211
|
+
suggestions.push('Consider implementing virtual scrolling for large lists')
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (metrics.batteryLevel < batteryLowThreshold) {
|
|
215
|
+
suggestions.push('Reduce animations and effects for better battery life')
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (metrics.layoutTime > 16) {
|
|
219
|
+
suggestions.push('Optimize layout calculations to stay under 16ms')
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return suggestions
|
|
223
|
+
}, [metrics, fpsTarget, memoryCleanupThreshold, batteryLowThreshold])
|
|
224
|
+
|
|
225
|
+
// Apply layout optimizations
|
|
226
|
+
const applyLayoutOptimizations = useCallback((optimizationType: string) => {
|
|
227
|
+
setIsOptimizing(true)
|
|
228
|
+
|
|
229
|
+
setTimeout(() => {
|
|
230
|
+
let optimization = ''
|
|
231
|
+
|
|
232
|
+
switch (optimizationType) {
|
|
233
|
+
case 'reduce-layout-complexity':
|
|
234
|
+
optimization = 'Layout complexity reduced - simplified DOM structure'
|
|
235
|
+
break
|
|
236
|
+
case 'virtual-scrolling':
|
|
237
|
+
optimization = 'Virtual scrolling implemented for better performance'
|
|
238
|
+
break
|
|
239
|
+
case 'animation-optimization':
|
|
240
|
+
optimization = 'Animations optimized for current device capabilities'
|
|
241
|
+
break
|
|
242
|
+
case 'touch-optimization':
|
|
243
|
+
optimization = 'Touch events optimized for better responsiveness'
|
|
244
|
+
break
|
|
245
|
+
default:
|
|
246
|
+
optimization = 'Layout optimization applied'
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
setOptimizations(prev => [...prev, optimization])
|
|
250
|
+
setIsOptimizing(false)
|
|
251
|
+
callbacks.onLayoutOptimization?.(optimization)
|
|
252
|
+
}, 300)
|
|
253
|
+
}, [callbacks])
|
|
254
|
+
|
|
255
|
+
// Initialize monitoring
|
|
256
|
+
useEffect(() => {
|
|
257
|
+
if (!enablePerformanceMonitoring) return
|
|
258
|
+
|
|
259
|
+
const interval = setInterval(() => {
|
|
260
|
+
calculateFPS()
|
|
261
|
+
measurePerformance()
|
|
262
|
+
}, 1000)
|
|
263
|
+
|
|
264
|
+
return () => clearInterval(interval)
|
|
265
|
+
}, [enablePerformanceMonitoring, calculateFPS, measurePerformance])
|
|
266
|
+
|
|
267
|
+
// Memory monitoring
|
|
268
|
+
useEffect(() => {
|
|
269
|
+
if (!enableMemoryManagement) return
|
|
270
|
+
|
|
271
|
+
const interval = setInterval(checkMemoryUsage, 5000)
|
|
272
|
+
return () => clearInterval(interval)
|
|
273
|
+
}, [enableMemoryManagement, checkMemoryUsage])
|
|
274
|
+
|
|
275
|
+
// Battery monitoring
|
|
276
|
+
useEffect(() => {
|
|
277
|
+
if (!enableBatteryOptimization) return
|
|
278
|
+
|
|
279
|
+
checkBatteryStatus()
|
|
280
|
+
const interval = setInterval(checkBatteryStatus, 30000) // Check every 30 seconds
|
|
281
|
+
return () => clearInterval(interval)
|
|
282
|
+
}, [enableBatteryOptimization, checkBatteryStatus])
|
|
283
|
+
|
|
284
|
+
// Cleanup on unmount
|
|
285
|
+
useEffect(() => {
|
|
286
|
+
return () => {
|
|
287
|
+
if (layoutThrottleRef.current) {
|
|
288
|
+
clearTimeout(layoutThrottleRef.current)
|
|
289
|
+
}
|
|
290
|
+
if (memoryCleanupRef.current) {
|
|
291
|
+
clearTimeout(memoryCleanupRef.current)
|
|
292
|
+
}
|
|
293
|
+
if (batteryCheckRef.current) {
|
|
294
|
+
clearTimeout(batteryCheckRef.current)
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}, [])
|
|
298
|
+
|
|
299
|
+
return {
|
|
300
|
+
// State
|
|
301
|
+
metrics,
|
|
302
|
+
isOptimizing,
|
|
303
|
+
optimizations,
|
|
304
|
+
|
|
305
|
+
// Actions
|
|
306
|
+
optimizedLayoutCalculation,
|
|
307
|
+
triggerMemoryCleanup,
|
|
308
|
+
enableBatteryOptimizations,
|
|
309
|
+
applyLayoutOptimizations,
|
|
310
|
+
|
|
311
|
+
// Computed values
|
|
312
|
+
layoutOptimizations: getLayoutOptimizations(),
|
|
313
|
+
isPerformanceOptimal: metrics.performanceScore >= 80,
|
|
314
|
+
isMemoryOptimal: metrics.memoryUsage < memoryCleanupThreshold,
|
|
315
|
+
isBatteryOptimal: metrics.batteryLevel > batteryLowThreshold
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export default useLayoutPerformance
|