@rakeyshgidwani/roger-ui-bank-theme-stan-design 0.2.8 → 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,52 +1,73 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback, useRef } from 'react'
|
|
2
2
|
|
|
3
3
|
export interface PerformanceConfig {
|
|
4
|
-
enableValidationThrottling
|
|
4
|
+
enableValidationThrottling: boolean
|
|
5
|
+
enableTouchEventOptimization: boolean
|
|
6
|
+
enableMemoryManagement: boolean
|
|
7
|
+
enableBatteryOptimization: boolean
|
|
8
|
+
validationThrottleDelay: number
|
|
9
|
+
touchEventThrottleDelay: number
|
|
10
|
+
memoryCleanupInterval: number
|
|
11
|
+
performanceMonitoringInterval: number
|
|
12
|
+
}
|
|
5
13
|
|
|
6
14
|
export interface PerformanceCallbacks {
|
|
7
|
-
onPerformanceWarning
|
|
8
|
-
onMemoryWarning
|
|
9
|
-
onBatteryWarning
|
|
10
|
-
onOptimizationApplied
|
|
15
|
+
onPerformanceWarning?: (warning: string, metrics: PerformanceMetrics) => void
|
|
16
|
+
onMemoryWarning?: (usage: number, threshold: number) => void
|
|
17
|
+
onBatteryWarning?: (level: number, isLow: boolean) => void
|
|
18
|
+
onOptimizationApplied?: (type: string, success: boolean) => void
|
|
11
19
|
}
|
|
12
20
|
|
|
13
21
|
export interface PerformanceMetrics {
|
|
14
|
-
validationCount
|
|
22
|
+
validationCount: number
|
|
23
|
+
touchEventCount: number
|
|
24
|
+
memoryUsage: number
|
|
25
|
+
batteryLevel: number
|
|
26
|
+
isLowPowerMode: boolean
|
|
27
|
+
averageResponseTime: number
|
|
28
|
+
lastOptimization: number
|
|
29
|
+
optimizationScore: number
|
|
30
|
+
}
|
|
15
31
|
|
|
16
32
|
export interface FormPerformanceState {
|
|
17
|
-
isOptimized
|
|
18
|
-
|
|
19
|
-
|
|
33
|
+
isOptimized: boolean
|
|
34
|
+
currentOptimizations: string[]
|
|
35
|
+
performanceMetrics: PerformanceMetrics
|
|
36
|
+
warnings: string[]
|
|
37
|
+
lastUpdate: number
|
|
38
|
+
}
|
|
20
39
|
|
|
21
40
|
export const useFormPerformance = (
|
|
22
|
-
callbacks= {},
|
|
23
|
-
config= {}
|
|
41
|
+
callbacks: PerformanceCallbacks = {},
|
|
42
|
+
config: Partial<PerformanceConfig> = {}
|
|
24
43
|
) => {
|
|
25
|
-
const defaultConfig= {
|
|
26
|
-
enableValidationThrottling,
|
|
27
|
-
enableTouchEventOptimization,
|
|
28
|
-
enableMemoryManagement,
|
|
29
|
-
enableBatteryOptimization,
|
|
30
|
-
validationThrottleDelay,
|
|
31
|
-
touchEventThrottleDelay, // ~60fps
|
|
32
|
-
memoryCleanupInterval, // 30 seconds
|
|
33
|
-
performanceMonitoringInterval, // 5 seconds
|
|
44
|
+
const defaultConfig: PerformanceConfig = {
|
|
45
|
+
enableValidationThrottling: true,
|
|
46
|
+
enableTouchEventOptimization: true,
|
|
47
|
+
enableMemoryManagement: true,
|
|
48
|
+
enableBatteryOptimization: true,
|
|
49
|
+
validationThrottleDelay: 300,
|
|
50
|
+
touchEventThrottleDelay: 16, // ~60fps
|
|
51
|
+
memoryCleanupInterval: 30000, // 30 seconds
|
|
52
|
+
performanceMonitoringInterval: 5000, // 5 seconds
|
|
34
53
|
...config
|
|
35
54
|
}
|
|
36
55
|
|
|
37
56
|
const [performanceState, setPerformanceState] = useState<FormPerformanceState>({
|
|
38
|
-
isOptimized,
|
|
39
|
-
currentOptimizations],
|
|
40
|
-
performanceMetrics
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
isOptimized: false,
|
|
58
|
+
currentOptimizations: [],
|
|
59
|
+
performanceMetrics: {
|
|
60
|
+
validationCount: 0,
|
|
61
|
+
touchEventCount: 0,
|
|
62
|
+
memoryUsage: 0,
|
|
63
|
+
batteryLevel: 1,
|
|
64
|
+
isLowPowerMode: false,
|
|
65
|
+
averageResponseTime: 0,
|
|
66
|
+
lastOptimization: 0,
|
|
67
|
+
optimizationScore: 0
|
|
68
|
+
},
|
|
69
|
+
warnings: [],
|
|
70
|
+
lastUpdate: Date.now()
|
|
50
71
|
})
|
|
51
72
|
|
|
52
73
|
const validationThrottleTimerRef = useRef<NodeJS.Timeout | null>(null)
|
|
@@ -67,16 +88,18 @@ export const useFormPerformance = (
|
|
|
67
88
|
|
|
68
89
|
setPerformanceState(prev => ({
|
|
69
90
|
...prev,
|
|
70
|
-
performanceMetrics
|
|
71
|
-
|
|
72
|
-
|
|
91
|
+
performanceMetrics: {
|
|
92
|
+
...prev.performanceMetrics,
|
|
93
|
+
batteryLevel: battery.level,
|
|
94
|
+
isLowPowerMode: battery.level < 0.2
|
|
95
|
+
}
|
|
73
96
|
}))
|
|
74
97
|
|
|
75
98
|
if (battery.level < 0.2) {
|
|
76
99
|
callbacks.onBatteryWarning?.(battery.level, true)
|
|
77
100
|
}
|
|
78
101
|
} catch (error) {
|
|
79
|
-
console.warn('Battery API not supported, error)
|
|
102
|
+
console.warn('Battery API not supported:', error)
|
|
80
103
|
}
|
|
81
104
|
}, [defaultConfig.enableBatteryOptimization, callbacks])
|
|
82
105
|
|
|
@@ -90,8 +113,10 @@ export const useFormPerformance = (
|
|
|
90
113
|
|
|
91
114
|
setPerformanceState(prev => ({
|
|
92
115
|
...prev,
|
|
93
|
-
performanceMetrics
|
|
94
|
-
|
|
116
|
+
performanceMetrics: {
|
|
117
|
+
...prev.performanceMetrics,
|
|
118
|
+
memoryUsage: usage
|
|
119
|
+
}
|
|
95
120
|
}))
|
|
96
121
|
|
|
97
122
|
if (usage > 0.8) {
|
|
@@ -99,7 +124,7 @@ export const useFormPerformance = (
|
|
|
99
124
|
triggerMemoryCleanup()
|
|
100
125
|
}
|
|
101
126
|
} catch (error) {
|
|
102
|
-
console.warn('Memory API not supported, error)
|
|
127
|
+
console.warn('Memory API not supported:', error)
|
|
103
128
|
}
|
|
104
129
|
}, [defaultConfig.enableMemoryManagement, callbacks])
|
|
105
130
|
|
|
@@ -126,21 +151,22 @@ export const useFormPerformance = (
|
|
|
126
151
|
|
|
127
152
|
setPerformanceState(prev => ({
|
|
128
153
|
...prev,
|
|
129
|
-
currentOptimizations, 'memory-cleanup'],
|
|
130
|
-
lastUpdate)
|
|
154
|
+
currentOptimizations: [...prev.currentOptimizations, 'memory-cleanup'],
|
|
155
|
+
lastUpdate: Date.now()
|
|
131
156
|
}))
|
|
132
157
|
|
|
133
158
|
callbacks.onOptimizationApplied?.('memory-cleanup', true)
|
|
134
159
|
} catch (error) {
|
|
135
|
-
console.warn('Memory cleanup failed, error)
|
|
160
|
+
console.warn('Memory cleanup failed:', error)
|
|
136
161
|
callbacks.onOptimizationApplied?.('memory-cleanup', false)
|
|
137
162
|
}
|
|
138
163
|
}, [defaultConfig.enableMemoryManagement, callbacks])
|
|
139
164
|
|
|
140
165
|
// Validation throttling
|
|
141
166
|
const throttledValidation = useCallback((
|
|
142
|
-
validationFunction) => void,
|
|
143
|
-
delay
|
|
167
|
+
validationFunction: () => void,
|
|
168
|
+
delay?: number
|
|
169
|
+
) => {
|
|
144
170
|
if (!defaultConfig.enableValidationThrottling) {
|
|
145
171
|
validationFunction()
|
|
146
172
|
return
|
|
@@ -160,9 +186,10 @@ export const useFormPerformance = (
|
|
|
160
186
|
|
|
161
187
|
setPerformanceState(prev => ({
|
|
162
188
|
...prev,
|
|
163
|
-
performanceMetrics
|
|
164
|
-
|
|
165
|
-
|
|
189
|
+
performanceMetrics: {
|
|
190
|
+
...prev.performanceMetrics,
|
|
191
|
+
validationCount: prev.performanceMetrics.validationCount + 1,
|
|
192
|
+
averageResponseTime: (prev.performanceMetrics.averageResponseTime * prev.performanceMetrics.validationCount + responseTime) / (prev.performanceMetrics.validationCount + 1)
|
|
166
193
|
}
|
|
167
194
|
}))
|
|
168
195
|
}, throttleDelay)
|
|
@@ -170,8 +197,9 @@ export const useFormPerformance = (
|
|
|
170
197
|
|
|
171
198
|
// Touch event optimization
|
|
172
199
|
const optimizedTouchEvent = useCallback((
|
|
173
|
-
touchFunction) => void,
|
|
174
|
-
delay
|
|
200
|
+
touchFunction: () => void,
|
|
201
|
+
delay?: number
|
|
202
|
+
) => {
|
|
175
203
|
if (!defaultConfig.enableTouchEventOptimization) {
|
|
176
204
|
touchFunction()
|
|
177
205
|
return
|
|
@@ -188,14 +216,16 @@ export const useFormPerformance = (
|
|
|
188
216
|
|
|
189
217
|
setPerformanceState(prev => ({
|
|
190
218
|
...prev,
|
|
191
|
-
performanceMetrics
|
|
192
|
-
|
|
219
|
+
performanceMetrics: {
|
|
220
|
+
...prev.performanceMetrics,
|
|
221
|
+
touchEventCount: prev.performanceMetrics.touchEventCount + 1
|
|
222
|
+
}
|
|
193
223
|
}))
|
|
194
224
|
}, throttleDelay)
|
|
195
225
|
}, [defaultConfig.enableTouchEventOptimization, defaultConfig.touchEventThrottleDelay])
|
|
196
226
|
|
|
197
227
|
// Calculate performance score
|
|
198
|
-
const calculatePerformanceScore = useCallback(()=> {
|
|
228
|
+
const calculatePerformanceScore = useCallback((): number => {
|
|
199
229
|
const { performanceMetrics } = performanceState
|
|
200
230
|
let score = 0
|
|
201
231
|
|
|
@@ -238,7 +268,7 @@ export const useFormPerformance = (
|
|
|
238
268
|
|
|
239
269
|
// Apply performance optimizations
|
|
240
270
|
const applyOptimizations = useCallback(() => {
|
|
241
|
-
const optimizations] = []
|
|
271
|
+
const optimizations: string[] = []
|
|
242
272
|
let success = true
|
|
243
273
|
|
|
244
274
|
try {
|
|
@@ -276,17 +306,18 @@ export const useFormPerformance = (
|
|
|
276
306
|
setPerformanceState(prev => ({
|
|
277
307
|
...prev,
|
|
278
308
|
isOptimized,
|
|
279
|
-
currentOptimizations,
|
|
280
|
-
performanceMetrics
|
|
309
|
+
currentOptimizations: optimizations,
|
|
310
|
+
performanceMetrics: {
|
|
311
|
+
...prev.performanceMetrics,
|
|
281
312
|
optimizationScore,
|
|
282
|
-
lastOptimization)
|
|
313
|
+
lastOptimization: Date.now()
|
|
283
314
|
},
|
|
284
|
-
lastUpdate)
|
|
315
|
+
lastUpdate: Date.now()
|
|
285
316
|
}))
|
|
286
317
|
|
|
287
318
|
callbacks.onOptimizationApplied?.('performance', success)
|
|
288
319
|
} catch (error) {
|
|
289
|
-
console.error('Performance optimization failed, error)
|
|
320
|
+
console.error('Performance optimization failed:', error)
|
|
290
321
|
success = false
|
|
291
322
|
callbacks.onOptimizationApplied?.('performance', false)
|
|
292
323
|
}
|
|
@@ -309,10 +340,10 @@ export const useFormPerformance = (
|
|
|
309
340
|
|
|
310
341
|
const score = calculatePerformanceScore()
|
|
311
342
|
if (score < 0.5) {
|
|
312
|
-
const warning = `Performance score is low).toFixed(1)}%`
|
|
343
|
+
const warning = `Performance score is low: ${(score * 100).toFixed(1)}%`
|
|
313
344
|
setPerformanceState(prev => ({
|
|
314
345
|
...prev,
|
|
315
|
-
warnings, warning]
|
|
346
|
+
warnings: [...prev.warnings, warning]
|
|
316
347
|
}))
|
|
317
348
|
callbacks.onPerformanceWarning?.(warning, performanceState.performanceMetrics)
|
|
318
349
|
}
|
|
@@ -337,18 +368,20 @@ export const useFormPerformance = (
|
|
|
337
368
|
// Reset performance state
|
|
338
369
|
const resetPerformance = useCallback(() => {
|
|
339
370
|
setPerformanceState({
|
|
340
|
-
isOptimized,
|
|
341
|
-
currentOptimizations],
|
|
342
|
-
performanceMetrics
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
371
|
+
isOptimized: false,
|
|
372
|
+
currentOptimizations: [],
|
|
373
|
+
performanceMetrics: {
|
|
374
|
+
validationCount: 0,
|
|
375
|
+
touchEventCount: 0,
|
|
376
|
+
memoryUsage: 0,
|
|
377
|
+
batteryLevel: 1,
|
|
378
|
+
isLowPowerMode: false,
|
|
379
|
+
averageResponseTime: 0,
|
|
380
|
+
lastOptimization: 0,
|
|
381
|
+
optimizationScore: 0
|
|
382
|
+
},
|
|
383
|
+
warnings: [],
|
|
384
|
+
lastUpdate: Date.now()
|
|
352
385
|
})
|
|
353
386
|
}, [])
|
|
354
387
|
|
|
@@ -357,17 +390,17 @@ export const useFormPerformance = (
|
|
|
357
390
|
const { performanceMetrics, currentOptimizations, warnings } = performanceState
|
|
358
391
|
|
|
359
392
|
return {
|
|
360
|
-
metrics,
|
|
361
|
-
optimizations,
|
|
393
|
+
metrics: performanceMetrics,
|
|
394
|
+
optimizations: currentOptimizations,
|
|
362
395
|
warnings,
|
|
363
|
-
recommendations)
|
|
396
|
+
recommendations: getPerformanceRecommendations()
|
|
364
397
|
}
|
|
365
398
|
}, [performanceState])
|
|
366
399
|
|
|
367
400
|
// Get performance recommendations
|
|
368
401
|
const getPerformanceRecommendations = useCallback(() => {
|
|
369
402
|
const { performanceMetrics } = performanceState
|
|
370
|
-
const recommendations] = []
|
|
403
|
+
const recommendations: string[] = []
|
|
371
404
|
|
|
372
405
|
if (performanceMetrics.averageResponseTime > 200) {
|
|
373
406
|
recommendations.push('Consider increasing validation throttle delay')
|
|
@@ -454,25 +487,27 @@ export const useFormPerformance = (
|
|
|
454
487
|
// Convenience hook for basic performance optimization
|
|
455
488
|
export const useBasicFormPerformance = () => {
|
|
456
489
|
return useFormPerformance({}, {
|
|
457
|
-
enableValidationThrottling,
|
|
458
|
-
enableTouchEventOptimization,
|
|
459
|
-
enableMemoryManagement,
|
|
460
|
-
enableBatteryOptimization,
|
|
461
|
-
validationThrottleDelay,
|
|
462
|
-
touchEventThrottleDelay,
|
|
463
|
-
memoryCleanupInterval,
|
|
464
|
-
performanceMonitoringInterval
|
|
490
|
+
enableValidationThrottling: true,
|
|
491
|
+
enableTouchEventOptimization: false,
|
|
492
|
+
enableMemoryManagement: false,
|
|
493
|
+
enableBatteryOptimization: false,
|
|
494
|
+
validationThrottleDelay: 500,
|
|
495
|
+
touchEventThrottleDelay: 32,
|
|
496
|
+
memoryCleanupInterval: 60000,
|
|
497
|
+
performanceMonitoringInterval: 10000
|
|
498
|
+
})
|
|
465
499
|
}
|
|
466
500
|
|
|
467
501
|
// Convenience hook for enhanced performance optimization
|
|
468
502
|
export const useEnhancedFormPerformance = () => {
|
|
469
503
|
return useFormPerformance({}, {
|
|
470
|
-
enableValidationThrottling,
|
|
471
|
-
enableTouchEventOptimization,
|
|
472
|
-
enableMemoryManagement,
|
|
473
|
-
enableBatteryOptimization,
|
|
474
|
-
validationThrottleDelay,
|
|
475
|
-
touchEventThrottleDelay,
|
|
476
|
-
memoryCleanupInterval,
|
|
477
|
-
performanceMonitoringInterval
|
|
504
|
+
enableValidationThrottling: true,
|
|
505
|
+
enableTouchEventOptimization: true,
|
|
506
|
+
enableMemoryManagement: true,
|
|
507
|
+
enableBatteryOptimization: true,
|
|
508
|
+
validationThrottleDelay: 300,
|
|
509
|
+
touchEventThrottleDelay: 16,
|
|
510
|
+
memoryCleanupInterval: 30000,
|
|
511
|
+
performanceMonitoringInterval: 5000
|
|
512
|
+
})
|
|
478
513
|
}
|
|
@@ -1,28 +1,44 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback, useRef, useMemo } from 'react'
|
|
2
2
|
|
|
3
3
|
export interface FrameRateMetrics {
|
|
4
|
-
fps
|
|
4
|
+
fps: number
|
|
5
|
+
frameTime: number
|
|
6
|
+
frameCount: number
|
|
7
|
+
averageFPS: number
|
|
8
|
+
minFPS: number
|
|
9
|
+
maxFPS: number
|
|
10
|
+
droppedFrames: number
|
|
11
|
+
performanceScore: 'excellent' | 'good' | 'fair' | 'poor'
|
|
12
|
+
}
|
|
5
13
|
|
|
6
14
|
export interface FrameRateThresholds {
|
|
7
|
-
warning
|
|
15
|
+
warning: number
|
|
16
|
+
critical: number
|
|
17
|
+
excellent: number
|
|
18
|
+
}
|
|
8
19
|
|
|
9
20
|
export interface FrameRateCallbacks {
|
|
10
|
-
onFPSWarning
|
|
11
|
-
onFPSDrop
|
|
12
|
-
onPerformanceScoreChange
|
|
21
|
+
onFPSWarning?: (fps: number) => void
|
|
22
|
+
onFPSDrop?: (fps: number, previousFPS: number) => void
|
|
23
|
+
onPerformanceScoreChange?: (score: FrameRateMetrics['performanceScore']) => void
|
|
13
24
|
}
|
|
14
25
|
|
|
15
26
|
export interface FrameRateOptions {
|
|
16
|
-
updateInterval
|
|
27
|
+
updateInterval?: number
|
|
28
|
+
sampleSize?: number
|
|
29
|
+
thresholds?: Partial<FrameRateThresholds>
|
|
30
|
+
callbacks?: FrameRateCallbacks
|
|
31
|
+
}
|
|
17
32
|
|
|
18
|
-
const DEFAULT_THRESHOLDS= {
|
|
19
|
-
warning,
|
|
20
|
-
critical,
|
|
21
|
-
excellent
|
|
33
|
+
const DEFAULT_THRESHOLDS: FrameRateThresholds = {
|
|
34
|
+
warning: 45,
|
|
35
|
+
critical: 30,
|
|
36
|
+
excellent: 55
|
|
37
|
+
}
|
|
22
38
|
|
|
23
39
|
const DEFAULT_SAMPLE_SIZE = 60 // 1 second at 60fps
|
|
24
40
|
|
|
25
|
-
export const useFrameRate = (options= {}) => {
|
|
41
|
+
export const useFrameRate = (options: FrameRateOptions = {}) => {
|
|
26
42
|
const {
|
|
27
43
|
updateInterval = 1000,
|
|
28
44
|
sampleSize = DEFAULT_SAMPLE_SIZE,
|
|
@@ -31,14 +47,15 @@ export const useFrameRate = (options= {}) => {
|
|
|
31
47
|
} = options
|
|
32
48
|
|
|
33
49
|
const [metrics, setMetrics] = useState<FrameRateMetrics>({
|
|
34
|
-
fps,
|
|
35
|
-
frameTime,
|
|
36
|
-
frameCount,
|
|
37
|
-
averageFPS,
|
|
38
|
-
minFPS,
|
|
39
|
-
maxFPS,
|
|
40
|
-
droppedFrames,
|
|
41
|
-
performanceScore
|
|
50
|
+
fps: 60,
|
|
51
|
+
frameTime: 16.67,
|
|
52
|
+
frameCount: 0,
|
|
53
|
+
averageFPS: 60,
|
|
54
|
+
minFPS: 60,
|
|
55
|
+
maxFPS: 60,
|
|
56
|
+
droppedFrames: 0,
|
|
57
|
+
performanceScore: 'excellent'
|
|
58
|
+
})
|
|
42
59
|
|
|
43
60
|
const [isMonitoring, setIsMonitoring] = useState(false)
|
|
44
61
|
const frameCountRef = useRef(0)
|
|
@@ -55,7 +72,7 @@ export const useFrameRate = (options= {}) => {
|
|
|
55
72
|
}), [thresholds])
|
|
56
73
|
|
|
57
74
|
// Calculate performance score based on FPS
|
|
58
|
-
const calculatePerformanceScore = useCallback((fps)] => {
|
|
75
|
+
const calculatePerformanceScore = useCallback((fps: number): FrameRateMetrics['performanceScore'] => {
|
|
59
76
|
if (fps >= finalThresholds.excellent) return 'excellent'
|
|
60
77
|
if (fps >= finalThresholds.warning) return 'good'
|
|
61
78
|
if (fps >= finalThresholds.critical) return 'fair'
|
|
@@ -63,7 +80,7 @@ export const useFrameRate = (options= {}) => {
|
|
|
63
80
|
}, [finalThresholds])
|
|
64
81
|
|
|
65
82
|
// Update FPS history and calculate statistics
|
|
66
|
-
const updateFPSHistory = useCallback((fps) => {
|
|
83
|
+
const updateFPSHistory = useCallback((fps: number) => {
|
|
67
84
|
fpsHistoryRef.current.push(fps)
|
|
68
85
|
|
|
69
86
|
// Keep only the last sampleSize frames
|
|
@@ -82,7 +99,7 @@ export const useFrameRate = (options= {}) => {
|
|
|
82
99
|
}, [sampleSize])
|
|
83
100
|
|
|
84
101
|
// Detect dropped frames
|
|
85
|
-
const detectDroppedFrames = useCallback((fps, previousFPS) => {
|
|
102
|
+
const detectDroppedFrames = useCallback((fps: number, previousFPS: number) => {
|
|
86
103
|
if (fps < previousFPS && previousFPS >= finalThresholds.warning) {
|
|
87
104
|
const drop = previousFPS - fps
|
|
88
105
|
if (drop > 10) { // Significant drop
|
|
@@ -110,10 +127,10 @@ export const useFrameRate = (options= {}) => {
|
|
|
110
127
|
// Calculate performance score
|
|
111
128
|
const performanceScore = calculatePerformanceScore(fps)
|
|
112
129
|
|
|
113
|
-
const newMetrics= {
|
|
130
|
+
const newMetrics: FrameRateMetrics = {
|
|
114
131
|
fps,
|
|
115
132
|
frameTime,
|
|
116
|
-
frameCount,
|
|
133
|
+
frameCount: frameCountRef.current,
|
|
117
134
|
averageFPS,
|
|
118
135
|
minFPS,
|
|
119
136
|
maxFPS,
|
|
@@ -172,10 +189,11 @@ export const useFrameRate = (options= {}) => {
|
|
|
172
189
|
fpsHistoryRef.current = []
|
|
173
190
|
setMetrics(prev => ({
|
|
174
191
|
...prev,
|
|
175
|
-
averageFPS,
|
|
176
|
-
minFPS,
|
|
177
|
-
maxFPS,
|
|
178
|
-
droppedFrames
|
|
192
|
+
averageFPS: 60,
|
|
193
|
+
minFPS: 60,
|
|
194
|
+
maxFPS: 60,
|
|
195
|
+
droppedFrames: 0
|
|
196
|
+
}))
|
|
179
197
|
}, [])
|
|
180
198
|
|
|
181
199
|
// Auto-start monitoring on mount
|
|
@@ -186,7 +204,7 @@ export const useFrameRate = (options= {}) => {
|
|
|
186
204
|
|
|
187
205
|
// Performance insights
|
|
188
206
|
const getPerformanceInsights = useCallback(() => {
|
|
189
|
-
const insights] = []
|
|
207
|
+
const insights: string[] = []
|
|
190
208
|
|
|
191
209
|
if (metrics.fps < finalThresholds.critical) {
|
|
192
210
|
insights.push('Critical FPS drop detected - consider reducing animation complexity')
|
|
@@ -216,17 +234,18 @@ export const useFrameRate = (options= {}) => {
|
|
|
216
234
|
resetStats,
|
|
217
235
|
|
|
218
236
|
// Performance analysis
|
|
219
|
-
performanceScore,
|
|
237
|
+
performanceScore: metrics.performanceScore,
|
|
220
238
|
getPerformanceInsights,
|
|
221
239
|
|
|
222
240
|
// Raw values
|
|
223
|
-
fps,
|
|
224
|
-
frameTime,
|
|
225
|
-
averageFPS,
|
|
226
|
-
minFPS,
|
|
227
|
-
maxFPS,
|
|
228
|
-
droppedFrames,
|
|
241
|
+
fps: metrics.fps,
|
|
242
|
+
frameTime: metrics.frameTime,
|
|
243
|
+
averageFPS: metrics.averageFPS,
|
|
244
|
+
minFPS: metrics.minFPS,
|
|
245
|
+
maxFPS: metrics.maxFPS,
|
|
246
|
+
droppedFrames: metrics.droppedFrames,
|
|
229
247
|
|
|
230
248
|
// Thresholds
|
|
231
|
-
thresholds
|
|
249
|
+
thresholds: finalThresholds
|
|
250
|
+
}
|
|
232
251
|
}
|