@tsachit/react-native-geo-service 1.0.2 → 1.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.
package/README.md CHANGED
@@ -6,7 +6,7 @@ Battery-efficient background geolocation for React Native — a lightweight, fre
6
6
  - Keeps tracking when the app is backgrounded or killed (headless mode)
7
7
  - Uses `FusedLocationProviderClient` on Android and `CLLocationManager` on iOS
8
8
  - **Adaptive accuracy** — GPS turns off automatically when the device is idle and wakes the moment movement is detected
9
- - **Debug panel** — draggable floating overlay that mounts automatically when `debug: true`, showing live metrics, GPS activity, and battery saving suggestions with no component needed in the app tree
9
+ - **Debug panel** — draggable floating overlay showing live metrics, GPS activity, and battery saving suggestions; add `<GeoDebugOverlay />` once and it self-manages based on `debug: true` and tracking state
10
10
  - Fully configurable from JavaScript — no API keys, no license required
11
11
 
12
12
  ---
@@ -284,10 +284,10 @@ interface BatteryInfo {
284
284
  levelAtStart: number; // battery level when start() was called
285
285
  drainSinceStart: number; // total % dropped since start() (whole device)
286
286
 
287
- updateCount: number; // location fixes received this session
287
+ updateCount: number; // total location received this session
288
288
  trackingElapsedSeconds: number; // seconds since start() was called
289
289
  gpsActiveSeconds: number; // seconds the GPS chip was actively running
290
- updatesPerMinute: number; // average location fixes per minute
290
+ updatesPerMinute: number; // average total location per minute
291
291
  drainRatePerHour: number; // battery drain rate in %/hr (whole device)
292
292
  }
293
293
  ```
@@ -312,39 +312,38 @@ Set `debug: true` in `configure()` to enable debug features:
312
312
  - **iOS** — forces the blue location arrow in the status bar while tracking is active
313
313
  - **Android** — notification title changes to `[DEBUG] <title>` so you can confirm the foreground service is running
314
314
  - **Both** — verbose native logging via `console.log` / `Logcat`
315
- - **Both** — a floating debug panel appears automatically showing live metrics and battery saving suggestions
315
+ - **Both** — a floating debug panel shows live metrics and battery saving suggestions; add `<GeoDebugOverlay />` once to your component tree and it self-manages visibility
316
316
 
317
- ### Setup (one-time)
317
+ ### Setup
318
318
 
319
- Add one import to the **top** of your app's `index.js`, before `AppRegistry.registerComponent`. This registers the overlay host so the panel can mount itself automatically when `debug: true` no component needed anywhere in the app.
319
+ Add `<GeoDebugOverlay />` once to your component tree, co-located with wherever you call `RNGeoService.start()`. It self-manages visibility it only shows when `debug: true` is set in `configure()` and tracking is active.
320
320
 
321
- ```ts
322
- // index.js
323
- import 'react-native-gesture-handler';
324
- import '@tsachit/react-native-geo-service/debug-panel'; // add this once
325
- import { AppRegistry } from 'react-native';
326
- import App from './App';
327
- import { name as appName } from './app.json';
328
-
329
- AppRegistry.registerComponent(appName, () => App);
321
+ ```tsx
322
+ import { GeoDebugOverlay } from '@tsachit/react-native-geo-service';
323
+
324
+ // Render it alongside your navigation root or wherever tracking is used:
325
+ return (
326
+ <>
327
+ <YourNavigator />
328
+ <GeoDebugOverlay />
329
+ </>
330
+ );
330
331
  ```
331
332
 
332
- > **Why must it be in `index.js`?** React Native's `AppRegistry.setWrapperComponentProvider` must be called before `registerComponent` — the same reason `react-native-gesture-handler` must also be imported there. Placing it anywhere else (e.g. inside a hook or screen) is too late; the app root has already mounted.
333
-
334
- ### Auto-mount debug panel
335
-
336
- Once the setup import is in place, the panel mounts and unmounts automatically:
333
+ Then set `debug: true` in your config:
337
334
 
338
335
  ```ts
339
- // Panel appears automatically when tracking starts
340
336
  await RNGeoService.configure({ debug: true, ... });
341
- await RNGeoService.start(); // panel is now visible
337
+ await RNGeoService.start(); // panel becomes visible automatically
342
338
 
343
- // Panel is removed when tracking stops
344
- await RNGeoService.stop();
339
+ await RNGeoService.stop(); // panel hides automatically
345
340
  ```
346
341
 
347
- No `<GeoDebugPanel />` or `<GeoDebugOverlay />` needed anywhere in the component tree.
342
+ > **Note:** `GeoDebugOverlay` is a standard React component — it renders nothing in production when `debug: false`. It is safe to leave in the tree at all times.
343
+
344
+ | Minimized | Opened |
345
+ |--------|-------------|
346
+ | <img width="349" height="261" alt="image" src="https://github.com/user-attachments/assets/a6b43b93-7a93-485d-a68d-f4e4fe658011" /> | <img width="363" height="348" alt="image" src="https://github.com/user-attachments/assets/9c02ebc9-28f2-4983-982b-810c98a32dfe" /> |
348
347
 
