@iternio/react-native-auto-play 0.2.0-alpha.3 → 0.2.0-alpha.4

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 (69) hide show
  1. package/android/build.gradle +2 -2
  2. package/android/src/automotive/AndroidManifest.xml +2 -0
  3. package/android/src/automotive/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/AndroidTelemetryObserver.kt +5 -2
  4. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/SignInWithGoogleActivity.kt +63 -0
  5. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/SignInTemplate.kt +52 -0
  6. package/lib/hooks/useAndroidAutoTelemetry.d.ts +4 -13
  7. package/lib/hooks/useAndroidAutoTelemetry.js +3 -6
  8. package/lib/index.d.ts +0 -4
  9. package/lib/index.js +0 -4
  10. package/lib/types/SignInMethod.d.ts +17 -2
  11. package/lib/types/SignInMethod.js +1 -1
  12. package/nitro.json +0 -3
  13. package/nitrogen/generated/android/ReactNativeAutoPlay+autolinking.cmake +1 -3
  14. package/nitrogen/generated/android/ReactNativeAutoPlayOnLoad.cpp +4 -16
  15. package/nitrogen/generated/android/c++/JFunc_void_std__optional_std__string__std__optional_GoogleSignInAccount_.hpp +79 -0
  16. package/nitrogen/generated/android/c++/JGoogleSignIn.hpp +81 -0
  17. package/nitrogen/generated/android/c++/JGoogleSignInAccount.hpp +86 -0
  18. package/nitrogen/generated/android/c++/JHybridSignInTemplateSpec.cpp +10 -1
  19. package/nitrogen/generated/android/c++/JSignInMethods.hpp +3 -3
  20. package/nitrogen/generated/android/c++/JSignInTemplateConfig.hpp +10 -5
  21. package/nitrogen/generated/android/c++/JVariant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn.cpp +34 -0
  22. package/nitrogen/generated/android/c++/{JVariant_QrSignIn_PinSignIn_InputSignIn.hpp → JVariant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn.hpp} +40 -20
  23. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/{Func_void_AppFocusState.kt → Func_void_std__optional_std__string__std__optional_GoogleSignInAccount_.kt} +14 -14
  24. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GoogleSignIn.kt +48 -0
  25. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GoogleSignInAccount.kt +59 -0
  26. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/SignInMethods.kt +1 -1
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/SignInTemplateConfig.kt +3 -3
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/{Variant_QrSignIn_PinSignIn_InputSignIn.kt → Variant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn.kt} +23 -10
  29. package/nitrogen/generated/shared/c++/GoogleSignIn.hpp +98 -0
  30. package/nitrogen/generated/shared/c++/GoogleSignInAccount.hpp +112 -0
  31. package/nitrogen/generated/shared/c++/SignInMethods.hpp +1 -1
  32. package/nitrogen/generated/shared/c++/SignInTemplateConfig.hpp +8 -5
  33. package/package.json +1 -1
  34. package/src/hooks/useAndroidAutoTelemetry.ts +32 -48
  35. package/src/index.ts +0 -11
  36. package/src/types/SignInMethod.ts +19 -2
  37. package/android/src/auto/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAndroidAutomotive.kt +0 -25
  38. package/android/src/automotive/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAndroidAutomotive.kt +0 -190
  39. package/lib/hooks/useIsAutoPlayFocused.d.ts +0 -7
  40. package/lib/hooks/useIsAutoPlayFocused.js +0 -20
  41. package/lib/hybrid.d.ts +0 -2
  42. package/lib/hybrid.js +0 -2
  43. package/lib/specs/AndroidAutomotive.nitro.d.ts +0 -33
  44. package/lib/specs/AndroidAutomotive.nitro.js +0 -13
  45. package/lib/specs/AutomotivePermissionRequestTemplate.d.ts +0 -11
  46. package/lib/specs/AutomotivePermissionRequestTemplate.js +0 -1
  47. package/lib/specs/AutomotivePermissionRequestTemplate.nitro.d.ts +0 -11
  48. package/lib/specs/AutomotivePermissionRequestTemplate.nitro.js +0 -1
  49. package/lib/templates/AutomotivePermissionRequestTemplate.d.ts +0 -23
  50. package/lib/templates/AutomotivePermissionRequestTemplate.js +0 -18
  51. package/nitrogen/generated/android/c++/JActiveCarUxRestrictions.hpp +0 -89
  52. package/nitrogen/generated/android/c++/JAppFocusState.hpp +0 -61
  53. package/nitrogen/generated/android/c++/JCarUxRestrictions.hpp +0 -82
  54. package/nitrogen/generated/android/c++/JFunc_void_ActiveCarUxRestrictions.hpp +0 -80
  55. package/nitrogen/generated/android/c++/JFunc_void_AppFocusState.hpp +0 -78
  56. package/nitrogen/generated/android/c++/JHybridAndroidAutomotiveSpec.cpp +0 -120
  57. package/nitrogen/generated/android/c++/JHybridAndroidAutomotiveSpec.hpp +0 -70
  58. package/nitrogen/generated/android/c++/JVariant_QrSignIn_PinSignIn_InputSignIn.cpp +0 -30
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/ActiveCarUxRestrictions.kt +0 -47
  60. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/AppFocusState.kt +0 -41
  61. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/CarUxRestrictions.kt +0 -31
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_ActiveCarUxRestrictions.kt +0 -80
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAndroidAutomotiveSpec.kt +0 -88
  64. package/nitrogen/generated/shared/c++/ActiveCarUxRestrictions.hpp +0 -97
  65. package/nitrogen/generated/shared/c++/AppFocusState.hpp +0 -87
  66. package/nitrogen/generated/shared/c++/CarUxRestrictions.hpp +0 -81
  67. package/nitrogen/generated/shared/c++/HybridAndroidAutomotiveSpec.cpp +0 -25
  68. package/nitrogen/generated/shared/c++/HybridAndroidAutomotiveSpec.hpp +0 -71
  69. package/src/specs/AndroidAutomotive.nitro.ts +0 -37
