@crumbsdk/react-native 0.0.1-rc.3
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/CrumbReactNative.podspec +38 -0
- package/LICENSE +201 -0
- package/README.md +109 -0
- package/android/CMakeLists.txt +20 -0
- package/android/build.gradle +118 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +10 -0
- package/android/src/main/java/com/margelo/nitro/crumbsdk/reactnative/CrumbReactNative.kt +228 -0
- package/android/src/main/java/com/margelo/nitro/crumbsdk/reactnative/ReactNativePackage.kt +22 -0
- package/ios/CrumbReactNative.swift +283 -0
- package/lib/module/CrumbReactNative.nitro.js +4 -0
- package/lib/module/CrumbReactNative.nitro.js.map +1 -0
- package/lib/module/NativeCrumbReactNative.js +5 -0
- package/lib/module/NativeCrumbReactNative.js.map +1 -0
- package/lib/module/NativeCrumbReactNative.web.js +18 -0
- package/lib/module/NativeCrumbReactNative.web.js.map +1 -0
- package/lib/module/index.js +60 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/log-buffer.js +200 -0
- package/lib/module/log-buffer.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/CrumbReactNative.nitro.d.ts +12 -0
- package/lib/typescript/src/CrumbReactNative.nitro.d.ts.map +1 -0
- package/lib/typescript/src/NativeCrumbReactNative.d.ts +4 -0
- package/lib/typescript/src/NativeCrumbReactNative.d.ts.map +1 -0
- package/lib/typescript/src/NativeCrumbReactNative.web.d.ts +4 -0
- package/lib/typescript/src/NativeCrumbReactNative.web.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +19 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/log-buffer.d.ts +8 -0
- package/lib/typescript/src/log-buffer.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +55 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/nitro.json +24 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/c++/JHybridCrumbReactNativeSpec.cpp +94 -0
- package/nitrogen/generated/android/c++/JHybridCrumbReactNativeSpec.hpp +67 -0
- package/nitrogen/generated/android/crumbsdk_reactnative+autolinking.cmake +81 -0
- package/nitrogen/generated/android/crumbsdk_reactnative+autolinking.gradle +27 -0
- package/nitrogen/generated/android/crumbsdk_reactnativeOnLoad.cpp +54 -0
- package/nitrogen/generated/android/crumbsdk_reactnativeOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/crumbsdk/reactnative/HybridCrumbReactNativeSpec.kt +73 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/crumbsdk/reactnative/crumbsdk_reactnativeOnLoad.kt +35 -0
- package/nitrogen/generated/ios/CrumbReactNative+autolinking.rb +62 -0
- package/nitrogen/generated/ios/CrumbReactNative-Swift-Cxx-Bridge.cpp +49 -0
- package/nitrogen/generated/ios/CrumbReactNative-Swift-Cxx-Bridge.hpp +119 -0
- package/nitrogen/generated/ios/CrumbReactNative-Swift-Cxx-Umbrella.hpp +45 -0
- package/nitrogen/generated/ios/CrumbReactNativeAutolinking.mm +33 -0
- package/nitrogen/generated/ios/CrumbReactNativeAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridCrumbReactNativeSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridCrumbReactNativeSpecSwift.hpp +109 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridCrumbReactNativeSpec.swift +59 -0
- package/nitrogen/generated/ios/swift/HybridCrumbReactNativeSpec_cxx.swift +197 -0
- package/nitrogen/generated/shared/c++/HybridCrumbReactNativeSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridCrumbReactNativeSpec.hpp +67 -0
- package/package.json +138 -0
- package/src/CrumbReactNative.nitro.ts +12 -0
- package/src/NativeCrumbReactNative.ts +6 -0
- package/src/NativeCrumbReactNative.web.ts +20 -0
- package/src/index.ts +115 -0
- package/src/log-buffer.ts +265 -0
- package/src/types.ts +70 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCrumbReactNativeSpecSwift.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
|
+
#include "HybridCrumbReactNativeSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridCrumbReactNativeSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace CrumbReactNative { class HybridCrumbReactNativeSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
#include <string>
|
|
18
|
+
#include <NitroModules/Promise.hpp>
|
|
19
|
+
|
|
20
|
+
#include "CrumbReactNative-Swift-Cxx-Umbrella.hpp"
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::crumbsdk_reactnative {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The C++ part of HybridCrumbReactNativeSpec_cxx.swift.
|
|
26
|
+
*
|
|
27
|
+
* HybridCrumbReactNativeSpecSwift (C++) accesses HybridCrumbReactNativeSpec_cxx (Swift), and might
|
|
28
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
29
|
+
*
|
|
30
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
31
|
+
* the future, HybridCrumbReactNativeSpec_cxx can directly inherit from the C++ class HybridCrumbReactNativeSpec
|
|
32
|
+
* to simplify the whole structure and memory management.
|
|
33
|
+
*/
|
|
34
|
+
class HybridCrumbReactNativeSpecSwift: public virtual HybridCrumbReactNativeSpec {
|
|
35
|
+
public:
|
|
36
|
+
// Constructor from a Swift instance
|
|
37
|
+
explicit HybridCrumbReactNativeSpecSwift(const CrumbReactNative::HybridCrumbReactNativeSpec_cxx& swiftPart):
|
|
38
|
+
HybridObject(HybridCrumbReactNativeSpec::TAG),
|
|
39
|
+
_swiftPart(swiftPart) { }
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
// Get the Swift part
|
|
43
|
+
inline CrumbReactNative::HybridCrumbReactNativeSpec_cxx& getSwiftPart() noexcept {
|
|
44
|
+
return _swiftPart;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
49
|
+
return _swiftPart.getMemorySize();
|
|
50
|
+
}
|
|
51
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override {
|
|
52
|
+
if (auto otherCast = std::dynamic_pointer_cast<HybridCrumbReactNativeSpecSwift>(other)) {
|
|
53
|
+
return _swiftPart.equals(otherCast->_swiftPart);
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
void dispose() noexcept override {
|
|
58
|
+
_swiftPart.dispose();
|
|
59
|
+
}
|
|
60
|
+
std::string toString() override {
|
|
61
|
+
return _swiftPart.toString();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public:
|
|
65
|
+
// Properties
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
public:
|
|
69
|
+
// Methods
|
|
70
|
+
inline void start(const std::string& configurationJson) override {
|
|
71
|
+
auto __result = _swiftPart.start(configurationJson);
|
|
72
|
+
if (__result.hasError()) [[unlikely]] {
|
|
73
|
+
std::rethrow_exception(__result.error());
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
inline std::shared_ptr<Promise<bool>> installReporter() override {
|
|
77
|
+
auto __result = _swiftPart.installReporter();
|
|
78
|
+
if (__result.hasError()) [[unlikely]] {
|
|
79
|
+
std::rethrow_exception(__result.error());
|
|
80
|
+
}
|
|
81
|
+
auto __value = std::move(__result.value());
|
|
82
|
+
return __value;
|
|
83
|
+
}
|
|
84
|
+
inline std::shared_ptr<Promise<bool>> show() override {
|
|
85
|
+
auto __result = _swiftPart.show();
|
|
86
|
+
if (__result.hasError()) [[unlikely]] {
|
|
87
|
+
std::rethrow_exception(__result.error());
|
|
88
|
+
}
|
|
89
|
+
auto __value = std::move(__result.value());
|
|
90
|
+
return __value;
|
|
91
|
+
}
|
|
92
|
+
inline void addLog(const std::string& entryJson) override {
|
|
93
|
+
auto __result = _swiftPart.addLog(entryJson);
|
|
94
|
+
if (__result.hasError()) [[unlikely]] {
|
|
95
|
+
std::rethrow_exception(__result.error());
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
inline void clearLogs() override {
|
|
99
|
+
auto __result = _swiftPart.clearLogs();
|
|
100
|
+
if (__result.hasError()) [[unlikely]] {
|
|
101
|
+
std::rethrow_exception(__result.error());
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private:
|
|
106
|
+
CrumbReactNative::HybridCrumbReactNativeSpec_cxx _swiftPart;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
} // namespace margelo::nitro::crumbsdk_reactnative
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_bool.swift
|
|
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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ value: Bool) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_bool {
|
|
15
|
+
public typealias bridge = margelo.nitro.crumbsdk_reactnative.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ value: Bool) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ value: Bool) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(value: Bool) -> Void {
|
|
25
|
+
self.closure(value)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_bool`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_bool>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_bool {
|
|
44
|
+
return Unmanaged<Func_void_bool>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__exception_ptr.swift
|
|
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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ error: Error) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__exception_ptr {
|
|
15
|
+
public typealias bridge = margelo.nitro.crumbsdk_reactnative.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ error: Error) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ error: Error) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(error: std.exception_ptr) -> Void {
|
|
25
|
+
self.closure(RuntimeError.from(cppError: error))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
|
|
44
|
+
return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCrumbReactNativeSpec.swift
|
|
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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/// See ``HybridCrumbReactNativeSpec``
|
|
11
|
+
public protocol HybridCrumbReactNativeSpec_protocol: HybridObject {
|
|
12
|
+
// Properties
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// Methods
|
|
16
|
+
func start(configurationJson: String) throws -> Void
|
|
17
|
+
func installReporter() throws -> Promise<Bool>
|
|
18
|
+
func show() throws -> Promise<Bool>
|
|
19
|
+
func addLog(entryJson: String) throws -> Void
|
|
20
|
+
func clearLogs() throws -> Void
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public extension HybridCrumbReactNativeSpec_protocol {
|
|
24
|
+
/// Default implementation of ``HybridObject.toString``
|
|
25
|
+
func toString() -> String {
|
|
26
|
+
return "[HybridObject CrumbReactNative]"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/// See ``HybridCrumbReactNativeSpec``
|
|
31
|
+
open class HybridCrumbReactNativeSpec_base {
|
|
32
|
+
private weak var cxxWrapper: HybridCrumbReactNativeSpec_cxx? = nil
|
|
33
|
+
public init() { }
|
|
34
|
+
public func getCxxWrapper() -> HybridCrumbReactNativeSpec_cxx {
|
|
35
|
+
#if DEBUG
|
|
36
|
+
guard self is any HybridCrumbReactNativeSpec else {
|
|
37
|
+
fatalError("`self` is not a `HybridCrumbReactNativeSpec`! Did you accidentally inherit from `HybridCrumbReactNativeSpec_base` instead of `HybridCrumbReactNativeSpec`?")
|
|
38
|
+
}
|
|
39
|
+
#endif
|
|
40
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
41
|
+
return cxxWrapper
|
|
42
|
+
} else {
|
|
43
|
+
let cxxWrapper = HybridCrumbReactNativeSpec_cxx(self as! any HybridCrumbReactNativeSpec)
|
|
44
|
+
self.cxxWrapper = cxxWrapper
|
|
45
|
+
return cxxWrapper
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A Swift base-protocol representing the CrumbReactNative HybridObject.
|
|
52
|
+
* Implement this protocol to create Swift-based instances of CrumbReactNative.
|
|
53
|
+
* ```swift
|
|
54
|
+
* class HybridCrumbReactNative : HybridCrumbReactNativeSpec {
|
|
55
|
+
* // ...
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
public typealias HybridCrumbReactNativeSpec = HybridCrumbReactNativeSpec_protocol & HybridCrumbReactNativeSpec_base
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCrumbReactNativeSpec_cxx.swift
|
|
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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A class implementation that bridges HybridCrumbReactNativeSpec over to C++.
|
|
12
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
13
|
+
*
|
|
14
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
15
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
16
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
17
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
18
|
+
*/
|
|
19
|
+
open class HybridCrumbReactNativeSpec_cxx {
|
|
20
|
+
/**
|
|
21
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::crumbsdk_reactnative::bridge::swift`)
|
|
22
|
+
* from `CrumbReactNative-Swift-Cxx-Bridge.hpp`.
|
|
23
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
24
|
+
*/
|
|
25
|
+
public typealias bridge = margelo.nitro.crumbsdk_reactnative.bridge.swift
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Holds an instance of the `HybridCrumbReactNativeSpec` Swift protocol.
|
|
29
|
+
*/
|
|
30
|
+
private var __implementation: any HybridCrumbReactNativeSpec
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
34
|
+
*/
|
|
35
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridCrumbReactNativeSpec_
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a new `HybridCrumbReactNativeSpec_cxx` that wraps the given `HybridCrumbReactNativeSpec`.
|
|
39
|
+
* All properties and methods bridge to C++ types.
|
|
40
|
+
*/
|
|
41
|
+
public init(_ implementation: any HybridCrumbReactNativeSpec) {
|
|
42
|
+
self.__implementation = implementation
|
|
43
|
+
self.__cxxPart = .init()
|
|
44
|
+
/* no base class */
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get the actual `HybridCrumbReactNativeSpec` instance this class wraps.
|
|
49
|
+
*/
|
|
50
|
+
@inline(__always)
|
|
51
|
+
public func getHybridCrumbReactNativeSpec() -> any HybridCrumbReactNativeSpec {
|
|
52
|
+
return __implementation
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
57
|
+
* This acquires one additional strong reference on the object!
|
|
58
|
+
*/
|
|
59
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
60
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Casts an unsafe pointer to a `HybridCrumbReactNativeSpec_cxx`.
|
|
65
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridCrumbReactNativeSpec_cxx>`.
|
|
66
|
+
* This removes one strong reference from the object!
|
|
67
|
+
*/
|
|
68
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridCrumbReactNativeSpec_cxx {
|
|
69
|
+
return Unmanaged<HybridCrumbReactNativeSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
74
|
+
* The C++ part is a `std::shared_ptr<HybridCrumbReactNativeSpec>`.
|
|
75
|
+
*/
|
|
76
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridCrumbReactNativeSpec_ {
|
|
77
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
78
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
79
|
+
return cachedCxxPart
|
|
80
|
+
} else {
|
|
81
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridCrumbReactNativeSpec_(self.toUnsafe())
|
|
82
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridCrumbReactNativeSpec_(newCxxPart)
|
|
83
|
+
return newCxxPart
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
91
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
92
|
+
*/
|
|
93
|
+
@inline(__always)
|
|
94
|
+
public var memorySize: Int {
|
|
95
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Compares this object with the given [other] object for reference equality.
|
|
100
|
+
*/
|
|
101
|
+
@inline(__always)
|
|
102
|
+
public func equals(other: HybridCrumbReactNativeSpec_cxx) -> Bool {
|
|
103
|
+
return self.__implementation === other.__implementation
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Call dispose() on the Swift class.
|
|
108
|
+
* This _may_ be called manually from JS.
|
|
109
|
+
*/
|
|
110
|
+
@inline(__always)
|
|
111
|
+
public func dispose() {
|
|
112
|
+
self.__implementation.dispose()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Call toString() on the Swift class.
|
|
117
|
+
*/
|
|
118
|
+
@inline(__always)
|
|
119
|
+
public func toString() -> String {
|
|
120
|
+
return self.__implementation.toString()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Properties
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
// Methods
|
|
127
|
+
@inline(__always)
|
|
128
|
+
public final func start(configurationJson: std.string) -> bridge.Result_void_ {
|
|
129
|
+
do {
|
|
130
|
+
try self.__implementation.start(configurationJson: String(configurationJson))
|
|
131
|
+
return bridge.create_Result_void_()
|
|
132
|
+
} catch (let __error) {
|
|
133
|
+
let __exceptionPtr = __error.toCpp()
|
|
134
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@inline(__always)
|
|
139
|
+
public final func installReporter() -> bridge.Result_std__shared_ptr_Promise_bool___ {
|
|
140
|
+
do {
|
|
141
|
+
let __result = try self.__implementation.installReporter()
|
|
142
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
|
|
143
|
+
let __promise = bridge.create_std__shared_ptr_Promise_bool__()
|
|
144
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
|
|
145
|
+
__result
|
|
146
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
147
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
148
|
+
return __promise
|
|
149
|
+
}()
|
|
150
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
|
|
151
|
+
} catch (let __error) {
|
|
152
|
+
let __exceptionPtr = __error.toCpp()
|
|
153
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@inline(__always)
|
|
158
|
+
public final func show() -> bridge.Result_std__shared_ptr_Promise_bool___ {
|
|
159
|
+
do {
|
|
160
|
+
let __result = try self.__implementation.show()
|
|
161
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
|
|
162
|
+
let __promise = bridge.create_std__shared_ptr_Promise_bool__()
|
|
163
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
|
|
164
|
+
__result
|
|
165
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
166
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
167
|
+
return __promise
|
|
168
|
+
}()
|
|
169
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
|
|
170
|
+
} catch (let __error) {
|
|
171
|
+
let __exceptionPtr = __error.toCpp()
|
|
172
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@inline(__always)
|
|
177
|
+
public final func addLog(entryJson: std.string) -> bridge.Result_void_ {
|
|
178
|
+
do {
|
|
179
|
+
try self.__implementation.addLog(entryJson: String(entryJson))
|
|
180
|
+
return bridge.create_Result_void_()
|
|
181
|
+
} catch (let __error) {
|
|
182
|
+
let __exceptionPtr = __error.toCpp()
|
|
183
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
@inline(__always)
|
|
188
|
+
public final func clearLogs() -> bridge.Result_void_ {
|
|
189
|
+
do {
|
|
190
|
+
try self.__implementation.clearLogs()
|
|
191
|
+
return bridge.create_Result_void_()
|
|
192
|
+
} catch (let __error) {
|
|
193
|
+
let __exceptionPtr = __error.toCpp()
|
|
194
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCrumbReactNativeSpec.cpp
|
|
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
|
+
#include "HybridCrumbReactNativeSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::crumbsdk_reactnative {
|
|
11
|
+
|
|
12
|
+
void HybridCrumbReactNativeSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("start", &HybridCrumbReactNativeSpec::start);
|
|
18
|
+
prototype.registerHybridMethod("installReporter", &HybridCrumbReactNativeSpec::installReporter);
|
|
19
|
+
prototype.registerHybridMethod("show", &HybridCrumbReactNativeSpec::show);
|
|
20
|
+
prototype.registerHybridMethod("addLog", &HybridCrumbReactNativeSpec::addLog);
|
|
21
|
+
prototype.registerHybridMethod("clearLogs", &HybridCrumbReactNativeSpec::clearLogs);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
} // namespace margelo::nitro::crumbsdk_reactnative
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCrumbReactNativeSpec.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/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
|
+
#include <string>
|
|
19
|
+
#include <NitroModules/Promise.hpp>
|
|
20
|
+
|
|
21
|
+
namespace margelo::nitro::crumbsdk_reactnative {
|
|
22
|
+
|
|
23
|
+
using namespace margelo::nitro;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* An abstract base class for `CrumbReactNative`
|
|
27
|
+
* Inherit this class to create instances of `HybridCrumbReactNativeSpec` in C++.
|
|
28
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
29
|
+
* @example
|
|
30
|
+
* ```cpp
|
|
31
|
+
* class HybridCrumbReactNative: public HybridCrumbReactNativeSpec {
|
|
32
|
+
* public:
|
|
33
|
+
* HybridCrumbReactNative(...): HybridObject(TAG) { ... }
|
|
34
|
+
* // ...
|
|
35
|
+
* };
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
class HybridCrumbReactNativeSpec: public virtual HybridObject {
|
|
39
|
+
public:
|
|
40
|
+
// Constructor
|
|
41
|
+
explicit HybridCrumbReactNativeSpec(): HybridObject(TAG) { }
|
|
42
|
+
|
|
43
|
+
// Destructor
|
|
44
|
+
~HybridCrumbReactNativeSpec() override = default;
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
// Properties
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
// Methods
|
|
52
|
+
virtual void start(const std::string& configurationJson) = 0;
|
|
53
|
+
virtual std::shared_ptr<Promise<bool>> installReporter() = 0;
|
|
54
|
+
virtual std::shared_ptr<Promise<bool>> show() = 0;
|
|
55
|
+
virtual void addLog(const std::string& entryJson) = 0;
|
|
56
|
+
virtual void clearLogs() = 0;
|
|
57
|
+
|
|
58
|
+
protected:
|
|
59
|
+
// Hybrid Setup
|
|
60
|
+
void loadHybridMethods() override;
|
|
61
|
+
|
|
62
|
+
protected:
|
|
63
|
+
// Tag for logging
|
|
64
|
+
static constexpr auto TAG = "CrumbReactNative";
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
} // namespace margelo::nitro::crumbsdk_reactnative
|
package/package.json
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@crumbsdk/react-native",
|
|
3
|
+
"version": "0.0.1-rc.3",
|
|
4
|
+
"description": "React Native adapter for the native Crumb issue-reporting SDK",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"crumbsdk-react-native-source": "./src/index.ts",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"nitrogen",
|
|
22
|
+
"nitro.json",
|
|
23
|
+
"CrumbReactNative.podspec",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE",
|
|
26
|
+
"!ios/build",
|
|
27
|
+
"!android/build",
|
|
28
|
+
"!android/.cxx",
|
|
29
|
+
"!**/__tests__"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"example": "yarn workspace @crumbsdk/react-native-example",
|
|
33
|
+
"clean": "del-cli lib",
|
|
34
|
+
"prepare": "bob build",
|
|
35
|
+
"nitrogen": "nitrogen",
|
|
36
|
+
"typecheck": "tsc",
|
|
37
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
38
|
+
"test": "jest --runInBand",
|
|
39
|
+
"quality": "yarn lint && yarn typecheck && yarn test && yarn prepare",
|
|
40
|
+
"pack:check": "yarn pack --dry-run"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"react-native",
|
|
44
|
+
"expo",
|
|
45
|
+
"ios",
|
|
46
|
+
"android",
|
|
47
|
+
"bug-reporting",
|
|
48
|
+
"issue-reporting"
|
|
49
|
+
],
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/alexander126/crumb.git",
|
|
53
|
+
"directory": "packages/react-native"
|
|
54
|
+
},
|
|
55
|
+
"author": "Crumb contributors <hellalex951@gmail.com> (https://github.com/alexander126)",
|
|
56
|
+
"license": "Apache-2.0",
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/alexander126/crumb/issues"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://crumbsdk.com",
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public",
|
|
63
|
+
"registry": "https://registry.npmjs.org/"
|
|
64
|
+
},
|
|
65
|
+
"crumbNativeVersion": "0.0.1-rc.3",
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@babel/core": "7.29.7",
|
|
68
|
+
"@eslint/compat": "2.1.0",
|
|
69
|
+
"@eslint/eslintrc": "3.3.5",
|
|
70
|
+
"@eslint/js": "9.39.4",
|
|
71
|
+
"@react-native/babel-preset": "0.83.10",
|
|
72
|
+
"@react-native/eslint-config": "0.83.10",
|
|
73
|
+
"@types/jest": "30.0.0",
|
|
74
|
+
"@types/react": "19.2.14",
|
|
75
|
+
"babel-jest": "30.2.0",
|
|
76
|
+
"del-cli": "7.0.0",
|
|
77
|
+
"eslint": "9.39.4",
|
|
78
|
+
"eslint-config-prettier": "10.1.8",
|
|
79
|
+
"eslint-plugin-prettier": "5.5.6",
|
|
80
|
+
"jest": "30.2.0",
|
|
81
|
+
"nitrogen": "0.37.1",
|
|
82
|
+
"prettier": "3.8.3",
|
|
83
|
+
"react": "19.2.0",
|
|
84
|
+
"react-native": "0.83.10",
|
|
85
|
+
"react-native-builder-bob": "0.43.0",
|
|
86
|
+
"react-native-nitro-modules": "0.37.1",
|
|
87
|
+
"typescript": "6.0.3"
|
|
88
|
+
},
|
|
89
|
+
"peerDependencies": {
|
|
90
|
+
"react": ">=18.0.0",
|
|
91
|
+
"react-native": ">=0.79.0",
|
|
92
|
+
"react-native-nitro-modules": ">=0.37.1 <0.38.0"
|
|
93
|
+
},
|
|
94
|
+
"workspaces": [
|
|
95
|
+
"example"
|
|
96
|
+
],
|
|
97
|
+
"packageManager": "yarn@4.11.0",
|
|
98
|
+
"react-native-builder-bob": {
|
|
99
|
+
"source": "src",
|
|
100
|
+
"output": "lib",
|
|
101
|
+
"targets": [
|
|
102
|
+
[
|
|
103
|
+
"custom",
|
|
104
|
+
{
|
|
105
|
+
"script": "nitrogen",
|
|
106
|
+
"clean": "nitrogen/"
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
"module",
|
|
111
|
+
{
|
|
112
|
+
"esm": true
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
"typescript",
|
|
117
|
+
{
|
|
118
|
+
"project": "tsconfig.build.json"
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
"prettier": {
|
|
124
|
+
"singleQuote": true,
|
|
125
|
+
"tabWidth": 2,
|
|
126
|
+
"trailingComma": "es5",
|
|
127
|
+
"useTabs": false
|
|
128
|
+
},
|
|
129
|
+
"create-react-native-library": {
|
|
130
|
+
"type": "nitro-module",
|
|
131
|
+
"languages": "kotlin-swift",
|
|
132
|
+
"tools": [
|
|
133
|
+
"eslint",
|
|
134
|
+
"jest"
|
|
135
|
+
],
|
|
136
|
+
"version": "0.63.0"
|
|
137
|
+
}
|
|
138
|
+
}
|