@ingissa/navcore-react-native 1.0.8 → 1.0.10
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 +3 -3
- package/README.md +135 -0
- package/dist/index.d.mts +131 -0
- package/dist/index.d.ts +131 -0
- package/dist/index.js +233 -0
- package/dist/index.mjs +223 -0
- package/package.json +46 -54
- package/dist/core/src/NavCore.d.ts +0 -142
- package/dist/core/src/NavCore.d.ts.map +0 -1
- package/dist/core/src/NavCore.js +0 -390
- package/dist/core/src/bearing/BearingEngine.d.ts +0 -24
- package/dist/core/src/bearing/BearingEngine.d.ts.map +0 -1
- package/dist/core/src/bearing/BearingEngine.js +0 -50
- package/dist/core/src/constants.d.ts +0 -34
- package/dist/core/src/constants.d.ts.map +0 -1
- package/dist/core/src/constants.js +0 -41
- package/dist/core/src/corridor/DeviationDetector.d.ts +0 -33
- package/dist/core/src/corridor/DeviationDetector.d.ts.map +0 -1
- package/dist/core/src/corridor/DeviationDetector.js +0 -83
- package/dist/core/src/corridor/DynamicCorridor.d.ts +0 -13
- package/dist/core/src/corridor/DynamicCorridor.d.ts.map +0 -1
- package/dist/core/src/corridor/DynamicCorridor.js +0 -26
- package/dist/core/src/dead-reckoning/DeadReckoning.d.ts +0 -35
- package/dist/core/src/dead-reckoning/DeadReckoning.d.ts.map +0 -1
- package/dist/core/src/dead-reckoning/DeadReckoning.js +0 -49
- package/dist/core/src/directions/DirectionsProvider.d.ts +0 -70
- package/dist/core/src/directions/DirectionsProvider.d.ts.map +0 -1
- package/dist/core/src/directions/DirectionsProvider.js +0 -7
- package/dist/core/src/directions/OSRMDirectionsProvider.d.ts +0 -26
- package/dist/core/src/directions/OSRMDirectionsProvider.d.ts.map +0 -1
- package/dist/core/src/directions/OSRMDirectionsProvider.js +0 -90
- package/dist/core/src/directions/OpenRouteServiceProvider.d.ts +0 -30
- package/dist/core/src/directions/OpenRouteServiceProvider.d.ts.map +0 -1
- package/dist/core/src/directions/OpenRouteServiceProvider.js +0 -111
- package/dist/core/src/directions/ValhallaDirectionsProvider.d.ts +0 -33
- package/dist/core/src/directions/ValhallaDirectionsProvider.d.ts.map +0 -1
- package/dist/core/src/directions/ValhallaDirectionsProvider.js +0 -155
- package/dist/core/src/eta/ETAEngine.d.ts +0 -61
- package/dist/core/src/eta/ETAEngine.d.ts.map +0 -1
- package/dist/core/src/eta/ETAEngine.js +0 -74
- package/dist/core/src/features.d.ts +0 -76
- package/dist/core/src/features.d.ts.map +0 -1
- package/dist/core/src/features.js +0 -76
- package/dist/core/src/geo/bearing.d.ts +0 -11
- package/dist/core/src/geo/bearing.d.ts.map +0 -1
- package/dist/core/src/geo/bearing.js +0 -25
- package/dist/core/src/geo/cumulative.d.ts +0 -9
- package/dist/core/src/geo/cumulative.d.ts.map +0 -1
- package/dist/core/src/geo/cumulative.js +0 -20
- package/dist/core/src/geo/haversine.d.ts +0 -13
- package/dist/core/src/geo/haversine.d.ts.map +0 -1
- package/dist/core/src/geo/haversine.js +0 -39
- package/dist/core/src/geo/projection.d.ts +0 -7
- package/dist/core/src/geo/projection.d.ts.map +0 -1
- package/dist/core/src/geo/projection.js +0 -17
- package/dist/core/src/geofencing/GeofencingEngine.d.ts +0 -93
- package/dist/core/src/geofencing/GeofencingEngine.d.ts.map +0 -1
- package/dist/core/src/geofencing/GeofencingEngine.js +0 -154
- package/dist/core/src/index.d.ts +0 -66
- package/dist/core/src/index.d.ts.map +0 -1
- package/dist/core/src/index.js +0 -62
- package/dist/core/src/kalman/KalmanFilter2D.d.ts +0 -46
- package/dist/core/src/kalman/KalmanFilter2D.d.ts.map +0 -1
- package/dist/core/src/kalman/KalmanFilter2D.js +0 -77
- package/dist/core/src/license/LicenseManager.d.ts +0 -40
- package/dist/core/src/license/LicenseManager.d.ts.map +0 -1
- package/dist/core/src/license/LicenseManager.js +0 -119
- package/dist/core/src/license/verifyP256Signature.d.ts +0 -2
- package/dist/core/src/license/verifyP256Signature.d.ts.map +0 -1
- package/dist/core/src/license/verifyP256Signature.js +0 -26
- package/dist/core/src/off-route/NavigationFSM.d.ts +0 -42
- package/dist/core/src/off-route/NavigationFSM.d.ts.map +0 -1
- package/dist/core/src/off-route/NavigationFSM.js +0 -56
- package/dist/core/src/off-route/OffRouteFSM.d.ts +0 -70
- package/dist/core/src/off-route/OffRouteFSM.d.ts.map +0 -1
- package/dist/core/src/off-route/OffRouteFSM.js +0 -151
- package/dist/core/src/predictor/RouteOffsetPredictor.d.ts +0 -24
- package/dist/core/src/predictor/RouteOffsetPredictor.d.ts.map +0 -1
- package/dist/core/src/predictor/RouteOffsetPredictor.js +0 -55
- package/dist/core/src/progress/InstructionEditor.d.ts +0 -77
- package/dist/core/src/progress/InstructionEditor.d.ts.map +0 -1
- package/dist/core/src/progress/InstructionEditor.js +0 -151
- package/dist/core/src/progress/InstructionResolver.d.ts +0 -25
- package/dist/core/src/progress/InstructionResolver.d.ts.map +0 -1
- package/dist/core/src/progress/InstructionResolver.js +0 -78
- package/dist/core/src/progress/ProgressTracker.d.ts +0 -12
- package/dist/core/src/progress/ProgressTracker.d.ts.map +0 -1
- package/dist/core/src/progress/ProgressTracker.js +0 -22
- package/dist/core/src/renderer/MapRendererAdapter.d.ts +0 -72
- package/dist/core/src/renderer/MapRendererAdapter.d.ts.map +0 -1
- package/dist/core/src/renderer/MapRendererAdapter.js +0 -19
- package/dist/core/src/route-builder/CustomRouteBuilder.d.ts +0 -83
- package/dist/core/src/route-builder/CustomRouteBuilder.d.ts.map +0 -1
- package/dist/core/src/route-builder/CustomRouteBuilder.js +0 -160
- package/dist/core/src/route-plan/RoutePlan.d.ts +0 -38
- package/dist/core/src/route-plan/RoutePlan.d.ts.map +0 -1
- package/dist/core/src/route-plan/RoutePlan.js +0 -102
- package/dist/core/src/session/NavigationSession.d.ts +0 -81
- package/dist/core/src/session/NavigationSession.d.ts.map +0 -1
- package/dist/core/src/session/NavigationSession.js +0 -115
- package/dist/core/src/snapper/ParallelRoadResolver.d.ts +0 -86
- package/dist/core/src/snapper/ParallelRoadResolver.d.ts.map +0 -1
- package/dist/core/src/snapper/ParallelRoadResolver.js +0 -83
- package/dist/core/src/snapper/RouteSnapper.d.ts +0 -38
- package/dist/core/src/snapper/RouteSnapper.d.ts.map +0 -1
- package/dist/core/src/snapper/RouteSnapper.js +0 -80
- package/dist/core/src/voice/VoiceTriggerEngine.d.ts +0 -80
- package/dist/core/src/voice/VoiceTriggerEngine.d.ts.map +0 -1
- package/dist/core/src/voice/VoiceTriggerEngine.js +0 -108
- package/dist/react-native/src/NavCoreProvider.d.ts +0 -33
- package/dist/react-native/src/NavCoreProvider.d.ts.map +0 -1
- package/dist/react-native/src/NavCoreProvider.js +0 -41
- package/dist/react-native/src/index.d.ts +0 -10
- package/dist/react-native/src/index.d.ts.map +0 -1
- package/dist/react-native/src/index.js +0 -8
- package/dist/react-native/src/useNavCore.d.ts +0 -60
- package/dist/react-native/src/useNavCore.d.ts.map +0 -1
- package/dist/react-native/src/useNavCore.js +0 -119
- package/dist/react-native/src/useNavSelectors.d.ts +0 -42
- package/dist/react-native/src/useNavSelectors.d.ts.map +0 -1
- package/dist/react-native/src/useNavSelectors.js +0 -103
- package/src/NavCoreProvider.tsx +0 -59
- package/src/index.ts +0 -18
- package/src/useNavCore.ts +0 -208
- package/src/useNavSelectors.ts +0 -143
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { createContext, useRef, useState, useEffect, useMemo, useContext, useCallback, useSyncExternalStore } from 'react';
|
|
2
|
+
import { NavCore } from '@ingissa/navcore-core';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
// src/useNavCore.ts
|
|
6
|
+
function useNavCore({
|
|
7
|
+
gpsCoord,
|
|
8
|
+
gpsBearing,
|
|
9
|
+
gpsAccuracy,
|
|
10
|
+
gpsTimestamp,
|
|
11
|
+
speed,
|
|
12
|
+
routeGeometry,
|
|
13
|
+
instructions,
|
|
14
|
+
isNavigating,
|
|
15
|
+
options,
|
|
16
|
+
resumeAtIndex,
|
|
17
|
+
outputRef,
|
|
18
|
+
onDeviation,
|
|
19
|
+
onRejoin,
|
|
20
|
+
onInstruction,
|
|
21
|
+
onArrival,
|
|
22
|
+
pollRateHz = 30
|
|
23
|
+
}) {
|
|
24
|
+
const navRef = useRef(null);
|
|
25
|
+
if (!navRef.current) {
|
|
26
|
+
navRef.current = new NavCore(options);
|
|
27
|
+
}
|
|
28
|
+
const engine = navRef.current;
|
|
29
|
+
const [state, setState] = useState(() => engine.getState());
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!onDeviation) return;
|
|
32
|
+
const handler = (data) => onDeviation(data);
|
|
33
|
+
engine.on("deviation", handler);
|
|
34
|
+
return () => {
|
|
35
|
+
engine.off("deviation", handler);
|
|
36
|
+
};
|
|
37
|
+
}, [engine, onDeviation]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!onRejoin) return;
|
|
40
|
+
const handler = (data) => onRejoin(data);
|
|
41
|
+
engine.on("rejoined", handler);
|
|
42
|
+
return () => {
|
|
43
|
+
engine.off("rejoined", handler);
|
|
44
|
+
};
|
|
45
|
+
}, [engine, onRejoin]);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!onInstruction) return;
|
|
48
|
+
const handler = (data) => onInstruction(data);
|
|
49
|
+
engine.on("instruction", handler);
|
|
50
|
+
return () => {
|
|
51
|
+
engine.off("instruction", handler);
|
|
52
|
+
};
|
|
53
|
+
}, [engine, onInstruction]);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!onArrival) return;
|
|
56
|
+
const handler = () => onArrival();
|
|
57
|
+
engine.on("arrival", handler);
|
|
58
|
+
return () => {
|
|
59
|
+
engine.off("arrival", handler);
|
|
60
|
+
};
|
|
61
|
+
}, [engine, onArrival]);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (routeGeometry && routeGeometry.length >= 2) {
|
|
64
|
+
engine.setRoute(routeGeometry, instructions);
|
|
65
|
+
}
|
|
66
|
+
}, [engine, routeGeometry]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (instructions && instructions.length > 0 && routeGeometry && routeGeometry.length >= 2) {
|
|
69
|
+
engine.setRoute(routeGeometry, instructions);
|
|
70
|
+
}
|
|
71
|
+
}, [engine, instructions]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!gpsCoord || !isNavigating) return;
|
|
74
|
+
const gpsUpdate = {
|
|
75
|
+
coord: gpsCoord,
|
|
76
|
+
accuracy: gpsAccuracy ?? null,
|
|
77
|
+
bearing: gpsBearing ?? null,
|
|
78
|
+
speed,
|
|
79
|
+
timestamp: gpsTimestamp ?? Date.now()
|
|
80
|
+
};
|
|
81
|
+
const nextState = engine.update(gpsUpdate);
|
|
82
|
+
if (outputRef) {
|
|
83
|
+
outputRef.current = {
|
|
84
|
+
coord: nextState.snappedCoord ?? gpsCoord,
|
|
85
|
+
bearing: nextState.bearing,
|
|
86
|
+
speed: nextState.currentSpeed
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}, [engine, gpsCoord, gpsAccuracy, gpsBearing, gpsTimestamp, speed, isNavigating, outputRef]);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (isNavigating) {
|
|
92
|
+
engine.startNavigation();
|
|
93
|
+
}
|
|
94
|
+
}, [engine, isNavigating]);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (!isNavigating) return;
|
|
97
|
+
const handleUpdate = (updatedState) => {
|
|
98
|
+
setState(updatedState);
|
|
99
|
+
};
|
|
100
|
+
engine.on("update", handleUpdate);
|
|
101
|
+
setState(engine.getState());
|
|
102
|
+
return () => {
|
|
103
|
+
engine.off("update", handleUpdate);
|
|
104
|
+
};
|
|
105
|
+
}, [engine, isNavigating]);
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
return () => {
|
|
108
|
+
engine.destroy();
|
|
109
|
+
navRef.current = null;
|
|
110
|
+
};
|
|
111
|
+
}, [engine]);
|
|
112
|
+
return useMemo(() => ({
|
|
113
|
+
...state,
|
|
114
|
+
engine
|
|
115
|
+
}), [state, engine]);
|
|
116
|
+
}
|
|
117
|
+
var NavCoreContext = createContext(null);
|
|
118
|
+
function NavCoreProvider({ children, options }) {
|
|
119
|
+
const engineRef = useRef(null);
|
|
120
|
+
if (!engineRef.current) {
|
|
121
|
+
engineRef.current = new NavCore(options);
|
|
122
|
+
}
|
|
123
|
+
const value = useMemo(() => ({
|
|
124
|
+
engine: engineRef.current
|
|
125
|
+
}), []);
|
|
126
|
+
return /* @__PURE__ */ jsx(NavCoreContext.Provider, { value, children });
|
|
127
|
+
}
|
|
128
|
+
function useNavCoreContext() {
|
|
129
|
+
const ctx = useContext(NavCoreContext);
|
|
130
|
+
if (!ctx) {
|
|
131
|
+
throw new Error("useNavCoreContext must be used within a <NavCoreProvider>");
|
|
132
|
+
}
|
|
133
|
+
return ctx;
|
|
134
|
+
}
|
|
135
|
+
function useNavSelector(selector, customEngine, isEqual = Object.is) {
|
|
136
|
+
let contextEngine;
|
|
137
|
+
try {
|
|
138
|
+
contextEngine = useNavCoreContext().engine;
|
|
139
|
+
} catch {
|
|
140
|
+
contextEngine = void 0;
|
|
141
|
+
}
|
|
142
|
+
const engine = customEngine ?? contextEngine;
|
|
143
|
+
if (!engine) {
|
|
144
|
+
throw new Error("useNavSelector must be provided an engine or used within a NavCoreProvider");
|
|
145
|
+
}
|
|
146
|
+
const lastSelectedRef = useRef(void 0);
|
|
147
|
+
const lastStateRef = useRef(void 0);
|
|
148
|
+
const getSnapshot = useCallback(() => {
|
|
149
|
+
const currentState = engine.getState();
|
|
150
|
+
if (lastStateRef.current === currentState && lastSelectedRef.current !== void 0) {
|
|
151
|
+
return lastSelectedRef.current;
|
|
152
|
+
}
|
|
153
|
+
const nextSelected = selector(currentState);
|
|
154
|
+
if (lastSelectedRef.current !== void 0 && isEqual(lastSelectedRef.current, nextSelected)) {
|
|
155
|
+
return lastSelectedRef.current;
|
|
156
|
+
}
|
|
157
|
+
lastStateRef.current = currentState;
|
|
158
|
+
lastSelectedRef.current = nextSelected;
|
|
159
|
+
return nextSelected;
|
|
160
|
+
}, [engine, selector, isEqual]);
|
|
161
|
+
const subscribe = useCallback((onStoreChange) => {
|
|
162
|
+
engine.on("update", onStoreChange);
|
|
163
|
+
return () => {
|
|
164
|
+
engine.off("update", onStoreChange);
|
|
165
|
+
};
|
|
166
|
+
}, [engine]);
|
|
167
|
+
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
168
|
+
}
|
|
169
|
+
function useNavInstruction(customEngine) {
|
|
170
|
+
return useNavSelector(
|
|
171
|
+
(state) => {
|
|
172
|
+
if (state.nextInstructionIndex === null) return null;
|
|
173
|
+
let engine = customEngine;
|
|
174
|
+
if (!engine) {
|
|
175
|
+
try {
|
|
176
|
+
engine = useNavCoreContext().engine;
|
|
177
|
+
} catch {
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (!engine) return null;
|
|
181
|
+
const list = engine.getInstructions();
|
|
182
|
+
return list[state.nextInstructionIndex] ?? null;
|
|
183
|
+
},
|
|
184
|
+
customEngine,
|
|
185
|
+
(a, b) => a === b || a?.geometryIndex === b?.geometryIndex && a?.instruction === b?.instruction
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
function useNavAlert(customEngine) {
|
|
189
|
+
return useNavSelector(
|
|
190
|
+
(state) => state.alertState,
|
|
191
|
+
customEngine,
|
|
192
|
+
Object.is
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
function useNavProgress(customEngine) {
|
|
196
|
+
return useNavSelector(
|
|
197
|
+
(state) => ({
|
|
198
|
+
distanceToDestination: state.distanceToDestination,
|
|
199
|
+
distanceToNextInstruction: state.distanceToNextInstruction,
|
|
200
|
+
progressIndex: state.progressIndex,
|
|
201
|
+
routeIndex: state.routeIndex,
|
|
202
|
+
hasArrived: state.hasArrived
|
|
203
|
+
}),
|
|
204
|
+
customEngine,
|
|
205
|
+
(a, b) => a.distanceToDestination === b.distanceToDestination && a.distanceToNextInstruction === b.distanceToNextInstruction && a.progressIndex === b.progressIndex && a.routeIndex === b.routeIndex && a.hasArrived === b.hasArrived
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
function useNavIsOffRoute(customEngine) {
|
|
209
|
+
return useNavSelector(
|
|
210
|
+
(state) => state.isOffRoute,
|
|
211
|
+
customEngine,
|
|
212
|
+
Object.is
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
function useNavSpeed(customEngine) {
|
|
216
|
+
return useNavSelector(
|
|
217
|
+
(state) => state.currentSpeed,
|
|
218
|
+
customEngine,
|
|
219
|
+
Object.is
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export { NavCoreProvider, useNavAlert, useNavCore, useNavCoreContext, useNavInstruction, useNavIsOffRoute, useNavProgress, useNavSelector, useNavSpeed };
|
package/package.json
CHANGED
|
@@ -1,54 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@ingissa/navcore-react-native",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "React Native bindings for the NavCore navigation engine.",
|
|
5
|
-
"author": "Ingissa <8abnav@gmail.com>",
|
|
6
|
-
"license": "SEE LICENSE IN LICENSE",
|
|
7
|
-
"homepage": "https://navcore.
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
},
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
"peerDependenciesMeta": {
|
|
49
|
-
"react-native-maps": {
|
|
50
|
-
"optional": true
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
"dependencies": {}
|
|
54
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@ingissa/navcore-react-native",
|
|
3
|
+
"version": "1.0.10",
|
|
4
|
+
"description": "React Native bindings for the NavCore navigation engine.",
|
|
5
|
+
"author": "Ingissa <8abnav@gmail.com>",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
7
|
+
"homepage": "https://navcore-web.vercel.app/",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"module": "dist/index.mjs",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.mjs",
|
|
15
|
+
"require": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=16"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsup",
|
|
31
|
+
"lint": "tsc --noEmit",
|
|
32
|
+
"prepublishOnly": "npm run build --prefix ../.. && node ../../scripts/check-release.mjs"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@ingissa/navcore-core": "^1.0.10",
|
|
36
|
+
"react": ">=18.0.0",
|
|
37
|
+
"react-native": ">=0.72.0",
|
|
38
|
+
"react-native-maps": ">=1.0.0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependenciesMeta": {
|
|
41
|
+
"react-native-maps": {
|
|
42
|
+
"optional": true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {}
|
|
46
|
+
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NavCore — Main Orchestrator
|
|
3
|
-
*
|
|
4
|
-
* Fuses all extracted modules into a single engine class.
|
|
5
|
-
* Framework-agnostic; license verification does not require platform crypto APIs.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* const engine = new NavCore({ licenseKey: '...' });
|
|
9
|
-
* engine.setRoute(routeCoords, instructions);
|
|
10
|
-
* engine.update(gpsUpdate);
|
|
11
|
-
* const state = engine.getState();
|
|
12
|
-
*/
|
|
13
|
-
import type { Coordinate } from './geo/haversine';
|
|
14
|
-
import { type NavInstruction } from './progress/InstructionResolver';
|
|
15
|
-
import { NavigationFSM } from './off-route/NavigationFSM';
|
|
16
|
-
import { OffRouteFSM } from './off-route/OffRouteFSM';
|
|
17
|
-
import { LicenseManager } from './license/LicenseManager';
|
|
18
|
-
import type { RoutePlan } from './route-plan/RoutePlan';
|
|
19
|
-
export interface NavGpsUpdate {
|
|
20
|
-
coord: Coordinate;
|
|
21
|
-
accuracy: number | null;
|
|
22
|
-
bearing: number | null;
|
|
23
|
-
speed: number;
|
|
24
|
-
timestamp: number;
|
|
25
|
-
}
|
|
26
|
-
export interface NavCoreOptions {
|
|
27
|
-
licenseKey?: string;
|
|
28
|
-
isDev?: boolean;
|
|
29
|
-
isCircuit?: boolean;
|
|
30
|
-
kalmanQ?: number;
|
|
31
|
-
kalmanRBase?: number;
|
|
32
|
-
baseCorridorMeters?: number;
|
|
33
|
-
maxCorridorMeters?: number;
|
|
34
|
-
arrivalThresholdMeters?: number;
|
|
35
|
-
bearingSmoothingAlpha?: number;
|
|
36
|
-
}
|
|
37
|
-
export interface NavCoreState {
|
|
38
|
-
snappedCoord: Coordinate | null;
|
|
39
|
-
ghostCoord: Coordinate | null;
|
|
40
|
-
rawGpsCoord: Coordinate | null;
|
|
41
|
-
bearing: number;
|
|
42
|
-
rawGpsBearing: number | null;
|
|
43
|
-
routeIndex: number;
|
|
44
|
-
anchorRouteIndex: number | null;
|
|
45
|
-
distanceToRoute: number;
|
|
46
|
-
corridor: number;
|
|
47
|
-
confidence: number;
|
|
48
|
-
isOffRoute: boolean;
|
|
49
|
-
navFsmState: string;
|
|
50
|
-
progressIndex: number;
|
|
51
|
-
hasArrived: boolean;
|
|
52
|
-
rejoinCandidate: {
|
|
53
|
-
coord: Coordinate;
|
|
54
|
-
index: number;
|
|
55
|
-
} | null;
|
|
56
|
-
confidenceCone: {
|
|
57
|
-
center: Coordinate;
|
|
58
|
-
bearing: number;
|
|
59
|
-
angle: number;
|
|
60
|
-
length: number;
|
|
61
|
-
} | null;
|
|
62
|
-
alertState: 'NONE' | 'DEVIATING' | 'RECALCULATING' | 'REJOINING' | 'REJOINED';
|
|
63
|
-
detourMode: 'NONE' | 'FREE' | 'COMMITTED';
|
|
64
|
-
detourCommitProgress: number;
|
|
65
|
-
distanceToDestination: number | null;
|
|
66
|
-
distanceToNextInstruction: number | null;
|
|
67
|
-
nextInstrIdx: number | null;
|
|
68
|
-
nextInstructionIndex: number | null;
|
|
69
|
-
currentSpeed: number;
|
|
70
|
-
isGpsStale: boolean;
|
|
71
|
-
gpsAgeMs: number;
|
|
72
|
-
licenseStatus: string;
|
|
73
|
-
offRouteState: string;
|
|
74
|
-
lifecycleState: string;
|
|
75
|
-
stability?: {
|
|
76
|
-
oscillation: number;
|
|
77
|
-
drift: number;
|
|
78
|
-
jump: number;
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
type EventHandler = (...args: unknown[]) => void;
|
|
82
|
-
export declare class NavCore {
|
|
83
|
-
private kalman;
|
|
84
|
-
private snapper;
|
|
85
|
-
private deadReckoning;
|
|
86
|
-
private deviationDetector;
|
|
87
|
-
private lifecycleFSM;
|
|
88
|
-
private offRouteFSM;
|
|
89
|
-
private license;
|
|
90
|
-
private route;
|
|
91
|
-
private instructions;
|
|
92
|
-
private forwardCum;
|
|
93
|
-
private reverseCum;
|
|
94
|
-
private snappedCoord;
|
|
95
|
-
private ghostCoord;
|
|
96
|
-
private rawGpsCoord;
|
|
97
|
-
private bearing;
|
|
98
|
-
private rawGpsBearing;
|
|
99
|
-
private routeIndex;
|
|
100
|
-
private maxProgressIdx;
|
|
101
|
-
private prevSegment;
|
|
102
|
-
private distanceToRoute;
|
|
103
|
-
private corridor;
|
|
104
|
-
private prevDistToNext;
|
|
105
|
-
private currentSpeed;
|
|
106
|
-
private lastGpsTimestamp;
|
|
107
|
-
private instrIdx;
|
|
108
|
-
private linearOffset;
|
|
109
|
-
private hasArrived;
|
|
110
|
-
private readonly options;
|
|
111
|
-
private listeners;
|
|
112
|
-
constructor(options?: NavCoreOptions);
|
|
113
|
-
/**
|
|
114
|
-
* Returns true if the feature is unlocked (dev mode OR valid license).
|
|
115
|
-
* Emits a one-time console warning when a Pro feature is blocked.
|
|
116
|
-
*/
|
|
117
|
-
private has;
|
|
118
|
-
/** Load route geometry and instructions */
|
|
119
|
-
setRoute(route: ReadonlyArray<Coordinate>, instructions?: ReadonlyArray<NavInstruction>): void;
|
|
120
|
-
/** Load a provider-normalized route plan without exposing mutable route state. */
|
|
121
|
-
loadRoute(plan: RoutePlan): void;
|
|
122
|
-
/** Start navigation */
|
|
123
|
-
startNavigation(): void;
|
|
124
|
-
/** Process a GPS update — the main engine tick */
|
|
125
|
-
update(gps: NavGpsUpdate): NavCoreState;
|
|
126
|
-
/** Time-advance tick for dead reckoning (call at RAF rate) */
|
|
127
|
-
tick(nowMs: number): NavCoreState;
|
|
128
|
-
/** Get the current engine state snapshot */
|
|
129
|
-
getState(): NavCoreState;
|
|
130
|
-
/** Destroy the engine */
|
|
131
|
-
destroy(): void;
|
|
132
|
-
on(event: string, handler: EventHandler): void;
|
|
133
|
-
off(event: string, handler: EventHandler): void;
|
|
134
|
-
private emit;
|
|
135
|
-
getLicenseManager(): LicenseManager;
|
|
136
|
-
getRoute(): ReadonlyArray<Coordinate>;
|
|
137
|
-
getInstructions(): ReadonlyArray<NavInstruction>;
|
|
138
|
-
getOffRouteFSM(): OffRouteFSM;
|
|
139
|
-
getLifecycleFSM(): NavigationFSM;
|
|
140
|
-
}
|
|
141
|
-
export {};
|
|
142
|
-
//# sourceMappingURL=NavCore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NavCore.d.ts","sourceRoot":"","sources":["../../../../core/src/NavCore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAUlD,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAE7F,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAIxD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,s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