349
348
  ### Debug panel behaviour
350
349
 
@@ -359,7 +358,7 @@ The panel is a **draggable, minimizable floating overlay** that starts minimized
359
358
  | Metric | Description |
360
359
  |--------|-------------|
361
360
  | Tracking for | How long the current session has been running |
362
- | Updates | Total location fixes received |
361
+ | Geopoints | Total locations received |
363
362
  | Updates/min | Average frequency of location updates |
364
363
  | GPS active | % of session time the GPS chip was on vs idle |
365
364
  | Battery now | Current device battery level |
@@ -374,19 +373,15 @@ The panel is a **draggable, minimizable floating overlay** that starts minimized
374
373
  - 🔴 Drain rate > 8%/hr → try `'balanced'` accuracy or longer update intervals
375
374
  - ✅ All metrics in range → confirms settings are efficient
376
375
 
377
- > **Note:** Battery drain is measured at the whole-device level since iOS and Android do not expose per-app battery consumption via public APIs. Use GPS active % and updates/min as the primary indicators of how much the package itself is contributing.
376
+ > **Note:** Battery drain is measured at the whole-device level since iOS and Android do not expose per-app battery consumption via public APIs. Use GPS active % and updates/min as the primary indicators of how much this package contributes.
378
377
 
379
- ### Manual usage (optional)
378
+ ### Manual panel (optional)
380
379
 
381
- If you prefer to control rendering yourself, `GeoDebugPanel` and `GeoDebugOverlay` are also exported for direct use — the `debug-panel` setup import is still required for them to render correctly.
380
+ For a custom poll interval or always-visible panel, use `GeoDebugPanel` directly:
382
381
 
383
382
  ```tsx
384
- import { GeoDebugPanel, GeoDebugOverlay } from '@tsachit/react-native-geo-service';
385
-
386
- // Renders anywhere in your tree — self-hides when tracking is inactive:
387
- <GeoDebugOverlay />
383
+ import { GeoDebugPanel } from '@tsachit/react-native-geo-service';
388
384
 
389
- // Always-visible panel with custom poll interval:
390
385
  <GeoDebugPanel pollInterval={15000} />
391
386
  ```
392
387
 
@@ -419,7 +414,7 @@ Upon relaunch, the module detects `UIApplicationLaunchOptionsLocationKey`, resto
419
414
  - On iOS, use `coarseTracking: true` if ~500m granularity is acceptable — uses cell towers only
420
415
  - On Android, increase `updateIntervalMs` (e.g. `10000`) to give FusedLocationProvider room to batch fixes
421
416
  - Set `motionActivity: 'automotiveNavigation'` or `'fitness'` so iOS applies activity-specific optimisations
422
- - Use the `GeoDebugPanel` to measure real-world impact and act on its suggestions
417
+ - Use the debug overlay (`debug: true`) to measure real-world impact and act on its suggestions
423
418
 
424
419
  ---
425
420
 
