@rnpack/utils 0.1.5 → 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.
Files changed (129) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +16 -26
  3. package/Utils.podspec +29 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +128 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/rnpack/utils/Utils.kt +10 -0
  10. package/android/src/main/java/com/margelo/nitro/rnpack/utils/UtilsPackage.kt +22 -0
  11. package/ios/Utils.swift +5 -0
  12. package/lib/module/Utils.nitro.js +4 -0
  13. package/lib/module/Utils.nitro.js.map +1 -0
  14. package/lib/module/constants/index.js +2 -0
  15. package/lib/module/constants/index.js.map +1 -1
  16. package/lib/module/constants/permissions.js +2 -0
  17. package/lib/module/constants/permissions.js.map +1 -1
  18. package/lib/module/constants/settings.js +2 -0
  19. package/lib/module/constants/settings.js.map +1 -1
  20. package/lib/module/hooks/index.js +2 -0
  21. package/lib/module/hooks/index.js.map +1 -1
  22. package/lib/module/hooks/usePagination.js +2 -0
  23. package/lib/module/hooks/usePagination.js.map +1 -1
  24. package/lib/module/hooks/useTimer.js +3 -1
  25. package/lib/module/hooks/useTimer.js.map +1 -1
  26. package/lib/module/index.js +7 -0
  27. package/lib/module/index.js.map +1 -1
  28. package/lib/module/types/index.js +2 -1
  29. package/lib/module/types/index.js.map +1 -1
  30. package/lib/module/types/settings.js +1 -1
  31. package/lib/module/utils/index.js +2 -1
  32. package/lib/module/utils/index.js.map +1 -1
  33. package/lib/module/utils/object.js +2 -0
  34. package/lib/module/utils/object.js.map +1 -1
  35. package/lib/module/utils/permissions.js +2 -0
  36. package/lib/module/utils/permissions.js.map +1 -1
  37. package/lib/module/utils/responsive.js +5 -3
  38. package/lib/module/utils/responsive.js.map +1 -1
  39. package/lib/module/utils/settings.js +2 -0
  40. package/lib/module/utils/settings.js.map +1 -1
  41. package/lib/module/utils/string.js +2 -0
  42. package/lib/module/utils/string.js.map +1 -1
  43. package/lib/module/utils/utils.js +2 -0
  44. package/lib/module/utils/utils.js.map +1 -1
  45. package/lib/typescript/package.json +1 -0
  46. package/lib/typescript/src/Utils.nitro.d.ts +8 -0
  47. package/lib/typescript/src/Utils.nitro.d.ts.map +1 -0
  48. package/lib/typescript/src/constants/permissions.d.ts +4 -4
  49. package/lib/typescript/src/index.d.ts +1 -0
  50. package/lib/typescript/src/index.d.ts.map +1 -1
  51. package/lib/typescript/src/types/index.d.ts +0 -1
  52. package/lib/typescript/src/types/index.d.ts.map +1 -1
  53. package/lib/typescript/src/utils/index.d.ts +0 -1
  54. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  55. package/nitro.json +17 -0
  56. package/nitrogen/generated/android/c++/JHybridUtilsSpec.cpp +52 -0
  57. package/nitrogen/generated/android/c++/JHybridUtilsSpec.hpp +65 -0
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnpack/utils/HybridUtilsSpec.kt +57 -0
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnpack/utils/rnpack_utilsOnLoad.kt +35 -0
  60. package/nitrogen/generated/android/rnpack_utils+autolinking.cmake +81 -0
  61. package/nitrogen/generated/android/rnpack_utils+autolinking.gradle +27 -0
  62. package/nitrogen/generated/android/rnpack_utilsOnLoad.cpp +44 -0
  63. package/nitrogen/generated/android/rnpack_utilsOnLoad.hpp +25 -0
  64. package/nitrogen/generated/ios/Utils+autolinking.rb +60 -0
  65. package/nitrogen/generated/ios/Utils-Swift-Cxx-Bridge.cpp +33 -0
  66. package/nitrogen/generated/ios/Utils-Swift-Cxx-Bridge.hpp +51 -0
  67. package/nitrogen/generated/ios/Utils-Swift-Cxx-Umbrella.hpp +43 -0
  68. package/nitrogen/generated/ios/UtilsAutolinking.mm +33 -0
  69. package/nitrogen/generated/ios/UtilsAutolinking.swift +25 -0
  70. package/nitrogen/generated/ios/c++/HybridUtilsSpecSwift.cpp +11 -0
  71. package/nitrogen/generated/ios/c++/HybridUtilsSpecSwift.hpp +76 -0
  72. package/nitrogen/generated/ios/swift/HybridUtilsSpec.swift +56 -0
  73. package/nitrogen/generated/ios/swift/HybridUtilsSpec_cxx.swift +131 -0
  74. package/nitrogen/generated/shared/c++/HybridUtilsSpec.cpp +21 -0
  75. package/nitrogen/generated/shared/c++/HybridUtilsSpec.hpp +62 -0
  76. package/package.json +94 -94
  77. package/src/Utils.nitro.ts +6 -0
  78. package/src/hooks/useTimer.tsx +1 -1
  79. package/src/index.tsx +9 -0
  80. package/src/types/index.ts +0 -1
  81. package/src/utils/index.ts +0 -1
  82. package/src/utils/responsive.tsx +3 -3
  83. package/lib/commonjs/constants/index.js +0 -28
  84. package/lib/commonjs/constants/index.js.map +0 -1
  85. package/lib/commonjs/constants/permissions.js +0 -20
  86. package/lib/commonjs/constants/permissions.js.map +0 -1
  87. package/lib/commonjs/constants/settings.js +0 -17
  88. package/lib/commonjs/constants/settings.js.map +0 -1
  89. package/lib/commonjs/hooks/index.js +0 -28
  90. package/lib/commonjs/hooks/index.js.map +0 -1
  91. package/lib/commonjs/hooks/usePagination.js +0 -29
  92. package/lib/commonjs/hooks/usePagination.js.map +0 -1
  93. package/lib/commonjs/hooks/useTimer.js +0 -44
  94. package/lib/commonjs/hooks/useTimer.js.map +0 -1
  95. package/lib/commonjs/index.js +0 -50
  96. package/lib/commonjs/index.js.map +0 -1
  97. package/lib/commonjs/package.json +0 -1
  98. package/lib/commonjs/types/index.js +0 -28
  99. package/lib/commonjs/types/index.js.map +0 -1
  100. package/lib/commonjs/types/settings.js +0 -2
  101. package/lib/commonjs/types/settings.js.map +0 -1
  102. package/lib/commonjs/types/storage.js +0 -2
  103. package/lib/commonjs/types/storage.js.map +0 -1
  104. package/lib/commonjs/utils/index.js +0 -83
  105. package/lib/commonjs/utils/index.js.map +0 -1
  106. package/lib/commonjs/utils/object.js +0 -32
  107. package/lib/commonjs/utils/object.js.map +0 -1
  108. package/lib/commonjs/utils/permissions.js +0 -55
  109. package/lib/commonjs/utils/permissions.js.map +0 -1
  110. package/lib/commonjs/utils/responsive.js +0 -36
  111. package/lib/commonjs/utils/responsive.js.map +0 -1
  112. package/lib/commonjs/utils/settings.js +0 -100
  113. package/lib/commonjs/utils/settings.js.map +0 -1
  114. package/lib/commonjs/utils/storage.js +0 -36
  115. package/lib/commonjs/utils/storage.js.map +0 -1
  116. package/lib/commonjs/utils/string.js +0 -60
  117. package/lib/commonjs/utils/string.js.map +0 -1
  118. package/lib/commonjs/utils/utils.js +0 -23
  119. package/lib/commonjs/utils/utils.js.map +0 -1
  120. package/lib/module/types/storage.js +0 -2
  121. package/lib/module/types/storage.js.map +0 -1
  122. package/lib/module/utils/storage.js +0 -30
  123. package/lib/module/utils/storage.js.map +0 -1
  124. package/lib/typescript/src/types/storage.d.ts +0 -16
  125. package/lib/typescript/src/types/storage.d.ts.map +0 -1
  126. package/lib/typescript/src/utils/storage.d.ts +0 -15
  127. package/lib/typescript/src/utils/storage.d.ts.map +0 -1
  128. package/src/types/storage.ts +0 -24
  129. package/src/utils/storage.ts +0 -45
