react-native-nitro-location-tracking 0.1.0
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/LICENSE +20 -0
- package/NitroLocationTracking.podspec +29 -0
- package/README.md +39 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +122 -0
- package/android/src/main/AndroidManifest.xml +18 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/ConnectionManager.kt +137 -0
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/LocationEngine.kt +93 -0
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/LocationForegroundService.kt +65 -0
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/NativeDBWriter.kt +80 -0
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/NitroLocationTracking.kt +180 -0
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/NitroLocationTrackingPackage.kt +22 -0
- package/android/src/main/java/com/margelo/nitro/nitrolocationtracking/NotificationService.kt +75 -0
- package/ios/ConnectionManager.swift +144 -0
- package/ios/LocationEngine.swift +146 -0
- package/ios/NativeDBWriter.swift +121 -0
- package/ios/NitroLocationTracking.swift +127 -0
- package/ios/NotificationService.swift +31 -0
- package/lib/module/LocationSmoother.js +33 -0
- package/lib/module/LocationSmoother.js.map +1 -0
- package/lib/module/NitroLocationTracking.nitro.js +4 -0
- package/lib/module/NitroLocationTracking.nitro.js.map +1 -0
- package/lib/module/bearing.js +19 -0
- package/lib/module/bearing.js.map +1 -0
- package/lib/module/db.js +234 -0
- package/lib/module/db.js.map +1 -0
- package/lib/module/index.js +68 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/LocationSmoother.d.ts +19 -0
- package/lib/typescript/src/LocationSmoother.d.ts.map +1 -0
- package/lib/typescript/src/NitroLocationTracking.nitro.d.ts +59 -0
- package/lib/typescript/src/NitroLocationTracking.nitro.d.ts.map +1 -0
- package/lib/typescript/src/bearing.d.ts +9 -0
- package/lib/typescript/src/bearing.d.ts.map +1 -0
- package/lib/typescript/src/db.d.ts +1 -0
- package/lib/typescript/src/db.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +21 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/c++/JAccuracyLevel.hpp +61 -0
- package/nitrogen/generated/android/c++/JConnectionConfig.hpp +81 -0
- package/nitrogen/generated/android/c++/JConnectionState.hpp +61 -0
- package/nitrogen/generated/android/c++/JFunc_void_ConnectionState.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_LocationData.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
- package/nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.cpp +179 -0
- package/nitrogen/generated/android/c++/JHybridNitroLocationTrackingSpec.hpp +83 -0
- package/nitrogen/generated/android/c++/JLocationConfig.hpp +91 -0
- package/nitrogen/generated/android/c++/JLocationData.hpp +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/AccuracyLevel.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/ConnectionConfig.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/ConnectionState.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/Func_void_ConnectionState.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/Func_void_LocationData.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/Func_void_bool.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/Func_void_std__string.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/HybridNitroLocationTrackingSpec.kt +146 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/LocationConfig.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/LocationData.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolocationtracking/nitrolocationtrackingOnLoad.kt +35 -0
- package/nitrogen/generated/android/nitrolocationtracking+autolinking.cmake +81 -0
- package/nitrogen/generated/android/nitrolocationtracking+autolinking.gradle +27 -0
- package/nitrogen/generated/android/nitrolocationtrackingOnLoad.cpp +52 -0
- package/nitrogen/generated/android/nitrolocationtrackingOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/NitroLocationTracking+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroLocationTracking-Swift-Cxx-Bridge.cpp +73 -0
- package/nitrogen/generated/ios/NitroLocationTracking-Swift-Cxx-Bridge.hpp +231 -0
- package/nitrogen/generated/ios/NitroLocationTracking-Swift-Cxx-Umbrella.hpp +61 -0
- package/nitrogen/generated/ios/NitroLocationTrackingAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroLocationTrackingAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridNitroLocationTrackingSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroLocationTrackingSpecSwift.hpp +206 -0
- package/nitrogen/generated/ios/swift/AccuracyLevel.swift +44 -0
- package/nitrogen/generated/ios/swift/ConnectionConfig.swift +59 -0
- package/nitrogen/generated/ios/swift/ConnectionState.swift +44 -0
- package/nitrogen/generated/ios/swift/Func_void_ConnectionState.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_LocationData.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridNitroLocationTrackingSpec.swift +72 -0
- package/nitrogen/generated/ios/swift/HybridNitroLocationTrackingSpec_cxx.swift +362 -0
- package/nitrogen/generated/ios/swift/LocationConfig.swift +69 -0
- package/nitrogen/generated/ios/swift/LocationData.swift +59 -0
- package/nitrogen/generated/shared/c++/AccuracyLevel.hpp +80 -0
- package/nitrogen/generated/shared/c++/ConnectionConfig.hpp +107 -0
- package/nitrogen/generated/shared/c++/ConnectionState.hpp +80 -0
- package/nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.cpp +38 -0
- package/nitrogen/generated/shared/c++/HybridNitroLocationTrackingSpec.hpp +92 -0
- package/nitrogen/generated/shared/c++/LocationConfig.hpp +117 -0
- package/nitrogen/generated/shared/c++/LocationData.hpp +107 -0
- package/package.json +174 -0
- package/src/LocationSmoother.ts +46 -0
- package/src/NitroLocationTracking.nitro.ts +79 -0
- package/src/bearing.ts +22 -0
- package/src/db.ts +232 -0
- package/src/index.tsx +92 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import NitroModules
|
|
3
|
+
|
|
4
|
+
class NitroLocationTracking: HybridNitroLocationTrackingSpec {
|
|
5
|
+
|
|
6
|
+
private let locationEngine = LocationEngine()
|
|
7
|
+
private let connectionManager = ConnectionManager()
|
|
8
|
+
private let dbWriter = NativeDBWriter()
|
|
9
|
+
private let notificationService = NotificationService()
|
|
10
|
+
|
|
11
|
+
private var locationCallback: ((LocationData) -> Void)?
|
|
12
|
+
private var motionCallback: ((Bool) -> Void)?
|
|
13
|
+
private var connectionStateCallback: ((ConnectionState) -> Void)?
|
|
14
|
+
private var messageCallback: ((String) -> Void)?
|
|
15
|
+
|
|
16
|
+
override init() {
|
|
17
|
+
super.init()
|
|
18
|
+
locationEngine.dbWriter = dbWriter
|
|
19
|
+
connectionManager.dbWriter = dbWriter
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// MARK: - Location Engine
|
|
23
|
+
|
|
24
|
+
func configure(config: LocationConfig) throws {
|
|
25
|
+
locationEngine.configure(config)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
func startTracking() throws {
|
|
29
|
+
locationEngine.onLocation = { [weak self] data in
|
|
30
|
+
self?.locationCallback?(data)
|
|
31
|
+
}
|
|
32
|
+
locationEngine.onMotionChange = { [weak self] isMoving in
|
|
33
|
+
self?.motionCallback?(isMoving)
|
|
34
|
+
}
|
|
35
|
+
locationEngine.start()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
func stopTracking() throws {
|
|
39
|
+
locationEngine.stop()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
func getCurrentLocation() throws -> Promise<LocationData> {
|
|
43
|
+
let promise = Promise<LocationData>()
|
|
44
|
+
locationEngine.getCurrentLocation { data in
|
|
45
|
+
if let data = data {
|
|
46
|
+
promise.resolve(withResult: data)
|
|
47
|
+
} else {
|
|
48
|
+
promise.reject(withError: NSError(domain: "NitroLocation",
|
|
49
|
+
code: 1,
|
|
50
|
+
userInfo: [NSLocalizedDescriptionKey: "Failed to get location"]))
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return promise
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
func isTracking() throws -> Bool {
|
|
57
|
+
return locationEngine.isTracking
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
func onLocation(callback: @escaping (LocationData) -> Void) throws {
|
|
61
|
+
locationCallback = callback
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
func onMotionChange(callback: @escaping (Bool) -> Void) throws {
|
|
65
|
+
motionCallback = callback
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// MARK: - Connection Manager
|
|
69
|
+
|
|
70
|
+
func configureConnection(config: ConnectionConfig) throws {
|
|
71
|
+
connectionManager.configure(config)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
func connectWebSocket() throws {
|
|
75
|
+
connectionManager.onStateChange = { [weak self] (state: ConnectionState) in
|
|
76
|
+
self?.connectionStateCallback?(state)
|
|
77
|
+
}
|
|
78
|
+
connectionManager.onMessage = { [weak self] message in
|
|
79
|
+
self?.messageCallback?(message)
|
|
80
|
+
}
|
|
81
|
+
connectionManager.connect()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
func disconnectWebSocket() throws {
|
|
85
|
+
connectionManager.disconnect()
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
func sendMessage(message: String) throws {
|
|
89
|
+
connectionManager.send(message)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
func getConnectionState() throws -> ConnectionState {
|
|
93
|
+
return connectionManager.getState()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
func onConnectionStateChange(callback: @escaping (ConnectionState) -> Void) throws {
|
|
97
|
+
connectionStateCallback = callback
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
func onMessage(callback: @escaping (String) -> Void) throws {
|
|
101
|
+
messageCallback = callback
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// MARK: - Sync Control
|
|
105
|
+
|
|
106
|
+
func forceSync() throws -> Promise<Bool> {
|
|
107
|
+
let result = connectionManager.flushQueue()
|
|
108
|
+
return Promise.resolved(withResult: result)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// MARK: - Notifications
|
|
112
|
+
|
|
113
|
+
func showLocalNotification(title: String, body: String) throws {
|
|
114
|
+
notificationService.showLocalNotification(title: title, body: body)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
func updateForegroundNotification(title: String, body: String) throws {
|
|
118
|
+
notificationService.updateForegroundNotification(title: title, body: body)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// MARK: - Lifecycle
|
|
122
|
+
|
|
123
|
+
func destroy() throws {
|
|
124
|
+
locationEngine.stop()
|
|
125
|
+
connectionManager.disconnect()
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import UserNotifications
|
|
2
|
+
|
|
3
|
+
class NotificationService {
|
|
4
|
+
|
|
5
|
+
init() {
|
|
6
|
+
UNUserNotificationCenter.current().requestAuthorization(
|
|
7
|
+
options: [.alert, .sound, .badge]) { _, _ in }
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
func showLocalNotification(title: String, body: String) {
|
|
11
|
+
let content = UNMutableNotificationContent()
|
|
12
|
+
content.title = title
|
|
13
|
+
content.body = body
|
|
14
|
+
content.sound = .default
|
|
15
|
+
|
|
16
|
+
let request = UNNotificationRequest(
|
|
17
|
+
identifier: UUID().uuidString,
|
|
18
|
+
content: content,
|
|
19
|
+
trigger: nil
|
|
20
|
+
)
|
|
21
|
+
UNUserNotificationCenter.current().add(request)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
func updateForegroundNotification(title: String, body: String) {
|
|
25
|
+
// iOS doesn't have a persistent foreground service notification
|
|
26
|
+
// like Android. This is a no-op on iOS — background tracking
|
|
27
|
+
// is handled via CoreLocation background mode.
|
|
28
|
+
// If needed, we show a local notification instead.
|
|
29
|
+
showLocalNotification(title: title, body: body)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
|
4
|
+
export class LocationSmoother {
|
|
5
|
+
queue = [];
|
|
6
|
+
isAnimating = false;
|
|
7
|
+
constructor(markerRef) {
|
|
8
|
+
this.markerRef = markerRef;
|
|
9
|
+
}
|
|
10
|
+
feed(location) {
|
|
11
|
+
this.queue.push(location);
|
|
12
|
+
if (this.queue.length > 10) this.queue = this.queue.slice(-3);
|
|
13
|
+
if (!this.isAnimating) this.drain();
|
|
14
|
+
}
|
|
15
|
+
async drain() {
|
|
16
|
+
this.isAnimating = true;
|
|
17
|
+
while (this.queue.length > 0) {
|
|
18
|
+
const next = this.queue.shift();
|
|
19
|
+
const dur = this.queue.length > 3 ? 500 : this.queue.length > 1 ? 1000 : 2000;
|
|
20
|
+
this.markerRef.current?.animateMarkerToCoordinate({
|
|
21
|
+
latitude: next.latitude,
|
|
22
|
+
longitude: next.longitude
|
|
23
|
+
}, dur);
|
|
24
|
+
await sleep(dur * 0.9);
|
|
25
|
+
}
|
|
26
|
+
this.isAnimating = false;
|
|
27
|
+
}
|
|
28
|
+
clear() {
|
|
29
|
+
this.queue = [];
|
|
30
|
+
this.isAnimating = false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=LocationSmoother.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["sleep","ms","Promise","r","setTimeout","LocationSmoother","queue","isAnimating","constructor","markerRef","feed","location","push","length","slice","drain","next","shift","dur","current","animateMarkerToCoordinate","latitude","longitude","clear"],"sourceRoot":"../../src","sources":["LocationSmoother.ts"],"mappings":";;AAEA,MAAMA,KAAK,GAAIC,EAAU,IAAK,IAAIC,OAAO,CAAQC,CAAC,IAAKC,UAAU,CAACD,CAAC,EAAEF,EAAE,CAAC,CAAC;AASzE,OAAO,MAAMI,gBAAgB,CAAC;EACpBC,KAAK,GAAmB,EAAE;EAC1BC,WAAW,GAAG,KAAK;EAG3BC,WAAWA,CAACC,SAAwC,EAAE;IACpD,IAAI,CAACA,SAAS,GAAGA,SAAS;EAC5B;EAEAC,IAAIA,CAACC,QAAsB,EAAE;IAC3B,IAAI,CAACL,KAAK,CAACM,IAAI,CAACD,QAAQ,CAAC;IACzB,IAAI,IAAI,CAACL,KAAK,CAACO,MAAM,GAAG,EAAE,EAAE,IAAI,CAACP,KAAK,GAAG,IAAI,CAACA,KAAK,CAACQ,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7D,IAAI,CAAC,IAAI,CAACP,WAAW,EAAE,IAAI,CAACQ,KAAK,CAAC,CAAC;EACrC;EAEA,MAAcA,KAAKA,CAAA,EAAG;IACpB,IAAI,CAACR,WAAW,GAAG,IAAI;IACvB,OAAO,IAAI,CAACD,KAAK,CAACO,MAAM,GAAG,CAAC,EAAE;MAC5B,MAAMG,IAAI,GAAG,IAAI,CAACV,KAAK,CAACW,KAAK,CAAC,CAAE;MAChC,MAAMC,GAAG,GACP,IAAI,CAACZ,KAAK,CAACO,MAAM,GAAG,CAAC,GAAG,GAAG,GAAG,IAAI,CAACP,KAAK,CAACO,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI;MACnE,IAAI,CAACJ,SAAS,CAACU,OAAO,EAAEC,yBAAyB,CAC/C;QAAEC,QAAQ,EAAEL,IAAI,CAACK,QAAQ;QAAEC,SAAS,EAAEN,IAAI,CAACM;MAAU,CAAC,EACtDJ,GACF,CAAC;MACD,MAAMlB,KAAK,CAACkB,GAAG,GAAG,GAAG,CAAC;IACxB;IACA,IAAI,CAACX,WAAW,GAAG,KAAK;EAC1B;EAEAgB,KAAKA,CAAA,EAAG;IACN,IAAI,CAACjB,KAAK,GAAG,EAAE;IACf,IAAI,CAACC,WAAW,GAAG,KAAK;EAC1B;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["NitroLocationTracking.nitro.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export function shortestRotation(from, to) {
|
|
4
|
+
let diff = to - from;
|
|
5
|
+
while (diff > 180) diff -= 360;
|
|
6
|
+
while (diff < -180) diff += 360;
|
|
7
|
+
return from + diff;
|
|
8
|
+
}
|
|
9
|
+
export function calculateBearing(from, to) {
|
|
10
|
+
const toRad = d => d * Math.PI / 180;
|
|
11
|
+
const toDeg = r => r * 180 / Math.PI;
|
|
12
|
+
const dLon = toRad(to.longitude - from.longitude);
|
|
13
|
+
const lat1 = toRad(from.latitude);
|
|
14
|
+
const lat2 = toRad(to.latitude);
|
|
15
|
+
const y = Math.sin(dLon) * Math.cos(lat2);
|
|
16
|
+
const x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon);
|
|
17
|
+
return (toDeg(Math.atan2(y, x)) + 360) % 360;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=bearing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["shortestRotation","from","to","diff","calculateBearing","toRad","d","Math","PI","toDeg","r","dLon","longitude","lat1","latitude","lat2","y","sin","cos","x","atan2"],"sourceRoot":"../../src","sources":["bearing.ts"],"mappings":";;AAAA,OAAO,SAASA,gBAAgBA,CAACC,IAAY,EAAEC,EAAU,EAAU;EACjE,IAAIC,IAAI,GAAGD,EAAE,GAAGD,IAAI;EACpB,OAAOE,IAAI,GAAG,GAAG,EAAEA,IAAI,IAAI,GAAG;EAC9B,OAAOA,IAAI,GAAG,CAAC,GAAG,EAAEA,IAAI,IAAI,GAAG;EAC/B,OAAOF,IAAI,GAAGE,IAAI;AACpB;AAEA,OAAO,SAASC,gBAAgBA,CAC9BH,IAA6C,EAC7CC,EAA2C,EACnC;EACR,MAAMG,KAAK,GAAIC,CAAS,IAAMA,CAAC,GAAGC,IAAI,CAACC,EAAE,GAAI,GAAG;EAChD,MAAMC,KAAK,GAAIC,CAAS,IAAMA,CAAC,GAAG,GAAG,GAAIH,IAAI,CAACC,EAAE;EAChD,MAAMG,IAAI,GAAGN,KAAK,CAACH,EAAE,CAACU,SAAS,GAAGX,IAAI,CAACW,SAAS,CAAC;EACjD,MAAMC,IAAI,GAAGR,KAAK,CAACJ,IAAI,CAACa,QAAQ,CAAC;EACjC,MAAMC,IAAI,GAAGV,KAAK,CAACH,EAAE,CAACY,QAAQ,CAAC;EAC/B,MAAME,CAAC,GAAGT,IAAI,CAACU,GAAG,CAACN,IAAI,CAAC,GAAGJ,IAAI,CAACW,GAAG,CAACH,IAAI,CAAC;EACzC,MAAMI,CAAC,GACLZ,IAAI,CAACW,GAAG,CAACL,IAAI,CAAC,GAAGN,IAAI,CAACU,GAAG,CAACF,IAAI,CAAC,GAC/BR,IAAI,CAACU,GAAG,CAACJ,IAAI,CAAC,GAAGN,IAAI,CAACW,GAAG,CAACH,IAAI,CAAC,GAAGR,IAAI,CAACW,GAAG,CAACP,IAAI,CAAC;EAClD,OAAO,CAACF,KAAK,CAACF,IAAI,CAACa,KAAK,CAACJ,CAAC,EAAEG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,GAAG;AAC9C","ignoreList":[]}
|
package/lib/module/db.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// import { open } from 'react-native-nitro-sqlite'
|
|
2
|
+
|
|
3
|
+
// // Open the SAME database that native module writes to
|
|
4
|
+
// export const db = open({ name: 'nitro_location.db' })
|
|
5
|
+
|
|
6
|
+
// // Enable WAL for safe concurrent access with native writer
|
|
7
|
+
// db.execute('PRAGMA journal_mode = WAL')
|
|
8
|
+
|
|
9
|
+
// // ─── Additional Tables (JS-managed) ────────────────
|
|
10
|
+
|
|
11
|
+
// db.execute(`
|
|
12
|
+
// CREATE TABLE IF NOT EXISTS rides (
|
|
13
|
+
// id TEXT PRIMARY KEY,
|
|
14
|
+
// driver_id TEXT,
|
|
15
|
+
// rider_id TEXT,
|
|
16
|
+
// status TEXT DEFAULT 'pending',
|
|
17
|
+
// pickup_lat REAL, pickup_lng REAL,
|
|
18
|
+
// dropoff_lat REAL, dropoff_lng REAL,
|
|
19
|
+
// pickup_address TEXT, dropoff_address TEXT,
|
|
20
|
+
// fare_amount REAL,
|
|
21
|
+
// distance_km REAL,
|
|
22
|
+
// duration_minutes REAL,
|
|
23
|
+
// started_at INTEGER,
|
|
24
|
+
// completed_at INTEGER,
|
|
25
|
+
// created_at INTEGER DEFAULT (strftime('%s','now') * 1000)
|
|
26
|
+
// )
|
|
27
|
+
// `)
|
|
28
|
+
|
|
29
|
+
// db.execute(`
|
|
30
|
+
// CREATE TABLE IF NOT EXISTS earnings (
|
|
31
|
+
// id TEXT PRIMARY KEY,
|
|
32
|
+
// date TEXT UNIQUE,
|
|
33
|
+
// ride_count INTEGER DEFAULT 0,
|
|
34
|
+
// total_amount REAL DEFAULT 0,
|
|
35
|
+
// total_distance REAL DEFAULT 0,
|
|
36
|
+
// online_hours REAL DEFAULT 0
|
|
37
|
+
// )
|
|
38
|
+
// `)
|
|
39
|
+
|
|
40
|
+
// db.execute(`
|
|
41
|
+
// CREATE TABLE IF NOT EXISTS settings (
|
|
42
|
+
// key TEXT PRIMARY KEY,
|
|
43
|
+
// value TEXT
|
|
44
|
+
// )
|
|
45
|
+
// `)
|
|
46
|
+
|
|
47
|
+
// // ─── Query Helpers — Locations ──────────────────────
|
|
48
|
+
|
|
49
|
+
// export function getRecentLocations(limit = 100) {
|
|
50
|
+
// return db.execute(
|
|
51
|
+
// 'SELECT * FROM locations ORDER BY timestamp DESC LIMIT ?',
|
|
52
|
+
// [limit]
|
|
53
|
+
// )
|
|
54
|
+
// }
|
|
55
|
+
|
|
56
|
+
// export function getRideLocations(rideId: string) {
|
|
57
|
+
// return db.execute(
|
|
58
|
+
// `
|
|
59
|
+
// SELECT latitude, longitude, speed, bearing, timestamp
|
|
60
|
+
// FROM locations WHERE ride_id = ? ORDER BY timestamp ASC
|
|
61
|
+
// `,
|
|
62
|
+
// [rideId]
|
|
63
|
+
// )
|
|
64
|
+
// }
|
|
65
|
+
|
|
66
|
+
// export function getLocationsBetween(startMs: number, endMs: number) {
|
|
67
|
+
// return db.execute(
|
|
68
|
+
// `
|
|
69
|
+
// SELECT * FROM locations
|
|
70
|
+
// WHERE timestamp BETWEEN ? AND ? ORDER BY timestamp ASC
|
|
71
|
+
// `,
|
|
72
|
+
// [startMs, endMs]
|
|
73
|
+
// )
|
|
74
|
+
// }
|
|
75
|
+
|
|
76
|
+
// export function getUnsyncedCount(): number {
|
|
77
|
+
// return db.execute(
|
|
78
|
+
// 'SELECT COUNT(*) as count FROM locations WHERE synced = 0'
|
|
79
|
+
// ).rows.item(0)!.count as number
|
|
80
|
+
// }
|
|
81
|
+
|
|
82
|
+
// // ─── Query Helpers — Analytics ──────────────────────
|
|
83
|
+
|
|
84
|
+
// export function getTodayStats() {
|
|
85
|
+
// const today = new Date().toISOString().split('T')[0]!
|
|
86
|
+
// return db.execute(
|
|
87
|
+
// `
|
|
88
|
+
// SELECT COUNT(*) as trips,
|
|
89
|
+
// COALESCE(SUM(fare_amount), 0) as earnings,
|
|
90
|
+
// COALESCE(SUM(distance_km), 0) as distance,
|
|
91
|
+
// COALESCE(SUM(duration_minutes), 0) as minutes
|
|
92
|
+
// FROM rides
|
|
93
|
+
// WHERE date(started_at / 1000, 'unixepoch') = ?
|
|
94
|
+
// AND status = 'completed'
|
|
95
|
+
// `,
|
|
96
|
+
// [today]
|
|
97
|
+
// )
|
|
98
|
+
// }
|
|
99
|
+
|
|
100
|
+
// export function getWeeklyEarnings() {
|
|
101
|
+
// return db.execute(
|
|
102
|
+
// `
|
|
103
|
+
// SELECT date(started_at / 1000, 'unixepoch') as day,
|
|
104
|
+
// COUNT(*) as trips, SUM(fare_amount) as earnings,
|
|
105
|
+
// SUM(distance_km) as distance
|
|
106
|
+
// FROM rides WHERE started_at > ? AND status = 'completed'
|
|
107
|
+
// GROUP BY day ORDER BY day ASC
|
|
108
|
+
// `,
|
|
109
|
+
// [Date.now() - 7 * 86400000]
|
|
110
|
+
// )
|
|
111
|
+
// }
|
|
112
|
+
|
|
113
|
+
// export function getSpeedHistory(lastHours = 1) {
|
|
114
|
+
// return db.execute(
|
|
115
|
+
// `
|
|
116
|
+
// SELECT CAST(timestamp / 60000 AS INTEGER) * 60000 as minute,
|
|
117
|
+
// AVG(speed) as avg_speed, MAX(speed) as max_speed
|
|
118
|
+
// FROM locations WHERE timestamp > ?
|
|
119
|
+
// GROUP BY minute ORDER BY minute ASC
|
|
120
|
+
// `,
|
|
121
|
+
// [Date.now() - lastHours * 3600000]
|
|
122
|
+
// )
|
|
123
|
+
// }
|
|
124
|
+
|
|
125
|
+
// export function getPickupHeatmap(limit = 50) {
|
|
126
|
+
// return db.execute(
|
|
127
|
+
// `
|
|
128
|
+
// SELECT ROUND(pickup_lat, 3) as lat, ROUND(pickup_lng, 3) as lng,
|
|
129
|
+
// COUNT(*) as ride_count
|
|
130
|
+
// FROM rides WHERE status = 'completed'
|
|
131
|
+
// GROUP BY lat, lng ORDER BY ride_count DESC LIMIT ?
|
|
132
|
+
// `,
|
|
133
|
+
// [limit]
|
|
134
|
+
// )
|
|
135
|
+
// }
|
|
136
|
+
|
|
137
|
+
// export function getPeakHours() {
|
|
138
|
+
// return db.execute(`
|
|
139
|
+
// SELECT CAST(strftime('%H', started_at / 1000, 'unixepoch') AS INTEGER) as hour,
|
|
140
|
+
// COUNT(*) as trips, AVG(fare_amount) as avg_fare
|
|
141
|
+
// FROM rides WHERE status = 'completed'
|
|
142
|
+
// GROUP BY hour ORDER BY hour ASC
|
|
143
|
+
// `)
|
|
144
|
+
// }
|
|
145
|
+
|
|
146
|
+
// // ─── Query Helpers — Ride Management ────────────────
|
|
147
|
+
|
|
148
|
+
// export function createRide(ride: {
|
|
149
|
+
// id: string
|
|
150
|
+
// driverId?: string
|
|
151
|
+
// riderId?: string
|
|
152
|
+
// pickupLat: number
|
|
153
|
+
// pickupLng: number
|
|
154
|
+
// pickupAddress: string
|
|
155
|
+
// dropoffLat: number
|
|
156
|
+
// dropoffLng: number
|
|
157
|
+
// dropoffAddress: string
|
|
158
|
+
// }) {
|
|
159
|
+
// return db.execute(
|
|
160
|
+
// `
|
|
161
|
+
// INSERT INTO rides (id, driver_id, rider_id, status,
|
|
162
|
+
// pickup_lat, pickup_lng, pickup_address,
|
|
163
|
+
// dropoff_lat, dropoff_lng, dropoff_address, started_at)
|
|
164
|
+
// VALUES (?, ?, ?, 'active', ?, ?, ?, ?, ?, ?, ?)
|
|
165
|
+
// `,
|
|
166
|
+
// [
|
|
167
|
+
// ride.id,
|
|
168
|
+
// ride.driverId ?? null,
|
|
169
|
+
// ride.riderId ?? null,
|
|
170
|
+
// ride.pickupLat,
|
|
171
|
+
// ride.pickupLng,
|
|
172
|
+
// ride.pickupAddress,
|
|
173
|
+
// ride.dropoffLat,
|
|
174
|
+
// ride.dropoffLng,
|
|
175
|
+
// ride.dropoffAddress,
|
|
176
|
+
// Date.now(),
|
|
177
|
+
// ]
|
|
178
|
+
// )
|
|
179
|
+
// }
|
|
180
|
+
|
|
181
|
+
// export function completeRide(
|
|
182
|
+
// rideId: string,
|
|
183
|
+
// fare: number,
|
|
184
|
+
// distKm: number
|
|
185
|
+
// ) {
|
|
186
|
+
// const now = Date.now()
|
|
187
|
+
// db.execute(
|
|
188
|
+
// `
|
|
189
|
+
// UPDATE rides SET status = 'completed', fare_amount = ?,
|
|
190
|
+
// distance_km = ?, completed_at = ?,
|
|
191
|
+
// duration_minutes = (? - started_at) / 60000.0
|
|
192
|
+
// WHERE id = ?
|
|
193
|
+
// `,
|
|
194
|
+
// [fare, distKm, now, now, rideId]
|
|
195
|
+
// )
|
|
196
|
+
// }
|
|
197
|
+
|
|
198
|
+
// export function getRideHistory(limit = 20) {
|
|
199
|
+
// return db.execute(
|
|
200
|
+
// `
|
|
201
|
+
// SELECT * FROM rides WHERE status = 'completed'
|
|
202
|
+
// ORDER BY completed_at DESC LIMIT ?
|
|
203
|
+
// `,
|
|
204
|
+
// [limit]
|
|
205
|
+
// )
|
|
206
|
+
// }
|
|
207
|
+
|
|
208
|
+
// export function getRideWithLocations(rideId: string) {
|
|
209
|
+
// const ride = db.execute('SELECT * FROM rides WHERE id = ?', [rideId])
|
|
210
|
+
// const locs = db.execute(
|
|
211
|
+
// `
|
|
212
|
+
// SELECT latitude, longitude, speed, bearing, timestamp
|
|
213
|
+
// FROM locations WHERE ride_id = ? ORDER BY timestamp ASC
|
|
214
|
+
// `,
|
|
215
|
+
// [rideId]
|
|
216
|
+
// )
|
|
217
|
+
// return { ride: ride.rows.item(0), locations: locs.rows._array }
|
|
218
|
+
// }
|
|
219
|
+
|
|
220
|
+
// // ─── Settings Helper ────────────────────────────────
|
|
221
|
+
|
|
222
|
+
// export function getSetting(key: string): string | null {
|
|
223
|
+
// const r = db.execute('SELECT value FROM settings WHERE key = ?', [key])
|
|
224
|
+
// return r.rows.length > 0 ? (r.rows.item(0)!.value as string) : null
|
|
225
|
+
// }
|
|
226
|
+
|
|
227
|
+
// export function setSetting(key: string, value: string) {
|
|
228
|
+
// db.execute(
|
|
229
|
+
// 'INSERT OR REPLACE INTO settings (key, value) VALUES (?, ?)',
|
|
230
|
+
// [key, value]
|
|
231
|
+
// )
|
|
232
|
+
// }
|
|
233
|
+
"use strict";
|
|
234
|
+
//# sourceMappingURL=db.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["db.ts"],"mappings":"AAAA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, useCallback, useRef } from 'react';
|
|
4
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
5
|
+
const NitroLocationModule = NitroModules.createHybridObject('NitroLocationTracking');
|
|
6
|
+
export default NitroLocationModule;
|
|
7
|
+
export { LocationSmoother } from "./LocationSmoother.js";
|
|
8
|
+
export { shortestRotation, calculateBearing } from "./bearing.js";
|
|
9
|
+
// export * from './db'
|
|
10
|
+
|
|
11
|
+
export function useDriverLocation(config) {
|
|
12
|
+
const [location, setLocation] = useState(null);
|
|
13
|
+
const [isMoving, setIsMoving] = useState(false);
|
|
14
|
+
const [isTracking, setIsTracking] = useState(false);
|
|
15
|
+
|
|
16
|
+
// Stabilize config by value so the effect doesn't re-run on every render
|
|
17
|
+
const configJson = JSON.stringify(config);
|
|
18
|
+
|
|
19
|
+
// Keep a ref to track whether we started, so cleanup only stops if we did
|
|
20
|
+
const trackingRef = useRef(false);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const parsed = JSON.parse(configJson);
|
|
23
|
+
NitroLocationModule.configure(parsed);
|
|
24
|
+
NitroLocationModule.onLocation(setLocation);
|
|
25
|
+
NitroLocationModule.onMotionChange(setIsMoving);
|
|
26
|
+
return () => {
|
|
27
|
+
if (trackingRef.current) {
|
|
28
|
+
NitroLocationModule.stopTracking();
|
|
29
|
+
trackingRef.current = false;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}, [configJson]);
|
|
33
|
+
return {
|
|
34
|
+
location,
|
|
35
|
+
isMoving,
|
|
36
|
+
isTracking,
|
|
37
|
+
startTracking: useCallback(() => {
|
|
38
|
+
NitroLocationModule.startTracking();
|
|
39
|
+
trackingRef.current = true;
|
|
40
|
+
setIsTracking(true);
|
|
41
|
+
}, []),
|
|
42
|
+
stopTracking: useCallback(() => {
|
|
43
|
+
NitroLocationModule.stopTracking();
|
|
44
|
+
trackingRef.current = false;
|
|
45
|
+
setIsTracking(false);
|
|
46
|
+
}, [])
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function useRideConnection(config) {
|
|
50
|
+
const [connectionState, setConnectionState] = useState('disconnected');
|
|
51
|
+
const [lastMessage, setLastMessage] = useState(null);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
NitroLocationModule.configureConnection(config);
|
|
54
|
+
NitroLocationModule.onConnectionStateChange(setConnectionState);
|
|
55
|
+
NitroLocationModule.onMessage(setLastMessage);
|
|
56
|
+
return () => {
|
|
57
|
+
NitroLocationModule.disconnectWebSocket();
|
|
58
|
+
};
|
|
59
|
+
}, [config]);
|
|
60
|
+
return {
|
|
61
|
+
connectionState,
|
|
62
|
+
lastMessage,
|
|
63
|
+
connect: useCallback(() => NitroLocationModule.connectWebSocket(), []),
|
|
64
|
+
disconnect: useCallback(() => NitroLocationModule.disconnectWebSocket(), []),
|
|
65
|
+
send: useCallback(m => NitroLocationModule.sendMessage(m), [])
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useState","useEffect","useCallback","useRef","NitroModules","NitroLocationModule","createHybridObject","LocationSmoother","shortestRotation","calculateBearing","useDriverLocation","config","location","setLocation","isMoving","setIsMoving","isTracking","setIsTracking","configJson","JSON","stringify","trackingRef","parsed","parse","configure","onLocation","onMotionChange","current","stopTracking","startTracking","useRideConnection","connectionState","setConnectionState","lastMessage","setLastMessage","configureConnection","onConnectionStateChange","onMessage","disconnectWebSocket","connect","connectWebSocket","disconnect","send","m","sendMessage"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { LocationData } from './NitroLocationTracking.nitro';
|
|
2
|
+
export interface MarkerRef {
|
|
3
|
+
animateMarkerToCoordinate(coordinate: {
|
|
4
|
+
latitude: number;
|
|
5
|
+
longitude: number;
|
|
6
|
+
}, duration: number): void;
|
|
7
|
+
}
|
|
8
|
+
export declare class LocationSmoother {
|
|
9
|
+
private queue;
|
|
10
|
+
private isAnimating;
|
|
11
|
+
private markerRef;
|
|
12
|
+
constructor(markerRef: {
|
|
13
|
+
current: MarkerRef | null;
|
|
14
|
+
});
|
|
15
|
+
feed(location: LocationData): void;
|
|
16
|
+
private drain;
|
|
17
|
+
clear(): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=LocationSmoother.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocationSmoother.d.ts","sourceRoot":"","sources":["../../../src/LocationSmoother.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAIlE,MAAM,WAAW,SAAS;IACxB,yBAAyB,CACvB,UAAU,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EACnD,QAAQ,EAAE,MAAM,GACf,IAAI,CAAC;CACT;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAgC;gBAErC,SAAS,EAAE;QAAE,OAAO,EAAE,SAAS,GAAG,IAAI,CAAA;KAAE;IAIpD,IAAI,CAAC,QAAQ,EAAE,YAAY;YAMb,KAAK;IAenB,KAAK;CAIN"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
export type AccuracyLevel = 'high' | 'balanced' | 'low';
|
|
3
|
+
export type ConnectionState = 'connected' | 'disconnected' | 'reconnecting';
|
|
4
|
+
export interface LocationData {
|
|
5
|
+
latitude: number;
|
|
6
|
+
longitude: number;
|
|
7
|
+
altitude: number;
|
|
8
|
+
speed: number;
|
|
9
|
+
bearing: number;
|
|
10
|
+
accuracy: number;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
}
|
|
13
|
+
export interface LocationConfig {
|
|
14
|
+
desiredAccuracy: AccuracyLevel;
|
|
15
|
+
distanceFilter: number;
|
|
16
|
+
intervalMs: number;
|
|
17
|
+
fastestIntervalMs: number;
|
|
18
|
+
stopTimeout: number;
|
|
19
|
+
stopOnTerminate: boolean;
|
|
20
|
+
startOnBoot: boolean;
|
|
21
|
+
foregroundNotificationTitle: string;
|
|
22
|
+
foregroundNotificationText: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ConnectionConfig {
|
|
25
|
+
wsUrl: string;
|
|
26
|
+
restUrl: string;
|
|
27
|
+
authToken: string;
|
|
28
|
+
reconnectIntervalMs: number;
|
|
29
|
+
maxReconnectAttempts: number;
|
|
30
|
+
batchSize: number;
|
|
31
|
+
syncIntervalMs: number;
|
|
32
|
+
}
|
|
33
|
+
export type LocationCallback = (location: LocationData) => void;
|
|
34
|
+
export type ConnectionStateCallback = (state: ConnectionState) => void;
|
|
35
|
+
export type MessageCallback = (message: string) => void;
|
|
36
|
+
export interface NitroLocationTracking extends HybridObject<{
|
|
37
|
+
ios: 'swift';
|
|
38
|
+
android: 'kotlin';
|
|
39
|
+
}> {
|
|
40
|
+
configure(config: LocationConfig): void;
|
|
41
|
+
startTracking(): void;
|
|
42
|
+
stopTracking(): void;
|
|
43
|
+
getCurrentLocation(): Promise<LocationData>;
|
|
44
|
+
isTracking(): boolean;
|
|
45
|
+
onLocation(callback: LocationCallback): void;
|
|
46
|
+
onMotionChange(callback: (isMoving: boolean) => void): void;
|
|
47
|
+
configureConnection(config: ConnectionConfig): void;
|
|
48
|
+
connectWebSocket(): void;
|
|
49
|
+
disconnectWebSocket(): void;
|
|
50
|
+
sendMessage(message: string): void;
|
|
51
|
+
getConnectionState(): ConnectionState;
|
|
52
|
+
onConnectionStateChange(callback: ConnectionStateCallback): void;
|
|
53
|
+
onMessage(callback: MessageCallback): void;
|
|
54
|
+
forceSync(): Promise<boolean>;
|
|
55
|
+
showLocalNotification(title: string, body: string): void;
|
|
56
|
+
updateForegroundNotification(title: string, body: string): void;
|
|
57
|
+
destroy(): void;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=NitroLocationTracking.nitro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NitroLocationTracking.nitro.d.ts","sourceRoot":"","sources":["../../../src/NitroLocationTracking.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI/D,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;AACxD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,cAAc,GAAG,cAAc,CAAC;AAI5E,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,eAAe,EAAE,aAAa,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,2BAA2B,EAAE,MAAM,CAAC;IACpC,0BAA0B,EAAE,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAC;AAChE,MAAM,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;AACvE,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAIxD,MAAM,WAAW,qBACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IAEzD,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IACxC,aAAa,IAAI,IAAI,CAAC;IACtB,YAAY,IAAI,IAAI,CAAC;IACrB,kBAAkB,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAC5C,UAAU,IAAI,OAAO,CAAC;IAEtB,UAAU,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC7C,cAAc,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAC;IAG5D,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACpD,gBAAgB,IAAI,IAAI,CAAC;IACzB,mBAAmB,IAAI,IAAI,CAAC;IAC5B,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,kBAAkB,IAAI,eAAe,CAAC;IAEtC,uBAAuB,CAAC,QAAQ,EAAE,uBAAuB,GAAG,IAAI,CAAC;IACjE,SAAS,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IAG3C,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAG9B,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACzD,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAGhE,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function shortestRotation(from: number, to: number): number;
|
|
2
|
+
export declare function calculateBearing(from: {
|
|
3
|
+
latitude: number;
|
|
4
|
+
longitude: number;
|
|
5
|
+
}, to: {
|
|
6
|
+
latitude: number;
|
|
7
|
+
longitude: number;
|
|
8
|
+
}): number;
|
|
9
|
+
//# sourceMappingURL=bearing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bearing.d.ts","sourceRoot":"","sources":["../../../src/bearing.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAKjE;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAC7C,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC1C,MAAM,CAWR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../../src/db.ts"],"names":[],"mappings":""}
|