@@ -1,5 +1,5 @@
1
1
  ///
2
- /// Variant_QrSignIn_PinSignIn_InputSignIn.kt
2
+ /// Variant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn.kt
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
@@ -11,23 +11,26 @@ import com.facebook.proguard.annotations.DoNotStrip
11
11
 
12
12
 
13
13
  /**
14
- * Represents the TypeScript variant "QrSignIn | PinSignIn | InputSignIn".
14
+ * Represents the TypeScript variant "QrSignIn | PinSignIn | InputSignIn | GoogleSignIn".
15
15
  */
16
16
  @Suppress("ClassName")
17
17
  @DoNotStrip
18
- sealed class Variant_QrSignIn_PinSignIn_InputSignIn {
18
+ sealed class Variant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn {
19
19
  @DoNotStrip
20
- data class First(@DoNotStrip val value: QrSignIn): Variant_QrSignIn_PinSignIn_InputSignIn()
20
+ data class First(@DoNotStrip val value: QrSignIn): Variant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn()
21
21
  @DoNotStrip
22
- data class Second(@DoNotStrip val value: PinSignIn): Variant_QrSignIn_PinSignIn_InputSignIn()
22
+ data class Second(@DoNotStrip val value: PinSignIn): Variant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn()
23
23
  @DoNotStrip
24
- data class Third(@DoNotStrip val value: InputSignIn): Variant_QrSignIn_PinSignIn_InputSignIn()
24
+ data class Third(@DoNotStrip val value: InputSignIn): Variant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn()
25
+ @DoNotStrip
26
+ data class Fourth(@DoNotStrip val value: GoogleSignIn): Variant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn()
25
27
 
26
28
  @Deprecated("getAs() is not type-safe. Use fold/asFirstOrNull/asSecondOrNull instead.", level = DeprecationLevel.ERROR)
27
29
  inline fun <reified T> getAs(): T? = when (this) {
28
30
  is First -> value as? T
29
31
  is Second -> value as? T
30
32
  is Third -> value as? T
33
+ is Fourth -> value as? T
31
34
  }
32
35
 
33
36
  val isFirst: Boolean
@@ -36,6 +39,8 @@ sealed class Variant_QrSignIn_PinSignIn_InputSignIn {
36
39
  get() = this is Second
37
40
  val isThird: Boolean
38
41
  get() = this is Third
42
+ val isFourth: Boolean
43
+ get() = this is Fourth
39
44
 
40
45
  fun asFirstOrNull(): QrSignIn? {
41
46
  val value = (this as? First)?.value ?: return null
@@ -49,24 +54,32 @@ sealed class Variant_QrSignIn_PinSignIn_InputSignIn {
49
54
  val value = (this as? Third)?.value ?: return null
50
55
  return value
51
56
  }
57
+ fun asFourthOrNull(): GoogleSignIn? {
58
+ val value = (this as? Fourth)?.value ?: return null
59
+ return value
60
+ }
52
61
 
53
- inline fun <R> match(first: (QrSignIn) -> R, second: (PinSignIn) -> R, third: (InputSignIn) -> R): R {
62
+ inline fun <R> match(first: (QrSignIn) -> R, second: (PinSignIn) -> R, third: (InputSignIn) -> R, fourth: (GoogleSignIn) -> R): R {
54
63
  return when (this) {
55
64
  is First -> first(value)
56
65
  is Second -> second(value)
57
66
  is Third -> third(value)
67
+ is Fourth -> fourth(value)
58
68
  }
59
69
  }
60
70
 
61
71
  companion object {
62
72
  @JvmStatic
63
73
  @DoNotStrip
64
- fun create(value: QrSignIn): Variant_QrSignIn_PinSignIn_InputSignIn = First(value)
74
+ fun create(value: QrSignIn): Variant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn = First(value)
75
+ @JvmStatic
76
+ @DoNotStrip
77
+ fun create(value: PinSignIn): Variant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn = Second(value)
65
78
  @JvmStatic
66
79
  @DoNotStrip
67
- fun create(value: PinSignIn): Variant_QrSignIn_PinSignIn_InputSignIn = Second(value)
80
+ fun create(value: InputSignIn): Variant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn = Third(value)
68
81
  @JvmStatic
69
82
  @DoNotStrip
70
- fun create(value: InputSignIn): Variant_QrSignIn_PinSignIn_InputSignIn = Third(value)
83
+ fun create(value: GoogleSignIn): Variant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn = Fourth(value)
71
84
  }
72
85
  }
@@ -0,0 +1,98 @@
1
+ ///
2
+ /// GoogleSignIn.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 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
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+ // Forward declaration of `SignInMethods` to properly resolve imports.
32
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class SignInMethods; }
33
+ // Forward declaration of `GoogleSignInAccount` to properly resolve imports.
34
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct GoogleSignInAccount; }
35
+
36
+ #include "SignInMethods.hpp"
37
+ #include <string>
38
+ #include <optional>
39
+ #include "GoogleSignInAccount.hpp"
40
+ #include <functional>
41
+
42
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
43
+
44
+ /**
45
+ * A struct which can be represented as a JavaScript object (GoogleSignIn).
46
+ */
47
+ struct GoogleSignIn final {
48
+ public:
49
+ SignInMethods method SWIFT_PRIVATE;
50
+ std::string serverClientId SWIFT_PRIVATE;
51
+ std::function<void(const std::optional<std::string>& /* error */, const std::optional<GoogleSignInAccount>& /* signInAccount */)> callback SWIFT_PRIVATE;
52
+
53
+ public:
54
+ GoogleSignIn() = default;
55
+ explicit GoogleSignIn(SignInMethods method, std::string serverClientId, std::function<void(const std::optional<std::string>& /* error */, const std::optional<GoogleSignInAccount>& /* signInAccount */)> callback): method(method), serverClientId(serverClientId), callback(callback) {}
56
+
57
+ public:
58
+ // GoogleSignIn is not equatable because these properties are not equatable: callback
59
+ };
60
+
61
+ } // namespace margelo::nitro::swe::iternio::reactnativeautoplay
62
+
63
+ namespace margelo::nitro {
64
+
65
+ // C++ GoogleSignIn <> JS GoogleSignIn (object)
66
+ template <>
67
+ struct JSIConverter<margelo::nitro::swe::iternio::reactnativeautoplay::GoogleSignIn> final {
68
+ static inline margelo::nitro::swe::iternio::reactnativeautoplay::GoogleSignIn fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
69
+ jsi::Object obj = arg.asObject(runtime);
70
+ return margelo::nitro::swe::iternio::reactnativeautoplay::GoogleSignIn(
71
+ JSIConverter<margelo::nitro::swe::iternio::reactnativeautoplay::SignInMethods>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "method"))),
72
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serverClientId"))),
73
+ JSIConverter<std::function<void(const std::optional<std::string>&, const std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::GoogleSignInAccount>&)>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "callback")))
74
+ );
75
+ }
76
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::swe::iternio::reactnativeautoplay::GoogleSignIn& arg) {
77
+ jsi::Object obj(runtime);
78
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "method"), JSIConverter<margelo::nitro::swe::iternio::reactnativeautoplay::SignInMethods>::toJSI(runtime, arg.method));
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "serverClientId"), JSIConverter<std::string>::toJSI(runtime, arg.serverClientId));
80
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "callback"), JSIConverter<std::function<void(const std::optional<std::string>&, const std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::GoogleSignInAccount>&)>>::toJSI(runtime, arg.callback));
81
+ return obj;
82
+ }
83
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
84
+ if (!value.isObject()) {
85
+ return false;
86
+ }
87
+ jsi::Object obj = value.getObject(runtime);
88
+ if (!nitro::isPlainObject(runtime, obj)) {
89
+ return false;
90
+ }
91
+ if (!JSIConverter<margelo::nitro::swe::iternio::reactnativeautoplay::SignInMethods>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "method")))) return false;
92
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serverClientId")))) return false;
93
+ if (!JSIConverter<std::function<void(const std::optional<std::string>&, const std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::GoogleSignInAccount>&)>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "callback")))) return false;
94
+ return true;
95
+ }
96
+ };
97
+
98
+ } // namespace margelo::nitro
@@ -0,0 +1,112 @@
1
+ ///
2
+ /// GoogleSignInAccount.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 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
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+ #include <string>
34
+ #include <optional>
35
+
36
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
37
+
38
+ /**
39
+ * A struct which can be represented as a JavaScript object (GoogleSignInAccount).
40
+ */
41
+ struct GoogleSignInAccount final {
42
+ public:
43
+ std::optional<std::string> serverAuthCode SWIFT_PRIVATE;
44
+ std::optional<std::string> email SWIFT_PRIVATE;
45
+ std::optional<std::string> id SWIFT_PRIVATE;
46
+ std::optional<std::string> displayName SWIFT_PRIVATE;
47
+ std::optional<std::string> photoUrl SWIFT_PRIVATE;
48
+ std::optional<std::string> idToken SWIFT_PRIVATE;
49
+ std::optional<std::string> givenName SWIFT_PRIVATE;
50
+ std::optional<std::string> familyName SWIFT_PRIVATE;
51
+
52
+ public:
53
+ GoogleSignInAccount() = default;
54
+ explicit GoogleSignInAccount(std::optional<std::string> serverAuthCode, std::optional<std::string> email, std::optional<std::string> id, std::optional<std::string> displayName, std::optional<std::string> photoUrl, std::optional<std::string> idToken, std::optional<std::string> givenName, std::optional<std::string> familyName): serverAuthCode(serverAuthCode), email(email), id(id), displayName(displayName), photoUrl(photoUrl), idToken(idToken), givenName(givenName), familyName(familyName) {}
55
+
56
+ public:
57
+ friend bool operator==(const GoogleSignInAccount& lhs, const GoogleSignInAccount& rhs) = default;
58
+ };
59
+
60
+ } // namespace margelo::nitro::swe::iternio::reactnativeautoplay
61
+
62
+ namespace margelo::nitro {
63
+
64
+ // C++ GoogleSignInAccount <> JS GoogleSignInAccount (object)
65
+ template <>
66
+ struct JSIConverter<margelo::nitro::swe::iternio::reactnativeautoplay::GoogleSignInAccount> final {
67
+ static inline margelo::nitro::swe::iternio::reactnativeautoplay::GoogleSignInAccount fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
68
+ jsi::Object obj = arg.asObject(runtime);
69
+ return margelo::nitro::swe::iternio::reactnativeautoplay::GoogleSignInAccount(
70
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serverAuthCode"))),
71
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "email"))),
72
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id"))),
73
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "displayName"))),
74
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "photoUrl"))),
75
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "idToken"))),
76
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "givenName"))),
77
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "familyName")))
78
+ );
79
+ }
80
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::swe::iternio::reactnativeautoplay::GoogleSignInAccount& arg) {
81
+ jsi::Object obj(runtime);
82
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "serverAuthCode"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.serverAuthCode));
83
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "email"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.email));
84
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "id"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.id));
85
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "displayName"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.displayName));
86
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "photoUrl"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.photoUrl));
87
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "idToken"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.idToken));
88
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "givenName"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.givenName));
89
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "familyName"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.familyName));
90
+ return obj;
91
+ }
92
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
93
+ if (!value.isObject()) {
94
+ return false;
95
+ }
96
+ jsi::Object obj = value.getObject(runtime);
97
+ if (!nitro::isPlainObject(runtime, obj)) {
98
+ return false;
99
+ }
100
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serverAuthCode")))) return false;
101
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "email")))) return false;
102
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id")))) return false;
103
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "displayName")))) return false;
104
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "photoUrl")))) return false;
105
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "idToken")))) return false;
106
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "givenName")))) return false;
107
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "familyName")))) return false;
108
+ return true;
109
+ }
110
+ };
111
+
112
+ } // namespace margelo::nitro
@@ -25,7 +25,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
25
25
  */