@@ -232,7 +232,7 @@ const GeoDebugPanel = ({ pollInterval = 30000 }) => {
232
232
  {/* ── Metrics grid ── */}
233
233
  <react_native_1.View style={styles.grid}>
234
234
  <MetricBox label="Tracking for" value={elapsed > 0 ? formatElapsed(elapsed) : '—'} desc="session duration"/>
235
- <MetricBox label="Updates" value={`${updates}`} desc="location fixes received"/>
235
+ <MetricBox label="Geopoints" value={`${updates}`} desc="total locations received"/>
236
236
  <MetricBox label="Updates/min" value={upm > 0 ? upm.toFixed(1) : '—'} desc="higher = more battery"/>
237
237
  <MetricBox label="GPS active" value={elapsed > 0 ? formatGpsPercent(gpsActive, elapsed) : '—'} desc="lower = adaptive saving"/>
238
238
  <MetricBox label="Battery now" value={formatBattery(level)} desc={info.isCharging ? '⚡ charging' : 'not charging'}/>
package/lib/index.d.ts CHANGED
@@ -4,9 +4,6 @@ export declare function _isDebugMode(): boolean;
4
4
  /**
5
5
  * Configure the geo service. Call this before start().
6
6
  * Safe to call multiple times; subsequent calls update the config.
7
- *
8
- * When debug: true, a draggable debug overlay is mounted automatically —
9
- * no component needs to be added to the app.
10
7
  */
11
8
  declare function configure(config: GeoServiceConfig): Promise<void>;
12
9
  /**
package/lib/index.js CHANGED
@@ -61,28 +61,13 @@ function _isDebugMode() { return _debugMode; }
61
61
  /**
62
62
  * Configure the geo service. Call this before start().
63
63
  * Safe to call multiple times; subsequent calls update the config.
64
- *
65
- * When debug: true, a draggable debug overlay is mounted automatically —
66
- * no component needs to be added to the app.
67
64
  */
68
65
  function configure(config) {
69
66
  return __awaiter(this, void 0, void 0, function* () {
70
67
  var _a;
71
- const wasDebug = _debugMode;
72
68
  _debugMode = (_a = config.debug) !== null && _a !== void 0 ? _a : false;
73
69
  const merged = Object.assign(Object.assign({}, DEFAULT_CONFIG), config);
74
- const result = nativeModule.configure(merged);
75
- // Lazy require to avoid circular dependency at module init time.
76
- // autoDebug → GeoDebugOverlay → GeoDebugPanel → index (all lazy references).
77
- if (_debugMode && !wasDebug) {
78
- // eslint-disable-next-line @typescript-eslint/no-var-requires
79
- require('./autoDebug').mountDebugOverlay();
80
- }
81
- else if (!_debugMode && wasDebug) {
82
- // eslint-disable-next-line @typescript-eslint/no-var-requires
83
- require('./autoDebug').unmountDebugOverlay();
84
- }
85
- return result;
70
+ return nativeModule.configure(merged);
86
71
  });
87
72
  }
88
73
  /**
@@ -92,12 +77,7 @@ function configure(config) {
92
77
  */
93
78
  function start() {
94
79
  return __awaiter(this, void 0, void 0, function* () {
95
- const result = nativeModule.start();
96
- if (_debugMode) {
97
- // eslint-disable-next-line @typescript-eslint/no-var-requires
98
- require('./autoDebug').mountDebugOverlay();
99
- }
100
- return result;
80
+ return nativeModule.start();
101
81
  });
102
82
  }
103
83
  /**
@@ -105,12 +85,7 @@ function start() {
105
85
  */
106
86
  function stop() {
107
87
  return __awaiter(this, void 0, void 0, function* () {
108
- const result = nativeModule.stop();
109
- if (_debugMode) {
110
- // eslint-disable-next-line @typescript-eslint/no-var-requires
111
- require('./autoDebug').unmountDebugOverlay();
112
- }
113
- return result;
88
+ return nativeModule.stop();
114
89
  });
115
90
  }
116
91
  /**
package/lib/types.d.ts CHANGED
@@ -146,7 +146,7 @@ export interface BatteryInfo {
146
146
  levelAtStart: number;
147
147
  /** Percentage points drained since tracking started */
148
148
  drainSinceStart: number;
149
- /** How many location fixes have been delivered since start() */
149
+ /** How many total location have been delivered since start() */
150
150
  updateCount: number;
151
151
  /** Total seconds since start() was called */
152
152
  trackingElapsedSeconds: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsachit/react-native-geo-service",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Battery-efficient background geolocation for React Native with headless support",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -8,9 +8,7 @@
8
8
  "lib",
9
9
  "android",
10
10
  "ios",
11
- "react-native-geo-service.podspec",
12
- "debug-panel.js",
13
- "debug-panel.d.ts"
11
+ "react-native-geo-service.podspec"
14
12
  ],
15
13
  "scripts": {
16
14
  "build": "tsc",
@@ -41,8 +39,5 @@
41
39
  "bugs": {
42
40
  "url": "https://github.com/tsachit/react-native-geo-service/issues"
43
41
  },
44
- "homepage": "https://github.com/tsachit/react-native-geo-service#readme",
45
- "dependencies": {
46
- "react-native-root-siblings": "^5.0.1"
47
- }
42
+ "homepage": "https://github.com/tsachit/react-native-geo-service#readme"
48
43
  }
package/debug-panel.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/debug-panel.js DELETED
@@ -1 +0,0 @@
1
- require('./lib/setup');
@@ -1,2 +0,0 @@
1
- export declare function mountDebugOverlay(): void;
2
- export declare function unmountDebugOverlay(): void;
package/lib/autoDebug.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.mountDebugOverlay = mountDebugOverlay;
7
- exports.unmountDebugOverlay = unmountDebugOverlay;
8
- const react_1 = __importDefault(require("react"));
9
- const react_native_root_siblings_1 = __importDefault(require("react-native-root-siblings"));
10
- const GeoDebugOverlay_1 = require("./GeoDebugOverlay");
11
- let sibling = null;
12
- function mountDebugOverlay() {
13
- if (!sibling) {
14
- sibling = new react_native_root_siblings_1.default(react_1.default.createElement(GeoDebugOverlay_1.GeoDebugOverlay));
15
- }
16
- }
17
- function unmountDebugOverlay() {
18
- if (sibling) {
19
- sibling.destroy();
20
- sibling = null;
21
- }
22
- }
package/lib/setup.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/lib/setup.js DELETED
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Import this file ONCE at the top of your app's index.js, before
5
- * AppRegistry.registerComponent. This registers RootSiblingParent as
6
- * the app wrapper so GeoService can render the debug overlay automatically
7
- * when configure({ debug: true }) is called — no component needed in the tree.
8
- *
9
- * index.js:
10
- * import '@tsachit/react-native-geo-service/setup'; // ← add this line
11
- * import { AppRegistry } from 'react-native';
12
- * import App from './App';
13
- * AppRegistry.registerComponent('MyApp', () => App);
14
- */
15
- const react_native_1 = require("react-native");
16
- const react_native_root_siblings_1 = require("react-native-root-siblings");
17
- react_native_1.AppRegistry.setWrapperComponentProvider(() => react_native_root_siblings_1.RootSiblingParent);