@umituz/react-native-design-system 4.27.14 → 4.27.15
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 +1 -1
- package/src/core/cache/domain/CleanupStrategy.ts +115 -0
- package/src/core/cache/domain/UnifiedCache.ts +196 -0
- package/src/core/cache/domain/types.ts +18 -0
- package/src/core/cache/index.ts +16 -0
- package/src/core/cache/infrastructure/CacheFactory.ts +102 -0
- package/src/core/index.ts +21 -0
- package/src/core/permissions/domain/PermissionHandler.ts +139 -0
- package/src/core/permissions/domain/types.ts +49 -0
- package/src/core/permissions/index.ts +15 -0
- package/src/core/repositories/domain/RepositoryKeyFactory.ts +41 -0
- package/src/core/repositories/domain/RepositoryUtils.ts +86 -0
- package/src/core/repositories/domain/types.ts +59 -0
- package/src/core/repositories/index.ts +23 -0
- package/src/device/detection/deviceDetection.ts +8 -2
- package/src/haptics/infrastructure/services/HapticService.ts +4 -1
- package/src/index.ts +1 -0
- package/src/media/domain/strategies/CameraPickerStrategy.ts +65 -0
- package/src/media/domain/strategies/LibraryPickerStrategy.ts +54 -0
- package/src/media/domain/strategies/PickerStrategy.ts +61 -0
- package/src/media/domain/strategies/index.ts +13 -0
- package/src/media/infrastructure/services/MediaPickerService.ts +118 -108
- package/src/media/infrastructure/utils/PermissionManager.ts +68 -66
- package/src/media/presentation/hooks/useMedia.ts +16 -4
- package/src/storage/cache/infrastructure/TTLCache.ts +3 -0
- package/src/tanstack/domain/repositories/BaseRepository.ts +18 -1
- package/src/timezone/infrastructure/utils/SimpleCache.ts +30 -75
- package/src/uuid/infrastructure/utils/UUIDUtils.ts +4 -1
|
@@ -1,65 +1,57 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SimpleCache
|
|
2
|
+
* SimpleCache (Backward Compatibility Wrapper)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* @deprecated Use UnifiedCache from core/cache instead.
|
|
5
|
+
* This wrapper maintains backward compatibility while migrating to UnifiedCache.
|
|
6
|
+
*
|
|
7
|
+
* Lightweight in-memory cache for performance optimization.
|
|
8
|
+
* Now implemented using UnifiedCache with timeout-based cleanup strategy.
|
|
6
9
|
*/
|
|
7
10
|
|
|
11
|
+
import { UnifiedCache } from '../../../core/cache/domain/UnifiedCache';
|
|
12
|
+
import { TimeoutCleanupStrategy } from '../../../core/cache/domain/CleanupStrategy';
|
|
8
13
|
import { ONE_MINUTE_MS } from '../../../utils/constants/TimeConstants';
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
/**
|
|
16
|
+
* SimpleCache - Wrapper around UnifiedCache for backward compatibility
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* // Old usage (still works):
|
|
21
|
+
* const cache = new SimpleCache<string>(60000);
|
|
22
|
+
*
|
|
23
|
+
* // New usage (recommended):
|
|
24
|
+
* import { CacheFactory } from '../../../core/cache';
|
|
25
|
+
* const cache = CacheFactory.createTimeoutCache(60000);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
15
28
|
export class SimpleCache<T> {
|
|
16
|
-
private cache
|
|
17
|
-
private defaultTTL: number;
|
|
18
|
-
private cleanupTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
19
|
-
private destroyed = false;
|
|
20
|
-
private cleanupScheduleLock = false;
|
|
29
|
+
private cache: UnifiedCache<T>;
|
|
21
30
|
|
|
22
31
|
constructor(defaultTTL: number = ONE_MINUTE_MS) {
|
|
23
|
-
this.
|
|
24
|
-
|
|
32
|
+
this.cache = new UnifiedCache<T>({
|
|
33
|
+
defaultTTL,
|
|
34
|
+
cleanupStrategy: new TimeoutCleanupStrategy(ONE_MINUTE_MS),
|
|
35
|
+
});
|
|
25
36
|
}
|
|
26
37
|
|
|
27
38
|
/**
|
|
28
39
|
* Destroy the cache and stop cleanup timer
|
|
29
40
|
*/
|
|
30
41
|
destroy(): void {
|
|
31
|
-
this.
|
|
32
|
-
this.cleanupScheduleLock = false;
|
|
33
|
-
if (this.cleanupTimeout) {
|
|
34
|
-
clearTimeout(this.cleanupTimeout);
|
|
35
|
-
this.cleanupTimeout = null;
|
|
36
|
-
}
|
|
37
|
-
this.cache.clear();
|
|
42
|
+
this.cache.destroy();
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
set(key: string, value: T, ttl?: number): void {
|
|
41
|
-
|
|
42
|
-
const expires = Date.now() + (ttl ?? this.defaultTTL);
|
|
43
|
-
this.cache.set(key, { value, expires });
|
|
46
|
+
this.cache.set(key, value, ttl);
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
get(key: string): T | undefined {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (!entry) {
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (Date.now() > entry.expires) {
|
|
54
|
-
this.cache.delete(key);
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return entry.value;
|
|
50
|
+
return this.cache.get(key);
|
|
59
51
|
}
|
|
60
52
|
|
|
61
53
|
has(key: string): boolean {
|
|
62
|
-
return this.
|
|
54
|
+
return this.cache.has(key);
|
|
63
55
|
}
|
|
64
56
|
|
|
65
57
|
clear(): void {
|
|
@@ -69,41 +61,4 @@ export class SimpleCache<T> {
|
|
|
69
61
|
delete(key: string): void {
|
|
70
62
|
this.cache.delete(key);
|
|
71
63
|
}
|
|
72
|
-
|
|
73
|
-
private cleanup(): void {
|
|
74
|
-
const now = Date.now();
|
|
75
|
-
for (const [key, entry] of this.cache.entries()) {
|
|
76
|
-
if (now > entry.expires) {
|
|
77
|
-
this.cache.delete(key);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private scheduleCleanup(): void {
|
|
83
|
-
if (this.destroyed || this.cleanupScheduleLock) return;
|
|
84
|
-
|
|
85
|
-
this.cleanupScheduleLock = true;
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
if (this.cleanupTimeout) {
|
|
89
|
-
clearTimeout(this.cleanupTimeout);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
this.cleanup();
|
|
93
|
-
|
|
94
|
-
if (!this.destroyed) {
|
|
95
|
-
this.cleanupTimeout = setTimeout(() => {
|
|
96
|
-
if (!this.destroyed) {
|
|
97
|
-
this.cleanupScheduleLock = false;
|
|
98
|
-
this.scheduleCleanup();
|
|
99
|
-
}
|
|
100
|
-
}, ONE_MINUTE_MS);
|
|
101
|
-
} else {
|
|
102
|
-
this.cleanupScheduleLock = false;
|
|
103
|
-
}
|
|
104
|
-
} catch (error) {
|
|
105
|
-
this.cleanupScheduleLock = false;
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
64
|
}
|
|
@@ -17,7 +17,10 @@ const getCryptoModule = (): typeof import('expo-crypto') | null => {
|
|
|
17
17
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
18
18
|
_cryptoModule = require('expo-crypto') as typeof import('expo-crypto');
|
|
19
19
|
return _cryptoModule;
|
|
20
|
-
} catch {
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (__DEV__) {
|
|
22
|
+
console.warn('[UUIDUtils] expo-crypto not available, using Math.random fallback:', error);
|
|
23
|
+
}
|
|
21
24
|
return null;
|
|
22
25
|
}
|
|
23
26
|
};
|