@smartcrab/react-native 0.3.0 → 0.3.1-next-20261013030252

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.
@@ -1,8 +1,8 @@
1
1
  import type { AppStatePort } from "../lifecycle-ports.js";
2
2
  /**
3
3
  * Default `AppStatePort`: React Native's own `AppState` (design.md §21.1,
4
- * §21.7). RN's `AppStateStatus` union is structurally identical to this
5
- * package's own (`active`/`background`/`inactive`/`unknown`/`extension`), so
6
- * this passes through without any cast.
4
+ * §21.7). RN 0.87 widens `AppState.currentState` to include `null`,
5
+ * `undefined`, and arbitrary strings. Pass through known lifecycle states and
6
+ * map anything else to `unknown` to preserve this package's narrower contract.
7
7
  */
8
8
  export declare const reactNativeAppStatePort: AppStatePort;
@@ -1,13 +1,22 @@
1
1
  import { AppState } from "react-native";
2
+ const KNOWN_APP_STATES = new Set([
3
+ "active",
4
+ "background",
5
+ "inactive",
6
+ "unknown",
7
+ "extension",
8
+ ]);
9
+ const isAppStateStatus = (value) => KNOWN_APP_STATES.has(value);
2
10
  /**
3
11
  * Default `AppStatePort`: React Native's own `AppState` (design.md §21.1,
4
- * §21.7). RN's `AppStateStatus` union is structurally identical to this
5
- * package's own (`active`/`background`/`inactive`/`unknown`/`extension`), so
6
- * this passes through without any cast.
12
+ * §21.7). RN 0.87 widens `AppState.currentState` to include `null`,
13
+ * `undefined`, and arbitrary strings. Pass through known lifecycle states and
14
+ * map anything else to `unknown` to preserve this package's narrower contract.
7
15
  */
8
16
  export const reactNativeAppStatePort = {
9
17
  get currentState() {
10
- return AppState.currentState;
18
+ const state = AppState.currentState;
19
+ return state != null && isAppStateStatus(state) ? state : "unknown";
11
20
  },
12
21
  addEventListener: (type, handler) => AppState.addEventListener(type, handler),
13
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartcrab/react-native",
3
- "version": "0.3.0",
3
+ "version": "0.3.1-next-20261013030252",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -34,7 +34,7 @@
34
34
  "access": "public"
35
35
  },
36
36
  "dependencies": {
37
- "@smartcrab/contracts-public": "0.3.0"
37
+ "@smartcrab/contracts-public": "0.3.1-next-20261013030252"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": ">=19",
@@ -50,16 +50,16 @@
50
50
  "devDependencies": {
51
51
  "typescript": "5.9.3",
52
52
  "vitest": "4.1.11",
53
- "react": "19.2.8",
54
- "react-native": "0.86.2",
55
- "expo": "57.0.10",
56
- "expo-secure-store": "57.0.1",
57
- "expo-web-browser": "57.0.2",
58
- "expo-auth-session": "57.0.6",
59
- "expo-linking": "57.0.5",
60
- "expo-crypto": "57.0.1",
61
- "react-native-passkeys": "0.4.1",
62
- "@types/react": "19.2.18"
53
+ "react": "19.3.0",
54
+ "react-native": "0.87.1",
55
+ "expo": "57.0.27",
56
+ "expo-secure-store": "57.0.4",
57
+ "expo-web-browser": "57.0.3",
58
+ "expo-auth-session": "57.0.14",
59
+ "expo-linking": "57.0.12",
60
+ "expo-crypto": "57.0.3",
61
+ "react-native-passkeys": "0.4.2",
62
+ "@types/react": "19.3.0"
63
63
  },
64
64
  "scripts": {
65
65
  "typecheck": "tsc --noEmit",
@@ -1,15 +1,26 @@
1
1
  import { AppState } from "react-native";
2
- import type { AppStatePort } from "../lifecycle-ports.js";
2
+ import type { AppStatePort, AppStateStatus } from "../lifecycle-ports.js";
3
+
4
+ const KNOWN_APP_STATES: ReadonlySet<string> = new Set<AppStateStatus>([
5
+ "active",
6
+ "background",
7
+ "inactive",
8
+ "unknown",
9
+ "extension",
10
+ ]);
11
+
12
+ const isAppStateStatus = (value: string): value is AppStateStatus => KNOWN_APP_STATES.has(value);
3
13
 
4
14
  /**
5
15
  * Default `AppStatePort`: React Native's own `AppState` (design.md §21.1,
6
- * §21.7). RN's `AppStateStatus` union is structurally identical to this
7
- * package's own (`active`/`background`/`inactive`/`unknown`/`extension`), so
8
- * this passes through without any cast.
16
+ * §21.7). RN 0.87 widens `AppState.currentState` to include `null`,
17
+ * `undefined`, and arbitrary strings. Pass through known lifecycle states and
18
+ * map anything else to `unknown` to preserve this package's narrower contract.
9
19
  */
10
20
  export const reactNativeAppStatePort: AppStatePort = {
11
21
  get currentState() {
12
- return AppState.currentState;
22
+ const state = AppState.currentState;
23
+ return state != null && isAppStateStatus(state) ? state : "unknown";
13
24
  },
14
25
  addEventListener: (type, handler) => AppState.addEventListener(type, handler),
15
26
  };