@onekeyfe/react-native-device-utils 6.7.0-6 → 6.7.0-61
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/README.md +117 -87
- package/android/src/main/java/com/margelo/nitro/reactnativedeviceutils/ReactNativeDeviceUtils.kt +156 -35
- package/ios/DualScreenDetector.swift +170 -0
- package/ios/MainMenuController.swift +170 -0
- package/ios/ReactNativeDeviceUtils.swift +29 -4
- package/ios/WindowControlsInsetsObserver.swift +151 -0
- package/lib/typescript/src/ReactNativeDeviceUtils.nitro.d.ts +46 -0
- package/nitrogen/generated/android/c++/JFunc_void_MainMenuCommand.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_WindowControlsInsets.hpp +77 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.cpp +45 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeDeviceUtilsSpec.hpp +6 -0
- package/nitrogen/generated/android/c++/JMainMenuCommand.hpp +61 -0
- package/nitrogen/generated/android/c++/JMainMenuConfig.hpp +90 -0
- package/nitrogen/generated/android/c++/JMainMenuLink.hpp +61 -0
- package/nitrogen/generated/android/c++/JWindowControlsInsets.hpp +69 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/Func_void_MainMenuCommand.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/Func_void_WindowControlsInsets.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/HybridReactNativeDeviceUtilsSpec.kt +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/MainMenuCommand.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/MainMenuConfig.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/MainMenuLink.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativedeviceutils/WindowControlsInsets.kt +66 -0
- package/nitrogen/generated/android/reactnativedeviceutilsOnLoad.cpp +4 -0
- package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Bridge.cpp +16 -0
- package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Bridge.hpp +73 -0
- package/nitrogen/generated/ios/ReactNativeDeviceUtils-Swift-Cxx-Umbrella.hpp +12 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeDeviceUtilsSpecSwift.hpp +55 -1
- package/nitrogen/generated/ios/swift/Func_void_MainMenuCommand.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_WindowControlsInsets.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec.swift +6 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeDeviceUtilsSpec_cxx.swift +79 -0
- package/nitrogen/generated/ios/swift/MainMenuCommand.swift +44 -0
- package/nitrogen/generated/ios/swift/MainMenuConfig.swift +50 -0
- package/nitrogen/generated/ios/swift/MainMenuLink.swift +34 -0
- package/nitrogen/generated/ios/swift/WindowControlsInsets.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.cpp +6 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeDeviceUtilsSpec.hpp +15 -0
- package/nitrogen/generated/shared/c++/MainMenuCommand.hpp +80 -0
- package/nitrogen/generated/shared/c++/MainMenuConfig.hpp +98 -0
- package/nitrogen/generated/shared/c++/MainMenuLink.hpp +87 -0
- package/nitrogen/generated/shared/c++/WindowControlsInsets.hpp +95 -0
- package/package.json +8 -7
- package/src/ReactNativeDeviceUtils.nitro.ts +54 -0
|
@@ -17,6 +17,12 @@
|
|
|
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 `WindowControlsInsets` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::reactnativedeviceutils { struct WindowControlsInsets; }
|
|
22
|
+
// Forward declaration of `MainMenuConfig` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::reactnativedeviceutils { struct MainMenuConfig; }
|
|
24
|
+
// Forward declaration of `MainMenuCommand` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::reactnativedeviceutils { enum class MainMenuCommand; }
|
|
20
26
|
// Forward declaration of `LaunchOptions` to properly resolve imports.
|
|
21
27
|
namespace margelo::nitro::reactnativedeviceutils { struct LaunchOptions; }
|
|
22
28
|
// Forward declaration of `WebViewPackageInfo` to properly resolve imports.
|
|
@@ -33,6 +39,9 @@ namespace margelo::nitro::reactnativedeviceutils { enum class InstallerPackageNa
|
|
|
33
39
|
#include <NitroModules/Promise.hpp>
|
|
34
40
|
#include <functional>
|
|
35
41
|
#include "UserInterfaceStyle.hpp"
|
|
42
|
+
#include "WindowControlsInsets.hpp"
|
|
43
|
+
#include "MainMenuConfig.hpp"
|
|
44
|
+
#include "MainMenuCommand.hpp"
|
|
36
45
|
#include "LaunchOptions.hpp"
|
|
37
46
|
#include <string>
|
|
38
47
|
#include <variant>
|
|
@@ -83,6 +92,12 @@ namespace margelo::nitro::reactnativedeviceutils {
|
|
|
83
92
|
virtual double addSpanningChangedListener(const std::function<void(bool /* isSpanning */)>& callback) = 0;
|
|
84
93
|
virtual void removeSpanningChangedListener(double id) = 0;
|
|
85
94
|
virtual void setUserInterfaceStyle(UserInterfaceStyle style) = 0;
|
|
95
|
+
virtual WindowControlsInsets getWindowControlsInsets() = 0;
|
|
96
|
+
virtual double addWindowControlsInsetsChangedListener(const std::function<void(const WindowControlsInsets& /* insets */)>& callback) = 0;
|
|
97
|
+
virtual void removeWindowControlsInsetsChangedListener(double id) = 0;
|
|
98
|
+
virtual void setMainMenuConfig(const MainMenuConfig& config) = 0;
|
|
99
|
+
virtual double addMainMenuCommandListener(const std::function<void(MainMenuCommand /* command */)>& callback) = 0;
|
|
100
|
+
virtual void removeMainMenuCommandListener(double id) = 0;
|
|
86
101
|
virtual std::shared_ptr<Promise<LaunchOptions>> getLaunchOptions() = 0;
|
|
87
102
|
virtual std::shared_ptr<Promise<bool>> clearLaunchOptions() = 0;
|
|
88
103
|
virtual std::shared_ptr<Promise<std::string>> getDeviceToken() = 0;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// MainMenuCommand.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/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::reactnativedeviceutils {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (MainMenuCommand).
|
|
30
|
+
*/
|
|
31
|
+
enum class MainMenuCommand {
|
|
32
|
+
ABOUT SWIFT_NAME(about) = 0,
|
|
33
|
+
PREFERENCES SWIFT_NAME(preferences) = 1,
|
|
34
|
+
LOCKNOW SWIFT_NAME(locknow) = 2,
|
|
35
|
+
} CLOSED_ENUM;
|
|
36
|
+
|
|
37
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro {
|
|
40
|
+
|
|
41
|
+
// C++ MainMenuCommand <> JS MainMenuCommand (union)
|
|
42
|
+
template <>
|
|
43
|
+
struct JSIConverter<margelo::nitro::reactnativedeviceutils::MainMenuCommand> final {
|
|
44
|
+
static inline margelo::nitro::reactnativedeviceutils::MainMenuCommand fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
45
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
46
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
47
|
+
case hashString("about"): return margelo::nitro::reactnativedeviceutils::MainMenuCommand::ABOUT;
|
|
48
|
+
case hashString("preferences"): return margelo::nitro::reactnativedeviceutils::MainMenuCommand::PREFERENCES;
|
|
49
|
+
case hashString("lockNow"): return margelo::nitro::reactnativedeviceutils::MainMenuCommand::LOCKNOW;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum MainMenuCommand - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::reactnativedeviceutils::MainMenuCommand arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case margelo::nitro::reactnativedeviceutils::MainMenuCommand::ABOUT: return JSIConverter<std::string>::toJSI(runtime, "about");
|
|
57
|
+
case margelo::nitro::reactnativedeviceutils::MainMenuCommand::PREFERENCES: return JSIConverter<std::string>::toJSI(runtime, "preferences");
|
|
58
|
+
case margelo::nitro::reactnativedeviceutils::MainMenuCommand::LOCKNOW: return JSIConverter<std::string>::toJSI(runtime, "lockNow");
|
|
59
|
+
default: [[unlikely]]
|
|
60
|
+
throw std::invalid_argument("Cannot convert MainMenuCommand to JS - invalid value: "
|
|
61
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
65
|
+
if (!value.isString()) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
69
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
70
|
+
case hashString("about"):
|
|
71
|
+
case hashString("preferences"):
|
|
72
|
+
case hashString("lockNow"):
|
|
73
|
+
return true;
|
|
74
|
+
default:
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// MainMenuConfig.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 `MainMenuLink` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::reactnativedeviceutils { struct MainMenuLink; }
|
|
33
|
+
|
|
34
|
+
#include <string>
|
|
35
|
+
#include "MainMenuLink.hpp"
|
|
36
|
+
#include <vector>
|
|
37
|
+
|
|
38
|
+
namespace margelo::nitro::reactnativedeviceutils {
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A struct which can be represented as a JavaScript object (MainMenuConfig).
|
|
42
|
+
*/
|
|
43
|
+
struct MainMenuConfig final {
|
|
44
|
+
public:
|
|
45
|
+
std::string aboutTitle SWIFT_PRIVATE;
|
|
46
|
+
std::string preferencesTitle SWIFT_PRIVATE;
|
|
47
|
+
std::string lockNowTitle SWIFT_PRIVATE;
|
|
48
|
+
std::vector<MainMenuLink> helpLinks SWIFT_PRIVATE;
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
MainMenuConfig() = default;
|
|
52
|
+
explicit MainMenuConfig(std::string aboutTitle, std::string preferencesTitle, std::string lockNowTitle, std::vector<MainMenuLink> helpLinks): aboutTitle(aboutTitle), preferencesTitle(preferencesTitle), lockNowTitle(lockNowTitle), helpLinks(helpLinks) {}
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
friend bool operator==(const MainMenuConfig& lhs, const MainMenuConfig& rhs) = default;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
59
|
+
|
|
60
|
+
namespace margelo::nitro {
|
|
61
|
+
|
|
62
|
+
// C++ MainMenuConfig <> JS MainMenuConfig (object)
|
|
63
|
+
template <>
|
|
64
|
+
struct JSIConverter<margelo::nitro::reactnativedeviceutils::MainMenuConfig> final {
|
|
65
|
+
static inline margelo::nitro::reactnativedeviceutils::MainMenuConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
66
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
67
|
+
return margelo::nitro::reactnativedeviceutils::MainMenuConfig(
|
|
68
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "aboutTitle"))),
|
|
69
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preferencesTitle"))),
|
|
70
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lockNowTitle"))),
|
|
71
|
+
JSIConverter<std::vector<margelo::nitro::reactnativedeviceutils::MainMenuLink>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "helpLinks")))
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativedeviceutils::MainMenuConfig& arg) {
|
|
75
|
+
jsi::Object obj(runtime);
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "aboutTitle"), JSIConverter<std::string>::toJSI(runtime, arg.aboutTitle));
|
|
77
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "preferencesTitle"), JSIConverter<std::string>::toJSI(runtime, arg.preferencesTitle));
|
|
78
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "lockNowTitle"), JSIConverter<std::string>::toJSI(runtime, arg.lockNowTitle));
|
|
79
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "helpLinks"), JSIConverter<std::vector<margelo::nitro::reactnativedeviceutils::MainMenuLink>>::toJSI(runtime, arg.helpLinks));
|
|
80
|
+
return obj;
|
|
81
|
+
}
|
|
82
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
83
|
+
if (!value.isObject()) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
jsi::Object obj = value.getObject(runtime);
|
|
87
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "aboutTitle")))) return false;
|
|
91
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "preferencesTitle")))) return false;
|
|
92
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lockNowTitle")))) return false;
|
|
93
|
+
if (!JSIConverter<std::vector<margelo::nitro::reactnativedeviceutils::MainMenuLink>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "helpLinks")))) return false;
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// MainMenuLink.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
|
+
|
|
35
|
+
namespace margelo::nitro::reactnativedeviceutils {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (MainMenuLink).
|
|
39
|
+
*/
|
|
40
|
+
struct MainMenuLink final {
|
|
41
|
+
public:
|
|
42
|
+
std::string title SWIFT_PRIVATE;
|
|
43
|
+
std::string url SWIFT_PRIVATE;
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
MainMenuLink() = default;
|
|
47
|
+
explicit MainMenuLink(std::string title, std::string url): title(title), url(url) {}
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
friend bool operator==(const MainMenuLink& lhs, const MainMenuLink& rhs) = default;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
54
|
+
|
|
55
|
+
namespace margelo::nitro {
|
|
56
|
+
|
|
57
|
+
// C++ MainMenuLink <> JS MainMenuLink (object)
|
|
58
|
+
template <>
|
|
59
|
+
struct JSIConverter<margelo::nitro::reactnativedeviceutils::MainMenuLink> final {
|
|
60
|
+
static inline margelo::nitro::reactnativedeviceutils::MainMenuLink fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
61
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
62
|
+
return margelo::nitro::reactnativedeviceutils::MainMenuLink(
|
|
63
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title"))),
|
|
64
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "url")))
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativedeviceutils::MainMenuLink& arg) {
|
|
68
|
+
jsi::Object obj(runtime);
|
|
69
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "title"), JSIConverter<std::string>::toJSI(runtime, arg.title));
|
|
70
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "url"), JSIConverter<std::string>::toJSI(runtime, arg.url));
|
|
71
|
+
return obj;
|
|
72
|
+
}
|
|
73
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
74
|
+
if (!value.isObject()) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
jsi::Object obj = value.getObject(runtime);
|
|
78
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title")))) return false;
|
|
82
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "url")))) return false;
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// WindowControlsInsets.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
|
+
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::reactnativedeviceutils {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (WindowControlsInsets).
|
|
39
|
+
*/
|
|
40
|
+
struct WindowControlsInsets final {
|
|
41
|
+
public:
|
|
42
|
+
double top SWIFT_PRIVATE;
|
|
43
|
+
double left SWIFT_PRIVATE;
|
|
44
|
+
double bottom SWIFT_PRIVATE;
|
|
45
|
+
double right SWIFT_PRIVATE;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
WindowControlsInsets() = default;
|
|
49
|
+
explicit WindowControlsInsets(double top, double left, double bottom, double right): top(top), left(left), bottom(bottom), right(right) {}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
friend bool operator==(const WindowControlsInsets& lhs, const WindowControlsInsets& rhs) = default;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
} // namespace margelo::nitro::reactnativedeviceutils
|
|
56
|
+
|
|
57
|
+
namespace margelo::nitro {
|
|
58
|
+
|
|
59
|
+
// C++ WindowControlsInsets <> JS WindowControlsInsets (object)
|
|
60
|
+
template <>
|
|
61
|
+
struct JSIConverter<margelo::nitro::reactnativedeviceutils::WindowControlsInsets> final {
|
|
62
|
+
static inline margelo::nitro::reactnativedeviceutils::WindowControlsInsets fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
63
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
64
|
+
return margelo::nitro::reactnativedeviceutils::WindowControlsInsets(
|
|
65
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "top"))),
|
|
66
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "left"))),
|
|
67
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bottom"))),
|
|
68
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "right")))
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativedeviceutils::WindowControlsInsets& arg) {
|
|
72
|
+
jsi::Object obj(runtime);
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "top"), JSIConverter<double>::toJSI(runtime, arg.top));
|
|
74
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "left"), JSIConverter<double>::toJSI(runtime, arg.left));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "bottom"), JSIConverter<double>::toJSI(runtime, arg.bottom));
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "right"), JSIConverter<double>::toJSI(runtime, arg.right));
|
|
77
|
+
return obj;
|
|
78
|
+
}
|
|
79
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
80
|
+
if (!value.isObject()) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
jsi::Object obj = value.getObject(runtime);
|
|
84
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "top")))) return false;
|
|
88
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "left")))) return false;
|
|
89
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bottom")))) return false;
|
|
90
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "right")))) return false;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
} // namespace margelo::nitro
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-device-utils",
|
|
3
|
-
"version": "6.7.0-
|
|
3
|
+
"version": "6.7.0-61",
|
|
4
4
|
"description": "Native device, launch, system appearance and boot recovery utilities for OneKey",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"@eslint/compat": "^1.3.2",
|
|
68
68
|
"@eslint/eslintrc": "^3.3.1",
|
|
69
69
|
"@eslint/js": "^9.35.0",
|
|
70
|
-
"@react-native/babel-preset": "0.
|
|
71
|
-
"@react-native/eslint-config": "0.
|
|
70
|
+
"@react-native/babel-preset": "0.88.0",
|
|
71
|
+
"@react-native/eslint-config": "0.88.0",
|
|
72
72
|
"@release-it/conventional-changelog": "^10.0.1",
|
|
73
73
|
"@types/jest": "^29.5.14",
|
|
74
|
-
"@types/react": "^19.
|
|
74
|
+
"@types/react": "^19.3.0",
|
|
75
75
|
"commitlint": "^19.8.1",
|
|
76
76
|
"del-cli": "^6.0.0",
|
|
77
77
|
"eslint": "^9.35.0",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"lefthook": "^2.0.3",
|
|
82
82
|
"nitrogen": "0.37.0",
|
|
83
83
|
"prettier": "^2.8.8",
|
|
84
|
-
"react": "19.
|
|
85
|
-
"react-native": "patch:react-native@npm%3A0.
|
|
84
|
+
"react": "19.3.0",
|
|
85
|
+
"react-native": "patch:react-native@npm%3A0.88.0#~/.yarn/patches/react-native-npm-0.88.0-60c6201dd2.patch",
|
|
86
86
|
"react-native-builder-bob": "^0.40.13",
|
|
87
87
|
"react-native-nitro-modules": "0.37.0",
|
|
88
88
|
"release-it": "^19.0.4",
|
|
@@ -90,6 +90,7 @@
|
|
|
90
90
|
"typescript": "^5.9.2"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
|
+
"@onekeyfe/react-native-native-logger": "*",
|
|
93
94
|
"react": "*",
|
|
94
95
|
"react-native": "*",
|
|
95
96
|
"react-native-nitro-modules": "0.37.0"
|
|
@@ -127,7 +128,7 @@
|
|
|
127
128
|
"useTabs": false
|
|
128
129
|
},
|
|
129
130
|
"jest": {
|
|
130
|
-
"preset": "react-native",
|
|
131
|
+
"preset": "@react-native/jest-preset",
|
|
131
132
|
"modulePathIgnorePatterns": [
|
|
132
133
|
"<rootDir>/example/node_modules",
|
|
133
134
|
"<rootDir>/lib/"
|
|
@@ -26,6 +26,39 @@ export interface DualScreenInfoRect {
|
|
|
26
26
|
height: number;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Extra room, in points beyond the safe area, that content near the window
|
|
31
|
+
* corners must leave for system window controls (the iPadOS window controls in
|
|
32
|
+
* the top-leading corner, for example). All zero when no controls are shown.
|
|
33
|
+
*/
|
|
34
|
+
export interface WindowControlsInsets {
|
|
35
|
+
top: number;
|
|
36
|
+
left: number;
|
|
37
|
+
bottom: number;
|
|
38
|
+
right: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** App commands in the iPadOS menu bar that JS performs. */
|
|
42
|
+
export type MainMenuCommand = 'about' | 'preferences' | 'lockNow';
|
|
43
|
+
|
|
44
|
+
export interface MainMenuLink {
|
|
45
|
+
title: string;
|
|
46
|
+
url: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Localized content of the custom main menu (the iPadOS menu bar). Help links
|
|
51
|
+
* open in the system browser natively; the other items notify JS. An empty
|
|
52
|
+
* `aboutTitle` removes the About item and empty `helpLinks` remove the Help
|
|
53
|
+
* menu.
|
|
54
|
+
*/
|
|
55
|
+
export interface MainMenuConfig {
|
|
56
|
+
aboutTitle: string;
|
|
57
|
+
preferencesTitle: string;
|
|
58
|
+
lockNowTitle: string;
|
|
59
|
+
helpLinks: MainMenuLink[];
|
|
60
|
+
}
|
|
61
|
+
|
|
29
62
|
export interface LaunchOptions {
|
|
30
63
|
launchType: string;
|
|
31
64
|
deepLink?: string;
|
|
@@ -67,6 +100,27 @@ export interface ReactNativeDeviceUtils
|
|
|
67
100
|
addSpanningChangedListener(callback: (isSpanning: boolean) => void): number;
|
|
68
101
|
removeSpanningChangedListener(id: number): void;
|
|
69
102
|
setUserInterfaceStyle(style: UserInterfaceStyle): void;
|
|
103
|
+
/**
|
|
104
|
+
* Window-controls insets of the app's main window, for content that adapts
|
|
105
|
+
* horizontally (a header row beside the controls). iOS 26+ reads UIKit's
|
|
106
|
+
* safe area with horizontal corner adaptation; Android and older iOS return
|
|
107
|
+
* all zeros. Listeners fire on the main thread when the value changes.
|
|
108
|
+
*/
|
|
109
|
+
getWindowControlsInsets(): WindowControlsInsets;
|
|
110
|
+
addWindowControlsInsetsChangedListener(
|
|
111
|
+
callback: (insets: WindowControlsInsets) => void
|
|
112
|
+
): number;
|
|
113
|
+
removeWindowControlsInsetsChangedListener(id: number): void;
|
|
114
|
+
/**
|
|
115
|
+
* Replaces the custom main menu content and rebuilds the menu bar. The menu
|
|
116
|
+
* only shows on iPadOS (and in windows with a menu bar); Android ignores it.
|
|
117
|
+
*/
|
|
118
|
+
setMainMenuConfig(config: MainMenuConfig): void;
|
|
119
|
+
/** Listeners fire on the main thread when the user picks an app command. */
|
|
120
|
+
addMainMenuCommandListener(
|
|
121
|
+
callback: (command: MainMenuCommand) => void
|
|
122
|
+
): number;
|
|
123
|
+
removeMainMenuCommandListener(id: number): void;
|
|
70
124
|
|
|
71
125
|
// LaunchOptionsManager
|
|
72
126
|
getLaunchOptions(): Promise<LaunchOptions>;
|