@rnpack/utils 0.1.4 → 0.1.6
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/LICENSE +1 -1
- package/README.md +16 -26
- package/Utils.podspec +29 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +128 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/rnpack/utils/Utils.kt +10 -0
- package/android/src/main/java/com/margelo/nitro/rnpack/utils/UtilsPackage.kt +22 -0
- package/ios/Utils.swift +5 -0
- package/lib/module/Utils.nitro.js +4 -0
- package/lib/module/Utils.nitro.js.map +1 -0
- package/lib/module/constants/index.js +2 -0
- package/lib/module/constants/index.js.map +1 -1
- package/lib/module/constants/permissions.js +2 -0
- package/lib/module/constants/permissions.js.map +1 -1
- package/lib/module/constants/settings.js +2 -0
- package/lib/module/constants/settings.js.map +1 -1
- package/lib/module/hooks/index.js +2 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/usePagination.js +2 -0
- package/lib/module/hooks/usePagination.js.map +1 -1
- package/lib/module/hooks/useTimer.js +3 -1
- package/lib/module/hooks/useTimer.js.map +1 -1
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/index.js +2 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/settings.js +1 -1
- package/lib/module/utils/index.js +2 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/object.js +2 -0
- package/lib/module/utils/object.js.map +1 -1
- package/lib/module/utils/permissions.js +2 -0
- package/lib/module/utils/permissions.js.map +1 -1
- package/lib/module/utils/responsive.js +5 -3
- package/lib/module/utils/responsive.js.map +1 -1
- package/lib/module/utils/settings.js +2 -0
- package/lib/module/utils/settings.js.map +1 -1
- package/lib/module/utils/string.js +2 -0
- package/lib/module/utils/string.js.map +1 -1
- package/lib/module/utils/utils.js +2 -0
- package/lib/module/utils/utils.js.map +1 -1
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/Utils.nitro.d.ts +8 -0
- package/lib/typescript/src/Utils.nitro.d.ts.map +1 -0
- package/lib/typescript/src/constants/permissions.d.ts +4 -4
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +0 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/nitro.json +17 -0
- package/nitrogen/generated/android/c++/JHybridUtilsSpec.cpp +52 -0
- package/nitrogen/generated/android/c++/JHybridUtilsSpec.hpp +65 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnpack/utils/HybridUtilsSpec.kt +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnpack/utils/rnpack_utilsOnLoad.kt +35 -0
- package/nitrogen/generated/android/rnpack_utils+autolinking.cmake +81 -0
- package/nitrogen/generated/android/rnpack_utils+autolinking.gradle +27 -0
- package/nitrogen/generated/android/rnpack_utilsOnLoad.cpp +44 -0
- package/nitrogen/generated/android/rnpack_utilsOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/Utils+autolinking.rb +60 -0
- package/nitrogen/generated/ios/Utils-Swift-Cxx-Bridge.cpp +33 -0
- package/nitrogen/generated/ios/Utils-Swift-Cxx-Bridge.hpp +51 -0
- package/nitrogen/generated/ios/Utils-Swift-Cxx-Umbrella.hpp +43 -0
- package/nitrogen/generated/ios/UtilsAutolinking.mm +33 -0
- package/nitrogen/generated/ios/UtilsAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridUtilsSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridUtilsSpecSwift.hpp +76 -0
- package/nitrogen/generated/ios/swift/HybridUtilsSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridUtilsSpec_cxx.swift +131 -0
- package/nitrogen/generated/shared/c++/HybridUtilsSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridUtilsSpec.hpp +62 -0
- package/package.json +92 -99
- package/src/Utils.nitro.ts +6 -0
- package/src/hooks/useTimer.tsx +1 -1
- package/src/index.tsx +9 -0
- package/src/types/index.ts +0 -1
- package/src/utils/responsive.tsx +3 -3
- package/lib/commonjs/constants/index.js +0 -28
- package/lib/commonjs/constants/index.js.map +0 -1
- package/lib/commonjs/constants/permissions.js +0 -20
- package/lib/commonjs/constants/permissions.js.map +0 -1
- package/lib/commonjs/constants/settings.js +0 -17
- package/lib/commonjs/constants/settings.js.map +0 -1
- package/lib/commonjs/hooks/index.js +0 -28
- package/lib/commonjs/hooks/index.js.map +0 -1
- package/lib/commonjs/hooks/usePagination.js +0 -29
- package/lib/commonjs/hooks/usePagination.js.map +0 -1
- package/lib/commonjs/hooks/useTimer.js +0 -44
- package/lib/commonjs/hooks/useTimer.js.map +0 -1
- package/lib/commonjs/index.js +0 -50
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/package.json +0 -1
- package/lib/commonjs/types/index.js +0 -28
- package/lib/commonjs/types/index.js.map +0 -1
- package/lib/commonjs/types/settings.js +0 -2
- package/lib/commonjs/types/settings.js.map +0 -1
- package/lib/commonjs/types/storage.js +0 -2
- package/lib/commonjs/types/storage.js.map +0 -1
- package/lib/commonjs/utils/index.js +0 -72
- package/lib/commonjs/utils/index.js.map +0 -1
- package/lib/commonjs/utils/object.js +0 -32
- package/lib/commonjs/utils/object.js.map +0 -1
- package/lib/commonjs/utils/permissions.js +0 -55
- package/lib/commonjs/utils/permissions.js.map +0 -1
- package/lib/commonjs/utils/responsive.js +0 -36
- package/lib/commonjs/utils/responsive.js.map +0 -1
- package/lib/commonjs/utils/settings.js +0 -100
- package/lib/commonjs/utils/settings.js.map +0 -1
- package/lib/commonjs/utils/storage.js +0 -36
- package/lib/commonjs/utils/storage.js.map +0 -1
- package/lib/commonjs/utils/string.js +0 -60
- package/lib/commonjs/utils/string.js.map +0 -1
- package/lib/commonjs/utils/utils.js +0 -23
- package/lib/commonjs/utils/utils.js.map +0 -1
- package/lib/module/types/storage.js +0 -2
- package/lib/module/types/storage.js.map +0 -1
- package/lib/module/utils/storage.js +0 -30
- package/lib/module/utils/storage.js.map +0 -1
- package/lib/typescript/src/types/storage.d.ts +0 -16
- package/lib/typescript/src/types/storage.d.ts.map +0 -1
- package/lib/typescript/src/utils/storage.d.ts +0 -15
- package/lib/typescript/src/utils/storage.d.ts.map +0 -1
- package/src/types/storage.ts +0 -24
- package/src/utils/storage.ts +0 -45
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// UtilsAutolinking.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
public final class UtilsAutolinking {
|
|
9
|
+
public typealias bridge = margelo.nitro.rnpack_utils.bridge.swift
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of a Swift class that implements `HybridUtilsSpec`,
|
|
13
|
+
* and wraps it in a Swift class that can directly interop with C++ (`HybridUtilsSpec_cxx`)
|
|
14
|
+
*
|
|
15
|
+
* This is generated by Nitrogen and will initialize the class specified
|
|
16
|
+
* in the `"autolinking"` property of `nitro.json` (in this case, `Utils`).
|
|
17
|
+
*/
|
|
18
|
+
public static func createUtils() -> bridge.std__shared_ptr_HybridUtilsSpec_ {
|
|
19
|
+
let hybridObject = Utils()
|
|
20
|
+
return { () -> bridge.std__shared_ptr_HybridUtilsSpec_ in
|
|
21
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
22
|
+
return __cxxWrapped.getCxxPart()
|
|
23
|
+
}()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUtilsSpecSwift.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridUtilsSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::rnpack_utils {
|
|
11
|
+
} // namespace margelo::nitro::rnpack_utils
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUtilsSpecSwift.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "HybridUtilsSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridUtilsSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace Utils { class HybridUtilsSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
#include "Utils-Swift-Cxx-Umbrella.hpp"
|
|
20
|
+
|
|
21
|
+
namespace margelo::nitro::rnpack_utils {
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The C++ part of HybridUtilsSpec_cxx.swift.
|
|
25
|
+
*
|
|
26
|
+
* HybridUtilsSpecSwift (C++) accesses HybridUtilsSpec_cxx (Swift), and might
|
|
27
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
28
|
+
*
|
|
29
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
30
|
+
* the future, HybridUtilsSpec_cxx can directly inherit from the C++ class HybridUtilsSpec
|
|
31
|
+
* to simplify the whole structure and memory management.
|
|
32
|
+
*/
|
|
33
|
+
class HybridUtilsSpecSwift: public virtual HybridUtilsSpec {
|
|
34
|
+
public:
|
|
35
|
+
// Constructor from a Swift instance
|
|
36
|
+
explicit HybridUtilsSpecSwift(const Utils::HybridUtilsSpec_cxx& swiftPart):
|
|
37
|
+
HybridObject(HybridUtilsSpec::TAG),
|
|
38
|
+
_swiftPart(swiftPart) { }
|
|
39
|
+
|
|
40
|
+
public:
|
|
41
|
+
// Get the Swift part
|
|
42
|
+
inline Utils::HybridUtilsSpec_cxx& getSwiftPart() noexcept {
|
|
43
|
+
return _swiftPart;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
48
|
+
return _swiftPart.getMemorySize();
|
|
49
|
+
}
|
|
50
|
+
void dispose() noexcept override {
|
|
51
|
+
_swiftPart.dispose();
|
|
52
|
+
}
|
|
53
|
+
std::string toString() override {
|
|
54
|
+
return _swiftPart.toString();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
// Properties
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
public:
|
|
62
|
+
// Methods
|
|
63
|
+
inline double multiply(double a, double b) override {
|
|
64
|
+
auto __result = _swiftPart.multiply(std::forward<decltype(a)>(a), std::forward<decltype(b)>(b));
|
|
65
|
+
if (__result.hasError()) [[unlikely]] {
|
|
66
|
+
std::rethrow_exception(__result.error());
|
|
67
|
+
}
|
|
68
|
+
auto __value = std::move(__result.value());
|
|
69
|
+
return __value;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private:
|
|
73
|
+
Utils::HybridUtilsSpec_cxx _swiftPart;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace margelo::nitro::rnpack_utils
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUtilsSpec.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/// See ``HybridUtilsSpec``
|
|
12
|
+
public protocol HybridUtilsSpec_protocol: HybridObject {
|
|
13
|
+
// Properties
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// Methods
|
|
17
|
+
func multiply(a: Double, b: Double) throws -> Double
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public extension HybridUtilsSpec_protocol {
|
|
21
|
+
/// Default implementation of ``HybridObject.toString``
|
|
22
|
+
func toString() -> String {
|
|
23
|
+
return "[HybridObject Utils]"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// See ``HybridUtilsSpec``
|
|
28
|
+
open class HybridUtilsSpec_base {
|
|
29
|
+
private weak var cxxWrapper: HybridUtilsSpec_cxx? = nil
|
|
30
|
+
public init() { }
|
|
31
|
+
public func getCxxWrapper() -> HybridUtilsSpec_cxx {
|
|
32
|
+
#if DEBUG
|
|
33
|
+
guard self is HybridUtilsSpec else {
|
|
34
|
+
fatalError("`self` is not a `HybridUtilsSpec`! Did you accidentally inherit from `HybridUtilsSpec_base` instead of `HybridUtilsSpec`?")
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
38
|
+
return cxxWrapper
|
|
39
|
+
} else {
|
|
40
|
+
let cxxWrapper = HybridUtilsSpec_cxx(self as! HybridUtilsSpec)
|
|
41
|
+
self.cxxWrapper = cxxWrapper
|
|
42
|
+
return cxxWrapper
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A Swift base-protocol representing the Utils HybridObject.
|
|
49
|
+
* Implement this protocol to create Swift-based instances of Utils.
|
|
50
|
+
* ```swift
|
|
51
|
+
* class HybridUtils : HybridUtilsSpec {
|
|
52
|
+
* // ...
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
public typealias HybridUtilsSpec = HybridUtilsSpec_protocol & HybridUtilsSpec_base
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUtilsSpec_cxx.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A class implementation that bridges HybridUtilsSpec over to C++.
|
|
13
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
14
|
+
*
|
|
15
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
16
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
17
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
18
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
19
|
+
*/
|
|
20
|
+
open class HybridUtilsSpec_cxx {
|
|
21
|
+
/**
|
|
22
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::rnpack_utils::bridge::swift`)
|
|
23
|
+
* from `Utils-Swift-Cxx-Bridge.hpp`.
|
|
24
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
25
|
+
*/
|
|
26
|
+
public typealias bridge = margelo.nitro.rnpack_utils.bridge.swift
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Holds an instance of the `HybridUtilsSpec` Swift protocol.
|
|
30
|
+
*/
|
|
31
|
+
private var __implementation: any HybridUtilsSpec
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
35
|
+
*/
|
|
36
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridUtilsSpec_
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a new `HybridUtilsSpec_cxx` that wraps the given `HybridUtilsSpec`.
|
|
40
|
+
* All properties and methods bridge to C++ types.
|
|
41
|
+
*/
|
|
42
|
+
public init(_ implementation: any HybridUtilsSpec) {
|
|
43
|
+
self.__implementation = implementation
|
|
44
|
+
self.__cxxPart = .init()
|
|
45
|
+
/* no base class */
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the actual `HybridUtilsSpec` instance this class wraps.
|
|
50
|
+
*/
|
|
51
|
+
@inline(__always)
|
|
52
|
+
public func getHybridUtilsSpec() -> any HybridUtilsSpec {
|
|
53
|
+
return __implementation
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
58
|
+
* This acquires one additional strong reference on the object!
|
|
59
|
+
*/
|
|
60
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
61
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Casts an unsafe pointer to a `HybridUtilsSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridUtilsSpec_cxx>`.
|
|
67
|
+
* This removes one strong reference from the object!
|
|
68
|
+
*/
|
|
69
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridUtilsSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridUtilsSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
75
|
+
* The C++ part is a `std::shared_ptr<HybridUtilsSpec>`.
|
|
76
|
+
*/
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridUtilsSpec_ {
|
|
78
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
80
|
+
return cachedCxxPart
|
|
81
|
+
} else {
|
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridUtilsSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridUtilsSpec_(newCxxPart)
|
|
84
|
+
return newCxxPart
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
92
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
93
|
+
*/
|
|
94
|
+
@inline(__always)
|
|
95
|
+
public var memorySize: Int {
|
|
96
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Call dispose() on the Swift class.
|
|
101
|
+
* This _may_ be called manually from JS.
|
|
102
|
+
*/
|
|
103
|
+
@inline(__always)
|
|
104
|
+
public func dispose() {
|
|
105
|
+
self.__implementation.dispose()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Call toString() on the Swift class.
|
|
110
|
+
*/
|
|
111
|
+
@inline(__always)
|
|
112
|
+
public func toString() -> String {
|
|
113
|
+
return self.__implementation.toString()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Properties
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
// Methods
|
|
120
|
+
@inline(__always)
|
|
121
|
+
public final func multiply(a: Double, b: Double) -> bridge.Result_double_ {
|
|
122
|
+
do {
|
|
123
|
+
let __result = try self.__implementation.multiply(a: a, b: b)
|
|
124
|
+
let __resultCpp = __result
|
|
125
|
+
return bridge.create_Result_double_(__resultCpp)
|
|
126
|
+
} catch (let __error) {
|
|
127
|
+
let __exceptionPtr = __error.toCpp()
|
|
128
|
+
return bridge.create_Result_double_(__exceptionPtr)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUtilsSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridUtilsSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::rnpack_utils {
|
|
11
|
+
|
|
12
|
+
void HybridUtilsSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("multiply", &HybridUtilsSpec::multiply);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
} // namespace margelo::nitro::rnpack_utils
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUtilsSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
namespace margelo::nitro::rnpack_utils {
|
|
21
|
+
|
|
22
|
+
using namespace margelo::nitro;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* An abstract base class for `Utils`
|
|
26
|
+
* Inherit this class to create instances of `HybridUtilsSpec` in C++.
|
|
27
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
28
|
+
* @example
|
|
29
|
+
* ```cpp
|
|
30
|
+
* class HybridUtils: public HybridUtilsSpec {
|
|
31
|
+
* public:
|
|
32
|
+
* HybridUtils(...): HybridObject(TAG) { ... }
|
|
33
|
+
* // ...
|
|
34
|
+
* };
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
class HybridUtilsSpec: public virtual HybridObject {
|
|
38
|
+
public:
|
|
39
|
+
// Constructor
|
|
40
|
+
explicit HybridUtilsSpec(): HybridObject(TAG) { }
|
|
41
|
+
|
|
42
|
+
// Destructor
|
|
43
|
+
~HybridUtilsSpec() override = default;
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
// Properties
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
// Methods
|
|
51
|
+
virtual double multiply(double a, double b) = 0;
|
|
52
|
+
|
|
53
|
+
protected:
|
|
54
|
+
// Hybrid Setup
|
|
55
|
+
void loadHybridMethods() override;
|
|
56
|
+
|
|
57
|
+
protected:
|
|
58
|
+
// Tag for logging
|
|
59
|
+
static constexpr auto TAG = "Utils";
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
} // namespace margelo::nitro::rnpack_utils
|
package/package.json
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnpack/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Basic utilities will be available and ready to use",
|
|
5
|
-
"
|
|
6
|
-
"main": "./lib/commonjs/index.js",
|
|
7
|
-
"module": "./lib/module/index.js",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
8
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
9
7
|
"exports": {
|
|
10
8
|
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
11
10
|
"types": "./lib/typescript/src/index.d.ts",
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
15
14
|
},
|
|
16
15
|
"files": [
|
|
17
16
|
"src",
|
|
@@ -19,7 +18,10 @@
|
|
|
19
18
|
"android",
|
|
20
19
|
"ios",
|
|
21
20
|
"cpp",
|
|
21
|
+
"nitrogen",
|
|
22
|
+
"nitro.json",
|
|
22
23
|
"*.podspec",
|
|
24
|
+
"react-native.config.js",
|
|
23
25
|
"!ios/build",
|
|
24
26
|
"!android/build",
|
|
25
27
|
"!android/gradle",
|
|
@@ -33,12 +35,13 @@
|
|
|
33
35
|
],
|
|
34
36
|
"scripts": {
|
|
35
37
|
"example": "yarn workspace @rnpack/utils-example",
|
|
36
|
-
"
|
|
37
|
-
"typecheck": "tsc --noEmit",
|
|
38
|
-
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
39
|
-
"clean": "del-cli lib",
|
|
38
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
40
39
|
"prepare": "bob build",
|
|
41
|
-
"
|
|
40
|
+
"nitrogen": "nitrogen",
|
|
41
|
+
"typecheck": "tsc",
|
|
42
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
43
|
+
"release": "release-it patch --only-version",
|
|
44
|
+
"test": "jest"
|
|
42
45
|
},
|
|
43
46
|
"keywords": [
|
|
44
47
|
"react-native",
|
|
@@ -56,49 +59,78 @@
|
|
|
56
59
|
},
|
|
57
60
|
"homepage": "https://github.com/rnpack/utils#readme",
|
|
58
61
|
"publishConfig": {
|
|
59
|
-
"registry": "https://registry.npmjs.org/"
|
|
60
|
-
"access": "public"
|
|
62
|
+
"registry": "https://registry.npmjs.org/"
|
|
61
63
|
},
|
|
62
64
|
"devDependencies": {
|
|
63
|
-
"@commitlint/config-conventional": "^
|
|
64
|
-
"@
|
|
65
|
-
"@
|
|
66
|
-
"@
|
|
67
|
-
"@
|
|
68
|
-
"@
|
|
69
|
-
"@
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
65
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
66
|
+
"@eslint/compat": "^1.3.2",
|
|
67
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
68
|
+
"@eslint/js": "^9.35.0",
|
|
69
|
+
"@react-native/babel-preset": "0.81.1",
|
|
70
|
+
"@react-native/eslint-config": "^0.81.1",
|
|
71
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
72
|
+
"@types/jest": "^29.5.14",
|
|
73
|
+
"@types/react": "^19.1.0",
|
|
74
|
+
"buffer": "^6.0.3",
|
|
75
|
+
"commitlint": "^19.8.1",
|
|
76
|
+
"del-cli": "^6.0.0",
|
|
77
|
+
"eslint": "^9.35.0",
|
|
78
|
+
"eslint-config-prettier": "^10.1.8",
|
|
79
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
75
80
|
"jest": "^29.7.0",
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"react
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"
|
|
81
|
+
"lefthook": "^2.0.3",
|
|
82
|
+
"nitrogen": "^0.31.10",
|
|
83
|
+
"prettier": "^2.8.8",
|
|
84
|
+
"react": "19.1.0",
|
|
85
|
+
"react-native": "0.81.1",
|
|
86
|
+
"react-native-builder-bob": "^0.40.16",
|
|
87
|
+
"react-native-nitro-modules": "^0.31.10",
|
|
88
|
+
"release-it": "^19.0.4",
|
|
89
|
+
"turbo": "^2.5.6",
|
|
90
|
+
"typescript": "^5.9.2"
|
|
85
91
|
},
|
|
86
92
|
"peerDependencies": {
|
|
87
|
-
"
|
|
93
|
+
"buffer": "*",
|
|
88
94
|
"react": "*",
|
|
89
|
-
"react-native": "*"
|
|
95
|
+
"react-native": "*",
|
|
96
|
+
"react-native-nitro-modules": "^0.31.10"
|
|
90
97
|
},
|
|
91
98
|
"workspaces": [
|
|
92
99
|
"example"
|
|
93
100
|
],
|
|
94
|
-
"packageManager": "yarn@
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
"packageManager": "yarn@4.11.0",
|
|
102
|
+
"react-native-builder-bob": {
|
|
103
|
+
"source": "src",
|
|
104
|
+
"output": "lib",
|
|
105
|
+
"targets": [
|
|
106
|
+
[
|
|
107
|
+
"custom",
|
|
108
|
+
{
|
|
109
|
+
"script": "nitrogen",
|
|
110
|
+
"clean": "nitrogen/"
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
[
|
|
114
|
+
"module",
|
|
115
|
+
{
|
|
116
|
+
"esm": true
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
[
|
|
120
|
+
"typescript",
|
|
121
|
+
{
|
|
122
|
+
"project": "tsconfig.build.json"
|
|
123
|
+
}
|
|
124
|
+
]
|
|
100
125
|
]
|
|
101
126
|
},
|
|
127
|
+
"prettier": {
|
|
128
|
+
"quoteProps": "consistent",
|
|
129
|
+
"singleQuote": true,
|
|
130
|
+
"tabWidth": 2,
|
|
131
|
+
"trailingComma": "es5",
|
|
132
|
+
"useTabs": false
|
|
133
|
+
},
|
|
102
134
|
"commitlint": {
|
|
103
135
|
"extends": [
|
|
104
136
|
"@commitlint/config-conventional"
|
|
@@ -117,67 +149,28 @@
|
|
|
117
149
|
},
|
|
118
150
|
"plugins": {
|
|
119
151
|
"@release-it/conventional-changelog": {
|
|
120
|
-
"preset":
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
"eslintConfig": {
|
|
125
|
-
"root": true,
|
|
126
|
-
"extends": [
|
|
127
|
-
"@react-native",
|
|
128
|
-
"prettier"
|
|
129
|
-
],
|
|
130
|
-
"rules": {
|
|
131
|
-
"react/react-in-jsx-scope": "off",
|
|
132
|
-
"prettier/prettier": [
|
|
133
|
-
"error",
|
|
134
|
-
{
|
|
135
|
-
"quoteProps": "consistent",
|
|
136
|
-
"singleQuote": true,
|
|
137
|
-
"tabWidth": 2,
|
|
138
|
-
"trailingComma": "es5",
|
|
139
|
-
"useTabs": false
|
|
152
|
+
"preset": {
|
|
153
|
+
"name": "angular"
|
|
140
154
|
}
|
|
141
|
-
|
|
155
|
+
}
|
|
142
156
|
}
|
|
143
157
|
},
|
|
144
|
-
"
|
|
145
|
-
"
|
|
146
|
-
"
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
"quoteProps": "consistent",
|
|
150
|
-
"singleQuote": true,
|
|
151
|
-
"tabWidth": 2,
|
|
152
|
-
"trailingComma": "es5",
|
|
153
|
-
"useTabs": false
|
|
154
|
-
},
|
|
155
|
-
"react-native-builder-bob": {
|
|
156
|
-
"source": "src",
|
|
157
|
-
"output": "lib",
|
|
158
|
-
"targets": [
|
|
159
|
-
[
|
|
160
|
-
"commonjs",
|
|
161
|
-
{
|
|
162
|
-
"esm": true
|
|
163
|
-
}
|
|
164
|
-
],
|
|
165
|
-
[
|
|
166
|
-
"module",
|
|
167
|
-
{
|
|
168
|
-
"esm": true
|
|
169
|
-
}
|
|
170
|
-
],
|
|
171
|
-
[
|
|
172
|
-
"typescript",
|
|
173
|
-
{
|
|
174
|
-
"project": "tsconfig.build.json"
|
|
175
|
-
}
|
|
176
|
-
]
|
|
158
|
+
"jest": {
|
|
159
|
+
"preset": "react-native",
|
|
160
|
+
"modulePathIgnorePatterns": [
|
|
161
|
+
"<rootDir>/example/node_modules",
|
|
162
|
+
"<rootDir>/lib/"
|
|
177
163
|
]
|
|
178
164
|
},
|
|
179
165
|
"create-react-native-library": {
|
|
180
|
-
"
|
|
181
|
-
"
|
|
166
|
+
"languages": "kotlin-swift",
|
|
167
|
+
"type": "nitro-module",
|
|
168
|
+
"tools": [
|
|
169
|
+
"eslint",
|
|
170
|
+
"lefthook",
|
|
171
|
+
"release-it",
|
|
172
|
+
"jest"
|
|
173
|
+
],
|
|
174
|
+
"version": "0.55.1"
|
|
182
175
|
}
|
|
183
176
|
}
|
package/src/hooks/useTimer.tsx
CHANGED
|
@@ -18,7 +18,7 @@ function useTimer(
|
|
|
18
18
|
const today = new Date();
|
|
19
19
|
const todayUnix = today?.getTime();
|
|
20
20
|
|
|
21
|
-
const timeIntervalRef = useRef<NodeJS.Timeout>();
|
|
21
|
+
const timeIntervalRef = useRef<NodeJS.Timeout | undefined>(undefined);
|
|
22
22
|
|
|
23
23
|
const durationDate = useMemo(
|
|
24
24
|
() => (props?.targetDate ? new Date(props?.targetDate) : new Date()),
|
package/src/index.tsx
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
+
import type { Utils } from './Utils.nitro';
|
|
3
|
+
|
|
4
|
+
const UtilsHybridObject = NitroModules.createHybridObject<Utils>('Utils');
|
|
5
|
+
|
|
6
|
+
export function multiply(a: number, b: number): number {
|
|
7
|
+
return UtilsHybridObject.multiply(a, b);
|
|
8
|
+
}
|
|
9
|
+
|
|
1
10
|
export * from './utils';
|
|
2
11
|
export * from './hooks';
|
|
3
12
|
export * from './constants';
|
package/src/types/index.ts
CHANGED