@symbiote-native/battery 0.0.1 → 0.1.0

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.
Files changed (75) hide show
  1. package/README.md +172 -27
  2. package/build/angular/index.d.ts +4 -0
  3. package/build/angular/index.js +8 -0
  4. package/build/angular/services/battery-level.service/index.d.ts +5 -0
  5. package/build/angular/services/battery-level.service/index.js +74 -0
  6. package/build/angular/services/battery-state.service/index.d.ts +6 -0
  7. package/build/angular/services/battery-state.service/index.js +69 -0
  8. package/build/angular/services/low-power-mode.service/index.d.ts +5 -0
  9. package/build/angular/services/low-power-mode.service/index.js +69 -0
  10. package/build/core/battery.d.ts +44 -0
  11. package/build/core/battery.js +79 -0
  12. package/build/core/index.d.ts +3 -0
  13. package/build/core/index.js +2 -0
  14. package/build/core/native-module.d.ts +13 -0
  15. package/build/core/native-module.js +3 -0
  16. package/build/core/types.d.ts +40 -0
  17. package/build/core/types.js +23 -0
  18. package/build/react/hooks/use-battery-level/index.d.ts +1 -0
  19. package/build/react/hooks/use-battery-level/index.js +16 -0
  20. package/build/react/hooks/use-battery-state/index.d.ts +2 -0
  21. package/build/react/hooks/use-battery-state/index.js +14 -0
  22. package/build/react/hooks/use-low-power-mode/index.d.ts +1 -0
  23. package/build/react/hooks/use-low-power-mode/index.js +15 -0
  24. package/build/react/index.d.ts +4 -0
  25. package/build/react/index.js +9 -0
  26. package/build/vue/composables/use-battery-level/index.d.ts +2 -0
  27. package/build/vue/composables/use-battery-level/index.js +23 -0
  28. package/build/vue/composables/use-battery-state/index.d.ts +3 -0
  29. package/build/vue/composables/use-battery-state/index.js +21 -0
  30. package/build/vue/composables/use-low-power-mode/index.d.ts +2 -0
  31. package/build/vue/composables/use-low-power-mode/index.js +22 -0
  32. package/build/vue/index.d.ts +4 -0
  33. package/build/vue/index.js +9 -0
  34. package/build-ngc/angular/index.d.ts +4 -0
  35. package/build-ngc/angular/index.js +9 -0
  36. package/build-ngc/angular/index.js.map +1 -0
  37. package/build-ngc/angular/services/battery-level.service/index.d.ts +8 -0
  38. package/build-ngc/angular/services/battery-level.service/index.js +33 -0
  39. package/build-ngc/angular/services/battery-level.service/index.js.map +1 -0
  40. package/build-ngc/angular/services/battery-state.service/index.d.ts +9 -0
  41. package/build-ngc/angular/services/battery-state.service/index.js +28 -0
  42. package/build-ngc/angular/services/battery-state.service/index.js.map +1 -0
  43. package/build-ngc/angular/services/low-power-mode.service/index.d.ts +8 -0
  44. package/build-ngc/angular/services/low-power-mode.service/index.js +28 -0
  45. package/build-ngc/angular/services/low-power-mode.service/index.js.map +1 -0
  46. package/build-ngc/core/battery.d.ts +44 -0
  47. package/build-ngc/core/battery.js +80 -0
  48. package/build-ngc/core/battery.js.map +1 -0
  49. package/build-ngc/core/index.d.ts +3 -0
  50. package/build-ngc/core/index.js +3 -0
  51. package/build-ngc/core/index.js.map +1 -0
  52. package/build-ngc/core/native-module.d.ts +13 -0
  53. package/build-ngc/core/native-module.js +4 -0
  54. package/build-ngc/core/native-module.js.map +1 -0
  55. package/build-ngc/core/types.d.ts +40 -0
  56. package/build-ngc/core/types.js +24 -0
  57. package/build-ngc/core/types.js.map +1 -0
  58. package/native-link.json +12 -0
  59. package/package.json +92 -1
  60. package/src/angular/index.ts +24 -0
  61. package/src/angular/services/battery-level.service/index.ts +32 -0
  62. package/src/angular/services/battery-state.service/index.ts +27 -0
  63. package/src/angular/services/low-power-mode.service/index.ts +27 -0
  64. package/src/core/battery.ts +105 -0
  65. package/src/core/index.ts +19 -0
  66. package/src/core/native-module.ts +31 -0
  67. package/src/core/types.ts +47 -0
  68. package/src/react/hooks/use-battery-level/index.ts +19 -0
  69. package/src/react/hooks/use-battery-state/index.ts +17 -0
  70. package/src/react/hooks/use-low-power-mode/index.ts +18 -0
  71. package/src/react/index.ts +26 -0
  72. package/src/vue/composables/use-battery-level/index.ts +32 -0
  73. package/src/vue/composables/use-battery-state/index.ts +31 -0
  74. package/src/vue/composables/use-low-power-mode/index.ts +31 -0
  75. package/src/vue/index.ts +26 -0
