@symbiote-native/battery 0.1.0 → 0.3.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 (58) hide show
  1. package/README.md +101 -28
  2. package/build/angular/index.d.ts +1 -1
  3. package/build/angular/index.js +1 -1
  4. package/build/angular/services/battery-level.service/index.js +1 -1
  5. package/build/angular/services/battery-state.service/index.js +2 -2
  6. package/build/angular/services/low-power-mode.service/index.js +2 -2
  7. package/build/react/hooks/use-battery-state/index.js +1 -1
  8. package/build/react/hooks/use-low-power-mode/index.js +1 -1
  9. package/build/react/index.d.ts +1 -1
  10. package/build/react/index.js +1 -1
  11. package/build/solid/index.d.ts +4 -0
  12. package/build/solid/index.js +10 -0
  13. package/build/solid/primitives/create-battery-level.d.ts +2 -0
  14. package/build/solid/primitives/create-battery-level.js +35 -0
  15. package/build/solid/primitives/create-battery-state.d.ts +3 -0
  16. package/build/solid/primitives/create-battery-state.js +21 -0
  17. package/build/solid/primitives/create-low-power-mode.d.ts +2 -0
  18. package/build/solid/primitives/create-low-power-mode.js +21 -0
  19. package/build/svelte/index.d.ts +4 -0
  20. package/build/svelte/index.js +9 -0
  21. package/build/svelte/runes/use-battery-level.svelte.d.ts +3 -0
  22. package/build/svelte/runes/use-battery-level.svelte.js +37 -0
  23. package/build/svelte/runes/use-battery-state.svelte.d.ts +4 -0
  24. package/build/svelte/runes/use-battery-state.svelte.js +22 -0
  25. package/build/svelte/runes/use-low-power-mode.svelte.d.ts +3 -0
  26. package/build/svelte/runes/use-low-power-mode.svelte.js +22 -0
  27. package/build/vue/index.d.ts +1 -1
  28. package/build/vue/index.js +1 -1
  29. package/build-ngc/angular/index.d.ts +1 -1
  30. package/build-ngc/angular/index.js +1 -1
  31. package/build-ngc/angular/index.js.map +1 -1
  32. package/build-ngc/angular/services/battery-level.service/index.js +4 -4
  33. package/build-ngc/angular/services/battery-level.service/index.js.map +1 -1
  34. package/build-ngc/angular/services/battery-state.service/index.js +5 -5
  35. package/build-ngc/angular/services/battery-state.service/index.js.map +1 -1
  36. package/build-ngc/angular/services/low-power-mode.service/index.js +5 -5
  37. package/build-ngc/angular/services/low-power-mode.service/index.js.map +1 -1
  38. package/build-ngc/core/native-module.js.map +1 -1
  39. package/package.json +42 -14
  40. package/src/angular/index.ts +1 -17
  41. package/src/angular/services/battery-level.service/index.ts +11 -2
  42. package/src/angular/services/battery-state.service/index.ts +16 -3
  43. package/src/angular/services/low-power-mode.service/index.ts +15 -3
  44. package/src/core/native-module.ts +9 -2
  45. package/src/react/hooks/use-battery-level/index.ts +3 -1
  46. package/src/react/hooks/use-battery-state/index.ts +11 -3
  47. package/src/react/hooks/use-low-power-mode/index.ts +7 -2
  48. package/src/react/index.ts +1 -17
  49. package/src/solid/index.ts +11 -0
  50. package/src/solid/primitives/create-battery-level.ts +45 -0
  51. package/src/solid/primitives/create-battery-state.ts +33 -0
  52. package/src/solid/primitives/create-low-power-mode.ts +30 -0
  53. package/src/svelte/index.ts +10 -0
  54. package/src/svelte/runes/use-battery-level.svelte.ts +45 -0
  55. package/src/svelte/runes/use-battery-state.svelte.ts +30 -0
  56. package/src/svelte/runes/use-low-power-mode.svelte.ts +29 -0
  57. package/src/svelte/svelte-ambient.d.ts +6 -0
  58. package/src/vue/index.ts +1 -17
