@iternio/react-native-auto-play 0.0.10 → 0.0.12
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/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/AndroidAutoSession.kt +59 -1
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlay.kt +19 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/MapTemplate.kt +10 -6
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/Parser.kt +3 -0
- package/ios/hybrid/HybridAutoPlay.swift +7 -0
- package/ios/hybrid/HybridMapTemplate.swift +8 -1
- package/ios/templates/MapTemplate.swift +8 -7
- package/lib/hooks/useVoiceInput.d.ts +8 -0
- package/lib/hooks/useVoiceInput.js +38 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/specs/AutoPlay.nitro.d.ts +8 -1
- package/lib/specs/VoiceInput.nitro.d.ts +8 -0
- package/lib/templates/MapTemplate.js +4 -0
- package/lib/types/Event.d.ts +4 -0
- package/lib/types/Maneuver.d.ts +5 -2
- package/lib/utils/NitroManeuver.d.ts +4 -1
- package/nitrogen/generated/android/ReactNativeAutoPlayOnLoad.cpp +2 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__optional_Location__std__optional_std__string_.hpp +78 -0
- package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.cpp +20 -0
- package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.hpp +1 -0
- package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.cpp +5 -1
- package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/JLocation.hpp +61 -0
- package/nitrogen/generated/android/c++/JNitroLoadingManeuver.hpp +57 -0
- package/nitrogen/generated/android/c++/JNitroManeuver.cpp +6 -2
- package/nitrogen/generated/android/c++/JNitroManeuver.hpp +19 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_std__optional_Location__std__optional_std__string_.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlaySpec.kt +9 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Location.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroLoadingManeuver.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroManeuver.kt +15 -2
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.cpp +8 -0
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +74 -25
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +6 -0
- package/nitrogen/generated/ios/c++/HybridAutoPlaySpecSwift.hpp +12 -1
- package/nitrogen/generated/ios/c++/HybridMapTemplateSpecSwift.hpp +4 -1
- package/nitrogen/generated/ios/swift/Func_void_std__optional_Location__std__optional_std__string_.swift +54 -0
- package/nitrogen/generated/ios/swift/HybridAutoPlaySpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridAutoPlaySpec_cxx.swift +32 -0
- package/nitrogen/generated/ios/swift/HybridMapTemplateSpec_cxx.swift +4 -1
- package/nitrogen/generated/ios/swift/Location.swift +46 -0
- package/nitrogen/generated/ios/swift/NitroLoadingManeuver.swift +35 -0
- package/nitrogen/generated/ios/swift/NitroManeuver.swift +2 -1
- package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.hpp +5 -1
- package/nitrogen/generated/shared/c++/HybridMapTemplateSpec.hpp +4 -1
- package/nitrogen/generated/shared/c++/Location.hpp +79 -0
- package/nitrogen/generated/shared/c++/NitroLoadingManeuver.hpp +75 -0
- package/package.json +1 -1
- package/src/hooks/useVoiceInput.ts +54 -0
- package/src/index.ts +1 -0
- package/src/specs/AutoPlay.nitro.ts +17 -1
- package/src/templates/MapTemplate.ts +5 -0
- package/src/types/Event.ts +4 -0
- package/src/types/Maneuver.ts +8 -1
- package/src/utils/NitroManeuver.ts +8 -1
- package/lib/specs/HybridAndroidAutoTelemetry.nitro.d.ts +0 -15
- package/lib/specs/HybridAutoPlay.nitro.d.ts +0 -64
- package/lib/specs/HybridAutoPlay.nitro.js +0 -1
- package/lib/specs/HybridCarPlayDashboard.nitro.d.ts +0 -22
- package/lib/specs/HybridCarPlayDashboard.nitro.js +0 -1
- package/lib/specs/HybridCluster.nitro.d.ts +0 -19
- package/lib/specs/HybridCluster.nitro.js +0 -1
- package/lib/specs/HybridGridTemplate.nitro.d.ts +0 -14
- package/lib/specs/HybridGridTemplate.nitro.js +0 -1
- package/lib/specs/HybridInformationTemplate.nitro.d.ts +0 -13
- package/lib/specs/HybridInformationTemplate.nitro.js +0 -1
- package/lib/specs/HybridListTemplate.nitro.d.ts +0 -13
- package/lib/specs/HybridListTemplate.nitro.js +0 -1
- package/lib/specs/HybridMapTemplate.nitro.d.ts +0 -25
- package/lib/specs/HybridMapTemplate.nitro.js +0 -1
- package/lib/specs/HybridMessageTemplate.nitro.d.ts +0 -12
- package/lib/specs/HybridMessageTemplate.nitro.js +0 -1
- package/lib/specs/HybridSearchTemplate.nitro.d.ts +0 -13
- package/lib/specs/HybridSearchTemplate.nitro.js +0 -1
- package/lib/types/GestureEvents.d.ts +0 -37
- package/lib/types/GestureEvents.js +0 -1
- /package/lib/specs/{HybridAndroidAutoTelemetry.nitro.js → VoiceInput.nitro.js} +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__optional_Location__std__optional_std__string_.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ coordinates: Location?, _ query: String?) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_std__optional_Location__std__optional_std__string_ {
|
|
16
|
+
public typealias bridge = margelo.nitro.swe.iternio.reactnativeautoplay.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ coordinates: Location?, _ query: String?) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ coordinates: Location?, _ query: String?) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(coordinates: bridge.std__optional_Location_, query: bridge.std__optional_std__string_) -> Void {
|
|
26
|
+
self.closure(coordinates.value, { () -> String? in
|
|
27
|
+
if bridge.has_value_std__optional_std__string_(query) {
|
|
28
|
+
let __unwrapped = bridge.get_std__optional_std__string_(query)
|
|
29
|
+
return String(__unwrapped)
|
|
30
|
+
} else {
|
|
31
|
+
return nil
|
|
32
|
+
}
|
|
33
|
+
}())
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
38
|
+
* This acquires one additional strong reference on the object!
|
|
39
|
+
*/
|
|
40
|
+
@inline(__always)
|
|
41
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
42
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Casts an unsafe pointer to a `Func_void_std__optional_Location__std__optional_std__string_`.
|
|
47
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__optional_Location__std__optional_std__string_>`.
|
|
48
|
+
* This removes one strong reference from the object!
|
|
49
|
+
*/
|
|
50
|
+
@inline(__always)
|
|
51
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__optional_Location__std__optional_std__string_ {
|
|
52
|
+
return Unmanaged<Func_void_std__optional_Location__std__optional_std__string_>.fromOpaque(pointer).takeRetainedValue()
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -17,6 +17,7 @@ public protocol HybridAutoPlaySpec_protocol: HybridObject {
|
|
|
17
17
|
// Methods
|
|
18
18
|
func addListener(eventType: EventName, callback: @escaping () -> Void) throws -> () -> Void
|
|
19
19
|
func addListenerRenderState(moduleName: String, callback: @escaping (_ payload: VisibilityState) -> Void) throws -> () -> Void
|
|
20
|
+
func addListenerVoiceInput(callback: @escaping (_ coordinates: Location?, _ query: String?) -> Void) throws -> () -> Void
|
|
20
21
|
func setRootTemplate(templateId: String) throws -> Promise<Void>
|
|
21
22
|
func pushTemplate(templateId: String) throws -> Promise<Void>
|
|
22
23
|
func popTemplate(animate: Bool?) throws -> Promise<Void>
|
|
@@ -158,6 +158,38 @@ open class HybridAutoPlaySpec_cxx {
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
@inline(__always)
|
|
162
|
+
public final func addListenerVoiceInput(callback: bridge.Func_void_std__optional_Location__std__optional_std__string_) -> bridge.Result_std__function_void____ {
|
|
163
|
+
do {
|
|
164
|
+
let __result = try self.__implementation.addListenerVoiceInput(callback: { () -> (Location?, String?) -> Void in
|
|
165
|
+
let __wrappedFunction = bridge.wrap_Func_void_std__optional_Location__std__optional_std__string_(callback)
|
|
166
|
+
return { (__coordinates: Location?, __query: String?) -> Void in
|
|
167
|
+
__wrappedFunction.call({ () -> bridge.std__optional_Location_ in
|
|
168
|
+
if let __unwrappedValue = __coordinates {
|
|
169
|
+
return bridge.create_std__optional_Location_(__unwrappedValue)
|
|
170
|
+
} else {
|
|
171
|
+
return .init()
|
|
172
|
+
}
|
|
173
|
+
}(), { () -> bridge.std__optional_std__string_ in
|
|
174
|
+
if let __unwrappedValue = __query {
|
|
175
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
176
|
+
} else {
|
|
177
|
+
return .init()
|
|
178
|
+
}
|
|
179
|
+
}())
|
|
180
|
+
}
|
|
181
|
+
}())
|
|
182
|
+
let __resultCpp = { () -> bridge.Func_void in
|
|
183
|
+
let __closureWrapper = Func_void(__result)
|
|
184
|
+
return bridge.create_Func_void(__closureWrapper.toUnsafe())
|
|
185
|
+
}()
|
|
186
|
+
return bridge.create_Result_std__function_void____(__resultCpp)
|
|
187
|
+
} catch (let __error) {
|
|
188
|
+
let __exceptionPtr = __error.toCpp()
|
|
189
|
+
return bridge.create_Result_std__function_void____(__exceptionPtr)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
161
193
|
@inline(__always)
|
|
162
194
|
public final func setRootTemplate(templateId: std.string) -> bridge.Result_std__shared_ptr_Promise_void___ {
|
|
163
195
|
do {
|
|
@@ -256,7 +256,7 @@ open class HybridMapTemplateSpec_cxx {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
@inline(__always)
|
|
259
|
-
public final func updateManeuvers(templateId: std.string, maneuvers: bridge.
|
|
259
|
+
public final func updateManeuvers(templateId: std.string, maneuvers: bridge.std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver__NitroLoadingManeuver_) -> bridge.Result_void_ {
|
|
260
260
|
do {
|
|
261
261
|
try self.__implementation.updateManeuvers(templateId: String(templateId), maneuvers: { () -> NitroManeuver in
|
|
262
262
|
let __variant = maneuvers
|
|
@@ -267,6 +267,9 @@ open class HybridMapTemplateSpec_cxx {
|
|
|
267
267
|
case 1:
|
|
268
268
|
let __actual = __variant.get_1()
|
|
269
269
|
return .second(__actual)
|
|
270
|
+
case 2:
|
|
271
|
+
let __actual = __variant.get_2()
|
|
272
|
+
return .third(__actual)
|
|
270
273
|
default:
|
|
271
274
|
fatalError("Variant can never have index \(__variant.index())!")
|
|
272
275
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Location.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `Location`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias Location = margelo.nitro.swe.iternio.reactnativeautoplay.Location
|
|
14
|
+
|
|
15
|
+
public extension Location {
|
|
16
|
+
private typealias bridge = margelo.nitro.swe.iternio.reactnativeautoplay.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `Location`.
|
|
20
|
+
*/
|
|
21
|
+
init(lat: Double, lon: Double) {
|
|
22
|
+
self.init(lat, lon)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var lat: Double {
|
|
26
|
+
@inline(__always)
|
|
27
|
+
get {
|
|
28
|
+
return self.__lat
|
|
29
|
+
}
|
|
30
|
+
@inline(__always)
|
|
31
|
+
set {
|
|
32
|
+
self.__lat = newValue
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var lon: Double {
|
|
37
|
+
@inline(__always)
|
|
38
|
+
get {
|
|
39
|
+
return self.__lon
|
|
40
|
+
}
|
|
41
|
+
@inline(__always)
|
|
42
|
+
set {
|
|
43
|
+
self.__lon = newValue
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroLoadingManeuver.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `NitroLoadingManeuver`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias NitroLoadingManeuver = margelo.nitro.swe.iternio.reactnativeautoplay.NitroLoadingManeuver
|
|
14
|
+
|
|
15
|
+
public extension NitroLoadingManeuver {
|
|
16
|
+
private typealias bridge = margelo.nitro.swe.iternio.reactnativeautoplay.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `NitroLoadingManeuver`.
|
|
20
|
+
*/
|
|
21
|
+
init(isLoading: Bool) {
|
|
22
|
+
self.init(isLoading)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var isLoading: Bool {
|
|
26
|
+
@inline(__always)
|
|
27
|
+
get {
|
|
28
|
+
return self.__isLoading
|
|
29
|
+
}
|
|
30
|
+
@inline(__always)
|
|
31
|
+
set {
|
|
32
|
+
self.__isLoading = newValue
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* An Swift enum with associated values representing a Variant/Union type.
|
|
12
|
-
* JS type: `array | struct`
|
|
12
|
+
* JS type: `array | struct | struct`
|
|
13
13
|
*/
|
|
14
14
|
@frozen
|
|
15
15
|
public indirect enum NitroManeuver {
|
|
16
16
|
case first([NitroRoutingManeuver])
|
|
17
17
|
case second(NitroMessageManeuver)
|
|
18
|
+
case third(NitroLoadingManeuver)
|
|
18
19
|
}
|
|
@@ -16,6 +16,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
16
16
|
registerHybrids(this, [](Prototype& prototype) {
|
|
17
17
|
prototype.registerHybridMethod("addListener", &HybridAutoPlaySpec::addListener);
|
|
18
18
|
prototype.registerHybridMethod("addListenerRenderState", &HybridAutoPlaySpec::addListenerRenderState);
|
|
19
|
+
prototype.registerHybridMethod("addListenerVoiceInput", &HybridAutoPlaySpec::addListenerVoiceInput);
|
|
19
20
|
prototype.registerHybridMethod("setRootTemplate", &HybridAutoPlaySpec::setRootTemplate);
|
|
20
21
|
prototype.registerHybridMethod("pushTemplate", &HybridAutoPlaySpec::pushTemplate);
|
|
21
22
|
prototype.registerHybridMethod("popTemplate", &HybridAutoPlaySpec::popTemplate);
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class EventName; }
|
|
18
18
|
// Forward declaration of `VisibilityState` to properly resolve imports.
|
|
19
19
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class VisibilityState; }
|
|
20
|
+
// Forward declaration of `Location` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct Location; }
|
|
20
22
|
// Forward declaration of `SafeAreaInsets` to properly resolve imports.
|
|
21
23
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct SafeAreaInsets; }
|
|
22
24
|
// Forward declaration of `NitroAction` to properly resolve imports.
|
|
@@ -26,8 +28,9 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroAction
|
|
|
26
28
|
#include "EventName.hpp"
|
|
27
29
|
#include <string>
|
|
28
30
|
#include "VisibilityState.hpp"
|
|
29
|
-
#include
|
|
31
|
+
#include "Location.hpp"
|
|
30
32
|
#include <optional>
|
|
33
|
+
#include <NitroModules/Promise.hpp>
|
|
31
34
|
#include "SafeAreaInsets.hpp"
|
|
32
35
|
#include "NitroAction.hpp"
|
|
33
36
|
#include <vector>
|
|
@@ -65,6 +68,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
65
68
|
// Methods
|
|
66
69
|
virtual std::function<void()> addListener(EventName eventType, const std::function<void()>& callback) = 0;
|
|
67
70
|
virtual std::function<void()> addListenerRenderState(const std::string& moduleName, const std::function<void(VisibilityState /* payload */)>& callback) = 0;
|
|
71
|
+
virtual std::function<void()> addListenerVoiceInput(const std::function<void(const std::optional<Location>& /* coordinates */, const std::optional<std::string>& /* query */)>& callback) = 0;
|
|
68
72
|
virtual std::shared_ptr<Promise<void>> setRootTemplate(const std::string& templateId) = 0;
|
|
69
73
|
virtual std::shared_ptr<Promise<void>> pushTemplate(const std::string& templateId) = 0;
|
|
70
74
|
virtual std::shared_ptr<Promise<void>> popTemplate(std::optional<bool> animate) = 0;
|
|
@@ -35,6 +35,8 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct TripPoint;
|
|
|
35
35
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroRoutingManeuver; }
|
|
36
36
|
// Forward declaration of `NitroMessageManeuver` to properly resolve imports.
|
|
37
37
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroMessageManeuver; }
|
|
38
|
+
// Forward declaration of `NitroLoadingManeuver` to properly resolve imports.
|
|
39
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroLoadingManeuver; }
|
|
38
40
|
// Forward declaration of `TripConfig` to properly resolve imports.
|
|
39
41
|
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct TripConfig; }
|
|
40
42
|
|
|
@@ -54,6 +56,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct TripConfig;
|
|
|
54
56
|
#include "TripPoint.hpp"
|
|
55
57
|
#include "NitroRoutingManeuver.hpp"
|
|
56
58
|
#include "NitroMessageManeuver.hpp"
|
|
59
|
+
#include "NitroLoadingManeuver.hpp"
|
|
57
60
|
#include <variant>
|
|
58
61
|
#include "TripConfig.hpp"
|
|
59
62
|
|
|
@@ -97,7 +100,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
97
100
|
virtual std::shared_ptr<Promise<void>> setTemplateMapButtons(const std::string& templateId, const std::optional<std::vector<NitroMapButton>>& buttons) = 0;
|
|
98
101
|
virtual void updateVisibleTravelEstimate(const std::string& templateId, VisibleTravelEstimate visibleTravelEstimate) = 0;
|
|
99
102
|
virtual void updateTravelEstimates(const std::string& templateId, const std::vector<TripPoint>& steps) = 0;
|
|
100
|
-
virtual void updateManeuvers(const std::string& templateId, const std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver>& maneuvers) = 0;
|
|
103
|
+
virtual void updateManeuvers(const std::string& templateId, const std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver, NitroLoadingManeuver>& maneuvers) = 0;
|
|
101
104
|
virtual void startNavigation(const std::string& templateId, const TripConfig& trip) = 0;
|
|
102
105
|
virtual void stopNavigation(const std::string& templateId) = 0;
|
|
103
106
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Location.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A struct which can be represented as a JavaScript object (Location).
|
|
34
|
+
*/
|
|
35
|
+
struct Location {
|
|
36
|
+
public:
|
|
37
|
+
double lat SWIFT_PRIVATE;
|
|
38
|
+
double lon SWIFT_PRIVATE;
|
|
39
|
+
|
|
40
|
+
public:
|
|
41
|
+
Location() = default;
|
|
42
|
+
explicit Location(double lat, double lon): lat(lat), lon(lon) {}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
46
|
+
|
|
47
|
+
namespace margelo::nitro {
|
|
48
|
+
|
|
49
|
+
// C++ Location <> JS Location (object)
|
|
50
|
+
template <>
|
|
51
|
+
struct JSIConverter<margelo::nitro::swe::iternio::reactnativeautoplay::Location> final {
|
|
52
|
+
static inline margelo::nitro::swe::iternio::reactnativeautoplay::Location fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
53
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
54
|
+
return margelo::nitro::swe::iternio::reactnativeautoplay::Location(
|
|
55
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "lat")),
|
|
56
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "lon"))
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::swe::iternio::reactnativeautoplay::Location& arg) {
|
|
60
|
+
jsi::Object obj(runtime);
|
|
61
|
+
obj.setProperty(runtime, "lat", JSIConverter<double>::toJSI(runtime, arg.lat));
|
|
62
|
+
obj.setProperty(runtime, "lon", JSIConverter<double>::toJSI(runtime, arg.lon));
|
|
63
|
+
return obj;
|
|
64
|
+
}
|
|
65
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
66
|
+
if (!value.isObject()) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
jsi::Object obj = value.getObject(runtime);
|
|
70
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "lat"))) return false;
|
|
74
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "lon"))) return false;
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroLoadingManeuver.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A struct which can be represented as a JavaScript object (NitroLoadingManeuver).
|
|
34
|
+
*/
|
|
35
|
+
struct NitroLoadingManeuver {
|
|
36
|
+
public:
|
|
37
|
+
bool isLoading SWIFT_PRIVATE;
|
|
38
|
+
|
|
39
|
+
public:
|
|
40
|
+
NitroLoadingManeuver() = default;
|
|
41
|
+
explicit NitroLoadingManeuver(bool isLoading): isLoading(isLoading) {}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
45
|
+
|
|
46
|
+
namespace margelo::nitro {
|
|
47
|
+
|
|
48
|
+
// C++ NitroLoadingManeuver <> JS NitroLoadingManeuver (object)
|
|
49
|
+
template <>
|
|
50
|
+
struct JSIConverter<margelo::nitro::swe::iternio::reactnativeautoplay::NitroLoadingManeuver> final {
|
|
51
|
+
static inline margelo::nitro::swe::iternio::reactnativeautoplay::NitroLoadingManeuver fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
52
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
53
|
+
return margelo::nitro::swe::iternio::reactnativeautoplay::NitroLoadingManeuver(
|
|
54
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isLoading"))
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::swe::iternio::reactnativeautoplay::NitroLoadingManeuver& arg) {
|
|
58
|
+
jsi::Object obj(runtime);
|
|
59
|
+
obj.setProperty(runtime, "isLoading", JSIConverter<bool>::toJSI(runtime, arg.isLoading));
|
|
60
|
+
return obj;
|
|
61
|
+
}
|
|
62
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
63
|
+
if (!value.isObject()) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
jsi::Object obj = value.getObject(runtime);
|
|
67
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isLoading"))) return false;
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace margelo::nitro
|
package/package.json
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { HybridAutoPlay, type Location } from '..';
|
|
3
|
+
|
|
4
|
+
export const useVoiceInput = () => {
|
|
5
|
+
const [isConnected, setIsConnected] = useState(false);
|
|
6
|
+
const [voiceInputResult, setVoiceInputResult] = useState<
|
|
7
|
+
| {
|
|
8
|
+
coordinates: Location | undefined;
|
|
9
|
+
query: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
| undefined
|
|
12
|
+
>();
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Resets the voice input result to undefined. This is useful when you want to clear the voice input result after processing it.
|
|
16
|
+
*/
|
|
17
|
+
const resetVoiceInputResult = useCallback(() => {
|
|
18
|
+
setVoiceInputResult(undefined);
|
|
19
|
+
}, []);
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const removeDidConnect = HybridAutoPlay.addListener('didConnect', () => setIsConnected(true));
|
|
23
|
+
const removeDidDisconnect = HybridAutoPlay.addListener('didDisconnect', () =>
|
|
24
|
+
setIsConnected(false)
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
setIsConnected(HybridAutoPlay.isConnected());
|
|
28
|
+
|
|
29
|
+
return () => {
|
|
30
|
+
removeDidConnect();
|
|
31
|
+
removeDidDisconnect();
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!isConnected) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const remove = HybridAutoPlay.addListenerVoiceInput((coordinates, query) => {
|
|
41
|
+
if (coordinates || query) {
|
|
42
|
+
setVoiceInputResult({ coordinates, query });
|
|
43
|
+
} else {
|
|
44
|
+
setVoiceInputResult(undefined);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return () => {
|
|
49
|
+
remove();
|
|
50
|
+
};
|
|
51
|
+
}, [isConnected]);
|
|
52
|
+
|
|
53
|
+
return { voiceInputResult, resetVoiceInputResult };
|
|
54
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ export * from './components/SafeAreaView';
|
|
|
27
27
|
export * from './hooks/useAndroidAutoTelemetry';
|
|
28
28
|
export * from './hooks/useMapTemplate';
|
|
29
29
|
export * from './hooks/useSafeAreaInsets';
|
|
30
|
+
export * from './hooks/useVoiceInput';
|
|
30
31
|
export * from './scenes/AutoPlayCluster';
|
|
31
32
|
export * from './scenes/CarPlayDashboardScene';
|
|
32
33
|
export * from './templates/GridTemplate';
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
2
|
import type { TemplateConfig } from '../templates/Template';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
CleanupCallback,
|
|
5
|
+
EventName,
|
|
6
|
+
Location,
|
|
7
|
+
SafeAreaInsets,
|
|
8
|
+
VisibilityState,
|
|
9
|
+
} from '../types/Event';
|
|
4
10
|
import type { NitroAction } from '../utils/NitroAction';
|
|
5
11
|
|
|
6
12
|
export interface NitroTemplateConfig extends TemplateConfig {
|
|
@@ -27,6 +33,16 @@ export interface AutoPlay extends HybridObject<{ android: 'kotlin'; ios: 'swift'
|
|
|
27
33
|
callback: (payload: VisibilityState) => void
|
|
28
34
|
): CleanupCallback;
|
|
29
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Adds a listener for voice input events. Not implemented on iOS.
|
|
38
|
+
* @param callback the callback to receive the voice input
|
|
39
|
+
* @returns callback to remove the listener
|
|
40
|
+
* @namespace Android
|
|
41
|
+
*/
|
|
42
|
+
addListenerVoiceInput(
|
|
43
|
+
callback: (coordinates: Location | undefined, query: string | undefined) => void
|
|
44
|
+
): CleanupCallback;
|
|
45
|
+
|
|
30
46
|
/**
|
|
31
47
|
* sets the specified template as root template, initializes a new stack
|
|
32
48
|
* Promise might contain an error message in case setting root template failed
|
|
@@ -320,6 +320,11 @@ export class MapTemplate extends Template<MapTemplateConfig, MapTemplateConfig['
|
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
+
if (maneuvers.type === 'loading') {
|
|
324
|
+
HybridMapTemplate.updateManeuvers(this.id, { isLoading: true });
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
|
|
323
328
|
const messageManeuver = NitroManeuverUtil.convert(maneuvers);
|
|
324
329
|
HybridMapTemplate.updateManeuvers(this.id, messageManeuver);
|
|
325
330
|
}
|
package/src/types/Event.ts
CHANGED
package/src/types/Maneuver.ts
CHANGED
|
@@ -237,4 +237,11 @@ export type MessageManeuver = {
|
|
|
237
237
|
type: 'message';
|
|
238
238
|
};
|
|
239
239
|
|
|
240
|
-
export type
|
|
240
|
+
export type LoadingManeuver = {
|
|
241
|
+
type: 'loading';
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export type AutoManeuver =
|
|
245
|
+
| (Array<RoutingManeuver> & { length: 0 | 1 | 2 })
|
|
246
|
+
| MessageManeuver
|
|
247
|
+
| LoadingManeuver;
|
|
@@ -52,7 +52,14 @@ export interface NitroMessageManeuver {
|
|
|
52
52
|
cardBackgroundColor: NitroColor;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
interface NitroLoadingManeuver {
|
|
56
|
+
isLoading: true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type NitroManeuver =
|
|
60
|
+
| Array<NitroRoutingManeuver>
|
|
61
|
+
| NitroMessageManeuver
|
|
62
|
+
| NitroLoadingManeuver;
|
|
56
63
|
|
|
57
64
|
function convertManeuverImage(image: ManeuverImage): NitroImage;
|
|
58
65
|
function convertManeuverImage(image: ManeuverImage | undefined): NitroImage | undefined;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
-
import type { CleanupCallback } from '../types/Event';
|
|
3
|
-
import type { Telemetry } from '../types/Telemetry';
|
|
4
|
-
export interface HybridAndroidAutoTelemetry extends HybridObject<{
|
|
5
|
-
android: 'kotlin';
|
|
6
|
-
}> {
|
|
7
|
-
/**
|
|
8
|
-
* Register a listener for Android Auto telemetry data. Should be registered only after the telemetry permissions are granted otherwise no data will be received.
|
|
9
|
-
* @param callback the callback to receive the telemetry data
|
|
10
|
-
* @param error the error message if the telemetry listener failed to start
|
|
11
|
-
* @returns callback to remove the listener
|
|
12
|
-
* @namespace Android
|
|
13
|
-
*/
|
|
14
|
-
registerTelemetryListener(callback: (tlm?: Telemetry, error?: string) => void): CleanupCallback;
|
|
15
|
-
}
|