@umituz/react-native-ai-pruna-provider 1.0.63 → 1.0.64
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/react-native-ai-pruna-provider",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.64",
|
|
4
4
|
"description": "Pruna AI provider for React Native - implements IAIProvider interface for unified AI generation",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -43,9 +43,6 @@
|
|
|
43
43
|
"@gorhom/bottom-sheet": "^5.2.8",
|
|
44
44
|
"@react-native-async-storage/async-storage": "^2.2.0",
|
|
45
45
|
"@react-native-community/slider": "^5.1.2",
|
|
46
|
-
"@react-navigation/bottom-tabs": "^7.15.5",
|
|
47
|
-
"@react-navigation/native": "^7.1.33",
|
|
48
|
-
"@react-navigation/stack": "^7.8.5",
|
|
49
46
|
"@tanstack/query-async-storage-persister": "^5.90.24",
|
|
50
47
|
"@tanstack/react-query": "^5.90.21",
|
|
51
48
|
"@tanstack/react-query-persist-client": "^5.90.24",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Calculation Utilities
|
|
3
|
-
*
|
|
3
|
+
* Internal calculation functions for Pruna provider
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { DEFAULT_PRUNA_CONFIG } from "../services/pruna-provider.constants";
|
|
@@ -21,7 +21,7 @@ export function bytesToKB(bytes: number): number {
|
|
|
21
21
|
/**
|
|
22
22
|
* Converts bytes to megabytes (MB)
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
function bytesToMB(bytes: number): number {
|
|
25
25
|
return Math.round(bytes / 1024 / 1024);
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -32,17 +32,6 @@ export function calculateElapsedMs(startTime: number): number {
|
|
|
32
32
|
return Date.now() - startTime;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
* Formats elapsed time in human-readable format
|
|
37
|
-
*/
|
|
38
|
-
export function formatElapsedMs(ms: number): string {
|
|
39
|
-
if (ms < 1000) return `${ms}ms`;
|
|
40
|
-
if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
|
|
41
|
-
const minutes = Math.floor(ms / 60000);
|
|
42
|
-
const seconds = Math.floor((ms % 60000) / 1000);
|
|
43
|
-
return `${minutes}m ${seconds}s`;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
35
|
/**
|
|
47
36
|
* Creates a preview of a string by truncating and adding ellipsis
|
|
48
37
|
*/
|
|
@@ -51,15 +40,6 @@ export function createStringPreview(str: string, maxLength: number = DEFAULT_MAX
|
|
|
51
40
|
return `${str.substring(0, maxLength)}...`;
|
|
52
41
|
}
|
|
53
42
|
|
|
54
|
-
/**
|
|
55
|
-
* Creates a size preview (e.g., "2.5 MB", "1024 KB")
|
|
56
|
-
*/
|
|
57
|
-
export function formatSize(bytes: number): string {
|
|
58
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
59
|
-
if (bytes < 1024 * 1024) return `${bytesToKB(bytes)} KB`;
|
|
60
|
-
return `${bytesToMB(bytes)} MB`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
43
|
/**
|
|
64
44
|
* Calculates percentage with specified precision
|
|
65
45
|
*/
|
|
@@ -68,25 +48,6 @@ export function calculatePercentage(value: number, total: number, precision: num
|
|
|
68
48
|
return Number(((value / total) * 100).toFixed(precision));
|
|
69
49
|
}
|
|
70
50
|
|
|
71
|
-
/**
|
|
72
|
-
* Clamps a number between min and max values
|
|
73
|
-
*/
|
|
74
|
-
export function clamp(value: number, min: number, max: number): number {
|
|
75
|
-
return Math.min(Math.max(value, min), max);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Calculates retry delay with exponential backoff
|
|
80
|
-
*/
|
|
81
|
-
export function calculateRetryDelay(
|
|
82
|
-
attempt: number,
|
|
83
|
-
baseDelayMs: number,
|
|
84
|
-
maxDelayMs: number
|
|
85
|
-
): number {
|
|
86
|
-
const delay = Math.min(baseDelayMs * Math.pow(2, attempt), maxDelayMs);
|
|
87
|
-
return Math.round(delay);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
51
|
/**
|
|
91
52
|
* Validates if a timeout value is within acceptable range
|
|
92
53
|
*/
|
|
@@ -97,17 +58,3 @@ export function isValidTimeout(timeoutMs: number): boolean {
|
|
|
97
58
|
timeoutMs <= MAX_TIMEOUT_MS
|
|
98
59
|
);
|
|
99
60
|
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Calculates hash of a string for request deduplication
|
|
103
|
-
* Uses base64 encoding for collision resistance
|
|
104
|
-
*/
|
|
105
|
-
export function calculateRequestHash(input: string): string {
|
|
106
|
-
// Replace non-alphanumeric chars with underscores for safe string representation
|
|
107
|
-
const safeInput = input.replace(/[^a-zA-Z0-9]/g, '_');
|
|
108
|
-
|
|
109
|
-
// Use first 64 chars + last 64 chars to keep key length manageable
|
|
110
|
-
if (safeInput.length <= 128) return safeInput;
|
|
111
|
-
|
|
112
|
-
return `${safeInput.substring(0, 64)}...${safeInput.slice(-64)}`;
|
|
113
|
-
}
|