@kontextso/sdk-react-native 3.2.0-rc.3 → 3.2.1
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/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +522 -523
- package/dist/index.mjs +500 -462
- package/package.json +1 -1
- package/src/context/AdsProvider.tsx +8 -1
package/package.json
CHANGED
|
@@ -20,6 +20,13 @@ ErrorUtils.setGlobalHandler((error, isFatal) => {
|
|
|
20
20
|
}
|
|
21
21
|
})
|
|
22
22
|
|
|
23
|
+
const batteryLevelToPercent = (level: unknown): number | undefined => {
|
|
24
|
+
if (typeof level !== 'number' || !isFinite(level)) return undefined
|
|
25
|
+
if (level < 0) return undefined
|
|
26
|
+
|
|
27
|
+
return Math.max(0, Math.min(100, Math.round(level * 100)))
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
const getDevice = async (): Promise<DeviceConfig> => {
|
|
24
31
|
try {
|
|
25
32
|
const powerState = await DeviceInfo.getPowerState()
|
|
@@ -79,7 +86,7 @@ const getDevice = async (): Promise<DeviceConfig> => {
|
|
|
79
86
|
orientation: screen.width > screen.height ? 'landscape' : 'portrait',
|
|
80
87
|
},
|
|
81
88
|
power: {
|
|
82
|
-
batteryLevel: powerState.batteryLevel,
|
|
89
|
+
batteryLevel: batteryLevelToPercent(powerState.batteryLevel),
|
|
83
90
|
batteryState: powerState.batteryState,
|
|
84
91
|
lowPowerMode: powerState.lowPowerMode,
|
|
85
92
|
},
|