@iternio/react-native-auto-play 0.0.10 → 0.0.11

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.
Files changed (26) hide show
  1. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/MapTemplate.kt +10 -6
  2. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/Parser.kt +3 -0
  3. package/ios/hybrid/HybridMapTemplate.swift +8 -1
  4. package/ios/templates/MapTemplate.swift +8 -7
  5. package/lib/templates/MapTemplate.js +4 -0
  6. package/lib/types/Maneuver.d.ts +5 -2
  7. package/lib/utils/NitroManeuver.d.ts +4 -1
  8. package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.cpp +5 -1
  9. package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.hpp +1 -1
  10. package/nitrogen/generated/android/c++/JNitroLoadingManeuver.hpp +57 -0
  11. package/nitrogen/generated/android/c++/JNitroManeuver.cpp +6 -2
  12. package/nitrogen/generated/android/c++/JNitroManeuver.hpp +19 -2
  13. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroLoadingManeuver.kt +38 -0
  14. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroManeuver.kt +15 -2
  15. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +19 -10
  16. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +3 -0
  17. package/nitrogen/generated/ios/c++/HybridMapTemplateSpecSwift.hpp +4 -1
  18. package/nitrogen/generated/ios/swift/HybridMapTemplateSpec_cxx.swift +4 -1
  19. package/nitrogen/generated/ios/swift/NitroLoadingManeuver.swift +35 -0
  20. package/nitrogen/generated/ios/swift/NitroManeuver.swift +2 -1
  21. package/nitrogen/generated/shared/c++/HybridMapTemplateSpec.hpp +4 -1
  22. package/nitrogen/generated/shared/c++/NitroLoadingManeuver.hpp +75 -0
  23. package/package.json +1 -1
  24. package/src/templates/MapTemplate.ts +5 -0
  25. package/src/types/Maneuver.ts +8 -1
  26. package/src/utils/NitroManeuver.ts +8 -1
