@symbiote-native/battery 0.3.0 → 2.0.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.
- package/README.md +46 -15
- package/package.json +27 -15
package/README.md
CHANGED
|
@@ -89,11 +89,11 @@ function BatteryScreen() {
|
|
|
89
89
|
|
|
90
90
|
return (
|
|
91
91
|
<>
|
|
92
|
-
<
|
|
93
|
-
<
|
|
92
|
+
<text>{batteryLevelLabel}</text>
|
|
93
|
+
<text>
|
|
94
94
|
{batteryState === BatteryState.CHARGING ? 'Charging' : 'Not charging'}
|
|
95
|
-
</
|
|
96
|
-
<
|
|
95
|
+
</text>
|
|
96
|
+
<text>{lowPowerMode ? 'On' : 'Off'}</text>
|
|
97
97
|
</>
|
|
98
98
|
);
|
|
99
99
|
}
|
|
@@ -120,11 +120,41 @@ const batteryLevelText = computed(() =>
|
|
|
120
120
|
);
|
|
121
121
|
</script>
|
|
122
122
|
<template>
|
|
123
|
-
<
|
|
124
|
-
<
|
|
123
|
+
<text>{{ batteryLevelText }}</text>
|
|
124
|
+
<text>{{ lowPowerMode ? 'ON' : 'OFF' }}</text>
|
|
125
125
|
</template>
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
+
```svelte
|
|
129
|
+
<!-- Svelte — examples/expo-svelte/screens/BatteryScreen.svelte. Each rune returns a boxed
|
|
130
|
+
getter object, read as `.current`, since a bare `$state` doesn't survive being handed out
|
|
131
|
+
of a plain function. -->
|
|
132
|
+
<script lang="ts">
|
|
133
|
+
import {
|
|
134
|
+
useBatteryLevel,
|
|
135
|
+
useBatteryState,
|
|
136
|
+
useLowPowerMode,
|
|
137
|
+
} from '@symbiote-native/battery/svelte';
|
|
138
|
+
import { BatteryState } from '@symbiote-native/battery';
|
|
139
|
+
|
|
140
|
+
const batteryLevel = useBatteryLevel(); // { current: number }, -1 until the first reading
|
|
141
|
+
const batteryState = useBatteryState(); // { current: BatteryState }
|
|
142
|
+
const lowPowerMode = useLowPowerMode(); // { current: boolean }
|
|
143
|
+
|
|
144
|
+
const batteryLevelLabel = $derived(
|
|
145
|
+
batteryLevel.current < 0
|
|
146
|
+
? 'unknown'
|
|
147
|
+
: `${Math.round(batteryLevel.current * 100)}%`,
|
|
148
|
+
);
|
|
149
|
+
</script>
|
|
150
|
+
|
|
151
|
+
<text>{batteryLevelLabel}</text>
|
|
152
|
+
<text>
|
|
153
|
+
{batteryState.current === BatteryState.CHARGING ? 'Charging' : 'Not charging'}
|
|
154
|
+
</text>
|
|
155
|
+
<text>{lowPowerMode.current ? 'On' : 'Off'}</text>
|
|
156
|
+
```
|
|
157
|
+
|
|
128
158
|
```tsx
|
|
129
159
|
// Solid — an accessor per value; call it to read, so a component body that runs once still
|
|
130
160
|
// re-renders the leaf that reads it.
|
|
@@ -142,15 +172,15 @@ function BatteryScreen() {
|
|
|
142
172
|
|
|
143
173
|
return (
|
|
144
174
|
<>
|
|
145
|
-
<
|
|
175
|
+
<text>
|
|
146
176
|
{batteryLevel() < 0
|
|
147
177
|
? 'unknown'
|
|
148
178
|
: `${Math.round(batteryLevel() * 100)}%`}
|
|
149
|
-
</
|
|
150
|
-
<
|
|
179
|
+
</text>
|
|
180
|
+
<text>
|
|
151
181
|
{batteryState() === BatteryState.CHARGING ? 'Charging' : 'Not charging'}
|
|
152
|
-
</
|
|
153
|
-
<
|
|
182
|
+
</text>
|
|
183
|
+
<text>{lowPowerMode() ? 'On' : 'Off'}</text>
|
|
154
184
|
</>
|
|
155
185
|
);
|
|
156
186
|
}
|
|
@@ -178,7 +208,7 @@ export class BatteryScreen {
|
|
|
178
208
|
}
|
|
179
209
|
```
|
|
180
210
|
|
|
181
|
-
Each of the
|
|
211
|
+
Each of the demo screens above also renders a one-shot capabilities card
|
|
182
212
|
(`isAvailableAsync()`, and Android-only `isBatteryOptimizationEnabledAsync()`) resolved directly
|
|
183
213
|
from `@symbiote-native/battery`'s core entry point — see the linked files for the full version.
|
|
184
214
|
The iOS Simulator reports the battery API as unavailable (`isAvailableAsync()` resolves `false`)
|
|
@@ -257,6 +287,7 @@ surface, never a view. Tests inject a fake native-module object in place of the
|
|
|
257
287
|
ViewConfig. Native rendering itself is verified on-device — see the parent
|
|
258
288
|
[README](../../README.md).
|
|
259
289
|
|
|
260
|
-
The Android/iOS native wiring is done across all
|
|
261
|
-
(`examples/expo-react`, `examples/expo-vue-sfc`, `examples/expo-vue-tsx`, `examples/expo-
|
|
262
|
-
this package isn't yet in the public, non-Expo
|
|
290
|
+
The Android/iOS native wiring is done across all six `examples/expo-*` canary apps
|
|
291
|
+
(`examples/expo-react`, `examples/expo-vue-sfc`, `examples/expo-vue-tsx`, `examples/expo-svelte`,
|
|
292
|
+
`examples/expo-solid`, `examples/expo-angular`); this package isn't yet in the public, non-Expo
|
|
293
|
+
`examples/react` canary.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbiote-native/battery",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.0",
|
|
4
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": {
|
|
@@ -13,6 +13,18 @@
|
|
|
13
13
|
"url": "https://github.com/OneEyed1366/symbiote-native/issues"
|
|
14
14
|
},
|
|
15
15
|
"author": "Andrey Prokopenko <psevdoproger@gmail.com>",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"react-native",
|
|
18
|
+
"symbiote-native",
|
|
19
|
+
"expo-battery",
|
|
20
|
+
"react",
|
|
21
|
+
"vue",
|
|
22
|
+
"svelte",
|
|
23
|
+
"solid",
|
|
24
|
+
"angular",
|
|
25
|
+
"battery-status",
|
|
26
|
+
"low-power-mode"
|
|
27
|
+
],
|
|
16
28
|
"type": "module",
|
|
17
29
|
"main": "./build/core/index.js",
|
|
18
30
|
"module": "./build/core/index.js",
|
|
@@ -61,19 +73,19 @@
|
|
|
61
73
|
"expo-modules-core": "57.0.5"
|
|
62
74
|
},
|
|
63
75
|
"peerDependencies": {
|
|
64
|
-
"@symbiote-native/angular": ">=0.6.2",
|
|
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",
|
|
70
76
|
"@angular/core": ">=20",
|
|
71
77
|
"@vue/runtime-core": "^3.5.13",
|
|
72
78
|
"react": ">=19.0.0",
|
|
73
79
|
"react-native": ">=0.86",
|
|
74
80
|
"solid-js": ">=1.9.0",
|
|
75
81
|
"svelte": ">=5.56.0",
|
|
76
|
-
"vue": ">=3.5.0"
|
|
82
|
+
"vue": ">=3.5.0",
|
|
83
|
+
"@symbiote-native/angular": "^2.0.0",
|
|
84
|
+
"@symbiote-native/engine": "^0.5.0",
|
|
85
|
+
"@symbiote-native/react": "^2.0.0",
|
|
86
|
+
"@symbiote-native/solid": "^2.0.0",
|
|
87
|
+
"@symbiote-native/svelte": "^2.0.0",
|
|
88
|
+
"@symbiote-native/vue": "^2.0.0"
|
|
77
89
|
},
|
|
78
90
|
"peerDependenciesMeta": {
|
|
79
91
|
"@symbiote-native/angular": {
|
|
@@ -121,13 +133,13 @@
|
|
|
121
133
|
"solid-js": "^1.9.14",
|
|
122
134
|
"svelte": "^5.56.0",
|
|
123
135
|
"typescript": "~6.0.0",
|
|
124
|
-
"@symbiote-native/angular": "0.
|
|
125
|
-
"@symbiote-native/engine": "0.
|
|
126
|
-
"@symbiote-native/react": "0.
|
|
127
|
-
"@symbiote-native/solid": "0.
|
|
128
|
-
"@symbiote-native/svelte": "0.
|
|
129
|
-
"@symbiote-native/test-utils": "0.
|
|
130
|
-
"@symbiote-native/vue": "0.
|
|
136
|
+
"@symbiote-native/angular": "2.0.0",
|
|
137
|
+
"@symbiote-native/engine": "0.5.0",
|
|
138
|
+
"@symbiote-native/react": "2.0.0",
|
|
139
|
+
"@symbiote-native/solid": "2.0.0",
|
|
140
|
+
"@symbiote-native/svelte": "2.0.0",
|
|
141
|
+
"@symbiote-native/test-utils": "0.3.0",
|
|
142
|
+
"@symbiote-native/vue": "2.0.0"
|
|
131
143
|
},
|
|
132
144
|
"scripts": {
|
|
133
145
|
"typecheck": "tsc --build",
|