@umituz/web-design-system 3.1.9 → 3.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-design-system",
3
- "version": "3.1.9",
3
+ "version": "3.1.10",
4
4
  "private": false,
5
5
  "description": "Web Design System - Atomic Design components (Atoms, Molecules, Organisms, Templates) for React applications",
6
6
  "main": "./src/index.ts",
@@ -1,6 +1,76 @@
1
- export { usePerformanceMonitor } from './usePerformanceMonitor';
1
+ export { usePerformanceMonitor, useRenderPerformance } from './usePerformanceMonitor';
2
2
  export { useLazyLoading } from './useLazyLoading';
3
- export { useMemoryOptimization } from './useMemoryOptimization';
3
+ export { useMemoryOptimization, useMemoryLeakDetector } from './useMemoryOptimization';
4
4
 
5
5
  export type { PerformanceMetrics, PerformanceConfig } from './usePerformanceMonitor';
6
6
  export type { MemoryOptimizationConfig, CleanupFunction } from './useMemoryOptimization';
7
+
8
+ // Performance monitoring utilities
9
+ export const performanceUtils = {
10
+ // Measure render performance
11
+ measureRender: (componentName: string, fn: () => void) => {
12
+ const start = performance.now();
13
+ fn();
14
+ const end = performance.now();
15
+
16
+ if (import.meta.env.DEV) {
17
+ const duration = end - start;
18
+ if (duration > 16) {
19
+ console.warn(`[Performance] ${componentName} took ${duration.toFixed(2)}ms to render`);
20
+ }
21
+ }
22
+
23
+ return end - start;
24
+ },
25
+
26
+ // Measure async operation
27
+ measureAsync: async <T>(componentName: string, operation: string, fn: () => Promise<T>): Promise<T> => {
28
+ const start = performance.now();
29
+ try {
30
+ const result = await fn();
31
+ const duration = performance.now() - start;
32
+
33
+ if (import.meta.env.DEV) {
34
+ console.log(`[Performance] ${componentName} ${operation} completed in ${duration.toFixed(2)}ms`);
35
+ }
36
+
37
+ return result;
38
+ } catch (error) {
39
+ const duration = performance.now() - start;
40
+ console.error(`[Performance] ${componentName} ${operation} failed after ${duration.toFixed(2)}ms:`, error);
41
+ throw error;
42
+ }
43
+ },
44
+
45
+ // Get performance metrics
46
+ getMetrics: () => {
47
+ if (typeof performance === 'undefined' || !performance.memory) {
48
+ return null;
49
+ }
50
+
51
+ return {
52
+ memory: {
53
+ usedJSHeapSize: performance.memory.usedJSHeapSize,
54
+ totalJSHeapSize: performance.memory.totalJSHeapSize,
55
+ jsHeapSizeLimit: performance.memory.jsHeapSizeLimit,
56
+ },
57
+ navigation: performance.getEntriesByType('navigation')[0] as PerformanceNavigationTiming | undefined,
58
+ };
59
+ },
60
+
61
+ // Log performance summary
62
+ logSummary: () => {
63
+ const metrics = performanceUtils.getMetrics();
64
+ if (!metrics) return;
65
+
66
+ if (import.meta.env.DEV && metrics.memory) {
67
+ const memoryUsage = ((metrics.memory.usedJSHeapSize / metrics.memory.jsHeapSizeLimit) * 100).toFixed(2);
68
+ console.log(`[Performance] Memory usage: ${memoryUsage}%`);
69
+ }
70
+
71
+ if (metrics.navigation) {
72
+ const loadTime = metrics.navigation.loadEventEnd - metrics.navigation.fetchStart;
73
+ console.log(`[Performance] Page load time: ${loadTime.toFixed(2)}ms`);
74
+ }
75
+ },
76
+ };