@@ -86,10 +86,6 @@ class MapTemplate(
86
86
  if (isNavigating) {
87
87
  navigationInfo?.let {
88
88
  setNavigationInfo(it)
89
- } ?: run {
90
- setNavigationInfo(RoutingInfo.Builder().apply {
91
- setLoading(true)
92
- }.build())
93
89
  }
94
90
  }
95
91
  config.onDidChangePanningInterface?.let {
@@ -309,13 +305,19 @@ class MapTemplate(
309
305
 
310
306
  val routingInfo = maneuvers.asFirstOrNull()
311
307
  val messageInfo = maneuvers.asSecondOrNull()
308
+ val loadingInfo = maneuvers.asThirdOrNull()
312
309
 
313
- if (routingInfo.isNullOrEmpty() && messageInfo == null) {
310
+ if (routingInfo.isNullOrEmpty() && messageInfo == null && loadingInfo == null) {
314
311
  navigationInfo = null
315
312
  AndroidAutoScreen.invalidateSurfaceScreens()
316
313
  return
317
314
  }
318
315
 
316
+ if (loadingInfo != null) {
317
+ navigationInfo = RoutingInfo.Builder().setLoading(true).build()
318
+ return
319
+ }
320
+
319
321
  if (messageInfo != null) {
320
322
  val backgroundColor =
321
323
  if (context.isDarkMode) messageInfo.cardBackgroundColor.darkColor else messageInfo.cardBackgroundColor.lightColor
@@ -359,7 +361,9 @@ class MapTemplate(
359
361
 
360
362
  val notificationText = currentStep.cue?.toString()
361
363
 
362
- val notificationTitle = "${currentDistance.displayDistance.toInt()} ${Parser.parseDistanceUnit(currentDistance.displayUnit)}"
364
+ val notificationTitle = "${currentDistance.displayDistance.toInt()} ${
365
+ Parser.parseDistanceUnit(currentDistance.displayUnit)
366
+ }"
363
367
 
364
368
  it.notify(
365
369
  notificationTitle, notificationText, notificationIcon
@@ -670,6 +670,9 @@ object Parser {
670
670
  setManeuver(parseManeuver(context, nitroManeuver))
671
671
  nitroManeuver.linkedLaneGuidance?.let { laneGuidance ->
672
672
  val lanes = laneGuidance.lanes.mapNotNull { it.asFirstOrNull() }
673
+ if (lanes.isEmpty()) {
674
+ return@let
675
+ }
673
676
  lanes.forEach { lane ->
674
677
  addLane(Lane.Builder().apply {
675
678
  addDirection(
@@ -29,7 +29,7 @@ class HybridMapTemplate: HybridMapTemplateSpec {
29
29
  "\(templateId) is not a MapTemplate"
30
30
  )
31
31
  }
32
-
32
+
33
33
  await MainActor.run {
34
34
  template.config.mapButtons = buttons
35
35
  template.invalidate()
@@ -141,6 +141,13 @@ class HybridMapTemplate: HybridMapTemplateSpec {
141
141
  {
142
142
  template.updateManeuvers(messageManeuver: messageManeuver)
143
143
  }()
144
+ case .third(let loadingManeuver):
145
+ {
146
+ template.navigationSession?.pauseTrip(
147
+ for: .loading,
148
+ description: nil
149
+ )
150
+ }()
144
151
  }
145
152
 
146
153
  }
@@ -182,9 +182,7 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
182
182
 
183
183
  template.tripEstimateStyle = isDark ? .dark : .light
184
184
 
185
- DispatchQueue.main.async {
186
- self.invalidate()
187
- }
185
+ invalidate()
188
186
  }
189
187
 
190
188
  // MARK: gestures
@@ -502,9 +500,7 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
502
500
  onTripSelected = nil
503
501
  onTripStarted = nil
504
502
 
505
- DispatchQueue.main.async {
506
- self.invalidate()
507
- }
503
+ invalidate()
508
504
  }
509
505
 
510
506
  func mapTemplate(
@@ -616,11 +612,16 @@ class MapTemplate: NSObject, AutoPlayTemplate, AutoPlayHeaderProviding,
616
612
  func updateManeuvers(maneuvers: [NitroRoutingManeuver]) {
617
613
  guard let navigationSession = navigationSession else { return }
618
614
 
615
+ if maneuvers.isEmpty {
616
+ navigationSession.upcomingManeuvers = []
617
+ return
618
+ }
619
+
619
620
  if #unavailable(iOS 15.4),
620
621
  let color = maneuvers.first?.cardBackgroundColor
621
622
  {
622
623
  // before iOS 15.4 the color had to be set on the template
623
- // later on the maneuer which Parser.parseManeuver does
624
+ // later on the maneuver which Parser.parseManeuver does
624
625
  template.guidanceBackgroundColor = Parser.parseColor(color: color)
625
626
  }
626
627
 
@@ -105,6 +105,10 @@ export class MapTemplate extends Template {
105
105
  HybridMapTemplate.updateManeuvers(this.id, nitroManeuvers);
106
106
  return;
107
107
  }
108
+ if (maneuvers.type === 'loading') {
109
+ HybridMapTemplate.updateManeuvers(this.id, { isLoading: true });
110
+ return;
111
+ }
108
112
  const messageManeuver = NitroManeuverUtil.convert(maneuvers);
109
113
  HybridMapTemplate.updateManeuvers(this.id, messageManeuver);
110
114
  }
@@ -196,7 +196,10 @@ export type MessageManeuver = {
196
196
  cardBackgroundColor: ThemedColor | string;
197
197
  type: 'message';
198
198
  };
199
+ export type LoadingManeuver = {
200
+ type: 'loading';
201
+ };
199
202
  export type AutoManeuver = (Array<RoutingManeuver> & {
200
- length: 1 | 2;
201
- }) | MessageManeuver;
203
+ length: 0 | 1 | 2;
204
+ }) | MessageManeuver | LoadingManeuver;
202
205
  export {};
@@ -33,7 +33,10 @@ export interface NitroMessageManeuver {
33
33
  image?: NitroImage;
34
34
  cardBackgroundColor: NitroColor;
35
35
  }
36
- export type NitroManeuver = Array<NitroRoutingManeuver> | NitroMessageManeuver;
36
+ interface NitroLoadingManeuver {
37
+ isLoading: true;
38
+ }
39
+ export type NitroManeuver = Array<NitroRoutingManeuver> | NitroMessageManeuver | NitroLoadingManeuver;
37
40
  declare function convert(autoManeuver: MessageManeuver): NitroMessageManeuver;
38
41
  declare function convert(autoManeuver: RoutingManeuver): NitroRoutingManeuver;
39
42
  export declare const NitroManeuverUtil: {
@@ -65,6 +65,8 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct TripPreview
65
65
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroRoutingManeuver; }
66
66
  // Forward declaration of `NitroMessageManeuver` to properly resolve imports.
67
67
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroMessageManeuver; }
68
+ // Forward declaration of `NitroLoadingManeuver` to properly resolve imports.
69
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroLoadingManeuver; }
68
70
  // Forward declaration of `NitroAttributedString` to properly resolve imports.
69
71
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroAttributedString; }
70
72
  // Forward declaration of `NitroAttributedStringImage` to properly resolve imports.
@@ -167,6 +169,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct TripConfig;
167
169
  #include "JFunc_void_std__string_std__string.hpp"
168
170
  #include "NitroRoutingManeuver.hpp"
169
171
  #include "NitroMessageManeuver.hpp"
172
+ #include "NitroLoadingManeuver.hpp"
170
173
  #include "JNitroManeuver.hpp"
171
174
  #include "JNitroRoutingManeuver.hpp"
172
175
  #include "NitroAttributedString.hpp"
@@ -195,6 +198,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct TripConfig;
195
198
  #include "ManeuverType.hpp"
196
199
  #include "JManeuverType.hpp"
197
200
  #include "JNitroMessageManeuver.hpp"
201
+ #include "JNitroLoadingManeuver.hpp"
198
202
  #include "TripConfig.hpp"
199
203
  #include "JTripConfig.hpp"
200
204
 
@@ -314,7 +318,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
314
318
  return __array;
315
319
  }());
316
320
  }
317
- void JHybridMapTemplateSpec::updateManeuvers(const std::string& templateId, const std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver>& maneuvers) {
321
+ void JHybridMapTemplateSpec::updateManeuvers(const std::string& templateId, const std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver, NitroLoadingManeuver>& maneuvers) {
318
322
  static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* templateId */, jni::alias_ref<JNitroManeuver> /* maneuvers */)>("updateManeuvers");
319
323
  method(_javaPart, jni::make_jstring(templateId), JNitroManeuver::fromCpp(maneuvers));
320
324
  }
@@ -63,7 +63,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
63
63
  std::shared_ptr<Promise<void>> setTemplateMapButtons(const std::string& templateId, const std::optional<std::vector<NitroMapButton>>& buttons) override;
64
64
  void updateVisibleTravelEstimate(const std::string& templateId, VisibleTravelEstimate visibleTravelEstimate) override;
65
65
  void updateTravelEstimates(const std::string& templateId, const std::vector<TripPoint>& steps) override;
66
- void updateManeuvers(const std::string& templateId, const std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver>& maneuvers) override;
66
+ void updateManeuvers(const std::string& templateId, const std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver, NitroLoadingManeuver>& maneuvers) override;
67
67
  void startNavigation(const std::string& templateId, const TripConfig& trip) override;
68
68
  void stopNavigation(const std::string& templateId) override;
69
69
 
@@ -0,0 +1,57 @@
1
+ ///
2
+ /// JNitroLoadingManeuver.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
+ #include <fbjni/fbjni.h>
11
+ #include "NitroLoadingManeuver.hpp"
12
+
13
+
14
+
15
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * The C++ JNI bridge between the C++ struct "NitroLoadingManeuver" and the the Kotlin data class "NitroLoadingManeuver".
21
+ */
22
+ struct JNitroLoadingManeuver final: public jni::JavaClass<JNitroLoadingManeuver> {
23
+ public:
24
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/swe/iternio/reactnativeautoplay/NitroLoadingManeuver;";
25
+
26
+ public:
27
+ /**
28
+ * Convert this Java/Kotlin-based struct to the C++ struct NitroLoadingManeuver by copying all values to C++.
29
+ */
30
+ [[maybe_unused]]
31
+ [[nodiscard]]
32
+ NitroLoadingManeuver toCpp() const {
33
+ static const auto clazz = javaClassStatic();
34
+ static const auto fieldIsLoading = clazz->getField<jboolean>("isLoading");
35
+ jboolean isLoading = this->getFieldValue(fieldIsLoading);
36
+ return NitroLoadingManeuver(
37
+ static_cast<bool>(isLoading)
38
+ );
39
+ }
40
+
41
+ public:
42
+ /**
43
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
44
+ */
45
+ [[maybe_unused]]
46
+ static jni::local_ref<JNitroLoadingManeuver::javaobject> fromCpp(const NitroLoadingManeuver& value) {
47
+ using JSignature = JNitroLoadingManeuver(jboolean);
48
+ static const auto clazz = javaClassStatic();
49
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
50
+ return create(
51
+ clazz,
52
+ value.isLoading
53
+ );
54
+ }
55
+ };
56
+
57
+ } // namespace margelo::nitro::swe::iternio::reactnativeautoplay
@@ -9,9 +9,9 @@
9
9
 
10
10
  namespace margelo::nitro::swe::iternio::reactnativeautoplay {
11
11
  /**
12
- * Converts JNitroManeuver to std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver>
12
+ * Converts JNitroManeuver to std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver, NitroLoadingManeuver>
13
13
  */
14
- std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver> JNitroManeuver::toCpp() const {
14
+ std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver, NitroLoadingManeuver> JNitroManeuver::toCpp() const {
15
15
  if (isInstanceOf(JNitroManeuver_impl::First::javaClassStatic())) {
16
16
  // It's a `std::vector<NitroRoutingManeuver>`
17
17
  auto jniValue = static_cast<const JNitroManeuver_impl::First*>(this)->getValue();
@@ -29,6 +29,10 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
29
29
  // It's a `NitroMessageManeuver`
30
30
  auto jniValue = static_cast<const JNitroManeuver_impl::Second*>(this)->getValue();
31
31
  return jniValue->toCpp();
32
+ } else if (isInstanceOf(JNitroManeuver_impl::Third::javaClassStatic())) {
33
+ // It's a `NitroLoadingManeuver`
34
+ auto jniValue = static_cast<const JNitroManeuver_impl::Third*>(this)->getValue();
35
+ return jniValue->toCpp();
32
36
  }
33
37
  throw std::invalid_argument("Variant is unknown Kotlin instance!");
34
38
  }
@@ -13,6 +13,7 @@
13
13
  #include "NitroRoutingManeuver.hpp"
14
14
  #include <vector>
15
15
  #include "NitroMessageManeuver.hpp"
16
+ #include "NitroLoadingManeuver.hpp"
16
17
  #include <variant>
17
18
  #include "JNitroRoutingManeuver.hpp"
18
19
  #include "NitroAttributedString.hpp"
@@ -61,6 +62,7 @@
61
62
  #include "ManeuverType.hpp"
62
63
  #include "JManeuverType.hpp"
63
64
  #include "JNitroMessageManeuver.hpp"
65
+ #include "JNitroLoadingManeuver.hpp"
64
66
 
65
67
  namespace margelo::nitro::swe::iternio::reactnativeautoplay {
66
68
 
@@ -81,8 +83,12 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
81
83
  static const auto method = javaClassStatic()->getStaticMethod<JNitroManeuver(jni::alias_ref<JNitroMessageManeuver>)>("create");
82
84
  return method(javaClassStatic(), value);
83
85
  }
86
+ static jni::local_ref<JNitroManeuver> create_2(jni::alias_ref<JNitroLoadingManeuver> value) {
87
+ static const auto method = javaClassStatic()->getStaticMethod<JNitroManeuver(jni::alias_ref<JNitroLoadingManeuver>)>("create");
88
+ return method(javaClassStatic(), value);
89
+ }
84
90
 
85
- static jni::local_ref<JNitroManeuver> fromCpp(const std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver>& variant) {
91
+ static jni::local_ref<JNitroManeuver> fromCpp(const std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver, NitroLoadingManeuver>& variant) {
86
92
  switch (variant.index()) {
87
93
  case 0: return create_0([&]() {
88
94
  size_t __size = std::get<0>(variant).size();
@@ -95,11 +101,12 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
95
101
  return __array;
96
102
  }());
97
103
  case 1: return create_1(JNitroMessageManeuver::fromCpp(std::get<1>(variant)));
104
+ case 2: return create_2(JNitroLoadingManeuver::fromCpp(std::get<2>(variant)));
98
105
  default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")");
99
106
  }
100
107
  }
101
108
 
102
- [[nodiscard]] std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver> toCpp() const;
109
+ [[nodiscard]] std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver, NitroLoadingManeuver> toCpp() const;
103
110
  };
104
111
 
105
112
  namespace JNitroManeuver_impl {
@@ -122,5 +129,15 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
122
129
  return getFieldValue(field);
123
130
  }
124
131
  };
132
+
133
+ class Third: public jni::JavaClass<Third, JNitroManeuver> {
134
+ public:
135
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/swe/iternio/reactnativeautoplay/NitroManeuver$Third;";
136
+
137
+ [[nodiscard]] jni::local_ref<JNitroLoadingManeuver> getValue() const {
138
+ static const auto field = javaClassStatic()->getField<JNitroLoadingManeuver>("value");
139
+ return getFieldValue(field);
140
+ }
141
+ };
125
142
  } // namespace JNitroManeuver_impl
