@umituz/react-native-design-system 4.23.105 → 4.23.107
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-design-system",
|
|
3
|
-
"version": "4.23.
|
|
3
|
+
"version": "4.23.107",
|
|
4
4
|
"description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive, safe area, exception, infinite scroll, UUID, image, timezone, offline, onboarding, and loading utilities",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -30,7 +30,12 @@ export async function downloadFile(url: string, dest?: string): Promise<FileOper
|
|
|
30
30
|
} catch (e: unknown) { return { success: false, error: e instanceof Error ? e.message : String(e) }; }
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export async function downloadFileWithProgress(
|
|
33
|
+
export async function downloadFileWithProgress(
|
|
34
|
+
url: string,
|
|
35
|
+
cacheDir: string,
|
|
36
|
+
onProgress?: DownloadProgressCallback,
|
|
37
|
+
signal?: AbortSignal
|
|
38
|
+
): Promise<DownloadWithProgressResult> {
|
|
34
39
|
try {
|
|
35
40
|
const dir = new Directory(cacheDir);
|
|
36
41
|
if (!dir.exists) dir.create({ intermediates: true, idempotent: true });
|
|
@@ -38,9 +43,9 @@ export async function downloadFileWithProgress(url: string, cacheDir: string, on
|
|
|
38
43
|
const destUri = getCacheUri(url, cacheDir);
|
|
39
44
|
if (new File(destUri).exists) return { success: true, uri: destUri, fromCache: true };
|
|
40
45
|
|
|
41
|
-
const response = await fetch(url);
|
|
46
|
+
const response = await fetch(url, { signal });
|
|
42
47
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
43
|
-
|
|
48
|
+
|
|
44
49
|
const totalBytes = parseInt(response.headers.get("content-length") || "0", 10);
|
|
45
50
|
if (!response.body) return { ...(await downloadFile(url, destUri)), fromCache: false };
|
|
46
51
|
|
|
@@ -48,20 +53,29 @@ export async function downloadFileWithProgress(url: string, cacheDir: string, on
|
|
|
48
53
|
const chunks: Uint8Array[] = [];
|
|
49
54
|
let received = 0;
|
|
50
55
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
56
|
+
try {
|
|
57
|
+
while (true) {
|
|
58
|
+
if (signal?.aborted) {
|
|
59
|
+
await reader.cancel();
|
|
60
|
+
throw new Error("Download aborted");
|
|
61
|
+
}
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
const { done, value } = await reader.read();
|
|
64
|
+
if (done) break;
|
|
65
|
+
chunks.push(value);
|
|
66
|
+
received += value.length;
|
|
67
|
+
onProgress?.({ totalBytesWritten: received, totalBytesExpectedToWrite: totalBytes || received });
|
|
68
|
+
}
|
|
63
69
|
|
|
64
|
-
|
|
70
|
+
const all = new Uint8Array(received);
|
|
71
|
+
let pos = 0;
|
|
72
|
+
for (const c of chunks) { all.set(c, pos); pos += c.length; }
|
|
73
|
+
new File(destUri).write(all);
|
|
74
|
+
|
|
75
|
+
return { success: true, uri: destUri, fromCache: false };
|
|
76
|
+
} finally {
|
|
77
|
+
reader.releaseLock();
|
|
78
|
+
}
|
|
65
79
|
} catch (e: unknown) { return { success: false, error: e instanceof Error ? e.message : String(e) }; }
|
|
66
80
|
}
|
|
67
81
|
|
|
@@ -66,10 +66,10 @@ export const AlertModal: React.FC<AlertModalProps> = ({ alert }) => {
|
|
|
66
66
|
title={action.label}
|
|
67
67
|
variant={action.style === 'destructive' ? 'danger' : action.style === 'secondary' ? 'secondary' : 'primary'}
|
|
68
68
|
onPress={async () => {
|
|
69
|
-
await action.onPress();
|
|
70
69
|
if (action.closeOnPress ?? true) {
|
|
71
70
|
handleClose();
|
|
72
71
|
}
|
|
72
|
+
await action.onPress();
|
|
73
73
|
}}
|
|
74
74
|
fullWidth
|
|
75
75
|
/>
|