@umituz/react-native-design-system 4.23.57 → 4.23.58
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/filesystem/infrastructure/utils/blob.utils.ts +3 -3
- package/src/image/infrastructure/services/ImageEditorService.ts +1 -1
- package/src/image/infrastructure/utils/ImageAnalysisUtils.ts +34 -34
- package/src/image/infrastructure/utils/ImageEditorHistoryUtils.ts +2 -2
- package/src/image/infrastructure/utils/LayerManager.ts +1 -1
- package/src/media/infrastructure/utils/url-media-detector.ts +1 -1
- package/src/molecules/circular-menu/CircularMenu.tsx +4 -2
- package/src/molecules/navigation/utils/NavigationTheme.ts +6 -6
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.58",
|
|
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",
|
|
@@ -13,7 +13,7 @@ export function extractBase64FromDataUri(dataUri: string): string {
|
|
|
13
13
|
return dataUri;
|
|
14
14
|
}
|
|
15
15
|
const parts = dataUri.split(",");
|
|
16
|
-
return parts.length > 1 ? parts[1] : dataUri;
|
|
16
|
+
return parts.length > 1 ? parts[1]! : dataUri;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -30,9 +30,9 @@ export function detectMimeType(base64: string): string {
|
|
|
30
30
|
* Get file extension from MIME type
|
|
31
31
|
*/
|
|
32
32
|
export function getExtensionFromMimeType(mimeType: string): string {
|
|
33
|
-
const ext = mimeType.split("/")[1];
|
|
33
|
+
const ext = mimeType.split("/")[1] ?? "jpg";
|
|
34
34
|
if (ext === "jpeg") return "jpg";
|
|
35
|
-
return ext
|
|
35
|
+
return ext;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Image Infrastructure - Image Analysis
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Image analysis utilities
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -12,18 +12,18 @@ export class ImageAnalysisUtils {
|
|
|
12
12
|
} {
|
|
13
13
|
let redSum = 0, greenSum = 0, blueSum = 0;
|
|
14
14
|
const pixelCount = imageData.length / 4;
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
for (let i = 0; i < imageData.length; i += 4) {
|
|
17
|
-
redSum += imageData[i]
|
|
18
|
-
greenSum += imageData[i + 1]
|
|
19
|
-
blueSum += imageData[i + 2]
|
|
17
|
+
redSum += imageData[i]!;
|
|
18
|
+
greenSum += imageData[i + 1]!;
|
|
19
|
+
blueSum += imageData[i + 2]!;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
const redMean = redSum / pixelCount;
|
|
23
23
|
const greenMean = greenSum / pixelCount;
|
|
24
24
|
const blueMean = blueSum / pixelCount;
|
|
25
25
|
const grayMean = (redMean + greenMean + blueMean) / 3;
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
return {
|
|
28
28
|
redBalance: (grayMean - redMean) / 255,
|
|
29
29
|
greenBalance: (grayMean - greenMean) / 255,
|
|
@@ -34,21 +34,21 @@ export class ImageAnalysisUtils {
|
|
|
34
34
|
static detectNoise(imageData: Uint8ClampedArray): number {
|
|
35
35
|
let noiseLevel = 0;
|
|
36
36
|
let sampleCount = 0;
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
for (let i = 0; i < imageData.length - 40; i += 40) {
|
|
39
|
-
const r1 = imageData[i]
|
|
40
|
-
const g1 = imageData[i + 1]
|
|
41
|
-
const b1 = imageData[i + 2]
|
|
42
|
-
|
|
43
|
-
const r2 = imageData[i + 4]
|
|
44
|
-
const g2 = imageData[i + 5]
|
|
45
|
-
const b2 = imageData[i + 6]
|
|
46
|
-
|
|
39
|
+
const r1 = imageData[i]!;
|
|
40
|
+
const g1 = imageData[i + 1]!;
|
|
41
|
+
const b1 = imageData[i + 2]!;
|
|
42
|
+
|
|
43
|
+
const r2 = imageData[i + 4]!;
|
|
44
|
+
const g2 = imageData[i + 5]!;
|
|
45
|
+
const b2 = imageData[i + 6]!;
|
|
46
|
+
|
|
47
47
|
const diff = Math.abs(r1 - r2) + Math.abs(g1 - g2) + Math.abs(b1 - b2);
|
|
48
48
|
noiseLevel += diff;
|
|
49
49
|
sampleCount++;
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
return noiseLevel / (sampleCount * 3 * 255);
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -60,63 +60,63 @@ export class ImageAnalysisUtils {
|
|
|
60
60
|
-1, 5, -1,
|
|
61
61
|
0, -1, 0
|
|
62
62
|
];
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
for (let i = 0; i < imageData.length; i += 4) {
|
|
65
65
|
const pixelIndex = i / 4;
|
|
66
66
|
const x = pixelIndex % width;
|
|
67
67
|
const y = Math.floor(pixelIndex / width);
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
for (let c = 0; c < 3; c++) {
|
|
70
70
|
let sum = 0;
|
|
71
71
|
for (let ky = -1; ky <= 1; ky++) {
|
|
72
72
|
for (let kx = -1; kx <= 1; kx++) {
|
|
73
73
|
const nx = x + kx;
|
|
74
74
|
const ny = y + ky;
|
|
75
|
-
|
|
75
|
+
|
|
76
76
|
if (nx >= 0 && nx < width && ny >= 0 && ny < width) {
|
|
77
77
|
const neighborIndex = (ny * width + nx) * 4 + c;
|
|
78
|
-
sum += imageData[neighborIndex] * kernel[(ky + 1) * 3 + (kx + 1)];
|
|
78
|
+
sum += (imageData[neighborIndex] ?? 0) * (kernel[(ky + 1) * 3 + (kx + 1)] ?? 0);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
result[i + c] = Math.min(255, Math.max(0, sum));
|
|
83
83
|
}
|
|
84
|
-
result[i + 3] = imageData[i + 3];
|
|
84
|
+
result[i + 3] = imageData[i + 3] ?? 255;
|
|
85
85
|
}
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
return result;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
static applyNoiseReduction(imageData: Uint8ClampedArray): Uint8ClampedArray {
|
|
91
91
|
const result = new Uint8ClampedArray(imageData.length);
|
|
92
92
|
const width = Math.sqrt(imageData.length / 4);
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
for (let i = 0; i < imageData.length; i += 4) {
|
|
95
95
|
const pixelIndex = i / 4;
|
|
96
96
|
const x = pixelIndex % width;
|
|
97
97
|
const y = Math.floor(pixelIndex / width);
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
for (let c = 0; c < 3; c++) {
|
|
100
|
-
const values = [];
|
|
101
|
-
|
|
100
|
+
const values: number[] = [];
|
|
101
|
+
|
|
102
102
|
for (let dy = -1; dy <= 1; dy++) {
|
|
103
103
|
for (let dx = -1; dx <= 1; dx++) {
|
|
104
104
|
const nx = x + dx;
|
|
105
105
|
const ny = y + dy;
|
|
106
|
-
|
|
106
|
+
|
|
107
107
|
if (nx >= 0 && nx < width && ny >= 0 && ny < width) {
|
|
108
108
|
const neighborIndex = (ny * width + nx) * 4 + c;
|
|
109
|
-
values.push(imageData[neighborIndex]);
|
|
109
|
+
values.push(imageData[neighborIndex] ?? 0);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
values.sort((a, b) => a - b);
|
|
115
|
-
result[i + c] = values[Math.floor(values.length / 2)];
|
|
115
|
+
result[i + c] = values[Math.floor(values.length / 2)] ?? 0;
|
|
116
116
|
}
|
|
117
|
-
result[i + 3] = imageData[i + 3];
|
|
117
|
+
result[i + 3] = imageData[i + 3] ?? 255;
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
|
|
120
120
|
return result;
|
|
121
121
|
}
|
|
122
|
-
}
|
|
122
|
+
}
|
|
@@ -29,7 +29,7 @@ export class ImageEditorHistoryUtils {
|
|
|
29
29
|
if (state.historyIndex <= 0) return state;
|
|
30
30
|
|
|
31
31
|
const newIndex = state.historyIndex - 1;
|
|
32
|
-
const historyState = state.history[newIndex]
|
|
32
|
+
const historyState = state.history[newIndex]!;
|
|
33
33
|
|
|
34
34
|
return {
|
|
35
35
|
...state,
|
|
@@ -43,7 +43,7 @@ export class ImageEditorHistoryUtils {
|
|
|
43
43
|
if (state.historyIndex >= state.history.length - 1) return state;
|
|
44
44
|
|
|
45
45
|
const newIndex = state.historyIndex + 1;
|
|
46
|
-
const historyState = state.history[newIndex]
|
|
46
|
+
const historyState = state.history[newIndex]!;
|
|
47
47
|
|
|
48
48
|
return {
|
|
49
49
|
...state,
|
|
@@ -70,7 +70,7 @@ export class LayerManager {
|
|
|
70
70
|
toIndex: number
|
|
71
71
|
): Array<{ id: string; index?: number }> {
|
|
72
72
|
const result = [...layers];
|
|
73
|
-
const [moved] = result.splice(fromIndex, 1);
|
|
73
|
+
const [moved] = result.splice(fromIndex, 1) as [{ id: string; index?: number }];
|
|
74
74
|
result.splice(toIndex, 0, moved);
|
|
75
75
|
|
|
76
76
|
return result.map((layer, index) => ({ ...layer, index }));
|
|
@@ -6,7 +6,7 @@ const AUDIO_EXTENSIONS = [".mp3", ".wav", ".ogg", ".m4a", ".aac", ".flac"];
|
|
|
6
6
|
|
|
7
7
|
function getExtensionFromUrl(url: string): string | null {
|
|
8
8
|
if (!url) return null;
|
|
9
|
-
const urlWithoutParams = url.toLowerCase().split("?")[0]
|
|
9
|
+
const urlWithoutParams = url.toLowerCase().split("?")[0]!;
|
|
10
10
|
const lastDotIndex = urlWithoutParams.lastIndexOf(".");
|
|
11
11
|
if (lastDotIndex === -1) return null;
|
|
12
12
|
return urlWithoutParams.substring(lastDotIndex);
|
|
@@ -63,11 +63,13 @@ export const CircularMenu: React.FC<CircularMenuProps> = ({
|
|
|
63
63
|
const topCount = Math.min(actions.length, 2);
|
|
64
64
|
const bottomCount = Math.max(0, actions.length - 2);
|
|
65
65
|
|
|
66
|
-
const mapped = [];
|
|
66
|
+
const mapped: Array<CircularMenuAction & { position: ViewStyle }> = [];
|
|
67
67
|
// Top row
|
|
68
68
|
for (let i = 0; i < topCount; i++) {
|
|
69
|
+
const action = actions[i];
|
|
70
|
+
if (!action) continue;
|
|
69
71
|
mapped.push({
|
|
70
|
-
...
|
|
72
|
+
...action,
|
|
71
73
|
position: getTopRowPosition(i, topCount),
|
|
72
74
|
});
|
|
73
75
|
}
|
|
@@ -10,12 +10,12 @@ export const createNavigationTheme = (colors: Record<string, string>, mode: 'lig
|
|
|
10
10
|
...baseTheme,
|
|
11
11
|
colors: {
|
|
12
12
|
...baseTheme.colors,
|
|
13
|
-
primary: colors.primary,
|
|
14
|
-
background: colors.backgroundPrimary,
|
|
15
|
-
card: colors.surface,
|
|
16
|
-
text: colors.textPrimary,
|
|
17
|
-
border: colors.border,
|
|
18
|
-
notification: colors.error,
|
|
13
|
+
primary: colors.primary ?? baseTheme.colors.primary,
|
|
14
|
+
background: colors.backgroundPrimary ?? baseTheme.colors.background,
|
|
15
|
+
card: colors.surface ?? baseTheme.colors.card,
|
|
16
|
+
text: colors.textPrimary ?? baseTheme.colors.text,
|
|
17
|
+
border: colors.border ?? baseTheme.colors.border,
|
|
18
|
+
notification: colors.error ?? baseTheme.colors.notification,
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
21
|
};
|