@umituz/react-native-design-system 2.6.17 → 2.6.18

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.6.17",
3
+ "version": "2.6.18",
4
4
  "description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive and safe area utilities",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -74,6 +74,8 @@ export { DeviceService } from './infrastructure/services/DeviceService';
74
74
  export { UserFriendlyIdService } from './infrastructure/services/UserFriendlyIdService';
75
75
  import { PersistentDeviceIdService } from './infrastructure/services/PersistentDeviceIdService';
76
76
  export { PersistentDeviceIdService };
77
+ export { collectDeviceExtras } from './infrastructure/services/DeviceExtrasCollector';
78
+ export type { DeviceExtras } from './infrastructure/services/DeviceExtrasCollector';
77
79
 
78
80
  // ============================================================================
79
81
  // PRESENTATION - Device hooks
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Device Extras Collector
3
+ *
4
+ * Collects device and application information for user documents.
5
+ * Used with @umituz/react-native-auth's UserDocumentService.
6
+ *
7
+ * @domain device
8
+ * @layer infrastructure/services
9
+ */
10
+
11
+ import * as Localization from 'expo-localization';
12
+ import { DeviceInfoService } from './DeviceInfoService';
13
+ import { ApplicationInfoService } from './ApplicationInfoService';
14
+ import { PersistentDeviceIdService } from './PersistentDeviceIdService';
15
+
16
+ /**
17
+ * Device extras for user documents
18
+ * Compatible with UserDocumentExtras from @umituz/react-native-auth
19
+ */
20
+ export interface DeviceExtras {
21
+ deviceId?: string;
22
+ platform?: string;
23
+ deviceModel?: string;
24
+ deviceBrand?: string;
25
+ osVersion?: string;
26
+ appVersion?: string;
27
+ buildNumber?: string;
28
+ locale?: string;
29
+ timezone?: string;
30
+ }
31
+
32
+ /**
33
+ * Get device locale code
34
+ */
35
+ function getDeviceLocale(): string | undefined {
36
+ try {
37
+ const locales = Localization.getLocales();
38
+ if (locales && locales.length > 0) {
39
+ const locale = locales[0];
40
+ return locale.languageTag || undefined;
41
+ }
42
+ return undefined;
43
+ } catch {
44
+ return undefined;
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Collect device extras for user documents
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * import { collectDeviceExtras } from '@umituz/react-native-design-system';
54
+ * import { initializeAuth } from '@umituz/react-native-auth';
55
+ *
56
+ * await initializeAuth({
57
+ * userCollection: 'users',
58
+ * collectExtras: collectDeviceExtras,
59
+ * });
60
+ * ```
61
+ */
62
+ export async function collectDeviceExtras(): Promise<DeviceExtras> {
63
+ try {
64
+ const [deviceInfo, appInfo, deviceId] = await Promise.all([
65
+ DeviceInfoService.getDeviceInfo(),
66
+ ApplicationInfoService.getApplicationInfo(),
67
+ PersistentDeviceIdService.getDeviceId(),
68
+ ]);
69
+
70
+ const locale = getDeviceLocale();
71
+
72
+ return {
73
+ deviceId,
74
+ platform: deviceInfo.platform,
75
+ deviceModel: deviceInfo.modelName || undefined,
76
+ deviceBrand: deviceInfo.brand || undefined,
77
+ osVersion: deviceInfo.osVersion || undefined,
78
+ appVersion: appInfo.nativeApplicationVersion || undefined,
79
+ buildNumber: appInfo.nativeBuildVersion || undefined,
80
+ locale,
81
+ timezone: deviceInfo.timezone || undefined,
82
+ };
83
+ } catch {
84
+ return {};
85
+ }
86
+ }
package/src/index.ts CHANGED
@@ -166,11 +166,13 @@ export {
166
166
  useDeviceId,
167
167
  useAnonymousUser,
168
168
  getAnonymousUserId,
169
+ collectDeviceExtras,
169
170
  type DeviceInfo,
170
171
  type ApplicationInfo,
171
172
  type SystemInfo,
172
173
  type AnonymousUser,
173
174
  type UseAnonymousUserOptions,
175
+ type DeviceExtras,
174
176
  } from './device';
175
177
 
176
178
  // =============================================================================