26
26
  enum class SignInMethods {
27
27
  QR SWIFT_NAME(qr) = 0,
28
- PROVIDER SWIFT_NAME(provider) = 1,
28
+ GOOGLE SWIFT_NAME(google) = 1,
29
29
  PIN SWIFT_NAME(pin) = 2,
30
30
  INPUT SWIFT_NAME(input) = 3,
31
31
  } CLOSED_ENUM;
@@ -34,6 +34,8 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct QrSignIn; }
34
34
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct PinSignIn; }
35
35
  // Forward declaration of `InputSignIn` to properly resolve imports.
36
36
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct InputSignIn; }
37
+ // Forward declaration of `GoogleSignIn` to properly resolve imports.
38
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct GoogleSignIn; }
37
39
  // Forward declaration of `NitroAction` to properly resolve imports.
38
40
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroAction; }
39
41
 
@@ -43,6 +45,7 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct NitroAction
43
45
  #include "QrSignIn.hpp"
44
46
  #include "PinSignIn.hpp"
45
47
  #include "InputSignIn.hpp"
48
+ #include "GoogleSignIn.hpp"
46
49
  #include <variant>
47
50
  #include "NitroAction.hpp"
48
51
  #include <vector>
@@ -63,14 +66,14 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
63
66
  std::optional<double> autoDismissMs SWIFT_PRIVATE;