126
143
  } // namespace margelo::nitro::swe::iternio::reactnativeautoplay
@@ -0,0 +1,38 @@
1
+ ///
2
+ /// NitroLoadingManeuver.kt
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
+ package com.margelo.nitro.swe.iternio.reactnativeautoplay
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+
14
+ /**
15
+ * Represents the JavaScript object/struct "NitroLoadingManeuver".
16
+ */
17
+ @DoNotStrip
18
+ @Keep
19
+ data class NitroLoadingManeuver(
20
+ @DoNotStrip
21
+ @Keep
22
+ val isLoading: Boolean
23
+ ) {
24
+ /* primary constructor */
25
+
26
+ private companion object {
27
+ /**
28
+ * Constructor called from C++
29
+ */
30
+ @DoNotStrip
31
+ @Keep
32
+ @Suppress("unused")
33
+ @JvmStatic
34
+ private fun fromCpp(isLoading: Boolean): NitroLoadingManeuver {
35
+ return NitroLoadingManeuver(isLoading)
36
+ }
37
+ }
38
+ }
@@ -11,7 +11,7 @@ import com.facebook.proguard.annotations.DoNotStrip
11
11
 
12
12
 
13
13
  /**
14
- * Represents the TypeScript variant "Array<NitroRoutingManeuver> | NitroMessageManeuver".
14
+ * Represents the TypeScript variant "Array<NitroRoutingManeuver> | NitroMessageManeuver | NitroLoadingManeuver".
15
15
  */