@@ -1 +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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/battery-state.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,UAAU,EACV,QAAQ,EACR,MAAM,GAEP,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,uBAAuB,EACvB,YAAY,EACZ,oBAAoB,GACrB,MAAM,eAAe,CAAC;;AAEvB,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,CACnD,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CACrC,CAAC;YACF,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;uGAlBU,mBAAmB;2GAAnB,mBAAmB,cADN,MAAM;;2FACnB,mBAAmB;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
@@ -1,5 +1,5 @@
1
- import { effect, inject, Injectable, Injector, signal } from '@angular/core';
2
- import { addLowPowerModeListener, isLowPowerModeEnabledAsync } from '../../../core';
1
+ import { effect, inject, Injectable, Injector, signal, } from '@angular/core';
2
+ import { addLowPowerModeListener, isLowPowerModeEnabledAsync, } from '../../../core';
3
3
  import * as i0 from "@angular/core";
4
4
  // Angular twin of React's `useLowPowerMode` hook and Vue's `useLowPowerMode` composable. See
5
5
  // BatteryLevelService for the `connect()` pattern rationale.
@@ -18,10 +18,10 @@ export class LowPowerModeService {
18
18
  }, { injector: this.injector });
19
19
  return lowPowerMode.asReadonly();
20
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' });
21
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LowPowerModeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
22
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LowPowerModeService, providedIn: 'root' });
23
23
  }
24
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: LowPowerModeService, decorators: [{
24
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LowPowerModeService, decorators: [{
25
25
  type: Injectable,
26
26
  args: [{ providedIn: 'root' }]
27
27
  }] });
