@symbiote-native/keep-awake 3.0.2 → 3.0.3

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 (2) hide show
  1. package/README.md +43 -33
  2. package/package.json +15 -15
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @symbiote-native/keep-awake
2
2
 
3
3
  Port of [`expo-keep-awake`](https://docs.expo.dev/versions/latest/sdk/keep-awake/) for
4
- [SymbioteNative](../../README.md) — keeps the screen on for the lifetime of a mounted
4
+ [SymbioteNative](../../README.md) - keeps the screen on for the lifetime of a mounted
5
5
  component/composable/service, reachable from every adapter (React, Vue, Svelte, Solid, Angular),
6
6
  not just React.
7
7
 
@@ -25,48 +25,48 @@ npx @symbiote-native/cli new my-app --keep-awake
25
25
  npx @symbiote-native/cli add --keep-awake
26
26
  ```
27
27
 
28
- Either way: installs `@symbiote-native/keep-awake` and wires the native autolinking automatically
29
- — see [`@symbiote-native/cli`](../cli).
28
+ Either way: installs `@symbiote-native/keep-awake` and wires the native autolinking automatically,
29
+ see [`@symbiote-native/cli`](../cli).
30
30
 
31
31
  <details>
32
- <summary>Manual install (no CLI — installing and wiring native autolinking by hand)</summary>
32
+ <summary>Manual install (no CLI - installing and wiring native autolinking by hand)</summary>
33
33
 
34
34
  ```bash
35
35
  npm install @symbiote-native/keep-awake
36
36
  ```
37
37
 
38
38
  Depends on `expo-keep-awake` and `expo-modules-core` directly (regular dependencies, pinned to
39
- exact versions — never a caret range, since this package's `core/` is hand-ported against one
39
+ exact versions - never a caret range, since this package's `core/` is hand-ported against one
40
40
  specific native API shape and a newer resolve could silently drift the two apart). Never install
41
- `expo-keep-awake` yourself, and never add the `expo` package to this project — it bundles its own
41
+ `expo-keep-awake` yourself, and never add the `expo` package to this project - it bundles its own
42
42
  Metro/Babel pipeline that conflicts with this project's own.
43
43
 
44
44
  ### Required one-time step: native autolinking wiring
45
45
 
46
46
  Unlike a plain RN native module, `expo-keep-awake`'s native code is discovered by
47
- `expo-modules-autolinking`, not RN's own `react-native.config.cjs` mechanism — this needs wiring
47
+ `expo-modules-autolinking`, not RN's own `react-native.config.cjs` mechanism - this needs wiring
48
48
  into the native host app **once**, covering this package and every other `expo-modules-core`
49
49
  package (`@symbiote-native/battery`, `@symbiote-native/device`, `@symbiote-native/sensors`, …)
50
50
  with zero further changes:
51
51
 
52
52
  | Platform | Touches |
53
53
  | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
54
- | iOS | `ios/Podfile` — add `use_expo_modules!` |
55
- | iOS | `AppDelegate.swift` — Expo's runtime-bootstrap hook |
56
- | Android | `settings.gradle` / `app/build.gradle` — resolve and include the Expo Gradle projects |
57
- | Android | `MainApplication.kt` — Expo's bootstrap hook, plus a hand-written native-module name map (there's no `expo` meta-package here to auto-generate one) |
54
+ | iOS | `ios/Podfile` - add `use_expo_modules!` |
55
+ | iOS | `AppDelegate.swift` - Expo's runtime-bootstrap hook |
56
+ | Android | `settings.gradle` / `app/build.gradle` - resolve and include the Expo Gradle projects |
57
+ | Android | `MainApplication.kt` - Expo's bootstrap hook, plus a hand-written native-module name map (there's no `expo` meta-package here to auto-generate one) |
58
58
 
59
59
  The recurring per-package half of the Android wiring (`app/build.gradle`'s
60
60
  `implementation project(':expo-keep-awake')` line and `MainApplication.kt`'s module-name map
61
- entry) is automated by installing `@symbiote-native/expo-modules-link` in the consuming app —
61
+ entry) is automated by installing `@symbiote-native/expo-modules-link` in the consuming app:
62
62
  its own `postinstall` hook scans `node_modules` for every installed package's `native-link.json`
63
63
  (this one included) and regenerates the registration blocks. This package ships no `postinstall`
64
- of its own — `native-link.json` above is passive data the aggregator reads. See that package's
65
- README for the full mechanism. Full mechanics — the Podfile pieces that normally ship inside the
66
- `expo` package, the `expo` peer-dependency exclusion list — live in the
64
+ of its own - `native-link.json` above is passive data the aggregator reads. See that package's
65
+ README for the full mechanism. Full mechanics - the Podfile pieces that normally ship inside the
66
+ `expo` package, the `expo` peer-dependency exclusion list - live in the
67
67
  `symbiote-expo-native-module` skill.
68
68
 
69
- No platform permission string is needed — keeping the screen awake has no runtime permission
69
+ No platform permission string is needed - keeping the screen awake has no runtime permission
70
70
  prompt on either platform.
71
71
 
72
72
  </details>
@@ -74,22 +74,22 @@ prompt on either platform.
74
74
  ## Shape
75
75
 
76
76
  ```
77
- src/core/ keep-awake.ts — isAvailableAsync/activateKeepAwakeAsync/
77
+ src/core/ keep-awake.ts - isAvailableAsync/activateKeepAwakeAsync/
78
78
  deactivateKeepAwake/addListener, ExpoKeepAwakeTag. native-module.ts
79
79
  resolves the native module through expo-modules-core's
80
- requireNativeModule. types.ts — KeepAwakeEvent/KeepAwakeListener/
80
+ requireNativeModule. types.ts - KeepAwakeEvent/KeepAwakeListener/
81
81
  KeepAwakeOptions, hand-ported from KeepAwake.types.ts.
82
- src/react/hooks/ @symbiote-native/keep-awake/react — useKeepAwake
83
- src/vue/composables/ @symbiote-native/keep-awake/vue — useKeepAwake
84
- src/svelte/runes/ @symbiote-native/keep-awake/svelte — useKeepAwake
85
- src/solid/primitives/ @symbiote-native/keep-awake/solid — createKeepAwake (Solid says
82
+ src/react/hooks/ @symbiote-native/keep-awake/react - useKeepAwake
83
+ src/vue/composables/ @symbiote-native/keep-awake/vue - useKeepAwake
84
+ src/svelte/runes/ @symbiote-native/keep-awake/svelte - useKeepAwake
85
+ src/solid/primitives/ @symbiote-native/keep-awake/solid - createKeepAwake (Solid says
86
86
  create*, not use*)
87
- src/angular/services/ @symbiote-native/keep-awake/angular — KeepAwakeService (`.connect()`,
88
- no return value — a pure side effect for the component's lifetime)
87
+ src/angular/services/ @symbiote-native/keep-awake/angular - KeepAwakeService (`.connect()`,
88
+ no return value - a pure side effect for the component's lifetime)
89
89
  ```
90
90
 
91
91
  Each adapter's hook/composable/rune/primitive/service activates a keep-awake lock on mount and
92
- deactivates it on unmount, over the same `core` functions — the tag-generation and
92
+ deactivates it on unmount, over the same `core` functions - the tag-generation and
93
93
  activate/deactivate lifecycle is written once and shared by every adapter. React uses `useId()`
94
94
  for its default per-instance tag, matching upstream; Vue, Svelte, Solid and Angular have no
95
95
  `useId` equivalent, so they fall back to a small monotonically-incrementing module-local counter (`keep-awake-tag-1`, `keep-awake-tag-2`, …) when
@@ -98,7 +98,7 @@ no explicit tag is given.
98
98
  ## Use it
99
99
 
100
100
  ```tsx
101
- // React — examples/expo-react/screens/KeepAwakeScreen.tsx
101
+ // React - examples/expo-react/screens/KeepAwakeScreen.tsx
102
102
  import { useKeepAwake } from '@symbiote-native/keep-awake/react';
103
103
 
104
104
  function KeepAwakeScreen() {
@@ -109,7 +109,7 @@ function KeepAwakeScreen() {
109
109
  ```
110
110
 
111
111
  ```vue
112
- <!-- Vue — examples/expo-vue-sfc/screens/KeepAwakeScreen.vue -->
112
+ <!-- Vue - examples/expo-vue-sfc/screens/KeepAwakeScreen.vue -->
113
113
  <script setup lang="ts">
114
114
  import { useKeepAwake } from '@symbiote-native/keep-awake/vue';
115
115
 
@@ -143,7 +143,7 @@ function KeepAwakeScreen() {
143
143
  ```
144
144
 
145
145
  ```ts
146
- // Angular — examples/expo-angular/src/screens/KeepAwakeScreen.ts
146
+ // Angular - examples/expo-angular/src/screens/KeepAwakeScreen.ts
147
147
  import { Component, inject } from '@angular/core';
148
148
  import { KeepAwakeService } from '@symbiote-native/keep-awake/angular';
149
149
 
@@ -165,7 +165,7 @@ addListener(tagOrListener, listener?): EventSubscription // subscribes to k
165
165
  ```
166
166
 
167
167
  Plus `ExpoKeepAwakeTag` (the shared default tag string), `KeepAwakeEvent`, `KeepAwakeListener`,
168
- `KeepAwakeOptions` — ported from upstream's `KeepAwake.types.ts`. `KeepAwakeEvent#state` is kept
168
+ `KeepAwakeOptions` - ported from upstream's `KeepAwake.types.ts`. `KeepAwakeEvent#state` is kept
169
169
  as a minimal `unknown` placeholder: upstream's own shape there is web-specific and has no native
170
170
  analogue, and native listeners for it rarely fire.
171
171
 
@@ -185,17 +185,27 @@ import { KeepAwakeService } from '@symbiote-native/keep-awake/angular';
185
185
  ```
186
186
 
187
187
  Each hook/composable/rune/primitive/service activates a lock on mount (optionally registering
188
- `options.listener` once activation resolves) and deactivates it on unmount — mirroring upstream's
188
+ `options.listener` once activation resolves) and deactivates it on unmount - mirroring upstream's
189
189
  own `useKeepAwake(tag?, options?)`. Solid's `createKeepAwake(tag?, options?)` does it from the
190
190
  primitive body, releasing through `onCleanup`.
191
191
 
192
+ ## Common questions
193
+
194
+ - **Two tags, sleeps after releasing one (Android).** Reported upstream; prefer one tag per screen.
195
+ - **Screen still turns off.** Android uses `FLAG_KEEP_SCREEN_ON`, which power saving can override.
196
+ - **Conflicts with another library.** Another library clearing the same window flag undoes it.
197
+
198
+ Sources: [expo/expo#6031](https://github.com/expo/expo/issues/6031),
199
+ [expo/expo#6324](https://github.com/expo/expo/issues/6324),
200
+ [expo/expo#24007](https://github.com/expo/expo/issues/24007).
201
+
192
202
  ## Test it
193
203
 
194
- No Fabric/Descriptor angle at all — keep-awake is a pure async-function + `EventEmitter` listener
204
+ No Fabric/Descriptor angle at all - keep-awake is a pure async-function + `EventEmitter` listener
195
205
  surface, never a view. Tests inject a fake native-module object in place of the real
196
206
  `requireNativeModule` resolution (`src/core/keep-awake.test.ts`,
197
207
  `src/{react,vue,svelte,solid,angular}/**/*.test.{ts,tsx}`, `vitest`), the same pattern
198
- `@symbiote-native/battery` and `@symbiote-native/device` use — no `installFabric()`-driven Fabric
208
+ `@symbiote-native/battery` and `@symbiote-native/device` use - no `installFabric()`-driven Fabric
199
209
  assertions on the core level, only the adapter lifecycle tests mount through the fake Fabric slot
200
- to prove activate-on-mount/deactivate-on-unmount. Native rendering itself is verified on-device —
210
+ to prove activate-on-mount/deactivate-on-unmount. Native rendering itself is verified on-device:
201
211
  see the parent [README](../../README.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbiote-native/keep-awake",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "expo-keep-awake wrapped for SymbioteNative — one framework-agnostic core, built once and reachable from the React, Vue, Svelte, Solid, and Angular adapters. Keeps the screen awake for the lifetime of a mounted component/composable/service, with an optional listener for keep-awake state changes.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "expo-keep-awake": "57.0.1",
73
- "expo-modules-core": "57.0.5"
73
+ "expo-modules-core": "57.0.20"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "@angular/core": ">=20",
@@ -80,12 +80,12 @@
80
80
  "solid-js": ">=1.9.0",
81
81
  "svelte": ">=5.56.0",
82
82
  "vue": ">=3.5.0",
83
- "@symbiote-native/angular": "^3.1.2",
84
- "@symbiote-native/engine": "^1.3.1",
85
- "@symbiote-native/react": "^3.0.4",
86
- "@symbiote-native/solid": "^3.0.4",
87
- "@symbiote-native/svelte": "^3.0.4",
88
- "@symbiote-native/vue": "^3.0.4"
83
+ "@symbiote-native/angular": "^3.2.0",
84
+ "@symbiote-native/engine": "^1.5.0",
85
+ "@symbiote-native/react": "^3.2.0",
86
+ "@symbiote-native/solid": "^3.1.0",
87
+ "@symbiote-native/svelte": "^3.1.0",
88
+ "@symbiote-native/vue": "^3.2.0"
89
89
  },
90
90
  "peerDependenciesMeta": {
91
91
  "@symbiote-native/angular": {
@@ -133,13 +133,13 @@
133
133
  "solid-js": "^1.9.14",
134
134
  "svelte": "^5.56.0",
135
135
  "typescript": "~6.0.0",
136
- "@symbiote-native/angular": "3.1.2",
137
- "@symbiote-native/engine": "1.3.1",
138
- "@symbiote-native/react": "3.0.4",
139
- "@symbiote-native/solid": "3.0.4",
140
- "@symbiote-native/svelte": "3.0.4",
141
- "@symbiote-native/test-utils": "0.4.4",
142
- "@symbiote-native/vue": "3.0.4"
136
+ "@symbiote-native/angular": "3.2.0",
137
+ "@symbiote-native/engine": "1.5.0",
138
+ "@symbiote-native/react": "3.2.0",
139
+ "@symbiote-native/solid": "3.1.0",
140
+ "@symbiote-native/svelte": "3.1.0",
141
+ "@symbiote-native/test-utils": "0.4.6",
142
+ "@symbiote-native/vue": "3.2.0"
143
143
  },
144
144
  "scripts": {
145
145
  "typecheck": "tsc --build",