16
16
  @Suppress("ClassName")
17
17
  @DoNotStrip
@@ -20,17 +20,22 @@ sealed class NitroManeuver {
20
20
  data class First(@DoNotStrip val value: Array<NitroRoutingManeuver>): NitroManeuver()
21
21
  @DoNotStrip
22
22
  data class Second(@DoNotStrip val value: NitroMessageManeuver): NitroManeuver()
23
+ @DoNotStrip
24
+ data class Third(@DoNotStrip val value: NitroLoadingManeuver): NitroManeuver()
23
25
 
24
26
  @Deprecated("getAs() is not type-safe. Use fold/asFirstOrNull/asSecondOrNull instead.", level = DeprecationLevel.ERROR)
25
27
  inline fun <reified T> getAs(): T? = when (this) {
26
28
  is First -> value as? T
27
29
  is Second -> value as? T
30
+ is Third -> value as? T
28
31
  }
29
32
 
30
33
  val isFirst: Boolean
31
34
  get() = this is First
32
35
  val isSecond: Boolean
33
36
  get() = this is Second
37
+ val isThird: Boolean
38
+ get() = this is Third
34
39
 
35
40
  fun asFirstOrNull(): Array<NitroRoutingManeuver>? {
36
41
  val value = (this as? First)?.value ?: return null
@@ -40,11 +45,16 @@ sealed class NitroManeuver {
40
45
  val value = (this as? Second)?.value ?: return null
41
46
  return value
42
47
  }
48
+ fun asThirdOrNull(): NitroLoadingManeuver? {
49
+ val value = (this as? Third)?.value ?: return null
50
+ return value
51
+ }
43
52
 
44
- inline fun <R> match(first: (Array<NitroRoutingManeuver>) -> R, second: (NitroMessageManeuver) -> R): R {
53
+ inline fun <R> match(first: (Array<NitroRoutingManeuver>) -> R, second: (NitroMessageManeuver) -> R, third: (NitroLoadingManeuver) -> R): R {
45
54
  return when (this) {
46
55
  is First -> first(value)
47
56
  is Second -> second(value)
57
+ is Third -> third(value)
48
58
  }
49
59
  }
50
60
 
@@ -55,5 +65,8 @@ sealed class NitroManeuver {
55
65
  @JvmStatic
56
66
  @DoNotStrip
57
67
  fun create(value: NitroMessageManeuver): NitroManeuver = Second(value)
68
+ @JvmStatic
69
+ @DoNotStrip
70
+ fun create(value: NitroLoadingManeuver): NitroManeuver = Third(value)
58
71
  }
59
72
  }
@@ -76,6 +76,8 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroCarPla
76
76
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroColor; }
77
77
  // Forward declaration of `NitroGridButton` to properly resolve imports.
78
78
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroGridButton; }
79
+ // Forward declaration of `NitroLoadingManeuver` to properly resolve imports.
80
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroLoadingManeuver; }
79
81
  // Forward declaration of `NitroMapButtonType` to properly resolve imports.