@@ -0,0 +1,40 @@
1
+ export type PowerState = {
2
+ /** A number between `0` and `1`, inclusive, or `-1` if the battery level is unknown. */
3
+ batteryLevel: number;
4
+ /** An enum value representing the battery state. */
5
+ batteryState: BatteryState;
6
+ /** `true` if lowPowerMode is on, `false` if lowPowerMode is off. */
7
+ lowPowerMode: boolean;
8
+ };
9
+ export declare enum BatteryState {
10
+ /** If the battery state is unknown or inaccessible. */
11
+ UNKNOWN = 0,
12
+ /**
13
+ * If the battery is discharging (typically not connected to power). On Android, this
14
+ * corresponds to `BATTERY_STATUS_DISCHARGING`.
15
+ */
16
+ UNPLUGGED = 1,
17
+ /** If battery is charging. */
18
+ CHARGING = 2,
19
+ /** If the battery level is full. */
20
+ FULL = 3,
21
+ /**
22
+ * The battery is not charging while power is connected (AC/USB/wireless), for example when
23
+ * battery protection limits charge to 80%, or optimized charging pauses. This differs from
24
+ * `UNPLUGGED` (discharging on battery).
25
+ * @platform android
26
+ */
27
+ NOT_CHARGING = 4
28
+ }
29
+ export type BatteryLevelEvent = {
30
+ /** A number between `0` and `1`, inclusive, or `-1` if the battery level is unknown. */
31
+ batteryLevel: number;
32
+ };
33
+ export type BatteryStateEvent = {
34
+ /** An enum value representing the battery state. */
35
+ batteryState: BatteryState;
36
+ };
37
+ export type PowerModeEvent = {
38
+ /** `true` if lowPowerMode is on, `false` if lowPowerMode is off. */
39
+ lowPowerMode: boolean;
40
+ };
@@ -0,0 +1,23 @@
1
+ // Hand-ported from .vendors/expo/packages/expo-battery/src/Battery.types.ts (sdk-57) — plain
2
+ // data shapes, no `expo` meta-package import to swap out (unlike local-auth's types.ts).
3
+ export var BatteryState;
4
+ (function (BatteryState) {
5
+ /** If the battery state is unknown or inaccessible. */
6
+ BatteryState[BatteryState["UNKNOWN"] = 0] = "UNKNOWN";
7
+ /**
8
+ * If the battery is discharging (typically not connected to power). On Android, this
9
+ * corresponds to `BATTERY_STATUS_DISCHARGING`.
10
+ */
11
+ BatteryState[BatteryState["UNPLUGGED"] = 1] = "UNPLUGGED";
12
+ /** If battery is charging. */
13
+ BatteryState[BatteryState["CHARGING"] = 2] = "CHARGING";
14
+ /** If the battery level is full. */
15
+ BatteryState[BatteryState["FULL"] = 3] = "FULL";
16
+ /**
17
+ * The battery is not charging while power is connected (AC/USB/wireless), for example when
18
+ * battery protection limits charge to 80%, or optimized charging pauses. This differs from
19
+ * `UNPLUGGED` (discharging on battery).
20
+ * @platform android
21
+ */
22
+ BatteryState[BatteryState["NOT_CHARGING"] = 4] = "NOT_CHARGING";
23
+ })(BatteryState || (BatteryState = {}));
@@ -0,0 +1 @@
1
+ export declare function useBatteryLevel(): number;
@@ -0,0 +1,16 @@
1
+ // React lifecycle wiring over the framework-agnostic core (core/battery.ts) — mirrors the
2
+ // lifecycle-bucket naming convention of adapters/react/src/hooks and the shape of
3
+ // packages/sensors/src/react/hooks/use-accelerometer. Seeds the initial value with a one-shot
4
+ // getBatteryLevelAsync() call before the first native event fires, matching upstream's own
5
+ // useBatteryLevel (.vendors/expo/packages/expo-battery/src/Battery.ts).
6
+ import { useEffect, useState } from 'react';
7
+ import { addBatteryLevelListener, getBatteryLevelAsync } from '../../../core/index.js';
8
+ export function useBatteryLevel() {
9
+ const [batteryLevel, setBatteryLevel] = useState(-1);
10
+ useEffect(() => {
11
+ getBatteryLevelAsync().then(setBatteryLevel);
12
+ const subscription = addBatteryLevelListener(event => setBatteryLevel(event.batteryLevel));
13
+ return () => subscription.remove();
14
+ }, []);
15
+ return batteryLevel;
16
+ }
@@ -0,0 +1,2 @@
1
+ import { BatteryState } from '../../../core';
2
+ export declare function useBatteryState(): BatteryState;
@@ -0,0 +1,14 @@
1
+ // React lifecycle wiring over the framework-agnostic core (core/battery.ts) — mirrors
2
+ // use-battery-level's shape. Seeds the initial value with a one-shot getBatteryStateAsync()
3
+ // call before the first native event fires, matching upstream's own useBatteryState.
4
+ import { useEffect, useState } from 'react';
5
+ import { addBatteryStateListener, BatteryState, getBatteryStateAsync } from '../../../core/index.js';
6
+ export function useBatteryState() {
7
+ const [batteryState, setBatteryState] = useState(BatteryState.UNKNOWN);
8
+ useEffect(() => {
9
+ getBatteryStateAsync().then(setBatteryState);
10
+ const subscription = addBatteryStateListener(event => setBatteryState(event.batteryState));
11
+ return () => subscription.remove();
12
+ }, []);
13
+ return batteryState;
14
+ }
@@ -0,0 +1 @@
1
+ export declare function useLowPowerMode(): boolean;
@@ -0,0 +1,15 @@
1
+ // React lifecycle wiring over the framework-agnostic core (core/battery.ts) — mirrors
2
+ // use-battery-level's shape. Seeds the initial value with a one-shot
3
+ // isLowPowerModeEnabledAsync() call before the first native event fires, matching upstream's
4
+ // own useLowPowerMode.
5
+ import { useEffect, useState } from 'react';
6
+ import { addLowPowerModeListener, isLowPowerModeEnabledAsync } from '../../../core/index.js';
7
+ export function useLowPowerMode() {
8
+ const [lowPowerMode, setLowPowerMode] = useState(false);
9
+ useEffect(() => {
10
+ isLowPowerModeEnabledAsync().then(setLowPowerMode);
11
+ const subscription = addLowPowerModeListener(event => setLowPowerMode(event.lowPowerMode));
12
+ return () => subscription.remove();
13
+ }, []);
14
+ return lowPowerMode;
15
+ }
@@ -0,0 +1,4 @@
1
+ export { useBatteryLevel } from './hooks/use-battery-level';
2
+ export { useBatteryState } from './hooks/use-battery-state';
3
+ export { useLowPowerMode } from './hooks/use-low-power-mode';
4
+ export { isAvailableAsync, getBatteryLevelAsync, getBatteryStateAsync, isLowPowerModeEnabledAsync, isBatteryOptimizationEnabledAsync, getPowerStateAsync, addBatteryLevelListener, addBatteryStateListener, addLowPowerModeListener, BatteryState, type PowerState, type BatteryLevelEvent, type BatteryStateEvent, type PowerModeEvent, type EventSubscription, } from '../core';
@@ -0,0 +1,9 @@
1
+ // @symbiote-native/battery/react: the React entry over the framework-agnostic core. Battery's
2
+ // three subscription-backed values (level/state/low-power-mode) each get their own lifecycle
3
+ // hook, matching upstream's own useBatteryLevel/useBatteryState/useLowPowerMode being three
4
+ // separate hooks, not one combined hook — mirrors the lifecycle-bucket naming convention of
5
+ // adapters/react/src/hooks (never `composables`, that's Vue's term).
6
+ export { useBatteryLevel } from './hooks/use-battery-level/index.js';
7
+ export { useBatteryState } from './hooks/use-battery-state/index.js';
8
+ export { useLowPowerMode } from './hooks/use-low-power-mode/index.js';
9
+ export { isAvailableAsync, getBatteryLevelAsync, getBatteryStateAsync, isLowPowerModeEnabledAsync, isBatteryOptimizationEnabledAsync, getPowerStateAsync, addBatteryLevelListener, addBatteryStateListener, addLowPowerModeListener, BatteryState, } from '../core/index.js';
@@ -0,0 +1,2 @@
1
+ import { type Ref } from '@vue/runtime-core';
2
+ export declare function useBatteryLevel(): Ref<number>;
@@ -0,0 +1,23 @@
1
+ // Vue lifecycle wiring over the framework-agnostic core (core/battery.ts) — mirrors the
2
+ // lifecycle-bucket naming convention of adapters/vue/src/composables and the
3
+ // onMounted/onUnmounted shape of packages/sensors/src/vue/composables/use-accelerometer. Seeds
4
+ // the initial value with a one-shot getBatteryLevelAsync() call before the first native event
5
+ // fires, matching upstream's own useBatteryLevel.
6
+ import { onMounted, onUnmounted, ref } from '@vue/runtime-core';
7
+ import { addBatteryLevelListener, getBatteryLevelAsync, } from '../../../core/index.js';
8
+ export function useBatteryLevel() {
9
+ const batteryLevel = ref(-1);
10
+ let subscription;
11
+ onMounted(() => {
12
+ getBatteryLevelAsync().then(level => {
13
+ batteryLevel.value = level;
14
+ });
15
+ subscription = addBatteryLevelListener(event => {
16
+ batteryLevel.value = event.batteryLevel;
17
+ });
18
+ });
19
+ onUnmounted(() => {
20
+ subscription?.remove();
21
+ });
22
+ return batteryLevel;
23
+ }
@@ -0,0 +1,3 @@
1
+ import { type Ref } from '@vue/runtime-core';
2
+ import { BatteryState } from '../../../core';
3
+ export declare function useBatteryState(): Ref<BatteryState>;
@@ -0,0 +1,21 @@
1
+ // Vue lifecycle wiring over the framework-agnostic core (core/battery.ts) — mirrors
2
+ // use-battery-level's shape. Seeds the initial value with a one-shot getBatteryStateAsync()
3
+ // call before the first native event fires, matching upstream's own useBatteryState.
4
+ import { onMounted, onUnmounted, ref } from '@vue/runtime-core';
5
+ import { addBatteryStateListener, BatteryState, getBatteryStateAsync, } from '../../../core/index.js';
6
+ export function useBatteryState() {
7
+ const batteryState = ref(BatteryState.UNKNOWN);
8
+ let subscription;
9
+ onMounted(() => {
10
+ getBatteryStateAsync().then(state => {
11
+ batteryState.value = state;
12
+ });
13
+ subscription = addBatteryStateListener(event => {
14
+ batteryState.value = event.batteryState;
15
+ });
16
+ });
17
+ onUnmounted(() => {
18
+ subscription?.remove();
19
+ });
20
+ return batteryState;
21
+ }
@@ -0,0 +1,2 @@
1
+ import { type Ref } from '@vue/runtime-core';
2
+ export declare function useLowPowerMode(): Ref<boolean>;
@@ -0,0 +1,22 @@
1
+ // Vue lifecycle wiring over the framework-agnostic core (core/battery.ts) — mirrors
2
+ // use-battery-level's shape. Seeds the initial value with a one-shot
3
+ // isLowPowerModeEnabledAsync() call before the first native event fires, matching upstream's
4
+ // own useLowPowerMode.
5
+ import { onMounted, onUnmounted, ref } from '@vue/runtime-core';
6
+ import { addLowPowerModeListener, isLowPowerModeEnabledAsync, } from '../../../core/index.js';
7
+ export function useLowPowerMode() {
8
+ const lowPowerMode = ref(false);
9
+ let subscription;
10
+ onMounted(() => {
11
+ isLowPowerModeEnabledAsync().then(enabled => {
12
+ lowPowerMode.value = enabled;
13
+ });
14
+ subscription = addLowPowerModeListener(event => {
15
+ lowPowerMode.value = event.lowPowerMode;
16
+ });
17
+ });
18
+ onUnmounted(() => {
19
+ subscription?.remove();
20
+ });
21
+ return lowPowerMode;
22
+ }
@@ -0,0 +1,4 @@
1
+ export { useBatteryLevel } from './composables/use-battery-level';
2
+ export { useBatteryState } from './composables/use-battery-state';
3
+ export { useLowPowerMode } from './composables/use-low-power-mode';
4
+ export { isAvailableAsync, getBatteryLevelAsync, getBatteryStateAsync, isLowPowerModeEnabledAsync, isBatteryOptimizationEnabledAsync, getPowerStateAsync, addBatteryLevelListener, addBatteryStateListener, addLowPowerModeListener, BatteryState, type PowerState, type BatteryLevelEvent, type BatteryStateEvent, type PowerModeEvent, type EventSubscription, } from '../core';
@@ -0,0 +1,9 @@
1
+ // @symbiote-native/battery/vue: the Vue entry over the framework-agnostic core. Battery's three
2
+ // subscription-backed values (level/state/low-power-mode) each get their own lifecycle
3
+ // composable, matching upstream's own useBatteryLevel/useBatteryState/useLowPowerMode being
4
+ // three separate hooks, not one combined hook — mirrors the lifecycle-bucket naming convention
5
+ // of adapters/vue/src/composables (never `hooks/`, that's React's term).
6
+ export { useBatteryLevel } from './composables/use-battery-level/index.js';
7
+ export { useBatteryState } from './composables/use-battery-state/index.js';
8
+ export { useLowPowerMode } from './composables/use-low-power-mode/index.js';
9
+ export { isAvailableAsync, getBatteryLevelAsync, getBatteryStateAsync, isLowPowerModeEnabledAsync, isBatteryOptimizationEnabledAsync, getPowerStateAsync, addBatteryLevelListener, addBatteryStateListener, addLowPowerModeListener, BatteryState, } from '../core/index.js';
@@ -0,0 +1,4 @@
1
+ export { BatteryLevelService } from './services/battery-level.service';
2
+ export { BatteryStateService } from './services/battery-state.service';
3
+ export { LowPowerModeService } from './services/low-power-mode.service';
4
+ export { isAvailableAsync, getBatteryLevelAsync, getBatteryStateAsync, isLowPowerModeEnabledAsync, isBatteryOptimizationEnabledAsync, getPowerStateAsync, addBatteryLevelListener, addBatteryStateListener, addLowPowerModeListener, BatteryState, type PowerState, type BatteryLevelEvent, type BatteryStateEvent, type PowerModeEvent, type EventSubscription, } from '../core';
@@ -0,0 +1,9 @@
1
+ // BatteryLevelService/BatteryStateService/LowPowerModeService are the Angular-only lifecycle
2
+ // half; the free functions and event subscription plumbing all live in core, shared with
3
+ // React/Vue. Three separate services (not one combined service), matching upstream's own
4
+ // useBatteryLevel/useBatteryState/useLowPowerMode being three separate hooks.
5
+ export { BatteryLevelService } from './services/battery-level.service';
6
+ export { BatteryStateService } from './services/battery-state.service';
7
+ export { LowPowerModeService } from './services/low-power-mode.service';
8
+ export { isAvailableAsync, getBatteryLevelAsync, getBatteryStateAsync, isLowPowerModeEnabledAsync, isBatteryOptimizationEnabledAsync, getPowerStateAsync, addBatteryLevelListener, addBatteryStateListener, addLowPowerModeListener, BatteryState, } from '../core';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/angular/index.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,yFAAyF;AACzF,yFAAyF;AACzF,8EAA8E;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC1B,iCAAiC,EACjC,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,GAMb,MAAM,SAAS,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type Signal } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export declare class BatteryLevelService {
4
+ private readonly injector;
5
+ connect(): Signal<number>;
6
+ static ɵfac: i0.ɵɵFactoryDeclaration<BatteryLevelService, never>;
7
+ static ɵprov: i0.ɵɵInjectableDeclaration<BatteryLevelService>;
8
+ }
@@ -0,0 +1,33 @@
1
+ import { effect, inject, Injectable, Injector, signal } from '@angular/core';
2
+ import { addBatteryLevelListener, getBatteryLevelAsync } from '../../../core';
3
+ import * as i0 from "@angular/core";
4
+ // Angular twin of React's `useBatteryLevel` hook and Vue's `useBatteryLevel` composable.
5
+ // Angular has no per-instance hook — state and lifecycle live in DI instead, so `connect()`
6
+ // stands in for the hook's role: call it ONCE (typically from a component's field initializer,
7
+ // inside an injection context).
8
+ //
9
+ // readonly batteryLevel = inject(BatteryLevelService).connect();
10
+ // // template: {{ batteryLevel() }}
11
+ //
12
+ // Mirrors AccelerometerService.connect() — a single effect() that seeds the initial value with
13
+ // getBatteryLevelAsync(), subscribes once, and cleans up once.
14
+ export class BatteryLevelService {
15
+ injector = inject(Injector);
16
+ connect() {
17
+ const batteryLevel = signal(-1, /* @ts-ignore */
18
+ ...(ngDevMode ? [{ debugName: "batteryLevel" }] : /* istanbul ignore next */ []));
19
+ effect(onCleanup => {
20
+ getBatteryLevelAsync().then(level => batteryLevel.set(level));
21
+ const subscription = addBatteryLevelListener(event => batteryLevel.set(event.batteryLevel));
22
+ onCleanup(() => subscription.remove());
23
+ }, { injector: this.injector });
24
+ return batteryLevel.asReadonly();
25
+ }
26
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: BatteryLevelService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
27
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: BatteryLevelService, providedIn: 'root' });
28
+ }
29
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: BatteryLevelService, decorators: [{
30
+ type: Injectable,
31
+ args: [{ providedIn: 'root' }]
32
+ }] });
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/battery-level.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;;AAE9E,yFAAyF;AACzF,4FAA4F;AAC5F,+FAA+F;AAC/F,gCAAgC;AAChC,EAAE;AACF,mEAAmE;AACnE,sCAAsC;AACtC,EAAE;AACF,+FAA+F;AAC/F,+DAA+D;AAE/D,MAAM,OAAO,mBAAmB;IACb,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE7C,OAAO;QACL,MAAM,YAAY,GAAG,MAAM,CAAC,CAAC,CAAC;yFAAC,CAAC;QAEhC,MAAM,CACJ,SAAS,CAAC,EAAE;YACV,oBAAoB,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;YAC9D,MAAM,YAAY,GAAG,uBAAuB,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;YAC5F,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAC5B,CAAC;QAEF,OAAO,YAAY,CAAC,UAAU,EAAE,CAAC;IACnC,CAAC;uGAhBU,mBAAmB;2GAAnB,mBAAmB,cADN,MAAM;;2FACnB,mBAAmB;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
@@ -0,0 +1,9 @@
1
+ import { type Signal } from '@angular/core';
2
+ import { BatteryState } from '../../../core';
3
+ import * as i0 from "@angular/core";
4
+ export declare class BatteryStateService {
5
+ private readonly injector;
6
+ connect(): Signal<BatteryState>;
7
+ static ɵfac: i0.ɵɵFactoryDeclaration<BatteryStateService, never>;
8
+ static ɵprov: i0.ɵɵInjectableDeclaration<BatteryStateService>;
9
+ }
@@ -0,0 +1,28 @@
1
+ import { effect, inject, Injectable, Injector, signal } from '@angular/core';
2
+ import { addBatteryStateListener, BatteryState, getBatteryStateAsync } from '../../../core';
3
+ import * as i0 from "@angular/core";
4
+ // Angular twin of React's `useBatteryState` hook and Vue's `useBatteryState` composable. See
5
+ // BatteryLevelService for the `connect()` pattern rationale.
6
+ //
7
+ // readonly batteryState = inject(BatteryStateService).connect();
8
+ // // template: {{ batteryState() }}
9
+ export class BatteryStateService {
10
+ injector = inject(Injector);
11
+ connect() {
12
+ const batteryState = signal(BatteryState.UNKNOWN, /* @ts-ignore */
13
+ ...(ngDevMode ? [{ debugName: "batteryState" }] : /* istanbul ignore next */ []));
14
+ effect(onCleanup => {
15
+ getBatteryStateAsync().then(state => batteryState.set(state));
16
+ const subscription = addBatteryStateListener(event => batteryState.set(event.batteryState));
17
+ onCleanup(() => subscription.remove());
18
+ }, { injector: this.injector });
19
+ return batteryState.asReadonly();
20
+ }
21
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: BatteryStateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
22
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: BatteryStateService, providedIn: 'root' });
23
+ }
24
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: BatteryStateService, decorators: [{
25
+ type: Injectable,
26
+ args: [{ providedIn: 'root' }]
27
+ }] });
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/battery-state.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;;AAE5F,6FAA6F;AAC7F,6DAA6D;AAC7D,EAAE;AACF,mEAAmE;AACnE,sCAAsC;AAEtC,MAAM,OAAO,mBAAmB;IACb,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE7C,OAAO;QACL,MAAM,YAAY,GAAG,MAAM,CAAe,YAAY,CAAC,OAAO;yFAAC,CAAC;QAEhE,MAAM,CACJ,SAAS,CAAC,EAAE;YACV,oBAAoB,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;YAC9D,MAAM,YAAY,GAAG,uBAAuB,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;YAC5F,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAC5B,CAAC;QAEF,OAAO,YAAY,CAAC,UAAU,EAAE,CAAC;IACnC,CAAC;uGAhBU,mBAAmB;2GAAnB,mBAAmB,cADN,MAAM;;2FACnB,mBAAmB;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
@@ -0,0 +1,8 @@
1
+ import { type Signal } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export declare class LowPowerModeService {
4
+ private readonly injector;
5
+ connect(): Signal<boolean>;
6
+ static ɵfac: i0.ɵɵFactoryDeclaration<LowPowerModeService, never>;
7
+ static ɵprov: i0.ɵɵInjectableDeclaration<LowPowerModeService>;
8
+ }
@@ -0,0 +1,28 @@
1
+ import { effect, inject, Injectable, Injector, signal } from '@angular/core';
2
+ import { addLowPowerModeListener, isLowPowerModeEnabledAsync } from '../../../core';
3
+ import * as i0 from "@angular/core";
4
+ // Angular twin of React's `useLowPowerMode` hook and Vue's `useLowPowerMode` composable. See
5
+ // BatteryLevelService for the `connect()` pattern rationale.
6
+ //
7
+ // readonly lowPowerMode = inject(LowPowerModeService).connect();
8
+ // // template: {{ lowPowerMode() }}
9
+ export class LowPowerModeService {
10
+ injector = inject(Injector);
11
+ connect() {
12
+ const lowPowerMode = signal(false, /* @ts-ignore */
13
+ ...(ngDevMode ? [{ debugName: "lowPowerMode" }] : /* istanbul ignore next */ []));
14
+ effect(onCleanup => {
15
+ isLowPowerModeEnabledAsync().then(enabled => lowPowerMode.set(enabled));
16
+ const subscription = addLowPowerModeListener(event => lowPowerMode.set(event.lowPowerMode));
17
+ onCleanup(() => subscription.remove());
18
+ }, { injector: this.injector });
19
+ return lowPowerMode.asReadonly();
20
+ }
21
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: LowPowerModeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
22
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: LowPowerModeService, providedIn: 'root' });
23
+ }
24
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: LowPowerModeService, decorators: [{
25
+ type: Injectable,
26
+ args: [{ providedIn: 'root' }]
27
+ }] });
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/low-power-mode.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;;AAEpF,6FAA6F;AAC7F,6DAA6D;AAC7D,EAAE;AACF,mEAAmE;AACnE,sCAAsC;AAEtC,MAAM,OAAO,mBAAmB;IACb,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE7C,OAAO;QACL,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK;yFAAC,CAAC;QAEnC,MAAM,CACJ,SAAS,CAAC,EAAE;YACV,0BAA0B,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;YACxE,MAAM,YAAY,GAAG,uBAAuB,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;YAC5F,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAC5B,CAAC;QAEF,OAAO,YAAY,CAAC,UAAU,EAAE,CAAC;IACnC,CAAC;uGAhBU,mBAAmB;2GAAnB,mBAAmB,cADN,MAAM;;2FACnB,mBAAmB;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
@@ -0,0 +1,44 @@
1
+ import type { EventSubscription } from 'expo-modules-core';
2
+ import { BatteryState, type BatteryLevelEvent, type BatteryStateEvent, type PowerModeEvent, type PowerState } from './types';
3
+ /**
4
+ * Resolves with whether the battery API is available on the current device. `true` on Android
5
+ * and physical iOS devices, `false` on iOS simulators.
6
+ */
7
+ export declare function isAvailableAsync(): Promise<boolean>;
8
+ /**
9
+ * Gets the battery level of the device as a number between `0` and `1`, inclusive. If the
10
+ * device does not support retrieving the battery level, this method returns `-1`.
11
+ */
12
+ export declare function getBatteryLevelAsync(): Promise<number>;
13
+ /** Tells the battery's current state. */
14
+ export declare function getBatteryStateAsync(): Promise<BatteryState>;
15
+ /**
16
+ * Gets the current status of Power Saver mode on Android and Low Power mode on iOS. If a
17
+ * platform doesn't support low-power-mode reporting, this always resolves `false`, even if the
18
+ * device is actually in low-power mode.
19
+ */
20
+ export declare function isLowPowerModeEnabledAsync(): Promise<boolean>;
21
+ /**
22
+ * Checks whether battery optimization is enabled for this app. If enabled, background tasks
23
+ * might be affected when the app goes into doze mode state.
24
+ * @platform android
25
+ */
26
+ export declare function isBatteryOptimizationEnabledAsync(): Promise<boolean>;
27
+ /**
28
+ * Gets the power state of the device: battery level, whether it is plugged in, and whether the
29
+ * system is currently in Power Saver Mode (Android) / Low Power Mode (iOS).
30
+ */
31
+ export declare function getPowerStateAsync(): Promise<PowerState>;
32
+ /**
33
+ * Subscribe to battery level change updates. On Android this only fires on significant changes
34
+ * (crossing the low/okay battery thresholds); on iOS it fires per one-percent drop, at most once
35
+ * a minute.
36
+ */
37
+ export declare function addBatteryLevelListener(listener: (event: BatteryLevelEvent) => void): EventSubscription;
38
+ /** Subscribe to battery state (charging/full/unplugged/unknown) change updates. */
39
+ export declare function addBatteryStateListener(listener: (event: BatteryStateEvent) => void): EventSubscription;
40
+ /**
41
+ * Subscribe to Power Saver Mode (Android) / Low Power Mode (iOS) updates. Fires whenever the
42
+ * power mode is toggled.
43
+ */
44
+ export declare function addLowPowerModeListener(listener: (event: PowerModeEvent) => void): EventSubscription;
@@ -0,0 +1,80 @@
1
+ import { expoBattery } from './native-module';
2
+ import { BatteryState, } from './types';
3
+ /**
4
+ * Resolves with whether the battery API is available on the current device. `true` on Android
5
+ * and physical iOS devices, `false` on iOS simulators.
6
+ */
7
+ export async function isAvailableAsync() {
8
+ return Promise.resolve((expoBattery && expoBattery.isSupported) || false);
9
+ }
10
+ /**
11
+ * Gets the battery level of the device as a number between `0` and `1`, inclusive. If the
12
+ * device does not support retrieving the battery level, this method returns `-1`.
13
+ */
14
+ export async function getBatteryLevelAsync() {
15
+ if (!expoBattery.getBatteryLevelAsync) {
16
+ return -1;
17
+ }
18
+ return expoBattery.getBatteryLevelAsync();
19
+ }
20
+ /** Tells the battery's current state. */
21
+ export async function getBatteryStateAsync() {
22
+ if (!expoBattery.getBatteryStateAsync) {
23
+ return BatteryState.UNKNOWN;
24
+ }
25
+ return expoBattery.getBatteryStateAsync();
26
+ }
27
+ /**
28
+ * Gets the current status of Power Saver mode on Android and Low Power mode on iOS. If a
29
+ * platform doesn't support low-power-mode reporting, this always resolves `false`, even if the
30
+ * device is actually in low-power mode.
31
+ */
32
+ export async function isLowPowerModeEnabledAsync() {
33
+ if (!expoBattery.isLowPowerModeEnabledAsync) {
34
+ return false;
35
+ }
36
+ return expoBattery.isLowPowerModeEnabledAsync();
37
+ }
38
+ /**
39
+ * Checks whether battery optimization is enabled for this app. If enabled, background tasks
40
+ * might be affected when the app goes into doze mode state.
41
+ * @platform android
42
+ */
43
+ export async function isBatteryOptimizationEnabledAsync() {
44
+ if (!expoBattery.isBatteryOptimizationEnabledAsync) {
45
+ return false;
46
+ }
47
+ return expoBattery.isBatteryOptimizationEnabledAsync();
48
+ }
49
+ /**
50
+ * Gets the power state of the device: battery level, whether it is plugged in, and whether the
51
+ * system is currently in Power Saver Mode (Android) / Low Power Mode (iOS).
52
+ */
53
+ export async function getPowerStateAsync() {
54
+ const [batteryLevel, batteryState, lowPowerMode] = await Promise.all([
55
+ getBatteryLevelAsync(),
56
+ getBatteryStateAsync(),
57
+ isLowPowerModeEnabledAsync(),
58
+ ]);
59
+ return { batteryLevel, batteryState, lowPowerMode };
60
+ }
61
+ /**
62
+ * Subscribe to battery level change updates. On Android this only fires on significant changes
63
+ * (crossing the low/okay battery thresholds); on iOS it fires per one-percent drop, at most once
64
+ * a minute.
65
+ */
66
+ export function addBatteryLevelListener(listener) {
67
+ return expoBattery.addListener('Expo.batteryLevelDidChange', listener);
68
+ }
69
+ /** Subscribe to battery state (charging/full/unplugged/unknown) change updates. */
70
+ export function addBatteryStateListener(listener) {
71
+ return expoBattery.addListener('Expo.batteryStateDidChange', listener);
72
+ }
73
+ /**
74
+ * Subscribe to Power Saver Mode (Android) / Low Power Mode (iOS) updates. Fires whenever the
75
+ * power mode is toggled.
76
+ */
77
+ export function addLowPowerModeListener(listener) {
78
+ return expoBattery.addListener('Expo.powerModeDidChange', listener);
79
+ }
80
+ //# sourceMappingURL=battery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"battery.js","sourceRoot":"","sources":["../../src/core/battery.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,YAAY,GAKb,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,IAAI,WAAW,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,CAAC;AAC5E,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE,CAAC;QACtC,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IACD,OAAO,WAAW,CAAC,oBAAoB,EAAE,CAAC;AAC5C,CAAC;AAED,yCAAyC;AACzC,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE,CAAC;QACtC,OAAO,YAAY,CAAC,OAAO,CAAC;IAC9B,CAAC;IACD,OAAO,WAAW,CAAC,oBAAoB,EAAE,CAAC;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B;IAC9C,IAAI,CAAC,WAAW,CAAC,0BAA0B,EAAE,CAAC;QAC5C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,WAAW,CAAC,0BAA0B,EAAE,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iCAAiC;IACrD,IAAI,CAAC,WAAW,CAAC,iCAAiC,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,WAAW,CAAC,iCAAiC,EAAE,CAAC;AACzD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,MAAM,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACnE,oBAAoB,EAAE;QACtB,oBAAoB,EAAE;QACtB,0BAA0B,EAAE;KAC7B,CAAC,CAAC;IACH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAA4C;IAE5C,OAAO,WAAW,CAAC,WAAW,CAAC,4BAA4B,EAAE,QAAQ,CAAC,CAAC;AACzE,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,uBAAuB,CACrC,QAA4C;IAE5C,OAAO,WAAW,CAAC,WAAW,CAAC,4BAA4B,EAAE,QAAQ,CAAC,CAAC;AACzE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAAyC;IAEzC,OAAO,WAAW,CAAC,WAAW,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;AACtE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { isAvailableAsync, getBatteryLevelAsync, getBatteryStateAsync, isLowPowerModeEnabledAsync, isBatteryOptimizationEnabledAsync, getPowerStateAsync, addBatteryLevelListener, addBatteryStateListener, addLowPowerModeListener, } from './battery';
2
+ export { BatteryState, type PowerState, type BatteryLevelEvent, type BatteryStateEvent, type PowerModeEvent, } from './types';
3
+ export type { EventSubscription } from 'expo-modules-core';
@@ -0,0 +1,3 @@
1
+ export { isAvailableAsync, getBatteryLevelAsync, getBatteryStateAsync, isLowPowerModeEnabledAsync, isBatteryOptimizationEnabledAsync, getPowerStateAsync, addBatteryLevelListener, addBatteryStateListener, addLowPowerModeListener, } from './battery';
2
+ export { BatteryState, } from './types';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC1B,iCAAiC,EACjC,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,YAAY,GAKb,MAAM,SAAS,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { EventSubscription } from 'expo-modules-core';
2
+ import type { BatteryLevelEvent, BatteryState, BatteryStateEvent, PowerModeEvent } from './types';
3
+ export type INativeBatteryModule = {
4
+ isSupported?: boolean;
5
+ getBatteryLevelAsync?(): Promise<number>;
6
+ getBatteryStateAsync?(): Promise<BatteryState>;
7
+ isLowPowerModeEnabledAsync?(): Promise<boolean>;
8
+ isBatteryOptimizationEnabledAsync?(): Promise<boolean>;
9
+ addListener(eventName: 'Expo.batteryLevelDidChange', listener: (event: BatteryLevelEvent) => void): EventSubscription;
10
+ addListener(eventName: 'Expo.batteryStateDidChange', listener: (event: BatteryStateEvent) => void): EventSubscription;
11
+ addListener(eventName: 'Expo.powerModeDidChange', listener: (event: PowerModeEvent) => void): EventSubscription;
12
+ };
13
+ export declare const expoBattery: INativeBatteryModule;
@@ -0,0 +1,4 @@
1
+ import { requireNativeModule } from 'expo-modules-core';
2
+ const EXPO_BATTERY_MODULE_NAME = 'ExpoBattery';
3
+ export const expoBattery = requireNativeModule(EXPO_BATTERY_MODULE_NAME);
4
+ //# sourceMappingURL=native-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-module.js","sourceRoot":"","sources":["../../src/core/native-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAIxD,MAAM,wBAAwB,GAAG,aAAa,CAAC;AA0B/C,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAAuB,wBAAwB,CAAC,CAAC"}
@@ -0,0 +1,40 @@
1
+ export type PowerState = {
2
+ /** A number between `0` and `1`, inclusive, or `-1` if the battery level is unknown. */
3
+ batteryLevel: number;
4
+ /** An enum value representing the battery state. */
5
+ batteryState: BatteryState;
6
+ /** `true` if lowPowerMode is on, `false` if lowPowerMode is off. */
7
+ lowPowerMode: boolean;
8
+ };
9
+ export declare enum BatteryState {
10
+ /** If the battery state is unknown or inaccessible. */
11
+ UNKNOWN = 0,
12
+ /**
13
+ * If the battery is discharging (typically not connected to power). On Android, this
14
+ * corresponds to `BATTERY_STATUS_DISCHARGING`.
15
+ */
16
+ UNPLUGGED = 1,
17
+ /** If battery is charging. */
18
+ CHARGING = 2,
19
+ /** If the battery level is full. */
20
+ FULL = 3,
21
+ /**
22
+ * The battery is not charging while power is connected (AC/USB/wireless), for example when
23
+ * battery protection limits charge to 80%, or optimized charging pauses. This differs from
24
+ * `UNPLUGGED` (discharging on battery).
25
+ * @platform android
26
+ */
27
+ NOT_CHARGING = 4
28
+ }
29
+ export type BatteryLevelEvent = {
30
+ /** A number between `0` and `1`, inclusive, or `-1` if the battery level is unknown. */
31
+ batteryLevel: number;
32
+ };
33
+ export type BatteryStateEvent = {
34
+ /** An enum value representing the battery state. */
35
+ batteryState: BatteryState;
36
+ };
37
+ export type PowerModeEvent = {
38
+ /** `true` if lowPowerMode is on, `false` if lowPowerMode is off. */
39
+ lowPowerMode: boolean;
40
+ };