@umituz/react-native-design-system 4.25.12 → 4.25.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-design-system",
3
- "version": "4.25.12",
3
+ "version": "4.25.14",
4
4
  "description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive, safe area, exception, infinite scroll, UUID, image, timezone, offline, onboarding, and loading utilities",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -1,17 +1,33 @@
1
1
  /**
2
2
  * useOffline Hook
3
3
  * Primary hook for accessing offline state in components
4
- * Automatically subscribes to network changes via expo-network
4
+ * Automatically subscribes to network changes via expo-network (lazy loaded)
5
5
  */
6
6
 
7
7
  import { useEffect, useCallback, useRef, useMemo } from 'react';
8
- import * as Network from 'expo-network';
9
8
  import type { NetworkState as ExpoNetworkState } from 'expo-network';
10
9
  import type { NetworkState, OfflineConfig } from '../../types';
11
10
  import { useOfflineStore } from '../../infrastructure/storage/OfflineStore';
12
11
  import { networkEvents } from '../../infrastructure/events/NetworkEvents';
13
12
  import { useOfflineConfigStore } from '../../infrastructure/storage/OfflineConfigStore';
14
13
 
14
+ /**
15
+ * Lazy-load expo-network to avoid crash when native module is not available
16
+ * (e.g. running in Expo Go without a custom dev build)
17
+ */
18
+ let _networkModule: typeof import('expo-network') | null = null;
19
+
20
+ const getNetworkModule = (): typeof import('expo-network') | null => {
21
+ if (_networkModule !== null) return _networkModule;
22
+ try {
23
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
24
+ _networkModule = require('expo-network') as typeof import('expo-network');
25
+ return _networkModule;
26
+ } catch {
27
+ return null;
28
+ }
29
+ };
30
+
15
31
  /**
16
32
  * Convert expo-network state to our internal format
17
33
  */
@@ -67,6 +83,15 @@ export const useOffline = (config?: OfflineConfig) => {
67
83
 
68
84
  isMountedRef.current = true;
69
85
 
86
+ const Network = getNetworkModule();
87
+
88
+ if (!Network) {
89
+ if (__DEV__ || mergedConfig.debug) {
90
+ console.warn('[DesignSystem] useOffline: expo-network native module not available. Network state tracking disabled.');
91
+ }
92
+ return;
93
+ }
94
+
70
95
  Network.getNetworkStateAsync()
71
96
  .then((state: ExpoNetworkState) => {
72
97
  if (isMountedRef.current) {