@umituz/react-native-design-system 2.9.38 → 2.9.40

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": "2.9.38",
3
+ "version": "2.9.40",
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",
@@ -44,6 +44,16 @@ export type { SaveResult, SaveOptions } from "./infrastructure/services/MediaSav
44
44
  // Presentation Layer - Original Media Hooks
45
45
  export { useMedia } from "./presentation/hooks/useMedia";
46
46
 
47
+ // Media Helper Utilities
48
+ export {
49
+ getMediaTypeFromUrl,
50
+ isVideoUrl,
51
+ isImageUrl,
52
+ getMediaType,
53
+ getCardMediaType,
54
+ formatFileSize,
55
+ } from "./infrastructure/utils/mediaHelpers";
56
+
47
57
  // Multimedia Flashcard Support
48
58
  export type {
49
59
  CardMediaType,
@@ -80,3 +80,47 @@ export const formatFileSize = (bytes: number): string => {
80
80
  const i = Math.floor(Math.log(bytes) / Math.log(1024));
81
81
  return Math.round((bytes / Math.pow(1024, i)) * 100) / 100 + " " + sizes[i];
82
82
  };
83
+
84
+ // URL-based media type detection constants
85
+ const VIDEO_EXTENSIONS = [".mp4", ".webm", ".mov", ".avi", ".mkv", ".m4v"];
86
+ const IMAGE_EXTENSIONS = [".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp", ".svg"];
87
+ const AUDIO_EXTENSIONS = [".mp3", ".wav", ".ogg", ".m4a", ".aac", ".flac"];
88
+
89
+ /**
90
+ * Get media type from URL based on file extension
91
+ */
92
+ export const getMediaTypeFromUrl = (
93
+ url: string
94
+ ): "image" | "video" | "audio" | "unknown" => {
95
+ if (!url) return "unknown";
96
+
97
+ const lowercaseUrl = url.toLowerCase();
98
+
99
+ // Extract extension (handle query params)
100
+ const urlWithoutParams = lowercaseUrl.split("?")[0];
101
+ const lastDotIndex = urlWithoutParams.lastIndexOf(".");
102
+ if (lastDotIndex === -1) return "unknown";
103
+
104
+ const extension = urlWithoutParams.substring(lastDotIndex);
105
+
106
+ if (VIDEO_EXTENSIONS.includes(extension)) return "video";
107
+ if (IMAGE_EXTENSIONS.includes(extension)) return "image";
108
+ if (AUDIO_EXTENSIONS.includes(extension)) return "audio";
109
+
110
+ return "unknown";
111
+ };
112
+
113
+ /**
114
+ * Check if URL points to a video file
115
+ */
116
+ export const isVideoUrl = (url: string): boolean => {
117
+ return getMediaTypeFromUrl(url) === "video";
118
+ };
119
+
120
+ /**
121
+ * Check if URL points to an image file
122
+ */
123
+ export const isImageUrl = (url: string): boolean => {
124
+ const mediaType = getMediaTypeFromUrl(url);
125
+ return mediaType === "image" || mediaType === "unknown";
126
+ };