react-native-candle 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +188 -0
- package/ReactNativeCandle.podspec +45 -0
- package/app.plugin.js +1 -0
- package/ios/Sources/CandleLinkSheetWrapperView.swift +53 -0
- package/ios/Sources/CandleLinkViewModel.swift +67 -0
- package/ios/Sources/HostingViewController.swift +56 -0
- package/ios/Sources/RNCandle.swift +155 -0
- package/ios/Sources/UIApplication++.swift +14 -0
- package/lib/commonjs/index.js +49 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/specs/RNCandle.nitro.js +6 -0
- package/lib/commonjs/specs/RNCandle.nitro.js.map +1 -0
- package/lib/module/index.js +38 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/specs/RNCandle.nitro.js +4 -0
- package/lib/module/specs/RNCandle.nitro.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +22 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts +21 -0
- package/lib/typescript/commonjs/src/specs/RNCandle.nitro.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/index.d.ts +22 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts +21 -0
- package/lib/typescript/module/src/specs/RNCandle.nitro.d.ts.map +1 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/ios/ReactNativeCandle+autolinking.rb +60 -0
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.cpp +56 -0
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Bridge.hpp +173 -0
- package/nitrogen/generated/ios/ReactNativeCandle-Swift-Cxx-Umbrella.hpp +58 -0
- package/nitrogen/generated/ios/ReactNativeCandleAutolinking.mm +33 -0
- package/nitrogen/generated/ios/ReactNativeCandleAutolinking.swift +30 -0
- package/nitrogen/generated/ios/c++/HybridRNCandleSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridRNCandleSpecSwift.hpp +139 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridRNCandleSpec.swift +55 -0
- package/nitrogen/generated/ios/swift/HybridRNCandleSpec_cxx.swift +263 -0
- package/nitrogen/generated/ios/swift/PresentationBackground.swift +40 -0
- package/nitrogen/generated/ios/swift/PresentationStyle.swift +40 -0
- package/nitrogen/generated/ios/swift/Service.swift +56 -0
- package/nitrogen/generated/ios/swift/ToolCall.swift +46 -0
- package/nitrogen/generated/shared/c++/HybridRNCandleSpec.cpp +28 -0
- package/nitrogen/generated/shared/c++/HybridRNCandleSpec.hpp +83 -0
- package/nitrogen/generated/shared/c++/PresentationBackground.hpp +78 -0
- package/nitrogen/generated/shared/c++/PresentationStyle.hpp +78 -0
- package/nitrogen/generated/shared/c++/Service.hpp +94 -0
- package/nitrogen/generated/shared/c++/ToolCall.hpp +73 -0
- package/package.json +111 -0
- package/plugin/withIosDeploymentTarget.js +46 -0
- package/src/index.ts +73 -0
- package/src/specs/RNCandle.nitro.ts +39 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Service.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
|
+
/**
|
|
9
|
+
* Represents the JS union `Service`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias Service = margelo.nitro.rncandle.Service
|
|
12
|
+
|
|
13
|
+
public extension Service {
|
|
14
|
+
/**
|
|
15
|
+
* Get a Service for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "robinhood":
|
|
21
|
+
self = .robinhood
|
|
22
|
+
case "cash_app":
|
|
23
|
+
self = .cashApp
|
|
24
|
+
case "venmo":
|
|
25
|
+
self = .venmo
|
|
26
|
+
case "apple":
|
|
27
|
+
self = .apple
|
|
28
|
+
case "demo":
|
|
29
|
+
self = .demo
|
|
30
|
+
case "default":
|
|
31
|
+
self = .default
|
|
32
|
+
default:
|
|
33
|
+
return nil
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Get the String value this Service represents.
|
|
39
|
+
*/
|
|
40
|
+
var stringValue: String {
|
|
41
|
+
switch self {
|
|
42
|
+
case .robinhood:
|
|
43
|
+
return "robinhood"
|
|
44
|
+
case .cashApp:
|
|
45
|
+
return "cash_app"
|
|
46
|
+
case .venmo:
|
|
47
|
+
return "venmo"
|
|
48
|
+
case .apple:
|
|
49
|
+
return "apple"
|
|
50
|
+
case .demo:
|
|
51
|
+
return "demo"
|
|
52
|
+
case .default:
|
|
53
|
+
return "default"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ToolCall.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 NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `ToolCall`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias ToolCall = margelo.nitro.rncandle.ToolCall
|
|
14
|
+
|
|
15
|
+
public extension ToolCall {
|
|
16
|
+
private typealias bridge = margelo.nitro.rncandle.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `ToolCall`.
|
|
20
|
+
*/
|
|
21
|
+
init(name: String, arguments: String) {
|
|
22
|
+
self.init(std.string(name), std.string(arguments))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var name: String {
|
|
26
|
+
@inline(__always)
|
|
27
|
+
get {
|
|
28
|
+
return String(self.__name)
|
|
29
|
+
}
|
|
30
|
+
@inline(__always)
|
|
31
|
+
set {
|
|
32
|
+
self.__name = std.string(newValue)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var arguments: String {
|
|
37
|
+
@inline(__always)
|
|
38
|
+
get {
|
|
39
|
+
return String(self.__arguments)
|
|
40
|
+
}
|
|
41
|
+
@inline(__always)
|
|
42
|
+
set {
|
|
43
|
+
self.__arguments = std.string(newValue)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridRNCandleSpec.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 "HybridRNCandleSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::rncandle {
|
|
11
|
+
|
|
12
|
+
void HybridRNCandleSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("candleLinkSheet", &HybridRNCandleSpec::candleLinkSheet);
|
|
18
|
+
prototype.registerHybridMethod("getLinkedAccounts", &HybridRNCandleSpec::getLinkedAccounts);
|
|
19
|
+
prototype.registerHybridMethod("unlinkAccount", &HybridRNCandleSpec::unlinkAccount);
|
|
20
|
+
prototype.registerHybridMethod("getFiatAccounts", &HybridRNCandleSpec::getFiatAccounts);
|
|
21
|
+
prototype.registerHybridMethod("getActivity", &HybridRNCandleSpec::getActivity);
|
|
22
|
+
prototype.registerHybridMethod("deleteUser", &HybridRNCandleSpec::deleteUser);
|
|
23
|
+
prototype.registerHybridMethod("getAvailableTools", &HybridRNCandleSpec::getAvailableTools);
|
|
24
|
+
prototype.registerHybridMethod("executeTool", &HybridRNCandleSpec::executeTool);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
} // namespace margelo::nitro::rncandle
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridRNCandleSpec.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
|
+
// Forward declaration of `Service` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::rncandle { enum class Service; }
|
|
18
|
+
// Forward declaration of `PresentationBackground` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::rncandle { enum class PresentationBackground; }
|
|
20
|
+
// Forward declaration of `PresentationStyle` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::rncandle { enum class PresentationStyle; }
|
|
22
|
+
// Forward declaration of `ToolCall` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::rncandle { struct ToolCall; }
|
|
24
|
+
|
|
25
|
+
#include "Service.hpp"
|
|
26
|
+
#include <optional>
|
|
27
|
+
#include <string>
|
|
28
|
+
#include "PresentationBackground.hpp"
|
|
29
|
+
#include "PresentationStyle.hpp"
|
|
30
|
+
#include <functional>
|
|
31
|
+
#include <NitroModules/Promise.hpp>
|
|
32
|
+
#include "ToolCall.hpp"
|
|
33
|
+
|
|
34
|
+
namespace margelo::nitro::rncandle {
|
|
35
|
+
|
|
36
|
+
using namespace margelo::nitro;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* An abstract base class for `RNCandle`
|
|
40
|
+
* Inherit this class to create instances of `HybridRNCandleSpec` in C++.
|
|
41
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
42
|
+
* @example
|
|
43
|
+
* ```cpp
|
|
44
|
+
* class HybridRNCandle: public HybridRNCandleSpec {
|
|
45
|
+
* public:
|
|
46
|
+
* HybridRNCandle(...): HybridObject(TAG) { ... }
|
|
47
|
+
* // ...
|
|
48
|
+
* };
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
class HybridRNCandleSpec: public virtual HybridObject {
|
|
52
|
+
public:
|
|
53
|
+
// Constructor
|
|
54
|
+
explicit HybridRNCandleSpec(): HybridObject(TAG) { }
|
|
55
|
+
|
|
56
|
+
// Destructor
|
|
57
|
+
~HybridRNCandleSpec() override = default;
|
|
58
|
+
|
|
59
|
+
public:
|
|
60
|
+
// Properties
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
public:
|
|
64
|
+
// Methods
|
|
65
|
+
virtual void candleLinkSheet(bool isPresented, Service service, double cornerRadius, const std::optional<std::string>& customerName, bool showSandbox, bool showDynamicLoading, PresentationBackground presentationBackground, PresentationStyle presentationStyle, const std::function<void(const std::string& /* account */)>& onSuccess) = 0;
|
|
66
|
+
virtual std::shared_ptr<Promise<std::string>> getLinkedAccounts() = 0;
|
|
67
|
+
virtual std::shared_ptr<Promise<void>> unlinkAccount(const std::string& linkedAccountID) = 0;
|
|
68
|
+
virtual std::shared_ptr<Promise<std::string>> getFiatAccounts() = 0;
|
|
69
|
+
virtual std::shared_ptr<Promise<std::string>> getActivity(const std::optional<std::string>& span) = 0;
|
|
70
|
+
virtual std::shared_ptr<Promise<void>> deleteUser() = 0;
|
|
71
|
+
virtual std::shared_ptr<Promise<std::string>> getAvailableTools() = 0;
|
|
72
|
+
virtual std::shared_ptr<Promise<std::string>> executeTool(const ToolCall& tool) = 0;
|
|
73
|
+
|
|
74
|
+
protected:
|
|
75
|
+
// Hybrid Setup
|
|
76
|
+
void loadHybridMethods() override;
|
|
77
|
+
|
|
78
|
+
protected:
|
|
79
|
+
// Tag for logging
|
|
80
|
+
static constexpr auto TAG = "RNCandle";
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
} // namespace margelo::nitro::rncandle
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PresentationBackground.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/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::rncandle {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (PresentationBackground).
|
|
30
|
+
*/
|
|
31
|
+
enum class PresentationBackground {
|
|
32
|
+
DEFAULT SWIFT_NAME(default) = 0,
|
|
33
|
+
BLUR SWIFT_NAME(blur) = 1,
|
|
34
|
+
} CLOSED_ENUM;
|
|
35
|
+
|
|
36
|
+
} // namespace margelo::nitro::rncandle
|
|
37
|
+
|
|
38
|
+
namespace margelo::nitro {
|
|
39
|
+
|
|
40
|
+
using namespace margelo::nitro::rncandle;
|
|
41
|
+
|
|
42
|
+
// C++ PresentationBackground <> JS PresentationBackground (union)
|
|
43
|
+
template <>
|
|
44
|
+
struct JSIConverter<PresentationBackground> final {
|
|
45
|
+
static inline PresentationBackground fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
46
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
47
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
48
|
+
case hashString("default"): return PresentationBackground::DEFAULT;
|
|
49
|
+
case hashString("blur"): return PresentationBackground::BLUR;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum PresentationBackground - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, PresentationBackground arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case PresentationBackground::DEFAULT: return JSIConverter<std::string>::toJSI(runtime, "default");
|
|
57
|
+
case PresentationBackground::BLUR: return JSIConverter<std::string>::toJSI(runtime, "blur");
|
|
58
|
+
default: [[unlikely]]
|
|
59
|
+
throw std::invalid_argument("Cannot convert PresentationBackground to JS - invalid value: "
|
|
60
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
64
|
+
if (!value.isString()) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
68
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
69
|
+
case hashString("default"):
|
|
70
|
+
case hashString("blur"):
|
|
71
|
+
return true;
|
|
72
|
+
default:
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PresentationStyle.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/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::rncandle {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (PresentationStyle).
|
|
30
|
+
*/
|
|
31
|
+
enum class PresentationStyle {
|
|
32
|
+
SHEET SWIFT_NAME(sheet) = 0,
|
|
33
|
+
FULLSCREEN SWIFT_NAME(fullscreen) = 1,
|
|
34
|
+
} CLOSED_ENUM;
|
|
35
|
+
|
|
36
|
+
} // namespace margelo::nitro::rncandle
|
|
37
|
+
|
|
38
|
+
namespace margelo::nitro {
|
|
39
|
+
|
|
40
|
+
using namespace margelo::nitro::rncandle;
|
|
41
|
+
|
|
42
|
+
// C++ PresentationStyle <> JS PresentationStyle (union)
|
|
43
|
+
template <>
|
|
44
|
+
struct JSIConverter<PresentationStyle> final {
|
|
45
|
+
static inline PresentationStyle fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
46
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
47
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
48
|
+
case hashString("sheet"): return PresentationStyle::SHEET;
|
|
49
|
+
case hashString("fullScreen"): return PresentationStyle::FULLSCREEN;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum PresentationStyle - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, PresentationStyle arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case PresentationStyle::SHEET: return JSIConverter<std::string>::toJSI(runtime, "sheet");
|
|
57
|
+
case PresentationStyle::FULLSCREEN: return JSIConverter<std::string>::toJSI(runtime, "fullScreen");
|
|
58
|
+
default: [[unlikely]]
|
|
59
|
+
throw std::invalid_argument("Cannot convert PresentationStyle to JS - invalid value: "
|
|
60
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
64
|
+
if (!value.isString()) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
68
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
69
|
+
case hashString("sheet"):
|
|
70
|
+
case hashString("fullScreen"):
|
|
71
|
+
return true;
|
|
72
|
+
default:
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Service.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/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::rncandle {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (Service).
|
|
30
|
+
*/
|
|
31
|
+
enum class Service {
|
|
32
|
+
ROBINHOOD SWIFT_NAME(robinhood) = 0,
|
|
33
|
+
CASH_APP SWIFT_NAME(cashApp) = 1,
|
|
34
|
+
VENMO SWIFT_NAME(venmo) = 2,
|
|
35
|
+
APPLE SWIFT_NAME(apple) = 3,
|
|
36
|
+
DEMO SWIFT_NAME(demo) = 4,
|
|
37
|
+
DEFAULT SWIFT_NAME(default) = 5,
|
|
38
|
+
} CLOSED_ENUM;
|
|
39
|
+
|
|
40
|
+
} // namespace margelo::nitro::rncandle
|
|
41
|
+
|
|
42
|
+
namespace margelo::nitro {
|
|
43
|
+
|
|
44
|
+
using namespace margelo::nitro::rncandle;
|
|
45
|
+
|
|
46
|
+
// C++ Service <> JS Service (union)
|
|
47
|
+
template <>
|
|
48
|
+
struct JSIConverter<Service> final {
|
|
49
|
+
static inline Service fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
50
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
51
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
52
|
+
case hashString("robinhood"): return Service::ROBINHOOD;
|
|
53
|
+
case hashString("cash_app"): return Service::CASH_APP;
|
|
54
|
+
case hashString("venmo"): return Service::VENMO;
|
|
55
|
+
case hashString("apple"): return Service::APPLE;
|
|
56
|
+
case hashString("demo"): return Service::DEMO;
|
|
57
|
+
case hashString("default"): return Service::DEFAULT;
|
|
58
|
+
default: [[unlikely]]
|
|
59
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum Service - invalid value!");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, Service arg) {
|
|
63
|
+
switch (arg) {
|
|
64
|
+
case Service::ROBINHOOD: return JSIConverter<std::string>::toJSI(runtime, "robinhood");
|
|
65
|
+
case Service::CASH_APP: return JSIConverter<std::string>::toJSI(runtime, "cash_app");
|
|
66
|
+
case Service::VENMO: return JSIConverter<std::string>::toJSI(runtime, "venmo");
|
|
67
|
+
case Service::APPLE: return JSIConverter<std::string>::toJSI(runtime, "apple");
|
|
68
|
+
case Service::DEMO: return JSIConverter<std::string>::toJSI(runtime, "demo");
|
|
69
|
+
case Service::DEFAULT: return JSIConverter<std::string>::toJSI(runtime, "default");
|
|
70
|
+
default: [[unlikely]]
|
|
71
|
+
throw std::invalid_argument("Cannot convert Service to JS - invalid value: "
|
|
72
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
76
|
+
if (!value.isString()) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
80
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
81
|
+
case hashString("robinhood"):
|
|
82
|
+
case hashString("cash_app"):
|
|
83
|
+
case hashString("venmo"):
|
|
84
|
+
case hashString("apple"):
|
|
85
|
+
case hashString("demo"):
|
|
86
|
+
case hashString("default"):
|
|
87
|
+
return true;
|
|
88
|
+
default:
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ToolCall.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/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
#include <string>
|
|
24
|
+
|
|
25
|
+
namespace margelo::nitro::rncandle {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A struct which can be represented as a JavaScript object (ToolCall).
|
|
29
|
+
*/
|
|
30
|
+
struct ToolCall {
|
|
31
|
+
public:
|
|
32
|
+
std::string name SWIFT_PRIVATE;
|
|
33
|
+
std::string arguments SWIFT_PRIVATE;
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
ToolCall() = default;
|
|
37
|
+
explicit ToolCall(std::string name, std::string arguments): name(name), arguments(arguments) {}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
} // namespace margelo::nitro::rncandle
|
|
41
|
+
|
|
42
|
+
namespace margelo::nitro {
|
|
43
|
+
|
|
44
|
+
using namespace margelo::nitro::rncandle;
|
|
45
|
+
|
|
46
|
+
// C++ ToolCall <> JS ToolCall (object)
|
|
47
|
+
template <>
|
|
48
|
+
struct JSIConverter<ToolCall> final {
|
|
49
|
+
static inline ToolCall fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
50
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
51
|
+
return ToolCall(
|
|
52
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "name")),
|
|
53
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "arguments"))
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const ToolCall& arg) {
|
|
57
|
+
jsi::Object obj(runtime);
|
|
58
|
+
obj.setProperty(runtime, "name", JSIConverter<std::string>::toJSI(runtime, arg.name));
|
|
59
|
+
obj.setProperty(runtime, "arguments", JSIConverter<std::string>::toJSI(runtime, arg.arguments));
|
|
60
|
+
return obj;
|
|
61
|
+
}
|
|
62
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
63
|
+
if (!value.isObject()) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
jsi::Object obj = value.getObject(runtime);
|
|
67
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "name"))) return false;
|
|
68
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "arguments"))) return false;
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
} // namespace margelo::nitro
|
package/package.json
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-candle",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Candle SDK for React Native",
|
|
5
|
+
"main": "./lib/commonjs/index.js",
|
|
6
|
+
"module": "./lib/module/index.js",
|
|
7
|
+
"types": "./lib/typescript/commonjs/src/index.d.ts",
|
|
8
|
+
"react-native": "src/index",
|
|
9
|
+
"source": "src/index",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "rm -rf lib && bun typecheck && bob build",
|
|
12
|
+
"typecheck": "tsc --noEmit",
|
|
13
|
+
"clean": "rm -rf android/build node_modules/**/android/build lib android/.cxx node_modules/**/android/.cxx",
|
|
14
|
+
"release": "release-it",
|
|
15
|
+
"specs": "bun typecheck && nitro-codegen --logLevel=\\\"debug\\\" && bun run build",
|
|
16
|
+
"specs:pod": "bun specs && bun --cwd ../example pod"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"react-native",
|
|
20
|
+
"nitro",
|
|
21
|
+
"nitro-modile",
|
|
22
|
+
"expo",
|
|
23
|
+
"apple",
|
|
24
|
+
"ai"
|
|
25
|
+
],
|
|
26
|
+
"files": [
|
|
27
|
+
"src",
|
|
28
|
+
"react-native.config.js",
|
|
29
|
+
"lib",
|
|
30
|
+
"nitrogen",
|
|
31
|
+
"plugin",
|
|
32
|
+
"cpp",
|
|
33
|
+
"android/build.gradle",
|
|
34
|
+
"android/gradle.properties",
|
|
35
|
+
"android/CMakeLists.txt",
|
|
36
|
+
"android/src",
|
|
37
|
+
"ios/**/*.h",
|
|
38
|
+
"ios/**/*.m",
|
|
39
|
+
"ios/**/*.mm",
|
|
40
|
+
"ios/**/*.cpp",
|
|
41
|
+
"ios/**/*.swift",
|
|
42
|
+
"app.plugin.js",
|
|
43
|
+
"*.podspec",
|
|
44
|
+
"README.md"
|
|
45
|
+
],
|
|
46
|
+
"repository": "https://github.com/candlefinance/candle-react-native.git",
|
|
47
|
+
"author": "Gary Tokman",
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"bugs": "https://github.com/candlefinance/candle-react-native/issues",
|
|
50
|
+
"homepage": "https://github.com/candlefinance/candle-react-native",
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"registry": "https://registry.npmjs.org/"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@expo/config-plugins": "^9.0.10",
|
|
56
|
+
"react": "^18.3.1",
|
|
57
|
+
"react-native": "^0.78.1",
|
|
58
|
+
"nitro-codegen": "^0.25.2",
|
|
59
|
+
"react-native-nitro-modules": "^0.25.2",
|
|
60
|
+
"react-native-builder-bob": "^0.35.2",
|
|
61
|
+
"release-it": "^18.1.2",
|
|
62
|
+
"@release-it/bumper": "^7.0.1",
|
|
63
|
+
"@release-it/conventional-changelog": "^10.0.0"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"react": "*",
|
|
67
|
+
"react-native": "*",
|
|
68
|
+
"react-native-nitro-modules": "*"
|
|
69
|
+
},
|
|
70
|
+
"release-it": {
|
|
71
|
+
"npm": {
|
|
72
|
+
"publish": true
|
|
73
|
+
},
|
|
74
|
+
"git": false,
|
|
75
|
+
"github": {
|
|
76
|
+
"release": false
|
|
77
|
+
},
|
|
78
|
+
"hooks": {
|
|
79
|
+
"before:init": "bun typecheck",
|
|
80
|
+
"after:bump": "bun build"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"react-native-builder-bob": {
|
|
84
|
+
"source": "src",
|
|
85
|
+
"output": "lib",
|
|
86
|
+
"targets": [
|
|
87
|
+
[
|
|
88
|
+
"commonjs",
|
|
89
|
+
{
|
|
90
|
+
"esm": true
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
[
|
|
94
|
+
"module",
|
|
95
|
+
{
|
|
96
|
+
"esm": true
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
"typescript",
|
|
101
|
+
{
|
|
102
|
+
"esm": true
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"eslintIgnore": [
|
|
108
|
+
"node_modules/",
|
|
109
|
+
"lib/"
|
|
110
|
+
]
|
|
111
|
+
}
|