64
67
  std::optional<std::string> title SWIFT_PRIVATE;
65
68
  std::optional<std::string> additionalText SWIFT_PRIVATE;
66
- std::optional<std::variant<QrSignIn, PinSignIn, InputSignIn>> signInMethod SWIFT_PRIVATE;
69
+ std::optional<std::variant<QrSignIn, PinSignIn, InputSignIn, GoogleSignIn>> signInMethod SWIFT_PRIVATE;
67
70
  std::optional<std::vector<NitroAction>> headerActions SWIFT_PRIVATE;
68
71
  std::optional<std::vector<NitroAction>> actions SWIFT_PRIVATE;
69
72
  std::optional<std::string> instructions SWIFT_PRIVATE;
70
73
 
71
74
  public:
72
75
  SignInTemplateConfig() = default;
73
- explicit SignInTemplateConfig(std::string id, std::optional<std::function<void(std::optional<bool> /* animated */)>> onWillAppear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onWillDisappear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onDidAppear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onDidDisappear, std::optional<std::function<void()>> onPopped, std::optional<double> autoDismissMs, std::optional<std::string> title, std::optional<std::string> additionalText, std::optional<std::variant<QrSignIn, PinSignIn, InputSignIn>> signInMethod, std::optional<std::vector<NitroAction>> headerActions, std::optional<std::vector<NitroAction>> actions, std::optional<std::string> instructions): id(id), onWillAppear(onWillAppear), onWillDisappear(onWillDisappear), onDidAppear(onDidAppear), onDidDisappear(onDidDisappear), onPopped(onPopped), autoDismissMs(autoDismissMs), title(title), additionalText(additionalText), signInMethod(signInMethod), headerActions(headerActions), actions(actions), instructions(instructions) {}
76
+ explicit SignInTemplateConfig(std::string id, std::optional<std::function<void(std::optional<bool> /* animated */)>> onWillAppear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onWillDisappear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onDidAppear, std::optional<std::function<void(std::optional<bool> /* animated */)>> onDidDisappear, std::optional<std::function<void()>> onPopped, std::optional<double> autoDismissMs, std::optional<std::string> title, std::optional<std::string> additionalText, std::optional<std::variant<QrSignIn, PinSignIn, InputSignIn, GoogleSignIn>> signInMethod, std::optional<std::vector<NitroAction>> headerActions, std::optional<std::vector<NitroAction>> actions, std::optional<std::string> instructions): id(id), onWillAppear(onWillAppear), onWillDisappear(onWillDisappear), onDidAppear(onDidAppear), onDidDisappear(onDidDisappear), onPopped(onPopped), autoDismissMs(autoDismissMs), title(title), additionalText(additionalText), signInMethod(signInMethod), headerActions(headerActions), actions(actions), instructions(instructions) {}
74
77
 
