@umituz/react-native-design-system 2.6.17 → 2.6.19
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.
|
|
3
|
+
"version": "2.6.19",
|
|
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",
|
package/src/device/index.ts
CHANGED
|
@@ -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,88 @@
|
|
|
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
|
+
* Index signature added for Record<string, unknown> compatibility
|
|
20
|
+
*/
|
|
21
|
+
export interface DeviceExtras {
|
|
22
|
+
[key: string]: string | undefined;
|
|
23
|
+
deviceId?: string;
|
|
24
|
+
platform?: string;
|
|
25
|
+
deviceModel?: string;
|
|
26
|
+
deviceBrand?: string;
|
|
27
|
+
osVersion?: string;
|
|
28
|
+
appVersion?: string;
|
|
29
|
+
buildNumber?: string;
|
|
30
|
+
locale?: string;
|
|
31
|
+
timezone?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get device locale code
|
|
36
|
+
*/
|
|
37
|
+
function getDeviceLocale(): string | undefined {
|
|
38
|
+
try {
|
|
39
|
+
const locales = Localization.getLocales();
|
|
40
|
+
if (locales && locales.length > 0) {
|
|
41
|
+
const locale = locales[0];
|
|
42
|
+
return locale.languageTag || undefined;
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
} catch {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Collect device extras for user documents
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* import { collectDeviceExtras } from '@umituz/react-native-design-system';
|
|
56
|
+
* import { initializeAuth } from '@umituz/react-native-auth';
|
|
57
|
+
*
|
|
58
|
+
* await initializeAuth({
|
|
59
|
+
* userCollection: 'users',
|
|
60
|
+
* collectExtras: collectDeviceExtras,
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export async function collectDeviceExtras(): Promise<DeviceExtras> {
|
|
65
|
+
try {
|
|
66
|
+
const [deviceInfo, appInfo, deviceId] = await Promise.all([
|
|
67
|
+
DeviceInfoService.getDeviceInfo(),
|
|
68
|
+
ApplicationInfoService.getApplicationInfo(),
|
|
69
|
+
PersistentDeviceIdService.getDeviceId(),
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
const locale = getDeviceLocale();
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
deviceId,
|
|
76
|
+
platform: deviceInfo.platform,
|
|
77
|
+
deviceModel: deviceInfo.modelName || undefined,
|
|
78
|
+
deviceBrand: deviceInfo.brand || undefined,
|
|
79
|
+
osVersion: deviceInfo.osVersion || undefined,
|
|
80
|
+
appVersion: appInfo.nativeApplicationVersion || undefined,
|
|
81
|
+
buildNumber: appInfo.nativeBuildVersion || undefined,
|
|
82
|
+
locale,
|
|
83
|
+
timezone: deviceInfo.timezone || undefined,
|
|
84
|
+
};
|
|
85
|
+
} catch {
|
|
86
|
+
return {};
|
|
87
|
+
}
|
|
88
|
+
}
|
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
|
// =============================================================================
|