@onekeyfe/react-native-device-utils 1.1.19 → 1.1.21

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 (37) hide show
  1. package/ReactNativeDeviceUtils.podspec +1 -0
  2. package/android/build.gradle +5 -0
  3. package/android/src/main/java/com/margelo/nitro/reactnativedeviceutils/ReactNativeDeviceUtils.kt +153 -8
  4. package/ios/ReactNativeDeviceUtils.swift +109 -0
  5. package/lib/typescript/src/ReactNativeDeviceUtils.nitro.d.ts +22 -0
  6. package/lib/typescript/src/ReactNativeDeviceUtils.nitro.d.ts.map +1 -1
  7. package/nitrogen/generated/android/c++/JGooglePlayServicesStatus.hpp +61 -0
  8. package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.cpp +145 -0
  9. package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.hpp +9 -0
  10. package/nitrogen/generated/android/c++/JLaunchOptions.hpp +62 -0
  11. package/nitrogen/generated/android/c++/JWebViewPackageInfo.hpp +65 -0
  12. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/GooglePlayServicesStatus.kt +41 -0
  13. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/HybridReactNativeDeviceUtilsSpec.kt +36 -0
  14. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/LaunchOptions.kt +41 -0
  15. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/WebViewPackageInfo.kt +44 -0
  16. package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Bridge.cpp +48 -0
  17. package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Bridge.hpp +305 -0
  18. package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Umbrella.hpp +11 -0
  19. package/nitrogen/generated/ios/c++/HybridReactNativeDeviceUtilsSpecSwift.hpp +81 -0
  20. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  21. package/nitrogen/generated/ios/swift/Func_void_GooglePlayServicesStatus.swift +47 -0
  22. package/nitrogen/generated/ios/swift/Func_void_LaunchOptions.swift +47 -0
  23. package/nitrogen/generated/ios/swift/Func_void_WebViewPackageInfo.swift +47 -0
  24. package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
  25. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
  26. package/nitrogen/generated/ios/swift/GooglePlayServicesStatus.swift +47 -0
  27. package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec.swift +9 -0
  28. package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec_cxx.swift +163 -0
  29. package/nitrogen/generated/ios/swift/LaunchOptions.swift +66 -0
  30. package/nitrogen/generated/ios/swift/WebViewPackageInfo.swift +58 -0
  31. package/nitrogen/generated/shared/c++/GooglePlayServicesStatus.hpp +79 -0
  32. package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.cpp +9 -0
  33. package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.hpp +19 -0
  34. package/nitrogen/generated/shared/c++/LaunchOptions.hpp +80 -0
  35. package/nitrogen/generated/shared/c++/WebViewPackageInfo.hpp +83 -0
  36. package/package.json +1 -1
  37. package/src/ReactNativeDeviceUtils.nitro.ts +31 -0