80
82
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class NitroMapButtonType; }
81
83
  // Forward declaration of `NitroMapButton` to properly resolve imports.
@@ -176,6 +178,7 @@ namespace ReactNativeAutoPlay { class HybridSearchTemplateSpec_cxx; }
176
178
  #include "NitroCarPlayDashboardButton.hpp"
177
179
  #include "NitroColor.hpp"
178
180
  #include "NitroGridButton.hpp"
181
+ #include "NitroLoadingManeuver.hpp"
179
182
  #include "NitroMapButton.hpp"
180
183
  #include "NitroMapButtonType.hpp"
181
184
  #include "NitroMessageManeuver.hpp"
@@ -1435,16 +1438,16 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay::bridge::swift {
1435
1438
  return vector;
1436
1439
  }
1437
1440
 
1438
- // pragma MARK: std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver>
1441
+ // pragma MARK: std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver, NitroLoadingManeuver>
1439
1442
  /**
1440
- * Wrapper struct for `std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver>`.
1443
+ * Wrapper struct for `std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver, NitroLoadingManeuver>`.
1441
1444
  * std::variant cannot be used in Swift because of a Swift bug.
1442
1445
  * Not even specializing it works. So we create a wrapper struct.
1443
1446
  */
1444
- struct std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver_ {
1445
- std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver> variant;
1446
- std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver_(std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver> variant): variant(variant) { }
1447
- operator std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver>() const noexcept {
1447
+ struct std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver__NitroLoadingManeuver_ {
1448
+ std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver, NitroLoadingManeuver> variant;
1449
+ std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver__NitroLoadingManeuver_(std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver, NitroLoadingManeuver> variant): variant(variant) { }
1450
+ operator std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver, NitroLoadingManeuver>() const noexcept {
1448
1451
  return variant;
1449
1452
  }
1450
1453
  inline size_t index() const noexcept {
@@ -1456,12 +1459,18 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay::bridge::swift {
1456
1459
  inline NitroMessageManeuver get_1() const noexcept {
1457
1460
  return std::get<1>(variant);
1458
1461
  }
1462
+ inline NitroLoadingManeuver get_2() const noexcept {
1463
+ return std::get<2>(variant);
1464
+ }
1459
1465
  };
1460
- inline std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver_ create_std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver_(const std::vector<NitroRoutingManeuver>& value) noexcept {
1461
- return std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver_(value);
1466
+ inline std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver__NitroLoadingManeuver_ create_std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver__NitroLoadingManeuver_(const std::vector<NitroRoutingManeuver>& value) noexcept {
1467
+ return std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver__NitroLoadingManeuver_(value);
1468
+ }
1469
+ inline std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver__NitroLoadingManeuver_ create_std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver__NitroLoadingManeuver_(const NitroMessageManeuver& value) noexcept {
1470
+ return std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver__NitroLoadingManeuver_(value);
1462
1471
  }
1463
- inline std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver_ create_std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver_(const NitroMessageManeuver& value) noexcept {
1464
- return std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver_(value);
1472
+ inline std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver__NitroLoadingManeuver_ create_std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver__NitroLoadingManeuver_(const NitroLoadingManeuver& value) noexcept {
1473
+ return std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver__NitroLoadingManeuver_(value);
1465
1474
  }
1466
1475
 
1467
1476
  // pragma MARK: std::shared_ptr<HybridMapTemplateSpec>
@@ -90,6 +90,8 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroCarPla
90
90
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroColor; }
91
91
  // Forward declaration of `NitroGridButton` to properly resolve imports.
92
92
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroGridButton; }
93
+ // Forward declaration of `NitroLoadingManeuver` to properly resolve imports.
94
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroLoadingManeuver; }
93
95
  // Forward declaration of `NitroMapButtonType` to properly resolve imports.
94
96
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class NitroMapButtonType; }
95
97
  // Forward declaration of `NitroMapButton` to properly resolve imports.
@@ -185,6 +187,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class ZoomEve
185
187
  #include "NitroCarPlayDashboardButton.hpp"
186
188
  #include "NitroColor.hpp"
187
189
  #include "NitroGridButton.hpp"
190
+ #include "NitroLoadingManeuver.hpp"
188
191
  #include "NitroMapButton.hpp"
189
192
  #include "NitroMapButtonType.hpp"
190
193
  #include "NitroMessageManeuver.hpp"
@@ -70,6 +70,8 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct TripPreview
70
70
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroRoutingManeuver; }
71
71
  // Forward declaration of `NitroMessageManeuver` to properly resolve imports.
72
72
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroMessageManeuver; }
73
+ // Forward declaration of `NitroLoadingManeuver` to properly resolve imports.
74
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroLoadingManeuver; }
73
75
  // Forward declaration of `NitroAttributedString` to properly resolve imports.