75
78
  public:
76
79
  // SignInTemplateConfig is not equatable because these properties are not equatable: onWillAppear, onWillDisappear, onDidAppear, onDidDisappear, onPopped, signInMethod, headerActions, actions
@@ -95,7 +98,7 @@ namespace margelo::nitro {
95
98
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoDismissMs"))),
96
99
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title"))),
97
100
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "additionalText"))),
98
- JSIConverter<std::optional<std::variant<margelo::nitro::swe::iternio::reactnativeautoplay::QrSignIn, margelo::nitro::swe::iternio::reactnativeautoplay::PinSignIn, margelo::nitro::swe::iternio::reactnativeautoplay::InputSignIn>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "signInMethod"))),
101
+ JSIConverter<std::optional<std::variant<margelo::nitro::swe::iternio::reactnativeautoplay::QrSignIn, margelo::nitro::swe::iternio::reactnativeautoplay::PinSignIn, margelo::nitro::swe::iternio::reactnativeautoplay::InputSignIn, margelo::nitro::swe::iternio::reactnativeautoplay::GoogleSignIn>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "signInMethod"))),
99
102
  JSIConverter<std::optional<std::vector<margelo::nitro::swe::iternio::reactnativeautoplay::NitroAction>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headerActions"))),
100
103
  JSIConverter<std::optional<std::vector<margelo::nitro::swe::iternio::reactnativeautoplay::NitroAction>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "actions"))),
