@rnpack/utils 0.1.6 → 0.1.7
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/Utils.podspec +2 -2
- package/android/CMakeLists.txt +3 -3
- package/android/build.gradle +3 -3
- package/android/gradle.properties +5 -5
- package/android/src/main/cpp/cpp-adapter.cpp +2 -2
- package/android/src/main/java/com/margelo/nitro/rnpack/utils/{Utils.kt → RNPackUtils.kt} +1 -1
- package/android/src/main/java/com/margelo/nitro/rnpack/utils/{UtilsPackage.kt → RNPackUtilsPackage.kt} +2 -2
- package/ios/{Utils.swift → RNPackUtils.swift} +1 -1
- package/lib/module/RNPackUtils.nitro.js +4 -0
- package/lib/module/RNPackUtils.nitro.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/{Utils.nitro.d.ts → RNPackUtils.nitro.d.ts} +2 -2
- package/lib/typescript/src/RNPackUtils.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/nitro.json +16 -9
- package/nitrogen/generated/android/{rnpack_utils+autolinking.cmake → RNPackUtils+autolinking.cmake} +10 -10
- package/nitrogen/generated/android/{rnpack_utils+autolinking.gradle → RNPackUtils+autolinking.gradle} +3 -3
- package/nitrogen/generated/android/{rnpack_utilsOnLoad.cpp → RNPackUtilsOnLoad.cpp} +10 -10
- package/nitrogen/generated/android/{rnpack_utilsOnLoad.hpp → RNPackUtilsOnLoad.hpp} +5 -5
- package/nitrogen/generated/android/c++/{JHybridUtilsSpec.cpp → JHybridRNPackUtilsSpec.cpp} +11 -11
- package/nitrogen/generated/android/c++/{JHybridUtilsSpec.hpp → JHybridRNPackUtilsSpec.hpp} +12 -12
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnpack/utils/{HybridUtilsSpec.kt → HybridRNPackUtilsSpec.kt} +6 -6
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rnpack/utils/{rnpack_utilsOnLoad.kt → RNPackUtilsOnLoad.kt} +8 -8
- package/nitrogen/generated/ios/{Utils+autolinking.rb → RNPackUtils+autolinking.rb} +4 -4
- package/nitrogen/generated/ios/RNPackUtils-Swift-Cxx-Bridge.cpp +33 -0
- package/nitrogen/generated/ios/RNPackUtils-Swift-Cxx-Bridge.hpp +51 -0
- package/nitrogen/generated/ios/{Utils-Swift-Cxx-Umbrella.hpp → RNPackUtils-Swift-Cxx-Umbrella.hpp} +13 -13
- package/nitrogen/generated/ios/{UtilsAutolinking.mm → RNPackUtilsAutolinking.mm} +8 -8
- package/nitrogen/generated/ios/{UtilsAutolinking.swift → RNPackUtilsAutolinking.swift} +9 -9
- package/nitrogen/generated/ios/c++/HybridRNPackUtilsSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/{HybridUtilsSpecSwift.hpp → HybridRNPackUtilsSpecSwift.hpp} +15 -15
- package/nitrogen/generated/ios/swift/HybridRNPackUtilsSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/{HybridUtilsSpec_cxx.swift → HybridRNPackUtilsSpec_cxx.swift} +21 -21
- package/nitrogen/generated/shared/c++/{HybridUtilsSpec.cpp → HybridRNPackUtilsSpec.cpp} +6 -6
- package/nitrogen/generated/shared/c++/{HybridUtilsSpec.hpp → HybridRNPackUtilsSpec.hpp} +11 -11
- package/package.json +2 -2
- package/src/{Utils.nitro.ts → RNPackUtils.nitro.ts} +1 -1
- package/src/index.tsx +3 -2
- package/lib/module/Utils.nitro.js +0 -4
- package/lib/module/Utils.nitro.js.map +0 -1
- package/lib/typescript/src/Utils.nitro.d.ts.map +0 -1
- package/nitrogen/generated/ios/Utils-Swift-Cxx-Bridge.cpp +0 -33
- package/nitrogen/generated/ios/Utils-Swift-Cxx-Bridge.hpp +0 -51
- package/nitrogen/generated/ios/c++/HybridUtilsSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/swift/HybridUtilsSpec.swift +0 -56
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// RNPackUtils-Swift-Cxx-Bridge.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
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridRNPackUtilsSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::RNPackUtils { class HybridRNPackUtilsSpec; }
|
|
13
|
+
|
|
14
|
+
// Forward declarations of Swift defined types
|
|
15
|
+
// Forward declaration of `HybridRNPackUtilsSpec_cxx` to properly resolve imports.
|
|
16
|
+
namespace RNPackUtils { class HybridRNPackUtilsSpec_cxx; }
|
|
17
|
+
|
|
18
|
+
// Include C++ defined types
|
|
19
|
+
#include "HybridRNPackUtilsSpec.hpp"
|
|
20
|
+
#include <NitroModules/Result.hpp>
|
|
21
|
+
#include <exception>
|
|
22
|
+
#include <memory>
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Contains specialized versions of C++ templated types so they can be accessed from Swift,
|
|
26
|
+
* as well as helper functions to interact with those C++ types from Swift.
|
|
27
|
+
*/
|
|
28
|
+
namespace margelo::nitro::RNPackUtils::bridge::swift {
|
|
29
|
+
|
|
30
|
+
// pragma MARK: std::shared_ptr<HybridRNPackUtilsSpec>
|
|
31
|
+
/**
|
|
32
|
+
* Specialized version of `std::shared_ptr<HybridRNPackUtilsSpec>`.
|
|
33
|
+
*/
|
|
34
|
+
using std__shared_ptr_HybridRNPackUtilsSpec_ = std::shared_ptr<HybridRNPackUtilsSpec>;
|
|
35
|
+
std::shared_ptr<HybridRNPackUtilsSpec> create_std__shared_ptr_HybridRNPackUtilsSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
36
|
+
void* NON_NULL get_std__shared_ptr_HybridRNPackUtilsSpec_(std__shared_ptr_HybridRNPackUtilsSpec_ cppType);
|
|
37
|
+
|
|
38
|
+
// pragma MARK: std::weak_ptr<HybridRNPackUtilsSpec>
|
|
39
|
+
using std__weak_ptr_HybridRNPackUtilsSpec_ = std::weak_ptr<HybridRNPackUtilsSpec>;
|
|
40
|
+
inline std__weak_ptr_HybridRNPackUtilsSpec_ weakify_std__shared_ptr_HybridRNPackUtilsSpec_(const std::shared_ptr<HybridRNPackUtilsSpec>& strong) noexcept { return strong; }
|
|
41
|
+
|
|
42
|
+
// pragma MARK: Result<double>
|
|
43
|
+
using Result_double_ = Result<double>;
|
|
44
|
+
inline Result_double_ create_Result_double_(double value) noexcept {
|
|
45
|
+
return Result<double>::withValue(std::move(value));
|
|
46
|
+
}
|
|
47
|
+
inline Result_double_ create_Result_double_(const std::exception_ptr& error) noexcept {
|
|
48
|
+
return Result<double>::withError(error);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
} // namespace margelo::nitro::RNPackUtils::bridge::swift
|
package/nitrogen/generated/ios/{Utils-Swift-Cxx-Umbrella.hpp → RNPackUtils-Swift-Cxx-Umbrella.hpp}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// RNPackUtils-Swift-Cxx-Umbrella.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
10
|
// Forward declarations of C++ defined types
|
|
11
|
-
// Forward declaration of `
|
|
12
|
-
namespace margelo::nitro::
|
|
11
|
+
// Forward declaration of `HybridRNPackUtilsSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::RNPackUtils { class HybridRNPackUtilsSpec; }
|
|
13
13
|
|
|
14
14
|
// Include C++ defined types
|
|
15
|
-
#include "
|
|
15
|
+
#include "HybridRNPackUtilsSpec.hpp"
|
|
16
16
|
#include <NitroModules/Result.hpp>
|
|
17
17
|
#include <exception>
|
|
18
18
|
#include <memory>
|
|
19
19
|
|
|
20
20
|
// C++ helpers for Swift
|
|
21
|
-
#include "
|
|
21
|
+
#include "RNPackUtils-Swift-Cxx-Bridge.hpp"
|
|
22
22
|
|
|
23
23
|
// Common C++ types used in Swift
|
|
24
24
|
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
@@ -27,17 +27,17 @@ namespace margelo::nitro::rnpack_utils { class HybridUtilsSpec; }
|
|
|
27
27
|
#include <NitroModules/DateToChronoDate.hpp>
|
|
28
28
|
|
|
29
29
|
// Forward declarations of Swift defined types
|
|
30
|
-
// Forward declaration of `
|
|
31
|
-
namespace
|
|
30
|
+
// Forward declaration of `HybridRNPackUtilsSpec_cxx` to properly resolve imports.
|
|
31
|
+
namespace RNPackUtils { class HybridRNPackUtilsSpec_cxx; }
|
|
32
32
|
|
|
33
33
|
// Include Swift defined types
|
|
34
|
-
#if __has_include("
|
|
34
|
+
#if __has_include("RNPackUtils-Swift.h")
|
|
35
35
|
// This header is generated by Xcode/Swift on every app build.
|
|
36
|
-
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "
|
|
37
|
-
#include "
|
|
36
|
+
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "RNPackUtils".
|
|
37
|
+
#include "RNPackUtils-Swift.h"
|
|
38
38
|
// Same as above, but used when building with frameworks (`use_frameworks`)
|
|
39
|
-
#elif __has_include(<
|
|
40
|
-
#include <
|
|
39
|
+
#elif __has_include(<RNPackUtils/RNPackUtils-Swift.h>)
|
|
40
|
+
#include <RNPackUtils/RNPackUtils-Swift.h>
|
|
41
41
|
#else
|
|
42
|
-
#error
|
|
42
|
+
#error RNPackUtils's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "RNPackUtils", and try building the app first.
|
|
43
43
|
#endif
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// RNPackUtilsAutolinking.mm
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
@@ -7,24 +7,24 @@
|
|
|
7
7
|
|
|
8
8
|
#import <Foundation/Foundation.h>
|
|
9
9
|
#import <NitroModules/HybridObjectRegistry.hpp>
|
|
10
|
-
#import "
|
|
10
|
+
#import "RNPackUtils-Swift-Cxx-Umbrella.hpp"
|
|
11
11
|
#import <type_traits>
|
|
12
12
|
|
|
13
|
-
#include "
|
|
13
|
+
#include "HybridRNPackUtilsSpecSwift.hpp"
|
|
14
14
|
|
|
15
|
-
@interface
|
|
15
|
+
@interface RNPackUtilsAutolinking : NSObject
|
|
16
16
|
@end
|
|
17
17
|
|
|
18
|
-
@implementation
|
|
18
|
+
@implementation RNPackUtilsAutolinking
|
|
19
19
|
|
|
20
20
|
+ (void) load {
|
|
21
21
|
using namespace margelo::nitro;
|
|
22
|
-
using namespace margelo::nitro::
|
|
22
|
+
using namespace margelo::nitro::RNPackUtils;
|
|
23
23
|
|
|
24
24
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
|
-
"
|
|
25
|
+
"RNPackUtils",
|
|
26
26
|
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
-
std::shared_ptr<
|
|
27
|
+
std::shared_ptr<HybridRNPackUtilsSpec> hybridObject = RNPackUtils::RNPackUtilsAutolinking::createRNPackUtils();
|
|
28
28
|
return hybridObject;
|
|
29
29
|
}
|
|
30
30
|
);
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// RNPackUtilsAutolinking.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
-
public final class
|
|
9
|
-
public typealias bridge = margelo.nitro.
|
|
8
|
+
public final class RNPackUtilsAutolinking {
|
|
9
|
+
public typealias bridge = margelo.nitro.RNPackUtils.bridge.swift
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Creates an instance of a Swift class that implements `
|
|
13
|
-
* and wraps it in a Swift class that can directly interop with C++ (`
|
|
12
|
+
* Creates an instance of a Swift class that implements `HybridRNPackUtilsSpec`,
|
|
13
|
+
* and wraps it in a Swift class that can directly interop with C++ (`HybridRNPackUtilsSpec_cxx`)
|
|
14
14
|
*
|
|
15
15
|
* This is generated by Nitrogen and will initialize the class specified
|
|
16
|
-
* in the `"autolinking"` property of `nitro.json` (in this case, `
|
|
16
|
+
* in the `"autolinking"` property of `nitro.json` (in this case, `RNPackUtils`).
|
|
17
17
|
*/
|
|
18
|
-
public static func
|
|
19
|
-
let hybridObject =
|
|
20
|
-
return { () -> bridge.
|
|
18
|
+
public static func createRNPackUtils() -> bridge.std__shared_ptr_HybridRNPackUtilsSpec_ {
|
|
19
|
+
let hybridObject = RNPackUtils()
|
|
20
|
+
return { () -> bridge.std__shared_ptr_HybridRNPackUtilsSpec_ in
|
|
21
21
|
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
22
22
|
return __cxxWrapped.getCxxPart()
|
|
23
23
|
}()
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridRNPackUtilsSpecSwift.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 "HybridRNPackUtilsSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::RNPackUtils {
|
|
11
|
+
} // namespace margelo::nitro::RNPackUtils
|
package/nitrogen/generated/ios/c++/{HybridUtilsSpecSwift.hpp → HybridRNPackUtilsSpecSwift.hpp}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// HybridRNPackUtilsSpecSwift.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
@@ -7,39 +7,39 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include "
|
|
10
|
+
#include "HybridRNPackUtilsSpec.hpp"
|
|
11
11
|
|
|
12
|
-
// Forward declaration of `
|
|
13
|
-
namespace
|
|
12
|
+
// Forward declaration of `HybridRNPackUtilsSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace RNPackUtils { class HybridRNPackUtilsSpec_cxx; }
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
#include "
|
|
19
|
+
#include "RNPackUtils-Swift-Cxx-Umbrella.hpp"
|
|
20
20
|
|
|
21
|
-
namespace margelo::nitro::
|
|
21
|
+
namespace margelo::nitro::RNPackUtils {
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* The C++ part of
|
|
24
|
+
* The C++ part of HybridRNPackUtilsSpec_cxx.swift.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
26
|
+
* HybridRNPackUtilsSpecSwift (C++) accesses HybridRNPackUtilsSpec_cxx (Swift), and might
|
|
27
27
|
* contain some additional bridging code for C++ <> Swift interop.
|
|
28
28
|
*
|
|
29
29
|
* Since this obviously introduces an overhead, I hope at some point in
|
|
30
|
-
* the future,
|
|
30
|
+
* the future, HybridRNPackUtilsSpec_cxx can directly inherit from the C++ class HybridRNPackUtilsSpec
|
|
31
31
|
* to simplify the whole structure and memory management.
|
|
32
32
|
*/
|
|
33
|
-
class
|
|
33
|
+
class HybridRNPackUtilsSpecSwift: public virtual HybridRNPackUtilsSpec {
|
|
34
34
|
public:
|
|
35
35
|
// Constructor from a Swift instance
|
|
36
|
-
explicit
|
|
37
|
-
HybridObject(
|
|
36
|
+
explicit HybridRNPackUtilsSpecSwift(const RNPackUtils::HybridRNPackUtilsSpec_cxx& swiftPart):
|
|
37
|
+
HybridObject(HybridRNPackUtilsSpec::TAG),
|
|
38
38
|
_swiftPart(swiftPart) { }
|
|
39
39
|
|
|
40
40
|
public:
|
|
41
41
|
// Get the Swift part
|
|
42
|
-
inline
|
|
42
|
+
inline RNPackUtils::HybridRNPackUtilsSpec_cxx& getSwiftPart() noexcept {
|
|
43
43
|
return _swiftPart;
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -70,7 +70,7 @@ namespace margelo::nitro::rnpack_utils {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
private:
|
|
73
|
-
|
|
73
|
+
RNPackUtils::HybridRNPackUtilsSpec_cxx _swiftPart;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
} // namespace margelo::nitro::
|
|
76
|
+
} // namespace margelo::nitro::RNPackUtils
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridRNPackUtilsSpec.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 ``HybridRNPackUtilsSpec``
|
|
12
|
+
public protocol HybridRNPackUtilsSpec_protocol: HybridObject {
|
|
13
|
+
// Properties
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// Methods
|
|
17
|
+
func multiply(a: Double, b: Double) throws -> Double
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public extension HybridRNPackUtilsSpec_protocol {
|
|
21
|
+
/// Default implementation of ``HybridObject.toString``
|
|
22
|
+
func toString() -> String {
|
|
23
|
+
return "[HybridObject RNPackUtils]"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// See ``HybridRNPackUtilsSpec``
|
|
28
|
+
open class HybridRNPackUtilsSpec_base {
|
|
29
|
+
private weak var cxxWrapper: HybridRNPackUtilsSpec_cxx? = nil
|
|
30
|
+
public init() { }
|
|
31
|
+
public func getCxxWrapper() -> HybridRNPackUtilsSpec_cxx {
|
|
32
|
+
#if DEBUG
|
|
33
|
+
guard self is HybridRNPackUtilsSpec else {
|
|
34
|
+
fatalError("`self` is not a `HybridRNPackUtilsSpec`! Did you accidentally inherit from `HybridRNPackUtilsSpec_base` instead of `HybridRNPackUtilsSpec`?")
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
38
|
+
return cxxWrapper
|
|
39
|
+
} else {
|
|
40
|
+
let cxxWrapper = HybridRNPackUtilsSpec_cxx(self as! HybridRNPackUtilsSpec)
|
|
41
|
+
self.cxxWrapper = cxxWrapper
|
|
42
|
+
return cxxWrapper
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A Swift base-protocol representing the RNPackUtils HybridObject.
|
|
49
|
+
* Implement this protocol to create Swift-based instances of RNPackUtils.
|
|
50
|
+
* ```swift
|
|
51
|
+
* class HybridRNPackUtils : HybridRNPackUtilsSpec {
|
|
52
|
+
* // ...
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
public typealias HybridRNPackUtilsSpec = HybridRNPackUtilsSpec_protocol & HybridRNPackUtilsSpec_base
|
package/nitrogen/generated/ios/swift/{HybridUtilsSpec_cxx.swift → HybridRNPackUtilsSpec_cxx.swift}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// HybridRNPackUtilsSpec_cxx.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
@@ -9,7 +9,7 @@ import Foundation
|
|
|
9
9
|
import NitroModules
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* A class implementation that bridges
|
|
12
|
+
* A class implementation that bridges HybridRNPackUtilsSpec over to C++.
|
|
13
13
|
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
14
14
|
*
|
|
15
15
|
* Also, some Swift types need to be bridged with special handling:
|
|
@@ -17,39 +17,39 @@ import NitroModules
|
|
|
17
17
|
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
18
18
|
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
19
19
|
*/
|
|
20
|
-
open class
|
|
20
|
+
open class HybridRNPackUtilsSpec_cxx {
|
|
21
21
|
/**
|
|
22
|
-
* The Swift <> C++ bridge's namespace (`margelo::nitro::
|
|
23
|
-
* from `
|
|
22
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::RNPackUtils::bridge::swift`)
|
|
23
|
+
* from `RNPackUtils-Swift-Cxx-Bridge.hpp`.
|
|
24
24
|
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
25
25
|
*/
|
|
26
|
-
public typealias bridge = margelo.nitro.
|
|
26
|
+
public typealias bridge = margelo.nitro.RNPackUtils.bridge.swift
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* Holds an instance of the `
|
|
29
|
+
* Holds an instance of the `HybridRNPackUtilsSpec` Swift protocol.
|
|
30
30
|
*/
|
|
31
|
-
private var __implementation: any
|
|
31
|
+
private var __implementation: any HybridRNPackUtilsSpec
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
35
35
|
*/
|
|
36
|
-
private var __cxxPart: bridge.
|
|
36
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridRNPackUtilsSpec_
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* Create a new `
|
|
39
|
+
* Create a new `HybridRNPackUtilsSpec_cxx` that wraps the given `HybridRNPackUtilsSpec`.
|
|
40
40
|
* All properties and methods bridge to C++ types.
|
|
41
41
|
*/
|
|
42
|
-
public init(_ implementation: any
|
|
42
|
+
public init(_ implementation: any HybridRNPackUtilsSpec) {
|
|
43
43
|
self.__implementation = implementation
|
|
44
44
|
self.__cxxPart = .init()
|
|
45
45
|
/* no base class */
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* Get the actual `
|
|
49
|
+
* Get the actual `HybridRNPackUtilsSpec` instance this class wraps.
|
|
50
50
|
*/
|
|
51
51
|
@inline(__always)
|
|
52
|
-
public func
|
|
52
|
+
public func getHybridRNPackUtilsSpec() -> any HybridRNPackUtilsSpec {
|
|
53
53
|
return __implementation
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -62,25 +62,25 @@ open class HybridUtilsSpec_cxx {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* Casts an unsafe pointer to a `
|
|
66
|
-
* The pointer has to be a retained opaque `Unmanaged<
|
|
65
|
+
* Casts an unsafe pointer to a `HybridRNPackUtilsSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridRNPackUtilsSpec_cxx>`.
|
|
67
67
|
* This removes one strong reference from the object!
|
|
68
68
|
*/
|
|
69
|
-
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) ->
|
|
70
|
-
return Unmanaged<
|
|
69
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridRNPackUtilsSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridRNPackUtilsSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
75
|
-
* The C++ part is a `std::shared_ptr<
|
|
75
|
+
* The C++ part is a `std::shared_ptr<HybridRNPackUtilsSpec>`.
|
|
76
76
|
*/
|
|
77
|
-
public func getCxxPart() -> bridge.
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridRNPackUtilsSpec_ {
|
|
78
78
|
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
79
|
if Bool(fromCxx: cachedCxxPart) {
|
|
80
80
|
return cachedCxxPart
|
|
81
81
|
} else {
|
|
82
|
-
let newCxxPart = bridge.
|
|
83
|
-
__cxxPart = bridge.
|
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridRNPackUtilsSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridRNPackUtilsSpec_(newCxxPart)
|
|
84
84
|
return newCxxPart
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// HybridRNPackUtilsSpec.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
-
#include "
|
|
8
|
+
#include "HybridRNPackUtilsSpec.hpp"
|
|
9
9
|
|
|
10
|
-
namespace margelo::nitro::
|
|
10
|
+
namespace margelo::nitro::RNPackUtils {
|
|
11
11
|
|
|
12
|
-
void
|
|
12
|
+
void HybridRNPackUtilsSpec::loadHybridMethods() {
|
|
13
13
|
// load base methods/properties
|
|
14
14
|
HybridObject::loadHybridMethods();
|
|
15
15
|
// load custom methods/properties
|
|
16
16
|
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
-
prototype.registerHybridMethod("multiply", &
|
|
17
|
+
prototype.registerHybridMethod("multiply", &HybridRNPackUtilsSpec::multiply);
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
} // namespace margelo::nitro::
|
|
21
|
+
} // namespace margelo::nitro::RNPackUtils
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// HybridRNPackUtilsSpec.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
@@ -17,30 +17,30 @@
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
namespace margelo::nitro::
|
|
20
|
+
namespace margelo::nitro::RNPackUtils {
|
|
21
21
|
|
|
22
22
|
using namespace margelo::nitro;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* An abstract base class for `
|
|
26
|
-
* Inherit this class to create instances of `
|
|
25
|
+
* An abstract base class for `RNPackUtils`
|
|
26
|
+
* Inherit this class to create instances of `HybridRNPackUtilsSpec` in C++.
|
|
27
27
|
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
28
28
|
* @example
|
|
29
29
|
* ```cpp
|
|
30
|
-
* class
|
|
30
|
+
* class HybridRNPackUtils: public HybridRNPackUtilsSpec {
|
|
31
31
|
* public:
|
|
32
|
-
*
|
|
32
|
+
* HybridRNPackUtils(...): HybridObject(TAG) { ... }
|
|
33
33
|
* // ...
|
|
34
34
|
* };
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
class
|
|
37
|
+
class HybridRNPackUtilsSpec: public virtual HybridObject {
|
|
38
38
|
public:
|
|
39
39
|
// Constructor
|
|
40
|
-
explicit
|
|
40
|
+
explicit HybridRNPackUtilsSpec(): HybridObject(TAG) { }
|
|
41
41
|
|
|
42
42
|
// Destructor
|
|
43
|
-
~
|
|
43
|
+
~HybridRNPackUtilsSpec() override = default;
|
|
44
44
|
|
|
45
45
|
public:
|
|
46
46
|
// Properties
|
|
@@ -56,7 +56,7 @@ namespace margelo::nitro::rnpack_utils {
|
|
|
56
56
|
|
|
57
57
|
protected:
|
|
58
58
|
// Tag for logging
|
|
59
|
-
static constexpr auto TAG = "
|
|
59
|
+
static constexpr auto TAG = "RNPackUtils";
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
} // namespace margelo::nitro::
|
|
62
|
+
} // namespace margelo::nitro::RNPackUtils
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnpack/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Basic utilities will be available and ready to use",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"type": "git",
|
|
53
53
|
"url": "git+https://github.com/rnpack/utils.git"
|
|
54
54
|
},
|
|
55
|
-
"author": "Abiraman K <abiramancit@gmail.com> (https://github.
|
|
55
|
+
"author": "Abiraman K <abiramancit@gmail.com> (https://abiramank.github.io)",
|
|
56
56
|
"license": "MIT",
|
|
57
57
|
"bugs": {
|
|
58
58
|
"url": "https://github.com/rnpack/utils/issues"
|
package/src/index.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RNPackUtils } from './RNPackUtils.nitro';
|
|
3
3
|
|
|
4
|
-
const UtilsHybridObject =
|
|
4
|
+
const UtilsHybridObject =
|
|
5
|
+
NitroModules.createHybridObject<RNPackUtils>('RNPackUtils');
|
|
5
6
|
|
|
6
7
|
export function multiply(a: number, b: number): number {
|
|
7
8
|
return UtilsHybridObject.multiply(a, b);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["Utils.nitro.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.nitro.d.ts","sourceRoot":"","sources":["../../../src/Utils.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,KACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IACzD,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// Utils-Swift-Cxx-Bridge.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 "Utils-Swift-Cxx-Bridge.hpp"
|
|
9
|
-
|
|
10
|
-
// Include C++ implementation defined types
|
|
11
|
-
#include "HybridUtilsSpecSwift.hpp"
|
|
12
|
-
#include "Utils-Swift-Cxx-Umbrella.hpp"
|
|
13
|
-
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
-
|
|
15
|
-
namespace margelo::nitro::rnpack_utils::bridge::swift {
|
|
16
|
-
|
|
17
|
-
// pragma MARK: std::shared_ptr<HybridUtilsSpec>
|
|
18
|
-
std::shared_ptr<HybridUtilsSpec> create_std__shared_ptr_HybridUtilsSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
19
|
-
Utils::HybridUtilsSpec_cxx swiftPart = Utils::HybridUtilsSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
20
|
-
return std::make_shared<margelo::nitro::rnpack_utils::HybridUtilsSpecSwift>(swiftPart);
|
|
21
|
-
}
|
|
22
|
-
void* NON_NULL get_std__shared_ptr_HybridUtilsSpec_(std__shared_ptr_HybridUtilsSpec_ cppType) {
|
|
23
|
-
std::shared_ptr<margelo::nitro::rnpack_utils::HybridUtilsSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::rnpack_utils::HybridUtilsSpecSwift>(cppType);
|
|
24
|
-
#ifdef NITRO_DEBUG
|
|
25
|
-
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
26
|
-
throw std::runtime_error("Class \"HybridUtilsSpec\" is not implemented in Swift!");
|
|
27
|
-
}
|
|
28
|
-
#endif
|
|
29
|
-
Utils::HybridUtilsSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
30
|
-
return swiftPart.toUnsafe();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
} // namespace margelo::nitro::rnpack_utils::bridge::swift
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// Utils-Swift-Cxx-Bridge.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
|
-
// Forward declarations of C++ defined types
|
|
11
|
-
// Forward declaration of `HybridUtilsSpec` to properly resolve imports.
|
|
12
|
-
namespace margelo::nitro::rnpack_utils { class HybridUtilsSpec; }
|
|
13
|
-
|
|
14
|
-
// Forward declarations of Swift defined types
|
|
15
|
-
// Forward declaration of `HybridUtilsSpec_cxx` to properly resolve imports.
|
|
16
|
-
namespace Utils { class HybridUtilsSpec_cxx; }
|
|
17
|
-
|
|
18
|
-
// Include C++ defined types
|
|
19
|
-
#include "HybridUtilsSpec.hpp"
|
|
20
|
-
#include <NitroModules/Result.hpp>
|
|
21
|
-
#include <exception>
|
|
22
|
-
#include <memory>
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Contains specialized versions of C++ templated types so they can be accessed from Swift,
|
|
26
|
-
* as well as helper functions to interact with those C++ types from Swift.
|
|
27
|
-
*/
|
|
28
|
-
namespace margelo::nitro::rnpack_utils::bridge::swift {
|
|
29
|
-
|
|
30
|
-
// pragma MARK: std::shared_ptr<HybridUtilsSpec>
|
|
31
|
-
/**
|
|
32
|
-
* Specialized version of `std::shared_ptr<HybridUtilsSpec>`.
|
|
33
|
-
*/
|
|
34
|
-
using std__shared_ptr_HybridUtilsSpec_ = std::shared_ptr<HybridUtilsSpec>;
|
|
35
|
-
std::shared_ptr<HybridUtilsSpec> create_std__shared_ptr_HybridUtilsSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
36
|
-
void* NON_NULL get_std__shared_ptr_HybridUtilsSpec_(std__shared_ptr_HybridUtilsSpec_ cppType);
|
|
37
|
-
|
|
38
|
-
// pragma MARK: std::weak_ptr<HybridUtilsSpec>
|
|
39
|
-
using std__weak_ptr_HybridUtilsSpec_ = std::weak_ptr<HybridUtilsSpec>;
|
|
40
|
-
inline std__weak_ptr_HybridUtilsSpec_ weakify_std__shared_ptr_HybridUtilsSpec_(const std::shared_ptr<HybridUtilsSpec>& strong) noexcept { return strong; }
|
|
41
|
-
|
|
42
|
-
// pragma MARK: Result<double>
|
|
43
|
-
using Result_double_ = Result<double>;
|
|
44
|
-
inline Result_double_ create_Result_double_(double value) noexcept {
|
|
45
|
-
return Result<double>::withValue(std::move(value));
|
|
46
|
-
}
|
|
47
|
-
inline Result_double_ create_Result_double_(const std::exception_ptr& error) noexcept {
|
|
48
|
-
return Result<double>::withError(error);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
} // namespace margelo::nitro::rnpack_utils::bridge::swift
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|