# Modular Subsystem Imports

## Simple install (default)

```bash
yarn add react-native-geolocation-pro
```

```ts
import Geolocation, { Pedometer, Geofencing, ActivityManager } from 'react-native-geolocation-pro';
```

**One package, everything included** — same as before. Subpaths are optional for bundle size.

## Optional subpath imports

| Subsystem | Import | Lifecycle |
|-----------|--------|-----------|
| Core | `react-native-geolocation-pro/core` | Permissions, types, config |
| Geolocation | `react-native-geolocation-pro/geolocation` | `Geolocation.watchPosition` / `stopObserving` |
| Pedometer | `react-native-geolocation-pro/pedometer` | `Pedometer.start` / `stop` (no GPS) |
| Geofence | `react-native-geolocation-pro/geofence` | Geofencing + Spatial |
| Activity | `react-native-geolocation-pro/activity` | ActivityManager sessions |
| Sync | `react-native-geolocation-pro/sync` | HttpSync, SyncEngine |
| Diagnostics | `react-native-geolocation-pro/diagnostics` | DebugMonitor, Health |

**Backward compatible:** `import Geolocation from 'react-native-geolocation-pro'` still works.

## Examples

```ts
// Pedometer-only app (no GPS imports in JS bundle)
import { Pedometer, PedometerMetrics } from 'react-native-geolocation-pro/pedometer';

// GPS-only app
import { Geolocation } from 'react-native-geolocation-pro/geolocation';

// Combined — separate lifecycles
import { Geolocation } from 'react-native-geolocation-pro/geolocation';
import { Pedometer } from 'react-native-geolocation-pro/pedometer';

await Pedometer.start();
await Geolocation.ready({ geolocation: { /* … */ } });
// … workout uses GPS; daily steps use Pedometer only
```

## Native linking (honest limits)

| Layer | Subpath tree-shaking |
|-------|----------------------|
| **JavaScript** | Yes — Metro/webpack resolve only imported subpaths |
| **Native iOS/Android** | Single module today — all native code links via one pod/gradle project |

Native optional feature flags (e.g. `GeolocationPro/PedometerOnly`) are planned; JS modular imports ship now without breaking current consumers.

## Design rules

1. **Separate lifecycles** — `Pedometer.stop()` does not call `Geolocation.stopObserving()`.
2. **Composable** — ActivityManager can use GPS + pedometer together when you import both.
3. **Pure metrics** — `PedometerMetrics` is JS-only math (no native dependency).

See also: [PEDOMETER.md](./PEDOMETER.md), [PEDOMETER_METRICS.md](./PEDOMETER_METRICS.md).