@@ -1 +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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/angular/services/low-power-mode.service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,UAAU,EACV,QAAQ,EACR,MAAM,GAEP,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,eAAe,CAAC;;AAEvB,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,CACnD,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CACrC,CAAC;YACF,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;uGAlBU,mBAAmB;2GAAnB,mBAAmB,cADN,MAAM;;2FACnB,mBAAmB;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE"}
@@ -1 +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"}
1
+ {"version":3,"file":"native-module.js","sourceRoot":"","sources":["../../src/core/native-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AASxD,MAAM,wBAAwB,GAAG,aAAa,CAAC;AA0B/C,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAC5C,wBAAwB,CACzB,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@symbiote-native/battery",
3
- "version": "0.1.0",
4
- "description": "expo-battery wrapped for SymbioteNative — one framework-agnostic core, built once and reachable from the React, Vue, and Angular adapters. Battery level and state (charging/full/unplugged/unknown), low-power-mode detection, plus event listeners for level and state changes.",
3
+ "version": "0.3.0",
4
+ "description": "expo-battery wrapped for SymbioteNative — one framework-agnostic core, built once and reachable from the React, Vue, Svelte, Solid, and Angular adapters. Battery level and state (charging/full/unplugged/unknown), low-power-mode detection, plus event listeners for level and state changes.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -30,6 +30,14 @@
30
30
  "types": "./build/react/index.d.ts",
31
31
  "default": "./build/react/index.js"
32
32
  },
33
+ "./svelte": {
34
+ "types": "./build/svelte/index.d.ts",
35
+ "default": "./build/svelte/index.js"
36
+ },
37
+ "./solid": {
38
+ "types": "./build/solid/index.d.ts",
39
+ "default": "./build/solid/index.js"
40
+ },
33
41
  "./angular": {
34
42
  "types": "./build-ngc/angular/index.d.ts",
35
43
  "react-native": "./build-ngc/angular/index.js",
@@ -53,15 +61,19 @@
53
61
  "expo-modules-core": "57.0.5"
54
62
  },
55
63
  "peerDependencies": {
64
+ "@symbiote-native/angular": ">=0.6.2",
56
65
  "@symbiote-native/engine": ">=0.1.7",
66
+ "@symbiote-native/react": ">=0.2.8",
67
+ "@symbiote-native/solid": ">=0.0.1",
68
+ "@symbiote-native/svelte": ">=0.1.0",
69
+ "@symbiote-native/vue": ">=0.3.8",
57
70
  "@angular/core": ">=20",
58
71
  "@vue/runtime-core": "^3.5.13",
59
72
  "react": ">=19.0.0",
60
73
  "react-native": ">=0.86",
61
- "vue": ">=3.5.0",
62
- "@symbiote-native/angular": "0.6.2",
63
- "@symbiote-native/react": "0.2.8",
64
- "@symbiote-native/vue": "0.3.8"
74
+ "solid-js": ">=1.9.0",
75
+ "svelte": ">=5.56.0",
76
+ "vue": ">=3.5.0"
65
77
  },
66
78
  "peerDependenciesMeta": {
67
79
  "@symbiote-native/angular": {
@@ -70,6 +82,12 @@
70
82
  "@symbiote-native/react": {
71
83
  "optional": true
72
84
  },
85
+ "@symbiote-native/solid": {
86
+ "optional": true
87
+ },
88
+ "@symbiote-native/svelte": {
89
+ "optional": true
90
+ },
73
91
  "@symbiote-native/vue": {
74
92
  "optional": true
75
93
  },
@@ -82,24 +100,34 @@
82
100
  "react": {
83
101
  "optional": true
84
102
  },
103
+ "solid-js": {
104
+ "optional": true
105
+ },
106
+ "svelte": {
107
+ "optional": true
108
+ },
85
109
  "vue": {
86
110
  "optional": true
87
111
  }
88
112
  },
89
113
  "devDependencies": {
90
- "@angular/compiler": "^22",
91
- "@angular/compiler-cli": "^22",
92
- "@angular/core": "^22",
114
+ "@angular/compiler": "~22.0.8",
115
+ "@angular/compiler-cli": "~22.0.8",
116
+ "@angular/core": "~22.0.8",
93
117
  "@types/node": "^26.0.0",
94
118
  "@types/react": "^19.2.0",
95
119
  "@vue/runtime-core": "^3.5.13",
96
120
  "react": "19.2.3",
121
+ "solid-js": "^1.9.14",
122
+ "svelte": "^5.56.0",
97
123
  "typescript": "~6.0.0",
98
- "@symbiote-native/angular": "0.6.2",
99
- "@symbiote-native/engine": "0.1.7",
100
- "@symbiote-native/react": "0.2.8",
101
- "@symbiote-native/test-utils": "0.1.6",
102
- "@symbiote-native/vue": "0.3.8"
124
+ "@symbiote-native/angular": "0.8.0",
125
+ "@symbiote-native/engine": "0.3.0",
126
+ "@symbiote-native/react": "0.4.0",
127
+ "@symbiote-native/solid": "0.1.0",
128
+ "@symbiote-native/svelte": "0.3.0",
129
+ "@symbiote-native/test-utils": "0.2.0",
130
+ "@symbiote-native/vue": "0.5.0"
103
131
  },
104
132
  "scripts": {
105
133
  "typecheck": "tsc --build",
@@ -5,20 +5,4 @@
5
5
  export { BatteryLevelService } from './services/battery-level.service';
6
6
  export { BatteryStateService } from './services/battery-state.service';
7
7
  export { LowPowerModeService } from './services/low-power-mode.service';
8
- export {
9
- isAvailableAsync,
10
- getBatteryLevelAsync,
11
- getBatteryStateAsync,
12
- isLowPowerModeEnabledAsync,
13
- isBatteryOptimizationEnabledAsync,
14
- getPowerStateAsync,
15
- addBatteryLevelListener,
16
- addBatteryStateListener,
17
- addLowPowerModeListener,
18
- BatteryState,
19
- type PowerState,
20
- type BatteryLevelEvent,
21
- type BatteryStateEvent,
22
- type PowerModeEvent,
23
- type EventSubscription,
24
- } from '../core';
8
+ export * from '../core';
@@ -1,4 +1,11 @@
1
- import { effect, inject, Injectable, Injector, signal, type Signal } from '@angular/core';
1
+ import {
2
+ effect,
3
+ inject,
4
+ Injectable,
5
+ Injector,
6
+ signal,
7
+ type Signal,
8
+ } from '@angular/core';
2
9
  import { addBatteryLevelListener, getBatteryLevelAsync } from '../../../core';
3
10
 
4
11
  // Angular twin of React's `useBatteryLevel` hook and Vue's `useBatteryLevel` composable.
@@ -21,7 +28,9 @@ export class BatteryLevelService {
21
28
  effect(
22
29
  onCleanup => {
23
30
  getBatteryLevelAsync().then(level => batteryLevel.set(level));
24
- const subscription = addBatteryLevelListener(event => batteryLevel.set(event.batteryLevel));
31
+ const subscription = addBatteryLevelListener(event =>
32
+ batteryLevel.set(event.batteryLevel),
33
+ );
25
34
  onCleanup(() => subscription.remove());
26
35
  },
27
36
  { injector: this.injector },
@@ -1,5 +1,16 @@
1
- import { effect, inject, Injectable, Injector, signal, type Signal } from '@angular/core';
2
- import { addBatteryStateListener, BatteryState, getBatteryStateAsync } from '../../../core';
1
+ import {
2
+ effect,
3
+ inject,
4
+ Injectable,
5
+ Injector,
6
+ signal,
7
+ type Signal,
8
+ } from '@angular/core';
9
+ import {
10
+ addBatteryStateListener,
11
+ BatteryState,
12
+ getBatteryStateAsync,
13
+ } from '../../../core';
3
14
 
4
15
  // Angular twin of React's `useBatteryState` hook and Vue's `useBatteryState` composable. See
5
16
  // BatteryLevelService for the `connect()` pattern rationale.
@@ -16,7 +27,9 @@ export class BatteryStateService {
16
27
  effect(
17
28
  onCleanup => {
18
29
  getBatteryStateAsync().then(state => batteryState.set(state));
19
- const subscription = addBatteryStateListener(event => batteryState.set(event.batteryState));
30
+ const subscription = addBatteryStateListener(event =>
31
+ batteryState.set(event.batteryState),
32
+ );
20
33
  onCleanup(() => subscription.remove());
21
34
  },
22
35
  { injector: this.injector },
@@ -1,5 +1,15 @@
1
- import { effect, inject, Injectable, Injector, signal, type Signal } from '@angular/core';
2
- import { addLowPowerModeListener, isLowPowerModeEnabledAsync } from '../../../core';
1
+ import {
2
+ effect,
3
+ inject,
4
+ Injectable,
5
+ Injector,
6
+ signal,
7
+ type Signal,
8
+ } from '@angular/core';
9
+ import {
10
+ addLowPowerModeListener,
11
+ isLowPowerModeEnabledAsync,
12
+ } from '../../../core';
3
13
 
4
14
  // Angular twin of React's `useLowPowerMode` hook and Vue's `useLowPowerMode` composable. See
5
15
  // BatteryLevelService for the `connect()` pattern rationale.
@@ -16,7 +26,9 @@ export class LowPowerModeService {
16
26
  effect(
17
27
  onCleanup => {
18
28
  isLowPowerModeEnabledAsync().then(enabled => lowPowerMode.set(enabled));
19
- const subscription = addLowPowerModeListener(event => lowPowerMode.set(event.lowPowerMode));
29
+ const subscription = addLowPowerModeListener(event =>
30
+ lowPowerMode.set(event.lowPowerMode),
31
+ );
20
32
  onCleanup(() => subscription.remove());
21
33
  },
22
34
  { injector: this.injector },
@@ -1,6 +1,11 @@
1
1
  import { requireNativeModule } from 'expo-modules-core';
2
2
  import type { EventSubscription } from 'expo-modules-core';
3
- import type { BatteryLevelEvent, BatteryState, BatteryStateEvent, PowerModeEvent } from './types';
3
+ import type {
4
+ BatteryLevelEvent,
5
+ BatteryState,
6
+ BatteryStateEvent,
7
+ PowerModeEvent,
8
+ } from './types';
4
9
 
5
10
  const EXPO_BATTERY_MODULE_NAME = 'ExpoBattery';
6
11
 
@@ -28,4 +33,6 @@ export type INativeBatteryModule = {
28
33
  ): EventSubscription;
29
34
  };
30
35
 
31
- export const expoBattery = requireNativeModule<INativeBatteryModule>(EXPO_BATTERY_MODULE_NAME);
36
+ export const expoBattery = requireNativeModule<INativeBatteryModule>(
37
+ EXPO_BATTERY_MODULE_NAME,
38
+ );
@@ -11,7 +11,9 @@ export function useBatteryLevel(): number {
11
11
 
12
12
  useEffect(() => {
13
13
  getBatteryLevelAsync().then(setBatteryLevel);
14
- const subscription = addBatteryLevelListener(event => setBatteryLevel(event.batteryLevel));
14
+ const subscription = addBatteryLevelListener(event =>
15
+ setBatteryLevel(event.batteryLevel),
16
+ );
15
17
  return () => subscription.remove();
16
18
  }, []);
17
19
 
@@ -2,14 +2,22 @@
2
2
  // use-battery-level's shape. Seeds the initial value with a one-shot getBatteryStateAsync()
3
3
  // call before the first native event fires, matching upstream's own useBatteryState.
4
4
  import { useEffect, useState } from 'react';
5
- import { addBatteryStateListener, BatteryState, getBatteryStateAsync } from '../../../core';
5
+ import {
6
+ addBatteryStateListener,
7
+ BatteryState,
8
+ getBatteryStateAsync,
9
+ } from '../../../core';
6
10
 
7
11
  export function useBatteryState(): BatteryState {
8
- const [batteryState, setBatteryState] = useState<BatteryState>(BatteryState.UNKNOWN);
12
+ const [batteryState, setBatteryState] = useState<BatteryState>(
13
+ BatteryState.UNKNOWN,
14
+ );
9
15
 
10
16
  useEffect(() => {
11
17
  getBatteryStateAsync().then(setBatteryState);
12
- const subscription = addBatteryStateListener(event => setBatteryState(event.batteryState));
18
+ const subscription = addBatteryStateListener(event =>
19
+ setBatteryState(event.batteryState),
20
+ );
13
21
  return () => subscription.remove();
14
22
  }, []);
15
23
 
@@ -3,14 +3,19 @@
3
3
  // isLowPowerModeEnabledAsync() call before the first native event fires, matching upstream's
4
4
  // own useLowPowerMode.
5
5
  import { useEffect, useState } from 'react';
6
- import { addLowPowerModeListener, isLowPowerModeEnabledAsync } from '../../../core';
6
+ import {
7
+ addLowPowerModeListener,
8
+ isLowPowerModeEnabledAsync,
9
+ } from '../../../core';
7
10
 
8
11
  export function useLowPowerMode(): boolean {
9
12
  const [lowPowerMode, setLowPowerMode] = useState(false);
10
13
 
11
14
  useEffect(() => {
12
15
  isLowPowerModeEnabledAsync().then(setLowPowerMode);
13
- const subscription = addLowPowerModeListener(event => setLowPowerMode(event.lowPowerMode));
16
+ const subscription = addLowPowerModeListener(event =>
17
+ setLowPowerMode(event.lowPowerMode),
18
+ );
14
19
  return () => subscription.remove();
15
20
  }, []);
16
21
 
@@ -7,20 +7,4 @@
7
7
  export { useBatteryLevel } from './hooks/use-battery-level';
8
8
  export { useBatteryState } from './hooks/use-battery-state';
9
9
  export { useLowPowerMode } from './hooks/use-low-power-mode';
10
- export {
11
- isAvailableAsync,
12
- getBatteryLevelAsync,
13
- getBatteryStateAsync,
14
- isLowPowerModeEnabledAsync,
15
- isBatteryOptimizationEnabledAsync,
16
- getPowerStateAsync,
17
- addBatteryLevelListener,
18
- addBatteryStateListener,
19
- addLowPowerModeListener,
20
- BatteryState,
21
- type PowerState,
22
- type BatteryLevelEvent,
23
- type BatteryStateEvent,
24
- type PowerModeEvent,
25
- type EventSubscription,
26
- } from '../core';
10
+ export * from '../core';
@@ -0,0 +1,11 @@
1
+ // @symbiote-native/battery/solid: the Solid entry over the framework-agnostic core. Battery's
2
+ // three subscription-backed values (level/state/low-power-mode) each get their own primitive,
3
+ // matching upstream's own useBatteryLevel/useBatteryState/useLowPowerMode being three separate
4
+ // hooks, not one combined hook — mirrors the lifecycle-bucket naming of
5
+ // adapters/solid/src/primitives (never `hooks/`/`composables/`/`runes/`, and `create*` rather
6
+ // than `use*`, which Solid reserves for consuming something that already exists).
7
+
8
+ export { createBatteryLevel } from './primitives/create-battery-level';
9
+ export { createBatteryState } from './primitives/create-battery-state';
10
+ export { createLowPowerMode } from './primitives/create-low-power-mode';
11
+ export * from '../core';
@@ -0,0 +1,45 @@
1
+ // Solid lifecycle wiring over the framework-agnostic core (core/battery.ts) — the twin of
2
+ // react/hooks/use-battery-level, vue/composables/use-battery-level and
3
+ // svelte/runes/use-battery-level.svelte. See adapters/solid/src/primitives/create-color-scheme.ts
4
+ // for why the bucket is `primitives/` and the name is `create*` rather than `use*`.
5
+ //
6
+ // Returns an ACCESSOR, never a snapshot: a Solid component body runs ONCE, so a returned number
7
+ // would freeze at the level the screen mounted with.
8
+ //
9
+ // The listener is registered SYNCHRONOUSLY with the body — there is no useEffect/onMounted twin
10
+ // to defer it to, so nothing can arrive before the subscription exists. The seed stays a promise,
11
+ // which leaves one ordering hazard the React and Vue versions both have and neither guards: a
12
+ // native event can land BEFORE getBatteryLevelAsync() resolves, and the late seed would then
13
+ // overwrite the fresher reading with an older one. `hasNativeReading` drops the seed in that case
14
+ // — these two writers are ordered by latency, not by time, so last-write-wins is wrong here.
15
+ import { createSignal, onCleanup, type Accessor } from 'solid-js';
16
+ import {
17
+ addBatteryLevelListener,
18
+ getBatteryLevelAsync,
19
+ type EventSubscription,
20
+ } from '../../core';
21
+
22
+ // core/battery.ts's documented sentinel for "no reading yet / this device cannot report a level".
23
+ const UNKNOWN_BATTERY_LEVEL = -1;
24
+
25
+ export function createBatteryLevel(): Accessor<number> {
26
+ const [batteryLevel, setBatteryLevel] = createSignal(UNKNOWN_BATTERY_LEVEL);
27
+ let hasNativeReading = false;
28
+
29
+ const subscription: EventSubscription = addBatteryLevelListener(event => {
30
+ hasNativeReading = true;
31
+ setBatteryLevel(event.batteryLevel);
32
+ });
33
+
34
+ getBatteryLevelAsync().then(level => {
35
+ if (!hasNativeReading) {
36
+ setBatteryLevel(level);
37
+ }
38
+ });
39
+
40
+ onCleanup(() => {
41
+ subscription.remove();
42
+ });
43
+
44
+ return batteryLevel;
45
+ }
@@ -0,0 +1,33 @@
1
+ // Solid lifecycle wiring over the framework-agnostic core (core/battery.ts) — mirrors
2
+ // create-battery-level's shape, including the seed-vs-event ordering guard documented there.
3
+ import { createSignal, onCleanup, type Accessor } from 'solid-js';
4
+ import {
5
+ addBatteryStateListener,
6
+ BatteryState,
7
+ getBatteryStateAsync,
8
+ type EventSubscription,
9
+ } from '../../core';
10
+
11
+ export function createBatteryState(): Accessor<BatteryState> {
12
+ const [batteryState, setBatteryState] = createSignal<BatteryState>(
13
+ BatteryState.UNKNOWN,
14
+ );
15
+ let hasNativeReading = false;
16
+
17
+ const subscription: EventSubscription = addBatteryStateListener(event => {
18
+ hasNativeReading = true;
19
+ setBatteryState(event.batteryState);
20
+ });
21
+
22
+ getBatteryStateAsync().then(state => {
23
+ if (!hasNativeReading) {
24
+ setBatteryState(state);
25
+ }
26
+ });
27
+
28
+ onCleanup(() => {
29
+ subscription.remove();
30
+ });
31
+
32
+ return batteryState;
33
+ }
@@ -0,0 +1,30 @@
1
+ // Solid lifecycle wiring over the framework-agnostic core (core/battery.ts) — mirrors
2
+ // create-battery-level's shape, including the seed-vs-event ordering guard documented there.
3
+ import { createSignal, onCleanup, type Accessor } from 'solid-js';
4
+ import {
5
+ addLowPowerModeListener,
6
+ isLowPowerModeEnabledAsync,
7
+ type EventSubscription,
8
+ } from '../../core';
9
+
10
+ export function createLowPowerMode(): Accessor<boolean> {
11
+ const [lowPowerMode, setLowPowerMode] = createSignal(false);
12
+ let hasNativeReading = false;
13
+
14
+ const subscription: EventSubscription = addLowPowerModeListener(event => {
15
+ hasNativeReading = true;
16
+ setLowPowerMode(event.lowPowerMode);
17
+ });
18
+
19
+ isLowPowerModeEnabledAsync().then(enabled => {
20
+ if (!hasNativeReading) {
21
+ setLowPowerMode(enabled);
22
+ }
23
+ });
24
+
25
+ onCleanup(() => {
26
+ subscription.remove();
27
+ });
28
+
29
+ return lowPowerMode;
30
+ }
@@ -0,0 +1,10 @@
1
+ // @symbiote-native/battery/svelte: the Svelte entry over the framework-agnostic core. Battery's
2
+ // three subscription-backed values (level/state/low-power-mode) each get their own lifecycle
3
+ // rune, 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/svelte/src/runes (never `hooks/`/`composables/`, those are React's and Vue's terms).
6
+
7
+ export { useBatteryLevel } from './runes/use-battery-level.svelte';
8
+ export { useBatteryState } from './runes/use-battery-state.svelte';
9
+ export { useLowPowerMode } from './runes/use-low-power-mode.svelte';
10
+ export * from '../core';
@@ -0,0 +1,45 @@
1
+ // Svelte lifecycle wiring over the framework-agnostic core (core/battery.ts) — the Svelte twin of
2
+ // vue/composables/use-battery-level and react/hooks/use-battery-level. Seeds the initial value
3
+ // with a one-shot getBatteryLevelAsync() call before the first native event fires, matching
4
+ // upstream's own useBatteryLevel.
5
+ //
6
+ // `.svelte.ts` (not `.ts`): runes ($state/$effect) are only usable in a file with this extension
7
+ // outside an actual `.svelte` component. `runes/` is Svelte's own term for the bucket React calls
8
+ // `hooks/` and Vue calls `composables/` — see adapters/svelte/src/runes.
9
+ //
10
+ // Vue's onMounted/onUnmounted pair collapses into ONE `$effect` whose returned function is the
11
+ // teardown. The effect only WRITES `batteryLevel`, never reads it, so its dependency set stays
12
+ // empty: it runs exactly once on mount and cleans up exactly once on unmount.
13
+ //
14
+ // Returns a boxed getter object, NOT a bare `$state`: Svelte 5 reactivity is lexically scoped to
15
+ // the declaring module, so a raw `let x = $state(...)` handed out of a plain function arrives
16
+ // dead at the caller. `{ get current() { … } }` is the sanctioned way across, read as `.current`
17
+ // exactly like Vue's `Ref` is unwrapped via `.value`.
18
+ import {
19
+ addBatteryLevelListener,
20
+ getBatteryLevelAsync,
21
+ type EventSubscription,
22
+ } from '../../core';
23
+
24
+ // core/battery.ts's documented sentinel for "this device cannot report a battery level".
25
+ const UNKNOWN_BATTERY_LEVEL = -1;
26
+
27
+ export function useBatteryLevel(): { readonly current: number } {
28
+ let batteryLevel = $state(UNKNOWN_BATTERY_LEVEL);
29
+
30
+ $effect(() => {
31
+ getBatteryLevelAsync().then(level => {
32
+ batteryLevel = level;
33
+ });
34
+ const subscription: EventSubscription = addBatteryLevelListener(event => {
35
+ batteryLevel = event.batteryLevel;
36
+ });
37
+ return () => subscription.remove();
38
+ });
39
+
40
+ return {
41
+ get current(): number {
42
+ return batteryLevel;
43
+ },
44
+ };
45
+ }
@@ -0,0 +1,30 @@
1
+ // Svelte lifecycle wiring over the framework-agnostic core (core/battery.ts) — mirrors
2
+ // use-battery-level.svelte.ts's shape; see its header for the `.svelte.ts`/`runes/`/boxed-getter
3
+ // reasoning. Seeds the initial value with a one-shot getBatteryStateAsync() call before the first
4
+ // native event fires, matching upstream's own useBatteryState.
5
+ import {
6
+ addBatteryStateListener,
7
+ BatteryState,
8
+ getBatteryStateAsync,
9
+ type EventSubscription,
10
+ } from '../../core';
11
+
12
+ export function useBatteryState(): { readonly current: BatteryState } {
13
+ let batteryState = $state<BatteryState>(BatteryState.UNKNOWN);
14
+
15
+ $effect(() => {
16
+ getBatteryStateAsync().then(state => {
17
+ batteryState = state;
18
+ });
19
+ const subscription: EventSubscription = addBatteryStateListener(event => {
20
+ batteryState = event.batteryState;
21
+ });
22
+ return () => subscription.remove();
23
+ });
24
+
25
+ return {
26
+ get current(): BatteryState {
27
+ return batteryState;
28
+ },
29
+ };
30
+ }
@@ -0,0 +1,29 @@
1
+ // Svelte lifecycle wiring over the framework-agnostic core (core/battery.ts) — mirrors
2
+ // use-battery-level.svelte.ts's shape; see its header for the `.svelte.ts`/`runes/`/boxed-getter
3
+ // reasoning. Seeds the initial value with a one-shot isLowPowerModeEnabledAsync() call before the
4
+ // first native event fires, matching upstream's own useLowPowerMode.
5
+ import {
6
+ addLowPowerModeListener,
7
+ isLowPowerModeEnabledAsync,
8
+ type EventSubscription,
9
+ } from '../../core';
10
+
11
+ export function useLowPowerMode(): { readonly current: boolean } {
12
+ let lowPowerMode = $state(false);
13
+
14
+ $effect(() => {
15
+ isLowPowerModeEnabledAsync().then(enabled => {
16
+ lowPowerMode = enabled;
17
+ });
18
+ const subscription: EventSubscription = addLowPowerModeListener(event => {
19
+ lowPowerMode = event.lowPowerMode;
20
+ });
21
+ return () => subscription.remove();
22
+ });
23
+
24
+ return {
25
+ get current(): boolean {
26
+ return lowPowerMode;
27
+ },
28
+ };
29
+ }
@@ -0,0 +1,6 @@
1
+ // Pulls in svelte's ambient global declarations ($state/$effect/...) for this package's tsc
2
+ // program. adapters/svelte gets these for free because render.ts does a real value import from
3
+ // 'svelte' (any file in a program importing a module loads its ambient globals for the whole
4
+ // program); this package has no such import, so a triple-slash reference does the same job
5
+ // explicitly rather than relying on an incidental side-effect.
6
+ /// <reference types="svelte" />
package/src/vue/index.ts CHANGED
@@ -7,20 +7,4 @@
7
7
  export { useBatteryLevel } from './composables/use-battery-level';
8
8
  export { useBatteryState } from './composables/use-battery-state';
9
9
  export { useLowPowerMode } from './composables/use-low-power-mode';
10
- export {
11
- isAvailableAsync,
12
- getBatteryLevelAsync,
13
- getBatteryStateAsync,
14
- isLowPowerModeEnabledAsync,
15
- isBatteryOptimizationEnabledAsync,
16
- getPowerStateAsync,
17
- addBatteryLevelListener,
18
- addBatteryStateListener,
19
- addLowPowerModeListener,
20
- BatteryState,
21
- type PowerState,
22
- type BatteryLevelEvent,
23
- type BatteryStateEvent,
24
- type PowerModeEvent,
25
- type EventSubscription,
26
- } from '../core';
10
+ export * from '../core';