@@ -0,0 +1,33 @@
1
+ ///
2
+ /// UtilsAutolinking.mm
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/Foundation.h>
9
+ #import <NitroModules/HybridObjectRegistry.hpp>
10
+ #import "Utils-Swift-Cxx-Umbrella.hpp"
11
+ #import <type_traits>
12
+
13
+ #include "HybridUtilsSpecSwift.hpp"
14
+
15
+ @interface UtilsAutolinking : NSObject
16
+ @end
17
+
18
+ @implementation UtilsAutolinking
19
+
20
+ + (void) load {
21
+ using namespace margelo::nitro;
22
+ using namespace margelo::nitro::rnpack_utils;
23
+
24
+ HybridObjectRegistry::registerHybridObjectConstructor(
25
+ "Utils",
26
+ []() -> std::shared_ptr<HybridObject> {
27
+ std::shared_ptr<HybridUtilsSpec> hybridObject = Utils::UtilsAutolinking::createUtils();
28
+ return hybridObject;
29
+ }
30
+ );
31
+ }
32
+
33
+ @end
@@ -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.5",
3
+ "version": "0.1.6",
4
4
  "description": "Basic utilities will be available and ready to use",
5
- "source": "./src/index.tsx",
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
- "import": "./lib/module/index.js",
13
- "require": "./lib/commonjs/index.js"
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
- "test": "jest",
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
- "release": "release-it"
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,42 +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": "^17.0.2",
64
- "@evilmartians/lefthook": "^1.5.0",
65
- "@react-native-async-storage/async-storage": "^1.24.0",
66
- "@react-native/eslint-config": "^0.73.1",
67
- "@release-it/conventional-changelog": "^5.0.0",
68
- "@types/jest": "^29.5.5",
69
- "@types/react": "^18.2.44",
70
- "commitlint": "^17.0.2",
71
- "del-cli": "^5.1.0",
72
- "eslint": "^8.51.0",
73
- "eslint-config-prettier": "^9.0.0",
74
- "eslint-plugin-prettier": "^5.0.1",
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
- "prettier": "^3.0.3",
77
- "react": "18.2.0",
78
- "react-native": "0.74.3",
79
- "react-native-builder-bob": "^0.26.0",
80
- "release-it": "^15.0.0",
81
- "typescript": "^5.2.2"
82
- },
83
- "resolutions": {
84
- "@types/react": "^18.2.44"
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
- "@react-native-async-storage/async-storage": "*",
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@3.6.1",
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
+ ]
125
+ ]
126
+ },
127
+ "prettier": {
128
+ "quoteProps": "consistent",
129
+ "singleQuote": true,
130
+ "tabWidth": 2,
131
+ "trailingComma": "es5",
132
+ "useTabs": false
133
+ },
95
134
  "commitlint": {
96
135
  "extends": [
97
136
  "@commitlint/config-conventional"
@@ -110,67 +149,28 @@
110
149
  },
111
150
  "plugins": {
112
151
  "@release-it/conventional-changelog": {
113
- "preset": "angular"
114
- }
115
- }
116
- },
117
- "eslintConfig": {
118
- "root": true,
119
- "extends": [
120
- "@react-native",
121
- "prettier"
122
- ],
123
- "rules": {
124
- "react/react-in-jsx-scope": "off",
125
- "prettier/prettier": [
126
- "error",
127
- {
128
- "quoteProps": "consistent",
129
- "singleQuote": true,
130
- "tabWidth": 2,
131
- "trailingComma": "es5",
132
- "useTabs": false
152
+ "preset": {
153
+ "name": "angular"
133
154
  }
134
- ]
155
+ }
135
156
  }
136
157
  },