101
104
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "instructions")))
@@ -112,7 +115,7 @@ namespace margelo::nitro {
112
115
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "autoDismissMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.autoDismissMs));
113
116
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "title"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.title));
114
117
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "additionalText"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.additionalText));
115
- obj.setProperty(runtime, PropNameIDCache::get(runtime, "signInMethod"), JSIConverter<std::optional<std::variant<margelo::nitro::swe::iternio::reactnativeautoplay::QrSignIn, margelo::nitro::swe::iternio::reactnativeautoplay::PinSignIn, margelo::nitro::swe::iternio::reactnativeautoplay::InputSignIn>>>::toJSI(runtime, arg.signInMethod));
118
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "signInMethod"), JSIConverter<std::optional<std::variant<margelo::nitro::swe::iternio::reactnativeautoplay::QrSignIn, margelo::nitro::swe::iternio::reactnativeautoplay::PinSignIn, margelo::nitro::swe::iternio::reactnativeautoplay::InputSignIn, margelo::nitro::swe::iternio::reactnativeautoplay::GoogleSignIn>>>::toJSI(runtime, arg.signInMethod));
116
119
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "headerActions"), JSIConverter<std::optional<std::vector<margelo::nitro::swe::iternio::reactnativeautoplay::NitroAction>>>::toJSI(runtime, arg.headerActions));
117
120
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "actions"), JSIConverter<std::optional<std::vector<margelo::nitro::swe::iternio::reactnativeautoplay::NitroAction>>>::toJSI(runtime, arg.actions));
118
121
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "instructions"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.instructions));
@@ -135,7 +138,7 @@ namespace margelo::nitro {
135
138
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoDismissMs")))) return false;
136
139
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title")))) return false;
137
140
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "additionalText")))) return false;
138
- if (!JSIConverter<std::optional<std::variant<margelo::nitro::swe::iternio::reactnativeautoplay::QrSignIn, margelo::nitro::swe::iternio::reactnativeautoplay::PinSignIn, margelo::nitro::swe::iternio::reactnativeautoplay::InputSignIn>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "signInMethod")))) return false;
141
+ if (!JSIConverter<std::optional<std::variant<margelo::nitro::swe::iternio::reactnativeautoplay::QrSignIn, margelo::nitro::swe::iternio::reactnativeautoplay::PinSignIn, margelo::nitro::swe::iternio::reactnativeautoplay::InputSignIn, margelo::nitro::swe::iternio::reactnativeautoplay::GoogleSignIn>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "signInMethod")))) return false;
139
142
  if (!JSIConverter<std::optional<std::vector<margelo::nitro::swe::iternio::reactnativeautoplay::NitroAction>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "headerActions")))) return false;
140
143
  if (!JSIConverter<std::optional<std::vector<margelo::nitro::swe::iternio::reactnativeautoplay::NitroAction>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "actions")))) return false;