74
76
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroAttributedString; }
75
77
  // Forward declaration of `NitroAttributedStringImage` to properly resolve imports.
@@ -132,6 +134,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct TripConfig;
132
134
  #include <NitroModules/Promise.hpp>
133
135
  #include "NitroRoutingManeuver.hpp"
134
136
  #include "NitroMessageManeuver.hpp"
137
+ #include "NitroLoadingManeuver.hpp"
135
138
  #include "NitroAttributedString.hpp"
136
139
  #include "NitroAttributedStringImage.hpp"
137
140
  #include "TurnType.hpp"
@@ -248,7 +251,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
248
251
  std::rethrow_exception(__result.error());
249
252
  }
250
253
  }
251
- inline void updateManeuvers(const std::string& templateId, const std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver>& maneuvers) override {
254
+ inline void updateManeuvers(const std::string& templateId, const std::variant<std::vector<NitroRoutingManeuver>, NitroMessageManeuver, NitroLoadingManeuver>& maneuvers) override {
252
255
  auto __result = _swiftPart.updateManeuvers(templateId, maneuvers);
253
256
  if (__result.hasError()) [[unlikely]] {
254
257
  std::rethrow_exception(__result.error());
@@ -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.std__variant_std__vector_NitroRoutingManeuver___NitroMessageManeuver_) -> bridge.Result_void_ {
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,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
  }
@@ -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,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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iternio/react-native-auto-play",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "Android Auto and Apple CarPlay for react-native",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",
@@ -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
  }
@@ -237,4 +237,11 @@ export type MessageManeuver = {
237
237
  type: 'message';
238
238
  };
239
239
 
240
- export type AutoManeuver = (Array<RoutingManeuver> & { length: 1 | 2 }) | MessageManeuver;
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
- export type NitroManeuver = Array<NitroRoutingManeuver> | NitroMessageManeuver;
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;