@mapzone/nav-speed-alert 1.0.0 → 1.0.1
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/CHANGELOG.md +5 -0
- package/android/build.gradle +2 -2
- package/build/NavSpeedAlert.types.d.ts +122 -0
- package/build/NavSpeedAlert.types.d.ts.map +1 -0
- package/build/NavSpeedAlert.types.js +26 -0
- package/build/NavSpeedAlert.types.js.map +1 -0
- package/build/NavSpeedAlertModule.d.ts +18 -0
- package/build/NavSpeedAlertModule.d.ts.map +1 -0
- package/build/NavSpeedAlertModule.js +3 -0
- package/build/NavSpeedAlertModule.js.map +1 -0
- package/build/index.d.ts +49 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +78 -0
- package/build/index.js.map +1 -0
- package/build/useNavSpeedAlertSigns.d.ts +11 -0
- package/build/useNavSpeedAlertSigns.d.ts.map +1 -0
- package/build/useNavSpeedAlertSigns.js +59 -0
- package/build/useNavSpeedAlertSigns.js.map +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/android/build.gradle
CHANGED
|
@@ -4,7 +4,7 @@ plugins {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
group = 'expo.modules.navspeedalert'
|
|
7
|
-
version = '1.0.
|
|
7
|
+
version = '1.0.1'
|
|
8
8
|
|
|
9
9
|
// Native Alert View SDK binary is consumed from JitPack. Hosts that lock
|
|
10
10
|
// repositories with RepositoriesMode.FAIL_ON_PROJECT_REPOS must add jitpack
|
|
@@ -17,7 +17,7 @@ android {
|
|
|
17
17
|
namespace "expo.modules.navspeedalert"
|
|
18
18
|
defaultConfig {
|
|
19
19
|
versionCode 1
|
|
20
|
-
versionName "1.0.
|
|
20
|
+
versionName "1.0.1"
|
|
21
21
|
}
|
|
22
22
|
lintOptions {
|
|
23
23
|
abortOnError false
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { SharedRef } from 'expo-modules-core';
|
|
2
|
+
/**
|
|
3
|
+
* Credentials and vehicle profile for the native engine. All fields are
|
|
4
|
+
* required; call `configure()` once before `start()`. The application id
|
|
5
|
+
* (bundle id) is resolved natively.
|
|
6
|
+
*/
|
|
7
|
+
export type ConfigureOptions = {
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
apiKeyId: string;
|
|
10
|
+
apiKey: string;
|
|
11
|
+
vehicleId: string;
|
|
12
|
+
/** Vehicle class 1..9 as defined by the alert service. */
|
|
13
|
+
vehicleType: number;
|
|
14
|
+
seats: number;
|
|
15
|
+
weights: number;
|
|
16
|
+
/** Maximum distance (m) a GPS fix may be from the route and still snap to it. */
|
|
17
|
+
maxSnapMeters: number;
|
|
18
|
+
};
|
|
19
|
+
/** One GPS sample forwarded to the engine. */
|
|
20
|
+
export type LocationFix = {
|
|
21
|
+
lat: number;
|
|
22
|
+
lng: number;
|
|
23
|
+
/** Heading in degrees, 0 = north. */
|
|
24
|
+
bearing: number;
|
|
25
|
+
speedKmh: number;
|
|
26
|
+
/** Horizontal accuracy in metres. */
|
|
27
|
+
accuracy: number;
|
|
28
|
+
/** Fix timestamp, epoch milliseconds. */
|
|
29
|
+
fixTimeMillis: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Voice alert categories that can be muted. Values MUST match
|
|
33
|
+
* `VoiceAlertType.java` / `VoiceAlertType.swift` in the native SDK.
|
|
34
|
+
*/
|
|
35
|
+
export declare enum VoiceAlertType {
|
|
36
|
+
SPEED_CAMERA = 3,
|
|
37
|
+
TOLL = 4,
|
|
38
|
+
TRAFFIC_ENFORCEMENT_CAMERA = 6,
|
|
39
|
+
RED_LIGHT_CAMERA = 7,
|
|
40
|
+
AI_CAMERA = 8,
|
|
41
|
+
NO_LEFT_TURN = 9,
|
|
42
|
+
NO_RIGHT_TURN = 10,
|
|
43
|
+
NO_UTURN = 11,
|
|
44
|
+
NO_OVERTAKING = 12,
|
|
45
|
+
NO_OVERTAKING_END = 13,
|
|
46
|
+
NO_PARKING = 14,
|
|
47
|
+
NO_STRAIGHT = 15,
|
|
48
|
+
BUILDUP_AREA_START = 16,
|
|
49
|
+
BUILDUP_AREA_END = 17,
|
|
50
|
+
REST_STATION = 18,
|
|
51
|
+
NO_STOPPING = 19,
|
|
52
|
+
ROAD_CLOSED = 20,
|
|
53
|
+
VEHICLE_RESTRICTED = 21
|
|
54
|
+
}
|
|
55
|
+
/** 0 = within limit, 1 = within 5 km/h of the limit, 2 = over the limit. */
|
|
56
|
+
export type SpeedStatus = 0 | 1 | 2;
|
|
57
|
+
/**
|
|
58
|
+
* Native reference to a rendered sign image (Bitmap on Android, UIImage on
|
|
59
|
+
* iOS). Pass it straight to `expo-image` as `source`. Call `release()` when
|
|
60
|
+
* the tick it belongs to is no longer displayed.
|
|
61
|
+
*/
|
|
62
|
+
export declare class AlertSignRef extends SharedRef<'image'> {
|
|
63
|
+
/** PNG-encoded bytes as base64 for hosts that do not use `expo-image`. */
|
|
64
|
+
toBase64(): string;
|
|
65
|
+
}
|
|
66
|
+
/** Emitted on every GPS tick after `start()`; a `null` slot means nothing to show. */
|
|
67
|
+
export type SignsEvent = {
|
|
68
|
+
current: AlertSignRef | null;
|
|
69
|
+
speedStatus: SpeedStatus;
|
|
70
|
+
next: AlertSignRef | null;
|
|
71
|
+
nextDistMeters: number;
|
|
72
|
+
camera: AlertSignRef | null;
|
|
73
|
+
cameraDistMeters: number;
|
|
74
|
+
toll: AlertSignRef | null;
|
|
75
|
+
tollDistMeters: number;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Emitted on every GPS tick while at least one `onRestriction` listener is
|
|
79
|
+
* registered. `*DistMeters === 0` means "currently on it".
|
|
80
|
+
*/
|
|
81
|
+
export type RestrictionEvent = {
|
|
82
|
+
stop: AlertSignRef | null;
|
|
83
|
+
stopDistMeters: number;
|
|
84
|
+
closed: AlertSignRef | null;
|
|
85
|
+
closedDistMeters: number;
|
|
86
|
+
vehicle: AlertSignRef | null;
|
|
87
|
+
vehicleDistMeters: number;
|
|
88
|
+
bua: AlertSignRef | null;
|
|
89
|
+
buaDistMeters: number;
|
|
90
|
+
inBua: boolean;
|
|
91
|
+
turn: AlertSignRef | null;
|
|
92
|
+
turnDistMeters: number;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Emitted instead of playing through the built-in player while at least one
|
|
96
|
+
* `onVoice` listener is registered. `wavBase64` is PCM16 mono 22050 Hz.
|
|
97
|
+
*/
|
|
98
|
+
export type VoiceEvent = {
|
|
99
|
+
wavBase64: string;
|
|
100
|
+
trigger: number;
|
|
101
|
+
/** 0 = current (lowest), 1 = normal, 2 = speeding. */
|
|
102
|
+
priority: number;
|
|
103
|
+
};
|
|
104
|
+
/** Result of fetching one route segment. `errorCode === 0` on success. */
|
|
105
|
+
export type ResultEvent = {
|
|
106
|
+
success: boolean;
|
|
107
|
+
errorCode: number;
|
|
108
|
+
errorMessage: string;
|
|
109
|
+
};
|
|
110
|
+
/** The vehicle left the route; host should request a new route from this point. */
|
|
111
|
+
export type RerouteEvent = {
|
|
112
|
+
lat: number;
|
|
113
|
+
lng: number;
|
|
114
|
+
};
|
|
115
|
+
export type NavSpeedAlertEvents = {
|
|
116
|
+
onSigns: (event: SignsEvent) => void;
|
|
117
|
+
onRestriction: (event: RestrictionEvent) => void;
|
|
118
|
+
onVoice: (event: VoiceEvent) => void;
|
|
119
|
+
onResult: (event: ResultEvent) => void;
|
|
120
|
+
onReroute: (event: RerouteEvent) => void;
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=NavSpeedAlert.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavSpeedAlert.types.d.ts","sourceRoot":"","sources":["../src/NavSpeedAlert.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,QA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C,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACjD,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,SAAS,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;CAC1C,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Voice alert categories that can be muted. Values MUST match
|
|
3
|
+
* `VoiceAlertType.java` / `VoiceAlertType.swift` in the native SDK.
|
|
4
|
+
*/
|
|
5
|
+
export var VoiceAlertType;
|
|
6
|
+
(function (VoiceAlertType) {
|
|
7
|
+
VoiceAlertType[VoiceAlertType["SPEED_CAMERA"] = 3] = "SPEED_CAMERA";
|
|
8
|
+
VoiceAlertType[VoiceAlertType["TOLL"] = 4] = "TOLL";
|
|
9
|
+
VoiceAlertType[VoiceAlertType["TRAFFIC_ENFORCEMENT_CAMERA"] = 6] = "TRAFFIC_ENFORCEMENT_CAMERA";
|
|
10
|
+
VoiceAlertType[VoiceAlertType["RED_LIGHT_CAMERA"] = 7] = "RED_LIGHT_CAMERA";
|
|
11
|
+
VoiceAlertType[VoiceAlertType["AI_CAMERA"] = 8] = "AI_CAMERA";
|
|
12
|
+
VoiceAlertType[VoiceAlertType["NO_LEFT_TURN"] = 9] = "NO_LEFT_TURN";
|
|
13
|
+
VoiceAlertType[VoiceAlertType["NO_RIGHT_TURN"] = 10] = "NO_RIGHT_TURN";
|
|
14
|
+
VoiceAlertType[VoiceAlertType["NO_UTURN"] = 11] = "NO_UTURN";
|
|
15
|
+
VoiceAlertType[VoiceAlertType["NO_OVERTAKING"] = 12] = "NO_OVERTAKING";
|
|
16
|
+
VoiceAlertType[VoiceAlertType["NO_OVERTAKING_END"] = 13] = "NO_OVERTAKING_END";
|
|
17
|
+
VoiceAlertType[VoiceAlertType["NO_PARKING"] = 14] = "NO_PARKING";
|
|
18
|
+
VoiceAlertType[VoiceAlertType["NO_STRAIGHT"] = 15] = "NO_STRAIGHT";
|
|
19
|
+
VoiceAlertType[VoiceAlertType["BUILDUP_AREA_START"] = 16] = "BUILDUP_AREA_START";
|
|
20
|
+
VoiceAlertType[VoiceAlertType["BUILDUP_AREA_END"] = 17] = "BUILDUP_AREA_END";
|
|
21
|
+
VoiceAlertType[VoiceAlertType["REST_STATION"] = 18] = "REST_STATION";
|
|
22
|
+
VoiceAlertType[VoiceAlertType["NO_STOPPING"] = 19] = "NO_STOPPING";
|
|
23
|
+
VoiceAlertType[VoiceAlertType["ROAD_CLOSED"] = 20] = "ROAD_CLOSED";
|
|
24
|
+
VoiceAlertType[VoiceAlertType["VEHICLE_RESTRICTED"] = 21] = "VEHICLE_RESTRICTED";
|
|
25
|
+
})(VoiceAlertType || (VoiceAlertType = {}));
|
|
26
|
+
//# sourceMappingURL=NavSpeedAlert.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavSpeedAlert.types.js","sourceRoot":"","sources":["../src/NavSpeedAlert.types.ts"],"names":[],"mappings":"AAiCA;;;GAGG;AACH,MAAM,CAAN,IAAY,cAmBX;AAnBD,WAAY,cAAc;IACxB,mEAAgB,CAAA;IAChB,mDAAQ,CAAA;IACR,+FAA8B,CAAA;IAC9B,2EAAoB,CAAA;IACpB,6DAAa,CAAA;IACb,mEAAgB,CAAA;IAChB,sEAAkB,CAAA;IAClB,4DAAa,CAAA;IACb,sEAAkB,CAAA;IAClB,8EAAsB,CAAA;IACtB,gEAAe,CAAA;IACf,kEAAgB,CAAA;IAChB,gFAAuB,CAAA;IACvB,4EAAqB,CAAA;IACrB,oEAAiB,CAAA;IACjB,kEAAgB,CAAA;IAChB,kEAAgB,CAAA;IAChB,gFAAuB,CAAA;AACzB,CAAC,EAnBW,cAAc,KAAd,cAAc,QAmBzB","sourcesContent":["import type { SharedRef } from 'expo-modules-core';\n\n/**\n * Credentials and vehicle profile for the native engine. All fields are\n * required; call `configure()` once before `start()`. The application id\n * (bundle id) is resolved natively.\n */\nexport type ConfigureOptions = {\n baseUrl: string;\n apiKeyId: string;\n apiKey: string;\n vehicleId: string;\n /** Vehicle class 1..9 as defined by the alert service. */\n vehicleType: number;\n seats: number;\n weights: number;\n /** Maximum distance (m) a GPS fix may be from the route and still snap to it. */\n maxSnapMeters: number;\n};\n\n/** One GPS sample forwarded to the engine. */\nexport type LocationFix = {\n lat: number;\n lng: number;\n /** Heading in degrees, 0 = north. */\n bearing: number;\n speedKmh: number;\n /** Horizontal accuracy in metres. */\n accuracy: number;\n /** Fix timestamp, epoch milliseconds. */\n fixTimeMillis: number;\n};\n\n/**\n * Voice alert categories that can be muted. Values MUST match\n * `VoiceAlertType.java` / `VoiceAlertType.swift` in the native SDK.\n */\nexport enum VoiceAlertType {\n SPEED_CAMERA = 3,\n TOLL = 4,\n TRAFFIC_ENFORCEMENT_CAMERA = 6,\n RED_LIGHT_CAMERA = 7,\n AI_CAMERA = 8,\n NO_LEFT_TURN = 9,\n NO_RIGHT_TURN = 10,\n NO_UTURN = 11,\n NO_OVERTAKING = 12,\n NO_OVERTAKING_END = 13,\n NO_PARKING = 14,\n NO_STRAIGHT = 15,\n BUILDUP_AREA_START = 16,\n BUILDUP_AREA_END = 17,\n REST_STATION = 18,\n NO_STOPPING = 19,\n ROAD_CLOSED = 20,\n VEHICLE_RESTRICTED = 21,\n}\n\n/** 0 = within limit, 1 = within 5 km/h of the limit, 2 = over the limit. */\nexport type SpeedStatus = 0 | 1 | 2;\n\n/**\n * Native reference to a rendered sign image (Bitmap on Android, UIImage on\n * iOS). Pass it straight to `expo-image` as `source`. Call `release()` when\n * the tick it belongs to is no longer displayed.\n */\nexport declare class AlertSignRef extends SharedRef<'image'> {\n /** PNG-encoded bytes as base64 for hosts that do not use `expo-image`. */\n toBase64(): string;\n}\n\n/** Emitted on every GPS tick after `start()`; a `null` slot means nothing to show. */\nexport type SignsEvent = {\n current: AlertSignRef | null;\n speedStatus: SpeedStatus;\n next: AlertSignRef | null;\n nextDistMeters: number;\n camera: AlertSignRef | null;\n cameraDistMeters: number;\n toll: AlertSignRef | null;\n tollDistMeters: number;\n};\n\n/**\n * Emitted on every GPS tick while at least one `onRestriction` listener is\n * registered. `*DistMeters === 0` means \"currently on it\".\n */\nexport type RestrictionEvent = {\n stop: AlertSignRef | null;\n stopDistMeters: number;\n closed: AlertSignRef | null;\n closedDistMeters: number;\n vehicle: AlertSignRef | null;\n vehicleDistMeters: number;\n bua: AlertSignRef | null;\n buaDistMeters: number;\n inBua: boolean;\n turn: AlertSignRef | null;\n turnDistMeters: number;\n};\n\n/**\n * Emitted instead of playing through the built-in player while at least one\n * `onVoice` listener is registered. `wavBase64` is PCM16 mono 22050 Hz.\n */\nexport type VoiceEvent = {\n wavBase64: string;\n trigger: number;\n /** 0 = current (lowest), 1 = normal, 2 = speeding. */\n priority: number;\n};\n\n/** Result of fetching one route segment. `errorCode === 0` on success. */\nexport type ResultEvent = {\n success: boolean;\n errorCode: number;\n errorMessage: string;\n};\n\n/** The vehicle left the route; host should request a new route from this point. */\nexport type RerouteEvent = {\n lat: number;\n lng: number;\n};\n\nexport type NavSpeedAlertEvents = {\n onSigns: (event: SignsEvent) => void;\n onRestriction: (event: RestrictionEvent) => void;\n onVoice: (event: VoiceEvent) => void;\n onResult: (event: ResultEvent) => void;\n onReroute: (event: RerouteEvent) => void;\n};\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NativeModule } from 'expo';
|
|
2
|
+
import type { ConfigureOptions, NavSpeedAlertEvents } from './NavSpeedAlert.types';
|
|
3
|
+
/** Raw native surface. Method order mirrors `AlertViewManager` in the native SDK. */
|
|
4
|
+
declare class NavSpeedAlertNativeModule extends NativeModule<NavSpeedAlertEvents> {
|
|
5
|
+
configure(options: ConfigureOptions): void;
|
|
6
|
+
setSegmentUrl(url: string): void;
|
|
7
|
+
setExtraHeaders(headers: Record<string, string>): string | null;
|
|
8
|
+
setExtraBodyFields(fields: Record<string, string>): string | null;
|
|
9
|
+
start(routePolyline: string): void;
|
|
10
|
+
onLocation(lat: number, lng: number, bearing: number, speedKmh: number, accuracy: number, fixTimeMillis: number): void;
|
|
11
|
+
reset(): void;
|
|
12
|
+
setMutedAlertTypes(codes: number[]): void;
|
|
13
|
+
canExportLogs(): Promise<boolean>;
|
|
14
|
+
exportLogs(path: string): Promise<number>;
|
|
15
|
+
}
|
|
16
|
+
declare const _default: NavSpeedAlertNativeModule;
|
|
17
|
+
export default _default;
|
|
18
|
+
//# sourceMappingURL=NavSpeedAlertModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavSpeedAlertModule.d.ts","sourceRoot":"","sources":["../src/NavSpeedAlertModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAEzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEnF,qFAAqF;AACrF,OAAO,OAAO,yBAA0B,SAAQ,YAAY,CAAC,mBAAmB,CAAC;IAC/E,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAC1C,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAChC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI;IAC/D,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI;IACjE,KAAK,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAClC,UAAU,CACR,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,GACpB,IAAI;IACP,KAAK,IAAI,IAAI;IACb,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IACzC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IACjC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAC1C;;AAED,wBAA+E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavSpeedAlertModule.js","sourceRoot":"","sources":["../src/NavSpeedAlertModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAyBzD,eAAe,mBAAmB,CAA4B,eAAe,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from 'expo';\n\nimport type { ConfigureOptions, NavSpeedAlertEvents } from './NavSpeedAlert.types';\n\n/** Raw native surface. Method order mirrors `AlertViewManager` in the native SDK. */\ndeclare class NavSpeedAlertNativeModule extends NativeModule<NavSpeedAlertEvents> {\n configure(options: ConfigureOptions): void;\n setSegmentUrl(url: string): void;\n setExtraHeaders(headers: Record<string, string>): string | null;\n setExtraBodyFields(fields: Record<string, string>): string | null;\n start(routePolyline: string): void;\n onLocation(\n lat: number,\n lng: number,\n bearing: number,\n speedKmh: number,\n accuracy: number,\n fixTimeMillis: number\n ): void;\n reset(): void;\n setMutedAlertTypes(codes: number[]): void;\n canExportLogs(): Promise<boolean>;\n exportLogs(path: string): Promise<number>;\n}\n\nexport default requireNativeModule<NavSpeedAlertNativeModule>('NavSpeedAlert');\n"]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { EventSubscription } from 'expo-modules-core';
|
|
2
|
+
import type { ConfigureOptions, LocationFix, RerouteEvent, RestrictionEvent, ResultEvent, SignsEvent, VoiceAlertType, VoiceEvent } from './NavSpeedAlert.types';
|
|
3
|
+
export * from './NavSpeedAlert.types';
|
|
4
|
+
export { useNavSpeedAlertSigns } from './useNavSpeedAlertSigns';
|
|
5
|
+
/** Configure credentials and vehicle profile. Must precede `start()`. */
|
|
6
|
+
export declare function configure(options: ConfigureOptions): void;
|
|
7
|
+
/** Override the segment endpoint. Empty string restores the default. */
|
|
8
|
+
export declare function setSegmentUrl(url: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Add HTTP headers to segment requests. Call after `configure()` and before
|
|
11
|
+
* `start()`. Returns `null` on success, otherwise the native error message
|
|
12
|
+
* (reserved or malformed key/value); previous headers are kept on error.
|
|
13
|
+
* Pass `{}` to clear.
|
|
14
|
+
*/
|
|
15
|
+
export declare function setExtraHeaders(headers: Record<string, string>): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Add body fields to segment requests. Same timing and return contract as
|
|
18
|
+
* `setExtraHeaders`. Pass `{}` to clear.
|
|
19
|
+
*/
|
|
20
|
+
export declare function setExtraBodyFields(fields: Record<string, string>): string | null;
|
|
21
|
+
/** Start (or restart after reroute) alerting along an encoded polyline (precision 1e6). */
|
|
22
|
+
export declare function start(routePolyline: string): void;
|
|
23
|
+
/** Feed one GPS fix. Call at ~1 Hz. */
|
|
24
|
+
export declare function onLocation(fix: LocationFix): void;
|
|
25
|
+
/** Stop alerting and drop the current route. Safe to call repeatedly. */
|
|
26
|
+
export declare function reset(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Mute voice for the given categories. Camera/toll mutes also hide their signs;
|
|
29
|
+
* restriction mutes only silence the voice. Pass `[]` to unmute everything.
|
|
30
|
+
*/
|
|
31
|
+
export declare function setMutedAlertTypes(types: VoiceAlertType[]): void;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the native build captures a diagnostic log that `exportLogs` can write.
|
|
34
|
+
* Async because it waits for the engine queue (a segment fetch may be in flight).
|
|
35
|
+
*/
|
|
36
|
+
export declare function canExportLogs(): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Write the diagnostic log to `path`. Resolves to bytes written: `0` = nothing
|
|
39
|
+
* captured, `-1` = the engine was busy or the write failed.
|
|
40
|
+
*/
|
|
41
|
+
export declare function exportLogs(path: string): Promise<number>;
|
|
42
|
+
export declare function addSignsListener(listener: (event: SignsEvent) => void): EventSubscription;
|
|
43
|
+
/** First listener registers the native restriction callback; last removal unregisters it. */
|
|
44
|
+
export declare function addRestrictionListener(listener: (event: RestrictionEvent) => void): EventSubscription;
|
|
45
|
+
/** While at least one listener exists the built-in voice player is silent. */
|
|
46
|
+
export declare function addVoiceListener(listener: (event: VoiceEvent) => void): EventSubscription;
|
|
47
|
+
export declare function addResultListener(listener: (event: ResultEvent) => void): EventSubscription;
|
|
48
|
+
export declare function addRerouteListener(listener: (event: RerouteEvent) => void): EventSubscription;
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,cAAc,EACd,UAAU,EACX,MAAM,uBAAuB,CAAC;AAG/B,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAEzD;AAED,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,CAE9E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,CAEhF;AAED,2FAA2F;AAC3F,wBAAgB,KAAK,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAEjD;AAED,uCAAuC;AACvC,wBAAgB,UAAU,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CASjD;AAED,yEAAyE;AACzE,wBAAgB,KAAK,IAAI,IAAI,CAE5B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,IAAI,CAEhE;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAEhD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAExD;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,iBAAiB,CAEzF;AAED,6FAA6F;AAC7F,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAC1C,iBAAiB,CAEnB;AAED,8EAA8E;AAC9E,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,iBAAiB,CAEzF;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,iBAAiB,CAE3F;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,iBAAiB,CAE7F"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import NavSpeedAlertModule from './NavSpeedAlertModule';
|
|
2
|
+
export * from './NavSpeedAlert.types';
|
|
3
|
+
export { useNavSpeedAlertSigns } from './useNavSpeedAlertSigns';
|
|
4
|
+
/** Configure credentials and vehicle profile. Must precede `start()`. */
|
|
5
|
+
export function configure(options) {
|
|
6
|
+
NavSpeedAlertModule.configure(options);
|
|
7
|
+
}
|
|
8
|
+
/** Override the segment endpoint. Empty string restores the default. */
|
|
9
|
+
export function setSegmentUrl(url) {
|
|
10
|
+
NavSpeedAlertModule.setSegmentUrl(url);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Add HTTP headers to segment requests. Call after `configure()` and before
|
|
14
|
+
* `start()`. Returns `null` on success, otherwise the native error message
|
|
15
|
+
* (reserved or malformed key/value); previous headers are kept on error.
|
|
16
|
+
* Pass `{}` to clear.
|
|
17
|
+
*/
|
|
18
|
+
export function setExtraHeaders(headers) {
|
|
19
|
+
return NavSpeedAlertModule.setExtraHeaders(headers);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Add body fields to segment requests. Same timing and return contract as
|
|
23
|
+
* `setExtraHeaders`. Pass `{}` to clear.
|
|
24
|
+
*/
|
|
25
|
+
export function setExtraBodyFields(fields) {
|
|
26
|
+
return NavSpeedAlertModule.setExtraBodyFields(fields);
|
|
27
|
+
}
|
|
28
|
+
/** Start (or restart after reroute) alerting along an encoded polyline (precision 1e6). */
|
|
29
|
+
export function start(routePolyline) {
|
|
30
|
+
NavSpeedAlertModule.start(routePolyline);
|
|
31
|
+
}
|
|
32
|
+
/** Feed one GPS fix. Call at ~1 Hz. */
|
|
33
|
+
export function onLocation(fix) {
|
|
34
|
+
NavSpeedAlertModule.onLocation(fix.lat, fix.lng, fix.bearing, fix.speedKmh, fix.accuracy, fix.fixTimeMillis);
|
|
35
|
+
}
|
|
36
|
+
/** Stop alerting and drop the current route. Safe to call repeatedly. */
|
|
37
|
+
export function reset() {
|
|
38
|
+
NavSpeedAlertModule.reset();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Mute voice for the given categories. Camera/toll mutes also hide their signs;
|
|
42
|
+
* restriction mutes only silence the voice. Pass `[]` to unmute everything.
|
|
43
|
+
*/
|
|
44
|
+
export function setMutedAlertTypes(types) {
|
|
45
|
+
NavSpeedAlertModule.setMutedAlertTypes(types.map((t) => t));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Whether the native build captures a diagnostic log that `exportLogs` can write.
|
|
49
|
+
* Async because it waits for the engine queue (a segment fetch may be in flight).
|
|
50
|
+
*/
|
|
51
|
+
export function canExportLogs() {
|
|
52
|
+
return NavSpeedAlertModule.canExportLogs();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Write the diagnostic log to `path`. Resolves to bytes written: `0` = nothing
|
|
56
|
+
* captured, `-1` = the engine was busy or the write failed.
|
|
57
|
+
*/
|
|
58
|
+
export function exportLogs(path) {
|
|
59
|
+
return NavSpeedAlertModule.exportLogs(path);
|
|
60
|
+
}
|
|
61
|
+
export function addSignsListener(listener) {
|
|
62
|
+
return NavSpeedAlertModule.addListener('onSigns', listener);
|
|
63
|
+
}
|
|
64
|
+
/** First listener registers the native restriction callback; last removal unregisters it. */
|
|
65
|
+
export function addRestrictionListener(listener) {
|
|
66
|
+
return NavSpeedAlertModule.addListener('onRestriction', listener);
|
|
67
|
+
}
|
|
68
|
+
/** While at least one listener exists the built-in voice player is silent. */
|
|
69
|
+
export function addVoiceListener(listener) {
|
|
70
|
+
return NavSpeedAlertModule.addListener('onVoice', listener);
|
|
71
|
+
}
|
|
72
|
+
export function addResultListener(listener) {
|
|
73
|
+
return NavSpeedAlertModule.addListener('onResult', listener);
|
|
74
|
+
}
|
|
75
|
+
export function addRerouteListener(listener) {
|
|
76
|
+
return NavSpeedAlertModule.addListener('onReroute', listener);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAYA,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,yEAAyE;AACzE,MAAM,UAAU,SAAS,CAAC,OAAyB;IACjD,mBAAmB,CAA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9C,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,QAAqC;IACpE,OAAO,mBAAmB,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,sBAAsB,CACpC,QAA2C;IAE3C,OAAO,mBAAmB,CAAC,WAAW,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;AACpE,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,gBAAgB,CAAC,QAAqC;IACpE,OAAO,mBAAmB,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAsC;IACtE,OAAO,mBAAmB,CAAC,WAAW,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAuC;IACxE,OAAO,mBAAmB,CAAC,WAAW,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import type { EventSubscription } from 'expo-modules-core';\n\nimport type {\n ConfigureOptions,\n LocationFix,\n RerouteEvent,\n RestrictionEvent,\n ResultEvent,\n SignsEvent,\n VoiceAlertType,\n VoiceEvent,\n} from './NavSpeedAlert.types';\nimport NavSpeedAlertModule from './NavSpeedAlertModule';\n\nexport * from './NavSpeedAlert.types';\nexport { useNavSpeedAlertSigns } from './useNavSpeedAlertSigns';\n\n/** Configure credentials and vehicle profile. Must precede `start()`. */\nexport function configure(options: ConfigureOptions): void {\n NavSpeedAlertModule.configure(options);\n}\n\n/** Override the segment endpoint. Empty string restores the default. */\nexport function setSegmentUrl(url: string): void {\n NavSpeedAlertModule.setSegmentUrl(url);\n}\n\n/**\n * Add HTTP headers to segment requests. Call after `configure()` and before\n * `start()`. Returns `null` on success, otherwise the native error message\n * (reserved or malformed key/value); previous headers are kept on error.\n * Pass `{}` to clear.\n */\nexport function setExtraHeaders(headers: Record<string, string>): string | null {\n return NavSpeedAlertModule.setExtraHeaders(headers);\n}\n\n/**\n * Add body fields to segment requests. Same timing and return contract as\n * `setExtraHeaders`. Pass `{}` to clear.\n */\nexport function setExtraBodyFields(fields: Record<string, string>): string | null {\n return NavSpeedAlertModule.setExtraBodyFields(fields);\n}\n\n/** Start (or restart after reroute) alerting along an encoded polyline (precision 1e6). */\nexport function start(routePolyline: string): void {\n NavSpeedAlertModule.start(routePolyline);\n}\n\n/** Feed one GPS fix. Call at ~1 Hz. */\nexport function onLocation(fix: LocationFix): void {\n NavSpeedAlertModule.onLocation(\n fix.lat,\n fix.lng,\n fix.bearing,\n fix.speedKmh,\n fix.accuracy,\n fix.fixTimeMillis\n );\n}\n\n/** Stop alerting and drop the current route. Safe to call repeatedly. */\nexport function reset(): void {\n NavSpeedAlertModule.reset();\n}\n\n/**\n * Mute voice for the given categories. Camera/toll mutes also hide their signs;\n * restriction mutes only silence the voice. Pass `[]` to unmute everything.\n */\nexport function setMutedAlertTypes(types: VoiceAlertType[]): void {\n NavSpeedAlertModule.setMutedAlertTypes(types.map((t) => t as number));\n}\n\n/**\n * Whether the native build captures a diagnostic log that `exportLogs` can write.\n * Async because it waits for the engine queue (a segment fetch may be in flight).\n */\nexport function canExportLogs(): Promise<boolean> {\n return NavSpeedAlertModule.canExportLogs();\n}\n\n/**\n * Write the diagnostic log to `path`. Resolves to bytes written: `0` = nothing\n * captured, `-1` = the engine was busy or the write failed.\n */\nexport function exportLogs(path: string): Promise<number> {\n return NavSpeedAlertModule.exportLogs(path);\n}\n\nexport function addSignsListener(listener: (event: SignsEvent) => void): EventSubscription {\n return NavSpeedAlertModule.addListener('onSigns', listener);\n}\n\n/** First listener registers the native restriction callback; last removal unregisters it. */\nexport function addRestrictionListener(\n listener: (event: RestrictionEvent) => void\n): EventSubscription {\n return NavSpeedAlertModule.addListener('onRestriction', listener);\n}\n\n/** While at least one listener exists the built-in voice player is silent. */\nexport function addVoiceListener(listener: (event: VoiceEvent) => void): EventSubscription {\n return NavSpeedAlertModule.addListener('onVoice', listener);\n}\n\nexport function addResultListener(listener: (event: ResultEvent) => void): EventSubscription {\n return NavSpeedAlertModule.addListener('onResult', listener);\n}\n\nexport function addRerouteListener(listener: (event: RerouteEvent) => void): EventSubscription {\n return NavSpeedAlertModule.addListener('onReroute', listener);\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RestrictionEvent, SignsEvent } from './NavSpeedAlert.types';
|
|
2
|
+
/**
|
|
3
|
+
* Latest `onSigns` / `onRestriction` tick. Subscribing to `onRestriction`
|
|
4
|
+
* here is what makes native start producing restriction signs; unmounting
|
|
5
|
+
* stops it again.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useNavSpeedAlertSigns(): {
|
|
8
|
+
signs: SignsEvent | null;
|
|
9
|
+
restriction: RestrictionEvent | null;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useNavSpeedAlertSigns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNavSpeedAlertSigns.d.ts","sourceRoot":"","sources":["../src/useNavSpeedAlertSigns.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AA+DxF;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI;IACvC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACtC,CAIA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import NavSpeedAlertModule from './NavSpeedAlertModule';
|
|
3
|
+
const subscribeSigns = (l) => NavSpeedAlertModule.addListener('onSigns', l);
|
|
4
|
+
const subscribeRestriction = (l) => NavSpeedAlertModule.addListener('onRestriction', l);
|
|
5
|
+
// Module-level constants keep the effect deps stable.
|
|
6
|
+
const SIGN_SLOTS = ['current', 'next', 'camera', 'toll'];
|
|
7
|
+
const RESTRICTION_SLOTS = ['stop', 'closed', 'vehicle', 'bua', 'turn'];
|
|
8
|
+
function releaseAll(event, slots) {
|
|
9
|
+
for (const slot of slots) {
|
|
10
|
+
event[slot]?.release();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Keeps one event kind in state and releases the native image refs of every
|
|
15
|
+
* delivered event once React has committed a newer one. Events that arrive
|
|
16
|
+
* between two commits (batched) never become state, so they are tracked in a
|
|
17
|
+
* ref and released together with the committed predecessor.
|
|
18
|
+
*/
|
|
19
|
+
function useLatestTick(subscribe, slots) {
|
|
20
|
+
const [current, setCurrent] = useState(null);
|
|
21
|
+
const pending = useRef([]);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const sub = subscribe((event) => {
|
|
24
|
+
pending.current.push(event);
|
|
25
|
+
setCurrent(event);
|
|
26
|
+
});
|
|
27
|
+
return () => sub.remove();
|
|
28
|
+
}, [subscribe]);
|
|
29
|
+
// Runs after each commit: everything delivered *before* the committed value
|
|
30
|
+
// is stale and is released exactly once here. Anything after it (an event
|
|
31
|
+
// that landed between the commit and this effect) is left alone — it is
|
|
32
|
+
// about to become `current` itself.
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!current)
|
|
35
|
+
return;
|
|
36
|
+
const idx = pending.current.indexOf(current);
|
|
37
|
+
if (idx <= 0)
|
|
38
|
+
return;
|
|
39
|
+
pending.current.splice(0, idx).forEach((e) => releaseAll(e, slots));
|
|
40
|
+
}, [current, slots]);
|
|
41
|
+
// Unmount only (the subscription above is already removed by then): release
|
|
42
|
+
// the committed value plus anything that arrived after the last commit.
|
|
43
|
+
useEffect(() => () => {
|
|
44
|
+
pending.current.forEach((e) => releaseAll(e, slots));
|
|
45
|
+
pending.current = [];
|
|
46
|
+
}, [slots]);
|
|
47
|
+
return current;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Latest `onSigns` / `onRestriction` tick. Subscribing to `onRestriction`
|
|
51
|
+
* here is what makes native start producing restriction signs; unmounting
|
|
52
|
+
* stops it again.
|
|
53
|
+
*/
|
|
54
|
+
export function useNavSpeedAlertSigns() {
|
|
55
|
+
const signs = useLatestTick(subscribeSigns, SIGN_SLOTS);
|
|
56
|
+
const restriction = useLatestTick(subscribeRestriction, RESTRICTION_SLOTS);
|
|
57
|
+
return { signs, restriction };
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=useNavSpeedAlertSigns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNavSpeedAlertSigns.js","sourceRoot":"","sources":["../src/useNavSpeedAlertSigns.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGpD,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AAExD,MAAM,cAAc,GAAG,CAAC,CAA0B,EAAE,EAAE,CACpD,mBAAmB,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;AAChD,MAAM,oBAAoB,GAAG,CAAC,CAAgC,EAAE,EAAE,CAChE,mBAAmB,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;AAEtD,sDAAsD;AACtD,MAAM,UAAU,GAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC/E,MAAM,iBAAiB,GAA+B,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAEnG,SAAS,UAAU,CAAI,KAAQ,EAAE,KAAkB;IACjD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACxB,KAAK,CAAC,IAAI,CAAyB,EAAE,OAAO,EAAE,CAAC;IAClD,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CACpB,SAA8D,EAC9D,KAAkB;IAElB,MAAM,CAAC,OAAO,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IG;AACH,MAAM,UAAU,qBAAqB;IAInC,MAAM,KAAK,GAAG,aAAa,CAAa,cAAc,EAAE,UAAU,CAAC,CAAC;IACpE,MAAM,WAAW,GAAG,aAAa,CAAmB,oBAAoB,EAAE,iBAAiB,CAAC,CAAC;IAC7F,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AAChC,CAAC","sourcesContent":["import type { EventSubscription } from 'expo-modules-core';\nimport { useEffect, useRef, useState } from 'react';\n\nimport type { AlertSignRef, RestrictionEvent, SignsEvent } from './NavSpeedAlert.types';\nimport NavSpeedAlertModule from './NavSpeedAlertModule';\n\nconst subscribeSigns = (l: (e: SignsEvent) => void) =>\n NavSpeedAlertModule.addListener('onSigns', l);\nconst subscribeRestriction = (l: (e: RestrictionEvent) => void) =>\n NavSpeedAlertModule.addListener('onRestriction', l);\n\n// Module-level constants keep the effect deps stable.\nconst SIGN_SLOTS: (keyof SignsEvent)[] = ['current', 'next', 'camera', 'toll'];\nconst RESTRICTION_SLOTS: (keyof RestrictionEvent)[] = ['stop', 'closed', 'vehicle', 'bua', 'turn'];\n\nfunction releaseAll<T>(event: T, slots: (keyof T)[]) {\n for (const slot of slots) {\n (event[slot] as AlertSignRef | null)?.release();\n }\n}\n\n/**\n * Keeps one event kind in state and releases the native image refs of every\n * delivered event once React has committed a newer one. Events that arrive\n * between two commits (batched) never become state, so they are tracked in a\n * ref and released together with the committed predecessor.\n */\nfunction useLatestTick<T>(\n subscribe: (listener: (event: T) => void) => EventSubscription,\n slots: (keyof T)[]\n): T | null {\n const [current, setCurrent] = useState<T | null>(null);\n const pending = useRef<T[]>([]);\n\n useEffect(() => {\n const sub = subscribe((event) => {\n pending.current.push(event);\n setCurrent(event);\n });\n return () => sub.remove();\n }, [subscribe]);\n\n // Runs after each commit: everything delivered *before* the committed value\n // is stale and is released exactly once here. Anything after it (an event\n // that landed between the commit and this effect) is left alone — it is\n // about to become `current` itself.\n useEffect(() => {\n if (!current) return;\n const idx = pending.current.indexOf(current);\n if (idx <= 0) return;\n pending.current.splice(0, idx).forEach((e) => releaseAll(e, slots));\n }, [current, slots]);\n\n // Unmount only (the subscription above is already removed by then): release\n // the committed value plus anything that arrived after the last commit.\n useEffect(\n () => () => {\n pending.current.forEach((e) => releaseAll(e, slots));\n pending.current = [];\n },\n [slots]\n );\n\n return current;\n}\n\n/**\n * Latest `onSigns` / `onRestriction` tick. Subscribing to `onRestriction`\n * here is what makes native start producing restriction signs; unmounting\n * stops it again.\n */\nexport function useNavSpeedAlertSigns(): {\n signs: SignsEvent | null;\n restriction: RestrictionEvent | null;\n} {\n const signs = useLatestTick<SignsEvent>(subscribeSigns, SIGN_SLOTS);\n const restriction = useLatestTick<RestrictionEvent>(subscribeRestriction, RESTRICTION_SLOTS);\n return { signs, restriction };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapzone/nav-speed-alert",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Warning for speed, camera, toll and restriction violations on a route in React Native navigation apps.",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Warning and alerting for speed, camera, toll and restriction violations on a route in React Native navigation apps.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"author": "Map Zone <toannn@vietmap.vn>",
|
|
48
48
|
"license": "MIT",
|
|
49
|
-
"homepage": "https://github.com/mapzone-global/mapzone-nav-speed-alert-react-native
|
|
49
|
+
"homepage": "https://github.com/mapzone-global/mapzone-nav-speed-alert-react-native",
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|