141
144
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "instructions")))) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iternio/react-native-auto-play",
3
- "version": "0.2.0-alpha.3",
3
+ "version": "0.2.0-alpha.4",
4
4
  "description": "Android Auto and Apple CarPlay for react-native",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",
@@ -4,46 +4,35 @@ import { HybridAndroidAutoTelemetry, HybridAutoPlay } from '..';
4
4
 
5
5
  import type { AndroidAutoPermissions, Telemetry } from '../types/Telemetry';
6
6
 
7
- type Props =
8
- | {
9
- /**
10
- * Can be used to delay asking for permissions if set to false. True by default.
11
- * Can be used to request other permissions first, so the permission request dialogs do not overlap.
12
- * @default true
13
- */
14
- requestTelemetryPermissions: true;
15
- /**
16
- * The permissions to check.
17
- */
18
- requiredPermissions: Array<AndroidAutoPermissions>;
19
- /**
20
- * Android Automotive specific permission request properties
21
- */
22
- automotivePermissionRequest?: {
23
- /**
24
- * message to be shown on the permission request screen
25
- */
26
- message: string;
27
- /**
28
- * primary action button text
29
- */
30
- grantButtonText: string;
31
- /**
32
- * secondary action button text, if not specified button will not be shown
33
- */
34
- cancelButtonText?: string;
35
- };
36
- /**
37
- * set to true in case your build variant targets Android Automotive
38
- */
39
- isAndroidAutomotive?: boolean;
40
- }
41
- | {
42
- requestTelemetryPermissions: false | undefined;
43
- requiredPermissions?: never;
44
- automotivePermissionRequest?: never;
45
- isAndroidAutomotive?: boolean;
46
- };
7
+ interface Props {
8
+ /**
9
+ * Can be used to delay asking for permissions if set to false. True by default.
10
+ * Can be used to request other permissions first, so the permission request dialogs do not overlap.
11
+ * @default true
12
+ */
13
+ requestTelemetryPermissions?: boolean;
14
+ /**
15
+ * The permissions to check.
16
+ */
17
+ requiredPermissions: Array<AndroidAutoPermissions>;
18
+ /**
19
+ * Android Automotive specific permission request properties
20
+ */
21
+ automotivePermissionRequest?: {
22
+ /**
23
+ * message to be shown on the permission request screen
24
+ */
25
+ message: string;
26
+ /**
27
+ * primary action button text
28
+ */
29
+ grantButtonText: string;
30
+ /**
31
+ * secondary action button text, if not specified button will not be shown
32
+ */
33
+ cancelButtonText?: string;
34
+ };
35
+ }
47
36
 
48
37
  /**
49
38
  * Hook to check if the telemetry permissions are granted. If the permissions are not granted, it will request them from the user.
@@ -54,20 +43,15 @@ type Props =
54
43
  */