@@ -63,6 +63,15 @@ namespace margelo::nitro::reactnativedeviceutils {
63
63
  double addSpanningChangedListener(const std::function<void(bool /* isSpanning */)>& callback) override;
64
64
  void removeSpanningChangedListener(double id) override;
65
65
  void setUserInterfaceStyle(UserInterfaceStyle style) override;
66
+ std::shared_ptr<Promise<LaunchOptions>> getLaunchOptions() override;
67
+ std::shared_ptr<Promise<bool>> clearLaunchOptions() override;
68
+ std::shared_ptr<Promise<std::string>> getDeviceToken() override;
69
+ std::shared_ptr<Promise<void>> saveDeviceToken(const std::string& token) override;
70
+ std::shared_ptr<Promise<bool>> registerDeviceToken() override;
71
+ std::shared_ptr<Promise<double>> getStartupTime() override;
72
+ void exitApp() override;
73
+ std::shared_ptr<Promise<WebViewPackageInfo>> getCurrentWebViewPackageInfo() override;
74
+ std::shared_ptr<Promise<GooglePlayServicesStatus>> isGooglePlayServicesAvailable() override;
66
75
 
67
76
  private:
68
77
  friend HybridBase;
@@ -0,0 +1,62 @@
1
+ ///
2
+ /// JLaunchOptions.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include "LaunchOptions.hpp"
12
+
13
+ #include <optional>
14
+ #include <string>
15
+
16
+ namespace margelo::nitro::reactnativedeviceutils {
17
+
18
+ using namespace facebook;
19
+
20
+ /**
21
+ * The C++ JNI bridge between the C++ struct "LaunchOptions" and the the Kotlin data class "LaunchOptions".
22
+ */
23
+ struct JLaunchOptions final: public jni::JavaClass<JLaunchOptions> {
24
+ public:
25
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/reactnativedeviceutils/LaunchOptions;";
26
+
27
+ public:
28
+ /**
29
+ * Convert this Java/Kotlin-based struct to the C++ struct LaunchOptions by copying all values to C++.
30
+ */
31
+ [[maybe_unused]]
32
+ [[nodiscard]]
33
+ LaunchOptions toCpp() const {
34
+ static const auto clazz = javaClassStatic();
35
+ static const auto fieldLaunchType = clazz->getField<jni::JString>("launchType");
36
+ jni::local_ref<jni::JString> launchType = this->getFieldValue(fieldLaunchType);
37
+ static const auto fieldDeepLink = clazz->getField<jni::JString>("deepLink");
38
+ jni::local_ref<jni::JString> deepLink = this->getFieldValue(fieldDeepLink);
39
+ return LaunchOptions(
40
+ launchType->toStdString(),
41
+ deepLink != nullptr ? std::make_optional(deepLink->toStdString()) : std::nullopt
42
+ );
43
+ }
44
+
45
+ public:
46
+ /**
47
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
48
+ */
49
+ [[maybe_unused]]
50
+ static jni::local_ref<JLaunchOptions::javaobject> fromCpp(const LaunchOptions& value) {
51
+ using JSignature = JLaunchOptions(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>);
52
+ static const auto clazz = javaClassStatic();
53
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
54
+ return create(
55
+ clazz,
56
+ jni::make_jstring(value.launchType),
57
+ value.deepLink.has_value() ? jni::make_jstring(value.deepLink.value()) : nullptr
58
+ );
59
+ }
60
+ };
61
+
62
+ } // namespace margelo::nitro::reactnativedeviceutils
@@ -0,0 +1,65 @@
1
+ ///
2
+ /// JWebViewPackageInfo.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include "WebViewPackageInfo.hpp"
12
+
13
+ #include <string>
14
+
15
+ namespace margelo::nitro::reactnativedeviceutils {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * The C++ JNI bridge between the C++ struct "WebViewPackageInfo" and the the Kotlin data class "WebViewPackageInfo".
21
+ */
22
+ struct JWebViewPackageInfo final: public jni::JavaClass<JWebViewPackageInfo> {
23
+ public:
24
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/reactnativedeviceutils/WebViewPackageInfo;";
25
+
26
+ public:
27
+ /**
28
+ * Convert this Java/Kotlin-based struct to the C++ struct WebViewPackageInfo by copying all values to C++.
29
+ */
30
+ [[maybe_unused]]
31
+ [[nodiscard]]
32
+ WebViewPackageInfo toCpp() const {
33
+ static const auto clazz = javaClassStatic();
34
+ static const auto fieldPackageName = clazz->getField<jni::JString>("packageName");
35
+ jni::local_ref<jni::JString> packageName = this->getFieldValue(fieldPackageName);
36
+ static const auto fieldVersionName = clazz->getField<jni::JString>("versionName");
37
+ jni::local_ref<jni::JString> versionName = this->getFieldValue(fieldVersionName);
38
+ static const auto fieldVersionCode = clazz->getField<double>("versionCode");
39
+ double versionCode = this->getFieldValue(fieldVersionCode);
40
+ return WebViewPackageInfo(
41
+ packageName->toStdString(),
42
+ versionName->toStdString(),
43
+ versionCode
44
+ );
45
+ }
46
+
47
+ public:
48
+ /**
49
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
50
+ */
51
+ [[maybe_unused]]
52
+ static jni::local_ref<JWebViewPackageInfo::javaobject> fromCpp(const WebViewPackageInfo& value) {
53
+ using JSignature = JWebViewPackageInfo(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, double);
54
+ static const auto clazz = javaClassStatic();
55
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
56
+ return create(
57
+ clazz,
58
+ jni::make_jstring(value.packageName),
59
+ jni::make_jstring(value.versionName),
60
+ value.versionCode
61
+ );
62
+ }
63
+ };
64
+
65
+ } // namespace margelo::nitro::reactnativedeviceutils
@@ -0,0 +1,41 @@
1
+ ///
2
+ /// GooglePlayServicesStatus.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.reactnativedeviceutils
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+
14
+ /**
15
+ * Represents the JavaScript object/struct "GooglePlayServicesStatus".
16
+ */
17
+ @DoNotStrip
18
+ @Keep
19
+ data class GooglePlayServicesStatus(
20
+ @DoNotStrip
21
+ @Keep
22
+ val status: Double,
23
+ @DoNotStrip
24
+ @Keep
25
+ val isAvailable: Boolean
26
+ ) {
27
+ /* primary constructor */
28
+
29
+ private companion object {
30
+ /**
31
+ * Constructor called from C++
32
+ */
33
+ @DoNotStrip
34
+ @Keep
35
+ @Suppress("unused")
36
+ @JvmStatic
37
+ private fun fromCpp(status: Double, isAvailable: Boolean): GooglePlayServicesStatus {
38
+ return GooglePlayServicesStatus(status, isAvailable)
39
+ }
40
+ }
41
+ }
@@ -86,6 +86,42 @@ abstract class HybridReactNativeDeviceUtilsSpec: HybridObject() {
86
86
  @DoNotStrip
87
87
  @Keep
88
88
  abstract fun setUserInterfaceStyle(style: UserInterfaceStyle): Unit
89
+
90
+ @DoNotStrip
91
+ @Keep
92
+ abstract fun getLaunchOptions(): Promise<LaunchOptions>
93
+
94
+ @DoNotStrip
95
+ @Keep
96
+ abstract fun clearLaunchOptions(): Promise<Boolean>
97
+
98
+ @DoNotStrip
99
+ @Keep
100
+ abstract fun getDeviceToken(): Promise<String>
101
+
102
+ @DoNotStrip
103
+ @Keep
104
+ abstract fun saveDeviceToken(token: String): Promise<Unit>
105
+
106
+ @DoNotStrip
107
+ @Keep
108
+ abstract fun registerDeviceToken(): Promise<Boolean>
109
+
110
+ @DoNotStrip
111
+ @Keep
112
+ abstract fun getStartupTime(): Promise<Double>
113
+
114
+ @DoNotStrip
115
+ @Keep
116
+ abstract fun exitApp(): Unit
117
+
118
+ @DoNotStrip
119
+ @Keep
120
+ abstract fun getCurrentWebViewPackageInfo(): Promise<WebViewPackageInfo>
121
+
122
+ @DoNotStrip
123
+ @Keep
124
+ abstract fun isGooglePlayServicesAvailable(): Promise<GooglePlayServicesStatus>
89
125
 
90
126
  private external fun initHybrid(): HybridData
91
127
 
@@ -0,0 +1,41 @@
1
+ ///
2
+ /// LaunchOptions.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.reactnativedeviceutils
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+
14
+ /**
15
+ * Represents the JavaScript object/struct "LaunchOptions".
16
+ */
17
+ @DoNotStrip
18
+ @Keep
19
+ data class LaunchOptions(
20
+ @DoNotStrip
21
+ @Keep
22
+ val launchType: String,
23
+ @DoNotStrip
24
+ @Keep
25
+ val deepLink: String?
26
+ ) {
27
+ /* primary constructor */
28
+
29
+ private companion object {
30
+ /**
31
+ * Constructor called from C++
32
+ */
33
+ @DoNotStrip
34
+ @Keep
35
+ @Suppress("unused")
36
+ @JvmStatic
37
+ private fun fromCpp(launchType: String, deepLink: String?): LaunchOptions {
38
+ return LaunchOptions(launchType, deepLink)
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// WebViewPackageInfo.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.reactnativedeviceutils
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+
14
+ /**
15
+ * Represents the JavaScript object/struct "WebViewPackageInfo".
16
+ */
17
+ @DoNotStrip
18
+ @Keep
19
+ data class WebViewPackageInfo(
20
+ @DoNotStrip
21
+ @Keep
22
+ val packageName: String,
23
+ @DoNotStrip
24
+ @Keep
25
+ val versionName: String,
26
+ @DoNotStrip
27
+ @Keep
28
+ val versionCode: Double
29
+ ) {
30
+ /* primary constructor */
31
+
32
+ private companion object {
33
+ /**
34
+ * Constructor called from C++
35
+ */
36
+ @DoNotStrip
37
+ @Keep
38
+ @Suppress("unused")
39
+ @JvmStatic
40
+ private fun fromCpp(packageName: String, versionName: String, versionCode: Double): WebViewPackageInfo {
41
+ return WebViewPackageInfo(packageName, versionName, versionCode)
42
+ }
43
+ }
44
+ }
@@ -46,6 +46,54 @@ namespace margelo::nitro::reactnativedeviceutils::bridge::swift {
46
46
  };
47
47
  }
48
48
 
49
+ // pragma MARK: std::function<void(const LaunchOptions& /* result */)>
50
+ Func_void_LaunchOptions create_Func_void_LaunchOptions(void* NON_NULL swiftClosureWrapper) noexcept {
51
+ auto swiftClosure = ReactNativeDeviceUtils::Func_void_LaunchOptions::fromUnsafe(swiftClosureWrapper);
52
+ return [swiftClosure = std::move(swiftClosure)](const LaunchOptions& result) mutable -> void {
53
+ swiftClosure.call(result);
54
+ };
55
+ }
56
+
57
+ // pragma MARK: std::function<void(const std::string& /* result */)>
58
+ Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
59
+ auto swiftClosure = ReactNativeDeviceUtils::Func_void_std__string::fromUnsafe(swiftClosureWrapper);
60
+ return [swiftClosure = std::move(swiftClosure)](const std::string& result) mutable -> void {
61
+ swiftClosure.call(result);
62
+ };
63
+ }
64
+
65
+ // pragma MARK: std::function<void()>
66
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
67
+ auto swiftClosure = ReactNativeDeviceUtils::Func_void::fromUnsafe(swiftClosureWrapper);
68
+ return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
69
+ swiftClosure.call();
70
+ };
71
+ }
72
+
73
+ // pragma MARK: std::function<void(double /* result */)>
74
+ Func_void_double create_Func_void_double(void* NON_NULL swiftClosureWrapper) noexcept {
75
+ auto swiftClosure = ReactNativeDeviceUtils::Func_void_double::fromUnsafe(swiftClosureWrapper);
76
+ return [swiftClosure = std::move(swiftClosure)](double result) mutable -> void {
77
+ swiftClosure.call(result);
78
+ };
79
+ }
80
+
81
+ // pragma MARK: std::function<void(const WebViewPackageInfo& /* result */)>
82
+ Func_void_WebViewPackageInfo create_Func_void_WebViewPackageInfo(void* NON_NULL swiftClosureWrapper) noexcept {
83
+ auto swiftClosure = ReactNativeDeviceUtils::Func_void_WebViewPackageInfo::fromUnsafe(swiftClosureWrapper);
84
+ return [swiftClosure = std::move(swiftClosure)](const WebViewPackageInfo& result) mutable -> void {
85
+ swiftClosure.call(result);
86
+ };
87
+ }
88
+
89
+ // pragma MARK: std::function<void(const GooglePlayServicesStatus& /* result */)>
90
+ Func_void_GooglePlayServicesStatus create_Func_void_GooglePlayServicesStatus(void* NON_NULL swiftClosureWrapper) noexcept {
91
+ auto swiftClosure = ReactNativeDeviceUtils::Func_void_GooglePlayServicesStatus::fromUnsafe(swiftClosureWrapper);
92
+ return [swiftClosure = std::move(swiftClosure)](const GooglePlayServicesStatus& result) mutable -> void {
93
+ swiftClosure.call(result);
94
+ };
95
+ }
96
+
49
97
  // pragma MARK: std::shared_ptr<HybridReactNativeDeviceUtilsSpec>
50
98
  std::shared_ptr<HybridReactNativeDeviceUtilsSpec> create_std__shared_ptr_HybridReactNativeDeviceUtilsSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
51
99
  ReactNativeDeviceUtils::HybridReactNativeDeviceUtilsSpec_cxx swiftPart = ReactNativeDeviceUtils::HybridReactNativeDeviceUtilsSpec_cxx::fromUnsafe(swiftUnsafePointer);