@rakeyshgidwani/roger-ui-bank-theme-stan-design 0.2.9 → 0.2.10
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/components/ui/accessibility-demo.esm.js +30 -24
- package/dist/components/ui/accessibility-demo.js +30 -24
- package/dist/components/ui/advanced-component-architecture-demo.esm.js +235 -179
- package/dist/components/ui/advanced-component-architecture-demo.js +235 -179
- package/dist/components/ui/advanced-transition-system-demo.esm.js +110 -64
- package/dist/components/ui/advanced-transition-system-demo.js +110 -64
- package/dist/components/ui/advanced-transition-system.esm.js +166 -122
- package/dist/components/ui/advanced-transition-system.js +166 -122
- package/dist/components/ui/animation/animated-container.esm.js +52 -29
- package/dist/components/ui/animation/animated-container.js +52 -29
- package/dist/components/ui/animation/staggered-container.esm.js +18 -9
- package/dist/components/ui/animation/staggered-container.js +18 -9
- package/dist/components/ui/animation-demo.esm.js +67 -35
- package/dist/components/ui/animation-demo.js +67 -35
- package/dist/components/ui/badge.esm.js +9 -6
- package/dist/components/ui/badge.js +9 -6
- package/dist/components/ui/battery-conscious-animation-demo.esm.js +122 -87
- package/dist/components/ui/battery-conscious-animation-demo.js +122 -87
- package/dist/components/ui/border-radius-shadow-demo.esm.js +23 -12
- package/dist/components/ui/border-radius-shadow-demo.js +23 -12
- package/dist/components/ui/button.esm.js +8 -2
- package/dist/components/ui/button.js +8 -2
- package/dist/components/ui/card.esm.js +33 -8
- package/dist/components/ui/card.js +33 -8
- package/dist/components/ui/checkbox.esm.js +3 -3
- package/dist/components/ui/checkbox.js +3 -3
- package/dist/components/ui/color-preview.esm.js +68 -45
- package/dist/components/ui/color-preview.js +68 -45
- package/dist/components/ui/data-display/chart.esm.js +112 -84
- package/dist/components/ui/data-display/chart.js +112 -84
- package/dist/components/ui/data-display/data-grid-simple.esm.js +1 -1
- package/dist/components/ui/data-display/data-grid-simple.js +1 -1
- package/dist/components/ui/data-display/data-grid.esm.js +80 -67
- package/dist/components/ui/data-display/data-grid.js +80 -67
- package/dist/components/ui/data-display/list.esm.js +53 -45
- package/dist/components/ui/data-display/list.js +53 -45
- package/dist/components/ui/data-display/table.esm.js +62 -54
- package/dist/components/ui/data-display/table.js +62 -54
- package/dist/components/ui/data-display/timeline.esm.js +39 -34
- package/dist/components/ui/data-display/timeline.js +39 -34
- package/dist/components/ui/data-display/tree.esm.js +116 -84
- package/dist/components/ui/data-display/tree.js +116 -84
- package/dist/components/ui/data-display/types.esm.js +389 -364
- package/dist/components/ui/data-display/types.js +389 -364
- package/dist/components/ui/enterprise-mobile-experience-demo.esm.js +120 -70
- package/dist/components/ui/enterprise-mobile-experience-demo.js +120 -70
- package/dist/components/ui/enterprise-mobile-experience.esm.js +124 -73
- package/dist/components/ui/enterprise-mobile-experience.js +124 -73
- package/dist/components/ui/feedback/alert.esm.js +22 -15
- package/dist/components/ui/feedback/alert.js +22 -15
- package/dist/components/ui/feedback/progress.esm.js +47 -24
- package/dist/components/ui/feedback/progress.js +47 -24
- package/dist/components/ui/feedback/skeleton.esm.js +39 -29
- package/dist/components/ui/feedback/skeleton.js +39 -29
- package/dist/components/ui/feedback/toast.esm.js +62 -38
- package/dist/components/ui/feedback/toast.js +62 -38
- package/dist/components/ui/feedback/types.esm.js +83 -83
- package/dist/components/ui/feedback/types.js +83 -83
- package/dist/components/ui/font-preview.esm.js +41 -39
- package/dist/components/ui/font-preview.js +41 -39
- package/dist/components/ui/form-demo.esm.js +150 -113
- package/dist/components/ui/form-demo.js +150 -113
- package/dist/components/ui/hardware-acceleration-demo.esm.js +137 -87
- package/dist/components/ui/hardware-acceleration-demo.js +137 -87
- package/dist/components/ui/input.esm.js +4 -1
- package/dist/components/ui/input.js +4 -1
- package/dist/components/ui/layout-demo.esm.js +81 -56
- package/dist/components/ui/layout-demo.js +81 -56
- package/dist/components/ui/layouts/adaptive-layout.esm.js +27 -8
- package/dist/components/ui/layouts/adaptive-layout.js +27 -8
- package/dist/components/ui/layouts/desktop-layout.esm.js +39 -19
- package/dist/components/ui/layouts/desktop-layout.js +39 -19
- package/dist/components/ui/layouts/mobile-layout.esm.js +19 -9
- package/dist/components/ui/layouts/mobile-layout.js +19 -9
- package/dist/components/ui/layouts/tablet-layout.esm.js +28 -14
- package/dist/components/ui/layouts/tablet-layout.js +28 -14
- package/dist/components/ui/mobile-form-validation.esm.js +120 -87
- package/dist/components/ui/mobile-form-validation.js +120 -87
- package/dist/components/ui/mobile-input-demo.esm.js +19 -13
- package/dist/components/ui/mobile-input-demo.js +19 -13
- package/dist/components/ui/mobile-input.esm.js +185 -120
- package/dist/components/ui/mobile-input.js +185 -120
- package/dist/components/ui/mobile-skeleton-loading-demo.esm.js +128 -111
- package/dist/components/ui/mobile-skeleton-loading-demo.js +128 -111
- package/dist/components/ui/navigation/breadcrumb.esm.js +17 -14
- package/dist/components/ui/navigation/breadcrumb.js +17 -14
- package/dist/components/ui/navigation/index.esm.js +23 -1
- package/dist/components/ui/navigation/index.js +23 -1
- package/dist/components/ui/navigation/menu.esm.js +49 -35
- package/dist/components/ui/navigation/menu.js +49 -35
- package/dist/components/ui/navigation/navigation-demo.esm.js +81 -74
- package/dist/components/ui/navigation/navigation-demo.js +81 -74
- package/dist/components/ui/navigation/pagination.esm.js +62 -50
- package/dist/components/ui/navigation/pagination.js +62 -50
- package/dist/components/ui/navigation/sidebar.esm.js +56 -42
- package/dist/components/ui/navigation/sidebar.js +56 -42
- package/dist/components/ui/navigation/stepper.esm.js +34 -23
- package/dist/components/ui/navigation/stepper.js +34 -23
- package/dist/components/ui/navigation/tabs.esm.js +32 -21
- package/dist/components/ui/navigation/tabs.js +32 -21
- package/dist/components/ui/navigation/types.esm.js +196 -195
- package/dist/components/ui/navigation/types.js +196 -195
- package/dist/components/ui/overlay/backdrop.esm.js +17 -16
- package/dist/components/ui/overlay/backdrop.js +17 -16
- package/dist/components/ui/overlay/focus-manager.esm.js +21 -19
- package/dist/components/ui/overlay/focus-manager.js +21 -19
- package/dist/components/ui/overlay/index.esm.js +22 -2
- package/dist/components/ui/overlay/index.js +22 -2
- package/dist/components/ui/overlay/modal.esm.js +38 -34
- package/dist/components/ui/overlay/modal.js +38 -34
- package/dist/components/ui/overlay/overlay-manager.esm.js +25 -20
- package/dist/components/ui/overlay/overlay-manager.js +25 -20
- package/dist/components/ui/overlay/popover.esm.js +74 -58
- package/dist/components/ui/overlay/popover.js +74 -58
- package/dist/components/ui/overlay/portal.esm.js +7 -7
- package/dist/components/ui/overlay/portal.js +7 -7
- package/dist/components/ui/overlay/tooltip.esm.js +54 -39
- package/dist/components/ui/overlay/tooltip.js +54 -39
- package/dist/components/ui/overlay/types.esm.js +132 -131
- package/dist/components/ui/overlay/types.js +132 -131
- package/dist/components/ui/performance-demo.esm.js +135 -88
- package/dist/components/ui/performance-demo.js +135 -88
- package/dist/components/ui/semantic-input-system-demo.esm.js +117 -80
- package/dist/components/ui/semantic-input-system-demo.js +117 -80
- package/dist/components/ui/theme-customizer.esm.js +84 -52
- package/dist/components/ui/theme-customizer.js +84 -52
- package/dist/components/ui/theme-preview.esm.js +95 -43
- package/dist/components/ui/theme-preview.js +95 -43
- package/dist/components/ui/theme-switcher.esm.js +70 -44
- package/dist/components/ui/theme-switcher.js +70 -44
- package/dist/components/ui/theme-toggle.esm.js +3 -3
- package/dist/components/ui/theme-toggle.js +3 -3
- package/dist/components/ui/token-demo.esm.js +33 -21
- package/dist/components/ui/token-demo.js +33 -21
- package/dist/components/ui/touch-demo.esm.js +102 -73
- package/dist/components/ui/touch-demo.js +102 -73
- package/dist/components/ui/touch-friendly-interface-demo.esm.js +102 -64
- package/dist/components/ui/touch-friendly-interface-demo.js +102 -64
- package/dist/components/ui/touch-friendly-interface.esm.js +85 -61
- package/dist/components/ui/touch-friendly-interface.js +85 -61
- package/dist/hooks/use-accessibility-support.esm.js +115 -85
- package/dist/hooks/use-accessibility-support.js +115 -85
- package/dist/hooks/use-adaptive-layout.esm.js +56 -33
- package/dist/hooks/use-adaptive-layout.js +56 -33
- package/dist/hooks/use-advanced-patterns.esm.js +57 -42
- package/dist/hooks/use-advanced-patterns.js +57 -42
- package/dist/hooks/use-advanced-transition-system.esm.js +112 -71
- package/dist/hooks/use-advanced-transition-system.js +112 -71
- package/dist/hooks/use-animation-profile.esm.js +63 -34
- package/dist/hooks/use-animation-profile.js +63 -34
- package/dist/hooks/use-battery-animations.esm.js +80 -55
- package/dist/hooks/use-battery-animations.js +80 -55
- package/dist/hooks/use-battery-conscious-loading.esm.js +166 -123
- package/dist/hooks/use-battery-conscious-loading.js +166 -123
- package/dist/hooks/use-battery-optimization.esm.js +78 -55
- package/dist/hooks/use-battery-optimization.js +78 -55
- package/dist/hooks/use-battery-status.esm.js +73 -51
- package/dist/hooks/use-battery-status.js +73 -51
- package/dist/hooks/use-component-performance.esm.js +62 -47
- package/dist/hooks/use-component-performance.js +62 -47
- package/dist/hooks/use-device-loading-states.esm.js +152 -109
- package/dist/hooks/use-device-loading-states.js +152 -109
- package/dist/hooks/use-device.esm.js +25 -14
- package/dist/hooks/use-device.js +25 -14
- package/dist/hooks/use-enterprise-mobile-experience.esm.js +137 -88
- package/dist/hooks/use-enterprise-mobile-experience.js +137 -88
- package/dist/hooks/use-form-feedback.esm.js +124 -81
- package/dist/hooks/use-form-feedback.js +124 -81
- package/dist/hooks/use-form-performance.esm.js +127 -92
- package/dist/hooks/use-form-performance.js +127 -92
- package/dist/hooks/use-frame-rate.esm.js +56 -37
- package/dist/hooks/use-frame-rate.js +56 -37
- package/dist/hooks/use-gestures.esm.js +96 -72
- package/dist/hooks/use-gestures.js +96 -72
- package/dist/hooks/use-hardware-acceleration.esm.js +65 -37
- package/dist/hooks/use-hardware-acceleration.js +65 -37
- package/dist/hooks/use-input-accessibility.esm.js +157 -119
- package/dist/hooks/use-input-accessibility.js +157 -119
- package/dist/hooks/use-input-performance.esm.js +139 -104
- package/dist/hooks/use-input-performance.js +139 -104
- package/dist/hooks/use-layout-performance.esm.js +50 -29
- package/dist/hooks/use-layout-performance.js +50 -29
- package/dist/hooks/use-loading-accessibility.esm.js +209 -169
- package/dist/hooks/use-loading-accessibility.js +209 -169
- package/dist/hooks/use-loading-performance.esm.js +117 -93
- package/dist/hooks/use-loading-performance.js +117 -93
- package/dist/hooks/use-memory-usage.esm.js +57 -38
- package/dist/hooks/use-memory-usage.js +57 -38
- package/dist/hooks/use-mobile-form-layout.esm.js +111 -74
- package/dist/hooks/use-mobile-form-layout.js +111 -74
- package/dist/hooks/use-mobile-form-validation.esm.js +211 -144
- package/dist/hooks/use-mobile-form-validation.js +211 -144
- package/dist/hooks/use-mobile-keyboard-optimization.esm.js +154 -113
- package/dist/hooks/use-mobile-keyboard-optimization.js +154 -113
- package/dist/hooks/use-mobile-layout.esm.js +73 -51
- package/dist/hooks/use-mobile-layout.js +73 -51
- package/dist/hooks/use-mobile-optimization.esm.js +72 -44
- package/dist/hooks/use-mobile-optimization.js +72 -44
- package/dist/hooks/use-mobile-skeleton.esm.js +97 -64
- package/dist/hooks/use-mobile-skeleton.js +97 -64
- package/dist/hooks/use-mobile-touch.esm.js +128 -93
- package/dist/hooks/use-mobile-touch.js +128 -93
- package/dist/hooks/use-performance-throttling.esm.js +72 -48
- package/dist/hooks/use-performance-throttling.js +72 -48
- package/dist/hooks/use-performance.esm.js +90 -52
- package/dist/hooks/use-performance.js +90 -52
- package/dist/hooks/use-reusable-architecture.esm.js +94 -65
- package/dist/hooks/use-reusable-architecture.js +94 -65
- package/dist/hooks/use-semantic-input-types.esm.js +166 -124
- package/dist/hooks/use-semantic-input-types.js +166 -124
- package/dist/hooks/use-semantic-input.esm.js +178 -126
- package/dist/hooks/use-semantic-input.js +178 -126
- package/dist/hooks/use-tablet-layout.esm.js +67 -38
- package/dist/hooks/use-tablet-layout.js +67 -38
- package/dist/hooks/use-touch-friendly-input.esm.js +193 -149
- package/dist/hooks/use-touch-friendly-input.js +193 -149
- package/dist/hooks/use-touch-friendly-interface.esm.js +99 -67
- package/dist/hooks/use-touch-friendly-interface.js +99 -67
- package/dist/hooks/use-touch-optimization.esm.js +99 -72
- package/dist/hooks/use-touch-optimization.js +99 -72
- package/dist/index.esm.js +289 -280
- package/dist/index.js +289 -280
- package/dist/lib/utils.esm.js +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/plugins/theme-css-generator.esm.js +104 -55
- package/dist/plugins/theme-css-generator.js +104 -55
- package/dist/provider.esm.js +4 -4
- package/dist/provider.js +4 -4
- package/dist/styles.css +1 -1
- package/dist/theme.esm.js +633 -468
- package/dist/theme.js +633 -468
- package/dist/themes/ThemeContext.esm.js +15 -15
- package/dist/themes/ThemeContext.js +15 -15
- package/dist/themes/ThemeProvider.esm.js +25 -22
- package/dist/themes/ThemeProvider.js +25 -22
- package/dist/themes/accessibility.esm.js +147 -108
- package/dist/themes/accessibility.js +147 -108
- package/dist/themes/aria-patterns.esm.js +198 -162
- package/dist/themes/aria-patterns.js +198 -162
- package/dist/themes/base-themes.esm.js +14 -11
- package/dist/themes/base-themes.js +14 -11
- package/dist/themes/colorManager.esm.js +101 -83
- package/dist/themes/colorManager.js +101 -83
- package/dist/themes/examples/dark-theme.esm.js +133 -103
- package/dist/themes/examples/dark-theme.js +133 -103
- package/dist/themes/examples/minimal-theme.esm.js +83 -61
- package/dist/themes/examples/minimal-theme.js +83 -61
- package/dist/themes/focus-management.esm.js +202 -143
- package/dist/themes/focus-management.js +202 -143
- package/dist/themes/fontLoader.esm.js +28 -19
- package/dist/themes/fontLoader.js +28 -19
- package/dist/themes/high-contrast.esm.js +152 -104
- package/dist/themes/high-contrast.js +152 -104
- package/dist/themes/inheritance.esm.js +35 -27
- package/dist/themes/inheritance.js +35 -27
- package/dist/themes/keyboard-navigation.esm.js +152 -123
- package/dist/themes/keyboard-navigation.js +152 -123
- package/dist/themes/motion-reduction.esm.js +193 -133
- package/dist/themes/motion-reduction.js +193 -133
- package/dist/themes/navigation.esm.js +146 -146
- package/dist/themes/navigation.js +146 -146
- package/dist/themes/screen-reader.esm.js +159 -94
- package/dist/themes/screen-reader.js +159 -94
- package/dist/themes/systemThemeDetector.esm.js +42 -34
- package/dist/themes/systemThemeDetector.js +42 -34
- package/dist/themes/themeCSSUpdater.esm.js +21 -9
- package/dist/themes/themeCSSUpdater.js +21 -9
- package/dist/themes/themePersistence.esm.js +68 -47
- package/dist/themes/themePersistence.js +68 -47
- package/dist/themes/themes/stan-design.esm.js +633 -468
- package/dist/themes/themes/stan-design.js +633 -468
- package/dist/themes/types.esm.js +301 -287
- package/dist/themes/types.js +301 -287
- package/dist/themes/useSystemTheme.esm.js +4 -4
- package/dist/themes/useSystemTheme.js +4 -4
- package/dist/themes/useTheme.esm.js +4 -4
- package/dist/themes/useTheme.js +4 -4
- package/dist/themes/validation.esm.js +128 -77
- package/dist/themes/validation.js +128 -77
- package/dist/tokens/index.esm.js +15 -4
- package/dist/tokens/index.js +15 -4
- package/dist/tokens/tokenExporter.esm.js +87 -61
- package/dist/tokens/tokenExporter.js +87 -61
- package/dist/tokens/tokenGenerator.esm.js +86 -77
- package/dist/tokens/tokenGenerator.js +86 -77
- package/dist/tokens/tokenManager.esm.js +64 -51
- package/dist/tokens/tokenManager.js +64 -51
- package/dist/tokens/tokenValidator.esm.js +193 -147
- package/dist/tokens/tokenValidator.js +193 -147
- package/dist/tokens/types.esm.js +49 -35
- package/dist/tokens/types.js +49 -35
- package/dist/utils/bundle-analyzer.esm.js +83 -65
- package/dist/utils/bundle-analyzer.js +83 -65
- package/dist/utils/bundle-splitting.esm.js +142 -117
- package/dist/utils/bundle-splitting.js +142 -117
- package/dist/utils/lazy-loading.esm.js +132 -106
- package/dist/utils/lazy-loading.js +132 -106
- package/dist/utils/performance-monitor.esm.js +170 -129
- package/dist/utils/performance-monitor.js +170 -129
- package/dist/utils/tree-shaking.esm.js +69 -61
- package/dist/utils/tree-shaking.js +69 -61
- package/package.json +1 -1
- package/src/index.ts +146 -146
|
@@ -1,25 +1,49 @@
|
|
|
1
1
|
import { useState, useCallback, useRef, useEffect } from 'react'
|
|
2
2
|
|
|
3
3
|
export interface InputPerformanceConfig {
|
|
4
|
-
enablePerformanceMonitoring
|
|
4
|
+
enablePerformanceMonitoring?: boolean
|
|
5
|
+
enableEventOptimization?: boolean
|
|
6
|
+
enableMemoryManagement?: boolean
|
|
7
|
+
enableBatteryOptimization?: boolean
|
|
8
|
+
enableAutoOptimization?: boolean
|
|
9
|
+
performanceThreshold?: number
|
|
10
|
+
memoryThreshold?: number
|
|
11
|
+
batteryThreshold?: number
|
|
12
|
+
}
|
|
5
13
|
|
|
6
14
|
export interface InputPerformanceMetrics {
|
|
7
|
-
frameRate
|
|
15
|
+
frameRate: number
|
|
16
|
+
inputLatency: number
|
|
17
|
+
eventProcessingTime: number
|
|
18
|
+
memoryUsage: number
|
|
19
|
+
batteryLevel: number
|
|
20
|
+
inputEfficiency: number
|
|
21
|
+
optimizationScore: number
|
|
22
|
+
}
|
|
8
23
|
|
|
9
24
|
export interface PerformanceOptimization {
|
|
10
|
-
id
|
|
25
|
+
id: string
|
|
26
|
+
name: string
|
|
27
|
+
type: 'event' | 'memory' | 'battery' | 'performance' | 'accessibility'
|
|
28
|
+
applied: boolean
|
|
29
|
+
impact: 'low' | 'medium' | 'high'
|
|
30
|
+
description: string
|
|
31
|
+
performanceGain: number
|
|
32
|
+
memorySavings: number
|
|
33
|
+
batterySavings: number
|
|
34
|
+
}
|
|
11
35
|
|
|
12
36
|
export interface InputPerformanceCallbacks {
|
|
13
|
-
onPerformanceOptimized
|
|
14
|
-
onMemoryOptimized
|
|
15
|
-
onBatteryOptimized
|
|
16
|
-
onEventOptimized
|
|
17
|
-
onPerformanceThresholdExceeded
|
|
37
|
+
onPerformanceOptimized?: (optimization: PerformanceOptimization) => void
|
|
38
|
+
onMemoryOptimized?: (optimization: string) => void
|
|
39
|
+
onBatteryOptimized?: (strategy: string) => void
|
|
40
|
+
onEventOptimized?: (optimization: string) => void
|
|
41
|
+
onPerformanceThresholdExceeded?: (metric: string, value: number, threshold: number) => void
|
|
18
42
|
}
|
|
19
43
|
|
|
20
44
|
export const useInputPerformance = (
|
|
21
|
-
config= {},
|
|
22
|
-
callbacks= {}
|
|
45
|
+
config: InputPerformanceConfig = {},
|
|
46
|
+
callbacks: InputPerformanceCallbacks = {}
|
|
23
47
|
) => {
|
|
24
48
|
const {
|
|
25
49
|
enablePerformanceMonitoring = true,
|
|
@@ -33,13 +57,14 @@ export const useInputPerformance = (
|
|
|
33
57
|
} = config
|
|
34
58
|
|
|
35
59
|
const [performanceMetrics, setPerformanceMetrics] = useState<InputPerformanceMetrics>({
|
|
36
|
-
frameRate,
|
|
37
|
-
inputLatency,
|
|
38
|
-
eventProcessingTime,
|
|
39
|
-
memoryUsage,
|
|
40
|
-
batteryLevel,
|
|
41
|
-
inputEfficiency,
|
|
42
|
-
optimizationScore
|
|
60
|
+
frameRate: 60,
|
|
61
|
+
inputLatency: 0,
|
|
62
|
+
eventProcessingTime: 0,
|
|
63
|
+
memoryUsage: 0,
|
|
64
|
+
batteryLevel: 1,
|
|
65
|
+
inputEfficiency: 100,
|
|
66
|
+
optimizationScore: 100
|
|
67
|
+
})
|
|
43
68
|
|
|
44
69
|
const [optimizations, setOptimizations] = useState<PerformanceOptimization[]>([])
|
|
45
70
|
const [isOptimizing, setIsOptimizing] = useState(false)
|
|
@@ -68,7 +93,7 @@ export const useInputPerformance = (
|
|
|
68
93
|
|
|
69
94
|
setPerformanceMetrics(prev => ({
|
|
70
95
|
...prev,
|
|
71
|
-
frameRate,
|
|
96
|
+
frameRate: fps,
|
|
72
97
|
inputLatency
|
|
73
98
|
}))
|
|
74
99
|
|
|
@@ -105,7 +130,7 @@ export const useInputPerformance = (
|
|
|
105
130
|
|
|
106
131
|
setPerformanceMetrics(prev => ({
|
|
107
132
|
...prev,
|
|
108
|
-
memoryUsage) / 100
|
|
133
|
+
memoryUsage: Math.round(usedMemory * 100) / 100
|
|
109
134
|
}))
|
|
110
135
|
|
|
111
136
|
// Check memory threshold
|
|
@@ -114,7 +139,7 @@ export const useInputPerformance = (
|
|
|
114
139
|
}
|
|
115
140
|
}
|
|
116
141
|
} catch (error) {
|
|
117
|
-
console.warn('Memory monitoring failed, error)
|
|
142
|
+
console.warn('Memory monitoring failed:', error)
|
|
118
143
|
}
|
|
119
144
|
}
|
|
120
145
|
|
|
@@ -139,7 +164,8 @@ export const useInputPerformance = (
|
|
|
139
164
|
|
|
140
165
|
setPerformanceMetrics(prev => ({
|
|
141
166
|
...prev,
|
|
142
|
-
batteryLevel
|
|
167
|
+
batteryLevel: level
|
|
168
|
+
}))
|
|
143
169
|
|
|
144
170
|
// Check battery threshold
|
|
145
171
|
if (level < batteryThreshold) {
|
|
@@ -147,7 +173,7 @@ export const useInputPerformance = (
|
|
|
147
173
|
}
|
|
148
174
|
}
|
|
149
175
|
} catch (error) {
|
|
150
|
-
console.warn('Battery monitoring failed, error)
|
|
176
|
+
console.warn('Battery monitoring failed:', error)
|
|
151
177
|
}
|
|
152
178
|
}
|
|
153
179
|
|
|
@@ -167,27 +193,29 @@ export const useInputPerformance = (
|
|
|
167
193
|
setIsOptimizing(true)
|
|
168
194
|
|
|
169
195
|
setTimeout(() => {
|
|
170
|
-
const eventOptimizations] = [
|
|
196
|
+
const eventOptimizations: PerformanceOptimization[] = [
|
|
171
197
|
{
|
|
172
|
-
id,
|
|
173
|
-
name,
|
|
174
|
-
type,
|
|
175
|
-
applied,
|
|
176
|
-
impact,
|
|
177
|
-
description,
|
|
178
|
-
performanceGain,
|
|
179
|
-
memorySavings,
|
|
180
|
-
batterySavings
|
|
198
|
+
id: 'event-1',
|
|
199
|
+
name: 'Input Event Optimization',
|
|
200
|
+
type: 'event',
|
|
201
|
+
applied: true,
|
|
202
|
+
impact: 'high',
|
|
203
|
+
description: 'Optimized input event handling for better performance',
|
|
204
|
+
performanceGain: 25,
|
|
205
|
+
memorySavings: 15,
|
|
206
|
+
batterySavings: 10
|
|
207
|
+
},
|
|
181
208
|
{
|
|
182
|
-
id,
|
|
183
|
-
name,
|
|
184
|
-
type,
|
|
185
|
-
applied,
|
|
186
|
-
impact,
|
|
187
|
-
description,
|
|
188
|
-
performanceGain,
|
|
189
|
-
memorySavings,
|
|
190
|
-
batterySavings
|
|
209
|
+
id: 'event-2',
|
|
210
|
+
name: 'Event Debouncing',
|
|
211
|
+
type: 'event',
|
|
212
|
+
applied: true,
|
|
213
|
+
impact: 'medium',
|
|
214
|
+
description: 'Implemented event debouncing to reduce processing overhead',
|
|
215
|
+
performanceGain: 20,
|
|
216
|
+
memorySavings: 10,
|
|
217
|
+
batterySavings: 15
|
|
218
|
+
}
|
|
191
219
|
]
|
|
192
220
|
|
|
193
221
|
setOptimizations(prev => [...prev, ...eventOptimizations])
|
|
@@ -208,27 +236,29 @@ export const useInputPerformance = (
|
|
|
208
236
|
setIsOptimizing(true)
|
|
209
237
|
|
|
210
238
|
setTimeout(() => {
|
|
211
|
-
const memoryOptimizations] = [
|
|
239
|
+
const memoryOptimizations: PerformanceOptimization[] = [
|
|
212
240
|
{
|
|
213
|
-
id,
|
|
214
|
-
name,
|
|
215
|
-
type,
|
|
216
|
-
applied,
|
|
217
|
-
impact,
|
|
218
|
-
description,
|
|
219
|
-
performanceGain,
|
|
220
|
-
memorySavings,
|
|
221
|
-
batterySavings
|
|
241
|
+
id: 'memory-1',
|
|
242
|
+
name: 'Memory Usage Optimization',
|
|
243
|
+
type: 'memory',
|
|
244
|
+
applied: true,
|
|
245
|
+
impact: 'high',
|
|
246
|
+
description: 'Optimized memory usage for input processing',
|
|
247
|
+
performanceGain: 15,
|
|
248
|
+
memorySavings: 30,
|
|
249
|
+
batterySavings: 20
|
|
250
|
+
},
|
|
222
251
|
{
|
|
223
|
-
id,
|
|
224
|
-
name,
|
|
225
|
-
type,
|
|
226
|
-
applied,
|
|
227
|
-
impact,
|
|
228
|
-
description,
|
|
229
|
-
performanceGain,
|
|
230
|
-
memorySavings,
|
|
231
|
-
batterySavings
|
|
252
|
+
id: 'memory-2',
|
|
253
|
+
name: 'Garbage Collection Optimization',
|
|
254
|
+
type: 'memory',
|
|
255
|
+
applied: true,
|
|
256
|
+
impact: 'medium',
|
|
257
|
+
description: 'Enhanced garbage collection for input events',
|
|
258
|
+
performanceGain: 10,
|
|
259
|
+
memorySavings: 25,
|
|
260
|
+
batterySavings: 15
|
|
261
|
+
}
|
|
232
262
|
]
|
|
233
263
|
|
|
234
264
|
setOptimizations(prev => [...prev, ...memoryOptimizations])
|
|
@@ -249,27 +279,29 @@ export const useInputPerformance = (
|
|
|
249
279
|
setIsOptimizing(true)
|
|
250
280
|
|
|
251
281
|
setTimeout(() => {
|
|
252
|
-
const batteryOptimizations] = [
|
|
282
|
+
const batteryOptimizations: PerformanceOptimization[] = [
|
|
253
283
|
{
|
|
254
|
-
id,
|
|
255
|
-
name,
|
|
256
|
-
type,
|
|
257
|
-
applied,
|
|
258
|
-
impact,
|
|
259
|
-
description,
|
|
260
|
-
performanceGain,
|
|
261
|
-
memorySavings,
|
|
262
|
-
batterySavings
|
|
284
|
+
id: 'battery-1',
|
|
285
|
+
name: 'Battery-Conscious Input Processing',
|
|
286
|
+
type: 'battery',
|
|
287
|
+
applied: true,
|
|
288
|
+
impact: 'medium',
|
|
289
|
+
description: 'Optimized input processing for battery efficiency',
|
|
290
|
+
performanceGain: 10,
|
|
291
|
+
memorySavings: 15,
|
|
292
|
+
batterySavings: 30
|
|
293
|
+
},
|
|
263
294
|
{
|
|
264
|
-
id,
|
|
265
|
-
name,
|
|
266
|
-
type,
|
|
267
|
-
applied,
|
|
268
|
-
impact,
|
|
269
|
-
description,
|
|
270
|
-
performanceGain,
|
|
271
|
-
memorySavings,
|
|
272
|
-
batterySavings
|
|
295
|
+
id: 'battery-2',
|
|
296
|
+
name: 'Power-Efficient Event Handling',
|
|
297
|
+
type: 'battery',
|
|
298
|
+
applied: true,
|
|
299
|
+
impact: 'low',
|
|
300
|
+
description: 'Implemented power-efficient event handling strategies',
|
|
301
|
+
performanceGain: 5,
|
|
302
|
+
memorySavings: 10,
|
|
303
|
+
batterySavings: 25
|
|
304
|
+
}
|
|
273
305
|
]
|
|
274
306
|
|
|
275
307
|
setOptimizations(prev => [...prev, ...batteryOptimizations])
|
|
@@ -290,27 +322,29 @@ export const useInputPerformance = (
|
|
|
290
322
|
setIsOptimizing(true)
|
|
291
323
|
|
|
292
324
|
setTimeout(() => {
|
|
293
|
-
const performanceOptimizations] = [
|
|
325
|
+
const performanceOptimizations: PerformanceOptimization[] = [
|
|
294
326
|
{
|
|
295
|
-
id,
|
|
296
|
-
name,
|
|
297
|
-
type,
|
|
298
|
-
applied,
|
|
299
|
-
impact,
|
|
300
|
-
description,
|
|
301
|
-
performanceGain,
|
|
302
|
-
memorySavings,
|
|
303
|
-
batterySavings
|
|
327
|
+
id: 'performance-1',
|
|
328
|
+
name: 'Overall Performance Enhancement',
|
|
329
|
+
type: 'performance',
|
|
330
|
+
applied: true,
|
|
331
|
+
impact: 'high',
|
|
332
|
+
description: 'Comprehensive performance optimization for input handling',
|
|
333
|
+
performanceGain: 35,
|
|
334
|
+
memorySavings: 25,
|
|
335
|
+
batterySavings: 20
|
|
336
|
+
},
|
|
304
337
|
{
|
|
305
|
-
id,
|
|
306
|
-
name,
|
|
307
|
-
type,
|
|
308
|
-
applied,
|
|
309
|
-
impact,
|
|
310
|
-
description,
|
|
311
|
-
performanceGain,
|
|
312
|
-
memorySavings,
|
|
313
|
-
batterySavings
|
|
338
|
+
id: 'performance-2',
|
|
339
|
+
name: 'Input Efficiency Optimization',
|
|
340
|
+
type: 'performance',
|
|
341
|
+
applied: true,
|
|
342
|
+
impact: 'medium',
|
|
343
|
+
description: 'Enhanced input efficiency and responsiveness',
|
|
344
|
+
performanceGain: 25,
|
|
345
|
+
memorySavings: 20,
|
|
346
|
+
batterySavings: 15
|
|
347
|
+
}
|
|
314
348
|
]
|
|
315
349
|
|
|
316
350
|
setOptimizations(prev => [...prev, ...performanceOptimizations])
|
|
@@ -369,7 +403,8 @@ export const useInputPerformance = (
|
|
|
369
403
|
else if (inputEfficiency >= 70) score += 5
|
|
370
404
|
else score += 0
|
|
371
405
|
|
|
372
|
-
let health
|
|
406
|
+
let health: 'excellent' | 'good' | 'fair' | 'poor'
|
|
407
|
+
if (score >= 90) health = 'excellent'
|
|
373
408
|
else if (score >= 75) health = 'good'
|
|
374
409
|
else if (score >= 60) health = 'fair'
|
|
375
410
|
else health = 'poor'
|
|
@@ -434,7 +469,7 @@ export const useInputPerformance = (
|
|
|
434
469
|
autoOptimize,
|
|
435
470
|
|
|
436
471
|
// Utility functions
|
|
437
|
-
getPerformanceScore) => {
|
|
472
|
+
getPerformanceScore: () => {
|
|
438
473
|
const { frameRate, inputLatency, memoryUsage, batteryLevel, inputEfficiency } = performanceMetrics
|
|
439
474
|
let score = 0
|
|
440
475
|
if (frameRate >= 58) score += 25
|
|
@@ -444,9 +479,9 @@ export const useInputPerformance = (
|
|
|
444
479
|
if (inputEfficiency >= 90) score += 15
|
|
445
480
|
return score
|
|
446
481
|
},
|
|
447
|
-
isPerformanceOptimal) => performanceHealth === 'excellent' || performanceHealth === 'good',
|
|
448
|
-
getOptimizationRecommendations) => {
|
|
449
|
-
const recommendations] = []
|
|
482
|
+
isPerformanceOptimal: () => performanceHealth === 'excellent' || performanceHealth === 'good',
|
|
483
|
+
getOptimizationRecommendations: () => {
|
|
484
|
+
const recommendations: string[] = []
|
|
450
485
|
|
|
451
486
|
if (performanceMetrics.frameRate < 50) {
|
|
452
487
|
recommendations.push('Consider reducing input event complexity to improve frame rate')
|
|
@@ -460,7 +495,7 @@ export const useInputPerformance = (
|
|
|
460
495
|
|
|
461
496
|
return recommendations
|
|
462
497
|
},
|
|
463
|
-
clearOptimizations) => {
|
|
498
|
+
clearOptimizations: () => {
|
|
464
499
|
setOptimizations([])
|
|
465
500
|
setActiveOptimizations([])
|
|
466
501
|
}
|
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback, useRef } from 'react'
|
|
2
2
|
|
|
3
3
|
export interface LayoutPerformanceMetrics {
|
|
4
|
-
renderTime
|
|
4
|
+
renderTime: number
|
|
5
|
+
layoutTime: number
|
|
6
|
+
memoryUsage: number
|
|
7
|
+
batteryLevel: number
|
|
8
|
+
fps: number
|
|
9
|
+
performanceScore: number
|
|
10
|
+
}
|
|
5
11
|
|
|
6
12
|
export interface LayoutPerformanceConfig {
|
|
7
|
-
enableLayoutCalculationOptimization
|
|
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
|
+
}
|
|
8
22
|
|
|
9
23
|
export interface LayoutPerformanceCallbacks {
|
|
10
|
-
onPerformanceWarning
|
|
11
|
-
onMemoryWarning
|
|
12
|
-
onBatteryWarning
|
|
13
|
-
onLayoutOptimization
|
|
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
|
|
14
28
|
}
|
|
15
29
|
|
|
16
30
|
export const useLayoutPerformance = (
|
|
17
|
-
config= {},
|
|
18
|
-
callbacks= {}
|
|
31
|
+
config: LayoutPerformanceConfig = {},
|
|
32
|
+
callbacks: LayoutPerformanceCallbacks = {}
|
|
19
33
|
) => {
|
|
20
34
|
const {
|
|
21
35
|
enableLayoutCalculationOptimization = true,
|
|
@@ -29,12 +43,13 @@ export const useLayoutPerformance = (
|
|
|
29
43
|
} = config
|
|
30
44
|
|
|
31
45
|
const [metrics, setMetrics] = useState<LayoutPerformanceMetrics>({
|
|
32
|
-
renderTime,
|
|
33
|
-
layoutTime,
|
|
34
|
-
memoryUsage,
|
|
35
|
-
batteryLevel,
|
|
36
|
-
fps,
|
|
37
|
-
performanceScore
|
|
46
|
+
renderTime: 0,
|
|
47
|
+
layoutTime: 0,
|
|
48
|
+
memoryUsage: 0,
|
|
49
|
+
batteryLevel: 1,
|
|
50
|
+
fps: 60,
|
|
51
|
+
performanceScore: 100
|
|
52
|
+
})
|
|
38
53
|
|
|
39
54
|
const [isOptimizing, setIsOptimizing] = useState(false)
|
|
40
55
|
const [optimizations, setOptimizations] = useState<string[]>([])
|
|
@@ -62,7 +77,7 @@ export const useLayoutPerformance = (
|
|
|
62
77
|
}, [])
|
|
63
78
|
|
|
64
79
|
// Layout calculation optimization
|
|
65
|
-
const optimizedLayoutCalculation = useCallback((callback) => void) => {
|
|
80
|
+
const optimizedLayoutCalculation = useCallback((callback: () => void) => {
|
|
66
81
|
if (!enableLayoutCalculationOptimization) {
|
|
67
82
|
callback()
|
|
68
83
|
return
|
|
@@ -90,7 +105,7 @@ export const useLayoutPerformance = (
|
|
|
90
105
|
const memory = (performance as any).memory
|
|
91
106
|
const usage = (memory.usedJSHeapSize / memory.jsHeapSizeLimit) * 100
|
|
92
107
|
|
|
93
|
-
setMetrics(prev => ({ ...prev, memoryUsage}))
|
|
108
|
+
setMetrics(prev => ({ ...prev, memoryUsage: usage }))
|
|
94
109
|
|
|
95
110
|
if (usage > memoryCleanupThreshold) {
|
|
96
111
|
callbacks.onMemoryWarning?.(usage, memoryCleanupThreshold)
|
|
@@ -130,14 +145,14 @@ export const useLayoutPerformance = (
|
|
|
130
145
|
const battery = await (navigator as any).getBattery()
|
|
131
146
|
const level = battery.level
|
|
132
147
|
|
|
133
|
-
setMetrics(prev => ({ ...prev, batteryLevel}))
|
|
148
|
+
setMetrics(prev => ({ ...prev, batteryLevel: level }))
|
|
134
149
|
|
|
135
150
|
if (level < batteryLowThreshold) {
|
|
136
151
|
callbacks.onBatteryWarning?.(level, true)
|
|
137
152
|
enableBatteryOptimizations()
|
|
138
153
|
}
|
|
139
154
|
} catch (error) {
|
|
140
|
-
console.warn('Battery API not available, error)
|
|
155
|
+
console.warn('Battery API not available:', error)
|
|
141
156
|
}
|
|
142
157
|
}, [enableBatteryOptimization, batteryLowThreshold, callbacks])
|
|
143
158
|
|
|
@@ -186,7 +201,7 @@ export const useLayoutPerformance = (
|
|
|
186
201
|
|
|
187
202
|
// Layout optimization suggestions
|
|
188
203
|
const getLayoutOptimizations = useCallback(() => {
|
|
189
|
-
const suggestions] = []
|
|
204
|
+
const suggestions: string[] = []
|
|
190
205
|
|
|
191
206
|
if (metrics.fps < fpsTarget * 0.8) {
|
|
192
207
|
suggestions.push('Reduce layout complexity to improve FPS')
|
|
@@ -208,22 +223,27 @@ export const useLayoutPerformance = (
|
|
|
208
223
|
}, [metrics, fpsTarget, memoryCleanupThreshold, batteryLowThreshold])
|
|
209
224
|
|
|
210
225
|
// Apply layout optimizations
|
|
211
|
-
const applyLayoutOptimizations = useCallback((optimizationType) => {
|
|
226
|
+
const applyLayoutOptimizations = useCallback((optimizationType: string) => {
|
|
212
227
|
setIsOptimizing(true)
|
|
213
228
|
|
|
214
229
|
setTimeout(() => {
|
|
215
230
|
let optimization = ''
|
|
216
231
|
|
|
217
232
|
switch (optimizationType) {
|
|
218
|
-
case 'reduce-layout-complexity'
|
|
233
|
+
case 'reduce-layout-complexity':
|
|
234
|
+
optimization = 'Layout complexity reduced - simplified DOM structure'
|
|
219
235
|
break
|
|
220
|
-
case 'virtual-scrolling'
|
|
236
|
+
case 'virtual-scrolling':
|
|
237
|
+
optimization = 'Virtual scrolling implemented for better performance'
|
|
221
238
|
break
|
|
222
|
-
case 'animation-optimization'
|
|
239
|
+
case 'animation-optimization':
|
|
240
|
+
optimization = 'Animations optimized for current device capabilities'
|
|
223
241
|
break
|
|
224
|
-
case 'touch-optimization'
|
|
242
|
+
case 'touch-optimization':
|
|
243
|
+
optimization = 'Touch events optimized for better responsiveness'
|
|
225
244
|
break
|
|
226
|
-
default
|
|
245
|
+
default:
|
|
246
|
+
optimization = 'Layout optimization applied'
|
|
227
247
|
}
|
|
228
248
|
|
|
229
249
|
setOptimizations(prev => [...prev, optimization])
|
|
@@ -289,10 +309,11 @@ export const useLayoutPerformance = (
|
|
|
289
309
|
applyLayoutOptimizations,
|
|
290
310
|
|
|
291
311
|
// Computed values
|
|
292
|
-
layoutOptimizations),
|
|
293
|
-
isPerformanceOptimal
|
|
294
|
-
isMemoryOptimal,
|
|
295
|
-
isBatteryOptimal
|
|
312
|
+
layoutOptimizations: getLayoutOptimizations(),
|
|
313
|
+
isPerformanceOptimal: metrics.performanceScore >= 80,
|
|
314
|
+
isMemoryOptimal: metrics.memoryUsage < memoryCleanupThreshold,
|
|
315
|
+
isBatteryOptimal: metrics.batteryLevel > batteryLowThreshold
|
|
316
|
+
}
|
|
296
317
|
}
|
|
297
318
|
|
|
298
319
|
export default useLayoutPerformance
|
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback, useRef } from 'react'
|
|
2
2
|
|
|
3
3
|
export interface LayoutPerformanceMetrics {
|
|
4
|
-
renderTime
|
|
4
|
+
renderTime: number
|
|
5
|
+
layoutTime: number
|
|
6
|
+
memoryUsage: number
|
|
7
|
+
batteryLevel: number
|
|
8
|
+
fps: number
|
|
9
|
+
performanceScore: number
|
|
10
|
+
}
|
|
5
11
|
|
|
6
12
|
export interface LayoutPerformanceConfig {
|
|
7
|
-
enableLayoutCalculationOptimization
|
|
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
|
+
}
|
|
8
22
|
|
|
9
23
|
export interface LayoutPerformanceCallbacks {
|
|
10
|
-
onPerformanceWarning
|
|
11
|
-
onMemoryWarning
|
|
12
|
-
onBatteryWarning
|
|
13
|
-
onLayoutOptimization
|
|
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
|
|
14
28
|
}
|
|
15
29
|
|
|
16
30
|
export const useLayoutPerformance = (
|
|
17
|
-
config= {},
|
|
18
|
-
callbacks= {}
|
|
31
|
+
config: LayoutPerformanceConfig = {},
|
|
32
|
+
callbacks: LayoutPerformanceCallbacks = {}
|
|
19
33
|
) => {
|
|
20
34
|
const {
|
|
21
35
|
enableLayoutCalculationOptimization = true,
|
|
@@ -29,12 +43,13 @@ export const useLayoutPerformance = (
|
|
|
29
43
|
} = config
|
|
30
44
|
|
|
31
45
|
const [metrics, setMetrics] = useState<LayoutPerformanceMetrics>({
|
|
32
|
-
renderTime,
|
|
33
|
-
layoutTime,
|
|
34
|
-
memoryUsage,
|
|
35
|
-
batteryLevel,
|
|
36
|
-
fps,
|
|
37
|
-
performanceScore
|
|
46
|
+
renderTime: 0,
|
|
47
|
+
layoutTime: 0,
|
|
48
|
+
memoryUsage: 0,
|
|
49
|
+
batteryLevel: 1,
|
|
50
|
+
fps: 60,
|
|
51
|
+
performanceScore: 100
|
|
52
|
+
})
|
|
38
53
|
|
|
39
54
|
const [isOptimizing, setIsOptimizing] = useState(false)
|
|
40
55
|
const [optimizations, setOptimizations] = useState<string[]>([])
|
|
@@ -62,7 +77,7 @@ export const useLayoutPerformance = (
|
|
|
62
77
|
}, [])
|
|
63
78
|
|
|
64
79
|
// Layout calculation optimization
|
|
65
|
-
const optimizedLayoutCalculation = useCallback((callback) => void) => {
|
|
80
|
+
const optimizedLayoutCalculation = useCallback((callback: () => void) => {
|
|
66
81
|
if (!enableLayoutCalculationOptimization) {
|
|
67
82
|
callback()
|
|
68
83
|
return
|
|
@@ -90,7 +105,7 @@ export const useLayoutPerformance = (
|
|
|
90
105
|
const memory = (performance as any).memory
|
|
91
106
|
const usage = (memory.usedJSHeapSize / memory.jsHeapSizeLimit) * 100
|
|
92
107
|
|
|
93
|
-
setMetrics(prev => ({ ...prev, memoryUsage}))
|
|
108
|
+
setMetrics(prev => ({ ...prev, memoryUsage: usage }))
|
|
94
109
|
|
|
95
110
|
if (usage > memoryCleanupThreshold) {
|
|
96
111
|
callbacks.onMemoryWarning?.(usage, memoryCleanupThreshold)
|
|
@@ -130,14 +145,14 @@ export const useLayoutPerformance = (
|
|
|
130
145
|
const battery = await (navigator as any).getBattery()
|
|
131
146
|
const level = battery.level
|
|
132
147
|
|
|
133
|
-
setMetrics(prev => ({ ...prev, batteryLevel}))
|
|
148
|
+
setMetrics(prev => ({ ...prev, batteryLevel: level }))
|
|
134
149
|
|
|
135
150
|
if (level < batteryLowThreshold) {
|
|
136
151
|
callbacks.onBatteryWarning?.(level, true)
|
|
137
152
|
enableBatteryOptimizations()
|
|
138
153
|
}
|
|
139
154
|
} catch (error) {
|
|
140
|
-
console.warn('Battery API not available, error)
|
|
155
|
+
console.warn('Battery API not available:', error)
|
|
141
156
|
}
|
|
142
157
|
}, [enableBatteryOptimization, batteryLowThreshold, callbacks])
|
|
143
158
|
|
|
@@ -186,7 +201,7 @@ export const useLayoutPerformance = (
|
|
|
186
201
|
|
|
187
202
|
// Layout optimization suggestions
|
|
188
203
|
const getLayoutOptimizations = useCallback(() => {
|
|
189
|
-
const suggestions] = []
|
|
204
|
+
const suggestions: string[] = []
|
|
190
205
|
|
|
191
206
|
if (metrics.fps < fpsTarget * 0.8) {
|
|
192
207
|
suggestions.push('Reduce layout complexity to improve FPS')
|
|
@@ -208,22 +223,27 @@ export const useLayoutPerformance = (
|
|
|
208
223
|
}, [metrics, fpsTarget, memoryCleanupThreshold, batteryLowThreshold])
|
|
209
224
|
|
|
210
225
|
// Apply layout optimizations
|
|
211
|
-
const applyLayoutOptimizations = useCallback((optimizationType) => {
|
|
226
|
+
const applyLayoutOptimizations = useCallback((optimizationType: string) => {
|
|
212
227
|
setIsOptimizing(true)
|
|
213
228
|
|
|
214
229
|
setTimeout(() => {
|
|
215
230
|
let optimization = ''
|
|
216
231
|
|
|
217
232
|
switch (optimizationType) {
|
|
218
|
-
case 'reduce-layout-complexity'
|
|
233
|
+
case 'reduce-layout-complexity':
|
|
234
|
+
optimization = 'Layout complexity reduced - simplified DOM structure'
|
|
219
235
|
break
|
|
220
|
-
case 'virtual-scrolling'
|
|
236
|
+
case 'virtual-scrolling':
|
|
237
|
+
optimization = 'Virtual scrolling implemented for better performance'
|
|
221
238
|
break
|
|
222
|
-
case 'animation-optimization'
|
|
239
|
+
case 'animation-optimization':
|
|
240
|
+
optimization = 'Animations optimized for current device capabilities'
|
|
223
241
|
break
|
|
224
|
-
case 'touch-optimization'
|
|
242
|
+
case 'touch-optimization':
|
|
243
|
+
optimization = 'Touch events optimized for better responsiveness'
|
|
225
244
|
break
|
|
226
|
-
default
|
|
245
|
+
default:
|
|
246
|
+
optimization = 'Layout optimization applied'
|
|
227
247
|
}
|
|
228
248
|
|
|
229
249
|
setOptimizations(prev => [...prev, optimization])
|
|
@@ -289,10 +309,11 @@ export const useLayoutPerformance = (
|
|
|
289
309
|
applyLayoutOptimizations,
|
|
290
310
|
|
|
291
311
|
// Computed values
|
|
292
|
-
layoutOptimizations),
|
|
293
|
-
isPerformanceOptimal
|
|
294
|
-
isMemoryOptimal,
|
|
295
|
-
isBatteryOptimal
|
|
312
|
+
layoutOptimizations: getLayoutOptimizations(),
|
|
313
|
+
isPerformanceOptimal: metrics.performanceScore >= 80,
|
|
314
|
+
isMemoryOptimal: metrics.memoryUsage < memoryCleanupThreshold,
|
|
315
|
+
isBatteryOptimal: metrics.batteryLevel > batteryLowThreshold
|
|
316
|
+
}
|
|
296
317
|
}
|
|
297
318
|
|
|
298
319
|
export default useLayoutPerformance
|