55
44
  export const useAndroidAutoTelemetry = ({
56
45
  requestTelemetryPermissions = true,
57
- requiredPermissions = [],
46
+ requiredPermissions,
58
47
  automotivePermissionRequest,
59
- isAndroidAutomotive = false,
60
48
  }: Props) => {
61
49
  const [permissionsGranted, setPermissionsGranted] = useState<boolean | null>(null);
62
50
  const [telemetry, setTelemetry] = useState<Telemetry | undefined>(undefined);
63
51
  const [error, setError] = useState<string | undefined>(undefined);
64
- const [isConnected, setIsConnected] = useState(isAndroidAutomotive);
52
+ const [isConnected, setIsConnected] = useState(false);
65
53
 
66
54
  useEffect(() => {
67
- if (isAndroidAutomotive) {
68
- return;
69
- }
70
-
71
55
  const removeDidConnect = HybridAutoPlay.addListener('didConnect', () => setIsConnected(true));
72
56
  const removeDidDisconnect = HybridAutoPlay.addListener('didDisconnect', () =>
73
57
  setIsConnected(false)
@@ -79,7 +63,7 @@ export const useAndroidAutoTelemetry = ({
79
63
  removeDidConnect();
80
64
  removeDidDisconnect();
81
65
  };
82
- }, [isAndroidAutomotive]);
66
+ }, []);
83
67
 
84
68
  useEffect(() => {
85
69
  const checkPermissions = async () => {
package/src/index.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { Platform } from 'react-native';
2
2
  import { NitroModules } from 'react-native-nitro-modules';
3
3
  import AutoPlayHeadlessJsTask from './AutoPlayHeadlessJsTask';
4
- import type { AndroidAutomotive } from './specs/AndroidAutomotive.nitro';
5
4
  import type { AndroidAutoTelemetry as NitroAndroidAutoTelemetry } from './specs/AndroidAutoTelemetry.nitro';
6
5
  import type { AutoPlay as NitroAutoPlay } from './specs/AutoPlay.nitro';
7
6
 
@@ -14,11 +13,6 @@ export const HybridAndroidAutoTelemetry =
14
13
  ? NitroModules.createHybridObject<NitroAndroidAutoTelemetry>('AndroidAutoTelemetry')
15
14
  : null;
16
15
 
17
- export const HybridAndroidAutomotive =
18
- Platform.OS === 'android'
19
- ? NitroModules.createHybridObject<AndroidAutomotive>('AndroidAutomotive')
20
- : null;
21
-
22
16
  /**
23
17
  * These are the static module names for the app running on the mobile device, head unit screen and the CarPlay dashboard.
24
18
  * Clusters generate uuids on native side that are passed in the RootComponentInitialProps
@@ -37,11 +31,6 @@ export * from './hooks/useSafeAreaInsets';
37
31
  export * from './hooks/useVoiceInput';
38
32
  export * from './scenes/AutoPlayCluster';
39
33
  export * from './scenes/CarPlayDashboardScene';
40
- export type {
41
- ActiveCarUxRestrictions,
42
- AppFocusState,
43
- } from './specs/AndroidAutomotive.nitro';
44
- export { CarUxRestrictions } from './specs/AndroidAutomotive.nitro';
45
34
  export * from './templates/GridTemplate';
46
35
  export * from './templates/InformationTemplate';
47
36
  export * from './templates/ListTemplate';
@@ -1,10 +1,27 @@
1
1
  export enum SignInMethods {
2
2
  QR = 0,
3
- PROVIDER = 1,
3
+ GOOGLE = 1,
4
4
  PIN = 2,
5
5
  INPUT = 3,
6
6
  }
7
7
 
8
+ export type GoogleSignInAccount = {
9
+ serverAuthCode?: string;
10
+ email?: string;
11
+ id?: string;
12
+ displayName?: string;
13
+ photoUrl?: string;
14
+ idToken?: string;
15
+ givenName?: string;
16
+ familyName?: string;
17
+ };
18
+
19
+ export type GoogleSignIn = {
20
+ method: SignInMethods.GOOGLE;
21
+ serverClientId: string;
22
+ callback: (error?: string, signInAccount?: GoogleSignInAccount) => void;
23
+ };
24
+
8
25
  export type PinSignIn = {
9
26
  method: SignInMethods.PIN;
10
27
  /**
@@ -38,4 +55,4 @@ export type QrSignIn = {
38
55
  url: string;
39
56
  };
40
57
 
41
- export type SignInMethod = QrSignIn | PinSignIn | InputSignIn;
58
+ export type SignInMethod = QrSignIn | PinSignIn | InputSignIn | GoogleSignIn;
@@ -1,25 +0,0 @@
1
- package com.margelo.nitro.swe.iternio.reactnativeautoplay
2
-
3
- class InvalidPlatformException(message: String) : Exception(message)
4
-
5
- class HybridAndroidAutomotive : HybridAndroidAutomotiveSpec() {
6
- override fun registerCarUxRestrictionsListener(callback: (restrictions: ActiveCarUxRestrictions) -> Unit): () -> Unit {
7
- throw InvalidPlatformException("registerCarUxRestrictionsListener is supported on Android Automotive only!")
8
- }
9
-
10
- override fun getCarUxRestrictions(): ActiveCarUxRestrictions {
11
- throw InvalidPlatformException("getCarUxRestrictions is supported on Android Automotive only!")
12
- }
13
-
14
- override fun registerAppFocusListener(callback: (state: AppFocusState) -> Unit): () -> Unit {
15
- throw InvalidPlatformException("registerAppFocusListener is supported on Android Automotive only!")
16
- }
17
-
18
- override fun getAppFocusState(): AppFocusState {
19
- throw InvalidPlatformException("getAppFocusState is supported on Android Automotive only!")
20
- }
21
-
22
- override fun requestAppFocus(): () -> Unit {
23
- throw InvalidPlatformException("requestAppFocus is supported on Android Automotive only!")
24
- }
25
- }