@onekeyfe/react-native-device-utils 1.1.20 → 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.
- package/android/build.gradle +4 -1
- package/android/src/main/java/com/margelo/nitro/reactnativedeviceutils/ReactNativeDeviceUtils.kt +138 -0
- package/ios/ReactNativeDeviceUtils.swift +105 -0
- package/lib/typescript/src/ReactNativeDeviceUtils.nitro.d.ts +22 -0
- package/lib/typescript/src/ReactNativeDeviceUtils.nitro.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JGooglePlayServicesStatus.hpp +61 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.cpp +145 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.hpp +9 -0
- package/nitrogen/generated/android/c++/JLaunchOptions.hpp +62 -0
- package/nitrogen/generated/android/c++/JWebViewPackageInfo.hpp +65 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/GooglePlayServicesStatus.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/HybridReactNativeDeviceUtilsSpec.kt +36 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/LaunchOptions.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/WebViewPackageInfo.kt +44 -0
- package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Bridge.cpp +48 -0
- package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Bridge.hpp +305 -0
- package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Umbrella.hpp +11 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeDeviceUtilsSpecSwift.hpp +81 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_GooglePlayServicesStatus.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_LaunchOptions.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_WebViewPackageInfo.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
- package/nitrogen/generated/ios/swift/GooglePlayServicesStatus.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec.swift +9 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec_cxx.swift +163 -0
- package/nitrogen/generated/ios/swift/LaunchOptions.swift +66 -0
- package/nitrogen/generated/ios/swift/WebViewPackageInfo.swift +58 -0
- package/nitrogen/generated/shared/c++/GooglePlayServicesStatus.hpp +79 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.cpp +9 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.hpp +19 -0
- package/nitrogen/generated/shared/c++/LaunchOptions.hpp +80 -0
- package/nitrogen/generated/shared/c++/WebViewPackageInfo.hpp +83 -0
- package/package.json +1 -1
- package/src/ReactNativeDeviceUtils.nitro.ts +31 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// WebViewPackageInfo.swift
|
|
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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents an instance of `WebViewPackageInfo`, backed by a C++ struct.
|
|
13
|
+
*/
|
|
14
|
+
public typealias WebViewPackageInfo = margelo.nitro.reactnativedeviceutils.WebViewPackageInfo
|
|
15
|
+
|
|
16
|
+
public extension WebViewPackageInfo {
|
|
17
|
+
private typealias bridge = margelo.nitro.reactnativedeviceutils.bridge.swift
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new instance of `WebViewPackageInfo`.
|
|
21
|
+
*/
|
|
22
|
+
init(packageName: String, versionName: String, versionCode: Double) {
|
|
23
|
+
self.init(std.string(packageName), std.string(versionName), versionCode)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var packageName: String {
|
|
27
|
+
@inline(__always)
|
|
28
|
+
get {
|
|
29
|
+
return String(self.__packageName)
|
|
30
|
+
}
|
|
31
|
+
@inline(__always)
|
|
32
|
+
set {
|
|
33
|
+
self.__packageName = std.string(newValue)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var versionName: String {
|
|
38
|
+
@inline(__always)
|
|
39
|
+
get {
|
|
40
|
+
return String(self.__versionName)
|
|
41
|
+
}
|
|
42
|
+
@inline(__always)
|
|
43
|
+
set {
|
|
44
|
+
self.__versionName = std.string(newValue)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var versionCode: Double {
|
|
49
|
+
@inline(__always)
|
|
50
|
+
get {
|
|
51
|
+
return self.__versionCode
|
|
52
|
+
}
|
|
53
|
+
@inline(__always)
|
|
54
|
+
set {
|
|
55
|
+
self.__versionCode = newValue
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// GooglePlayServicesStatus.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
|
+
#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::reactnativedeviceutils {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A struct which can be represented as a JavaScript object (GooglePlayServicesStatus).
|
|
34
|
+
*/
|
|
35
|
+
struct GooglePlayServicesStatus {
|
|
36
|
+
public:
|
|
37
|
+
double status SWIFT_PRIVATE;
|
|
38
|
+
bool isAvailable SWIFT_PRIVATE;
|
|
39
|
+
|
|
40
|
+
public:
|
|
41
|
+
GooglePlayServicesStatus() = default;
|
|
42
|
+
explicit GooglePlayServicesStatus(double status, bool isAvailable): status(status), isAvailable(isAvailable) {}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
46
|
+
|
|
47
|
+
namespace margelo::nitro {
|
|
48
|
+
|
|
49
|
+
// C++ GooglePlayServicesStatus <> JS GooglePlayServicesStatus (object)
|
|
50
|
+
template <>
|
|
51
|
+
struct JSIConverter<margelo::nitro::reactnativedeviceutils::GooglePlayServicesStatus> final {
|
|
52
|
+
static inline margelo::nitro::reactnativedeviceutils::GooglePlayServicesStatus fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
53
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
54
|
+
return margelo::nitro::reactnativedeviceutils::GooglePlayServicesStatus(
|
|
55
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "status")),
|
|
56
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isAvailable"))
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativedeviceutils::GooglePlayServicesStatus& arg) {
|
|
60
|
+
jsi::Object obj(runtime);
|
|
61
|
+
obj.setProperty(runtime, "status", JSIConverter<double>::toJSI(runtime, arg.status));
|
|
62
|
+
obj.setProperty(runtime, "isAvailable", JSIConverter<bool>::toJSI(runtime, arg.isAvailable));
|
|
63
|
+
return obj;
|
|
64
|
+
}
|
|
65
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
66
|
+
if (!value.isObject()) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
jsi::Object obj = value.getObject(runtime);
|
|
70
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "status"))) return false;
|
|
74
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isAvailable"))) return false;
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
} // namespace margelo::nitro
|
|
@@ -23,6 +23,15 @@ namespace margelo::nitro::reactnativedeviceutils {
|
|
|
23
23
|
prototype.registerHybridMethod("addSpanningChangedListener", &HybridReactNativeDeviceUtilsSpec::addSpanningChangedListener);
|
|
24
24
|
prototype.registerHybridMethod("removeSpanningChangedListener", &HybridReactNativeDeviceUtilsSpec::removeSpanningChangedListener);
|
|
25
25
|
prototype.registerHybridMethod("setUserInterfaceStyle", &HybridReactNativeDeviceUtilsSpec::setUserInterfaceStyle);
|
|
26
|
+
prototype.registerHybridMethod("getLaunchOptions", &HybridReactNativeDeviceUtilsSpec::getLaunchOptions);
|
|
27
|
+
prototype.registerHybridMethod("clearLaunchOptions", &HybridReactNativeDeviceUtilsSpec::clearLaunchOptions);
|
|
28
|
+
prototype.registerHybridMethod("getDeviceToken", &HybridReactNativeDeviceUtilsSpec::getDeviceToken);
|
|
29
|
+
prototype.registerHybridMethod("saveDeviceToken", &HybridReactNativeDeviceUtilsSpec::saveDeviceToken);
|
|
30
|
+
prototype.registerHybridMethod("registerDeviceToken", &HybridReactNativeDeviceUtilsSpec::registerDeviceToken);
|
|
31
|
+
prototype.registerHybridMethod("getStartupTime", &HybridReactNativeDeviceUtilsSpec::getStartupTime);
|
|
32
|
+
prototype.registerHybridMethod("exitApp", &HybridReactNativeDeviceUtilsSpec::exitApp);
|
|
33
|
+
prototype.registerHybridMethod("getCurrentWebViewPackageInfo", &HybridReactNativeDeviceUtilsSpec::getCurrentWebViewPackageInfo);
|
|
34
|
+
prototype.registerHybridMethod("isGooglePlayServicesAvailable", &HybridReactNativeDeviceUtilsSpec::isGooglePlayServicesAvailable);
|
|
26
35
|
});
|
|
27
36
|
}
|
|
28
37
|
|
|
@@ -17,12 +17,22 @@
|
|
|
17
17
|
namespace margelo::nitro::reactnativedeviceutils { struct DualScreenInfoRect; }
|
|
18
18
|
// Forward declaration of `UserInterfaceStyle` to properly resolve imports.
|
|
19
19
|
namespace margelo::nitro::reactnativedeviceutils { enum class UserInterfaceStyle; }
|
|
20
|
+
// Forward declaration of `LaunchOptions` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::reactnativedeviceutils { struct LaunchOptions; }
|
|
22
|
+
// Forward declaration of `WebViewPackageInfo` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::reactnativedeviceutils { struct WebViewPackageInfo; }
|
|
24
|
+
// Forward declaration of `GooglePlayServicesStatus` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::reactnativedeviceutils { struct GooglePlayServicesStatus; }
|
|
20
26
|
|
|
21
27
|
#include "DualScreenInfoRect.hpp"
|
|
22
28
|
#include <vector>
|
|
23
29
|
#include <NitroModules/Promise.hpp>
|
|
24
30
|
#include <functional>
|
|
25
31
|
#include "UserInterfaceStyle.hpp"
|
|
32
|
+
#include "LaunchOptions.hpp"
|
|
33
|
+
#include <string>
|
|
34
|
+
#include "WebViewPackageInfo.hpp"
|
|
35
|
+
#include "GooglePlayServicesStatus.hpp"
|
|
26
36
|
|
|
27
37
|
namespace margelo::nitro::reactnativedeviceutils {
|
|
28
38
|
|
|
@@ -64,6 +74,15 @@ namespace margelo::nitro::reactnativedeviceutils {
|
|
|
64
74
|
virtual double addSpanningChangedListener(const std::function<void(bool /* isSpanning */)>& callback) = 0;
|
|
65
75
|
virtual void removeSpanningChangedListener(double id) = 0;
|
|
66
76
|
virtual void setUserInterfaceStyle(UserInterfaceStyle style) = 0;
|
|
77
|
+
virtual std::shared_ptr<Promise<LaunchOptions>> getLaunchOptions() = 0;
|
|
78
|
+
virtual std::shared_ptr<Promise<bool>> clearLaunchOptions() = 0;
|
|
79
|
+
virtual std::shared_ptr<Promise<std::string>> getDeviceToken() = 0;
|
|
80
|
+
virtual std::shared_ptr<Promise<void>> saveDeviceToken(const std::string& token) = 0;
|
|
81
|
+
virtual std::shared_ptr<Promise<bool>> registerDeviceToken() = 0;
|
|
82
|
+
virtual std::shared_ptr<Promise<double>> getStartupTime() = 0;
|
|
83
|
+
virtual void exitApp() = 0;
|
|
84
|
+
virtual std::shared_ptr<Promise<WebViewPackageInfo>> getCurrentWebViewPackageInfo() = 0;
|
|
85
|
+
virtual std::shared_ptr<Promise<GooglePlayServicesStatus>> isGooglePlayServicesAvailable() = 0;
|
|
67
86
|
|
|
68
87
|
protected:
|
|
69
88
|
// Hybrid Setup
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LaunchOptions.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
|
+
#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
|
+
#include <string>
|
|
29
|
+
#include <optional>
|
|
30
|
+
|
|
31
|
+
namespace margelo::nitro::reactnativedeviceutils {
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A struct which can be represented as a JavaScript object (LaunchOptions).
|
|
35
|
+
*/
|
|
36
|
+
struct LaunchOptions {
|
|
37
|
+
public:
|
|
38
|
+
std::string launchType SWIFT_PRIVATE;
|
|
39
|
+
std::optional<std::string> deepLink SWIFT_PRIVATE;
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
LaunchOptions() = default;
|
|
43
|
+
explicit LaunchOptions(std::string launchType, std::optional<std::string> deepLink): launchType(launchType), deepLink(deepLink) {}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
47
|
+
|
|
48
|
+
namespace margelo::nitro {
|
|
49
|
+
|
|
50
|
+
// C++ LaunchOptions <> JS LaunchOptions (object)
|
|
51
|
+
template <>
|
|
52
|
+
struct JSIConverter<margelo::nitro::reactnativedeviceutils::LaunchOptions> final {
|
|
53
|
+
static inline margelo::nitro::reactnativedeviceutils::LaunchOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
54
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
55
|
+
return margelo::nitro::reactnativedeviceutils::LaunchOptions(
|
|
56
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "launchType")),
|
|
57
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "deepLink"))
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativedeviceutils::LaunchOptions& arg) {
|
|
61
|
+
jsi::Object obj(runtime);
|
|
62
|
+
obj.setProperty(runtime, "launchType", JSIConverter<std::string>::toJSI(runtime, arg.launchType));
|
|
63
|
+
obj.setProperty(runtime, "deepLink", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.deepLink));
|
|
64
|
+
return obj;
|
|
65
|
+
}
|
|
66
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
67
|
+
if (!value.isObject()) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
jsi::Object obj = value.getObject(runtime);
|
|
71
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "launchType"))) return false;
|
|
75
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "deepLink"))) return false;
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// WebViewPackageInfo.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
|
+
#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
|
+
#include <string>
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::reactnativedeviceutils {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A struct which can be represented as a JavaScript object (WebViewPackageInfo).
|
|
34
|
+
*/
|
|
35
|
+
struct WebViewPackageInfo {
|
|
36
|
+
public:
|
|
37
|
+
std::string packageName SWIFT_PRIVATE;
|
|
38
|
+
std::string versionName SWIFT_PRIVATE;
|
|
39
|
+
double versionCode SWIFT_PRIVATE;
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
WebViewPackageInfo() = default;
|
|
43
|
+
explicit WebViewPackageInfo(std::string packageName, std::string versionName, double versionCode): packageName(packageName), versionName(versionName), versionCode(versionCode) {}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
47
|
+
|
|
48
|
+
namespace margelo::nitro {
|
|
49
|
+
|
|
50
|
+
// C++ WebViewPackageInfo <> JS WebViewPackageInfo (object)
|
|
51
|
+
template <>
|
|
52
|
+
struct JSIConverter<margelo::nitro::reactnativedeviceutils::WebViewPackageInfo> final {
|
|
53
|
+
static inline margelo::nitro::reactnativedeviceutils::WebViewPackageInfo fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
54
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
55
|
+
return margelo::nitro::reactnativedeviceutils::WebViewPackageInfo(
|
|
56
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "packageName")),
|
|
57
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "versionName")),
|
|
58
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "versionCode"))
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativedeviceutils::WebViewPackageInfo& arg) {
|
|
62
|
+
jsi::Object obj(runtime);
|
|
63
|
+
obj.setProperty(runtime, "packageName", JSIConverter<std::string>::toJSI(runtime, arg.packageName));
|
|
64
|
+
obj.setProperty(runtime, "versionName", JSIConverter<std::string>::toJSI(runtime, arg.versionName));
|
|
65
|
+
obj.setProperty(runtime, "versionCode", JSIConverter<double>::toJSI(runtime, arg.versionCode));
|
|
66
|
+
return obj;
|
|
67
|
+
}
|
|
68
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
69
|
+
if (!value.isObject()) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
jsi::Object obj = value.getObject(runtime);
|
|
73
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "packageName"))) return false;
|
|
77
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "versionName"))) return false;
|
|
78
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "versionCode"))) return false;
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
} // namespace margelo::nitro
|
package/package.json
CHANGED
|
@@ -10,6 +10,22 @@ export interface DualScreenInfoRect {
|
|
|
10
10
|
height: number;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
export interface LaunchOptions {
|
|
14
|
+
launchType: string;
|
|
15
|
+
deepLink?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface WebViewPackageInfo {
|
|
19
|
+
packageName: string;
|
|
20
|
+
versionName: string;
|
|
21
|
+
versionCode: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface GooglePlayServicesStatus {
|
|
25
|
+
status: number;
|
|
26
|
+
isAvailable: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
13
29
|
export interface ReactNativeDeviceUtils
|
|
14
30
|
extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
|
|
15
31
|
initEventListeners(): void;
|
|
@@ -21,4 +37,19 @@ export interface ReactNativeDeviceUtils
|
|
|
21
37
|
addSpanningChangedListener(callback: (isSpanning: boolean) => void): number;
|
|
22
38
|
removeSpanningChangedListener(id: number): void;
|
|
23
39
|
setUserInterfaceStyle(style: UserInterfaceStyle): void;
|
|
40
|
+
|
|
41
|
+
// LaunchOptionsManager
|
|
42
|
+
getLaunchOptions(): Promise<LaunchOptions>;
|
|
43
|
+
clearLaunchOptions(): Promise<boolean>;
|
|
44
|
+
getDeviceToken(): Promise<string>;
|
|
45
|
+
saveDeviceToken(token: string): Promise<void>;
|
|
46
|
+
registerDeviceToken(): Promise<boolean>;
|
|
47
|
+
getStartupTime(): Promise<number>;
|
|
48
|
+
|
|
49
|
+
// ExitModule
|
|
50
|
+
exitApp(): void;
|
|
51
|
+
|
|
52
|
+
// WebView & Play Services
|
|
53
|
+
getCurrentWebViewPackageInfo(): Promise<WebViewPackageInfo>;
|
|
54
|
+
isGooglePlayServicesAvailable(): Promise<GooglePlayServicesStatus>;
|
|
24
55
|
}
|