137
- "eslintIgnore": [
138
- "node_modules/",
139
- "lib/"
140
- ],
141
- "prettier": {
142
- "quoteProps": "consistent",
143
- "singleQuote": true,
144
- "tabWidth": 2,
145
- "trailingComma": "es5",
146
- "useTabs": false
147
- },
148
- "react-native-builder-bob": {
149
- "source": "src",
150
- "output": "lib",
151
- "targets": [
152
- [
153
- "commonjs",
154
- {
155
- "esm": true
156
- }
157
- ],
158
- [
159
- "module",
160
- {
161
- "esm": true
162
- }
163
- ],
164
- [
165
- "typescript",
166
- {
167
- "project": "tsconfig.build.json"
168
- }
169
- ]
158
+ "jest": {
159
+ "preset": "react-native",
160
+ "modulePathIgnorePatterns": [
161
+ "<rootDir>/example/node_modules",
162
+ "<rootDir>/lib/"
170
163
  ]
171
164
  },
172
165
  "create-react-native-library": {
173
- "type": "library",
174
- "version": "0.38.2"
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"
175
175
  }
176
176
  }
@@ -0,0 +1,6 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+
3
+ export interface Utils
4
+ extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
5
+ multiply(a: number, b: number): number;
6
+ }
@@ -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()),